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 --- .gitattributes | 19 + .gitignore | 26 +- INSTALL | 71 - LICENSE | 2 +- NEWS | 1220 ---- README | 27 - build/bootstrap.make | 101 - build/configuration-rules.make | 16 - build/configuration.make | 30 - build/configure | 69 - build/import/cli/cli-cxx.make | 47 - build/import/cli/configuration-rules.make | 13 - build/import/cli/configure | 53 - build/import/cli/stub.make | 28 - build/import/libace/configuration-rules.make | 13 - build/import/libace/configure | 56 - build/import/libace/rules.make | 27 - build/import/libace/stub.make | 30 - build/import/libace/version | 1 - build/import/libboost/configuration-rules.make | 13 - build/import/libboost/configure | 72 - build/import/libboost/date-time/rules.make | 49 - build/import/libboost/date-time/stub.make | 34 - build/import/libboost/serialization/rules.make | 48 - build/import/libboost/serialization/stub.make | 34 - build/import/libboost/version | 1 - build/import/libcutl/configuration-rules.make | 13 - build/import/libcutl/configure | 53 - build/import/libcutl/stub.make | 28 - build/import/libxerces-c/configuration-rules.make | 13 - build/import/libxerces-c/configure | 71 - build/import/libxerces-c/rules.make | 50 - build/import/libxerces-c/stub.make | 30 - build/import/libxerces-c/version | 1 - build/import/libxqilla/configuration-rules.make | 13 - build/import/libxqilla/configure | 55 - build/import/libxqilla/rules.make | 28 - build/import/libxqilla/stub.make | 30 - build/import/libxqilla/version | 1 - .../libxsd-frontend/configuration-rules.make | 13 - build/import/libxsd-frontend/configure | 53 - build/import/libxsd-frontend/stub.make | 28 - build/import/libz/configuration-rules.make | 13 - build/import/libz/configure | 56 - build/import/libz/rules.make | 27 - build/import/libz/stub.make | 30 - build/import/libz/version | 1 - build/xsd/parser/xsd-cxx.make | 75 - build/xsd/tree/xsd-cxx.make | 46 - buildfile | 7 + dist/README-UNIX | 82 - dist/README-WINDOWS | 192 - dist/etc/vc-1x.0/xsd-cxx-parser.props | 33 - dist/etc/vc-1x.0/xsd-cxx-parser.targets | 92 - dist/etc/vc-1x.0/xsd-cxx-parser.xml | 284 - dist/etc/vc-1x.0/xsd-cxx-tree.props | 47 - dist/etc/vc-1x.0/xsd-cxx-tree.targets | 107 - dist/etc/vc-1x.0/xsd-cxx-tree.xml | 411 -- dist/etc/vc-8.0/xsd-cxx-parser.rules | 206 - dist/etc/vc-8.0/xsd-cxx-tree.rules | 320 - dist/etc/vc-9.0/xsd-cxx-parser.rules | 206 - dist/etc/vc-9.0/xsd-cxx-tree.rules | 319 - dist/examples/build/cxx/compilers.make | 117 - dist/examples/build/cxx/rules.make | 57 - dist/examples/build/xsd/common.make | 9 - dist/examples/build/xsd/parser-rules.make | 21 - dist/examples/build/xsd/tree-rules.make | 13 - dist/examples/cxx/makefile | 11 - .../cxx/parser/generated/generated-vc10.vcxproj | 203 - .../generated/generated-vc10.vcxproj.filters | 44 - .../cxx/parser/generated/generated-vc11.vcxproj | 207 - .../generated/generated-vc11.vcxproj.filters | 44 - .../cxx/parser/generated/generated-vc12.vcxproj | 211 - .../generated/generated-vc12.vcxproj.filters | 44 - .../cxx/parser/generated/generated-vc8.vcproj | 427 -- .../cxx/parser/generated/generated-vc9.vcproj | 424 -- dist/examples/cxx/parser/generated/makefile | 49 - dist/examples/cxx/parser/hello/hello-vc10.vcxproj | 201 - .../cxx/parser/hello/hello-vc10.vcxproj.filters | 38 - dist/examples/cxx/parser/hello/hello-vc11.vcxproj | 205 - .../cxx/parser/hello/hello-vc11.vcxproj.filters | 38 - dist/examples/cxx/parser/hello/hello-vc12.vcxproj | 209 - .../cxx/parser/hello/hello-vc12.vcxproj.filters | 38 - dist/examples/cxx/parser/hello/hello-vc8.vcproj | 419 -- dist/examples/cxx/parser/hello/hello-vc9.vcproj | 416 -- dist/examples/cxx/parser/hello/makefile | 28 - .../cxx/parser/library/library-vc10.vcxproj | 205 - .../parser/library/library-vc10.vcxproj.filters | 54 - .../cxx/parser/library/library-vc11.vcxproj | 209 - .../parser/library/library-vc11.vcxproj.filters | 54 - .../cxx/parser/library/library-vc12.vcxproj | 213 - .../parser/library/library-vc12.vcxproj.filters | 54 - .../examples/cxx/parser/library/library-vc8.vcproj | 440 -- .../examples/cxx/parser/library/library-vc9.vcproj | 437 -- dist/examples/cxx/parser/library/makefile | 30 - dist/examples/cxx/parser/makefile | 12 - dist/examples/cxx/parser/mixed/makefile | 30 - dist/examples/cxx/parser/mixed/mixed-vc10.vcxproj | 202 - .../cxx/parser/mixed/mixed-vc10.vcxproj.filters | 41 - dist/examples/cxx/parser/mixed/mixed-vc11.vcxproj | 206 - .../cxx/parser/mixed/mixed-vc11.vcxproj.filters | 41 - dist/examples/cxx/parser/mixed/mixed-vc12.vcxproj | 210 - .../cxx/parser/mixed/mixed-vc12.vcxproj.filters | 41 - dist/examples/cxx/parser/mixed/mixed-vc8.vcproj | 423 -- dist/examples/cxx/parser/mixed/mixed-vc9.vcproj | 420 -- dist/examples/cxx/parser/mixin/makefile | 30 - dist/examples/cxx/parser/mixin/mixin-vc10.vcxproj | 202 - .../cxx/parser/mixin/mixin-vc10.vcxproj.filters | 41 - dist/examples/cxx/parser/mixin/mixin-vc11.vcxproj | 206 - .../cxx/parser/mixin/mixin-vc11.vcxproj.filters | 41 - dist/examples/cxx/parser/mixin/mixin-vc12.vcxproj | 210 - .../cxx/parser/mixin/mixin-vc12.vcxproj.filters | 41 - dist/examples/cxx/parser/mixin/mixin-vc8.vcproj | 423 -- dist/examples/cxx/parser/mixin/mixin-vc9.vcproj | 420 -- dist/examples/cxx/parser/multiroot/makefile | 32 - .../cxx/parser/multiroot/multiroot-vc10.vcxproj | 208 - .../multiroot/multiroot-vc10.vcxproj.filters | 47 - .../cxx/parser/multiroot/multiroot-vc11.vcxproj | 212 - .../multiroot/multiroot-vc11.vcxproj.filters | 47 - .../cxx/parser/multiroot/multiroot-vc12.vcxproj | 216 - .../multiroot/multiroot-vc12.vcxproj.filters | 47 - .../cxx/parser/multiroot/multiroot-vc8.vcproj | 435 -- .../cxx/parser/multiroot/multiroot-vc9.vcproj | 432 -- dist/examples/cxx/parser/performance/makefile | 30 - .../parser/performance/performance-vc10.vcxproj | 203 - .../performance/performance-vc10.vcxproj.filters | 44 - .../parser/performance/performance-vc11.vcxproj | 207 - .../performance/performance-vc11.vcxproj.filters | 44 - .../parser/performance/performance-vc12.vcxproj | 211 - .../performance/performance-vc12.vcxproj.filters | 44 - .../cxx/parser/performance/performance-vc8.vcproj | 427 -- .../cxx/parser/performance/performance-vc9.vcproj | 424 -- dist/examples/cxx/parser/polymorphism/makefile | 30 - .../parser/polymorphism/polymorphism-vc10.vcxproj | 207 - .../polymorphism/polymorphism-vc10.vcxproj.filters | 44 - .../parser/polymorphism/polymorphism-vc11.vcxproj | 211 - .../polymorphism/polymorphism-vc11.vcxproj.filters | 44 - .../parser/polymorphism/polymorphism-vc12.vcxproj | 215 - .../polymorphism/polymorphism-vc12.vcxproj.filters | 44 - .../parser/polymorphism/polymorphism-vc8.vcproj | 431 -- .../parser/polymorphism/polymorphism-vc9.vcproj | 428 -- dist/examples/cxx/parser/polyroot/makefile | 31 - .../cxx/parser/polyroot/polyroot-vc10.vcxproj | 207 - .../parser/polyroot/polyroot-vc10.vcxproj.filters | 44 - .../cxx/parser/polyroot/polyroot-vc11.vcxproj | 211 - .../parser/polyroot/polyroot-vc11.vcxproj.filters | 44 - .../cxx/parser/polyroot/polyroot-vc12.vcxproj | 215 - .../parser/polyroot/polyroot-vc12.vcxproj.filters | 44 - .../cxx/parser/polyroot/polyroot-vc8.vcproj | 431 -- .../cxx/parser/polyroot/polyroot-vc9.vcproj | 428 -- dist/examples/cxx/parser/wildcard/makefile | 28 - .../cxx/parser/wildcard/wildcard-vc10.vcxproj | 201 - .../parser/wildcard/wildcard-vc10.vcxproj.filters | 38 - .../cxx/parser/wildcard/wildcard-vc11.vcxproj | 205 - .../parser/wildcard/wildcard-vc11.vcxproj.filters | 38 - .../cxx/parser/wildcard/wildcard-vc12.vcxproj | 209 - .../parser/wildcard/wildcard-vc12.vcxproj.filters | 38 - .../cxx/parser/wildcard/wildcard-vc8.vcproj | 419 -- .../cxx/parser/wildcard/wildcard-vc9.vcproj | 416 -- .../cxx/tree/binary/boost/boost-vc10.vcxproj | 208 - .../tree/binary/boost/boost-vc10.vcxproj.filters | 47 - .../cxx/tree/binary/boost/boost-vc11.vcxproj | 212 - .../tree/binary/boost/boost-vc11.vcxproj.filters | 47 - .../cxx/tree/binary/boost/boost-vc12.vcxproj | 216 - .../tree/binary/boost/boost-vc12.vcxproj.filters | 47 - .../cxx/tree/binary/boost/boost-vc8.vcproj | 435 -- .../cxx/tree/binary/boost/boost-vc9.vcproj | 432 -- dist/examples/cxx/tree/binary/boost/makefile | 37 - dist/examples/cxx/tree/binary/cdr/cdr-vc10.vcxproj | 205 - .../cxx/tree/binary/cdr/cdr-vc10.vcxproj.filters | 38 - dist/examples/cxx/tree/binary/cdr/cdr-vc11.vcxproj | 209 - .../cxx/tree/binary/cdr/cdr-vc11.vcxproj.filters | 38 - dist/examples/cxx/tree/binary/cdr/cdr-vc12.vcxproj | 213 - .../cxx/tree/binary/cdr/cdr-vc12.vcxproj.filters | 38 - dist/examples/cxx/tree/binary/cdr/cdr-vc8.vcproj | 423 -- dist/examples/cxx/tree/binary/cdr/cdr-vc9.vcproj | 420 -- dist/examples/cxx/tree/binary/cdr/makefile | 35 - dist/examples/cxx/tree/binary/makefile | 25 - dist/examples/cxx/tree/binary/xdr/makefile | 35 - dist/examples/cxx/tree/binary/xdr/xdr-vc10.vcxproj | 205 - .../cxx/tree/binary/xdr/xdr-vc10.vcxproj.filters | 38 - dist/examples/cxx/tree/binary/xdr/xdr-vc11.vcxproj | 209 - .../cxx/tree/binary/xdr/xdr-vc11.vcxproj.filters | 38 - dist/examples/cxx/tree/binary/xdr/xdr-vc12.vcxproj | 213 - .../cxx/tree/binary/xdr/xdr-vc12.vcxproj.filters | 38 - dist/examples/cxx/tree/binary/xdr/xdr-vc8.vcproj | 423 -- dist/examples/cxx/tree/binary/xdr/xdr-vc9.vcproj | 420 -- .../examples/cxx/tree/caching/caching-vc10.vcxproj | 205 - .../cxx/tree/caching/caching-vc10.vcxproj.filters | 38 - .../examples/cxx/tree/caching/caching-vc11.vcxproj | 209 - .../cxx/tree/caching/caching-vc11.vcxproj.filters | 38 - .../examples/cxx/tree/caching/caching-vc12.vcxproj | 213 - .../cxx/tree/caching/caching-vc12.vcxproj.filters | 38 - dist/examples/cxx/tree/caching/caching-vc8.vcproj | 423 -- dist/examples/cxx/tree/caching/caching-vc9.vcproj | 420 -- dist/examples/cxx/tree/caching/makefile | 28 - .../cxx/tree/compression/compression-vc10.vcxproj | 209 - .../compression/compression-vc10.vcxproj.filters | 50 - .../cxx/tree/compression/compression-vc11.vcxproj | 213 - .../compression/compression-vc11.vcxproj.filters | 50 - .../cxx/tree/compression/compression-vc12.vcxproj | 217 - .../compression/compression-vc12.vcxproj.filters | 50 - .../cxx/tree/compression/compression-vc8.vcproj | 435 -- .../cxx/tree/compression/compression-vc9.vcproj | 432 -- dist/examples/cxx/tree/compression/makefile | 37 - .../cxx/tree/custom/calendar/calendar-vc10.vcxproj | 229 - .../custom/calendar/calendar-vc10.vcxproj.filters | 54 - .../cxx/tree/custom/calendar/calendar-vc11.vcxproj | 233 - .../custom/calendar/calendar-vc11.vcxproj.filters | 54 - .../cxx/tree/custom/calendar/calendar-vc12.vcxproj | 237 - .../custom/calendar/calendar-vc12.vcxproj.filters | 54 - .../cxx/tree/custom/calendar/calendar-vc8.vcproj | 456 -- .../cxx/tree/custom/calendar/calendar-vc9.vcproj | 453 -- dist/examples/cxx/tree/custom/calendar/makefile | 42 - .../cxx/tree/custom/comments/comments-vc10.vcxproj | 231 - .../custom/comments/comments-vc10.vcxproj.filters | 60 - .../cxx/tree/custom/comments/comments-vc11.vcxproj | 235 - .../custom/comments/comments-vc11.vcxproj.filters | 60 - .../cxx/tree/custom/comments/comments-vc12.vcxproj | 239 - .../custom/comments/comments-vc12.vcxproj.filters | 60 - .../cxx/tree/custom/comments/comments-vc8.vcproj | 464 -- .../cxx/tree/custom/comments/comments-vc9.vcproj | 461 -- dist/examples/cxx/tree/custom/comments/makefile | 49 - .../cxx/tree/custom/contacts/contacts-vc10.vcxproj | 208 - .../custom/contacts/contacts-vc10.vcxproj.filters | 51 - .../cxx/tree/custom/contacts/contacts-vc11.vcxproj | 212 - .../custom/contacts/contacts-vc11.vcxproj.filters | 51 - .../cxx/tree/custom/contacts/contacts-vc12.vcxproj | 216 - .../custom/contacts/contacts-vc12.vcxproj.filters | 51 - .../cxx/tree/custom/contacts/contacts-vc8.vcproj | 440 -- .../cxx/tree/custom/contacts/contacts-vc9.vcproj | 437 -- dist/examples/cxx/tree/custom/contacts/makefile | 39 - .../cxx/tree/custom/double/double-vc10.vcxproj | 229 - .../tree/custom/double/double-vc10.vcxproj.filters | 54 - .../cxx/tree/custom/double/double-vc11.vcxproj | 233 - .../tree/custom/double/double-vc11.vcxproj.filters | 54 - .../cxx/tree/custom/double/double-vc12.vcxproj | 237 - .../tree/custom/double/double-vc12.vcxproj.filters | 54 - .../cxx/tree/custom/double/double-vc8.vcproj | 456 -- .../cxx/tree/custom/double/double-vc9.vcproj | 453 -- dist/examples/cxx/tree/custom/double/makefile | 42 - dist/examples/cxx/tree/custom/makefile | 15 - dist/examples/cxx/tree/custom/mixed/makefile | 40 - .../cxx/tree/custom/mixed/mixed-vc10.vcxproj | 208 - .../tree/custom/mixed/mixed-vc10.vcxproj.filters | 51 - .../cxx/tree/custom/mixed/mixed-vc11.vcxproj | 212 - .../tree/custom/mixed/mixed-vc11.vcxproj.filters | 51 - .../cxx/tree/custom/mixed/mixed-vc12.vcxproj | 216 - .../tree/custom/mixed/mixed-vc12.vcxproj.filters | 51 - .../cxx/tree/custom/mixed/mixed-vc8.vcproj | 440 -- .../cxx/tree/custom/mixed/mixed-vc9.vcproj | 437 -- dist/examples/cxx/tree/custom/taxonomy/makefile | 39 - .../cxx/tree/custom/taxonomy/taxonomy-vc10.vcxproj | 210 - .../custom/taxonomy/taxonomy-vc10.vcxproj.filters | 57 - .../cxx/tree/custom/taxonomy/taxonomy-vc11.vcxproj | 214 - .../custom/taxonomy/taxonomy-vc11.vcxproj.filters | 57 - .../cxx/tree/custom/taxonomy/taxonomy-vc12.vcxproj | 218 - .../custom/taxonomy/taxonomy-vc12.vcxproj.filters | 57 - .../cxx/tree/custom/taxonomy/taxonomy-vc8.vcproj | 448 -- .../cxx/tree/custom/taxonomy/taxonomy-vc9.vcproj | 445 -- dist/examples/cxx/tree/custom/wildcard/makefile | 40 - .../cxx/tree/custom/wildcard/wildcard-vc10.vcxproj | 208 - .../custom/wildcard/wildcard-vc10.vcxproj.filters | 51 - .../cxx/tree/custom/wildcard/wildcard-vc11.vcxproj | 212 - .../custom/wildcard/wildcard-vc11.vcxproj.filters | 51 - .../cxx/tree/custom/wildcard/wildcard-vc12.vcxproj | 216 - .../custom/wildcard/wildcard-vc12.vcxproj.filters | 51 - .../cxx/tree/custom/wildcard/wildcard-vc8.vcproj | 440 -- .../cxx/tree/custom/wildcard/wildcard-vc9.vcproj | 437 -- dist/examples/cxx/tree/embedded/embedded-vc10.sln | 38 - .../cxx/tree/embedded/embedded-vc10.vcxproj | 215 - .../tree/embedded/embedded-vc10.vcxproj.filters | 50 - dist/examples/cxx/tree/embedded/embedded-vc11.sln | 38 - .../cxx/tree/embedded/embedded-vc11.vcxproj | 219 - .../tree/embedded/embedded-vc11.vcxproj.filters | 50 - dist/examples/cxx/tree/embedded/embedded-vc12.sln | 40 - .../cxx/tree/embedded/embedded-vc12.vcxproj | 223 - .../tree/embedded/embedded-vc12.vcxproj.filters | 50 - dist/examples/cxx/tree/embedded/embedded-vc8.sln | 41 - .../examples/cxx/tree/embedded/embedded-vc8.vcproj | 439 -- dist/examples/cxx/tree/embedded/embedded-vc9.sln | 41 - .../examples/cxx/tree/embedded/embedded-vc9.vcproj | 436 -- dist/examples/cxx/tree/embedded/makefile | 36 - .../examples/cxx/tree/embedded/xsdbin-vc10.vcxproj | 182 - .../cxx/tree/embedded/xsdbin-vc10.vcxproj.filters | 14 - .../examples/cxx/tree/embedded/xsdbin-vc11.vcxproj | 186 - .../cxx/tree/embedded/xsdbin-vc11.vcxproj.filters | 14 - .../examples/cxx/tree/embedded/xsdbin-vc12.vcxproj | 190 - .../cxx/tree/embedded/xsdbin-vc12.vcxproj.filters | 14 - dist/examples/cxx/tree/embedded/xsdbin-vc8.vcproj | 356 - dist/examples/cxx/tree/embedded/xsdbin-vc9.vcproj | 353 - dist/examples/cxx/tree/hello/hello-vc10.vcxproj | 205 - .../cxx/tree/hello/hello-vc10.vcxproj.filters | 38 - dist/examples/cxx/tree/hello/hello-vc11.vcxproj | 209 - .../cxx/tree/hello/hello-vc11.vcxproj.filters | 38 - dist/examples/cxx/tree/hello/hello-vc12.vcxproj | 213 - .../cxx/tree/hello/hello-vc12.vcxproj.filters | 38 - dist/examples/cxx/tree/hello/hello-vc8.vcproj | 423 -- dist/examples/cxx/tree/hello/hello-vc9.vcproj | 420 -- dist/examples/cxx/tree/hello/makefile | 29 - .../examples/cxx/tree/library/library-vc10.vcxproj | 206 - .../cxx/tree/library/library-vc10.vcxproj.filters | 45 - .../examples/cxx/tree/library/library-vc11.vcxproj | 210 - .../cxx/tree/library/library-vc11.vcxproj.filters | 45 - .../examples/cxx/tree/library/library-vc12.vcxproj | 214 - .../cxx/tree/library/library-vc12.vcxproj.filters | 45 - dist/examples/cxx/tree/library/library-vc8.vcproj | 432 -- dist/examples/cxx/tree/library/library-vc9.vcproj | 429 -- dist/examples/cxx/tree/library/makefile | 32 - dist/examples/cxx/tree/makefile | 20 - dist/examples/cxx/tree/messaging/makefile | 35 - .../cxx/tree/messaging/messaging-vc10.vcxproj | 209 - .../tree/messaging/messaging-vc10.vcxproj.filters | 50 - .../cxx/tree/messaging/messaging-vc11.vcxproj | 213 - .../tree/messaging/messaging-vc11.vcxproj.filters | 50 - .../cxx/tree/messaging/messaging-vc12.vcxproj | 217 - .../tree/messaging/messaging-vc12.vcxproj.filters | 50 - .../cxx/tree/messaging/messaging-vc8.vcproj | 439 -- .../cxx/tree/messaging/messaging-vc9.vcproj | 436 -- dist/examples/cxx/tree/mixed/makefile | 28 - dist/examples/cxx/tree/mixed/mixed-vc10.vcxproj | 205 - .../cxx/tree/mixed/mixed-vc10.vcxproj.filters | 38 - dist/examples/cxx/tree/mixed/mixed-vc11.vcxproj | 209 - .../cxx/tree/mixed/mixed-vc11.vcxproj.filters | 38 - dist/examples/cxx/tree/mixed/mixed-vc12.vcxproj | 213 - .../cxx/tree/mixed/mixed-vc12.vcxproj.filters | 38 - dist/examples/cxx/tree/mixed/mixed-vc8.vcproj | 423 -- dist/examples/cxx/tree/mixed/mixed-vc9.vcproj | 420 -- dist/examples/cxx/tree/multiroot/makefile | 33 - .../cxx/tree/multiroot/multiroot-vc10.vcxproj | 207 - .../tree/multiroot/multiroot-vc10.vcxproj.filters | 44 - .../cxx/tree/multiroot/multiroot-vc11.vcxproj | 211 - .../tree/multiroot/multiroot-vc11.vcxproj.filters | 44 - .../cxx/tree/multiroot/multiroot-vc12.vcxproj | 215 - .../tree/multiroot/multiroot-vc12.vcxproj.filters | 44 - .../cxx/tree/multiroot/multiroot-vc8.vcproj | 431 -- .../cxx/tree/multiroot/multiroot-vc9.vcproj | 428 -- dist/examples/cxx/tree/order/element/makefile | 31 - .../tree/order/element/order-element-vc10.vcxproj | 205 - .../element/order-element-vc10.vcxproj.filters | 38 - .../tree/order/element/order-element-vc11.vcxproj | 209 - .../element/order-element-vc11.vcxproj.filters | 38 - .../tree/order/element/order-element-vc12.vcxproj | 213 - .../element/order-element-vc12.vcxproj.filters | 38 - .../tree/order/element/order-element-vc8.vcproj | 423 -- .../tree/order/element/order-element-vc9.vcproj | 420 -- dist/examples/cxx/tree/order/makefile | 11 - dist/examples/cxx/tree/order/mixed/makefile | 32 - .../cxx/tree/order/mixed/order-mixed-vc10.vcxproj | 205 - .../order/mixed/order-mixed-vc10.vcxproj.filters | 38 - .../cxx/tree/order/mixed/order-mixed-vc11.vcxproj | 209 - .../order/mixed/order-mixed-vc11.vcxproj.filters | 38 - .../cxx/tree/order/mixed/order-mixed-vc12.vcxproj | 213 - .../order/mixed/order-mixed-vc12.vcxproj.filters | 38 - .../cxx/tree/order/mixed/order-mixed-vc8.vcproj | 423 -- .../cxx/tree/order/mixed/order-mixed-vc9.vcproj | 420 -- dist/examples/cxx/tree/performance/makefile | 34 - .../cxx/tree/performance/performance-vc10.vcxproj | 210 - .../performance/performance-vc10.vcxproj.filters | 57 - .../cxx/tree/performance/performance-vc11.vcxproj | 214 - .../performance/performance-vc11.vcxproj.filters | 57 - .../cxx/tree/performance/performance-vc12.vcxproj | 218 - .../performance/performance-vc12.vcxproj.filters | 57 - .../cxx/tree/performance/performance-vc8.vcproj | 445 -- .../cxx/tree/performance/performance-vc9.vcproj | 442 -- dist/examples/cxx/tree/polymorphism/makefile | 30 - .../tree/polymorphism/polymorphism-vc10.vcxproj | 205 - .../polymorphism/polymorphism-vc10.vcxproj.filters | 38 - .../tree/polymorphism/polymorphism-vc11.vcxproj | 209 - .../polymorphism/polymorphism-vc11.vcxproj.filters | 38 - .../tree/polymorphism/polymorphism-vc12.vcxproj | 213 - .../polymorphism/polymorphism-vc12.vcxproj.filters | 38 - .../cxx/tree/polymorphism/polymorphism-vc8.vcproj | 423 -- .../cxx/tree/polymorphism/polymorphism-vc9.vcproj | 420 -- dist/examples/cxx/tree/secure/makefile | 28 - dist/examples/cxx/tree/streaming/makefile | 34 - .../cxx/tree/streaming/streaming-vc10.vcxproj | 211 - .../tree/streaming/streaming-vc10.vcxproj.filters | 56 - .../cxx/tree/streaming/streaming-vc11.vcxproj | 215 - .../tree/streaming/streaming-vc11.vcxproj.filters | 56 - .../cxx/tree/streaming/streaming-vc12.vcxproj | 219 - .../tree/streaming/streaming-vc12.vcxproj.filters | 56 - .../cxx/tree/streaming/streaming-vc8.vcproj | 441 -- .../cxx/tree/streaming/streaming-vc9.vcproj | 438 -- dist/examples/cxx/tree/wildcard/makefile | 32 - .../cxx/tree/wildcard/wildcard-vc10.vcxproj | 206 - .../tree/wildcard/wildcard-vc10.vcxproj.filters | 45 - .../cxx/tree/wildcard/wildcard-vc11.vcxproj | 210 - .../tree/wildcard/wildcard-vc11.vcxproj.filters | 45 - .../cxx/tree/wildcard/wildcard-vc12.vcxproj | 214 - .../tree/wildcard/wildcard-vc12.vcxproj.filters | 45 - .../examples/cxx/tree/wildcard/wildcard-vc8.vcproj | 432 -- .../examples/cxx/tree/wildcard/wildcard-vc9.vcproj | 429 -- dist/examples/cxx/tree/xpath/makefile | 30 - dist/examples/cxx/tree/xpath/xpath-vc10.vcxproj | 207 - .../cxx/tree/xpath/xpath-vc10.vcxproj.filters | 44 - dist/examples/cxx/tree/xpath/xpath-vc11.vcxproj | 211 - .../cxx/tree/xpath/xpath-vc11.vcxproj.filters | 44 - dist/examples/cxx/tree/xpath/xpath-vc12.vcxproj | 215 - .../cxx/tree/xpath/xpath-vc12.vcxproj.filters | 44 - dist/examples/cxx/tree/xpath/xpath-vc8.vcproj | 431 -- dist/examples/cxx/tree/xpath/xpath-vc9.vcproj | 428 -- dist/examples/makefile | 11 - dist/examples/test.bat | 73 - dist/examples/tester.bat | 46 - dist/template-vc10.sln | 15 - dist/template-vc11.sln | 15 - dist/template-vc12.sln | 17 - dist/template-vc8.sln | 15 - dist/template-vc9.sln | 15 - doc/custom-literals.xsd | 48 - doc/cxx/makefile | 20 - doc/cxx/parser/guide/figure-1.png | Bin 34195 -> 0 bytes doc/cxx/parser/guide/figure-1.svg | 373 -- doc/cxx/parser/guide/guide.html2ps | 65 - doc/cxx/parser/guide/index.xhtml | 4158 ------------ doc/cxx/parser/guide/makefile | 55 - doc/cxx/parser/makefile | 20 - doc/cxx/tree/guide/guide.html2ps | 65 - doc/cxx/tree/guide/index.xhtml | 2732 -------- doc/cxx/tree/guide/makefile | 53 - doc/cxx/tree/makefile | 40 - doc/cxx/tree/manual/index.xhtml | 6822 ------------------- doc/cxx/tree/manual/makefile | 53 - doc/cxx/tree/manual/manual.html2ps | 66 - doc/cxx/tree/reference/footer.html | 6 - doc/cxx/tree/reference/libxsd.doxygen | 1291 ---- doc/cxx/tree/reference/makefile | 18 - doc/default.css | 319 - doc/doc.sh | 105 - doc/makefile | 142 - doc/xsd-epilogue.1 | 566 -- doc/xsd-epilogue.xhtml | 422 -- doc/xsd-parser-header.1 | 4 - doc/xsd-parser-header.xhtml | 1 - doc/xsd-prologue.1 | 119 - doc/xsd-prologue.xhtml | 122 - doc/xsd-tree-header.1 | 4 - doc/xsd-tree-header.xhtml | 1 - examples/cxx/parser/README | 45 - examples/cxx/parser/generated/README | 32 - examples/cxx/parser/generated/library.xml | 52 - examples/cxx/parser/generated/library.xsd | 78 - examples/cxx/parser/generated/makefile | 109 - examples/cxx/parser/hello/README | 28 - examples/cxx/parser/hello/driver.cxx | 67 - examples/cxx/parser/hello/hello.xml | 19 - examples/cxx/parser/hello/hello.xsd | 21 - examples/cxx/parser/hello/makefile | 100 - examples/cxx/parser/library/README | 44 - examples/cxx/parser/library/driver.cxx | 109 - examples/cxx/parser/library/library-pimpl.cxx | 183 - examples/cxx/parser/library/library-pimpl.hxx | 135 - examples/cxx/parser/library/library.hxx | 241 - examples/cxx/parser/library/library.map | 15 - examples/cxx/parser/library/library.xml | 52 - examples/cxx/parser/library/library.xsd | 78 - examples/cxx/parser/library/makefile | 109 - examples/cxx/parser/makefile | 55 - examples/cxx/parser/mixed/README | 49 - examples/cxx/parser/mixed/anchor.hxx | 33 - examples/cxx/parser/mixed/driver.cxx | 100 - examples/cxx/parser/mixed/makefile | 106 - examples/cxx/parser/mixed/text.map | 6 - examples/cxx/parser/mixed/text.xml | 17 - examples/cxx/parser/mixed/text.xsd | 28 - examples/cxx/parser/mixin/README | 34 - examples/cxx/parser/mixin/driver.cxx | 103 - examples/cxx/parser/mixin/instance.xml | 16 - examples/cxx/parser/mixin/makefile | 106 - examples/cxx/parser/mixin/schema.map | 7 - examples/cxx/parser/mixin/schema.xsd | 30 - examples/cxx/parser/mixin/types.hxx | 43 - 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 - examples/cxx/parser/performance/README | 42 - examples/cxx/parser/performance/driver.cxx | 341 - examples/cxx/parser/performance/gen.cxx | 76 - examples/cxx/parser/performance/makefile | 108 - examples/cxx/parser/performance/test-50k.xml | 1 - examples/cxx/parser/performance/test.xsd | 49 - examples/cxx/parser/performance/time.cxx | 46 - examples/cxx/parser/performance/time.hxx | 110 - examples/cxx/parser/polymorphism/README | 30 - examples/cxx/parser/polymorphism/driver.cxx | 70 - examples/cxx/parser/polymorphism/makefile | 105 - .../cxx/parser/polymorphism/supermen-pimpl.cxx | 85 - .../cxx/parser/polymorphism/supermen-pimpl.hxx | 68 - examples/cxx/parser/polymorphism/supermen.xml | 25 - examples/cxx/parser/polymorphism/supermen.xsd | 48 - examples/cxx/parser/polyroot/README | 36 - examples/cxx/parser/polyroot/batman.xml | 16 - examples/cxx/parser/polyroot/driver.cxx | 138 - examples/cxx/parser/polyroot/makefile | 109 - examples/cxx/parser/polyroot/person.xml | 15 - examples/cxx/parser/polyroot/superman.xml | 16 - examples/cxx/parser/polyroot/supermen-pimpl.cxx | 85 - examples/cxx/parser/polyroot/supermen-pimpl.hxx | 64 - examples/cxx/parser/polyroot/supermen.xsd | 36 - examples/cxx/parser/wildcard/README | 27 - examples/cxx/parser/wildcard/driver.cxx | 239 - examples/cxx/parser/wildcard/email.xml | 31 - examples/cxx/parser/wildcard/email.xsd | 50 - examples/cxx/parser/wildcard/makefile | 101 - examples/cxx/tree/README | 84 - examples/cxx/tree/binary/README | 16 - examples/cxx/tree/binary/boost/README | 49 - .../tree/binary/boost/boost-archive-extraction.hxx | 188 - .../tree/binary/boost/boost-archive-insertion.hxx | 177 - examples/cxx/tree/binary/boost/driver.cxx | 72 - .../cxx/tree/binary/boost/library-prologue.hxx | 9 - examples/cxx/tree/binary/boost/library.xml | 52 - examples/cxx/tree/binary/boost/library.xsd | 75 - examples/cxx/tree/binary/boost/makefile | 131 - examples/cxx/tree/binary/cdr/README | 36 - examples/cxx/tree/binary/cdr/driver.cxx | 87 - examples/cxx/tree/binary/cdr/library.xml | 52 - examples/cxx/tree/binary/cdr/library.xsd | 75 - examples/cxx/tree/binary/cdr/makefile | 119 - examples/cxx/tree/binary/makefile | 55 - 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 - examples/cxx/tree/caching/README | 29 - examples/cxx/tree/caching/driver.cxx | 165 - examples/cxx/tree/caching/library.xml | 52 - examples/cxx/tree/caching/library.xsd | 72 - examples/cxx/tree/caching/makefile | 100 - examples/cxx/tree/compression/README | 48 - .../tree/compression/compressed-format-target.cxx | 152 - .../tree/compression/compressed-format-target.hxx | 91 - .../tree/compression/compressed-input-source.cxx | 195 - .../tree/compression/compressed-input-source.hxx | 121 - examples/cxx/tree/compression/driver.cxx | 124 - examples/cxx/tree/compression/library.xml.gz | Bin 486 -> 0 bytes examples/cxx/tree/compression/library.xsd | 72 - examples/cxx/tree/compression/makefile | 127 - examples/cxx/tree/custom/README | 40 - examples/cxx/tree/custom/calendar/README | 47 - examples/cxx/tree/custom/calendar/calendar.xml | 22 - examples/cxx/tree/custom/calendar/calendar.xsd | 31 - examples/cxx/tree/custom/calendar/driver.cxx | 39 - examples/cxx/tree/custom/calendar/makefile | 136 - .../cxx/tree/custom/calendar/xml-schema-custom.cxx | 56 - .../cxx/tree/custom/calendar/xml-schema-custom.hxx | 33 - 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 - examples/cxx/tree/custom/contacts/README | 40 - .../cxx/tree/custom/contacts/contacts-custom.cxx | 50 - .../cxx/tree/custom/contacts/contacts-custom.hxx | 43 - examples/cxx/tree/custom/contacts/contacts.xml | 20 - examples/cxx/tree/custom/contacts/contacts.xsd | 31 - examples/cxx/tree/custom/contacts/driver.cxx | 38 - examples/cxx/tree/custom/contacts/makefile | 112 - examples/cxx/tree/custom/double/README | 62 - examples/cxx/tree/custom/double/double-custom.cxx | 96 - examples/cxx/tree/custom/double/double-custom.hxx | 67 - examples/cxx/tree/custom/double/driver.cxx | 31 - examples/cxx/tree/custom/double/makefile | 111 - examples/cxx/tree/custom/double/order.xsd | 25 - examples/cxx/tree/custom/makefile | 60 - examples/cxx/tree/custom/mixed/README | 50 - examples/cxx/tree/custom/mixed/driver.cxx | 123 - examples/cxx/tree/custom/mixed/makefile | 114 - examples/cxx/tree/custom/mixed/people-custom.cxx | 89 - examples/cxx/tree/custom/mixed/people-custom.hxx | 83 - examples/cxx/tree/custom/mixed/people.xml | 38 - examples/cxx/tree/custom/mixed/people.xsd | 45 - examples/cxx/tree/custom/taxonomy/README | 53 - examples/cxx/tree/custom/taxonomy/driver.cxx | 38 - examples/cxx/tree/custom/taxonomy/makefile | 121 - .../cxx/tree/custom/taxonomy/people-custom-fwd.hxx | 19 - .../cxx/tree/custom/taxonomy/people-custom.cxx | 156 - .../cxx/tree/custom/taxonomy/people-custom.hxx | 96 - examples/cxx/tree/custom/taxonomy/people.xml | 26 - examples/cxx/tree/custom/taxonomy/people.xsd | 44 - examples/cxx/tree/custom/wildcard/README | 45 - examples/cxx/tree/custom/wildcard/driver.cxx | 47 - examples/cxx/tree/custom/wildcard/makefile | 115 - .../cxx/tree/custom/wildcard/wildcard-custom.cxx | 84 - .../cxx/tree/custom/wildcard/wildcard-custom.hxx | 66 - examples/cxx/tree/custom/wildcard/wildcard.xml | 14 - examples/cxx/tree/custom/wildcard/wildcard.xsd | 25 - examples/cxx/tree/embedded/README | 48 - examples/cxx/tree/embedded/driver.cxx | 183 - .../cxx/tree/embedded/grammar-input-stream.cxx | 95 - .../cxx/tree/embedded/grammar-input-stream.hxx | 40 - examples/cxx/tree/embedded/library.xml | 52 - examples/cxx/tree/embedded/library.xsd | 72 - examples/cxx/tree/embedded/makefile | 122 - examples/cxx/tree/embedded/xsdbin.cxx | 494 -- examples/cxx/tree/hello/README | 26 - examples/cxx/tree/hello/driver.cxx | 36 - examples/cxx/tree/hello/hello.xml | 19 - examples/cxx/tree/hello/hello.xsd | 52 - examples/cxx/tree/hello/makefile | 100 - examples/cxx/tree/library/README | 32 - examples/cxx/tree/library/driver.cxx | 130 - examples/cxx/tree/library/library.xml | 52 - examples/cxx/tree/library/library.xsd | 72 - examples/cxx/tree/library/makefile | 101 - examples/cxx/tree/makefile | 69 - examples/cxx/tree/messaging/README | 58 - examples/cxx/tree/messaging/balance.xml | 16 - examples/cxx/tree/messaging/deposit.xml | 17 - examples/cxx/tree/messaging/dom-parse.cxx | 93 - examples/cxx/tree/messaging/dom-parse.hxx | 22 - examples/cxx/tree/messaging/dom-serialize.cxx | 64 - examples/cxx/tree/messaging/dom-serialize.hxx | 20 - examples/cxx/tree/messaging/driver.cxx | 144 - examples/cxx/tree/messaging/makefile | 116 - examples/cxx/tree/messaging/protocol.xsd | 53 - examples/cxx/tree/messaging/withdraw.xml | 17 - examples/cxx/tree/mixed/README | 45 - examples/cxx/tree/mixed/driver.cxx | 122 - examples/cxx/tree/mixed/makefile | 101 - examples/cxx/tree/mixed/text.xml | 17 - examples/cxx/tree/mixed/text.xsd | 28 - 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 - examples/cxx/tree/order/README | 11 - examples/cxx/tree/order/element/README | 35 - examples/cxx/tree/order/element/driver.cxx | 147 - examples/cxx/tree/order/element/makefile | 99 - examples/cxx/tree/order/element/transactions.xml | 32 - examples/cxx/tree/order/element/transactions.xsd | 58 - examples/cxx/tree/order/makefile | 43 - examples/cxx/tree/order/mixed/README | 45 - examples/cxx/tree/order/mixed/driver.cxx | 89 - examples/cxx/tree/order/mixed/makefile | 98 - examples/cxx/tree/order/mixed/text.xml | 17 - examples/cxx/tree/order/mixed/text.xsd | 28 - examples/cxx/tree/performance/README | 58 - examples/cxx/tree/performance/driver.cxx | 90 - examples/cxx/tree/performance/gen.cxx | 76 - examples/cxx/tree/performance/makefile | 110 - examples/cxx/tree/performance/parsing.cxx | 172 - examples/cxx/tree/performance/serialization.cxx | 132 - examples/cxx/tree/performance/test-50k.xml | 1 - examples/cxx/tree/performance/test.xsd | 49 - examples/cxx/tree/performance/time.cxx | 46 - examples/cxx/tree/performance/time.hxx | 110 - examples/cxx/tree/polymorphism/README | 32 - examples/cxx/tree/polymorphism/driver.cxx | 59 - examples/cxx/tree/polymorphism/makefile | 103 - examples/cxx/tree/polymorphism/supermen.xml | 25 - examples/cxx/tree/polymorphism/supermen.xsd | 48 - examples/cxx/tree/secure/README | 41 - examples/cxx/tree/secure/driver.cxx | 141 - examples/cxx/tree/secure/library.xml | 59 - examples/cxx/tree/secure/library.xsd | 72 - examples/cxx/tree/secure/makefile | 103 - examples/cxx/tree/secure/secure-dom-parser.cxx | 24 - examples/cxx/tree/secure/secure-dom-parser.hxx | 25 - examples/cxx/tree/streaming/README | 51 - examples/cxx/tree/streaming/driver.cxx | 139 - .../cxx/tree/streaming/grammar-input-stream.cxx | 96 - .../cxx/tree/streaming/grammar-input-stream.hxx | 41 - examples/cxx/tree/streaming/makefile | 114 - examples/cxx/tree/streaming/parser.cxx | 372 -- examples/cxx/tree/streaming/parser.hxx | 67 - examples/cxx/tree/streaming/position.xml | 29 - examples/cxx/tree/streaming/position.xsd | 37 - examples/cxx/tree/streaming/serializer.cxx | 636 -- examples/cxx/tree/streaming/serializer.hxx | 205 - examples/cxx/tree/wildcard/README | 34 - examples/cxx/tree/wildcard/driver.cxx | 159 - examples/cxx/tree/wildcard/email.xml | 31 - examples/cxx/tree/wildcard/email.xsd | 50 - examples/cxx/tree/wildcard/makefile | 101 - examples/cxx/tree/xpath/README | 43 - examples/cxx/tree/xpath/dom-parse.cxx | 88 - examples/cxx/tree/xpath/dom-parse.hxx | 25 - examples/cxx/tree/xpath/driver.cxx | 136 - examples/cxx/tree/xpath/makefile | 122 - examples/cxx/tree/xpath/people.xml | 28 - examples/cxx/tree/xpath/people.xsd | 38 - examples/makefile | 19 - libxsd-tests/.gitignore | 28 + libxsd-tests/FLOSSE | 1 + libxsd-tests/GPLv2 | 1 + libxsd-tests/LICENSE | 1 + libxsd-tests/README | 8 + libxsd-tests/build/.gitignore | 3 + libxsd-tests/build/bootstrap.build | 9 + libxsd-tests/build/root.build | 25 + libxsd-tests/buildfile | 4 + libxsd-tests/cxx/parser/expat/basic/buildfile | 7 + libxsd-tests/cxx/parser/expat/basic/driver.cxx | 124 + libxsd-tests/cxx/parser/expat/basic/testscript | 41 + libxsd-tests/cxx/parser/xerces/basic/buildfile | 7 + libxsd-tests/cxx/parser/xerces/basic/driver.cxx | 124 + libxsd-tests/cxx/parser/xerces/basic/testscript | 41 + libxsd-tests/cxx/tree/basic/buildfile | 7 + libxsd-tests/cxx/tree/basic/driver.cxx | 65 + libxsd-tests/cxx/tree/basic/testscript | 73 + libxsd-tests/manifest | 15 + libxsd/.gitignore | 19 + libxsd/FLOSSE | 90 +- libxsd/GPLv2 | 341 +- libxsd/INSTALL | 19 +- libxsd/LICENSE | 29 +- libxsd/NEWS | 1 + libxsd/README | 7 +- libxsd/README-GIT | 4 + libxsd/build/.gitignore | 3 + libxsd/build/bootstrap.build | 10 + libxsd/build/export.build | 9 + libxsd/build/root.build | 14 + libxsd/buildfile | 8 + libxsd/doc/buildfile | 83 + libxsd/doc/cxx/tree/reference/.gitignore | 4 + libxsd/doc/cxx/tree/reference/footer.html.in | 6 + libxsd/doc/cxx/tree/reference/libxsd.doxygen.in | 1289 ++++ libxsd/makefile | 43 - libxsd/manifest | 17 + libxsd/xsd/buildfile | 39 + libxsd/xsd/cxx/tree/elements.hxx | 10 +- libxsd/xsd/cxx/tree/types.hxx | 4 + libxsd/xsd/cxx/version.hxx | 27 - libxsd/xsd/cxx/version.hxx.in | 43 + libxsd/xsd/cxx/xml/char-utf8.txx | 4 + makefile | 102 - packages.manifest | 10 + repositories.manifest | 22 + tests/clash/clash.xsd | 25 - tests/clash/foo.xsd | 11 - tests/code/name-conflict/test.xsd | 40 - tests/code/name-escaping/test.xsd | 60 - tests/cxx/makefile | 15 - tests/cxx/parser/built-in/driver.cxx | 529 -- tests/cxx/parser/built-in/makefile | 82 - tests/cxx/parser/built-in/output | 164 - tests/cxx/parser/built-in/test.xml | 199 - tests/cxx/parser/built-in/test.xsd | 63 - tests/cxx/parser/enumeration/driver.cxx | 81 - tests/cxx/parser/enumeration/gender.hxx | 13 - tests/cxx/parser/enumeration/makefile | 83 - tests/cxx/parser/enumeration/output | 3 - tests/cxx/parser/enumeration/test.map | 7 - tests/cxx/parser/enumeration/test.xml | 10 - tests/cxx/parser/enumeration/test.xsd | 35 - tests/cxx/parser/generated-impl/makefile | 93 - tests/cxx/parser/generated-impl/output | 122 - tests/cxx/parser/generated-impl/test.xml | 168 - tests/cxx/parser/generated-impl/test.xsd | 142 - tests/cxx/parser/list/driver.cxx | 105 - tests/cxx/parser/list/makefile | 82 - tests/cxx/parser/list/output | 26 - tests/cxx/parser/list/test.xml | 25 - tests/cxx/parser/list/test.xsd | 25 - tests/cxx/parser/makefile | 18 - tests/cxx/parser/name-clash/inheritance/driver.cxx | 62 - tests/cxx/parser/name-clash/inheritance/makefile | 83 - tests/cxx/parser/name-clash/inheritance/output | 2 - tests/cxx/parser/name-clash/inheritance/test.xml | 8 - tests/cxx/parser/name-clash/inheritance/test.xsd | 22 - tests/cxx/parser/polymorphism/makefile | 16 - tests/cxx/parser/polymorphism/recursive/driver.cxx | 68 - tests/cxx/parser/polymorphism/recursive/makefile | 83 - tests/cxx/parser/polymorphism/recursive/output | 22 - .../parser/polymorphism/recursive/test-pimpl.cxx | 147 - .../parser/polymorphism/recursive/test-pimpl.hxx | 94 - tests/cxx/parser/polymorphism/recursive/test.xml | 15 - tests/cxx/parser/polymorphism/recursive/test.xsd | 53 - tests/cxx/parser/polymorphism/same-type/driver.cxx | 62 - tests/cxx/parser/polymorphism/same-type/makefile | 83 - tests/cxx/parser/polymorphism/same-type/output | 4 - tests/cxx/parser/polymorphism/same-type/test.xml | 10 - tests/cxx/parser/polymorphism/same-type/test.xsd | 21 - tests/cxx/parser/recursive/driver.cxx | 139 - tests/cxx/parser/recursive/makefile | 83 - tests/cxx/parser/recursive/output | 22 - tests/cxx/parser/recursive/test.xml | 11 - tests/cxx/parser/recursive/test.xsd | 27 - tests/cxx/parser/test-template/driver.cxx | 66 - tests/cxx/parser/test-template/makefile | 82 - tests/cxx/parser/test-template/output | 1 - tests/cxx/parser/test-template/test.xml | 7 - tests/cxx/parser/test-template/test.xsd | 12 - tests/cxx/parser/union/driver.cxx | 60 - tests/cxx/parser/union/makefile | 82 - tests/cxx/parser/union/output | 2 - tests/cxx/parser/union/test.xml | 10 - tests/cxx/parser/union/test.xsd | 16 - tests/cxx/parser/validation/all/driver.cxx | 98 - tests/cxx/parser/validation/all/makefile | 92 - tests/cxx/parser/validation/all/test-000.std | 46 - tests/cxx/parser/validation/all/test-000.xml | 53 - tests/cxx/parser/validation/all/test-001.std | 6 - tests/cxx/parser/validation/all/test-001.xml | 11 - tests/cxx/parser/validation/all/test-002.std | 4 - tests/cxx/parser/validation/all/test-002.xml | 9 - tests/cxx/parser/validation/all/test-003.std | 6 - tests/cxx/parser/validation/all/test-003.xml | 12 - tests/cxx/parser/validation/all/test.xsd | 20 - tests/cxx/parser/validation/any/driver.cxx | 121 - tests/cxx/parser/validation/any/makefile | 92 - tests/cxx/parser/validation/any/test-000.std | 29 - tests/cxx/parser/validation/any/test-000.xml | 21 - tests/cxx/parser/validation/any/test.xsd | 20 - tests/cxx/parser/validation/attribute/driver.cxx | 197 - tests/cxx/parser/validation/attribute/makefile | 92 - tests/cxx/parser/validation/attribute/test-000.std | 24 - tests/cxx/parser/validation/attribute/test-000.xml | 10 - tests/cxx/parser/validation/attribute/test.xsd | 71 - .../parser/validation/built-in/any-type/driver.cxx | 154 - .../parser/validation/built-in/any-type/makefile | 92 - .../validation/built-in/any-type/test-000.std | 99 - .../validation/built-in/any-type/test-000.xml | 41 - .../parser/validation/built-in/any-type/test.xsd | 31 - .../parser/validation/built-in/binary/driver.cxx | 153 - .../cxx/parser/validation/built-in/binary/makefile | 70 - .../parser/validation/built-in/boolean/driver.cxx | 145 - .../parser/validation/built-in/boolean/makefile | 70 - .../cxx/parser/validation/built-in/byte/driver.cxx | 256 - tests/cxx/parser/validation/built-in/byte/makefile | 70 - .../validation/built-in/date-time/driver.cxx | 1533 ----- .../parser/validation/built-in/date-time/makefile | 70 - .../parser/validation/built-in/float/driver.cxx | 285 - .../cxx/parser/validation/built-in/float/makefile | 70 - .../cxx/parser/validation/built-in/int/driver.cxx | 116 - tests/cxx/parser/validation/built-in/int/makefile | 70 - .../parser/validation/built-in/integer/driver.cxx | 303 - .../parser/validation/built-in/integer/makefile | 70 - .../cxx/parser/validation/built-in/long/driver.cxx | 116 - tests/cxx/parser/validation/built-in/long/makefile | 70 - tests/cxx/parser/validation/built-in/makefile | 17 - .../parser/validation/built-in/qname/driver.cxx | 105 - .../cxx/parser/validation/built-in/qname/makefile | 70 - .../parser/validation/built-in/short/driver.cxx | 116 - .../cxx/parser/validation/built-in/short/makefile | 70 - .../parser/validation/built-in/string/driver.cxx | 512 -- .../cxx/parser/validation/built-in/string/makefile | 70 - .../cxx/parser/validation/built-in/uri/driver.cxx | 53 - tests/cxx/parser/validation/built-in/uri/makefile | 70 - tests/cxx/parser/validation/choice/driver.cxx | 126 - tests/cxx/parser/validation/choice/makefile | 92 - tests/cxx/parser/validation/choice/test-000.std | 22 - tests/cxx/parser/validation/choice/test-000.xml | 30 - tests/cxx/parser/validation/choice/test-001.std | 4 - tests/cxx/parser/validation/choice/test-001.xml | 10 - tests/cxx/parser/validation/choice/test-002.std | 11 - tests/cxx/parser/validation/choice/test-002.xml | 17 - tests/cxx/parser/validation/choice/test-003.std | 5 - tests/cxx/parser/validation/choice/test-003.xml | 11 - tests/cxx/parser/validation/choice/test-004.std | 4 - tests/cxx/parser/validation/choice/test-004.xml | 11 - tests/cxx/parser/validation/choice/test.xsd | 24 - tests/cxx/parser/validation/makefile | 16 - tests/cxx/parser/validation/restriction/driver.cxx | 107 - tests/cxx/parser/validation/restriction/makefile | 92 - .../cxx/parser/validation/restriction/test-000.std | 0 .../cxx/parser/validation/restriction/test-000.xml | 31 - .../cxx/parser/validation/restriction/test-001.std | 1 - .../cxx/parser/validation/restriction/test-001.xml | 11 - .../cxx/parser/validation/restriction/test-002.std | 1 - .../cxx/parser/validation/restriction/test-002.xml | 12 - .../cxx/parser/validation/restriction/test-003.std | 1 - .../cxx/parser/validation/restriction/test-003.xml | 16 - .../cxx/parser/validation/restriction/test-004.std | 1 - .../cxx/parser/validation/restriction/test-004.xml | 10 - .../cxx/parser/validation/restriction/test-005.std | 1 - .../cxx/parser/validation/restriction/test-005.xml | 11 - tests/cxx/parser/validation/restriction/test.xsd | 82 - tests/cxx/parser/validation/sequence/driver.cxx | 139 - tests/cxx/parser/validation/sequence/makefile | 92 - tests/cxx/parser/validation/sequence/test-000.std | 56 - tests/cxx/parser/validation/sequence/test-000.xml | 46 - tests/cxx/parser/validation/sequence/test-001.std | 4 - tests/cxx/parser/validation/sequence/test-001.xml | 10 - tests/cxx/parser/validation/sequence/test-002.std | 20 - tests/cxx/parser/validation/sequence/test-002.xml | 27 - tests/cxx/parser/validation/sequence/test-003.std | 5 - tests/cxx/parser/validation/sequence/test-003.xml | 17 - tests/cxx/parser/validation/sequence/test-004.std | 4 - tests/cxx/parser/validation/sequence/test-004.xml | 14 - tests/cxx/parser/validation/sequence/test-005.std | 6 - tests/cxx/parser/validation/sequence/test-005.xml | 15 - tests/cxx/parser/validation/sequence/test-006.std | 13 - tests/cxx/parser/validation/sequence/test-006.xml | 17 - tests/cxx/parser/validation/sequence/test.xsd | 28 - tests/cxx/tree/any-type/driver.cxx | 144 - tests/cxx/tree/any-type/makefile | 86 - tests/cxx/tree/any-type/output | 73 - tests/cxx/tree/any-type/test.xml | 26 - tests/cxx/tree/any-type/test.xsd | 19 - tests/cxx/tree/binary/cdr/driver.cxx | 143 - tests/cxx/tree/binary/cdr/makefile | 89 - tests/cxx/tree/binary/cdr/test.xml | 93 - tests/cxx/tree/binary/cdr/test.xsd | 123 - tests/cxx/tree/binary/makefile | 16 - tests/cxx/tree/binary/polymorphic/driver.cxx | 164 - tests/cxx/tree/binary/polymorphic/makefile | 90 - tests/cxx/tree/binary/polymorphic/test.xml | 92 - tests/cxx/tree/binary/polymorphic/test.xsd | 125 - tests/cxx/tree/binary/xdr-ordered/driver.cxx | 189 - tests/cxx/tree/binary/xdr-ordered/makefile | 85 - tests/cxx/tree/binary/xdr-ordered/test.xml | 93 - tests/cxx/tree/binary/xdr-ordered/test.xsd | 123 - tests/cxx/tree/binary/xdr/driver.cxx | 187 - tests/cxx/tree/binary/xdr/makefile | 85 - tests/cxx/tree/binary/xdr/test.xml | 93 - tests/cxx/tree/binary/xdr/test.xsd | 123 - tests/cxx/tree/built-in/attributes.xml | 73 - tests/cxx/tree/built-in/driver.cxx | 93 - tests/cxx/tree/built-in/elements.xml | 84 - tests/cxx/tree/built-in/inherited.xml | 84 - tests/cxx/tree/built-in/makefile | 99 - tests/cxx/tree/built-in/types.xsd | 460 -- tests/cxx/tree/chameleon/driver.cxx | 35 - tests/cxx/tree/chameleon/includee.xsd | 13 - tests/cxx/tree/chameleon/includer.xsd | 12 - tests/cxx/tree/chameleon/makefile | 85 - tests/cxx/tree/chameleon/output | 3 - tests/cxx/tree/chameleon/test.xml | 8 - tests/cxx/tree/comparison/driver.cxx | 38 - tests/cxx/tree/comparison/makefile | 85 - tests/cxx/tree/comparison/test.xml | 19 - tests/cxx/tree/comparison/test.xsd | 30 - tests/cxx/tree/compilation/driver.cxx | 116 - tests/cxx/tree/compilation/makefile | 85 - tests/cxx/tree/compilation/test.xsd | 12 - tests/cxx/tree/complex/ctor/driver.cxx | 122 - tests/cxx/tree/complex/ctor/makefile | 86 - tests/cxx/tree/complex/ctor/test.xsd | 182 - tests/cxx/tree/complex/makefile | 16 - tests/cxx/tree/containment/driver.cxx | 118 - tests/cxx/tree/containment/makefile | 85 - tests/cxx/tree/containment/test.xsd | 59 - tests/cxx/tree/default/general/driver.cxx | 37 - tests/cxx/tree/default/general/makefile | 86 - tests/cxx/tree/default/general/output | 15 - tests/cxx/tree/default/general/test.xml | 16 - tests/cxx/tree/default/general/test.xsd | 241 - tests/cxx/tree/default/makefile | 16 - tests/cxx/tree/default/omit/driver.cxx | 46 - tests/cxx/tree/default/omit/makefile | 86 - tests/cxx/tree/default/omit/output | 19 - tests/cxx/tree/default/omit/test.xml | 9 - tests/cxx/tree/default/omit/test.xsd | 30 - tests/cxx/tree/detach/driver.cxx | 108 - tests/cxx/tree/detach/makefile | 85 - tests/cxx/tree/detach/test.xsd | 32 - tests/cxx/tree/dom-association/dom-parse.cxx | 95 - tests/cxx/tree/dom-association/dom-parse.hxx | 23 - tests/cxx/tree/dom-association/driver.cxx | 71 - tests/cxx/tree/dom-association/makefile | 91 - tests/cxx/tree/dom-association/output | 0 tests/cxx/tree/dom-association/test.xml | 7 - tests/cxx/tree/dom-association/test.xsd | 12 - tests/cxx/tree/encoding/char/iso-8859-1/driver.cxx | 74 - tests/cxx/tree/encoding/char/iso-8859-1/makefile | 86 - tests/cxx/tree/encoding/char/iso-8859-1/test.std | 10 - tests/cxx/tree/encoding/char/iso-8859-1/test.xml | 14 - tests/cxx/tree/encoding/char/iso-8859-1/test.xsd | 31 - tests/cxx/tree/encoding/char/lcp/driver.cxx | 40 - tests/cxx/tree/encoding/char/lcp/makefile | 85 - tests/cxx/tree/encoding/char/lcp/test.std | 4 - tests/cxx/tree/encoding/char/lcp/test.xml | 7 - tests/cxx/tree/encoding/char/lcp/test.xsd | 12 - tests/cxx/tree/encoding/char/makefile | 16 - tests/cxx/tree/encoding/char/utf-8/driver.cxx | 63 - tests/cxx/tree/encoding/char/utf-8/makefile | 85 - tests/cxx/tree/encoding/char/utf-8/test.std | 9 - tests/cxx/tree/encoding/char/utf-8/test.xml | 13 - tests/cxx/tree/encoding/char/utf-8/test.xsd | 31 - tests/cxx/tree/encoding/makefile | 16 - tests/cxx/tree/encoding/wchar/driver.cxx | 55 - tests/cxx/tree/encoding/wchar/makefile | 86 - tests/cxx/tree/encoding/wchar/test.std | 10 - tests/cxx/tree/encoding/wchar/test.xml | 14 - tests/cxx/tree/encoding/wchar/test.xsd | 33 - tests/cxx/tree/enumeration/ctor/driver.cxx | 30 - tests/cxx/tree/enumeration/ctor/makefile | 86 - tests/cxx/tree/enumeration/ctor/test.xsd | 41 - tests/cxx/tree/enumeration/inheritance/driver.cxx | 53 - tests/cxx/tree/enumeration/inheritance/makefile | 85 - tests/cxx/tree/enumeration/inheritance/output | 1 - tests/cxx/tree/enumeration/inheritance/test.xml | 3 - tests/cxx/tree/enumeration/inheritance/test.xsd | 22 - tests/cxx/tree/enumeration/makefile | 16 - tests/cxx/tree/float/driver.cxx | 53 - tests/cxx/tree/float/makefile | 85 - tests/cxx/tree/float/test.std | 35 - tests/cxx/tree/float/test.xml | 35 - tests/cxx/tree/float/test.xsd | 74 - tests/cxx/tree/list/ctor/driver.cxx | 50 - tests/cxx/tree/list/ctor/makefile | 86 - tests/cxx/tree/list/ctor/test.xsd | 18 - tests/cxx/tree/list/makefile | 16 - tests/cxx/tree/makefile | 43 - tests/cxx/tree/name-clash/inheritance/driver.cxx | 35 - tests/cxx/tree/name-clash/inheritance/makefile | 85 - tests/cxx/tree/name-clash/inheritance/output | 3 - tests/cxx/tree/name-clash/inheritance/test.xml | 8 - tests/cxx/tree/name-clash/inheritance/test.xsd | 53 - tests/cxx/tree/name-clash/makefile | 16 - tests/cxx/tree/naming/camel/driver.cxx | 154 - tests/cxx/tree/naming/camel/makefile | 93 - tests/cxx/tree/naming/camel/test.xsd | 31 - tests/cxx/tree/naming/java/driver.cxx | 153 - tests/cxx/tree/naming/java/makefile | 93 - tests/cxx/tree/naming/java/test.xsd | 31 - tests/cxx/tree/naming/knr/driver.cxx | 154 - tests/cxx/tree/naming/knr/makefile | 93 - tests/cxx/tree/naming/knr/test.xsd | 31 - tests/cxx/tree/naming/makefile | 16 - tests/cxx/tree/order/driver.cxx | 64 - tests/cxx/tree/order/makefile | 93 - tests/cxx/tree/order/output | 92 - tests/cxx/tree/order/test.xml | 71 - tests/cxx/tree/order/test.xsd | 130 - tests/cxx/tree/polymorphism/comparison/driver.cxx | 85 - tests/cxx/tree/polymorphism/comparison/makefile | 86 - tests/cxx/tree/polymorphism/comparison/test.xml | 7 - tests/cxx/tree/polymorphism/comparison/test.xsd | 39 - tests/cxx/tree/polymorphism/makefile | 16 - tests/cxx/tree/polymorphism/ostream/driver.cxx | 34 - tests/cxx/tree/polymorphism/ostream/makefile | 87 - tests/cxx/tree/polymorphism/ostream/output | 18 - tests/cxx/tree/polymorphism/ostream/test.xml | 10 - tests/cxx/tree/polymorphism/ostream/test.xsd | 62 - tests/cxx/tree/polymorphism/same-type/driver.cxx | 35 - tests/cxx/tree/polymorphism/same-type/makefile | 86 - tests/cxx/tree/polymorphism/same-type/output | 9 - tests/cxx/tree/polymorphism/same-type/test.xml | 10 - tests/cxx/tree/polymorphism/same-type/test.xsd | 21 - tests/cxx/tree/prefix/bar.xsd | 34 - tests/cxx/tree/prefix/driver.cxx | 34 - tests/cxx/tree/prefix/foo.xsd | 16 - tests/cxx/tree/prefix/makefile | 86 - tests/cxx/tree/prefix/output | 18 - tests/cxx/tree/prefix/test.xml | 19 - tests/cxx/tree/prefix/test.xsd | 40 - tests/cxx/tree/test-template/driver.cxx | 35 - tests/cxx/tree/test-template/makefile | 85 - tests/cxx/tree/test-template/output | 2 - tests/cxx/tree/test-template/test.xml | 7 - tests/cxx/tree/test-template/test.xsd | 12 - tests/cxx/tree/types-only/driver.cxx | 30 - tests/cxx/tree/types-only/makefile | 85 - tests/cxx/tree/types-only/test.xsd | 52 - tests/cxx/tree/union/ctor/driver.cxx | 30 - tests/cxx/tree/union/ctor/makefile | 86 - tests/cxx/tree/union/ctor/test.xsd | 14 - tests/cxx/tree/union/makefile | 16 - tests/cxx/tree/wildcard/driver.cxx | 203 - tests/cxx/tree/wildcard/makefile | 86 - tests/cxx/tree/wildcard/output | 24 - tests/cxx/tree/wildcard/test.xml | 19 - tests/cxx/tree/wildcard/test.xsd | 18 - tests/failed/test-00.xsd | 12 - tests/makefile | 14 - tests/morphing/anonymous/attribute-group/test.xsd | 31 - .../anonymous/cyclic-inclusion/includee.xsd | 18 - .../anonymous/cyclic-inclusion/includer.xsd | 18 - tests/morphing/anonymous/group/test.xsd | 29 - tests/morphing/anonymous/test-000.xsd | 20 - tests/morphing/anonymous/unstable/includee-1.xsd | 12 - tests/morphing/anonymous/unstable/includee-2.xsd | 14 - tests/morphing/anonymous/unstable/includer.xsd | 18 - tests/processing/inheritance/test-000.xsd | 22 - tests/processing/inheritance/test-001.xsd | 26 - tests/schema/anonymous/test.xsd | 143 - tests/schema/any-attribute/test.xsd | 22 - tests/schema/any-type/test.xsd | 22 - tests/schema/any/fail.xsd | 19 - tests/schema/any/test.xsd | 19 - tests/schema/attribute-group/global.xsd | 50 - tests/schema/attribute/global.xsd | 21 - tests/schema/attribute/local.xsd | 37 - tests/schema/attribute/ref.xsd | 42 - tests/schema/cardinality/test.xsd | 46 - tests/schema/chameleon/includer.xsd | 17 - tests/schema/chameleon/schemas/includee.xsd | 12 - tests/schema/enumeration/test.xsd | 89 - tests/schema/forward/test.xsd | 32 - tests/schema/group/global.xsd | 39 - tests/schema/group/test.xsd | 148 - tests/schema/import/importer.xsd | 20 - tests/schema/import/schemas/importee.xsd | 15 - tests/schema/include/includer.xsd | 17 - tests/schema/include/schemas/includee.xsd | 14 - tests/schema/inheritance/cycle.xsd | 34 - .../inheritance/sourced-forward/includee.xsd | 10 - .../inheritance/sourced-forward/includer.xsd | 14 - tests/schema/list/anonymous/test.xsd | 16 - tests/schema/list/any-simple-type/test.xsd | 12 - tests/schema/list/driver.cxx | 13 - tests/schema/list/test.xsd | 72 - tests/schema/no-namespace/test.xsd | 15 - tests/schema/recursive/test.xsd | 43 - tests/schema/ref-type/idref.xsd | 42 - tests/schema/ref-type/idrefs.xsd | 43 - tests/schema/ref-type/invalid-0.xsd | 17 - tests/schema/ref-type/invalid-1.xsd | 11 - tests/schema/restriction/test.xsd | 67 - tests/schema/union/test.xsd | 65 - version | 1 - xsd-examples/.gitignore | 32 + xsd-examples/README | 21 + xsd-examples/UNLICENSE | 24 + xsd-examples/build/.gitignore | 3 + xsd-examples/build/bootstrap.build | 9 + xsd-examples/build/root.build | 38 + xsd-examples/buildfile | 4 + xsd-examples/cxx/parser/.gitignore | 1 + xsd-examples/cxx/parser/README | 45 + xsd-examples/cxx/parser/buildfile | 4 + xsd-examples/cxx/parser/generated/.gitignore | 2 + xsd-examples/cxx/parser/generated/README | 32 + xsd-examples/cxx/parser/generated/buildfile | 32 + xsd-examples/cxx/parser/generated/library.xml | 52 + xsd-examples/cxx/parser/generated/library.xsd | 78 + xsd-examples/cxx/parser/hello/README | 28 + xsd-examples/cxx/parser/hello/buildfile | 24 + xsd-examples/cxx/parser/hello/driver.cxx | 67 + xsd-examples/cxx/parser/hello/hello.xml | 19 + xsd-examples/cxx/parser/hello/hello.xsd | 21 + xsd-examples/cxx/parser/library/README | 44 + xsd-examples/cxx/parser/library/buildfile | 25 + xsd-examples/cxx/parser/library/driver.cxx | 109 + xsd-examples/cxx/parser/library/library-pimpl.cxx | 183 + xsd-examples/cxx/parser/library/library-pimpl.hxx | 135 + xsd-examples/cxx/parser/library/library.hxx | 241 + xsd-examples/cxx/parser/library/library.map | 15 + xsd-examples/cxx/parser/library/library.xml | 52 + xsd-examples/cxx/parser/library/library.xsd | 78 + xsd-examples/cxx/parser/mixed/README | 49 + xsd-examples/cxx/parser/mixed/anchor.hxx | 33 + xsd-examples/cxx/parser/mixed/buildfile | 25 + xsd-examples/cxx/parser/mixed/driver.cxx | 100 + xsd-examples/cxx/parser/mixed/text.map | 6 + xsd-examples/cxx/parser/mixed/text.xml | 17 + xsd-examples/cxx/parser/mixed/text.xsd | 28 + xsd-examples/cxx/parser/mixin/README | 34 + xsd-examples/cxx/parser/mixin/buildfile | 25 + xsd-examples/cxx/parser/mixin/driver.cxx | 103 + xsd-examples/cxx/parser/mixin/instance.xml | 16 + xsd-examples/cxx/parser/mixin/schema.map | 7 + xsd-examples/cxx/parser/mixin/schema.xsd | 30 + xsd-examples/cxx/parser/mixin/types.hxx | 43 + xsd-examples/cxx/parser/multiroot/README | 51 + xsd-examples/cxx/parser/multiroot/balance.xml | 16 + xsd-examples/cxx/parser/multiroot/buildfile | 24 + xsd-examples/cxx/parser/multiroot/deposit.xml | 17 + xsd-examples/cxx/parser/multiroot/driver.cxx | 161 + .../cxx/parser/multiroot/protocol-pimpl.cxx | 46 + .../cxx/parser/multiroot/protocol-pimpl.hxx | 48 + xsd-examples/cxx/parser/multiroot/protocol.hxx | 61 + xsd-examples/cxx/parser/multiroot/protocol.map | 11 + xsd-examples/cxx/parser/multiroot/protocol.xsd | 50 + xsd-examples/cxx/parser/multiroot/testscript | 6 + xsd-examples/cxx/parser/multiroot/withdraw.xml | 17 + xsd-examples/cxx/parser/performance/.gitignore | 7 + xsd-examples/cxx/parser/performance/README | 46 + xsd-examples/cxx/parser/performance/buildfile | 57 + xsd-examples/cxx/parser/performance/driver.cxx | 346 + xsd-examples/cxx/parser/performance/gen.cxx | 79 + xsd-examples/cxx/parser/performance/gen.testscript | 9 + xsd-examples/cxx/parser/performance/test-50k.xml | 1 + xsd-examples/cxx/parser/performance/test.xsd | 49 + xsd-examples/cxx/parser/performance/time.cxx | 46 + xsd-examples/cxx/parser/performance/time.hxx | 110 + xsd-examples/cxx/parser/polymorphism/README | 30 + xsd-examples/cxx/parser/polymorphism/buildfile | 25 + xsd-examples/cxx/parser/polymorphism/driver.cxx | 70 + .../cxx/parser/polymorphism/supermen-pimpl.cxx | 85 + .../cxx/parser/polymorphism/supermen-pimpl.hxx | 68 + xsd-examples/cxx/parser/polymorphism/supermen.xml | 25 + xsd-examples/cxx/parser/polymorphism/supermen.xsd | 48 + xsd-examples/cxx/parser/polyroot/README | 36 + xsd-examples/cxx/parser/polyroot/batman.xml | 16 + xsd-examples/cxx/parser/polyroot/buildfile | 24 + xsd-examples/cxx/parser/polyroot/driver.cxx | 138 + xsd-examples/cxx/parser/polyroot/person.xml | 15 + xsd-examples/cxx/parser/polyroot/superman.xml | 16 + .../cxx/parser/polyroot/supermen-pimpl.cxx | 85 + .../cxx/parser/polyroot/supermen-pimpl.hxx | 64 + xsd-examples/cxx/parser/polyroot/supermen.xsd | 36 + xsd-examples/cxx/parser/polyroot/testscript | 6 + xsd-examples/cxx/parser/wildcard/README | 27 + xsd-examples/cxx/parser/wildcard/buildfile | 24 + xsd-examples/cxx/parser/wildcard/driver.cxx | 239 + xsd-examples/cxx/parser/wildcard/email.xml | 31 + xsd-examples/cxx/parser/wildcard/email.xsd | 50 + xsd-examples/cxx/tree/README | 84 + xsd-examples/cxx/tree/binary/README | 16 + xsd-examples/cxx/tree/binary/boost/.gitignore | 1 + xsd-examples/cxx/tree/binary/boost/README | 49 + .../tree/binary/boost/boost-archive-extraction.hxx | 188 + .../tree/binary/boost/boost-archive-insertion.hxx | 177 + xsd-examples/cxx/tree/binary/boost/buildfile | 32 + xsd-examples/cxx/tree/binary/boost/driver.cxx | 72 + .../cxx/tree/binary/boost/library-prologue.hxx | 9 + xsd-examples/cxx/tree/binary/boost/library.xml | 52 + xsd-examples/cxx/tree/binary/boost/library.xsd | 75 + xsd-examples/cxx/tree/binary/cdr/.gitignore | 1 + xsd-examples/cxx/tree/binary/cdr/README | 36 + xsd-examples/cxx/tree/binary/cdr/buildfile | 28 + xsd-examples/cxx/tree/binary/cdr/driver.cxx | 87 + xsd-examples/cxx/tree/binary/cdr/library.xml | 52 + xsd-examples/cxx/tree/binary/cdr/library.xsd | 75 + xsd-examples/cxx/tree/binary/xdr/.gitignore | 1 + xsd-examples/cxx/tree/binary/xdr/README | 36 + xsd-examples/cxx/tree/binary/xdr/buildfile | 30 + xsd-examples/cxx/tree/binary/xdr/driver.cxx | 148 + xsd-examples/cxx/tree/binary/xdr/library.xml | 52 + xsd-examples/cxx/tree/binary/xdr/library.xsd | 75 + xsd-examples/cxx/tree/buildfile | 6 + xsd-examples/cxx/tree/caching/.gitignore | 1 + xsd-examples/cxx/tree/caching/README | 29 + xsd-examples/cxx/tree/caching/buildfile | 27 + xsd-examples/cxx/tree/caching/driver.cxx | 165 + xsd-examples/cxx/tree/caching/library.xml | 52 + xsd-examples/cxx/tree/caching/library.xsd | 72 + xsd-examples/cxx/tree/compression/.gitignore | 2 + xsd-examples/cxx/tree/compression/README | 48 + xsd-examples/cxx/tree/compression/buildfile | 28 + .../tree/compression/compressed-format-target.cxx | 152 + .../tree/compression/compressed-format-target.hxx | 91 + .../tree/compression/compressed-input-source.cxx | 195 + .../tree/compression/compressed-input-source.hxx | 121 + xsd-examples/cxx/tree/compression/driver.cxx | 124 + xsd-examples/cxx/tree/compression/library.xml.gz | Bin 0 -> 486 bytes xsd-examples/cxx/tree/compression/library.xsd | 72 + xsd-examples/cxx/tree/compression/testscript | 4 + xsd-examples/cxx/tree/custom/README | 40 + xsd-examples/cxx/tree/custom/buildfile | 6 + xsd-examples/cxx/tree/custom/calendar/.gitignore | 2 + xsd-examples/cxx/tree/custom/calendar/README | 47 + xsd-examples/cxx/tree/custom/calendar/buildfile | 47 + xsd-examples/cxx/tree/custom/calendar/calendar.xml | 22 + xsd-examples/cxx/tree/custom/calendar/calendar.xsd | 31 + xsd-examples/cxx/tree/custom/calendar/driver.cxx | 39 + .../cxx/tree/custom/calendar/xml-schema-custom.cxx | 56 + .../cxx/tree/custom/calendar/xml-schema-custom.hxx | 33 + xsd-examples/cxx/tree/custom/comments/.gitignore | 2 + xsd-examples/cxx/tree/custom/comments/README | 57 + xsd-examples/cxx/tree/custom/comments/buildfile | 48 + .../cxx/tree/custom/comments/dom-parse.cxx | 93 + .../cxx/tree/custom/comments/dom-parse.hxx | 23 + xsd-examples/cxx/tree/custom/comments/driver.cxx | 90 + xsd-examples/cxx/tree/custom/comments/people.xml | 20 + xsd-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 | 60 + xsd-examples/cxx/tree/custom/contacts/.gitignore | 1 + xsd-examples/cxx/tree/custom/contacts/README | 40 + xsd-examples/cxx/tree/custom/contacts/buildfile | 25 + .../cxx/tree/custom/contacts/contacts-custom.cxx | 50 + .../cxx/tree/custom/contacts/contacts-custom.hxx | 43 + xsd-examples/cxx/tree/custom/contacts/contacts.xml | 20 + xsd-examples/cxx/tree/custom/contacts/contacts.xsd | 31 + xsd-examples/cxx/tree/custom/contacts/driver.cxx | 38 + xsd-examples/cxx/tree/custom/double/.gitignore | 2 + xsd-examples/cxx/tree/custom/double/README | 62 + xsd-examples/cxx/tree/custom/double/buildfile | 46 + .../cxx/tree/custom/double/double-custom.cxx | 96 + .../cxx/tree/custom/double/double-custom.hxx | 67 + xsd-examples/cxx/tree/custom/double/driver.cxx | 31 + xsd-examples/cxx/tree/custom/double/order.xsd | 25 + xsd-examples/cxx/tree/custom/mixed/.gitignore | 1 + xsd-examples/cxx/tree/custom/mixed/README | 50 + xsd-examples/cxx/tree/custom/mixed/buildfile | 30 + xsd-examples/cxx/tree/custom/mixed/driver.cxx | 122 + .../cxx/tree/custom/mixed/people-custom.cxx | 89 + .../cxx/tree/custom/mixed/people-custom.hxx | 83 + xsd-examples/cxx/tree/custom/mixed/people.xml | 38 + xsd-examples/cxx/tree/custom/mixed/people.xsd | 45 + xsd-examples/cxx/tree/custom/taxonomy/.gitignore | 2 + xsd-examples/cxx/tree/custom/taxonomy/README | 53 + xsd-examples/cxx/tree/custom/taxonomy/buildfile | 31 + xsd-examples/cxx/tree/custom/taxonomy/driver.cxx | 38 + .../cxx/tree/custom/taxonomy/people-custom-fwd.hxx | 19 + .../cxx/tree/custom/taxonomy/people-custom.cxx | 156 + .../cxx/tree/custom/taxonomy/people-custom.hxx | 105 + xsd-examples/cxx/tree/custom/taxonomy/people.xml | 26 + xsd-examples/cxx/tree/custom/taxonomy/people.xsd | 44 + xsd-examples/cxx/tree/custom/wildcard/.gitignore | 1 + xsd-examples/cxx/tree/custom/wildcard/README | 45 + xsd-examples/cxx/tree/custom/wildcard/buildfile | 27 + xsd-examples/cxx/tree/custom/wildcard/driver.cxx | 47 + .../cxx/tree/custom/wildcard/wildcard-custom.cxx | 84 + .../cxx/tree/custom/wildcard/wildcard-custom.hxx | 66 + xsd-examples/cxx/tree/custom/wildcard/wildcard.xml | 14 + xsd-examples/cxx/tree/custom/wildcard/wildcard.xsd | 25 + xsd-examples/cxx/tree/embedded/.gitignore | 3 + xsd-examples/cxx/tree/embedded/README | 48 + xsd-examples/cxx/tree/embedded/buildfile | 46 + xsd-examples/cxx/tree/embedded/driver.cxx | 183 + .../cxx/tree/embedded/grammar-input-stream.cxx | 95 + .../cxx/tree/embedded/grammar-input-stream.hxx | 40 + xsd-examples/cxx/tree/embedded/library.xml | 52 + xsd-examples/cxx/tree/embedded/library.xsd | 72 + xsd-examples/cxx/tree/embedded/xsdbin.cxx | 494 ++ xsd-examples/cxx/tree/hello/.gitignore | 1 + xsd-examples/cxx/tree/hello/README | 26 + xsd-examples/cxx/tree/hello/buildfile | 23 + xsd-examples/cxx/tree/hello/driver.cxx | 36 + xsd-examples/cxx/tree/hello/hello.xml | 19 + xsd-examples/cxx/tree/hello/hello.xsd | 52 + xsd-examples/cxx/tree/library/.gitignore | 1 + xsd-examples/cxx/tree/library/README | 32 + xsd-examples/cxx/tree/library/buildfile | 25 + xsd-examples/cxx/tree/library/driver.cxx | 130 + xsd-examples/cxx/tree/library/library.xml | 52 + xsd-examples/cxx/tree/library/library.xsd | 72 + xsd-examples/cxx/tree/messaging/.gitignore | 1 + xsd-examples/cxx/tree/messaging/README | 58 + xsd-examples/cxx/tree/messaging/balance.xml | 16 + xsd-examples/cxx/tree/messaging/buildfile | 29 + xsd-examples/cxx/tree/messaging/deposit.xml | 17 + xsd-examples/cxx/tree/messaging/dom-parse.cxx | 93 + xsd-examples/cxx/tree/messaging/dom-parse.hxx | 22 + xsd-examples/cxx/tree/messaging/dom-serialize.cxx | 64 + xsd-examples/cxx/tree/messaging/dom-serialize.hxx | 20 + xsd-examples/cxx/tree/messaging/driver.cxx | 146 + xsd-examples/cxx/tree/messaging/protocol.xsd | 53 + xsd-examples/cxx/tree/messaging/testscript | 6 + xsd-examples/cxx/tree/messaging/withdraw.xml | 17 + xsd-examples/cxx/tree/mixed/.gitignore | 1 + xsd-examples/cxx/tree/mixed/README | 45 + xsd-examples/cxx/tree/mixed/buildfile | 27 + xsd-examples/cxx/tree/mixed/driver.cxx | 122 + xsd-examples/cxx/tree/mixed/text.xml | 17 + xsd-examples/cxx/tree/mixed/text.xsd | 28 + xsd-examples/cxx/tree/multiroot/.gitignore | 1 + xsd-examples/cxx/tree/multiroot/README | 45 + xsd-examples/cxx/tree/multiroot/balance.xml | 16 + xsd-examples/cxx/tree/multiroot/buildfile | 26 + xsd-examples/cxx/tree/multiroot/deposit.xml | 17 + xsd-examples/cxx/tree/multiroot/dom-parse.cxx | 93 + xsd-examples/cxx/tree/multiroot/dom-parse.hxx | 22 + xsd-examples/cxx/tree/multiroot/driver.cxx | 124 + xsd-examples/cxx/tree/multiroot/protocol.xsd | 50 + xsd-examples/cxx/tree/multiroot/testscript | 6 + xsd-examples/cxx/tree/multiroot/withdraw.xml | 17 + xsd-examples/cxx/tree/order/README | 11 + xsd-examples/cxx/tree/order/element/.gitignore | 1 + xsd-examples/cxx/tree/order/element/README | 35 + xsd-examples/cxx/tree/order/element/buildfile | 30 + xsd-examples/cxx/tree/order/element/driver.cxx | 147 + .../cxx/tree/order/element/transactions.xml | 32 + .../cxx/tree/order/element/transactions.xsd | 58 + xsd-examples/cxx/tree/order/mixed/.gitignore | 1 + xsd-examples/cxx/tree/order/mixed/README | 45 + xsd-examples/cxx/tree/order/mixed/buildfile | 25 + xsd-examples/cxx/tree/order/mixed/driver.cxx | 89 + xsd-examples/cxx/tree/order/mixed/text.xml | 17 + xsd-examples/cxx/tree/order/mixed/text.xsd | 28 + xsd-examples/cxx/tree/performance/.gitignore | 5 + xsd-examples/cxx/tree/performance/README | 62 + xsd-examples/cxx/tree/performance/buildfile | 36 + xsd-examples/cxx/tree/performance/driver.cxx | 90 + xsd-examples/cxx/tree/performance/gen.cxx | 76 + xsd-examples/cxx/tree/performance/gen.testscript | 9 + xsd-examples/cxx/tree/performance/parsing.cxx | 172 + .../cxx/tree/performance/serialization.cxx | 132 + xsd-examples/cxx/tree/performance/test-50k.xml | 1 + xsd-examples/cxx/tree/performance/test.xsd | 49 + xsd-examples/cxx/tree/performance/time.cxx | 46 + xsd-examples/cxx/tree/performance/time.hxx | 110 + xsd-examples/cxx/tree/polymorphism/.gitignore | 1 + xsd-examples/cxx/tree/polymorphism/README | 32 + xsd-examples/cxx/tree/polymorphism/buildfile | 26 + xsd-examples/cxx/tree/polymorphism/driver.cxx | 59 + xsd-examples/cxx/tree/polymorphism/supermen.xml | 25 + xsd-examples/cxx/tree/polymorphism/supermen.xsd | 48 + xsd-examples/cxx/tree/secure/.gitignore | 1 + xsd-examples/cxx/tree/secure/README | 41 + xsd-examples/cxx/tree/secure/buildfile | 27 + xsd-examples/cxx/tree/secure/driver.cxx | 141 + xsd-examples/cxx/tree/secure/library.xml | 59 + xsd-examples/cxx/tree/secure/library.xsd | 72 + xsd-examples/cxx/tree/secure/secure-dom-parser.cxx | 24 + xsd-examples/cxx/tree/secure/secure-dom-parser.hxx | 25 + xsd-examples/cxx/tree/streaming/.gitignore | 1 + xsd-examples/cxx/tree/streaming/README | 51 + xsd-examples/cxx/tree/streaming/buildfile | 26 + xsd-examples/cxx/tree/streaming/driver.cxx | 139 + .../cxx/tree/streaming/grammar-input-stream.cxx | 96 + .../cxx/tree/streaming/grammar-input-stream.hxx | 41 + xsd-examples/cxx/tree/streaming/parser.cxx | 371 ++ xsd-examples/cxx/tree/streaming/parser.hxx | 67 + xsd-examples/cxx/tree/streaming/position.xml | 29 + xsd-examples/cxx/tree/streaming/position.xsd | 37 + xsd-examples/cxx/tree/streaming/serializer.cxx | 636 ++ xsd-examples/cxx/tree/streaming/serializer.hxx | 209 + xsd-examples/cxx/tree/streaming/testscript | 10 + xsd-examples/cxx/tree/wildcard/.gitignore | 1 + xsd-examples/cxx/tree/wildcard/README | 34 + xsd-examples/cxx/tree/wildcard/buildfile | 30 + xsd-examples/cxx/tree/wildcard/driver.cxx | 159 + xsd-examples/cxx/tree/wildcard/email.xml | 31 + xsd-examples/cxx/tree/wildcard/email.xsd | 50 + xsd-examples/cxx/tree/xpath/.gitignore | 1 + xsd-examples/cxx/tree/xpath/README | 43 + xsd-examples/cxx/tree/xpath/buildfile | 28 + xsd-examples/cxx/tree/xpath/dom-parse.cxx | 88 + xsd-examples/cxx/tree/xpath/dom-parse.hxx | 25 + xsd-examples/cxx/tree/xpath/driver.cxx | 137 + xsd-examples/cxx/tree/xpath/people.xml | 28 + xsd-examples/cxx/tree/xpath/people.xsd | 38 + xsd-examples/manifest | 17 + xsd-tests/.gitignore | 32 + xsd-tests/FLOSSE | 1 + xsd-tests/GPLv2 | 1 + xsd-tests/LICENSE | 1 + xsd-tests/README | 8 + xsd-tests/build/.gitignore | 3 + xsd-tests/build/bootstrap.build | 9 + xsd-tests/build/root.build | 40 + xsd-tests/buildfile | 4 + xsd-tests/clash/.gitignore | 2 + xsd-tests/clash/buildfile | 27 + xsd-tests/clash/clash.xsd | 25 + xsd-tests/clash/driver.cxx | 10 + xsd-tests/clash/foo.xsd | 11 + xsd-tests/code/name-conflict/buildfile | 22 + xsd-tests/code/name-conflict/driver.cxx | 9 + xsd-tests/code/name-conflict/test.xsd | 40 + xsd-tests/code/name-escaping/buildfile | 22 + xsd-tests/code/name-escaping/driver.cxx | 9 + xsd-tests/code/name-escaping/test.xsd | 60 + xsd-tests/cxx/parser/.gitignore | 1 + xsd-tests/cxx/parser/built-in/buildfile | 23 + xsd-tests/cxx/parser/built-in/driver.cxx | 529 ++ xsd-tests/cxx/parser/built-in/output | 164 + xsd-tests/cxx/parser/built-in/test.xml | 199 + xsd-tests/cxx/parser/built-in/test.xsd | 63 + xsd-tests/cxx/parser/enumeration/buildfile | 24 + xsd-tests/cxx/parser/enumeration/driver.cxx | 81 + xsd-tests/cxx/parser/enumeration/gender.hxx | 13 + xsd-tests/cxx/parser/enumeration/output | 3 + xsd-tests/cxx/parser/enumeration/test.map | 7 + xsd-tests/cxx/parser/enumeration/test.xml | 10 + xsd-tests/cxx/parser/enumeration/test.xsd | 35 + xsd-tests/cxx/parser/generated-impl/.gitignore | 2 + xsd-tests/cxx/parser/generated-impl/buildfile | 31 + xsd-tests/cxx/parser/generated-impl/output | 122 + xsd-tests/cxx/parser/generated-impl/test.xml | 168 + xsd-tests/cxx/parser/generated-impl/test.xsd | 142 + xsd-tests/cxx/parser/list/buildfile | 23 + xsd-tests/cxx/parser/list/driver.cxx | 105 + xsd-tests/cxx/parser/list/output | 26 + xsd-tests/cxx/parser/list/test.xml | 25 + xsd-tests/cxx/parser/list/test.xsd | 25 + .../cxx/parser/name-clash/inheritance/buildfile | 24 + .../cxx/parser/name-clash/inheritance/driver.cxx | 62 + xsd-tests/cxx/parser/name-clash/inheritance/output | 2 + .../cxx/parser/name-clash/inheritance/test.xml | 8 + .../cxx/parser/name-clash/inheritance/test.xsd | 22 + .../cxx/parser/polymorphism/recursive/buildfile | 24 + .../cxx/parser/polymorphism/recursive/driver.cxx | 68 + xsd-tests/cxx/parser/polymorphism/recursive/output | 22 + .../parser/polymorphism/recursive/test-pimpl.cxx | 147 + .../parser/polymorphism/recursive/test-pimpl.hxx | 94 + .../cxx/parser/polymorphism/recursive/test.xml | 15 + .../cxx/parser/polymorphism/recursive/test.xsd | 53 + .../cxx/parser/polymorphism/same-type/buildfile | 24 + .../cxx/parser/polymorphism/same-type/driver.cxx | 62 + xsd-tests/cxx/parser/polymorphism/same-type/output | 4 + .../cxx/parser/polymorphism/same-type/test.xml | 10 + .../cxx/parser/polymorphism/same-type/test.xsd | 21 + xsd-tests/cxx/parser/recursive/buildfile | 24 + xsd-tests/cxx/parser/recursive/driver.cxx | 139 + xsd-tests/cxx/parser/recursive/output | 22 + xsd-tests/cxx/parser/recursive/test.xml | 11 + xsd-tests/cxx/parser/recursive/test.xsd | 27 + xsd-tests/cxx/parser/test-template/buildfile | 23 + xsd-tests/cxx/parser/test-template/driver.cxx | 66 + xsd-tests/cxx/parser/test-template/output | 1 + xsd-tests/cxx/parser/test-template/test.xml | 7 + xsd-tests/cxx/parser/test-template/test.xsd | 12 + xsd-tests/cxx/parser/union/buildfile | 23 + xsd-tests/cxx/parser/union/driver.cxx | 60 + xsd-tests/cxx/parser/union/output | 2 + xsd-tests/cxx/parser/union/test.xml | 10 + xsd-tests/cxx/parser/union/test.xsd | 16 + xsd-tests/cxx/parser/validation/all/buildfile | 22 + xsd-tests/cxx/parser/validation/all/driver.cxx | 98 + xsd-tests/cxx/parser/validation/all/test.xsd | 20 + xsd-tests/cxx/parser/validation/all/testscript | 190 + xsd-tests/cxx/parser/validation/any/buildfile | 24 + xsd-tests/cxx/parser/validation/any/driver.cxx | 121 + xsd-tests/cxx/parser/validation/any/output | 29 + xsd-tests/cxx/parser/validation/any/test.xml | 21 + xsd-tests/cxx/parser/validation/any/test.xsd | 20 + .../cxx/parser/validation/attribute/buildfile | 24 + .../cxx/parser/validation/attribute/driver.cxx | 197 + xsd-tests/cxx/parser/validation/attribute/output | 24 + xsd-tests/cxx/parser/validation/attribute/test.xml | 10 + xsd-tests/cxx/parser/validation/attribute/test.xsd | 71 + .../parser/validation/built-in/any-type/buildfile | 24 + .../parser/validation/built-in/any-type/driver.cxx | 154 + .../cxx/parser/validation/built-in/any-type/output | 99 + .../parser/validation/built-in/any-type/test.xml | 41 + .../parser/validation/built-in/any-type/test.xsd | 31 + .../parser/validation/built-in/binary/buildfile | 10 + .../parser/validation/built-in/binary/driver.cxx | 153 + .../parser/validation/built-in/boolean/buildfile | 10 + .../parser/validation/built-in/boolean/driver.cxx | 145 + .../cxx/parser/validation/built-in/byte/buildfile | 10 + .../cxx/parser/validation/built-in/byte/driver.cxx | 256 + .../parser/validation/built-in/date-time/buildfile | 10 + .../validation/built-in/date-time/driver.cxx | 1533 +++++ .../cxx/parser/validation/built-in/float/buildfile | 10 + .../parser/validation/built-in/float/driver.cxx | 285 + .../cxx/parser/validation/built-in/int/buildfile | 10 + .../cxx/parser/validation/built-in/int/driver.cxx | 116 + .../parser/validation/built-in/integer/buildfile | 10 + .../parser/validation/built-in/integer/driver.cxx | 303 + .../cxx/parser/validation/built-in/long/buildfile | 10 + .../cxx/parser/validation/built-in/long/driver.cxx | 116 + .../cxx/parser/validation/built-in/qname/buildfile | 10 + .../parser/validation/built-in/qname/driver.cxx | 105 + .../cxx/parser/validation/built-in/short/buildfile | 10 + .../parser/validation/built-in/short/driver.cxx | 116 + .../parser/validation/built-in/string/buildfile | 10 + .../parser/validation/built-in/string/driver.cxx | 512 ++ .../cxx/parser/validation/built-in/uri/buildfile | 10 + .../cxx/parser/validation/built-in/uri/driver.cxx | 53 + xsd-tests/cxx/parser/validation/choice/buildfile | 22 + xsd-tests/cxx/parser/validation/choice/driver.cxx | 126 + xsd-tests/cxx/parser/validation/choice/test.xsd | 24 + xsd-tests/cxx/parser/validation/choice/testscript | 179 + .../cxx/parser/validation/restriction/buildfile | 22 + .../cxx/parser/validation/restriction/driver.cxx | 107 + .../cxx/parser/validation/restriction/test.xsd | 82 + .../cxx/parser/validation/restriction/testscript | 159 + xsd-tests/cxx/parser/validation/sequence/buildfile | 22 + .../cxx/parser/validation/sequence/driver.cxx | 139 + xsd-tests/cxx/parser/validation/sequence/test.xsd | 28 + .../cxx/parser/validation/sequence/testscript | 328 + xsd-tests/cxx/tree/any-type/buildfile | 26 + xsd-tests/cxx/tree/any-type/driver.cxx | 144 + xsd-tests/cxx/tree/any-type/output | 73 + xsd-tests/cxx/tree/any-type/test.xml | 26 + xsd-tests/cxx/tree/any-type/test.xsd | 19 + xsd-tests/cxx/tree/binary/cdr/buildfile | 25 + xsd-tests/cxx/tree/binary/cdr/driver.cxx | 143 + xsd-tests/cxx/tree/binary/cdr/test.xml | 93 + xsd-tests/cxx/tree/binary/cdr/test.xsd | 123 + xsd-tests/cxx/tree/binary/polymorphic/buildfile | 27 + xsd-tests/cxx/tree/binary/polymorphic/driver.cxx | 164 + xsd-tests/cxx/tree/binary/polymorphic/test.xml | 92 + xsd-tests/cxx/tree/binary/polymorphic/test.xsd | 125 + xsd-tests/cxx/tree/binary/xdr-ordered/buildfile | 28 + xsd-tests/cxx/tree/binary/xdr-ordered/driver.cxx | 206 + xsd-tests/cxx/tree/binary/xdr-ordered/test.xml | 93 + xsd-tests/cxx/tree/binary/xdr-ordered/test.xsd | 123 + xsd-tests/cxx/tree/binary/xdr/buildfile | 27 + xsd-tests/cxx/tree/binary/xdr/driver.cxx | 204 + xsd-tests/cxx/tree/binary/xdr/test.xml | 93 + xsd-tests/cxx/tree/binary/xdr/test.xsd | 123 + xsd-tests/cxx/tree/buildfile | 6 + xsd-tests/cxx/tree/built-in/.gitignore | 1 + xsd-tests/cxx/tree/built-in/buildfile | 25 + xsd-tests/cxx/tree/built-in/driver.cxx | 93 + xsd-tests/cxx/tree/built-in/testscript | 394 ++ xsd-tests/cxx/tree/built-in/types.xsd | 460 ++ xsd-tests/cxx/tree/chameleon/.gitignore | 1 + xsd-tests/cxx/tree/chameleon/buildfile | 24 + xsd-tests/cxx/tree/chameleon/driver.cxx | 35 + xsd-tests/cxx/tree/chameleon/includee.xsd | 13 + xsd-tests/cxx/tree/chameleon/includer.xsd | 12 + xsd-tests/cxx/tree/chameleon/output | 3 + xsd-tests/cxx/tree/chameleon/test.xml | 8 + xsd-tests/cxx/tree/comparison/buildfile | 22 + xsd-tests/cxx/tree/comparison/driver.cxx | 38 + xsd-tests/cxx/tree/comparison/test.xml | 19 + xsd-tests/cxx/tree/comparison/test.xsd | 30 + xsd-tests/cxx/tree/compilation/buildfile | 20 + xsd-tests/cxx/tree/compilation/driver.cxx | 116 + xsd-tests/cxx/tree/compilation/test.xsd | 12 + xsd-tests/cxx/tree/complex/ctor/buildfile | 25 + xsd-tests/cxx/tree/complex/ctor/driver.cxx | 122 + xsd-tests/cxx/tree/complex/ctor/test.xsd | 182 + xsd-tests/cxx/tree/containment/buildfile | 20 + xsd-tests/cxx/tree/containment/driver.cxx | 118 + xsd-tests/cxx/tree/containment/test.xsd | 59 + xsd-tests/cxx/tree/default/general/buildfile | 26 + xsd-tests/cxx/tree/default/general/driver.cxx | 37 + xsd-tests/cxx/tree/default/general/output | 15 + xsd-tests/cxx/tree/default/general/test.xml | 16 + xsd-tests/cxx/tree/default/general/test.xsd | 241 + xsd-tests/cxx/tree/default/omit/buildfile | 27 + xsd-tests/cxx/tree/default/omit/driver.cxx | 46 + xsd-tests/cxx/tree/default/omit/output | 19 + xsd-tests/cxx/tree/default/omit/test.xml | 9 + xsd-tests/cxx/tree/default/omit/test.xsd | 30 + xsd-tests/cxx/tree/detach/buildfile | 21 + xsd-tests/cxx/tree/detach/driver.cxx | 108 + xsd-tests/cxx/tree/detach/test.xsd | 32 + xsd-tests/cxx/tree/dom-association/buildfile | 27 + xsd-tests/cxx/tree/dom-association/dom-parse.cxx | 95 + xsd-tests/cxx/tree/dom-association/dom-parse.hxx | 23 + xsd-tests/cxx/tree/dom-association/driver.cxx | 71 + xsd-tests/cxx/tree/dom-association/output | 0 xsd-tests/cxx/tree/dom-association/test.xml | 7 + xsd-tests/cxx/tree/dom-association/test.xsd | 12 + .../cxx/tree/encoding/char/iso-8859-1/buildfile | 25 + .../cxx/tree/encoding/char/iso-8859-1/driver.cxx | 74 + xsd-tests/cxx/tree/encoding/char/iso-8859-1/output | 10 + .../cxx/tree/encoding/char/iso-8859-1/test.xml | 14 + .../cxx/tree/encoding/char/iso-8859-1/test.xsd | 31 + xsd-tests/cxx/tree/encoding/char/lcp/buildfile | 24 + xsd-tests/cxx/tree/encoding/char/lcp/driver.cxx | 40 + xsd-tests/cxx/tree/encoding/char/lcp/output | 4 + xsd-tests/cxx/tree/encoding/char/lcp/test.xml | 7 + xsd-tests/cxx/tree/encoding/char/lcp/test.xsd | 12 + xsd-tests/cxx/tree/encoding/char/utf-8/buildfile | 24 + xsd-tests/cxx/tree/encoding/char/utf-8/driver.cxx | 63 + xsd-tests/cxx/tree/encoding/char/utf-8/output | 9 + xsd-tests/cxx/tree/encoding/char/utf-8/test.xml | 13 + xsd-tests/cxx/tree/encoding/char/utf-8/test.xsd | 31 + xsd-tests/cxx/tree/encoding/wchar/buildfile | 25 + xsd-tests/cxx/tree/encoding/wchar/driver.cxx | 55 + xsd-tests/cxx/tree/encoding/wchar/output | 10 + xsd-tests/cxx/tree/encoding/wchar/test.xml | 14 + xsd-tests/cxx/tree/encoding/wchar/test.xsd | 33 + xsd-tests/cxx/tree/enumeration/ctor/buildfile | 22 + xsd-tests/cxx/tree/enumeration/ctor/driver.cxx | 30 + xsd-tests/cxx/tree/enumeration/ctor/test.xsd | 41 + .../cxx/tree/enumeration/inheritance/buildfile | 23 + .../cxx/tree/enumeration/inheritance/driver.cxx | 53 + xsd-tests/cxx/tree/enumeration/inheritance/output | 1 + .../cxx/tree/enumeration/inheritance/test.xml | 3 + .../cxx/tree/enumeration/inheritance/test.xsd | 22 + xsd-tests/cxx/tree/float/buildfile | 24 + xsd-tests/cxx/tree/float/driver.cxx | 53 + xsd-tests/cxx/tree/float/output | 35 + xsd-tests/cxx/tree/float/test.xml | 35 + xsd-tests/cxx/tree/float/test.xsd | 74 + xsd-tests/cxx/tree/list/ctor/buildfile | 22 + xsd-tests/cxx/tree/list/ctor/driver.cxx | 50 + xsd-tests/cxx/tree/list/ctor/test.xsd | 18 + .../cxx/tree/name-clash/inheritance/buildfile | 23 + .../cxx/tree/name-clash/inheritance/driver.cxx | 35 + xsd-tests/cxx/tree/name-clash/inheritance/output | 3 + xsd-tests/cxx/tree/name-clash/inheritance/test.xml | 8 + xsd-tests/cxx/tree/name-clash/inheritance/test.xsd | 53 + xsd-tests/cxx/tree/naming/camel/buildfile | 25 + xsd-tests/cxx/tree/naming/camel/driver.cxx | 154 + xsd-tests/cxx/tree/naming/camel/test.xsd | 31 + xsd-tests/cxx/tree/naming/java/buildfile | 25 + xsd-tests/cxx/tree/naming/java/driver.cxx | 153 + xsd-tests/cxx/tree/naming/java/test.xsd | 31 + xsd-tests/cxx/tree/naming/knr/buildfile | 25 + xsd-tests/cxx/tree/naming/knr/driver.cxx | 154 + xsd-tests/cxx/tree/naming/knr/test.xsd | 31 + xsd-tests/cxx/tree/order/buildfile | 37 + xsd-tests/cxx/tree/order/driver.cxx | 64 + xsd-tests/cxx/tree/order/output | 92 + xsd-tests/cxx/tree/order/test.xml | 71 + xsd-tests/cxx/tree/order/test.xsd | 130 + .../cxx/tree/polymorphism/comparison/buildfile | 25 + .../cxx/tree/polymorphism/comparison/driver.cxx | 85 + .../cxx/tree/polymorphism/comparison/test.xml | 7 + .../cxx/tree/polymorphism/comparison/test.xsd | 39 + xsd-tests/cxx/tree/polymorphism/ostream/buildfile | 26 + xsd-tests/cxx/tree/polymorphism/ostream/driver.cxx | 34 + xsd-tests/cxx/tree/polymorphism/ostream/output | 18 + xsd-tests/cxx/tree/polymorphism/ostream/test.xml | 10 + xsd-tests/cxx/tree/polymorphism/ostream/test.xsd | 62 + .../cxx/tree/polymorphism/same-type/buildfile | 25 + .../cxx/tree/polymorphism/same-type/driver.cxx | 35 + xsd-tests/cxx/tree/polymorphism/same-type/output | 9 + xsd-tests/cxx/tree/polymorphism/same-type/test.xml | 10 + xsd-tests/cxx/tree/polymorphism/same-type/test.xsd | 21 + xsd-tests/cxx/tree/prefix/.gitignore | 2 + xsd-tests/cxx/tree/prefix/bar.xsd | 34 + xsd-tests/cxx/tree/prefix/buildfile | 31 + xsd-tests/cxx/tree/prefix/driver.cxx | 34 + xsd-tests/cxx/tree/prefix/foo.xsd | 16 + xsd-tests/cxx/tree/prefix/output | 18 + xsd-tests/cxx/tree/prefix/test.xml | 19 + xsd-tests/cxx/tree/prefix/test.xsd | 40 + xsd-tests/cxx/tree/test-template/buildfile | 23 + xsd-tests/cxx/tree/test-template/driver.cxx | 35 + xsd-tests/cxx/tree/test-template/output | 2 + xsd-tests/cxx/tree/test-template/test.xml | 7 + xsd-tests/cxx/tree/test-template/test.xsd | 12 + xsd-tests/cxx/tree/types-only/buildfile | 20 + xsd-tests/cxx/tree/types-only/driver.cxx | 30 + xsd-tests/cxx/tree/types-only/test.xsd | 52 + xsd-tests/cxx/tree/union/ctor/buildfile | 22 + xsd-tests/cxx/tree/union/ctor/driver.cxx | 30 + xsd-tests/cxx/tree/union/ctor/test.xsd | 14 + xsd-tests/cxx/tree/wildcard/buildfile | 27 + xsd-tests/cxx/tree/wildcard/driver.cxx | 203 + xsd-tests/cxx/tree/wildcard/output | 24 + xsd-tests/cxx/tree/wildcard/test.xml | 19 + xsd-tests/cxx/tree/wildcard/test.xsd | 18 + xsd-tests/failed/.gitignore | 1 + xsd-tests/failed/buildfile | 27 + xsd-tests/failed/driver.cxx | 9 + xsd-tests/failed/test-00.xsd | 12 + xsd-tests/manifest | 15 + .../morphing/anonymous/attribute-group/buildfile | 22 + .../morphing/anonymous/attribute-group/driver.cxx | 9 + .../morphing/anonymous/attribute-group/test.xsd | 31 + xsd-tests/morphing/anonymous/basic/buildfile | 22 + xsd-tests/morphing/anonymous/basic/driver.cxx | 9 + xsd-tests/morphing/anonymous/basic/test.xsd | 20 + .../morphing/anonymous/cyclic-inclusion/.gitignore | 2 + .../morphing/anonymous/cyclic-inclusion/buildfile | 27 + .../morphing/anonymous/cyclic-inclusion/driver.cxx | 10 + .../anonymous/cyclic-inclusion/includee.xsd | 18 + .../anonymous/cyclic-inclusion/includer.xsd | 18 + xsd-tests/morphing/anonymous/group/buildfile | 22 + xsd-tests/morphing/anonymous/group/driver.cxx | 9 + xsd-tests/morphing/anonymous/group/test.xsd | 29 + xsd-tests/morphing/anonymous/unstable/.gitignore | 1 + xsd-tests/morphing/anonymous/unstable/buildfile | 31 + .../morphing/anonymous/unstable/includee-1.xsd | 12 + .../morphing/anonymous/unstable/includee-2.xsd | 14 + xsd-tests/morphing/anonymous/unstable/includer.xsd | 18 + xsd-tests/morphing/anonymous/unstable/testscript | 11 + xsd-tests/processing/inheritance/.gitignore | 3 + xsd-tests/processing/inheritance/buildfile | 36 + xsd-tests/processing/inheritance/driver.cxx.in | 9 + xsd-tests/processing/inheritance/test-000.xsd | 22 + xsd-tests/processing/inheritance/test-001.xsd | 26 + xsd-tests/schema/anonymous/buildfile | 22 + xsd-tests/schema/anonymous/driver.cxx | 9 + xsd-tests/schema/anonymous/test.xsd | 143 + xsd-tests/schema/any-attribute/buildfile | 12 + xsd-tests/schema/any-attribute/test.xsd | 22 + xsd-tests/schema/any-attribute/testscript | 8 + xsd-tests/schema/any-type/buildfile | 24 + xsd-tests/schema/any-type/driver.cxx | 9 + xsd-tests/schema/any-type/test.xsd | 22 + xsd-tests/schema/any/.gitignore | 5 + xsd-tests/schema/any/buildfile | 47 + xsd-tests/schema/any/driver.cxx.in | 9 + xsd-tests/schema/any/fail.xsd | 19 + xsd-tests/schema/any/test.xsd | 19 + xsd-tests/schema/attribute-group/.gitignore | 1 + xsd-tests/schema/attribute-group/buildfile | 22 + xsd-tests/schema/attribute-group/driver.cxx | 9 + xsd-tests/schema/attribute-group/global.xsd | 50 + xsd-tests/schema/attribute/.gitignore | 3 + xsd-tests/schema/attribute/buildfile | 27 + xsd-tests/schema/attribute/driver.cxx | 11 + xsd-tests/schema/attribute/global.xsd | 21 + xsd-tests/schema/attribute/local.xsd | 37 + xsd-tests/schema/attribute/ref.xsd | 42 + xsd-tests/schema/cardinality/buildfile | 22 + xsd-tests/schema/cardinality/driver.cxx | 9 + xsd-tests/schema/cardinality/test.xsd | 46 + xsd-tests/schema/chameleon/.gitignore | 1 + xsd-tests/schema/chameleon/buildfile | 27 + xsd-tests/schema/chameleon/driver.cxx | 10 + xsd-tests/schema/chameleon/includer.xsd | 17 + xsd-tests/schema/chameleon/schemas/.gitignore | 1 + xsd-tests/schema/chameleon/schemas/includee.xsd | 12 + xsd-tests/schema/enumeration/buildfile | 22 + xsd-tests/schema/enumeration/driver.cxx | 9 + xsd-tests/schema/enumeration/test.xsd | 89 + xsd-tests/schema/forward/buildfile | 22 + xsd-tests/schema/forward/driver.cxx | 9 + xsd-tests/schema/forward/test.xsd | 32 + xsd-tests/schema/group/.gitignore | 1 + xsd-tests/schema/group/buildfile | 27 + xsd-tests/schema/group/driver.cxx | 10 + xsd-tests/schema/group/global.xsd | 39 + xsd-tests/schema/group/test.xsd | 148 + xsd-tests/schema/import/.gitignore | 1 + xsd-tests/schema/import/buildfile | 27 + xsd-tests/schema/import/driver.cxx | 9 + xsd-tests/schema/import/importer.xsd | 20 + xsd-tests/schema/import/schemas/.gitignore | 1 + xsd-tests/schema/import/schemas/importee.xsd | 15 + xsd-tests/schema/include/.gitignore | 1 + xsd-tests/schema/include/buildfile | 27 + xsd-tests/schema/include/driver.cxx | 9 + xsd-tests/schema/include/includer.xsd | 17 + xsd-tests/schema/include/schemas/.gitignore | 1 + xsd-tests/schema/include/schemas/includee.xsd | 14 + xsd-tests/schema/inheritance/.gitignore | 1 + xsd-tests/schema/inheritance/buildfile | 30 + xsd-tests/schema/inheritance/cycle.xsd | 34 + .../schema/inheritance/sourced-forward/.gitignore | 1 + .../inheritance/sourced-forward/includee.xsd | 10 + .../inheritance/sourced-forward/includer.xsd | 14 + xsd-tests/schema/inheritance/testscript | 8 + xsd-tests/schema/list/anonymous/test.xsd | 16 + xsd-tests/schema/list/any-simple-type/test.xsd | 12 + xsd-tests/schema/list/buildfile | 31 + xsd-tests/schema/list/test.xsd | 72 + xsd-tests/schema/list/testscript | 8 + xsd-tests/schema/no-namespace/buildfile | 22 + xsd-tests/schema/no-namespace/driver.cxx | 9 + xsd-tests/schema/no-namespace/test.xsd | 15 + xsd-tests/schema/recursive/buildfile | 22 + xsd-tests/schema/recursive/driver.cxx | 9 + xsd-tests/schema/recursive/test.xsd | 43 + xsd-tests/schema/ref-type/invalid/buildfile | 12 + xsd-tests/schema/ref-type/invalid/invalid-0.xsd | 17 + xsd-tests/schema/ref-type/invalid/invalid-1.xsd | 11 + xsd-tests/schema/ref-type/invalid/testscript | 16 + xsd-tests/schema/ref-type/valid/.gitignore | 6 + xsd-tests/schema/ref-type/valid/buildfile | 35 + xsd-tests/schema/ref-type/valid/driver.cxx.in | 9 + xsd-tests/schema/ref-type/valid/idref.xsd | 42 + xsd-tests/schema/ref-type/valid/idrefs.xsd | 43 + xsd-tests/schema/restriction/buildfile | 22 + xsd-tests/schema/restriction/driver.cxx | 9 + xsd-tests/schema/restriction/test.xsd | 67 + xsd-tests/schema/union/buildfile | 22 + xsd-tests/schema/union/driver.cxx | 9 + xsd-tests/schema/union/test.xsd | 65 + xsd/.gitignore | 19 + xsd/FLOSSE | 1 + xsd/GPLv2 | 1 + xsd/INSTALL | 6 + xsd/LICENSE | 1 + xsd/NEWS | 1220 ++++ xsd/README | 27 + xsd/build/.gitignore | 3 + xsd/build/bootstrap.build | 9 + xsd/build/export.build | 9 + xsd/build/root.build | 37 + xsd/buildfile | 8 + xsd/cxx/elements.cxx | 1319 ---- xsd/cxx/elements.hxx | 626 -- xsd/cxx/literal-map.cxx | 261 - xsd/cxx/literal-map.hxx | 19 - xsd/cxx/option-types.cxx | 47 - xsd/cxx/option-types.hxx | 34 - xsd/cxx/options.cli | 550 -- xsd/cxx/parser/attribute-validation-source.cxx | 412 -- xsd/cxx/parser/attribute-validation-source.hxx | 18 - xsd/cxx/parser/characters-validation-source.cxx | 73 - xsd/cxx/parser/characters-validation-source.hxx | 18 - xsd/cxx/parser/driver-source.cxx | 775 --- xsd/cxx/parser/driver-source.hxx | 18 - xsd/cxx/parser/element-validation-source.cxx | 1600 ----- xsd/cxx/parser/element-validation-source.hxx | 18 - xsd/cxx/parser/elements.cxx | 247 - xsd/cxx/parser/elements.hxx | 315 - xsd/cxx/parser/generator.cxx | 1099 ---- xsd/cxx/parser/generator.hxx | 45 - xsd/cxx/parser/impl-header.cxx | 232 - xsd/cxx/parser/impl-header.hxx | 18 - xsd/cxx/parser/impl-source.cxx | 384 -- xsd/cxx/parser/impl-source.hxx | 18 - xsd/cxx/parser/name-processor.cxx | 1175 ---- xsd/cxx/parser/name-processor.hxx | 30 - xsd/cxx/parser/options.cli | 147 - xsd/cxx/parser/parser-forward.cxx | 110 - xsd/cxx/parser/parser-forward.hxx | 18 - xsd/cxx/parser/parser-header.cxx | 1440 ----- xsd/cxx/parser/parser-header.hxx | 18 - xsd/cxx/parser/parser-inline.cxx | 399 -- xsd/cxx/parser/parser-inline.hxx | 18 - xsd/cxx/parser/parser-source.cxx | 957 --- xsd/cxx/parser/parser-source.hxx | 18 - xsd/cxx/parser/print-impl-common.hxx | 641 -- xsd/cxx/parser/state-processor.cxx | 319 - xsd/cxx/parser/state-processor.hxx | 25 - xsd/cxx/parser/type-processor.cxx | 347 - xsd/cxx/parser/type-processor.hxx | 31 - xsd/cxx/parser/validator.cxx | 718 -- xsd/cxx/parser/validator.hxx | 30 - xsd/cxx/tree/counter.cxx | 260 - xsd/cxx/tree/counter.hxx | 25 - xsd/cxx/tree/default-value.cxx | 1273 ---- xsd/cxx/tree/default-value.hxx | 355 - xsd/cxx/tree/elements.cxx | 1409 ---- xsd/cxx/tree/elements.hxx | 2118 ------ xsd/cxx/tree/fundamental-header.hxx | 1335 ---- xsd/cxx/tree/generator.cxx | 1227 ---- xsd/cxx/tree/generator.hxx | 44 - xsd/cxx/tree/name-processor.cxx | 2399 ------- xsd/cxx/tree/name-processor.hxx | 28 - xsd/cxx/tree/options.cli | 479 -- xsd/cxx/tree/order-processor.cxx | 243 - xsd/cxx/tree/order-processor.hxx | 29 - xsd/cxx/tree/parser-header.cxx | 472 -- xsd/cxx/tree/parser-header.hxx | 19 - xsd/cxx/tree/parser-source.cxx | 541 -- xsd/cxx/tree/parser-source.hxx | 18 - xsd/cxx/tree/polymorphism-processor.cxx | 740 --- xsd/cxx/tree/polymorphism-processor.hxx | 30 - xsd/cxx/tree/serialization-header.cxx | 579 -- xsd/cxx/tree/serialization-header.hxx | 18 - xsd/cxx/tree/serialization-source.cxx | 1468 ----- xsd/cxx/tree/serialization-source.hxx | 18 - xsd/cxx/tree/stream-extraction-source.cxx | 864 --- xsd/cxx/tree/stream-extraction-source.hxx | 18 - xsd/cxx/tree/stream-header.cxx | 181 - xsd/cxx/tree/stream-header.hxx | 18 - xsd/cxx/tree/stream-insertion-header.cxx | 178 - xsd/cxx/tree/stream-insertion-header.hxx | 18 - xsd/cxx/tree/stream-insertion-source.cxx | 623 -- xsd/cxx/tree/stream-insertion-source.hxx | 18 - xsd/cxx/tree/stream-source.cxx | 496 -- xsd/cxx/tree/stream-source.hxx | 18 - xsd/cxx/tree/tree-forward.cxx | 325 - xsd/cxx/tree/tree-forward.hxx | 18 - xsd/cxx/tree/tree-header.cxx | 4299 ------------ xsd/cxx/tree/tree-header.hxx | 18 - xsd/cxx/tree/tree-inline.cxx | 1161 ---- xsd/cxx/tree/tree-inline.hxx | 18 - xsd/cxx/tree/tree-source.cxx | 3900 ----------- xsd/cxx/tree/tree-source.hxx | 18 - xsd/cxx/tree/validator.cxx | 671 -- xsd/cxx/tree/validator.hxx | 29 - xsd/doc/.gitignore | 2 + xsd/doc/buildfile | 187 + xsd/doc/custom-literals.xsd | 48 + xsd/doc/cxx/.gitignore | 2 + xsd/doc/cxx/parser/guide/.gitignore | 2 + xsd/doc/cxx/parser/guide/figure-1.png | Bin 0 -> 34195 bytes xsd/doc/cxx/parser/guide/figure-1.svg | 373 ++ xsd/doc/cxx/parser/guide/guide.html2ps.in | 65 + xsd/doc/cxx/parser/guide/index.xhtml.in | 4164 ++++++++++++ xsd/doc/cxx/tree/guide/.gitignore | 2 + xsd/doc/cxx/tree/guide/guide.html2ps.in | 65 + xsd/doc/cxx/tree/guide/index.xhtml.in | 2738 ++++++++ xsd/doc/cxx/tree/manual/.gitignore | 2 + xsd/doc/cxx/tree/manual/index.xhtml.in | 6826 ++++++++++++++++++++ xsd/doc/cxx/tree/manual/manual.html2ps.in | 66 + xsd/doc/default.css | 319 + xsd/doc/xsd-epilogue.1 | 566 ++ xsd/doc/xsd-epilogue.xhtml | 422 ++ xsd/doc/xsd-parser-header.1 | 4 + xsd/doc/xsd-parser-header.xhtml | 1 + xsd/doc/xsd-prologue.1 | 119 + xsd/doc/xsd-prologue.xhtml | 123 + xsd/doc/xsd-tree-header.1 | 4 + xsd/doc/xsd-tree-header.xhtml | 1 + xsd/elements.hxx | 125 - xsd/makefile | 190 - xsd/manifest | 23 + xsd/options-parser.hxx | 29 - xsd/options.cli | 312 - xsd/processing/cardinality/processor.cxx | 407 -- xsd/processing/cardinality/processor.hxx | 28 - xsd/processing/inheritance/processor.cxx | 492 -- xsd/processing/inheritance/processor.hxx | 28 - xsd/type-map/lexer.cxx | 131 - xsd/type-map/lexer.hxx | 74 - xsd/type-map/parser.cxx | 279 - xsd/type-map/parser.hxx | 41 - xsd/type-map/type-map.hxx | 178 - xsd/types.hxx | 19 - xsd/xsd.cxx | 1126 ---- xsd/xsd.hxx | 24 - xsd/xsd/.gitignore | 3 + xsd/xsd/buildfile | 68 + xsd/xsd/cxx/elements.cxx | 1322 ++++ xsd/xsd/cxx/elements.hxx | 626 ++ xsd/xsd/cxx/literal-map.cxx | 261 + xsd/xsd/cxx/literal-map.hxx | 19 + xsd/xsd/cxx/option-types.cxx | 47 + xsd/xsd/cxx/option-types.hxx | 34 + xsd/xsd/cxx/options.cli | 550 ++ xsd/xsd/cxx/parser/attribute-validation-source.cxx | 412 ++ xsd/xsd/cxx/parser/attribute-validation-source.hxx | 18 + .../cxx/parser/characters-validation-source.cxx | 73 + .../cxx/parser/characters-validation-source.hxx | 18 + xsd/xsd/cxx/parser/driver-source.cxx | 775 +++ xsd/xsd/cxx/parser/driver-source.hxx | 18 + xsd/xsd/cxx/parser/element-validation-source.cxx | 1600 +++++ xsd/xsd/cxx/parser/element-validation-source.hxx | 18 + xsd/xsd/cxx/parser/elements.cxx | 247 + xsd/xsd/cxx/parser/elements.hxx | 315 + xsd/xsd/cxx/parser/generator.cxx | 1099 ++++ xsd/xsd/cxx/parser/generator.hxx | 45 + xsd/xsd/cxx/parser/impl-header.cxx | 232 + xsd/xsd/cxx/parser/impl-header.hxx | 18 + xsd/xsd/cxx/parser/impl-source.cxx | 384 ++ xsd/xsd/cxx/parser/impl-source.hxx | 18 + xsd/xsd/cxx/parser/name-processor.cxx | 1175 ++++ xsd/xsd/cxx/parser/name-processor.hxx | 30 + xsd/xsd/cxx/parser/options.cli | 147 + xsd/xsd/cxx/parser/parser-forward.cxx | 110 + xsd/xsd/cxx/parser/parser-forward.hxx | 18 + xsd/xsd/cxx/parser/parser-header.cxx | 1440 +++++ xsd/xsd/cxx/parser/parser-header.hxx | 18 + xsd/xsd/cxx/parser/parser-inline.cxx | 399 ++ xsd/xsd/cxx/parser/parser-inline.hxx | 18 + xsd/xsd/cxx/parser/parser-source.cxx | 957 +++ xsd/xsd/cxx/parser/parser-source.hxx | 18 + xsd/xsd/cxx/parser/print-impl-common.hxx | 641 ++ xsd/xsd/cxx/parser/state-processor.cxx | 319 + xsd/xsd/cxx/parser/state-processor.hxx | 25 + xsd/xsd/cxx/parser/type-processor.cxx | 347 + xsd/xsd/cxx/parser/type-processor.hxx | 31 + xsd/xsd/cxx/parser/validator.cxx | 718 ++ xsd/xsd/cxx/parser/validator.hxx | 30 + xsd/xsd/cxx/tree/counter.cxx | 260 + xsd/xsd/cxx/tree/counter.hxx | 25 + xsd/xsd/cxx/tree/default-value.cxx | 1273 ++++ xsd/xsd/cxx/tree/default-value.hxx | 355 + xsd/xsd/cxx/tree/elements.cxx | 1409 ++++ xsd/xsd/cxx/tree/elements.hxx | 2118 ++++++ xsd/xsd/cxx/tree/fundamental-header.hxx | 1335 ++++ xsd/xsd/cxx/tree/generator.cxx | 1227 ++++ xsd/xsd/cxx/tree/generator.hxx | 44 + xsd/xsd/cxx/tree/name-processor.cxx | 2399 +++++++ xsd/xsd/cxx/tree/name-processor.hxx | 28 + xsd/xsd/cxx/tree/options.cli | 479 ++ xsd/xsd/cxx/tree/order-processor.cxx | 243 + xsd/xsd/cxx/tree/order-processor.hxx | 29 + xsd/xsd/cxx/tree/parser-header.cxx | 472 ++ xsd/xsd/cxx/tree/parser-header.hxx | 19 + xsd/xsd/cxx/tree/parser-source.cxx | 541 ++ xsd/xsd/cxx/tree/parser-source.hxx | 18 + xsd/xsd/cxx/tree/polymorphism-processor.cxx | 740 +++ xsd/xsd/cxx/tree/polymorphism-processor.hxx | 30 + xsd/xsd/cxx/tree/serialization-header.cxx | 579 ++ xsd/xsd/cxx/tree/serialization-header.hxx | 18 + xsd/xsd/cxx/tree/serialization-source.cxx | 1468 +++++ xsd/xsd/cxx/tree/serialization-source.hxx | 18 + xsd/xsd/cxx/tree/stream-extraction-source.cxx | 864 +++ xsd/xsd/cxx/tree/stream-extraction-source.hxx | 18 + xsd/xsd/cxx/tree/stream-header.cxx | 181 + xsd/xsd/cxx/tree/stream-header.hxx | 18 + xsd/xsd/cxx/tree/stream-insertion-header.cxx | 178 + xsd/xsd/cxx/tree/stream-insertion-header.hxx | 18 + xsd/xsd/cxx/tree/stream-insertion-source.cxx | 623 ++ xsd/xsd/cxx/tree/stream-insertion-source.hxx | 18 + xsd/xsd/cxx/tree/stream-source.cxx | 496 ++ xsd/xsd/cxx/tree/stream-source.hxx | 18 + xsd/xsd/cxx/tree/tree-forward.cxx | 325 + xsd/xsd/cxx/tree/tree-forward.hxx | 18 + xsd/xsd/cxx/tree/tree-header.cxx | 4299 ++++++++++++ xsd/xsd/cxx/tree/tree-header.hxx | 18 + xsd/xsd/cxx/tree/tree-inline.cxx | 1161 ++++ xsd/xsd/cxx/tree/tree-inline.hxx | 18 + xsd/xsd/cxx/tree/tree-source.cxx | 3900 +++++++++++ xsd/xsd/cxx/tree/tree-source.hxx | 18 + xsd/xsd/cxx/tree/validator.cxx | 671 ++ xsd/xsd/cxx/tree/validator.hxx | 29 + xsd/xsd/elements.hxx | 125 + xsd/xsd/options-parser.hxx | 29 + xsd/xsd/options.cli | 315 + xsd/xsd/processing/cardinality/processor.cxx | 407 ++ xsd/xsd/processing/cardinality/processor.hxx | 28 + xsd/xsd/processing/inheritance/processor.cxx | 492 ++ xsd/xsd/processing/inheritance/processor.hxx | 28 + xsd/xsd/type-map/lexer.cxx | 131 + xsd/xsd/type-map/lexer.hxx | 74 + xsd/xsd/type-map/parser.cxx | 279 + xsd/xsd/type-map/parser.hxx | 41 + xsd/xsd/type-map/type-map.hxx | 178 + xsd/xsd/types.hxx | 19 + xsd/xsd/version.hxx.in | 55 + xsd/xsd/xsd.cxx | 1144 ++++ xsd/xsd/xsd.hxx | 24 + 2081 files changed, 102398 insertions(+), 172387 deletions(-) create mode 100644 .gitattributes delete mode 100644 INSTALL delete mode 100644 NEWS delete mode 100644 README delete mode 100644 build/bootstrap.make delete mode 100644 build/configuration-rules.make delete mode 100644 build/configuration.make delete mode 100755 build/configure delete mode 100644 build/import/cli/cli-cxx.make delete mode 100644 build/import/cli/configuration-rules.make delete mode 100755 build/import/cli/configure delete mode 100644 build/import/cli/stub.make delete mode 100644 build/import/libace/configuration-rules.make delete mode 100755 build/import/libace/configure delete mode 100644 build/import/libace/rules.make delete mode 100644 build/import/libace/stub.make delete mode 100644 build/import/libace/version delete mode 100644 build/import/libboost/configuration-rules.make delete mode 100755 build/import/libboost/configure delete mode 100644 build/import/libboost/date-time/rules.make delete mode 100644 build/import/libboost/date-time/stub.make delete mode 100644 build/import/libboost/serialization/rules.make delete mode 100644 build/import/libboost/serialization/stub.make delete mode 100644 build/import/libboost/version delete mode 100644 build/import/libcutl/configuration-rules.make delete mode 100755 build/import/libcutl/configure delete mode 100644 build/import/libcutl/stub.make delete mode 100644 build/import/libxerces-c/configuration-rules.make delete mode 100755 build/import/libxerces-c/configure delete mode 100644 build/import/libxerces-c/rules.make delete mode 100644 build/import/libxerces-c/stub.make delete mode 100644 build/import/libxerces-c/version delete mode 100644 build/import/libxqilla/configuration-rules.make delete mode 100755 build/import/libxqilla/configure delete mode 100644 build/import/libxqilla/rules.make delete mode 100644 build/import/libxqilla/stub.make delete mode 100644 build/import/libxqilla/version delete mode 100644 build/import/libxsd-frontend/configuration-rules.make delete mode 100755 build/import/libxsd-frontend/configure delete mode 100644 build/import/libxsd-frontend/stub.make delete mode 100644 build/import/libz/configuration-rules.make delete mode 100755 build/import/libz/configure delete mode 100644 build/import/libz/rules.make delete mode 100644 build/import/libz/stub.make delete mode 100644 build/import/libz/version delete mode 100644 build/xsd/parser/xsd-cxx.make delete mode 100644 build/xsd/tree/xsd-cxx.make create mode 100644 buildfile delete mode 100644 dist/README-UNIX delete mode 100644 dist/README-WINDOWS delete mode 100644 dist/etc/vc-1x.0/xsd-cxx-parser.props delete mode 100644 dist/etc/vc-1x.0/xsd-cxx-parser.targets delete mode 100644 dist/etc/vc-1x.0/xsd-cxx-parser.xml delete mode 100644 dist/etc/vc-1x.0/xsd-cxx-tree.props delete mode 100644 dist/etc/vc-1x.0/xsd-cxx-tree.targets delete mode 100644 dist/etc/vc-1x.0/xsd-cxx-tree.xml delete mode 100644 dist/etc/vc-8.0/xsd-cxx-parser.rules delete mode 100644 dist/etc/vc-8.0/xsd-cxx-tree.rules delete mode 100644 dist/etc/vc-9.0/xsd-cxx-parser.rules delete mode 100644 dist/etc/vc-9.0/xsd-cxx-tree.rules delete mode 100644 dist/examples/build/cxx/compilers.make delete mode 100644 dist/examples/build/cxx/rules.make delete mode 100644 dist/examples/build/xsd/common.make delete mode 100644 dist/examples/build/xsd/parser-rules.make delete mode 100644 dist/examples/build/xsd/tree-rules.make delete mode 100644 dist/examples/cxx/makefile delete mode 100644 dist/examples/cxx/parser/generated/generated-vc10.vcxproj delete mode 100644 dist/examples/cxx/parser/generated/generated-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/generated/generated-vc11.vcxproj delete mode 100644 dist/examples/cxx/parser/generated/generated-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/generated/generated-vc12.vcxproj delete mode 100644 dist/examples/cxx/parser/generated/generated-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/generated/generated-vc8.vcproj delete mode 100644 dist/examples/cxx/parser/generated/generated-vc9.vcproj delete mode 100644 dist/examples/cxx/parser/generated/makefile delete mode 100644 dist/examples/cxx/parser/hello/hello-vc10.vcxproj delete mode 100644 dist/examples/cxx/parser/hello/hello-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/hello/hello-vc11.vcxproj delete mode 100644 dist/examples/cxx/parser/hello/hello-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/hello/hello-vc12.vcxproj delete mode 100644 dist/examples/cxx/parser/hello/hello-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/hello/hello-vc8.vcproj delete mode 100644 dist/examples/cxx/parser/hello/hello-vc9.vcproj delete mode 100644 dist/examples/cxx/parser/hello/makefile delete mode 100644 dist/examples/cxx/parser/library/library-vc10.vcxproj delete mode 100644 dist/examples/cxx/parser/library/library-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/library/library-vc11.vcxproj delete mode 100644 dist/examples/cxx/parser/library/library-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/library/library-vc12.vcxproj delete mode 100644 dist/examples/cxx/parser/library/library-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/library/library-vc8.vcproj delete mode 100644 dist/examples/cxx/parser/library/library-vc9.vcproj delete mode 100644 dist/examples/cxx/parser/library/makefile delete mode 100644 dist/examples/cxx/parser/makefile delete mode 100644 dist/examples/cxx/parser/mixed/makefile delete mode 100644 dist/examples/cxx/parser/mixed/mixed-vc10.vcxproj delete mode 100644 dist/examples/cxx/parser/mixed/mixed-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/mixed/mixed-vc11.vcxproj delete mode 100644 dist/examples/cxx/parser/mixed/mixed-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/mixed/mixed-vc12.vcxproj delete mode 100644 dist/examples/cxx/parser/mixed/mixed-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/mixed/mixed-vc8.vcproj delete mode 100644 dist/examples/cxx/parser/mixed/mixed-vc9.vcproj delete mode 100644 dist/examples/cxx/parser/mixin/makefile delete mode 100644 dist/examples/cxx/parser/mixin/mixin-vc10.vcxproj delete mode 100644 dist/examples/cxx/parser/mixin/mixin-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/mixin/mixin-vc11.vcxproj delete mode 100644 dist/examples/cxx/parser/mixin/mixin-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/mixin/mixin-vc12.vcxproj delete mode 100644 dist/examples/cxx/parser/mixin/mixin-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/mixin/mixin-vc8.vcproj delete mode 100644 dist/examples/cxx/parser/mixin/mixin-vc9.vcproj delete mode 100644 dist/examples/cxx/parser/multiroot/makefile delete mode 100644 dist/examples/cxx/parser/multiroot/multiroot-vc10.vcxproj delete mode 100644 dist/examples/cxx/parser/multiroot/multiroot-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/multiroot/multiroot-vc11.vcxproj delete mode 100644 dist/examples/cxx/parser/multiroot/multiroot-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/multiroot/multiroot-vc12.vcxproj delete mode 100644 dist/examples/cxx/parser/multiroot/multiroot-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/multiroot/multiroot-vc8.vcproj delete mode 100644 dist/examples/cxx/parser/multiroot/multiroot-vc9.vcproj delete mode 100644 dist/examples/cxx/parser/performance/makefile delete mode 100644 dist/examples/cxx/parser/performance/performance-vc10.vcxproj delete mode 100644 dist/examples/cxx/parser/performance/performance-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/performance/performance-vc11.vcxproj delete mode 100644 dist/examples/cxx/parser/performance/performance-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/performance/performance-vc12.vcxproj delete mode 100644 dist/examples/cxx/parser/performance/performance-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/performance/performance-vc8.vcproj delete mode 100644 dist/examples/cxx/parser/performance/performance-vc9.vcproj delete mode 100644 dist/examples/cxx/parser/polymorphism/makefile delete mode 100644 dist/examples/cxx/parser/polymorphism/polymorphism-vc10.vcxproj delete mode 100644 dist/examples/cxx/parser/polymorphism/polymorphism-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/polymorphism/polymorphism-vc11.vcxproj delete mode 100644 dist/examples/cxx/parser/polymorphism/polymorphism-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/polymorphism/polymorphism-vc12.vcxproj delete mode 100644 dist/examples/cxx/parser/polymorphism/polymorphism-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/polymorphism/polymorphism-vc8.vcproj delete mode 100644 dist/examples/cxx/parser/polymorphism/polymorphism-vc9.vcproj delete mode 100644 dist/examples/cxx/parser/polyroot/makefile delete mode 100644 dist/examples/cxx/parser/polyroot/polyroot-vc10.vcxproj delete mode 100644 dist/examples/cxx/parser/polyroot/polyroot-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/polyroot/polyroot-vc11.vcxproj delete mode 100644 dist/examples/cxx/parser/polyroot/polyroot-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/polyroot/polyroot-vc12.vcxproj delete mode 100644 dist/examples/cxx/parser/polyroot/polyroot-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/polyroot/polyroot-vc8.vcproj delete mode 100644 dist/examples/cxx/parser/polyroot/polyroot-vc9.vcproj delete mode 100644 dist/examples/cxx/parser/wildcard/makefile delete mode 100644 dist/examples/cxx/parser/wildcard/wildcard-vc10.vcxproj delete mode 100644 dist/examples/cxx/parser/wildcard/wildcard-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/wildcard/wildcard-vc11.vcxproj delete mode 100644 dist/examples/cxx/parser/wildcard/wildcard-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/wildcard/wildcard-vc12.vcxproj delete mode 100644 dist/examples/cxx/parser/wildcard/wildcard-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/parser/wildcard/wildcard-vc8.vcproj delete mode 100644 dist/examples/cxx/parser/wildcard/wildcard-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/binary/boost/boost-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/binary/boost/boost-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/binary/boost/boost-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/binary/boost/boost-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/binary/boost/boost-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/binary/boost/boost-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/binary/boost/boost-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/binary/boost/boost-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/binary/boost/makefile delete mode 100644 dist/examples/cxx/tree/binary/cdr/cdr-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/binary/cdr/cdr-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/binary/cdr/cdr-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/binary/cdr/cdr-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/binary/cdr/cdr-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/binary/cdr/cdr-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/binary/cdr/cdr-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/binary/cdr/cdr-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/binary/cdr/makefile delete mode 100644 dist/examples/cxx/tree/binary/makefile delete mode 100644 dist/examples/cxx/tree/binary/xdr/makefile delete mode 100644 dist/examples/cxx/tree/binary/xdr/xdr-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/binary/xdr/xdr-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/binary/xdr/xdr-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/binary/xdr/xdr-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/binary/xdr/xdr-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/binary/xdr/xdr-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/binary/xdr/xdr-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/binary/xdr/xdr-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/caching/caching-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/caching/caching-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/caching/caching-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/caching/caching-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/caching/caching-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/caching/caching-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/caching/caching-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/caching/caching-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/caching/makefile delete mode 100644 dist/examples/cxx/tree/compression/compression-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/compression/compression-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/compression/compression-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/compression/compression-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/compression/compression-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/compression/compression-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/compression/compression-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/compression/compression-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/compression/makefile delete mode 100644 dist/examples/cxx/tree/custom/calendar/calendar-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/calendar/calendar-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/calendar/calendar-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/calendar/calendar-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/calendar/calendar-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/calendar/calendar-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/calendar/calendar-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/custom/calendar/calendar-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/custom/calendar/makefile delete mode 100644 dist/examples/cxx/tree/custom/comments/comments-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/comments/comments-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/comments/comments-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/comments/comments-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/comments/comments-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/comments/comments-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/comments/comments-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/custom/comments/comments-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/custom/comments/makefile delete mode 100644 dist/examples/cxx/tree/custom/contacts/contacts-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/contacts/contacts-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/contacts/contacts-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/contacts/contacts-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/contacts/contacts-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/contacts/contacts-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/contacts/contacts-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/custom/contacts/contacts-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/custom/contacts/makefile delete mode 100644 dist/examples/cxx/tree/custom/double/double-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/double/double-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/double/double-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/double/double-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/double/double-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/double/double-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/double/double-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/custom/double/double-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/custom/double/makefile delete mode 100644 dist/examples/cxx/tree/custom/makefile delete mode 100644 dist/examples/cxx/tree/custom/mixed/makefile delete mode 100644 dist/examples/cxx/tree/custom/mixed/mixed-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/mixed/mixed-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/mixed/mixed-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/mixed/mixed-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/mixed/mixed-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/mixed/mixed-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/mixed/mixed-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/custom/mixed/mixed-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/custom/taxonomy/makefile delete mode 100644 dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/custom/wildcard/makefile delete mode 100644 dist/examples/cxx/tree/custom/wildcard/wildcard-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/wildcard/wildcard-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/wildcard/wildcard-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/wildcard/wildcard-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/wildcard/wildcard-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/custom/wildcard/wildcard-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/custom/wildcard/wildcard-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/custom/wildcard/wildcard-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/embedded/embedded-vc10.sln delete mode 100644 dist/examples/cxx/tree/embedded/embedded-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/embedded/embedded-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/embedded/embedded-vc11.sln delete mode 100644 dist/examples/cxx/tree/embedded/embedded-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/embedded/embedded-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/embedded/embedded-vc12.sln delete mode 100644 dist/examples/cxx/tree/embedded/embedded-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/embedded/embedded-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/embedded/embedded-vc8.sln delete mode 100644 dist/examples/cxx/tree/embedded/embedded-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/embedded/embedded-vc9.sln delete mode 100644 dist/examples/cxx/tree/embedded/embedded-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/embedded/makefile delete mode 100644 dist/examples/cxx/tree/embedded/xsdbin-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/embedded/xsdbin-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/embedded/xsdbin-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/embedded/xsdbin-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/embedded/xsdbin-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/embedded/xsdbin-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/embedded/xsdbin-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/embedded/xsdbin-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/hello/hello-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/hello/hello-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/hello/hello-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/hello/hello-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/hello/hello-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/hello/hello-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/hello/hello-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/hello/hello-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/hello/makefile delete mode 100644 dist/examples/cxx/tree/library/library-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/library/library-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/library/library-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/library/library-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/library/library-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/library/library-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/library/library-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/library/library-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/library/makefile delete mode 100644 dist/examples/cxx/tree/makefile delete mode 100644 dist/examples/cxx/tree/messaging/makefile delete mode 100644 dist/examples/cxx/tree/messaging/messaging-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/messaging/messaging-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/messaging/messaging-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/messaging/messaging-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/messaging/messaging-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/messaging/messaging-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/messaging/messaging-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/messaging/messaging-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/mixed/makefile delete mode 100644 dist/examples/cxx/tree/mixed/mixed-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/mixed/mixed-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/mixed/mixed-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/mixed/mixed-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/mixed/mixed-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/mixed/mixed-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/mixed/mixed-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/mixed/mixed-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/multiroot/makefile delete mode 100644 dist/examples/cxx/tree/multiroot/multiroot-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/multiroot/multiroot-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/multiroot/multiroot-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/multiroot/multiroot-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/multiroot/multiroot-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/multiroot/multiroot-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/multiroot/multiroot-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/multiroot/multiroot-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/order/element/makefile delete mode 100644 dist/examples/cxx/tree/order/element/order-element-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/order/element/order-element-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/order/element/order-element-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/order/element/order-element-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/order/element/order-element-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/order/element/order-element-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/order/element/order-element-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/order/element/order-element-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/order/makefile delete mode 100644 dist/examples/cxx/tree/order/mixed/makefile delete mode 100644 dist/examples/cxx/tree/order/mixed/order-mixed-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/order/mixed/order-mixed-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/order/mixed/order-mixed-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/order/mixed/order-mixed-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/order/mixed/order-mixed-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/order/mixed/order-mixed-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/order/mixed/order-mixed-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/order/mixed/order-mixed-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/performance/makefile delete mode 100644 dist/examples/cxx/tree/performance/performance-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/performance/performance-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/performance/performance-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/performance/performance-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/performance/performance-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/performance/performance-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/performance/performance-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/performance/performance-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/polymorphism/makefile delete mode 100644 dist/examples/cxx/tree/polymorphism/polymorphism-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/polymorphism/polymorphism-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/polymorphism/polymorphism-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/polymorphism/polymorphism-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/polymorphism/polymorphism-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/polymorphism/polymorphism-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/polymorphism/polymorphism-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/polymorphism/polymorphism-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/secure/makefile delete mode 100644 dist/examples/cxx/tree/streaming/makefile delete mode 100644 dist/examples/cxx/tree/streaming/streaming-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/streaming/streaming-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/streaming/streaming-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/streaming/streaming-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/streaming/streaming-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/streaming/streaming-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/streaming/streaming-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/streaming/streaming-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/wildcard/makefile delete mode 100644 dist/examples/cxx/tree/wildcard/wildcard-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/wildcard/wildcard-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/wildcard/wildcard-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/wildcard/wildcard-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/wildcard/wildcard-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/wildcard/wildcard-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/wildcard/wildcard-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/wildcard/wildcard-vc9.vcproj delete mode 100644 dist/examples/cxx/tree/xpath/makefile delete mode 100644 dist/examples/cxx/tree/xpath/xpath-vc10.vcxproj delete mode 100644 dist/examples/cxx/tree/xpath/xpath-vc10.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/xpath/xpath-vc11.vcxproj delete mode 100644 dist/examples/cxx/tree/xpath/xpath-vc11.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/xpath/xpath-vc12.vcxproj delete mode 100644 dist/examples/cxx/tree/xpath/xpath-vc12.vcxproj.filters delete mode 100644 dist/examples/cxx/tree/xpath/xpath-vc8.vcproj delete mode 100644 dist/examples/cxx/tree/xpath/xpath-vc9.vcproj delete mode 100644 dist/examples/makefile delete mode 100644 dist/examples/test.bat delete mode 100644 dist/examples/tester.bat delete mode 100644 dist/template-vc10.sln delete mode 100644 dist/template-vc11.sln delete mode 100644 dist/template-vc12.sln delete mode 100644 dist/template-vc8.sln delete mode 100644 dist/template-vc9.sln delete mode 100644 doc/custom-literals.xsd delete mode 100644 doc/cxx/makefile delete mode 100644 doc/cxx/parser/guide/figure-1.png delete mode 100644 doc/cxx/parser/guide/figure-1.svg delete mode 100644 doc/cxx/parser/guide/guide.html2ps delete mode 100644 doc/cxx/parser/guide/index.xhtml delete mode 100644 doc/cxx/parser/guide/makefile delete mode 100644 doc/cxx/parser/makefile delete mode 100644 doc/cxx/tree/guide/guide.html2ps delete mode 100644 doc/cxx/tree/guide/index.xhtml delete mode 100644 doc/cxx/tree/guide/makefile delete mode 100644 doc/cxx/tree/makefile delete mode 100644 doc/cxx/tree/manual/index.xhtml delete mode 100644 doc/cxx/tree/manual/makefile delete mode 100644 doc/cxx/tree/manual/manual.html2ps delete mode 100644 doc/cxx/tree/reference/footer.html delete mode 100644 doc/cxx/tree/reference/libxsd.doxygen delete mode 100644 doc/cxx/tree/reference/makefile delete mode 100644 doc/default.css delete mode 100755 doc/doc.sh delete mode 100644 doc/makefile delete mode 100644 doc/xsd-epilogue.1 delete mode 100644 doc/xsd-epilogue.xhtml delete mode 100644 doc/xsd-parser-header.1 delete mode 100644 doc/xsd-parser-header.xhtml delete mode 100644 doc/xsd-prologue.1 delete mode 100644 doc/xsd-prologue.xhtml delete mode 100644 doc/xsd-tree-header.1 delete mode 100644 doc/xsd-tree-header.xhtml delete mode 100644 examples/cxx/parser/README delete mode 100644 examples/cxx/parser/generated/README delete mode 100644 examples/cxx/parser/generated/library.xml delete mode 100644 examples/cxx/parser/generated/library.xsd delete mode 100644 examples/cxx/parser/generated/makefile delete mode 100644 examples/cxx/parser/hello/README delete mode 100644 examples/cxx/parser/hello/driver.cxx delete mode 100644 examples/cxx/parser/hello/hello.xml delete mode 100644 examples/cxx/parser/hello/hello.xsd delete mode 100644 examples/cxx/parser/hello/makefile delete mode 100644 examples/cxx/parser/library/README delete mode 100644 examples/cxx/parser/library/driver.cxx delete mode 100644 examples/cxx/parser/library/library-pimpl.cxx delete mode 100644 examples/cxx/parser/library/library-pimpl.hxx delete mode 100644 examples/cxx/parser/library/library.hxx delete mode 100644 examples/cxx/parser/library/library.map delete mode 100644 examples/cxx/parser/library/library.xml delete mode 100644 examples/cxx/parser/library/library.xsd delete mode 100644 examples/cxx/parser/library/makefile delete mode 100644 examples/cxx/parser/makefile delete mode 100644 examples/cxx/parser/mixed/README delete mode 100644 examples/cxx/parser/mixed/anchor.hxx delete mode 100644 examples/cxx/parser/mixed/driver.cxx delete mode 100644 examples/cxx/parser/mixed/makefile delete mode 100644 examples/cxx/parser/mixed/text.map delete mode 100644 examples/cxx/parser/mixed/text.xml delete mode 100644 examples/cxx/parser/mixed/text.xsd delete mode 100644 examples/cxx/parser/mixin/README delete mode 100644 examples/cxx/parser/mixin/driver.cxx delete mode 100644 examples/cxx/parser/mixin/instance.xml delete mode 100644 examples/cxx/parser/mixin/makefile delete mode 100644 examples/cxx/parser/mixin/schema.map delete mode 100644 examples/cxx/parser/mixin/schema.xsd delete mode 100644 examples/cxx/parser/mixin/types.hxx 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 delete mode 100644 examples/cxx/parser/performance/README delete mode 100644 examples/cxx/parser/performance/driver.cxx delete mode 100644 examples/cxx/parser/performance/gen.cxx delete mode 100644 examples/cxx/parser/performance/makefile delete mode 100644 examples/cxx/parser/performance/test-50k.xml delete mode 100644 examples/cxx/parser/performance/test.xsd delete mode 100644 examples/cxx/parser/performance/time.cxx delete mode 100644 examples/cxx/parser/performance/time.hxx delete mode 100644 examples/cxx/parser/polymorphism/README delete mode 100644 examples/cxx/parser/polymorphism/driver.cxx delete mode 100644 examples/cxx/parser/polymorphism/makefile delete mode 100644 examples/cxx/parser/polymorphism/supermen-pimpl.cxx delete mode 100644 examples/cxx/parser/polymorphism/supermen-pimpl.hxx delete mode 100644 examples/cxx/parser/polymorphism/supermen.xml delete mode 100644 examples/cxx/parser/polymorphism/supermen.xsd delete mode 100644 examples/cxx/parser/polyroot/README delete mode 100644 examples/cxx/parser/polyroot/batman.xml delete mode 100644 examples/cxx/parser/polyroot/driver.cxx delete mode 100644 examples/cxx/parser/polyroot/makefile delete mode 100644 examples/cxx/parser/polyroot/person.xml delete mode 100644 examples/cxx/parser/polyroot/superman.xml delete mode 100644 examples/cxx/parser/polyroot/supermen-pimpl.cxx delete mode 100644 examples/cxx/parser/polyroot/supermen-pimpl.hxx delete mode 100644 examples/cxx/parser/polyroot/supermen.xsd delete mode 100644 examples/cxx/parser/wildcard/README delete mode 100644 examples/cxx/parser/wildcard/driver.cxx delete mode 100644 examples/cxx/parser/wildcard/email.xml delete mode 100644 examples/cxx/parser/wildcard/email.xsd delete mode 100644 examples/cxx/parser/wildcard/makefile delete mode 100644 examples/cxx/tree/README delete mode 100644 examples/cxx/tree/binary/README delete mode 100644 examples/cxx/tree/binary/boost/README delete mode 100644 examples/cxx/tree/binary/boost/boost-archive-extraction.hxx delete mode 100644 examples/cxx/tree/binary/boost/boost-archive-insertion.hxx delete mode 100644 examples/cxx/tree/binary/boost/driver.cxx delete mode 100644 examples/cxx/tree/binary/boost/library-prologue.hxx delete mode 100644 examples/cxx/tree/binary/boost/library.xml delete mode 100644 examples/cxx/tree/binary/boost/library.xsd delete mode 100644 examples/cxx/tree/binary/boost/makefile delete mode 100644 examples/cxx/tree/binary/cdr/README delete mode 100644 examples/cxx/tree/binary/cdr/driver.cxx delete mode 100644 examples/cxx/tree/binary/cdr/library.xml delete mode 100644 examples/cxx/tree/binary/cdr/library.xsd delete mode 100644 examples/cxx/tree/binary/cdr/makefile delete mode 100644 examples/cxx/tree/binary/makefile 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 delete mode 100644 examples/cxx/tree/caching/README delete mode 100644 examples/cxx/tree/caching/driver.cxx delete mode 100644 examples/cxx/tree/caching/library.xml delete mode 100644 examples/cxx/tree/caching/library.xsd delete mode 100644 examples/cxx/tree/caching/makefile delete mode 100644 examples/cxx/tree/compression/README delete mode 100644 examples/cxx/tree/compression/compressed-format-target.cxx delete mode 100644 examples/cxx/tree/compression/compressed-format-target.hxx delete mode 100644 examples/cxx/tree/compression/compressed-input-source.cxx delete mode 100644 examples/cxx/tree/compression/compressed-input-source.hxx delete mode 100644 examples/cxx/tree/compression/driver.cxx delete mode 100644 examples/cxx/tree/compression/library.xml.gz delete mode 100644 examples/cxx/tree/compression/library.xsd delete mode 100644 examples/cxx/tree/compression/makefile delete mode 100644 examples/cxx/tree/custom/README delete mode 100644 examples/cxx/tree/custom/calendar/README delete mode 100644 examples/cxx/tree/custom/calendar/calendar.xml delete mode 100644 examples/cxx/tree/custom/calendar/calendar.xsd delete mode 100644 examples/cxx/tree/custom/calendar/driver.cxx delete mode 100644 examples/cxx/tree/custom/calendar/makefile delete mode 100644 examples/cxx/tree/custom/calendar/xml-schema-custom.cxx delete mode 100644 examples/cxx/tree/custom/calendar/xml-schema-custom.hxx 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 delete mode 100644 examples/cxx/tree/custom/contacts/README delete mode 100644 examples/cxx/tree/custom/contacts/contacts-custom.cxx delete mode 100644 examples/cxx/tree/custom/contacts/contacts-custom.hxx delete mode 100644 examples/cxx/tree/custom/contacts/contacts.xml delete mode 100644 examples/cxx/tree/custom/contacts/contacts.xsd delete mode 100644 examples/cxx/tree/custom/contacts/driver.cxx delete mode 100644 examples/cxx/tree/custom/contacts/makefile delete mode 100644 examples/cxx/tree/custom/double/README delete mode 100644 examples/cxx/tree/custom/double/double-custom.cxx delete mode 100644 examples/cxx/tree/custom/double/double-custom.hxx delete mode 100644 examples/cxx/tree/custom/double/driver.cxx delete mode 100644 examples/cxx/tree/custom/double/makefile delete mode 100644 examples/cxx/tree/custom/double/order.xsd delete mode 100644 examples/cxx/tree/custom/makefile delete mode 100644 examples/cxx/tree/custom/mixed/README delete mode 100644 examples/cxx/tree/custom/mixed/driver.cxx delete mode 100644 examples/cxx/tree/custom/mixed/makefile delete mode 100644 examples/cxx/tree/custom/mixed/people-custom.cxx delete mode 100644 examples/cxx/tree/custom/mixed/people-custom.hxx delete mode 100644 examples/cxx/tree/custom/mixed/people.xml delete mode 100644 examples/cxx/tree/custom/mixed/people.xsd delete mode 100644 examples/cxx/tree/custom/taxonomy/README delete mode 100644 examples/cxx/tree/custom/taxonomy/driver.cxx delete mode 100644 examples/cxx/tree/custom/taxonomy/makefile delete mode 100644 examples/cxx/tree/custom/taxonomy/people-custom-fwd.hxx delete mode 100644 examples/cxx/tree/custom/taxonomy/people-custom.cxx delete mode 100644 examples/cxx/tree/custom/taxonomy/people-custom.hxx delete mode 100644 examples/cxx/tree/custom/taxonomy/people.xml delete mode 100644 examples/cxx/tree/custom/taxonomy/people.xsd delete mode 100644 examples/cxx/tree/custom/wildcard/README delete mode 100644 examples/cxx/tree/custom/wildcard/driver.cxx delete mode 100644 examples/cxx/tree/custom/wildcard/makefile delete mode 100644 examples/cxx/tree/custom/wildcard/wildcard-custom.cxx delete mode 100644 examples/cxx/tree/custom/wildcard/wildcard-custom.hxx delete mode 100644 examples/cxx/tree/custom/wildcard/wildcard.xml delete mode 100644 examples/cxx/tree/custom/wildcard/wildcard.xsd delete mode 100644 examples/cxx/tree/embedded/README delete mode 100644 examples/cxx/tree/embedded/driver.cxx delete mode 100644 examples/cxx/tree/embedded/grammar-input-stream.cxx delete mode 100644 examples/cxx/tree/embedded/grammar-input-stream.hxx delete mode 100644 examples/cxx/tree/embedded/library.xml delete mode 100644 examples/cxx/tree/embedded/library.xsd delete mode 100644 examples/cxx/tree/embedded/makefile delete mode 100644 examples/cxx/tree/embedded/xsdbin.cxx delete mode 100644 examples/cxx/tree/hello/README delete mode 100644 examples/cxx/tree/hello/driver.cxx delete mode 100644 examples/cxx/tree/hello/hello.xml delete mode 100644 examples/cxx/tree/hello/hello.xsd delete mode 100644 examples/cxx/tree/hello/makefile delete mode 100644 examples/cxx/tree/library/README delete mode 100644 examples/cxx/tree/library/driver.cxx delete mode 100644 examples/cxx/tree/library/library.xml delete mode 100644 examples/cxx/tree/library/library.xsd delete mode 100644 examples/cxx/tree/library/makefile delete mode 100644 examples/cxx/tree/makefile delete mode 100644 examples/cxx/tree/messaging/README delete mode 100644 examples/cxx/tree/messaging/balance.xml delete mode 100644 examples/cxx/tree/messaging/deposit.xml delete mode 100644 examples/cxx/tree/messaging/dom-parse.cxx delete mode 100644 examples/cxx/tree/messaging/dom-parse.hxx delete mode 100644 examples/cxx/tree/messaging/dom-serialize.cxx delete mode 100644 examples/cxx/tree/messaging/dom-serialize.hxx delete mode 100644 examples/cxx/tree/messaging/driver.cxx delete mode 100644 examples/cxx/tree/messaging/makefile delete mode 100644 examples/cxx/tree/messaging/protocol.xsd delete mode 100644 examples/cxx/tree/messaging/withdraw.xml delete mode 100644 examples/cxx/tree/mixed/README delete mode 100644 examples/cxx/tree/mixed/driver.cxx delete mode 100644 examples/cxx/tree/mixed/makefile delete mode 100644 examples/cxx/tree/mixed/text.xml delete mode 100644 examples/cxx/tree/mixed/text.xsd 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 delete mode 100644 examples/cxx/tree/order/README delete mode 100644 examples/cxx/tree/order/element/README delete mode 100644 examples/cxx/tree/order/element/driver.cxx delete mode 100644 examples/cxx/tree/order/element/makefile delete mode 100644 examples/cxx/tree/order/element/transactions.xml delete mode 100644 examples/cxx/tree/order/element/transactions.xsd delete mode 100644 examples/cxx/tree/order/makefile delete mode 100644 examples/cxx/tree/order/mixed/README delete mode 100644 examples/cxx/tree/order/mixed/driver.cxx delete mode 100644 examples/cxx/tree/order/mixed/makefile delete mode 100644 examples/cxx/tree/order/mixed/text.xml delete mode 100644 examples/cxx/tree/order/mixed/text.xsd delete mode 100644 examples/cxx/tree/performance/README delete mode 100644 examples/cxx/tree/performance/driver.cxx delete mode 100644 examples/cxx/tree/performance/gen.cxx delete mode 100644 examples/cxx/tree/performance/makefile delete mode 100644 examples/cxx/tree/performance/parsing.cxx delete mode 100644 examples/cxx/tree/performance/serialization.cxx delete mode 100644 examples/cxx/tree/performance/test-50k.xml delete mode 100644 examples/cxx/tree/performance/test.xsd delete mode 100644 examples/cxx/tree/performance/time.cxx delete mode 100644 examples/cxx/tree/performance/time.hxx delete mode 100644 examples/cxx/tree/polymorphism/README delete mode 100644 examples/cxx/tree/polymorphism/driver.cxx delete mode 100644 examples/cxx/tree/polymorphism/makefile delete mode 100644 examples/cxx/tree/polymorphism/supermen.xml delete mode 100644 examples/cxx/tree/polymorphism/supermen.xsd delete mode 100644 examples/cxx/tree/secure/README delete mode 100644 examples/cxx/tree/secure/driver.cxx delete mode 100644 examples/cxx/tree/secure/library.xml delete mode 100644 examples/cxx/tree/secure/library.xsd delete mode 100644 examples/cxx/tree/secure/makefile delete mode 100644 examples/cxx/tree/secure/secure-dom-parser.cxx delete mode 100644 examples/cxx/tree/secure/secure-dom-parser.hxx delete mode 100644 examples/cxx/tree/streaming/README delete mode 100644 examples/cxx/tree/streaming/driver.cxx delete mode 100644 examples/cxx/tree/streaming/grammar-input-stream.cxx delete mode 100644 examples/cxx/tree/streaming/grammar-input-stream.hxx delete mode 100644 examples/cxx/tree/streaming/makefile delete mode 100644 examples/cxx/tree/streaming/parser.cxx delete mode 100644 examples/cxx/tree/streaming/parser.hxx delete mode 100644 examples/cxx/tree/streaming/position.xml delete mode 100644 examples/cxx/tree/streaming/position.xsd delete mode 100644 examples/cxx/tree/streaming/serializer.cxx delete mode 100644 examples/cxx/tree/streaming/serializer.hxx delete mode 100644 examples/cxx/tree/wildcard/README delete mode 100644 examples/cxx/tree/wildcard/driver.cxx delete mode 100644 examples/cxx/tree/wildcard/email.xml delete mode 100644 examples/cxx/tree/wildcard/email.xsd delete mode 100644 examples/cxx/tree/wildcard/makefile delete mode 100644 examples/cxx/tree/xpath/README delete mode 100644 examples/cxx/tree/xpath/dom-parse.cxx delete mode 100644 examples/cxx/tree/xpath/dom-parse.hxx delete mode 100644 examples/cxx/tree/xpath/driver.cxx delete mode 100644 examples/cxx/tree/xpath/makefile delete mode 100644 examples/cxx/tree/xpath/people.xml delete mode 100644 examples/cxx/tree/xpath/people.xsd delete mode 100644 examples/makefile create mode 100644 libxsd-tests/.gitignore create mode 120000 libxsd-tests/FLOSSE create mode 120000 libxsd-tests/GPLv2 create mode 120000 libxsd-tests/LICENSE create mode 100644 libxsd-tests/README create mode 100644 libxsd-tests/build/.gitignore create mode 100644 libxsd-tests/build/bootstrap.build create mode 100644 libxsd-tests/build/root.build create mode 100644 libxsd-tests/buildfile create mode 100644 libxsd-tests/cxx/parser/expat/basic/buildfile create mode 100644 libxsd-tests/cxx/parser/expat/basic/driver.cxx create mode 100644 libxsd-tests/cxx/parser/expat/basic/testscript create mode 100644 libxsd-tests/cxx/parser/xerces/basic/buildfile create mode 100644 libxsd-tests/cxx/parser/xerces/basic/driver.cxx create mode 100644 libxsd-tests/cxx/parser/xerces/basic/testscript create mode 100644 libxsd-tests/cxx/tree/basic/buildfile create mode 100644 libxsd-tests/cxx/tree/basic/driver.cxx create mode 100644 libxsd-tests/cxx/tree/basic/testscript create mode 100644 libxsd-tests/manifest create mode 100644 libxsd/.gitignore mode change 100644 => 120000 libxsd/FLOSSE mode change 100644 => 120000 libxsd/GPLv2 mode change 100644 => 120000 libxsd/LICENSE create mode 100644 libxsd/NEWS create mode 100644 libxsd/README-GIT create mode 100644 libxsd/build/.gitignore create mode 100644 libxsd/build/bootstrap.build create mode 100644 libxsd/build/export.build create mode 100644 libxsd/build/root.build create mode 100644 libxsd/buildfile create mode 100644 libxsd/doc/buildfile create mode 100644 libxsd/doc/cxx/tree/reference/.gitignore create mode 100644 libxsd/doc/cxx/tree/reference/footer.html.in create mode 100644 libxsd/doc/cxx/tree/reference/libxsd.doxygen.in delete mode 100644 libxsd/makefile create mode 100644 libxsd/manifest create mode 100644 libxsd/xsd/buildfile create mode 100644 libxsd/xsd/cxx/version.hxx.in delete mode 100644 makefile create mode 100644 packages.manifest create mode 100644 repositories.manifest delete mode 100644 tests/clash/clash.xsd delete mode 100644 tests/clash/foo.xsd delete mode 100644 tests/code/name-conflict/test.xsd delete mode 100644 tests/code/name-escaping/test.xsd delete mode 100644 tests/cxx/makefile delete mode 100644 tests/cxx/parser/built-in/driver.cxx delete mode 100644 tests/cxx/parser/built-in/makefile delete mode 100644 tests/cxx/parser/built-in/output delete mode 100644 tests/cxx/parser/built-in/test.xml delete mode 100644 tests/cxx/parser/built-in/test.xsd delete mode 100644 tests/cxx/parser/enumeration/driver.cxx delete mode 100644 tests/cxx/parser/enumeration/gender.hxx delete mode 100644 tests/cxx/parser/enumeration/makefile delete mode 100644 tests/cxx/parser/enumeration/output delete mode 100644 tests/cxx/parser/enumeration/test.map delete mode 100644 tests/cxx/parser/enumeration/test.xml delete mode 100644 tests/cxx/parser/enumeration/test.xsd delete mode 100644 tests/cxx/parser/generated-impl/makefile delete mode 100644 tests/cxx/parser/generated-impl/output delete mode 100644 tests/cxx/parser/generated-impl/test.xml delete mode 100644 tests/cxx/parser/generated-impl/test.xsd delete mode 100644 tests/cxx/parser/list/driver.cxx delete mode 100644 tests/cxx/parser/list/makefile delete mode 100644 tests/cxx/parser/list/output delete mode 100644 tests/cxx/parser/list/test.xml delete mode 100644 tests/cxx/parser/list/test.xsd delete mode 100644 tests/cxx/parser/makefile delete mode 100644 tests/cxx/parser/name-clash/inheritance/driver.cxx delete mode 100644 tests/cxx/parser/name-clash/inheritance/makefile delete mode 100644 tests/cxx/parser/name-clash/inheritance/output delete mode 100644 tests/cxx/parser/name-clash/inheritance/test.xml delete mode 100644 tests/cxx/parser/name-clash/inheritance/test.xsd delete mode 100644 tests/cxx/parser/polymorphism/makefile delete mode 100644 tests/cxx/parser/polymorphism/recursive/driver.cxx delete mode 100644 tests/cxx/parser/polymorphism/recursive/makefile delete mode 100644 tests/cxx/parser/polymorphism/recursive/output delete mode 100644 tests/cxx/parser/polymorphism/recursive/test-pimpl.cxx delete mode 100644 tests/cxx/parser/polymorphism/recursive/test-pimpl.hxx delete mode 100644 tests/cxx/parser/polymorphism/recursive/test.xml delete mode 100644 tests/cxx/parser/polymorphism/recursive/test.xsd delete mode 100644 tests/cxx/parser/polymorphism/same-type/driver.cxx delete mode 100644 tests/cxx/parser/polymorphism/same-type/makefile delete mode 100644 tests/cxx/parser/polymorphism/same-type/output delete mode 100644 tests/cxx/parser/polymorphism/same-type/test.xml delete mode 100644 tests/cxx/parser/polymorphism/same-type/test.xsd delete mode 100644 tests/cxx/parser/recursive/driver.cxx delete mode 100644 tests/cxx/parser/recursive/makefile delete mode 100644 tests/cxx/parser/recursive/output delete mode 100644 tests/cxx/parser/recursive/test.xml delete mode 100644 tests/cxx/parser/recursive/test.xsd delete mode 100644 tests/cxx/parser/test-template/driver.cxx delete mode 100644 tests/cxx/parser/test-template/makefile delete mode 100644 tests/cxx/parser/test-template/output delete mode 100644 tests/cxx/parser/test-template/test.xml delete mode 100644 tests/cxx/parser/test-template/test.xsd delete mode 100644 tests/cxx/parser/union/driver.cxx delete mode 100644 tests/cxx/parser/union/makefile delete mode 100644 tests/cxx/parser/union/output delete mode 100644 tests/cxx/parser/union/test.xml delete mode 100644 tests/cxx/parser/union/test.xsd delete mode 100644 tests/cxx/parser/validation/all/driver.cxx delete mode 100644 tests/cxx/parser/validation/all/makefile delete mode 100644 tests/cxx/parser/validation/all/test-000.std delete mode 100644 tests/cxx/parser/validation/all/test-000.xml delete mode 100644 tests/cxx/parser/validation/all/test-001.std delete mode 100644 tests/cxx/parser/validation/all/test-001.xml delete mode 100644 tests/cxx/parser/validation/all/test-002.std delete mode 100644 tests/cxx/parser/validation/all/test-002.xml delete mode 100644 tests/cxx/parser/validation/all/test-003.std delete mode 100644 tests/cxx/parser/validation/all/test-003.xml delete mode 100644 tests/cxx/parser/validation/all/test.xsd delete mode 100644 tests/cxx/parser/validation/any/driver.cxx delete mode 100644 tests/cxx/parser/validation/any/makefile delete mode 100644 tests/cxx/parser/validation/any/test-000.std delete mode 100644 tests/cxx/parser/validation/any/test-000.xml delete mode 100644 tests/cxx/parser/validation/any/test.xsd delete mode 100644 tests/cxx/parser/validation/attribute/driver.cxx delete mode 100644 tests/cxx/parser/validation/attribute/makefile delete mode 100644 tests/cxx/parser/validation/attribute/test-000.std delete mode 100644 tests/cxx/parser/validation/attribute/test-000.xml delete mode 100644 tests/cxx/parser/validation/attribute/test.xsd delete mode 100644 tests/cxx/parser/validation/built-in/any-type/driver.cxx delete mode 100644 tests/cxx/parser/validation/built-in/any-type/makefile delete mode 100644 tests/cxx/parser/validation/built-in/any-type/test-000.std delete mode 100644 tests/cxx/parser/validation/built-in/any-type/test-000.xml delete mode 100644 tests/cxx/parser/validation/built-in/any-type/test.xsd delete mode 100644 tests/cxx/parser/validation/built-in/binary/driver.cxx delete mode 100644 tests/cxx/parser/validation/built-in/binary/makefile delete mode 100644 tests/cxx/parser/validation/built-in/boolean/driver.cxx delete mode 100644 tests/cxx/parser/validation/built-in/boolean/makefile delete mode 100644 tests/cxx/parser/validation/built-in/byte/driver.cxx delete mode 100644 tests/cxx/parser/validation/built-in/byte/makefile delete mode 100644 tests/cxx/parser/validation/built-in/date-time/driver.cxx delete mode 100644 tests/cxx/parser/validation/built-in/date-time/makefile delete mode 100644 tests/cxx/parser/validation/built-in/float/driver.cxx delete mode 100644 tests/cxx/parser/validation/built-in/float/makefile delete mode 100644 tests/cxx/parser/validation/built-in/int/driver.cxx delete mode 100644 tests/cxx/parser/validation/built-in/int/makefile delete mode 100644 tests/cxx/parser/validation/built-in/integer/driver.cxx delete mode 100644 tests/cxx/parser/validation/built-in/integer/makefile delete mode 100644 tests/cxx/parser/validation/built-in/long/driver.cxx delete mode 100644 tests/cxx/parser/validation/built-in/long/makefile delete mode 100644 tests/cxx/parser/validation/built-in/makefile delete mode 100644 tests/cxx/parser/validation/built-in/qname/driver.cxx delete mode 100644 tests/cxx/parser/validation/built-in/qname/makefile delete mode 100644 tests/cxx/parser/validation/built-in/short/driver.cxx delete mode 100644 tests/cxx/parser/validation/built-in/short/makefile delete mode 100644 tests/cxx/parser/validation/built-in/string/driver.cxx delete mode 100644 tests/cxx/parser/validation/built-in/string/makefile delete mode 100644 tests/cxx/parser/validation/built-in/uri/driver.cxx delete mode 100644 tests/cxx/parser/validation/built-in/uri/makefile delete mode 100644 tests/cxx/parser/validation/choice/driver.cxx delete mode 100644 tests/cxx/parser/validation/choice/makefile delete mode 100644 tests/cxx/parser/validation/choice/test-000.std delete mode 100644 tests/cxx/parser/validation/choice/test-000.xml delete mode 100644 tests/cxx/parser/validation/choice/test-001.std delete mode 100644 tests/cxx/parser/validation/choice/test-001.xml delete mode 100644 tests/cxx/parser/validation/choice/test-002.std delete mode 100644 tests/cxx/parser/validation/choice/test-002.xml delete mode 100644 tests/cxx/parser/validation/choice/test-003.std delete mode 100644 tests/cxx/parser/validation/choice/test-003.xml delete mode 100644 tests/cxx/parser/validation/choice/test-004.std delete mode 100644 tests/cxx/parser/validation/choice/test-004.xml delete mode 100644 tests/cxx/parser/validation/choice/test.xsd delete mode 100644 tests/cxx/parser/validation/makefile delete mode 100644 tests/cxx/parser/validation/restriction/driver.cxx delete mode 100644 tests/cxx/parser/validation/restriction/makefile delete mode 100644 tests/cxx/parser/validation/restriction/test-000.std delete mode 100644 tests/cxx/parser/validation/restriction/test-000.xml delete mode 100644 tests/cxx/parser/validation/restriction/test-001.std delete mode 100644 tests/cxx/parser/validation/restriction/test-001.xml delete mode 100644 tests/cxx/parser/validation/restriction/test-002.std delete mode 100644 tests/cxx/parser/validation/restriction/test-002.xml delete mode 100644 tests/cxx/parser/validation/restriction/test-003.std delete mode 100644 tests/cxx/parser/validation/restriction/test-003.xml delete mode 100644 tests/cxx/parser/validation/restriction/test-004.std delete mode 100644 tests/cxx/parser/validation/restriction/test-004.xml delete mode 100644 tests/cxx/parser/validation/restriction/test-005.std delete mode 100644 tests/cxx/parser/validation/restriction/test-005.xml delete mode 100644 tests/cxx/parser/validation/restriction/test.xsd delete mode 100644 tests/cxx/parser/validation/sequence/driver.cxx delete mode 100644 tests/cxx/parser/validation/sequence/makefile delete mode 100644 tests/cxx/parser/validation/sequence/test-000.std delete mode 100644 tests/cxx/parser/validation/sequence/test-000.xml delete mode 100644 tests/cxx/parser/validation/sequence/test-001.std delete mode 100644 tests/cxx/parser/validation/sequence/test-001.xml delete mode 100644 tests/cxx/parser/validation/sequence/test-002.std delete mode 100644 tests/cxx/parser/validation/sequence/test-002.xml delete mode 100644 tests/cxx/parser/validation/sequence/test-003.std delete mode 100644 tests/cxx/parser/validation/sequence/test-003.xml delete mode 100644 tests/cxx/parser/validation/sequence/test-004.std delete mode 100644 tests/cxx/parser/validation/sequence/test-004.xml delete mode 100644 tests/cxx/parser/validation/sequence/test-005.std delete mode 100644 tests/cxx/parser/validation/sequence/test-005.xml delete mode 100644 tests/cxx/parser/validation/sequence/test-006.std delete mode 100644 tests/cxx/parser/validation/sequence/test-006.xml delete mode 100644 tests/cxx/parser/validation/sequence/test.xsd delete mode 100644 tests/cxx/tree/any-type/driver.cxx delete mode 100644 tests/cxx/tree/any-type/makefile delete mode 100644 tests/cxx/tree/any-type/output delete mode 100644 tests/cxx/tree/any-type/test.xml delete mode 100644 tests/cxx/tree/any-type/test.xsd delete mode 100644 tests/cxx/tree/binary/cdr/driver.cxx delete mode 100644 tests/cxx/tree/binary/cdr/makefile delete mode 100644 tests/cxx/tree/binary/cdr/test.xml delete mode 100644 tests/cxx/tree/binary/cdr/test.xsd delete mode 100644 tests/cxx/tree/binary/makefile delete mode 100644 tests/cxx/tree/binary/polymorphic/driver.cxx delete mode 100644 tests/cxx/tree/binary/polymorphic/makefile delete mode 100644 tests/cxx/tree/binary/polymorphic/test.xml delete mode 100644 tests/cxx/tree/binary/polymorphic/test.xsd delete mode 100644 tests/cxx/tree/binary/xdr-ordered/driver.cxx delete mode 100644 tests/cxx/tree/binary/xdr-ordered/makefile delete mode 100644 tests/cxx/tree/binary/xdr-ordered/test.xml delete mode 100644 tests/cxx/tree/binary/xdr-ordered/test.xsd delete mode 100644 tests/cxx/tree/binary/xdr/driver.cxx delete mode 100644 tests/cxx/tree/binary/xdr/makefile delete mode 100644 tests/cxx/tree/binary/xdr/test.xml delete mode 100644 tests/cxx/tree/binary/xdr/test.xsd delete mode 100644 tests/cxx/tree/built-in/attributes.xml delete mode 100644 tests/cxx/tree/built-in/driver.cxx delete mode 100644 tests/cxx/tree/built-in/elements.xml delete mode 100644 tests/cxx/tree/built-in/inherited.xml delete mode 100644 tests/cxx/tree/built-in/makefile delete mode 100644 tests/cxx/tree/built-in/types.xsd delete mode 100644 tests/cxx/tree/chameleon/driver.cxx delete mode 100644 tests/cxx/tree/chameleon/includee.xsd delete mode 100644 tests/cxx/tree/chameleon/includer.xsd delete mode 100644 tests/cxx/tree/chameleon/makefile delete mode 100644 tests/cxx/tree/chameleon/output delete mode 100644 tests/cxx/tree/chameleon/test.xml delete mode 100644 tests/cxx/tree/comparison/driver.cxx delete mode 100644 tests/cxx/tree/comparison/makefile delete mode 100644 tests/cxx/tree/comparison/test.xml delete mode 100644 tests/cxx/tree/comparison/test.xsd delete mode 100644 tests/cxx/tree/compilation/driver.cxx delete mode 100644 tests/cxx/tree/compilation/makefile delete mode 100644 tests/cxx/tree/compilation/test.xsd delete mode 100644 tests/cxx/tree/complex/ctor/driver.cxx delete mode 100644 tests/cxx/tree/complex/ctor/makefile delete mode 100644 tests/cxx/tree/complex/ctor/test.xsd delete mode 100644 tests/cxx/tree/complex/makefile delete mode 100644 tests/cxx/tree/containment/driver.cxx delete mode 100644 tests/cxx/tree/containment/makefile delete mode 100644 tests/cxx/tree/containment/test.xsd delete mode 100644 tests/cxx/tree/default/general/driver.cxx delete mode 100644 tests/cxx/tree/default/general/makefile delete mode 100644 tests/cxx/tree/default/general/output delete mode 100644 tests/cxx/tree/default/general/test.xml delete mode 100644 tests/cxx/tree/default/general/test.xsd delete mode 100644 tests/cxx/tree/default/makefile delete mode 100644 tests/cxx/tree/default/omit/driver.cxx delete mode 100644 tests/cxx/tree/default/omit/makefile delete mode 100644 tests/cxx/tree/default/omit/output delete mode 100644 tests/cxx/tree/default/omit/test.xml delete mode 100644 tests/cxx/tree/default/omit/test.xsd delete mode 100644 tests/cxx/tree/detach/driver.cxx delete mode 100644 tests/cxx/tree/detach/makefile delete mode 100644 tests/cxx/tree/detach/test.xsd delete mode 100644 tests/cxx/tree/dom-association/dom-parse.cxx delete mode 100644 tests/cxx/tree/dom-association/dom-parse.hxx delete mode 100644 tests/cxx/tree/dom-association/driver.cxx delete mode 100644 tests/cxx/tree/dom-association/makefile delete mode 100644 tests/cxx/tree/dom-association/output delete mode 100644 tests/cxx/tree/dom-association/test.xml delete mode 100644 tests/cxx/tree/dom-association/test.xsd delete mode 100644 tests/cxx/tree/encoding/char/iso-8859-1/driver.cxx delete mode 100644 tests/cxx/tree/encoding/char/iso-8859-1/makefile delete mode 100644 tests/cxx/tree/encoding/char/iso-8859-1/test.std delete mode 100644 tests/cxx/tree/encoding/char/iso-8859-1/test.xml delete mode 100644 tests/cxx/tree/encoding/char/iso-8859-1/test.xsd delete mode 100644 tests/cxx/tree/encoding/char/lcp/driver.cxx delete mode 100644 tests/cxx/tree/encoding/char/lcp/makefile delete mode 100644 tests/cxx/tree/encoding/char/lcp/test.std delete mode 100644 tests/cxx/tree/encoding/char/lcp/test.xml delete mode 100644 tests/cxx/tree/encoding/char/lcp/test.xsd delete mode 100644 tests/cxx/tree/encoding/char/makefile delete mode 100644 tests/cxx/tree/encoding/char/utf-8/driver.cxx delete mode 100644 tests/cxx/tree/encoding/char/utf-8/makefile delete mode 100644 tests/cxx/tree/encoding/char/utf-8/test.std delete mode 100644 tests/cxx/tree/encoding/char/utf-8/test.xml delete mode 100644 tests/cxx/tree/encoding/char/utf-8/test.xsd delete mode 100644 tests/cxx/tree/encoding/makefile delete mode 100644 tests/cxx/tree/encoding/wchar/driver.cxx delete mode 100644 tests/cxx/tree/encoding/wchar/makefile delete mode 100644 tests/cxx/tree/encoding/wchar/test.std delete mode 100644 tests/cxx/tree/encoding/wchar/test.xml delete mode 100644 tests/cxx/tree/encoding/wchar/test.xsd delete mode 100644 tests/cxx/tree/enumeration/ctor/driver.cxx delete mode 100644 tests/cxx/tree/enumeration/ctor/makefile delete mode 100644 tests/cxx/tree/enumeration/ctor/test.xsd delete mode 100644 tests/cxx/tree/enumeration/inheritance/driver.cxx delete mode 100644 tests/cxx/tree/enumeration/inheritance/makefile delete mode 100644 tests/cxx/tree/enumeration/inheritance/output delete mode 100644 tests/cxx/tree/enumeration/inheritance/test.xml delete mode 100644 tests/cxx/tree/enumeration/inheritance/test.xsd delete mode 100644 tests/cxx/tree/enumeration/makefile delete mode 100644 tests/cxx/tree/float/driver.cxx delete mode 100644 tests/cxx/tree/float/makefile delete mode 100644 tests/cxx/tree/float/test.std delete mode 100644 tests/cxx/tree/float/test.xml delete mode 100644 tests/cxx/tree/float/test.xsd delete mode 100644 tests/cxx/tree/list/ctor/driver.cxx delete mode 100644 tests/cxx/tree/list/ctor/makefile delete mode 100644 tests/cxx/tree/list/ctor/test.xsd delete mode 100644 tests/cxx/tree/list/makefile delete mode 100644 tests/cxx/tree/makefile delete mode 100644 tests/cxx/tree/name-clash/inheritance/driver.cxx delete mode 100644 tests/cxx/tree/name-clash/inheritance/makefile delete mode 100644 tests/cxx/tree/name-clash/inheritance/output delete mode 100644 tests/cxx/tree/name-clash/inheritance/test.xml delete mode 100644 tests/cxx/tree/name-clash/inheritance/test.xsd delete mode 100644 tests/cxx/tree/name-clash/makefile delete mode 100644 tests/cxx/tree/naming/camel/driver.cxx delete mode 100644 tests/cxx/tree/naming/camel/makefile delete mode 100644 tests/cxx/tree/naming/camel/test.xsd delete mode 100644 tests/cxx/tree/naming/java/driver.cxx delete mode 100644 tests/cxx/tree/naming/java/makefile delete mode 100644 tests/cxx/tree/naming/java/test.xsd delete mode 100644 tests/cxx/tree/naming/knr/driver.cxx delete mode 100644 tests/cxx/tree/naming/knr/makefile delete mode 100644 tests/cxx/tree/naming/knr/test.xsd delete mode 100644 tests/cxx/tree/naming/makefile delete mode 100644 tests/cxx/tree/order/driver.cxx delete mode 100644 tests/cxx/tree/order/makefile delete mode 100644 tests/cxx/tree/order/output delete mode 100644 tests/cxx/tree/order/test.xml delete mode 100644 tests/cxx/tree/order/test.xsd delete mode 100644 tests/cxx/tree/polymorphism/comparison/driver.cxx delete mode 100644 tests/cxx/tree/polymorphism/comparison/makefile delete mode 100644 tests/cxx/tree/polymorphism/comparison/test.xml delete mode 100644 tests/cxx/tree/polymorphism/comparison/test.xsd delete mode 100644 tests/cxx/tree/polymorphism/makefile delete mode 100644 tests/cxx/tree/polymorphism/ostream/driver.cxx delete mode 100644 tests/cxx/tree/polymorphism/ostream/makefile delete mode 100644 tests/cxx/tree/polymorphism/ostream/output delete mode 100644 tests/cxx/tree/polymorphism/ostream/test.xml delete mode 100644 tests/cxx/tree/polymorphism/ostream/test.xsd delete mode 100644 tests/cxx/tree/polymorphism/same-type/driver.cxx delete mode 100644 tests/cxx/tree/polymorphism/same-type/makefile delete mode 100644 tests/cxx/tree/polymorphism/same-type/output delete mode 100644 tests/cxx/tree/polymorphism/same-type/test.xml delete mode 100644 tests/cxx/tree/polymorphism/same-type/test.xsd delete mode 100644 tests/cxx/tree/prefix/bar.xsd delete mode 100644 tests/cxx/tree/prefix/driver.cxx delete mode 100644 tests/cxx/tree/prefix/foo.xsd delete mode 100644 tests/cxx/tree/prefix/makefile delete mode 100644 tests/cxx/tree/prefix/output delete mode 100644 tests/cxx/tree/prefix/test.xml delete mode 100644 tests/cxx/tree/prefix/test.xsd delete mode 100644 tests/cxx/tree/test-template/driver.cxx delete mode 100644 tests/cxx/tree/test-template/makefile delete mode 100644 tests/cxx/tree/test-template/output delete mode 100644 tests/cxx/tree/test-template/test.xml delete mode 100644 tests/cxx/tree/test-template/test.xsd delete mode 100644 tests/cxx/tree/types-only/driver.cxx delete mode 100644 tests/cxx/tree/types-only/makefile delete mode 100644 tests/cxx/tree/types-only/test.xsd delete mode 100644 tests/cxx/tree/union/ctor/driver.cxx delete mode 100644 tests/cxx/tree/union/ctor/makefile delete mode 100644 tests/cxx/tree/union/ctor/test.xsd delete mode 100644 tests/cxx/tree/union/makefile delete mode 100644 tests/cxx/tree/wildcard/driver.cxx delete mode 100644 tests/cxx/tree/wildcard/makefile delete mode 100644 tests/cxx/tree/wildcard/output delete mode 100644 tests/cxx/tree/wildcard/test.xml delete mode 100644 tests/cxx/tree/wildcard/test.xsd delete mode 100644 tests/failed/test-00.xsd delete mode 100644 tests/makefile delete mode 100644 tests/morphing/anonymous/attribute-group/test.xsd delete mode 100644 tests/morphing/anonymous/cyclic-inclusion/includee.xsd delete mode 100644 tests/morphing/anonymous/cyclic-inclusion/includer.xsd delete mode 100644 tests/morphing/anonymous/group/test.xsd delete mode 100644 tests/morphing/anonymous/test-000.xsd delete mode 100644 tests/morphing/anonymous/unstable/includee-1.xsd delete mode 100644 tests/morphing/anonymous/unstable/includee-2.xsd delete mode 100644 tests/morphing/anonymous/unstable/includer.xsd delete mode 100644 tests/processing/inheritance/test-000.xsd delete mode 100644 tests/processing/inheritance/test-001.xsd delete mode 100644 tests/schema/anonymous/test.xsd delete mode 100644 tests/schema/any-attribute/test.xsd delete mode 100644 tests/schema/any-type/test.xsd delete mode 100644 tests/schema/any/fail.xsd delete mode 100644 tests/schema/any/test.xsd delete mode 100644 tests/schema/attribute-group/global.xsd delete mode 100644 tests/schema/attribute/global.xsd delete mode 100644 tests/schema/attribute/local.xsd delete mode 100644 tests/schema/attribute/ref.xsd delete mode 100644 tests/schema/cardinality/test.xsd delete mode 100644 tests/schema/chameleon/includer.xsd delete mode 100644 tests/schema/chameleon/schemas/includee.xsd delete mode 100644 tests/schema/enumeration/test.xsd delete mode 100644 tests/schema/forward/test.xsd delete mode 100644 tests/schema/group/global.xsd delete mode 100644 tests/schema/group/test.xsd delete mode 100644 tests/schema/import/importer.xsd delete mode 100644 tests/schema/import/schemas/importee.xsd delete mode 100644 tests/schema/include/includer.xsd delete mode 100644 tests/schema/include/schemas/includee.xsd delete mode 100644 tests/schema/inheritance/cycle.xsd delete mode 100644 tests/schema/inheritance/sourced-forward/includee.xsd delete mode 100644 tests/schema/inheritance/sourced-forward/includer.xsd delete mode 100644 tests/schema/list/anonymous/test.xsd delete mode 100644 tests/schema/list/any-simple-type/test.xsd delete mode 100644 tests/schema/list/driver.cxx delete mode 100644 tests/schema/list/test.xsd delete mode 100644 tests/schema/no-namespace/test.xsd delete mode 100644 tests/schema/recursive/test.xsd delete mode 100644 tests/schema/ref-type/idref.xsd delete mode 100644 tests/schema/ref-type/idrefs.xsd delete mode 100644 tests/schema/ref-type/invalid-0.xsd delete mode 100644 tests/schema/ref-type/invalid-1.xsd delete mode 100644 tests/schema/restriction/test.xsd delete mode 100644 tests/schema/union/test.xsd delete mode 100644 version create mode 100644 xsd-examples/.gitignore create mode 100644 xsd-examples/README create mode 100644 xsd-examples/UNLICENSE create mode 100644 xsd-examples/build/.gitignore create mode 100644 xsd-examples/build/bootstrap.build create mode 100644 xsd-examples/build/root.build create mode 100644 xsd-examples/buildfile create mode 100644 xsd-examples/cxx/parser/.gitignore create mode 100644 xsd-examples/cxx/parser/README create mode 100644 xsd-examples/cxx/parser/buildfile create mode 100644 xsd-examples/cxx/parser/generated/.gitignore create mode 100644 xsd-examples/cxx/parser/generated/README create mode 100644 xsd-examples/cxx/parser/generated/buildfile create mode 100644 xsd-examples/cxx/parser/generated/library.xml create mode 100644 xsd-examples/cxx/parser/generated/library.xsd create mode 100644 xsd-examples/cxx/parser/hello/README create mode 100644 xsd-examples/cxx/parser/hello/buildfile create mode 100644 xsd-examples/cxx/parser/hello/driver.cxx create mode 100644 xsd-examples/cxx/parser/hello/hello.xml create mode 100644 xsd-examples/cxx/parser/hello/hello.xsd create mode 100644 xsd-examples/cxx/parser/library/README create mode 100644 xsd-examples/cxx/parser/library/buildfile create mode 100644 xsd-examples/cxx/parser/library/driver.cxx create mode 100644 xsd-examples/cxx/parser/library/library-pimpl.cxx create mode 100644 xsd-examples/cxx/parser/library/library-pimpl.hxx create mode 100644 xsd-examples/cxx/parser/library/library.hxx create mode 100644 xsd-examples/cxx/parser/library/library.map create mode 100644 xsd-examples/cxx/parser/library/library.xml create mode 100644 xsd-examples/cxx/parser/library/library.xsd create mode 100644 xsd-examples/cxx/parser/mixed/README create mode 100644 xsd-examples/cxx/parser/mixed/anchor.hxx create mode 100644 xsd-examples/cxx/parser/mixed/buildfile create mode 100644 xsd-examples/cxx/parser/mixed/driver.cxx create mode 100644 xsd-examples/cxx/parser/mixed/text.map create mode 100644 xsd-examples/cxx/parser/mixed/text.xml create mode 100644 xsd-examples/cxx/parser/mixed/text.xsd create mode 100644 xsd-examples/cxx/parser/mixin/README create mode 100644 xsd-examples/cxx/parser/mixin/buildfile create mode 100644 xsd-examples/cxx/parser/mixin/driver.cxx create mode 100644 xsd-examples/cxx/parser/mixin/instance.xml create mode 100644 xsd-examples/cxx/parser/mixin/schema.map create mode 100644 xsd-examples/cxx/parser/mixin/schema.xsd create mode 100644 xsd-examples/cxx/parser/mixin/types.hxx create mode 100644 xsd-examples/cxx/parser/multiroot/README create mode 100644 xsd-examples/cxx/parser/multiroot/balance.xml create mode 100644 xsd-examples/cxx/parser/multiroot/buildfile create mode 100644 xsd-examples/cxx/parser/multiroot/deposit.xml create mode 100644 xsd-examples/cxx/parser/multiroot/driver.cxx create mode 100644 xsd-examples/cxx/parser/multiroot/protocol-pimpl.cxx create mode 100644 xsd-examples/cxx/parser/multiroot/protocol-pimpl.hxx create mode 100644 xsd-examples/cxx/parser/multiroot/protocol.hxx create mode 100644 xsd-examples/cxx/parser/multiroot/protocol.map create mode 100644 xsd-examples/cxx/parser/multiroot/protocol.xsd create mode 100644 xsd-examples/cxx/parser/multiroot/testscript create mode 100644 xsd-examples/cxx/parser/multiroot/withdraw.xml create mode 100644 xsd-examples/cxx/parser/performance/.gitignore create mode 100644 xsd-examples/cxx/parser/performance/README create mode 100644 xsd-examples/cxx/parser/performance/buildfile create mode 100644 xsd-examples/cxx/parser/performance/driver.cxx create mode 100644 xsd-examples/cxx/parser/performance/gen.cxx create mode 100644 xsd-examples/cxx/parser/performance/gen.testscript create mode 100644 xsd-examples/cxx/parser/performance/test-50k.xml create mode 100644 xsd-examples/cxx/parser/performance/test.xsd create mode 100644 xsd-examples/cxx/parser/performance/time.cxx create mode 100644 xsd-examples/cxx/parser/performance/time.hxx create mode 100644 xsd-examples/cxx/parser/polymorphism/README create mode 100644 xsd-examples/cxx/parser/polymorphism/buildfile create mode 100644 xsd-examples/cxx/parser/polymorphism/driver.cxx create mode 100644 xsd-examples/cxx/parser/polymorphism/supermen-pimpl.cxx create mode 100644 xsd-examples/cxx/parser/polymorphism/supermen-pimpl.hxx create mode 100644 xsd-examples/cxx/parser/polymorphism/supermen.xml create mode 100644 xsd-examples/cxx/parser/polymorphism/supermen.xsd create mode 100644 xsd-examples/cxx/parser/polyroot/README create mode 100644 xsd-examples/cxx/parser/polyroot/batman.xml create mode 100644 xsd-examples/cxx/parser/polyroot/buildfile create mode 100644 xsd-examples/cxx/parser/polyroot/driver.cxx create mode 100644 xsd-examples/cxx/parser/polyroot/person.xml create mode 100644 xsd-examples/cxx/parser/polyroot/superman.xml create mode 100644 xsd-examples/cxx/parser/polyroot/supermen-pimpl.cxx create mode 100644 xsd-examples/cxx/parser/polyroot/supermen-pimpl.hxx create mode 100644 xsd-examples/cxx/parser/polyroot/supermen.xsd create mode 100644 xsd-examples/cxx/parser/polyroot/testscript create mode 100644 xsd-examples/cxx/parser/wildcard/README create mode 100644 xsd-examples/cxx/parser/wildcard/buildfile create mode 100644 xsd-examples/cxx/parser/wildcard/driver.cxx create mode 100644 xsd-examples/cxx/parser/wildcard/email.xml create mode 100644 xsd-examples/cxx/parser/wildcard/email.xsd create mode 100644 xsd-examples/cxx/tree/README create mode 100644 xsd-examples/cxx/tree/binary/README create mode 100644 xsd-examples/cxx/tree/binary/boost/.gitignore create mode 100644 xsd-examples/cxx/tree/binary/boost/README create mode 100644 xsd-examples/cxx/tree/binary/boost/boost-archive-extraction.hxx create mode 100644 xsd-examples/cxx/tree/binary/boost/boost-archive-insertion.hxx create mode 100644 xsd-examples/cxx/tree/binary/boost/buildfile create mode 100644 xsd-examples/cxx/tree/binary/boost/driver.cxx create mode 100644 xsd-examples/cxx/tree/binary/boost/library-prologue.hxx create mode 100644 xsd-examples/cxx/tree/binary/boost/library.xml create mode 100644 xsd-examples/cxx/tree/binary/boost/library.xsd create mode 100644 xsd-examples/cxx/tree/binary/cdr/.gitignore create mode 100644 xsd-examples/cxx/tree/binary/cdr/README create mode 100644 xsd-examples/cxx/tree/binary/cdr/buildfile create mode 100644 xsd-examples/cxx/tree/binary/cdr/driver.cxx create mode 100644 xsd-examples/cxx/tree/binary/cdr/library.xml create mode 100644 xsd-examples/cxx/tree/binary/cdr/library.xsd create mode 100644 xsd-examples/cxx/tree/binary/xdr/.gitignore create mode 100644 xsd-examples/cxx/tree/binary/xdr/README create mode 100644 xsd-examples/cxx/tree/binary/xdr/buildfile create mode 100644 xsd-examples/cxx/tree/binary/xdr/driver.cxx create mode 100644 xsd-examples/cxx/tree/binary/xdr/library.xml create mode 100644 xsd-examples/cxx/tree/binary/xdr/library.xsd create mode 100644 xsd-examples/cxx/tree/buildfile create mode 100644 xsd-examples/cxx/tree/caching/.gitignore create mode 100644 xsd-examples/cxx/tree/caching/README create mode 100644 xsd-examples/cxx/tree/caching/buildfile create mode 100644 xsd-examples/cxx/tree/caching/driver.cxx create mode 100644 xsd-examples/cxx/tree/caching/library.xml create mode 100644 xsd-examples/cxx/tree/caching/library.xsd create mode 100644 xsd-examples/cxx/tree/compression/.gitignore create mode 100644 xsd-examples/cxx/tree/compression/README create mode 100644 xsd-examples/cxx/tree/compression/buildfile create mode 100644 xsd-examples/cxx/tree/compression/compressed-format-target.cxx create mode 100644 xsd-examples/cxx/tree/compression/compressed-format-target.hxx create mode 100644 xsd-examples/cxx/tree/compression/compressed-input-source.cxx create mode 100644 xsd-examples/cxx/tree/compression/compressed-input-source.hxx create mode 100644 xsd-examples/cxx/tree/compression/driver.cxx create mode 100644 xsd-examples/cxx/tree/compression/library.xml.gz create mode 100644 xsd-examples/cxx/tree/compression/library.xsd create mode 100644 xsd-examples/cxx/tree/compression/testscript create mode 100644 xsd-examples/cxx/tree/custom/README create mode 100644 xsd-examples/cxx/tree/custom/buildfile create mode 100644 xsd-examples/cxx/tree/custom/calendar/.gitignore create mode 100644 xsd-examples/cxx/tree/custom/calendar/README create mode 100644 xsd-examples/cxx/tree/custom/calendar/buildfile create mode 100644 xsd-examples/cxx/tree/custom/calendar/calendar.xml create mode 100644 xsd-examples/cxx/tree/custom/calendar/calendar.xsd create mode 100644 xsd-examples/cxx/tree/custom/calendar/driver.cxx create mode 100644 xsd-examples/cxx/tree/custom/calendar/xml-schema-custom.cxx create mode 100644 xsd-examples/cxx/tree/custom/calendar/xml-schema-custom.hxx create mode 100644 xsd-examples/cxx/tree/custom/comments/.gitignore create mode 100644 xsd-examples/cxx/tree/custom/comments/README create mode 100644 xsd-examples/cxx/tree/custom/comments/buildfile create mode 100644 xsd-examples/cxx/tree/custom/comments/dom-parse.cxx create mode 100644 xsd-examples/cxx/tree/custom/comments/dom-parse.hxx create mode 100644 xsd-examples/cxx/tree/custom/comments/driver.cxx create mode 100644 xsd-examples/cxx/tree/custom/comments/people.xml create mode 100644 xsd-examples/cxx/tree/custom/comments/people.xsd create mode 100644 xsd-examples/cxx/tree/custom/comments/xml-schema-custom.cxx create mode 100644 xsd-examples/cxx/tree/custom/comments/xml-schema-custom.hxx create mode 100644 xsd-examples/cxx/tree/custom/contacts/.gitignore create mode 100644 xsd-examples/cxx/tree/custom/contacts/README create mode 100644 xsd-examples/cxx/tree/custom/contacts/buildfile create mode 100644 xsd-examples/cxx/tree/custom/contacts/contacts-custom.cxx create mode 100644 xsd-examples/cxx/tree/custom/contacts/contacts-custom.hxx create mode 100644 xsd-examples/cxx/tree/custom/contacts/contacts.xml create mode 100644 xsd-examples/cxx/tree/custom/contacts/contacts.xsd create mode 100644 xsd-examples/cxx/tree/custom/contacts/driver.cxx create mode 100644 xsd-examples/cxx/tree/custom/double/.gitignore create mode 100644 xsd-examples/cxx/tree/custom/double/README create mode 100644 xsd-examples/cxx/tree/custom/double/buildfile create mode 100644 xsd-examples/cxx/tree/custom/double/double-custom.cxx create mode 100644 xsd-examples/cxx/tree/custom/double/double-custom.hxx create mode 100644 xsd-examples/cxx/tree/custom/double/driver.cxx create mode 100644 xsd-examples/cxx/tree/custom/double/order.xsd create mode 100644 xsd-examples/cxx/tree/custom/mixed/.gitignore create mode 100644 xsd-examples/cxx/tree/custom/mixed/README create mode 100644 xsd-examples/cxx/tree/custom/mixed/buildfile create mode 100644 xsd-examples/cxx/tree/custom/mixed/driver.cxx create mode 100644 xsd-examples/cxx/tree/custom/mixed/people-custom.cxx create mode 100644 xsd-examples/cxx/tree/custom/mixed/people-custom.hxx create mode 100644 xsd-examples/cxx/tree/custom/mixed/people.xml create mode 100644 xsd-examples/cxx/tree/custom/mixed/people.xsd create mode 100644 xsd-examples/cxx/tree/custom/taxonomy/.gitignore create mode 100644 xsd-examples/cxx/tree/custom/taxonomy/README create mode 100644 xsd-examples/cxx/tree/custom/taxonomy/buildfile create mode 100644 xsd-examples/cxx/tree/custom/taxonomy/driver.cxx create mode 100644 xsd-examples/cxx/tree/custom/taxonomy/people-custom-fwd.hxx create mode 100644 xsd-examples/cxx/tree/custom/taxonomy/people-custom.cxx create mode 100644 xsd-examples/cxx/tree/custom/taxonomy/people-custom.hxx create mode 100644 xsd-examples/cxx/tree/custom/taxonomy/people.xml create mode 100644 xsd-examples/cxx/tree/custom/taxonomy/people.xsd create mode 100644 xsd-examples/cxx/tree/custom/wildcard/.gitignore create mode 100644 xsd-examples/cxx/tree/custom/wildcard/README create mode 100644 xsd-examples/cxx/tree/custom/wildcard/buildfile create mode 100644 xsd-examples/cxx/tree/custom/wildcard/driver.cxx create mode 100644 xsd-examples/cxx/tree/custom/wildcard/wildcard-custom.cxx create mode 100644 xsd-examples/cxx/tree/custom/wildcard/wildcard-custom.hxx create mode 100644 xsd-examples/cxx/tree/custom/wildcard/wildcard.xml create mode 100644 xsd-examples/cxx/tree/custom/wildcard/wildcard.xsd create mode 100644 xsd-examples/cxx/tree/embedded/.gitignore create mode 100644 xsd-examples/cxx/tree/embedded/README create mode 100644 xsd-examples/cxx/tree/embedded/buildfile create mode 100644 xsd-examples/cxx/tree/embedded/driver.cxx create mode 100644 xsd-examples/cxx/tree/embedded/grammar-input-stream.cxx create mode 100644 xsd-examples/cxx/tree/embedded/grammar-input-stream.hxx create mode 100644 xsd-examples/cxx/tree/embedded/library.xml create mode 100644 xsd-examples/cxx/tree/embedded/library.xsd create mode 100644 xsd-examples/cxx/tree/embedded/xsdbin.cxx create mode 100644 xsd-examples/cxx/tree/hello/.gitignore create mode 100644 xsd-examples/cxx/tree/hello/README create mode 100644 xsd-examples/cxx/tree/hello/buildfile create mode 100644 xsd-examples/cxx/tree/hello/driver.cxx create mode 100644 xsd-examples/cxx/tree/hello/hello.xml create mode 100644 xsd-examples/cxx/tree/hello/hello.xsd create mode 100644 xsd-examples/cxx/tree/library/.gitignore create mode 100644 xsd-examples/cxx/tree/library/README create mode 100644 xsd-examples/cxx/tree/library/buildfile create mode 100644 xsd-examples/cxx/tree/library/driver.cxx create mode 100644 xsd-examples/cxx/tree/library/library.xml create mode 100644 xsd-examples/cxx/tree/library/library.xsd create mode 100644 xsd-examples/cxx/tree/messaging/.gitignore create mode 100644 xsd-examples/cxx/tree/messaging/README create mode 100644 xsd-examples/cxx/tree/messaging/balance.xml create mode 100644 xsd-examples/cxx/tree/messaging/buildfile create mode 100644 xsd-examples/cxx/tree/messaging/deposit.xml create mode 100644 xsd-examples/cxx/tree/messaging/dom-parse.cxx create mode 100644 xsd-examples/cxx/tree/messaging/dom-parse.hxx create mode 100644 xsd-examples/cxx/tree/messaging/dom-serialize.cxx create mode 100644 xsd-examples/cxx/tree/messaging/dom-serialize.hxx create mode 100644 xsd-examples/cxx/tree/messaging/driver.cxx create mode 100644 xsd-examples/cxx/tree/messaging/protocol.xsd create mode 100644 xsd-examples/cxx/tree/messaging/testscript create mode 100644 xsd-examples/cxx/tree/messaging/withdraw.xml create mode 100644 xsd-examples/cxx/tree/mixed/.gitignore create mode 100644 xsd-examples/cxx/tree/mixed/README create mode 100644 xsd-examples/cxx/tree/mixed/buildfile create mode 100644 xsd-examples/cxx/tree/mixed/driver.cxx create mode 100644 xsd-examples/cxx/tree/mixed/text.xml create mode 100644 xsd-examples/cxx/tree/mixed/text.xsd create mode 100644 xsd-examples/cxx/tree/multiroot/.gitignore create mode 100644 xsd-examples/cxx/tree/multiroot/README create mode 100644 xsd-examples/cxx/tree/multiroot/balance.xml create mode 100644 xsd-examples/cxx/tree/multiroot/buildfile create mode 100644 xsd-examples/cxx/tree/multiroot/deposit.xml create mode 100644 xsd-examples/cxx/tree/multiroot/dom-parse.cxx create mode 100644 xsd-examples/cxx/tree/multiroot/dom-parse.hxx create mode 100644 xsd-examples/cxx/tree/multiroot/driver.cxx create mode 100644 xsd-examples/cxx/tree/multiroot/protocol.xsd create mode 100644 xsd-examples/cxx/tree/multiroot/testscript create mode 100644 xsd-examples/cxx/tree/multiroot/withdraw.xml create mode 100644 xsd-examples/cxx/tree/order/README create mode 100644 xsd-examples/cxx/tree/order/element/.gitignore create mode 100644 xsd-examples/cxx/tree/order/element/README create mode 100644 xsd-examples/cxx/tree/order/element/buildfile create mode 100644 xsd-examples/cxx/tree/order/element/driver.cxx create mode 100644 xsd-examples/cxx/tree/order/element/transactions.xml create mode 100644 xsd-examples/cxx/tree/order/element/transactions.xsd create mode 100644 xsd-examples/cxx/tree/order/mixed/.gitignore create mode 100644 xsd-examples/cxx/tree/order/mixed/README create mode 100644 xsd-examples/cxx/tree/order/mixed/buildfile create mode 100644 xsd-examples/cxx/tree/order/mixed/driver.cxx create mode 100644 xsd-examples/cxx/tree/order/mixed/text.xml create mode 100644 xsd-examples/cxx/tree/order/mixed/text.xsd create mode 100644 xsd-examples/cxx/tree/performance/.gitignore create mode 100644 xsd-examples/cxx/tree/performance/README create mode 100644 xsd-examples/cxx/tree/performance/buildfile create mode 100644 xsd-examples/cxx/tree/performance/driver.cxx create mode 100644 xsd-examples/cxx/tree/performance/gen.cxx create mode 100644 xsd-examples/cxx/tree/performance/gen.testscript create mode 100644 xsd-examples/cxx/tree/performance/parsing.cxx create mode 100644 xsd-examples/cxx/tree/performance/serialization.cxx create mode 100644 xsd-examples/cxx/tree/performance/test-50k.xml create mode 100644 xsd-examples/cxx/tree/performance/test.xsd create mode 100644 xsd-examples/cxx/tree/performance/time.cxx create mode 100644 xsd-examples/cxx/tree/performance/time.hxx create mode 100644 xsd-examples/cxx/tree/polymorphism/.gitignore create mode 100644 xsd-examples/cxx/tree/polymorphism/README create mode 100644 xsd-examples/cxx/tree/polymorphism/buildfile create mode 100644 xsd-examples/cxx/tree/polymorphism/driver.cxx create mode 100644 xsd-examples/cxx/tree/polymorphism/supermen.xml create mode 100644 xsd-examples/cxx/tree/polymorphism/supermen.xsd create mode 100644 xsd-examples/cxx/tree/secure/.gitignore create mode 100644 xsd-examples/cxx/tree/secure/README create mode 100644 xsd-examples/cxx/tree/secure/buildfile create mode 100644 xsd-examples/cxx/tree/secure/driver.cxx create mode 100644 xsd-examples/cxx/tree/secure/library.xml create mode 100644 xsd-examples/cxx/tree/secure/library.xsd create mode 100644 xsd-examples/cxx/tree/secure/secure-dom-parser.cxx create mode 100644 xsd-examples/cxx/tree/secure/secure-dom-parser.hxx create mode 100644 xsd-examples/cxx/tree/streaming/.gitignore create mode 100644 xsd-examples/cxx/tree/streaming/README create mode 100644 xsd-examples/cxx/tree/streaming/buildfile create mode 100644 xsd-examples/cxx/tree/streaming/driver.cxx create mode 100644 xsd-examples/cxx/tree/streaming/grammar-input-stream.cxx create mode 100644 xsd-examples/cxx/tree/streaming/grammar-input-stream.hxx create mode 100644 xsd-examples/cxx/tree/streaming/parser.cxx create mode 100644 xsd-examples/cxx/tree/streaming/parser.hxx create mode 100644 xsd-examples/cxx/tree/streaming/position.xml create mode 100644 xsd-examples/cxx/tree/streaming/position.xsd create mode 100644 xsd-examples/cxx/tree/streaming/serializer.cxx create mode 100644 xsd-examples/cxx/tree/streaming/serializer.hxx create mode 100644 xsd-examples/cxx/tree/streaming/testscript create mode 100644 xsd-examples/cxx/tree/wildcard/.gitignore create mode 100644 xsd-examples/cxx/tree/wildcard/README create mode 100644 xsd-examples/cxx/tree/wildcard/buildfile create mode 100644 xsd-examples/cxx/tree/wildcard/driver.cxx create mode 100644 xsd-examples/cxx/tree/wildcard/email.xml create mode 100644 xsd-examples/cxx/tree/wildcard/email.xsd create mode 100644 xsd-examples/cxx/tree/xpath/.gitignore create mode 100644 xsd-examples/cxx/tree/xpath/README create mode 100644 xsd-examples/cxx/tree/xpath/buildfile create mode 100644 xsd-examples/cxx/tree/xpath/dom-parse.cxx create mode 100644 xsd-examples/cxx/tree/xpath/dom-parse.hxx create mode 100644 xsd-examples/cxx/tree/xpath/driver.cxx create mode 100644 xsd-examples/cxx/tree/xpath/people.xml create mode 100644 xsd-examples/cxx/tree/xpath/people.xsd create mode 100644 xsd-examples/manifest create mode 100644 xsd-tests/.gitignore create mode 120000 xsd-tests/FLOSSE create mode 120000 xsd-tests/GPLv2 create mode 120000 xsd-tests/LICENSE create mode 100644 xsd-tests/README create mode 100644 xsd-tests/build/.gitignore create mode 100644 xsd-tests/build/bootstrap.build create mode 100644 xsd-tests/build/root.build create mode 100644 xsd-tests/buildfile create mode 100644 xsd-tests/clash/.gitignore create mode 100644 xsd-tests/clash/buildfile create mode 100644 xsd-tests/clash/clash.xsd create mode 100644 xsd-tests/clash/driver.cxx create mode 100644 xsd-tests/clash/foo.xsd create mode 100644 xsd-tests/code/name-conflict/buildfile create mode 100644 xsd-tests/code/name-conflict/driver.cxx create mode 100644 xsd-tests/code/name-conflict/test.xsd create mode 100644 xsd-tests/code/name-escaping/buildfile create mode 100644 xsd-tests/code/name-escaping/driver.cxx create mode 100644 xsd-tests/code/name-escaping/test.xsd create mode 100644 xsd-tests/cxx/parser/.gitignore create mode 100644 xsd-tests/cxx/parser/built-in/buildfile create mode 100644 xsd-tests/cxx/parser/built-in/driver.cxx create mode 100644 xsd-tests/cxx/parser/built-in/output create mode 100644 xsd-tests/cxx/parser/built-in/test.xml create mode 100644 xsd-tests/cxx/parser/built-in/test.xsd create mode 100644 xsd-tests/cxx/parser/enumeration/buildfile create mode 100644 xsd-tests/cxx/parser/enumeration/driver.cxx create mode 100644 xsd-tests/cxx/parser/enumeration/gender.hxx create mode 100644 xsd-tests/cxx/parser/enumeration/output create mode 100644 xsd-tests/cxx/parser/enumeration/test.map create mode 100644 xsd-tests/cxx/parser/enumeration/test.xml create mode 100644 xsd-tests/cxx/parser/enumeration/test.xsd create mode 100644 xsd-tests/cxx/parser/generated-impl/.gitignore create mode 100644 xsd-tests/cxx/parser/generated-impl/buildfile create mode 100644 xsd-tests/cxx/parser/generated-impl/output create mode 100644 xsd-tests/cxx/parser/generated-impl/test.xml create mode 100644 xsd-tests/cxx/parser/generated-impl/test.xsd create mode 100644 xsd-tests/cxx/parser/list/buildfile create mode 100644 xsd-tests/cxx/parser/list/driver.cxx create mode 100644 xsd-tests/cxx/parser/list/output create mode 100644 xsd-tests/cxx/parser/list/test.xml create mode 100644 xsd-tests/cxx/parser/list/test.xsd create mode 100644 xsd-tests/cxx/parser/name-clash/inheritance/buildfile create mode 100644 xsd-tests/cxx/parser/name-clash/inheritance/driver.cxx create mode 100644 xsd-tests/cxx/parser/name-clash/inheritance/output create mode 100644 xsd-tests/cxx/parser/name-clash/inheritance/test.xml create mode 100644 xsd-tests/cxx/parser/name-clash/inheritance/test.xsd create mode 100644 xsd-tests/cxx/parser/polymorphism/recursive/buildfile create mode 100644 xsd-tests/cxx/parser/polymorphism/recursive/driver.cxx create mode 100644 xsd-tests/cxx/parser/polymorphism/recursive/output create mode 100644 xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.cxx create mode 100644 xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.hxx create mode 100644 xsd-tests/cxx/parser/polymorphism/recursive/test.xml create mode 100644 xsd-tests/cxx/parser/polymorphism/recursive/test.xsd create mode 100644 xsd-tests/cxx/parser/polymorphism/same-type/buildfile create mode 100644 xsd-tests/cxx/parser/polymorphism/same-type/driver.cxx create mode 100644 xsd-tests/cxx/parser/polymorphism/same-type/output create mode 100644 xsd-tests/cxx/parser/polymorphism/same-type/test.xml create mode 100644 xsd-tests/cxx/parser/polymorphism/same-type/test.xsd create mode 100644 xsd-tests/cxx/parser/recursive/buildfile create mode 100644 xsd-tests/cxx/parser/recursive/driver.cxx create mode 100644 xsd-tests/cxx/parser/recursive/output create mode 100644 xsd-tests/cxx/parser/recursive/test.xml create mode 100644 xsd-tests/cxx/parser/recursive/test.xsd create mode 100644 xsd-tests/cxx/parser/test-template/buildfile create mode 100644 xsd-tests/cxx/parser/test-template/driver.cxx create mode 100644 xsd-tests/cxx/parser/test-template/output create mode 100644 xsd-tests/cxx/parser/test-template/test.xml create mode 100644 xsd-tests/cxx/parser/test-template/test.xsd create mode 100644 xsd-tests/cxx/parser/union/buildfile create mode 100644 xsd-tests/cxx/parser/union/driver.cxx create mode 100644 xsd-tests/cxx/parser/union/output create mode 100644 xsd-tests/cxx/parser/union/test.xml create mode 100644 xsd-tests/cxx/parser/union/test.xsd create mode 100644 xsd-tests/cxx/parser/validation/all/buildfile create mode 100644 xsd-tests/cxx/parser/validation/all/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/all/test.xsd create mode 100644 xsd-tests/cxx/parser/validation/all/testscript create mode 100644 xsd-tests/cxx/parser/validation/any/buildfile create mode 100644 xsd-tests/cxx/parser/validation/any/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/any/output create mode 100644 xsd-tests/cxx/parser/validation/any/test.xml create mode 100644 xsd-tests/cxx/parser/validation/any/test.xsd create mode 100644 xsd-tests/cxx/parser/validation/attribute/buildfile create mode 100644 xsd-tests/cxx/parser/validation/attribute/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/attribute/output create mode 100644 xsd-tests/cxx/parser/validation/attribute/test.xml create mode 100644 xsd-tests/cxx/parser/validation/attribute/test.xsd create mode 100644 xsd-tests/cxx/parser/validation/built-in/any-type/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/any-type/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/any-type/output create mode 100644 xsd-tests/cxx/parser/validation/built-in/any-type/test.xml create mode 100644 xsd-tests/cxx/parser/validation/built-in/any-type/test.xsd create mode 100644 xsd-tests/cxx/parser/validation/built-in/binary/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/binary/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/boolean/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/boolean/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/byte/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/byte/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/date-time/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/date-time/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/float/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/float/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/int/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/int/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/integer/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/integer/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/long/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/long/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/qname/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/qname/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/short/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/short/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/string/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/string/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/uri/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/uri/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/choice/buildfile create mode 100644 xsd-tests/cxx/parser/validation/choice/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/choice/test.xsd create mode 100644 xsd-tests/cxx/parser/validation/choice/testscript create mode 100644 xsd-tests/cxx/parser/validation/restriction/buildfile create mode 100644 xsd-tests/cxx/parser/validation/restriction/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/restriction/test.xsd create mode 100644 xsd-tests/cxx/parser/validation/restriction/testscript create mode 100644 xsd-tests/cxx/parser/validation/sequence/buildfile create mode 100644 xsd-tests/cxx/parser/validation/sequence/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/sequence/test.xsd create mode 100644 xsd-tests/cxx/parser/validation/sequence/testscript create mode 100644 xsd-tests/cxx/tree/any-type/buildfile create mode 100644 xsd-tests/cxx/tree/any-type/driver.cxx create mode 100644 xsd-tests/cxx/tree/any-type/output create mode 100644 xsd-tests/cxx/tree/any-type/test.xml create mode 100644 xsd-tests/cxx/tree/any-type/test.xsd create mode 100644 xsd-tests/cxx/tree/binary/cdr/buildfile create mode 100644 xsd-tests/cxx/tree/binary/cdr/driver.cxx create mode 100644 xsd-tests/cxx/tree/binary/cdr/test.xml create mode 100644 xsd-tests/cxx/tree/binary/cdr/test.xsd create mode 100644 xsd-tests/cxx/tree/binary/polymorphic/buildfile create mode 100644 xsd-tests/cxx/tree/binary/polymorphic/driver.cxx create mode 100644 xsd-tests/cxx/tree/binary/polymorphic/test.xml create mode 100644 xsd-tests/cxx/tree/binary/polymorphic/test.xsd create mode 100644 xsd-tests/cxx/tree/binary/xdr-ordered/buildfile create mode 100644 xsd-tests/cxx/tree/binary/xdr-ordered/driver.cxx create mode 100644 xsd-tests/cxx/tree/binary/xdr-ordered/test.xml create mode 100644 xsd-tests/cxx/tree/binary/xdr-ordered/test.xsd create mode 100644 xsd-tests/cxx/tree/binary/xdr/buildfile create mode 100644 xsd-tests/cxx/tree/binary/xdr/driver.cxx create mode 100644 xsd-tests/cxx/tree/binary/xdr/test.xml create mode 100644 xsd-tests/cxx/tree/binary/xdr/test.xsd create mode 100644 xsd-tests/cxx/tree/buildfile create mode 100644 xsd-tests/cxx/tree/built-in/.gitignore create mode 100644 xsd-tests/cxx/tree/built-in/buildfile create mode 100644 xsd-tests/cxx/tree/built-in/driver.cxx create mode 100644 xsd-tests/cxx/tree/built-in/testscript create mode 100644 xsd-tests/cxx/tree/built-in/types.xsd create mode 100644 xsd-tests/cxx/tree/chameleon/.gitignore create mode 100644 xsd-tests/cxx/tree/chameleon/buildfile create mode 100644 xsd-tests/cxx/tree/chameleon/driver.cxx create mode 100644 xsd-tests/cxx/tree/chameleon/includee.xsd create mode 100644 xsd-tests/cxx/tree/chameleon/includer.xsd create mode 100644 xsd-tests/cxx/tree/chameleon/output create mode 100644 xsd-tests/cxx/tree/chameleon/test.xml create mode 100644 xsd-tests/cxx/tree/comparison/buildfile create mode 100644 xsd-tests/cxx/tree/comparison/driver.cxx create mode 100644 xsd-tests/cxx/tree/comparison/test.xml create mode 100644 xsd-tests/cxx/tree/comparison/test.xsd create mode 100644 xsd-tests/cxx/tree/compilation/buildfile create mode 100644 xsd-tests/cxx/tree/compilation/driver.cxx create mode 100644 xsd-tests/cxx/tree/compilation/test.xsd create mode 100644 xsd-tests/cxx/tree/complex/ctor/buildfile create mode 100644 xsd-tests/cxx/tree/complex/ctor/driver.cxx create mode 100644 xsd-tests/cxx/tree/complex/ctor/test.xsd create mode 100644 xsd-tests/cxx/tree/containment/buildfile create mode 100644 xsd-tests/cxx/tree/containment/driver.cxx create mode 100644 xsd-tests/cxx/tree/containment/test.xsd create mode 100644 xsd-tests/cxx/tree/default/general/buildfile create mode 100644 xsd-tests/cxx/tree/default/general/driver.cxx create mode 100644 xsd-tests/cxx/tree/default/general/output create mode 100644 xsd-tests/cxx/tree/default/general/test.xml create mode 100644 xsd-tests/cxx/tree/default/general/test.xsd create mode 100644 xsd-tests/cxx/tree/default/omit/buildfile create mode 100644 xsd-tests/cxx/tree/default/omit/driver.cxx create mode 100644 xsd-tests/cxx/tree/default/omit/output create mode 100644 xsd-tests/cxx/tree/default/omit/test.xml create mode 100644 xsd-tests/cxx/tree/default/omit/test.xsd create mode 100644 xsd-tests/cxx/tree/detach/buildfile create mode 100644 xsd-tests/cxx/tree/detach/driver.cxx create mode 100644 xsd-tests/cxx/tree/detach/test.xsd create mode 100644 xsd-tests/cxx/tree/dom-association/buildfile create mode 100644 xsd-tests/cxx/tree/dom-association/dom-parse.cxx create mode 100644 xsd-tests/cxx/tree/dom-association/dom-parse.hxx create mode 100644 xsd-tests/cxx/tree/dom-association/driver.cxx create mode 100644 xsd-tests/cxx/tree/dom-association/output create mode 100644 xsd-tests/cxx/tree/dom-association/test.xml create mode 100644 xsd-tests/cxx/tree/dom-association/test.xsd create mode 100644 xsd-tests/cxx/tree/encoding/char/iso-8859-1/buildfile create mode 100644 xsd-tests/cxx/tree/encoding/char/iso-8859-1/driver.cxx create mode 100644 xsd-tests/cxx/tree/encoding/char/iso-8859-1/output create mode 100644 xsd-tests/cxx/tree/encoding/char/iso-8859-1/test.xml create mode 100644 xsd-tests/cxx/tree/encoding/char/iso-8859-1/test.xsd create mode 100644 xsd-tests/cxx/tree/encoding/char/lcp/buildfile create mode 100644 xsd-tests/cxx/tree/encoding/char/lcp/driver.cxx create mode 100644 xsd-tests/cxx/tree/encoding/char/lcp/output create mode 100644 xsd-tests/cxx/tree/encoding/char/lcp/test.xml create mode 100644 xsd-tests/cxx/tree/encoding/char/lcp/test.xsd create mode 100644 xsd-tests/cxx/tree/encoding/char/utf-8/buildfile create mode 100644 xsd-tests/cxx/tree/encoding/char/utf-8/driver.cxx create mode 100644 xsd-tests/cxx/tree/encoding/char/utf-8/output create mode 100644 xsd-tests/cxx/tree/encoding/char/utf-8/test.xml create mode 100644 xsd-tests/cxx/tree/encoding/char/utf-8/test.xsd create mode 100644 xsd-tests/cxx/tree/encoding/wchar/buildfile create mode 100644 xsd-tests/cxx/tree/encoding/wchar/driver.cxx create mode 100644 xsd-tests/cxx/tree/encoding/wchar/output create mode 100644 xsd-tests/cxx/tree/encoding/wchar/test.xml create mode 100644 xsd-tests/cxx/tree/encoding/wchar/test.xsd create mode 100644 xsd-tests/cxx/tree/enumeration/ctor/buildfile create mode 100644 xsd-tests/cxx/tree/enumeration/ctor/driver.cxx create mode 100644 xsd-tests/cxx/tree/enumeration/ctor/test.xsd create mode 100644 xsd-tests/cxx/tree/enumeration/inheritance/buildfile create mode 100644 xsd-tests/cxx/tree/enumeration/inheritance/driver.cxx create mode 100644 xsd-tests/cxx/tree/enumeration/inheritance/output create mode 100644 xsd-tests/cxx/tree/enumeration/inheritance/test.xml create mode 100644 xsd-tests/cxx/tree/enumeration/inheritance/test.xsd create mode 100644 xsd-tests/cxx/tree/float/buildfile create mode 100644 xsd-tests/cxx/tree/float/driver.cxx create mode 100644 xsd-tests/cxx/tree/float/output create mode 100644 xsd-tests/cxx/tree/float/test.xml create mode 100644 xsd-tests/cxx/tree/float/test.xsd create mode 100644 xsd-tests/cxx/tree/list/ctor/buildfile create mode 100644 xsd-tests/cxx/tree/list/ctor/driver.cxx create mode 100644 xsd-tests/cxx/tree/list/ctor/test.xsd create mode 100644 xsd-tests/cxx/tree/name-clash/inheritance/buildfile create mode 100644 xsd-tests/cxx/tree/name-clash/inheritance/driver.cxx create mode 100644 xsd-tests/cxx/tree/name-clash/inheritance/output create mode 100644 xsd-tests/cxx/tree/name-clash/inheritance/test.xml create mode 100644 xsd-tests/cxx/tree/name-clash/inheritance/test.xsd create mode 100644 xsd-tests/cxx/tree/naming/camel/buildfile create mode 100644 xsd-tests/cxx/tree/naming/camel/driver.cxx create mode 100644 xsd-tests/cxx/tree/naming/camel/test.xsd create mode 100644 xsd-tests/cxx/tree/naming/java/buildfile create mode 100644 xsd-tests/cxx/tree/naming/java/driver.cxx create mode 100644 xsd-tests/cxx/tree/naming/java/test.xsd create mode 100644 xsd-tests/cxx/tree/naming/knr/buildfile create mode 100644 xsd-tests/cxx/tree/naming/knr/driver.cxx create mode 100644 xsd-tests/cxx/tree/naming/knr/test.xsd create mode 100644 xsd-tests/cxx/tree/order/buildfile create mode 100644 xsd-tests/cxx/tree/order/driver.cxx create mode 100644 xsd-tests/cxx/tree/order/output create mode 100644 xsd-tests/cxx/tree/order/test.xml create mode 100644 xsd-tests/cxx/tree/order/test.xsd create mode 100644 xsd-tests/cxx/tree/polymorphism/comparison/buildfile create mode 100644 xsd-tests/cxx/tree/polymorphism/comparison/driver.cxx create mode 100644 xsd-tests/cxx/tree/polymorphism/comparison/test.xml create mode 100644 xsd-tests/cxx/tree/polymorphism/comparison/test.xsd create mode 100644 xsd-tests/cxx/tree/polymorphism/ostream/buildfile create mode 100644 xsd-tests/cxx/tree/polymorphism/ostream/driver.cxx create mode 100644 xsd-tests/cxx/tree/polymorphism/ostream/output create mode 100644 xsd-tests/cxx/tree/polymorphism/ostream/test.xml create mode 100644 xsd-tests/cxx/tree/polymorphism/ostream/test.xsd create mode 100644 xsd-tests/cxx/tree/polymorphism/same-type/buildfile create mode 100644 xsd-tests/cxx/tree/polymorphism/same-type/driver.cxx create mode 100644 xsd-tests/cxx/tree/polymorphism/same-type/output create mode 100644 xsd-tests/cxx/tree/polymorphism/same-type/test.xml create mode 100644 xsd-tests/cxx/tree/polymorphism/same-type/test.xsd create mode 100644 xsd-tests/cxx/tree/prefix/.gitignore create mode 100644 xsd-tests/cxx/tree/prefix/bar.xsd create mode 100644 xsd-tests/cxx/tree/prefix/buildfile create mode 100644 xsd-tests/cxx/tree/prefix/driver.cxx create mode 100644 xsd-tests/cxx/tree/prefix/foo.xsd create mode 100644 xsd-tests/cxx/tree/prefix/output create mode 100644 xsd-tests/cxx/tree/prefix/test.xml create mode 100644 xsd-tests/cxx/tree/prefix/test.xsd create mode 100644 xsd-tests/cxx/tree/test-template/buildfile create mode 100644 xsd-tests/cxx/tree/test-template/driver.cxx create mode 100644 xsd-tests/cxx/tree/test-template/output create mode 100644 xsd-tests/cxx/tree/test-template/test.xml create mode 100644 xsd-tests/cxx/tree/test-template/test.xsd create mode 100644 xsd-tests/cxx/tree/types-only/buildfile create mode 100644 xsd-tests/cxx/tree/types-only/driver.cxx create mode 100644 xsd-tests/cxx/tree/types-only/test.xsd create mode 100644 xsd-tests/cxx/tree/union/ctor/buildfile create mode 100644 xsd-tests/cxx/tree/union/ctor/driver.cxx create mode 100644 xsd-tests/cxx/tree/union/ctor/test.xsd create mode 100644 xsd-tests/cxx/tree/wildcard/buildfile create mode 100644 xsd-tests/cxx/tree/wildcard/driver.cxx create mode 100644 xsd-tests/cxx/tree/wildcard/output create mode 100644 xsd-tests/cxx/tree/wildcard/test.xml create mode 100644 xsd-tests/cxx/tree/wildcard/test.xsd create mode 100644 xsd-tests/failed/.gitignore create mode 100644 xsd-tests/failed/buildfile create mode 100644 xsd-tests/failed/driver.cxx create mode 100644 xsd-tests/failed/test-00.xsd create mode 100644 xsd-tests/manifest create mode 100644 xsd-tests/morphing/anonymous/attribute-group/buildfile create mode 100644 xsd-tests/morphing/anonymous/attribute-group/driver.cxx create mode 100644 xsd-tests/morphing/anonymous/attribute-group/test.xsd create mode 100644 xsd-tests/morphing/anonymous/basic/buildfile create mode 100644 xsd-tests/morphing/anonymous/basic/driver.cxx create mode 100644 xsd-tests/morphing/anonymous/basic/test.xsd create mode 100644 xsd-tests/morphing/anonymous/cyclic-inclusion/.gitignore create mode 100644 xsd-tests/morphing/anonymous/cyclic-inclusion/buildfile create mode 100644 xsd-tests/morphing/anonymous/cyclic-inclusion/driver.cxx create mode 100644 xsd-tests/morphing/anonymous/cyclic-inclusion/includee.xsd create mode 100644 xsd-tests/morphing/anonymous/cyclic-inclusion/includer.xsd create mode 100644 xsd-tests/morphing/anonymous/group/buildfile create mode 100644 xsd-tests/morphing/anonymous/group/driver.cxx create mode 100644 xsd-tests/morphing/anonymous/group/test.xsd create mode 100644 xsd-tests/morphing/anonymous/unstable/.gitignore create mode 100644 xsd-tests/morphing/anonymous/unstable/buildfile create mode 100644 xsd-tests/morphing/anonymous/unstable/includee-1.xsd create mode 100644 xsd-tests/morphing/anonymous/unstable/includee-2.xsd create mode 100644 xsd-tests/morphing/anonymous/unstable/includer.xsd create mode 100644 xsd-tests/morphing/anonymous/unstable/testscript create mode 100644 xsd-tests/processing/inheritance/.gitignore create mode 100644 xsd-tests/processing/inheritance/buildfile create mode 100644 xsd-tests/processing/inheritance/driver.cxx.in create mode 100644 xsd-tests/processing/inheritance/test-000.xsd create mode 100644 xsd-tests/processing/inheritance/test-001.xsd create mode 100644 xsd-tests/schema/anonymous/buildfile create mode 100644 xsd-tests/schema/anonymous/driver.cxx create mode 100644 xsd-tests/schema/anonymous/test.xsd create mode 100644 xsd-tests/schema/any-attribute/buildfile create mode 100644 xsd-tests/schema/any-attribute/test.xsd create mode 100644 xsd-tests/schema/any-attribute/testscript create mode 100644 xsd-tests/schema/any-type/buildfile create mode 100644 xsd-tests/schema/any-type/driver.cxx create mode 100644 xsd-tests/schema/any-type/test.xsd create mode 100644 xsd-tests/schema/any/.gitignore create mode 100644 xsd-tests/schema/any/buildfile create mode 100644 xsd-tests/schema/any/driver.cxx.in create mode 100644 xsd-tests/schema/any/fail.xsd create mode 100644 xsd-tests/schema/any/test.xsd create mode 100644 xsd-tests/schema/attribute-group/.gitignore create mode 100644 xsd-tests/schema/attribute-group/buildfile create mode 100644 xsd-tests/schema/attribute-group/driver.cxx create mode 100644 xsd-tests/schema/attribute-group/global.xsd create mode 100644 xsd-tests/schema/attribute/.gitignore create mode 100644 xsd-tests/schema/attribute/buildfile create mode 100644 xsd-tests/schema/attribute/driver.cxx create mode 100644 xsd-tests/schema/attribute/global.xsd create mode 100644 xsd-tests/schema/attribute/local.xsd create mode 100644 xsd-tests/schema/attribute/ref.xsd create mode 100644 xsd-tests/schema/cardinality/buildfile create mode 100644 xsd-tests/schema/cardinality/driver.cxx create mode 100644 xsd-tests/schema/cardinality/test.xsd create mode 100644 xsd-tests/schema/chameleon/.gitignore create mode 100644 xsd-tests/schema/chameleon/buildfile create mode 100644 xsd-tests/schema/chameleon/driver.cxx create mode 100644 xsd-tests/schema/chameleon/includer.xsd create mode 100644 xsd-tests/schema/chameleon/schemas/.gitignore create mode 100644 xsd-tests/schema/chameleon/schemas/includee.xsd create mode 100644 xsd-tests/schema/enumeration/buildfile create mode 100644 xsd-tests/schema/enumeration/driver.cxx create mode 100644 xsd-tests/schema/enumeration/test.xsd create mode 100644 xsd-tests/schema/forward/buildfile create mode 100644 xsd-tests/schema/forward/driver.cxx create mode 100644 xsd-tests/schema/forward/test.xsd create mode 100644 xsd-tests/schema/group/.gitignore create mode 100644 xsd-tests/schema/group/buildfile create mode 100644 xsd-tests/schema/group/driver.cxx create mode 100644 xsd-tests/schema/group/global.xsd create mode 100644 xsd-tests/schema/group/test.xsd create mode 100644 xsd-tests/schema/import/.gitignore create mode 100644 xsd-tests/schema/import/buildfile create mode 100644 xsd-tests/schema/import/driver.cxx create mode 100644 xsd-tests/schema/import/importer.xsd create mode 100644 xsd-tests/schema/import/schemas/.gitignore create mode 100644 xsd-tests/schema/import/schemas/importee.xsd create mode 100644 xsd-tests/schema/include/.gitignore create mode 100644 xsd-tests/schema/include/buildfile create mode 100644 xsd-tests/schema/include/driver.cxx create mode 100644 xsd-tests/schema/include/includer.xsd create mode 100644 xsd-tests/schema/include/schemas/.gitignore create mode 100644 xsd-tests/schema/include/schemas/includee.xsd create mode 100644 xsd-tests/schema/inheritance/.gitignore create mode 100644 xsd-tests/schema/inheritance/buildfile create mode 100644 xsd-tests/schema/inheritance/cycle.xsd create mode 100644 xsd-tests/schema/inheritance/sourced-forward/.gitignore create mode 100644 xsd-tests/schema/inheritance/sourced-forward/includee.xsd create mode 100644 xsd-tests/schema/inheritance/sourced-forward/includer.xsd create mode 100644 xsd-tests/schema/inheritance/testscript create mode 100644 xsd-tests/schema/list/anonymous/test.xsd create mode 100644 xsd-tests/schema/list/any-simple-type/test.xsd create mode 100644 xsd-tests/schema/list/buildfile create mode 100644 xsd-tests/schema/list/test.xsd create mode 100644 xsd-tests/schema/list/testscript create mode 100644 xsd-tests/schema/no-namespace/buildfile create mode 100644 xsd-tests/schema/no-namespace/driver.cxx create mode 100644 xsd-tests/schema/no-namespace/test.xsd create mode 100644 xsd-tests/schema/recursive/buildfile create mode 100644 xsd-tests/schema/recursive/driver.cxx create mode 100644 xsd-tests/schema/recursive/test.xsd create mode 100644 xsd-tests/schema/ref-type/invalid/buildfile create mode 100644 xsd-tests/schema/ref-type/invalid/invalid-0.xsd create mode 100644 xsd-tests/schema/ref-type/invalid/invalid-1.xsd create mode 100644 xsd-tests/schema/ref-type/invalid/testscript create mode 100644 xsd-tests/schema/ref-type/valid/.gitignore create mode 100644 xsd-tests/schema/ref-type/valid/buildfile create mode 100644 xsd-tests/schema/ref-type/valid/driver.cxx.in create mode 100644 xsd-tests/schema/ref-type/valid/idref.xsd create mode 100644 xsd-tests/schema/ref-type/valid/idrefs.xsd create mode 100644 xsd-tests/schema/restriction/buildfile create mode 100644 xsd-tests/schema/restriction/driver.cxx create mode 100644 xsd-tests/schema/restriction/test.xsd create mode 100644 xsd-tests/schema/union/buildfile create mode 100644 xsd-tests/schema/union/driver.cxx create mode 100644 xsd-tests/schema/union/test.xsd create mode 100644 xsd/.gitignore create mode 120000 xsd/FLOSSE create mode 120000 xsd/GPLv2 create mode 100644 xsd/INSTALL create mode 120000 xsd/LICENSE create mode 100644 xsd/NEWS create mode 100644 xsd/README create mode 100644 xsd/build/.gitignore create mode 100644 xsd/build/bootstrap.build create mode 100644 xsd/build/export.build create mode 100644 xsd/build/root.build create mode 100644 xsd/buildfile delete mode 100644 xsd/cxx/elements.cxx delete mode 100644 xsd/cxx/elements.hxx delete mode 100644 xsd/cxx/literal-map.cxx delete mode 100644 xsd/cxx/literal-map.hxx delete mode 100644 xsd/cxx/option-types.cxx delete mode 100644 xsd/cxx/option-types.hxx delete mode 100644 xsd/cxx/options.cli delete mode 100644 xsd/cxx/parser/attribute-validation-source.cxx delete mode 100644 xsd/cxx/parser/attribute-validation-source.hxx delete mode 100644 xsd/cxx/parser/characters-validation-source.cxx delete mode 100644 xsd/cxx/parser/characters-validation-source.hxx delete mode 100644 xsd/cxx/parser/driver-source.cxx delete mode 100644 xsd/cxx/parser/driver-source.hxx delete mode 100644 xsd/cxx/parser/element-validation-source.cxx delete mode 100644 xsd/cxx/parser/element-validation-source.hxx delete mode 100644 xsd/cxx/parser/elements.cxx delete mode 100644 xsd/cxx/parser/elements.hxx delete mode 100644 xsd/cxx/parser/generator.cxx delete mode 100644 xsd/cxx/parser/generator.hxx delete mode 100644 xsd/cxx/parser/impl-header.cxx delete mode 100644 xsd/cxx/parser/impl-header.hxx delete mode 100644 xsd/cxx/parser/impl-source.cxx delete mode 100644 xsd/cxx/parser/impl-source.hxx delete mode 100644 xsd/cxx/parser/name-processor.cxx delete mode 100644 xsd/cxx/parser/name-processor.hxx delete mode 100644 xsd/cxx/parser/options.cli delete mode 100644 xsd/cxx/parser/parser-forward.cxx delete mode 100644 xsd/cxx/parser/parser-forward.hxx delete mode 100644 xsd/cxx/parser/parser-header.cxx delete mode 100644 xsd/cxx/parser/parser-header.hxx delete mode 100644 xsd/cxx/parser/parser-inline.cxx delete mode 100644 xsd/cxx/parser/parser-inline.hxx delete mode 100644 xsd/cxx/parser/parser-source.cxx delete mode 100644 xsd/cxx/parser/parser-source.hxx delete mode 100644 xsd/cxx/parser/print-impl-common.hxx delete mode 100644 xsd/cxx/parser/state-processor.cxx delete mode 100644 xsd/cxx/parser/state-processor.hxx delete mode 100644 xsd/cxx/parser/type-processor.cxx delete mode 100644 xsd/cxx/parser/type-processor.hxx delete mode 100644 xsd/cxx/parser/validator.cxx delete mode 100644 xsd/cxx/parser/validator.hxx delete mode 100644 xsd/cxx/tree/counter.cxx delete mode 100644 xsd/cxx/tree/counter.hxx delete mode 100644 xsd/cxx/tree/default-value.cxx delete mode 100644 xsd/cxx/tree/default-value.hxx delete mode 100644 xsd/cxx/tree/elements.cxx delete mode 100644 xsd/cxx/tree/elements.hxx delete mode 100644 xsd/cxx/tree/fundamental-header.hxx delete mode 100644 xsd/cxx/tree/generator.cxx delete mode 100644 xsd/cxx/tree/generator.hxx delete mode 100644 xsd/cxx/tree/name-processor.cxx delete mode 100644 xsd/cxx/tree/name-processor.hxx delete mode 100644 xsd/cxx/tree/options.cli delete mode 100644 xsd/cxx/tree/order-processor.cxx delete mode 100644 xsd/cxx/tree/order-processor.hxx delete mode 100644 xsd/cxx/tree/parser-header.cxx delete mode 100644 xsd/cxx/tree/parser-header.hxx delete mode 100644 xsd/cxx/tree/parser-source.cxx delete mode 100644 xsd/cxx/tree/parser-source.hxx delete mode 100644 xsd/cxx/tree/polymorphism-processor.cxx delete mode 100644 xsd/cxx/tree/polymorphism-processor.hxx delete mode 100644 xsd/cxx/tree/serialization-header.cxx delete mode 100644 xsd/cxx/tree/serialization-header.hxx delete mode 100644 xsd/cxx/tree/serialization-source.cxx delete mode 100644 xsd/cxx/tree/serialization-source.hxx delete mode 100644 xsd/cxx/tree/stream-extraction-source.cxx delete mode 100644 xsd/cxx/tree/stream-extraction-source.hxx delete mode 100644 xsd/cxx/tree/stream-header.cxx delete mode 100644 xsd/cxx/tree/stream-header.hxx delete mode 100644 xsd/cxx/tree/stream-insertion-header.cxx delete mode 100644 xsd/cxx/tree/stream-insertion-header.hxx delete mode 100644 xsd/cxx/tree/stream-insertion-source.cxx delete mode 100644 xsd/cxx/tree/stream-insertion-source.hxx delete mode 100644 xsd/cxx/tree/stream-source.cxx delete mode 100644 xsd/cxx/tree/stream-source.hxx delete mode 100644 xsd/cxx/tree/tree-forward.cxx delete mode 100644 xsd/cxx/tree/tree-forward.hxx delete mode 100644 xsd/cxx/tree/tree-header.cxx delete mode 100644 xsd/cxx/tree/tree-header.hxx delete mode 100644 xsd/cxx/tree/tree-inline.cxx delete mode 100644 xsd/cxx/tree/tree-inline.hxx delete mode 100644 xsd/cxx/tree/tree-source.cxx delete mode 100644 xsd/cxx/tree/tree-source.hxx delete mode 100644 xsd/cxx/tree/validator.cxx delete mode 100644 xsd/cxx/tree/validator.hxx create mode 100644 xsd/doc/.gitignore create mode 100644 xsd/doc/buildfile create mode 100644 xsd/doc/custom-literals.xsd create mode 100644 xsd/doc/cxx/.gitignore create mode 100644 xsd/doc/cxx/parser/guide/.gitignore create mode 100644 xsd/doc/cxx/parser/guide/figure-1.png create mode 100644 xsd/doc/cxx/parser/guide/figure-1.svg create mode 100644 xsd/doc/cxx/parser/guide/guide.html2ps.in create mode 100644 xsd/doc/cxx/parser/guide/index.xhtml.in create mode 100644 xsd/doc/cxx/tree/guide/.gitignore create mode 100644 xsd/doc/cxx/tree/guide/guide.html2ps.in create mode 100644 xsd/doc/cxx/tree/guide/index.xhtml.in create mode 100644 xsd/doc/cxx/tree/manual/.gitignore create mode 100644 xsd/doc/cxx/tree/manual/index.xhtml.in create mode 100644 xsd/doc/cxx/tree/manual/manual.html2ps.in create mode 100644 xsd/doc/default.css create mode 100644 xsd/doc/xsd-epilogue.1 create mode 100644 xsd/doc/xsd-epilogue.xhtml create mode 100644 xsd/doc/xsd-parser-header.1 create mode 100644 xsd/doc/xsd-parser-header.xhtml create mode 100644 xsd/doc/xsd-prologue.1 create mode 100644 xsd/doc/xsd-prologue.xhtml create mode 100644 xsd/doc/xsd-tree-header.1 create mode 100644 xsd/doc/xsd-tree-header.xhtml delete mode 100644 xsd/elements.hxx delete mode 100644 xsd/makefile create mode 100644 xsd/manifest delete mode 100644 xsd/options-parser.hxx delete mode 100644 xsd/options.cli delete mode 100644 xsd/processing/cardinality/processor.cxx delete mode 100644 xsd/processing/cardinality/processor.hxx delete mode 100644 xsd/processing/inheritance/processor.cxx delete mode 100644 xsd/processing/inheritance/processor.hxx delete mode 100644 xsd/type-map/lexer.cxx delete mode 100644 xsd/type-map/lexer.hxx delete mode 100644 xsd/type-map/parser.cxx delete mode 100644 xsd/type-map/parser.hxx delete mode 100644 xsd/type-map/type-map.hxx delete mode 100644 xsd/types.hxx delete mode 100644 xsd/xsd.cxx delete mode 100644 xsd/xsd.hxx create mode 100644 xsd/xsd/.gitignore create mode 100644 xsd/xsd/buildfile create mode 100644 xsd/xsd/cxx/elements.cxx create mode 100644 xsd/xsd/cxx/elements.hxx create mode 100644 xsd/xsd/cxx/literal-map.cxx create mode 100644 xsd/xsd/cxx/literal-map.hxx create mode 100644 xsd/xsd/cxx/option-types.cxx create mode 100644 xsd/xsd/cxx/option-types.hxx create mode 100644 xsd/xsd/cxx/options.cli create mode 100644 xsd/xsd/cxx/parser/attribute-validation-source.cxx create mode 100644 xsd/xsd/cxx/parser/attribute-validation-source.hxx create mode 100644 xsd/xsd/cxx/parser/characters-validation-source.cxx create mode 100644 xsd/xsd/cxx/parser/characters-validation-source.hxx create mode 100644 xsd/xsd/cxx/parser/driver-source.cxx create mode 100644 xsd/xsd/cxx/parser/driver-source.hxx create mode 100644 xsd/xsd/cxx/parser/element-validation-source.cxx create mode 100644 xsd/xsd/cxx/parser/element-validation-source.hxx create mode 100644 xsd/xsd/cxx/parser/elements.cxx create mode 100644 xsd/xsd/cxx/parser/elements.hxx create mode 100644 xsd/xsd/cxx/parser/generator.cxx create mode 100644 xsd/xsd/cxx/parser/generator.hxx create mode 100644 xsd/xsd/cxx/parser/impl-header.cxx create mode 100644 xsd/xsd/cxx/parser/impl-header.hxx create mode 100644 xsd/xsd/cxx/parser/impl-source.cxx create mode 100644 xsd/xsd/cxx/parser/impl-source.hxx create mode 100644 xsd/xsd/cxx/parser/name-processor.cxx create mode 100644 xsd/xsd/cxx/parser/name-processor.hxx create mode 100644 xsd/xsd/cxx/parser/options.cli create mode 100644 xsd/xsd/cxx/parser/parser-forward.cxx create mode 100644 xsd/xsd/cxx/parser/parser-forward.hxx create mode 100644 xsd/xsd/cxx/parser/parser-header.cxx create mode 100644 xsd/xsd/cxx/parser/parser-header.hxx create mode 100644 xsd/xsd/cxx/parser/parser-inline.cxx create mode 100644 xsd/xsd/cxx/parser/parser-inline.hxx create mode 100644 xsd/xsd/cxx/parser/parser-source.cxx create mode 100644 xsd/xsd/cxx/parser/parser-source.hxx create mode 100644 xsd/xsd/cxx/parser/print-impl-common.hxx create mode 100644 xsd/xsd/cxx/parser/state-processor.cxx create mode 100644 xsd/xsd/cxx/parser/state-processor.hxx create mode 100644 xsd/xsd/cxx/parser/type-processor.cxx create mode 100644 xsd/xsd/cxx/parser/type-processor.hxx create mode 100644 xsd/xsd/cxx/parser/validator.cxx create mode 100644 xsd/xsd/cxx/parser/validator.hxx create mode 100644 xsd/xsd/cxx/tree/counter.cxx create mode 100644 xsd/xsd/cxx/tree/counter.hxx create mode 100644 xsd/xsd/cxx/tree/default-value.cxx create mode 100644 xsd/xsd/cxx/tree/default-value.hxx create mode 100644 xsd/xsd/cxx/tree/elements.cxx create mode 100644 xsd/xsd/cxx/tree/elements.hxx create mode 100644 xsd/xsd/cxx/tree/fundamental-header.hxx create mode 100644 xsd/xsd/cxx/tree/generator.cxx create mode 100644 xsd/xsd/cxx/tree/generator.hxx create mode 100644 xsd/xsd/cxx/tree/name-processor.cxx create mode 100644 xsd/xsd/cxx/tree/name-processor.hxx create mode 100644 xsd/xsd/cxx/tree/options.cli create mode 100644 xsd/xsd/cxx/tree/order-processor.cxx create mode 100644 xsd/xsd/cxx/tree/order-processor.hxx create mode 100644 xsd/xsd/cxx/tree/parser-header.cxx create mode 100644 xsd/xsd/cxx/tree/parser-header.hxx create mode 100644 xsd/xsd/cxx/tree/parser-source.cxx create mode 100644 xsd/xsd/cxx/tree/parser-source.hxx create mode 100644 xsd/xsd/cxx/tree/polymorphism-processor.cxx create mode 100644 xsd/xsd/cxx/tree/polymorphism-processor.hxx create mode 100644 xsd/xsd/cxx/tree/serialization-header.cxx create mode 100644 xsd/xsd/cxx/tree/serialization-header.hxx create mode 100644 xsd/xsd/cxx/tree/serialization-source.cxx create mode 100644 xsd/xsd/cxx/tree/serialization-source.hxx create mode 100644 xsd/xsd/cxx/tree/stream-extraction-source.cxx create mode 100644 xsd/xsd/cxx/tree/stream-extraction-source.hxx create mode 100644 xsd/xsd/cxx/tree/stream-header.cxx create mode 100644 xsd/xsd/cxx/tree/stream-header.hxx create mode 100644 xsd/xsd/cxx/tree/stream-insertion-header.cxx create mode 100644 xsd/xsd/cxx/tree/stream-insertion-header.hxx create mode 100644 xsd/xsd/cxx/tree/stream-insertion-source.cxx create mode 100644 xsd/xsd/cxx/tree/stream-insertion-source.hxx create mode 100644 xsd/xsd/cxx/tree/stream-source.cxx create mode 100644 xsd/xsd/cxx/tree/stream-source.hxx create mode 100644 xsd/xsd/cxx/tree/tree-forward.cxx create mode 100644 xsd/xsd/cxx/tree/tree-forward.hxx create mode 100644 xsd/xsd/cxx/tree/tree-header.cxx create mode 100644 xsd/xsd/cxx/tree/tree-header.hxx create mode 100644 xsd/xsd/cxx/tree/tree-inline.cxx create mode 100644 xsd/xsd/cxx/tree/tree-inline.hxx create mode 100644 xsd/xsd/cxx/tree/tree-source.cxx create mode 100644 xsd/xsd/cxx/tree/tree-source.hxx create mode 100644 xsd/xsd/cxx/tree/validator.cxx create mode 100644 xsd/xsd/cxx/tree/validator.hxx create mode 100644 xsd/xsd/elements.hxx create mode 100644 xsd/xsd/options-parser.hxx create mode 100644 xsd/xsd/options.cli create mode 100644 xsd/xsd/processing/cardinality/processor.cxx create mode 100644 xsd/xsd/processing/cardinality/processor.hxx create mode 100644 xsd/xsd/processing/inheritance/processor.cxx create mode 100644 xsd/xsd/processing/inheritance/processor.hxx create mode 100644 xsd/xsd/type-map/lexer.cxx create mode 100644 xsd/xsd/type-map/lexer.hxx create mode 100644 xsd/xsd/type-map/parser.cxx create mode 100644 xsd/xsd/type-map/parser.hxx create mode 100644 xsd/xsd/type-map/type-map.hxx create mode 100644 xsd/xsd/types.hxx create mode 100644 xsd/xsd/version.hxx.in create mode 100644 xsd/xsd/xsd.cxx create mode 100644 xsd/xsd/xsd.hxx diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1631641 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,19 @@ +# This is a good default: files that are auto-detected by git to be text are +# converted to the platform-native line ending (LF on Unix, CRLF on Windows) +# in the working tree and to LF in the repository. +# +* text=auto + +# Use `eol=crlf` for files that should have the CRLF line ending both in the +# working tree (even on Unix) and in the repository. +# +#*.bat text eol=crlf + +# Use `eol=lf` for files that should have the LF line ending both in the +# working tree (even on Windows) and in the repository. +# +#*.sh text eol=lf + +# Use `binary` to make sure certain files are never auto-detected as text. +# +#*.png binary diff --git a/.gitignore b/.gitignore index 0ac4cf2..13d880b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,25 +1 @@ -# Compiler/linker output. -# -*.o -*.o.d -*.so -*.a -*.l -*.l.cpp-options - -# Generated documentation. -# -*.pdf -*.ps - -# Generated build system files. -# -*-dynamic.make - -# Generated .gitignore files. -# -.gitignore - -# Convenience symlink to the XSD binary built in a separate directory. -# -xsd/xsd +.bdep/ diff --git a/INSTALL b/INSTALL deleted file mode 100644 index 5926538..0000000 --- a/INSTALL +++ /dev/null @@ -1,71 +0,0 @@ -Compiler Prerequisites - - build-time: - - - g++ >= 3.4.3 http://gcc.gnu.org - - build >= 0.3.10 https://www.codesynthesis.com/projects/build/ - - cli >= 1.2.0 https://www.codesynthesis.com/projects/cli/ - - run-time: - - - libxerces-c >= 3.0.0 http://xerces.apache.org/xerces-c/ - - libcutl >= 1.8.0 https://www.codesynthesis.com/projects/libcutl/ - - libxsd-frontend >= 2.0.0 https://www.codesynthesis.com/projects/libxsd-frontend/ - - -Generated Code Prerequisites - - build-time: - - - libxsd (header-only XSD runtime library, part of the XSD distribution) - - run-time: - - - libxerces-c >= 3.0.0 (C++/Tree and C++/Parser mappings) - http://xerces.apache.org/xerces-c/ - - - libexpat >= 1.95.8 (C++/Parser mapping, alternative to libxerces-c) - http://www.libexpat.org - - -Building XSD - - First build (and optionally install) all the prerequisites listed above. - Alternatively, you can use the xsd+dep package that includes all the - prerequisites (except g++ and libxerces-c) and can be built with a - single 'make' invocation. - - Once the prerequisites are ready, to build the XSD compiler in source - directory simply run 'make'. You can also build in a separate directory, - for example: - - $ mkdir xsd-i686-pc-linux-gnu - $ cd xsd-i686-pc-linux-gnu - $ make -f ../xsd-x.y.z/makefile - - -Installing XSD - - To install XSD, run 'make install'. Use the install_prefix command - line variable to specify installation location (default is /usr/local), - for example: - - $ make install_prefix=/usr install - - You can fine-tune the installation locations with the following make - variables: - - install_prefix default is /usr/local - install_data_prefix default is install_prefix - install_exec_prefix default is install_prefix - - install_bin_dir default is install_exec_prefix/bin - install_sbin_dir default is install_exec_prefix/sbin - install_lib_dir default is install_exec_prefix/lib - - install_data_dir default is install_data_prefix/share - install_inc_dir default is install_data_prefix/include - - install_doc_dir default is install_data_dir/doc - install_man_dir default is install_data_dir/man - install_info_dir default is install_data_dir/info diff --git a/LICENSE b/LICENSE index 7bd52e7..1a691ad 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009-2020 Code Synthesis Tools CC. +Copyright (c) 2005-2021 Code Synthesis Tools CC. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as diff --git a/NEWS b/NEWS deleted file mode 100644 index 03f5942..0000000 --- a/NEWS +++ /dev/null @@ -1,1220 +0,0 @@ -Version 4.1.0 - -C++/Tree - - * Support for abstract XML Schema types. The corresponding C++ classes - now have _clone() declared pure virtual which prevents construction - of their instances. - -Version 4.0.0 - - * Xerces-C++ 2-series (2.8.0 and earlier) is no longer supported. - - * Visual Studio 2003 (7.1) is no longer supported. - - * HP aCC3 (HP-UX/PA-RISC) is no longer supported. - - * Oracle/Berkeley DB XML support has been removed since it no longer - supports the Xerces-C++-based document access. - - * New option, --std, specifies the C++ standard that the generated code - should conform to. Valid values are c++98 (default) and c++11. - - The C++ standard affects various aspects of the generated code that are - discussed in more detail in mapping-specific documentation (guides and - manuals). Overall, when C++11 is selected, the generated code relies on - the move semantics and uses std::unique_ptr instead of deprecated - std::auto_ptr. See also the documentation for the --std option in the - XSD compiler command line manual (man pages). - - * New option, --fat-type-file, triggers the placement of code corresponding - to global elements into type files instead of schema files in the file- - per-type mode. This option is primarily useful when trying to minimize - the amount of object code that is linked to an executable by packaging - compiled generated code into a static (archive) library. - -C++/Tree - - * Support for ordered types. C++/Tree flattens nested compositors which - sometimes can result in the loss of element ordering information that - could be significant to the application. Ordered types address this - problem. For more information, refer to Section 2.8.4, "Element Order" - in the C++/Tree Mapping User Manual. - - * Support for mixed content in ordered types. For more information, refer - to Section 2.13, "Mapping for Mixed Content Models" in the C++/Tree - Mapping User Manual. - - * xml_schema::type represents anyType content as a DOM fragment, similar - to wildcards. For more information, refer to Section 2.5.2, "Mapping - for anyType" in the C++/Tree Mapping User Manual. - - * xml_schema::simple_type represents anySimpleType content as a text - string. For more information, refer to Section 2.5.3, "Mapping for - anySimpleType" in the C++/Tree Mapping User Manual. - - * Improved streaming example that now provides better XML namespace - handling and supports streaming parsing and serialization at multiple - document levels. - - * New option, --generate-dep, triggers the generation of the make - dependency files (.d) for the generated C++ files. Other options - controlling dependency generation are: --generate-dep-only, - --dep-phony, --dep-target, --dep-suffix, and --dep-regex. For - details on this functionality, refer to the XSD compiler command - line manual (man pages). - - * New option, --suppress-assignment, suppresses the generation of copy - assignment operators for complex types. If this option is specified, - the copy assignment operators for such types are declared private and - left unimplemented. - - * Binary representation now stores string-based enumerations as integer - values corresponding to C++ enumerators instead of string literals. - - * Binary representation now pools polymorphic type-id strings in an - implicit string pool. The string pool support can also be used to - pool strings in other situations. For example, you can implement - string insertion/extraction operators for your stream to pool all - strings. This can be useful if your documents contain a large number - of repetitive strings. - - * New option, --polymorphic-plate, allows the creation of multiple - polymorphic map plates in the same application. For details, refer - to the XSD compiler command line manual (man pages). - - * To get the DOM association in the copy of an object model tree one - now needs to explicitly pass the xml_schema::flags::keep_dom flag as - the second argument to the copy constructor or clone() function. - -Version 3.3.0 - - * New option, --char-encoding, allows you to specify the character encoding - that should be used in the generated code. Valid values for the 'char' - character type are 'utf8' (default), 'iso8859-1' (new), 'lcp' (Xerces-C++ - local code page), and 'custom' (provides support for custom encodings). - Note that if you use a non-default character encoding and include some - libxsd headers (e.g., xsd/cxx/xml/string.hxx) directly, then you will - need to first include the correct xsd/cxx/xml/char-.hxx header, - where is iso8859-1, lcp, etc. This mechanism replaces the - XSD_USE_LCP macro. - - For the wchar_t character type the only valid value for this option is - 'auto' and the encoding is automatically selected between UTF-16 and - UTF-32, depending on the wchar_t type size. - - * When the XSD compiler is built with Xerces-C++ 3.1.0 or later, the - handling of multiple imports for the same namespace is enabled. Before, - all subsequent imports for a namespace were ignored which caused errors - in some schemas. Note that if your application has XML Schema validation - enabled, then you will also need to build it with Xerces-C++ 3.1.0 or - later to take advantage of this feature. - - * Automatic mapping for the urn-style XML namespaces. The last component - in the urn name is used to derive the C++ namespace name. - - * New option, --schema-file-regex, in combination with the existing - --type-file-regex, can be used to place the generated files into - subdirectories or to resolve file name conflicts in the file-per- - type mode (--file-per-type). - - * Warning id's have changed to start with a letter identifying the - component issuing the warning. F - compiler frontend, D - compiler - driver, P - C++/Parser mapping, T - C++/Tree mapping. - - * Strings used to match regular expressions supplied with the - --namespace-regex and --anonymous-regex options now include the file - component for the schema being compiled. - - * The XSD_NO_EXPORT macro can be used to omit code generated with the - --export/import-maps and, for C++/Tree, --generate-xml-schema options - during C++ compilation. This may be useful if you would like to use - the same generated code across multiple platforms. - - C++/Tree - - * New option, --generate-element-type, triggers the generation of types - instead of parsing/serialization functions for root elements. This - is primarily useful to distinguish object models with the same root - type but with different root elements. For more information, refer - to the messaging example and Section 2.9.1, "Element Types" in the - C++/Tree Mapping User Manual. To support the customization of the - element type naming the --element-type-regex option has been added. - See the NAMING CONVENTION section in the compiler command line manual - (man pages) for details. - - * New option, --generate-element-map, triggers the generation of a root - element map. The element map allows uniform parsing and serialization - of multiple root elements. This option can only be used together with - --generate-element-type. For more information, refer to the messaging - example and Section 2.9.2, "Element Map" in the C++/Tree Mapping - User Manual. - - * Prior to this version, if the --generate-polymorphic option is - specified, the compiler treats all types as potentially polymorphic. - Now by default only type hierarchies used in substitution groups and - those explicitly declared polymorphic with the new --polymorphic-type - option are treated as polymorphic. This results in smaller and faster - generated code. If you would like to continue using the old behavior, - you will need to specify --polymorphic-type-all. For more information, - on this change see Section 2.11, "Mapping for xsi:type and Substitution - Groups" in the C++/Tree Mapping User Manual. - - * New option, --generate-detach, triggers the generation of detach - functions for required elements and attributes. For optional and - sequence cardinalities the detach functions are now provided by the - respective containers even without this option. These functions, for - example, allow one to move sub-trees in the object model either within - the same tree or between different trees without copying. For more - information, refer to Section 2.8 "Mapping for Local Elements and - Attributes" in the C++/Tree Mapping User Manual. - - * New option, --export-xml-schema, causes the compiler to export/import - types in the XML Schema namespace using the export symbol provided - with the --export-symbol option. - - * New example, embedded, shows how to embed the binary representation of - the schema grammar into an application and then use it to parse and - validate XML documents. - - * New example, compression, shows how to compress an XML document during - serialization and decompress it during parsing using the zlib library. - - * New example, custom/mixed, shows how to use type customization to parse - and serialize mixed content. - - * The streaming example has been extended to show how to perform stream- - oriented, partially in-memory XML processing using the C++/Tree mapping. - With the partially in-memory parsing and serialization only a part of - the object model is in memory at any given time. With this approach one - can process parts of the document as they become available as well as - handle documents that are too large to fit into memory. - - * New default/fixed value initialization code. Now the default/fixed values - are parsed by the XSD compiler at compile time instead of the standard - parsing code at runtime. This will allow the compilation of schemas that - use the default/fixed values without support for XML parsing - (--suppress-parsing option). - - * Empty XML Schema enumeration values are now mapped to the 'empty' C++ - enumerator name instead of 'cxx'. - - * XML Schema union types with members that are enumeration types are - automatically converted to equivalent enumeration types with a union - of all the members' enumerators. - -Version 3.2.0 - - * New option, --disable-warning, disables printing of a warning with - the specified id. Specifying 'all' for the warning id disables all - warnings. - - * New options, --export-maps and --import-maps, provide support for - splitting a polymorphic type hierarchy across several Win32 DLLs. - See the compiler command line manual (man pages) for details. - - C++/Tree - - * During serialization the generated code automatically assigns - generic prefixes (p1, p2, etc) to XML namespaces used in the - vocabulary and for which no custom prefix-namespace mapping - was provided via the xml_schema::namespace_infomap argument. - The xml_schema::namespace_infomap argument in the serialization - functions is now default-initialized to an empty map. The - xml_schema::no_namespace_mapping and xml_schema::xsi_already_in_use - exceptions have been removed. - - * New example, performance, measures the performance of parsing and - serialization. This example also shows how to structure your code - to achieve the maximum performance for these two operations. - - * New example, xpath, shows how to use the C++/Tree mapping together - with XPath. - - * New options, --one-accessor-regex, --opt-accessor-regex, - --seq-accessor-regex, --one-modifier-regex, --opt-modifier-regex, - and --seq-modifier-regex, allow specification of transformations - for accessor and modifier function names for elements and attributes - with specific cardinalities. For more information see the NAMING - CONVENTION section in the compiler command line manual (man pages). - - * Support for comparison (--generate-comparison) and printing - (--generate-ostream) of polymorphic object models. - - * New serialization flag, xml_schema::flags::dont_pretty_print, - disables extra spaces and new lines that make the resulting XML - slightly bigger but easier to read. - - * New example, custom/double, shows how to customize parsing and - serialization code for the xsd:double XML Schema built-in type. - It can be used as a guide on how to customize built-in XML Schema - types that are mapped to fundamental C++ types. - - * Support for fractionDigits and totalDigits facets in serialization - of types derived from xsd:decimal. - - * New set of compile-time macros that control how the xsd:float, - xsd:double, and xsd:decimal types are serialized. The following - macros control the format: - - XSD_CXX_TREE_FLOAT_FIXED - XSD_CXX_TREE_FLOAT_SCIENTIFIC - XSD_CXX_TREE_DOUBLE_FIXED - XSD_CXX_TREE_DOUBLE_SCIENTIFIC - - The following macros control the precision: - - XSD_CXX_TREE_FLOAT_PRECISION_MAX - XSD_CXX_TREE_FLOAT_PRECISION - XSD_CXX_TREE_DOUBLE_PRECISION_MAX - XSD_CXX_TREE_DOUBLE_PRECISION - XSD_CXX_TREE_DECIMAL_PRECISION_MAX - XSD_CXX_TREE_DECIMAL_PRECISION - - If the *_PRECISION_MAX macro is defined then the maximum number of - potentially significant decimal digits that the type can represent - is used. Otherwise, if the *_PRECISION macro is defined then its - value is used. By default the precision is set to the number of - decimal digits that the type can represent without change. For - more information on these options, refer to the following paper: - - http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1822.pdf - - The old macro, XSD_FP_ALL_DIGITS, that was equivalent to defining - all three *_PRECISION_MAX macros has been removed. - - An alternative to using these macros is to customize the floating - point type as shown in the custom/double example. - - * An additional constructor is generated in situations where a type - contains one or more required element of complex type (that is, - it itself contains elements or attributes). In this constructor, - initializers for such elements are passed as std::auto_ptr and the - newly created instance is directly initialized with and assumes - ownership of the pointed to objects. This constructor is a logical - addition to the non-copying modifiers that were introduced in the - previous version. - - * Extra conversion operators in the fundamental_base class template - which is used to emulate inheritance from fundamental types are now - disabled by default since they cause problems on several compilers. - To enable them compile your code with the XSD_TREE_EXTRA_FUND_CONV - macro defined. - - C++/Parser - - * New options, --generate-xml-schema and --extern-xml-schema, trigger - generation of the mapping for the XML Schema namespace to a separate - header file and inclusion of that header into other generated header - files instead of generating the necessary declarations inline, - respectively. See the compiler command line manual (man pages) for - details. - - * New example, performance, measures the performance of XML parsing. - This example also shows how to structure your code to achieve the - maximum performance for this operation. - - * Type map files can now include comments. A comment starts with # - and ends with a new line or end of file. To specify a name that - contains # enclose it in "". - - * In type map files the optional argument type now defaults to the - return type if the return type ends with * or & (that is, it is - a pointer or a reference) and 'const return type&' otherwise. - - * The interface for polymorphic parsing has been simplified. Calling the - *_parser() functions multiple times to specify several parsers is no - longer supported. Instead you need to pass the xml_schema::parser_map - object which contains the parsers. For more information refer to - Section 5.4, "Support for Polymorphism" in the C++/Parser Mapping - Getting Started Guide. - - * The use of virtual inheritance has been reduced which results in a - much smaller object code size (more than factor of 2 on some tests) - and faster C++ compilation with less RAM used. - - * The low-level Expat-specific parsing API (parse_begin() and parse_end()) - has been extended to provide XML and XML Schema error translation to - exceptions or error handler calls. See Section 7.2, "Expat Document - Parser" in the C++/Parser Mapping Getting Started Guide for more - information. - -Version 3.1.0 - - * New option, --file-per-type, triggers generation of a separate set - of C++ files for each type defined in XML Schema. This compilation - mode is primarily useful when some of your schemas cannot be compiled - separately or have cyclic dependencies which involve inheritance. - Other new options that are useful in this compilation mode are - --type-file-regex, --type-file-regex-trace, and --file-list. See the - compiler command line manual (man pages) for more information. - - * New option, --options-file, allows additional command line options - to be provided in files, with one option per line. - - * New option, --reserved-name, allows insertion of additional names - with optional replacements to the list of names that should not be - used as identifiers. See the compiler command line manual (man pages) - for details. - - * New options, --location-map, --location-regex, and - --location-regex-trace, allow re-mapping of schema locations - specified in the include and import elements without modifying the - schema files. See the compiler command line manual (man pages) for - more information. - - * New option, --guard-prefix, allows specification of a prefix that - should be added to generated header inclusion guards. - - * New option, --file-list, triggers creation of a file with a list of - generated C++ files. This option is primarily useful in the file-per- - type compilation mode (--file-per-type) to create a list of generated - C++ files, for example, as a makefile fragment. Other new options - that are useful with --file-list are --file-list-prologue, - --file-list-epilogue, and --file-list-delim. See the compiler command - line manual (man pages) for more information. - - * Support for the upcoming Xerces-C++ 3.0.0 release. - - C++/Tree - - * New option, --generate-intellisense, triggers generation of workarounds - for IntelliSense bugs in Visual Studio 2005 (8.0). When this option is - used, the resulting code is slightly more verbose. IntelliSense in - Visual Studio 2008 (9.0) does not require these workarounds. Support - for IntelliSense in Visual Studio 2003 (7.1) is improved with this - option but is still incomplete. - - * New options, --type-naming and --function-naming, allow specification - of the type and function naming conventions that should be used in the - generated code. Supported values for --type-naming are: knr (K&R), ucc - (upper-camel-case), and java. Supported values for --function-naming - are: knr (K&R), lcc (lower-camel-case), and java. For more information - see the NAMING CONVENTION section in the compiler command line manual - (man pages). - - * New options, --type-regex, --accessor-regex, --modifier-regex, - --parser-regex, --serializer-regex, and --enumerator-regex, allow - specification of transformations for type, accessor function, - modifier function, parsing function, serialization function, and - enumerator names in order to produce the generated code using a - custom naming convention. For more information see the NAMING - CONVENTION section in the compiler command line manual (man pages). - - * Generated list classes now provide a complete set of constructors and - conform to the standard C++ sequence interface. - - * String-based types now provide two extra constructors that expect a - C string and std::string as their arguments. This allows direct - initialization of string-based types from string literals. - - * New implementations of the XML Schema date/time types (date, dateTime, - duration, gDay, gMonth, gMonthDay, gYear, gYearMonth, and time) that - represent the information in the numerical form. - - * New binary serialization examples: binary/boost, which shows how to - save/load the object model to/from a custom format using the Boost - serialization library as an example, and binary/xdr, which shows how to - save/load the object model to/from XDR (eXternal Data Representation) - binary format using the XDR API provided as part of Sun RPC. - - * The non-copying modifier functions can now be used to assemble object - models from scratch. For more information see Section 4.4, "Creating - the Object Model from Scratch" in the C++/Tree Mapping Getting Started - Guide as well as Section 2.8, "Mapping for Local Elements and Attributes" - in the C++/Tree Mapping User Manual. - - * Doxygen documentation was added to the XSD runtime for the built-in XML - Schema types, exceptions, etc. This allows linking of the generated - documentation to the XSD runtime documentation using the Doxygen tags - mechanism. The Doxygen configuration file for the XSD runtime is - provided in the documentation/cxx/tree/reference/ directory. - - * Support for customization of anyType. Because anyType is a base type - for every generated type, customizing it allows one to implement custom - functionality that spans the entire type system. See the comments - example in the examples/cxx/tree/custom/ directory. - - * New option, --omit-default-attributes, triggers generation of extra - checks that exclude attributes with default and fixed values from the - serialized XML documents. - - * The parsing functions that used to read from DOMInputSource were changed - to use InputSource to ease support of Xerces-C++ 3 and 2 series in the - same code base. - - * The parsing function that used to parse DOMDocument* was changed to - parse xml_schema::dom::auto_ptr& instead. If the keep_dom - and own_dom flags are specified then this parsing function resets the - passed automatic pointer and the returned object model assumes - ownership of the DOM document. xml_schema::dom::auto_ptr is a simple - automatic pointer for Xerces-C++ DOM with the same interface as - std::auto_ptr. - - * The xml_schema::tree_node_key DOM user data key was moved to - xml_schema::dom::tree_node_key. - - C++/Parser - - * New option, --generate-polymorphic, triggers generation of polymorphism- - aware code. This option should be used on XML vocabularies which use - xsi:type and/or substitution groups. For more information see Section - 5.4, "Support for Polymorphism" in the C++/Parser Mapping Getting - Started Guide we well as the polymorphism and polyroot examples in the - examples/cxx/parser/ directory. - - * The date/time types (date, dateTime, gDay, gMonth, gMonthDay, gYear, - gYearMonth, and time) now represent time zone in the numerical form. - - * In order to support parsing of polymorphic XML documents, the signatures - of the start_* functions (_start_element, _start_any_element, and - start_root_element) have changed to include a third argument of type - const ro_string*. This argument contains the resolved type name and - namespace in case the xsi:type attribute was specified. - -Version 3.0.0 - - * Anonymous type morphing (automatic type naming) is now performed by - default in both mappings. The --morph-anonymous option does not have - any effect but is preserved for backwards compatibility. A new option, - --preserve-anonymous, disables anonymous type morphing. This option is - useful together with --show-anonymous if you want to make sure your - schemas do not have any anonymous types. - - * A number of bugs fixed in both C++/Tree and C++/Parser mappings. - - C++/Tree - - * The new C++/Tree Mapping Getting Started Guide is available in the - documentation/cxx/tree/guide/ directory. - - * The type definitions for local elements and attributes in the form - name::type have been changed to name_type. For example, an element - bar in type foo with maxOccurs="unbounded" used to have its iterator - type defined as foo::bar::iterator. With this change it becomes - foo::bar_iterator. Furthermore, the container type name for sequence - elements has changed from foo::bar::container to foo::bar_sequence - and for optional elements and attributes from foo::bar::container - to foo::bar_optional. This is a backwards incompatible change and - may require application code adjustments (the C++ compiler will - pinpoint the affected places). - - * New option, --generate-doxygen, triggers generation of documentation - comments suitable for extraction by the Doxygen documentation system. - Documentation from annotations is added to the comments if present in - the schema. - - * New option, --generate-wildcard, triggers generation of the new - wildcard (any and anyAttribute) mapping. This mapping represents the - content matched by wildcards as DOM fragments. For more information on - the new mapping see Section 2.12, "Mapping for any and anyAttribute" - in the C++/Tree Mapping User Manual as well as the wildcard example in - the examples/cxx/tree/ directory. - - * New option, --generate-comparison, triggers generation of comparison - operators (== and !=) for complex types. Comparison is performed - memberwise. - - * Support for the RPC XDR binary stream in addition to ACE CDR. - - * New constructor is generated for complex types with ultimate bases - that are simple types and can be default-initialized. This constructor - includes initializers for all required members but omits the initializer - for the base type. See Section 2.7, "Mapping for Complex Types" in the - C++/Tree Mapping User Manual for more information. - - * Support for polymorphic binary serialization and extraction. Note that - the semantics of the --generate-insertion and --generate-extraction - options has changed. See the the compiler command line manual (man - pages) for details. - - * New parsing function with the DOMDocument* argument and the own_dom - flag allow the tree to assume the ownership of the DOM document - being parsed when DOM association is requested (keep_dom flag). - See the C++/Tree Mapping User Manual for more information. - - * New example, multiroot, shows how to handle XML vocabularies with - multiple root elements. - - * New example, caching, shows how to parse several XML documents while - reusing the underlying XML parser and caching the schemas used for - validation. - - * The mapping of built-in XML Schema type decimal has changed from - long double to double. The old mapping can be obtained by providing - a custom mapping for this type. - - * The xml_schema::errors type which is used in the xml_schema::parsing - and xml_schema::serialization exceptions has been renamed to - xml_schema::diagnostics and extended to include warnings in addition - to errors. - - * Serialization operators now clear the element being serialized to from - existing child nodes and attributes (except for special attributes such - as prefix-namespace mappings, etc.). - - * Improved built-in type parsing, including support for normalization and - whitespace collapsing. - - * Optimizations for the generated code size and compilation time, - including space optimizations for polymorphic parsing and - serialization. Optimizations for XML parsing speed. - - C++/Parser - - * The C++/Parser mapping have been significantly redesigned. See the new - Getting Started Guide in documentation/cxx/parser/guide/ for details. - - * The new C++/Parser Mapping Getting Started Guide is available in the - documentation/cxx/parser/guide/ directory. - - * The mapping now provides parser implementations for all built-in XML - Schema types. See Chapter 6, "Built-In XML Schema Type Parsers" in - the C++/Parser Mapping Getting Started Guide for more information. - - * The mapping now supports automatic generation of sample parser - implementations and a test driver. The --generate-noop-impl option - triggers generation of a sample implementation with empty function - bodies. The --generate-print-impl option triggers generation of a - sample implementation that prints the data stored in XML to STDOUT. - The --generate-test-driver option trigger generation of a test driver. - For more information on this feature see the compiler command line - manual (man pages) and the generated example in the examples/cxx/parser/ - directory. Other relevant options include: --force-overwrite, - --root-element-first, --root-element-last, and --root-element. - - * New example, wildcard, shows how to parse the XML data matched by - XML Schema wildcards (any and anyAttribute). - - * The xml_schema::document parser has been extended with overridable - virtual functions start_root_element and end_root_element to support - parsing of XML vocabularies with multiple document roots. See the - multiroot example in the examples/cxx/parser/ directory for more - information. - - * The xml_schema::errors type which is used in the xml_schema::parsing - exception has been renamed to xml_schema::diagnostics and extended to - include warnings in addition to errors. - -Version 2.3.1 - - * The compiler is now capable of translating multiple schemas with - one invocation. - - * New option, --sloc-limit, allows one to limit the amount of the - generated code. - - * New option, --proprietary-license, instructs the compiler not to - include the GPL banner in each generated file. Instead a short - notice about a required proprietary license is generated. You - should not use this option unless you have obtained a proprietary - license from Code Synthesis Tools CC. - - * The default encoding for the 'char' character type is now UTF-8. - To get the previous behavior (local code page via the Xerces-C++ - transcode functions) define the XSD_USE_LCP preprocessor macro - when compiling your source code. - - C++/Tree - - * The --parts option has been improved to split generated code more - evenly by analyzing the complexity of the generated schema constructs. - - * Ability to customize serialization, std::ostream, and binary - insertion/extraction operators. See examples/cxx/tree/custom/wildcard - for an example on how to handle XML Schema wildcards (xsd:any and - xsd:anyAttribute) by customizing the parsing constructor and - serialization operators. - - * Optimizations for the run-time memory consumption. - - * Optimizations for space in the generated code. - - * Number of bug fixes. - - C++/Parser - - * Proper handling of an xsd:any nested content. Nested elements, - attributes, and text are reported via _any_* hooks of the current - parser. - - * Number of bug fixes, mostly in the generated validation code. - - -Version 2.3.0 - - * Name conflicts across type inheritance hierarchies are now detected - and resolved via name escaping. - - C++/Tree - - * New option, --suppress-parsing, suppresses generation of the parsing - constructors and functions. This can be used to minimize the generated - code footprint when parsing from XML is not used. - - * New option, --generate-forward, triggers generation of a forward - declaration header file for types defined in the schema. A set of - --fwd-* options that control the resulting file name as well as - prologue and epilogue code are available. - - * New option, --generate-xml-schema, triggers generation of the mapping - for the XML Schema namespace to a separate header file. See the man - pages for details and examples/cxx/tree/custom/calendar for an example. - - * New option, --extern-xml-schema, triggers inclusion of a header - file for the XML Schema namespace instead of generating the - necessary declarations inline. See the man pages for details and - examples/cxx/tree/custom/calendar for an example. - - * New options, --custom-type and --custom-type-regex, instruct the - compiler to use custom C++ type for a type defined in the schema. - The standard mapping can still be generated (with a different name) - usually to be used as a base. Built-in XML Schema types can be - customized using this mechanism. See the man pages for details and - examples/cxx/tree/custom/* for examples. - - * The generated parsing constructors and serialization operators have - been changed to use the Xerces-C++ DOM elements and attributes - instead of the internal wrapper types. This should provide easier - integration with other code and libraries that use the Xerces-C++ - DOM types such as Berkeley DB XML. - - * New example, examples/cxx/tree/dbxml, shows how to use the C++/Tree - mapping on top of the Berkeley DB XML database. - - C++/Parser - - * Validation of the attribute structure in the generated code. - - * Validation of the character content models including mixed content in - the generated code. - - * Validation of the built-in XML Schema types. - - * Optimizations for space and time in the generated code. In particular - data coping during parsing and validation was significantly reduced. - - -Version 2.2.0 - - * Detection of a version mismatch between the generated code and - the runtime. - - C++/Tree - - * Escaping of a global element name that conflicts with a global type - name. This is a backwards-incompatible change. Previous versions - map them to the same name. - - * New options, --generate--insertion and --generate-extraction, - trigger generation of (binary) data representation stream - insertion and extraction operators, respectively. This allows - one to serialize/deserialize in-memory representation to/from - data representation streams such as XSD, CDR, etc. ACE CDR - streams are supported out of the box (see the binary example). - User-supplied streams can be used via an adaptation layer. - - * New serialization flag, no_xml_declaration, instructs the XML - serialization functions to omit an XML declaration. This is useful - for streaming serialization (see the streaming example). - - * Optimizations to reduce generated code size. - - - C++/Parser - - * New options, --generate-validation and --suppress-validation, - trigger and suppress generation of the validation code, - respectively. The validation code is the implementation of the - XML Schema validation in the generated code (also known as - "perfect" parser). In this version validation of the element - structure has been implemented. - - * New architecture for underlying XML parsers. This is a backwards- - incompatible change. Existing applications will have to be - modified. See examples for details. - - -Version 2.1.1 - - C++/Tree - - * New option, --namespace-map, allows direct mapping of XML Schema - namespaces to C++ namespaces without the use of regular expressions. - - * Further optimizations in the container code and enum mapping to - reduce generated code size. - - * Number of bug fixes in the generated code. - - - C++/Parser - - * New option, --namespace-map, allows direct mapping of XML Schema - namespaces to C++ namespaces without the use of regular expressions. - - -Version 2.1.0 - - * Automatic handling of forward inheritance. XML Schema allows - inheritance from yet undefined types while it is illegal to do - so in C++. Now the translator automatically handles forward - inheritance by re-arranging the schema during compilation. - - - C++/Tree - - * New enum mapping with support for inheritance. Enumerators are - now parsed using binary search instead of linear search. - - * Associated DOM nodes now retain "back" pointers to tree nodes. - - * Optimizations to reduce generated code size. - - - C++/Parser - - * Specialization for void. You can now use void as a hook argument - type if you don't want to pass any data between parsers. - - * Support for re-use of implementations of base parsers in derived - parsers using the mixin C++ idiom. See the examples/cxx/parser/mixin - for more information. - - * Support for uninitialized parser. If you don't provide a parser - for element/attribute, that element/attribute will be ignored - during parsing. - - -Version 2.0.0 - - * New cardinality calculator. This improves support for schemas that - use complex structures with repeated elements, e.g., - - - - - - - - - - - - - - - - * New identifier escaping code. With this feature xsd generates proper - code for schemas that use the same name for an element and an attribute - in the same type or use several elements/attributes with different - qualified names but with the same local name, e.g., - - - - - - - - - - - - - - - - - - - - - - - - - - C++/Tree - - * New option, --generate-polymorphic, triggers generation of - polymorphism-aware code. Before this release xsd used to always - generate polymorphism-aware code. However, it appears to be quite - wasteful in terms of the generated code size (up to 40%). You will - now need to explicitly specify this option if you use substitution - groups or xsi:type. A warning is issued if this option is not - specified but the schema makes use of substitution groups. - - * New options, --root-element-first, --root-element-last, - --root-element-all, --root-element-none, and --root-element, control - generation of parsing and serialization functions. With these options - you can avoid generating extra code for global elements that are not - document roots. See the man pages for details. - - * New options, --parts and -parts-suffix, allows you to split generated - source code into a number of parts. This is useful when translating - large, monolithic schemas and a C++ compiler is not able to compile - the resulting source code at once (usually due to insufficient memory). - - * New option, --generate-default-ctor, triggers generation of default - constructors even for types that have required members. Required - members of an instance constructed using such a constructor are not - initialized and accessing them results in undefined behavior. Thanks - to Jean-Francois Dube for suggesting this - feature. - - * New option, --generate-from-base-ctor, triggers generation of - constructors that expect an instance of a base type followed by all - required members. Thanks to Jean-Francois Dube - for suggesting this feature. - - * Information scopes for attributes and elements with default/fixed values - now define the public static default_value function which allows one to - obtain the default/fixed value for the element/attribute. Thanks to - Dave Moss for suggesting this feature. - - * MSVC 7.1 has a limit on the length of the "if else if" chain. This - results in ICE when compiling generated code for enumerations with - a large number of values. This version addresses this issue. Thanks - to Cyrille Chépélov for reporting this and - suggesting a fix. - - - C++/Parser - - * The parser construction API has changed. Now, for element 'foo', - the name of the parser modifier function is 'foo_parser'. Likewise, - operator() for setting all parsers at once has been changed to the - 'parsers' function. - - -Version 1.9.0 - - C++/Tree - - * The size modifier function in the base64_binary and hex_binary - built-in types automatically adjusts capacity if needed. - - * More internal names (names that start with _xsd_) were made - private or protected. - - C++/Parser - - * Typedef for the parser base in the xml_schema namespace. - - C++/Parser-E - - * C++/Parser mapping optimized for embedded systems. For now it - is equivalent to 'cxx-parser --xml-parser expat'. - - -Version 1.8.0 - - * Moved to the build 0.2 series. - - C++/Tree - - * Support for default and fixed values in attributes. An optional - attribute with a default or fixed value is mapped to the One - cardinality class instead of the Optional cardinality class. - - * Mapping for base64Binary and hexBinary has improved. Now these - types support a basic buffer abstraction and perform automatic - encoding and decoding. - - * Internal names are protected. We've noticed (via bug reports) a - wide use of internal names (names that start with _xsd_) in user - code. This is not portable and instead you should use public - names. To prevent this from happening in the future we've made - all internal names protected. - - C++/Parser - - * Support for Expat as the underlying XML parser in addition to - Xerces-C++. This allows one to use the C++/Parser mapping in - memory-constrained environments such as embedded systems. To - select Expat instead of Xerces-C++ (default) add - '--xml-parser expat' to the command line. At the moment only - 'char' (UTF-8) is supported as the base character type when - Expat is selected. - - * The invalid_instance exception has been renamed to parsing. - - * Generic error_handler interface has been added in addition - to Xerces-C++-specific DOMErrorHandler. It allows you to - handle parsing errors and warnings without having to deal - with Xerces-C++ specifics. - - * The default error handling behavior has changed in parsing - functions. Instead of printing errors and warnings to STDERR, - the errors are now collected and thrown as part of the parsing - exception. - - * In parsing functions, the name, namespace arguments order has - been reversed to be consistent with the one used in parsing - hooks. - -Version 1.7.0 - - * Number of bug fixes in libxsd and the generated code. - - C++/Tree - - * Comprehensive XML Schema C++/Tree Mapping User Manual. - - * Basic support for union. A simple type that is defined using - derivation by union is mapped to a C++ class that derives from - string. - - * The _clone function has its arguments default-initialized. - - * The invalid_instance exception has been renamed to parsing. - - * Generic error_handler interface has been added in addition - to Xerces-C++-specific DOMErrorHandler. It allows you to - handle parsing/serialization errors and warnings without - having to deal with Xerces-C++ specifics. See the user - manual for more information. - - * The default error handling behavior has changed in parsing - and serialization functions. Instead of printing errors and - warnings to STDERR, the errors are now collected and thrown - as part of the parsing/serialization exception. See the user - manual for more information. - - * The optional and sequence containers now support operators ==, - !=, <, >, <=, and >=. - - * Flags argument has been added to serialization functions. The - only flag that is currently supported is dont_initialize. - - * Generated code cleanups. - - C++/Parser - - * Basic support for union. A simple type that is defined using - derivation by union is mapped to a C++ class template that - is just an alias for the generic parser. You are expected to - override the _characters function in your implementation. - - * Properties argument to parsing functions which allows to - programmatically specify schemas for instance document - validation. - - * Flags argument to parsing functions. The following flags - are supported: - - dont_validate - do not validate instance documents - dont_initialize - do not initialize the Xerces-C++ runtime - -Version 1.6.0 - - * Number of bug fixes in libxsd and the generated code. - - C++/Tree - - * Support for xsi:type and substitution groups in parsing and - serialization. See examples/cxx/tree/polymorphism for a code - sample. - - * Properties argument to parsing functions which allows to - programmatically specify schemas for instance document - validation. - - * Extra checks in parsing code which prevents construction - of inconsistent in-memory representation from invalid - instance documents. Should be useful when validation is - disabled. - - * Accessors and modifier were made normal member functions. - Before they were implemented via functors. - - * Workaround for g++-3.3 bug# 16650: - - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16650 - - C++/Parser - - * All "service" functions were renamed to start with '_'. - This should prevent hiding of service functions by - elements/attributes with the same names. - -Version 1.5.0 - - * Number of bug fixes in libxsd and the generated code. - - C++/Tree - - * Basic support for inheritance-by-restriction in complex types. - - * The following parsing flags have been introduced: - - keep_dom - keep association with underlying DOM nodes - dont_validate - do not validate instance documents - dont_initialize - do not initialize the Xerces-C++ runtime - - * "Type-less content" such as mixed content models, xsd:anyType/ - xsd:anySimpleType, and xsd:any/xsd:anyAttribute is supported by - exposing corresponding DOM nodes (see the keep_dom parsing flag). - Note that only a subset of XML Schema xsd:any functionality is - supported. The compiler will issue diagnostics for unsupported - cases. See examples/cxx/tree/mixed for a code sample. - - C++/Parser - - * Support for inheritance-by-restriction in complex types. - - * "Type-less content" such as mixed content models, xsd:anyType/ - xsd:anySimpleType, and xsd:any/xsd:anyAttribute is supported - by forwarding parsing events to a set of "unexpected" hooks. - Note that only a subset of XML Schema xsd:any functionality is - supported. The compiler will issue diagnostics for unsupported - cases. See examples/cxx/parser/mixed for a code sample. - -Version 1.4.0 - - * Number of improvements and bug fixes in the diagnostics code. - - * libxsd has been reorganized to provide a clean split of code with - regards to char/wchar_t use. It should be possible to use libxsd - and the xsd-generated code on platforms that lack wchar_t support, - such as mingw. - - C++/Tree - - * Work around for g++ bug# 23206. - - * Support for xsd:list. - - * Type/member name conflicts are auto-resolved. Such conflicts - occur when a type and an element or attribute withing this type - share the same name. - - * XML Schema extension, the 'refType' attribute, allows one to - specify referenced type for xsd:IDREF and xsd:IDREFS data types. - See examples/cxx/tree/library for details. - - * New option, --morph-anonymous, allows automatic morphing - of anonymous types to named ones. See the man pages for - details. - - * New option, --namespace-regex-trace, allows one to trace the - namespace mapping process. See the man pages for details. - - * Mapping for optional elements/attributes (cardinality 0..1) - has changed in a backwards-incompatible way. In the previous - version you would write: - - Bar& bar = ... - - if (bar.foo.present ()) // test - { - Foo& foo (bar.foo ()); // get - - bar.foo (Foo (...)); // set - - bar.foo.reset (); // reset - } - - Now you would write it like this: - - if (bar.foo ().present ()) // test - { - Foo& foo (bar.foo ().get ()); // get - - bar.foo (Foo (...)); // set - - bar.foo ().reset (); // reset - } - - Or using the pointer notation: - - if (bar.foo ()) // test - { - Foo& foo (*bar.foo ()); // get - - bar.foo (Foo (...)); // set - - bar.foo ().reset (); // reset - } - - C++/Parser - - * Support for xsd:list. - - * Type/member name conflicts are auto-resolved. Such conflicts - occur when a type and an element or attribute withing this type - share the same name. - - * New option, --namespace-regex-trace, allows one to trace the - namespace mapping process. See the man pages for details. - -Version 1.3.0 - - * Numerous bug fixes. - - * The XML subsystem of libxsd has been reorganized to provide - a clean split of DOM and SAX functionalities. - - C++/Parser - - * New option, --morph-anonymous, allows automatic morphing - of anonymous types to named ones. See the man pages for - details. - - C++/Tree - - * Additional parser functions provide support for reading - from std::istream. - -Version 1.2.0 - - C++/Parser - - * New backend that generates the C++/Parser mapping. - -Version 1.1.1 - - all backends - - * Bug fixes in the filesystem path handling logic. - -Version 1.1.0 - - C++/Tree - - * New option, --generate-serialization, triggers generation of - serialization functions. Serialization functions convert an in-memory - representation back to XML. - - * xsd::cxx::tree::vector has been extended to closely follow std::vector - API. This allows you to access and modify element sequences as if they - were of type std::vector. - - * Generated constructors from xml::attribute and xml::element are made - explicit. - - * The library example was extended to showcase modification and - serialization of the in-memory representation. - - * New "XML Schema C++/Tree Mapping Serialization Guide" has an in-depth - treatment of the serialization mechanisms provided by xsd. - -Version 1.0.1 - - all backends - - * Improved diagnostics. - - * Bug fixes in the schema inclusion/importing logic. - - C++/Tree - - * Two new options: --include-with-brackets and --include-prefix - -Version 1.0.0 - - * First public release. diff --git a/README b/README deleted file mode 100644 index 80d707f..0000000 --- a/README +++ /dev/null @@ -1,27 +0,0 @@ -CodeSynthesis XSD is a W3C XML Schema to C++ data binding compiler. -It generates vocabulary-specific, statically-typed C++ mappings (also -called bindings) from XML Schema definitions. XSD supports two C++ -mappings: in-memory C++/Tree and event-driven C++/Parser. - -The C++/Tree mapping consists of types that represent the given -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. - -The C++/Parser mapping provides parser templates for data types -defined in XML Schema. Using these parser templates you can build -your own in-memory representations or perform immediate processing -of XML instance documents. - -See the NEWS file for the user-visible changes from the previous release. - -See the LICENSE file for distribution conditions. - -See the INSTALL file for prerequisites and installation instructions. - -See the doc/ directory for documentation. - -The project page is at https://www.codesynthesis.com/projects/xsd/. - -Send bug reports or any other feedback to the xsd-users@codesynthesis.com -mailing list. diff --git a/build/bootstrap.make b/build/bootstrap.make deleted file mode 100644 index da317c3..0000000 --- a/build/bootstrap.make +++ /dev/null @@ -1,101 +0,0 @@ -# file : build/bootstrap.make -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -project_name := xsd - -# First try to include the bundled bootstrap.make if it exist. If that -# fails, let make search for the external bootstrap.make. -# -build := build-0.3 - --include $(dir $(lastword $(MAKEFILE_LIST)))../../$(build)/bootstrap.make - -ifeq ($(patsubst %build/bootstrap.make,,$(lastword $(MAKEFILE_LIST))),) -include $(build)/bootstrap.make -endif - -def_goal := $(.DEFAULT_GOAL) - -# Configuration -# -$(call include,$(scf_root)/configuration.make) - -# Include C++ configuration. We need to know if we are using the generic -# C++ compiler in which case we need to compensate for missing dependency -# auto-generation (see below). -# -$(call include,$(bld_root)/cxx/configuration.make) - -# Aliases -# -.PHONY: $(out_base)/ \ - $(out_base)/.test \ - $(out_base)/.install \ - $(out_base)/.dist \ - $(out_base)/.dist-win \ - $(out_base)/.dist-common \ - $(out_base)/.clean - -ifdef %interactive% - -.PHONY: test install dist dist-win clean - -test: $(out_base)/.test -install: $(out_base)/.install -dist: $(out_base)/.dist -dist-win: $(out_base)/.dist-win -clean: $(out_base)/.clean - -endif - - -# Make sure the distribution prefix is set if the goal is dist or dist-win. -# -ifneq ($(filter $(MAKECMDGOALS),dist dist-win),) -ifeq ($(dist_prefix),) -$(error dist_prefix is not set) -endif -endif - -# If we don't have dependency auto-generation then we need to manually -# make sure that generated files are generated before C++ file are -# compiler. To do this we make the object files ($2) depend in order- -# only on generated files ($3). -# -ifeq ($(cxx_id),generic) - -define include-dep -$(if $2,$(eval $2: | $3)) -endef - -else - -define include-dep -$(call -include,$1) -endef - -endif - -# Don't include dependency info for certain targets. -# -ifneq ($(filter $(MAKECMDGOALS),clean disfigure),) -include-dep = -endif - - -# For dist, install don't include dependencies in examples, and tests -# since we might be cross-compiling. -# -ifneq ($(filter $(MAKECMDGOALS),dist dist-win install),) - -ifneq ($(subst $(src_root)/tests/,,$(src_base)),$(src_base)) -include-dep = -endif - -ifneq ($(subst $(src_root)/examples/,,$(src_base)),$(src_base)) -include-dep = -endif - -endif - -.DEFAULT_GOAL := $(def_goal) diff --git a/build/configuration-rules.make b/build/configuration-rules.make deleted file mode 100644 index e5e2b08..0000000 --- a/build/configuration-rules.make +++ /dev/null @@ -1,16 +0,0 @@ -# file : build/configuration-rules.make -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -$(dcf_root)/configuration-dynamic.make: | $(dcf_root)/. - $(call message,,$(scf_root)/configure $@) - -ifndef %foreign% - -disfigure:: - $(call message,rm $$1,rm -f $$1,$(dcf_root)/configuration-dynamic.make) - -endif - -ifeq ($(.DEFAULT_GOAL),$(dcf_root)/configuration-dynamic.make) -.DEFAULT_GOAL := -endif diff --git a/build/configuration.make b/build/configuration.make deleted file mode 100644 index fe7f42d..0000000 --- a/build/configuration.make +++ /dev/null @@ -1,30 +0,0 @@ -# file : build/configuration.make -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -$(call include-once,$(scf_root)/configuration-rules.make,$(dcf_root)) - -# Dynamic configuration. -# -xsd_with_zlib := -xsd_with_ace := -xsd_with_xdr := -xsd_with_xqilla := -xsd_with_boost_date_time := -xsd_with_boost_serialization := - -$(call -include,$(dcf_root)/configuration-dynamic.make) - -ifdef xsd_with_zlib - -$(out_root)/%: xsd_with_zlib := $(xsd_with_zlib) -$(out_root)/%: xsd_with_ace := $(xsd_with_ace) -$(out_root)/%: xsd_with_xdr := $(xsd_with_xdr) -$(out_root)/%: xsd_with_xqilla := $(xsd_with_xqilla) -$(out_root)/%: xsd_with_boost_date_time := $(xsd_with_boost_date_time) -$(out_root)/%: xsd_with_boost_serialization := $(xsd_with_boost_serialization) - -else - -.NOTPARALLEL: - -endif diff --git a/build/configure b/build/configure deleted file mode 100755 index 7e3ac79..0000000 --- a/build/configure +++ /dev/null @@ -1,69 +0,0 @@ -#! /usr/bin/env bash - -# file : build/configure -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -# $1 out file -# -# bld_root - build root -# project_name - project name -# - -source $bld_root/dialog.bash - - -$echo -$echo -$echo "configuring '$project_name'" -$echo -$echo - -$echo -$echo "Would you like to build optional parts of '$project_name' that require" -$echo "the 'zlib' library?" -$echo - -with_zlib=`read_y_n n` - -$echo -$echo "Would you like to build optional parts of '$project_name' that require" -$echo "the 'ACE' library?" -$echo - -with_ace=`read_y_n n` - -$echo -$echo "Would you like to build optional parts of '$project_name' that require" -$echo "the 'XDR' library (part of the system in most GNU/Linux and" -$echo "UNIX distributions)?" -$echo - -with_xdr=`read_y_n n` - -$echo -$echo "Would you like to build optional parts of '$project_name' that require" -$echo "the boost 'serialization' library?" -$echo - -with_boost_serialization=`read_y_n n` - -$echo -$echo "Would you like to build optional parts of '$project_name' that require" -$echo "the boost 'date_time' library?" -$echo - -with_boost_date_time=`read_y_n n` - -$echo -$echo "Would you like to build optional parts of '$project_name' that require" -$echo "the XQilla library?" -$echo - -with_xqilla=`read_y_n n` - -echo "xsd_with_zlib := $with_zlib" >$1 -echo "xsd_with_ace := $with_ace" >>$1 -echo "xsd_with_xdr := $with_xdr" >>$1 -echo "xsd_with_xqilla := $with_xqilla" >>$1 -echo "xsd_with_boost_date_time := $with_boost_date_time" >>$1 -echo "xsd_with_boost_serialization := $with_boost_serialization" >>$1 diff --git a/build/import/cli/cli-cxx.make b/build/import/cli/cli-cxx.make deleted file mode 100644 index 9bdf238..0000000 --- a/build/import/cli/cli-cxx.make +++ /dev/null @@ -1,47 +0,0 @@ -# file : build/import/cli/cli-cxx.make -# license : MIT; see accompanying LICENSE file - -# Here we are operating in the importing project's space, not in -# cli's. -# - -# Get the C++ file extensions. -# -$(call include,$(bld_root)/cxx/configuration-static.make) - -cli_pattern := \ -$(out_base)/%.$(cxx_s_suffix) \ -$(out_base)/%.$(cxx_h_suffix) \ -$(out_base)/%.$(cxx_i_suffix) - -$(cli_pattern): cli_options := \ ---hxx-suffix .$(cxx_h_suffix) \ ---ixx-suffix .$(cxx_i_suffix) \ ---cxx-suffix .$(cxx_s_suffix) - -.PRECIOUS: $(cli_pattern) - -ifeq ($(out_base),$(src_base)) - -$(cli_pattern): $(src_base)/%.cli - $(call message,cli $<,$(cli) $(cli_options) --output-dir $(dir $@) $<) - -else - -$(cli_pattern): $(src_base)/%.cli | $$(dir $$@). - $(call message,cli $<,$(cli) $(cli_options) --output-dir $(dir $@) $<) - -$(cli_pattern): $(out_base)/%.cli | $$(dir $$@). - $(call message,cli $<,$(cli) $(cli_options) --output-dir $(dir $@) $<) -endif - -.PHONY: $(out_base)/%.cxx.cli.clean - -$(out_base)/%.cxx.cli.clean: cxx_s_suffix := $(cxx_s_suffix) -$(out_base)/%.cxx.cli.clean: cxx_h_suffix := $(cxx_h_suffix) -$(out_base)/%.cxx.cli.clean: cxx_i_suffix := $(cxx_i_suffix) - -$(out_base)/%.cxx.cli.clean: - $(call message,rm $$1,rm -f $$1,$(@:.cxx.cli.clean=.$(cxx_s_suffix))) - $(call message,rm $$1,rm -f $$1,$(@:.cxx.cli.clean=.$(cxx_h_suffix))) - $(call message,rm $$1,rm -f $$1,$(@:.cxx.cli.clean=.$(cxx_i_suffix))) diff --git a/build/import/cli/configuration-rules.make b/build/import/cli/configuration-rules.make deleted file mode 100644 index 6355000..0000000 --- a/build/import/cli/configuration-rules.make +++ /dev/null @@ -1,13 +0,0 @@ -# file : build/import/cli/configuration-rules.make -# license : MIT; see accompanying LICENSE file - -$(dcf_root)/import/cli/configuration-dynamic.make: | $(dcf_root)/import/cli/. - $(call message,,$(scf_root)/import/cli/configure $@) - -ifndef %foreign% - -$(dcf_root)/.disfigure:: - $(call message,rm $(dcf_root)/import/cli/configuration-dynamic.make,\ -rm -f $(dcf_root)/import/cli/configuration-dynamic.make) - -endif diff --git a/build/import/cli/configure b/build/import/cli/configure deleted file mode 100755 index 2a1fde4..0000000 --- a/build/import/cli/configure +++ /dev/null @@ -1,53 +0,0 @@ -#! /usr/bin/env bash - -# file : build/import/cli/configure -# license : MIT; see accompanying LICENSE file - - -# $1 - out file -# -# bld_root - build root -# project_name - project name -# - -source $bld_root/dialog.bash - - -$echo -$echo "Configuring external dependency on 'cli' for '$project_name'." -$echo - -$echo -$echo "Would you like to configure dependency on the installed " -$echo "version of 'cli' as opposed to the development build?" -$echo - -installed=`read_y_n y` - -path= - -if [ "$installed" = "n" ]; then - -$echo -$echo "Please enter the src_root for 'cli'." -$echo - -src_root=`read_path --directory --exist` - -$echo -$echo "Please enter the out_root for 'cli'." -$eche - -out_root=`read_path --directory $src_root` - -fi - -echo cli_installed := $installed >$1 - -if [ "$installed" = "n" ]; then - -echo src_root := $src_root >>$1 -echo scf_root := \$\(src_root\)/build >>$1 -echo out_root := $out_root >>$1 - -fi diff --git a/build/import/cli/stub.make b/build/import/cli/stub.make deleted file mode 100644 index 741b371..0000000 --- a/build/import/cli/stub.make +++ /dev/null @@ -1,28 +0,0 @@ -# file : build/import/cli/stub.make -# license : MIT; see accompanying LICENSE file - -$(call include-once,$(scf_root)/import/cli/configuration-rules.make,$(dcf_root)) - -cli_installed := - -$(call -include,$(dcf_root)/import/cli/configuration-dynamic.make) - -ifdef cli_installed - -ifeq ($(cli_installed),y) - -$(call export,cli: cli,cli-rules: $(scf_root)/import/cli/cli-cxx.make) - -else - -# Include export stub. -# -$(call include,$(scf_root)/export/cli/stub.make) - -endif - -else - -.NOTPARALLEL: - -endif diff --git a/build/import/libace/configuration-rules.make b/build/import/libace/configuration-rules.make deleted file mode 100644 index 380e849..0000000 --- a/build/import/libace/configuration-rules.make +++ /dev/null @@ -1,13 +0,0 @@ -# file : build/import/libace/configuration-rules.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(dcf_root)/import/libace/configuration-dynamic.make: | $(dcf_root)/import/libace/. - $(call message,,$(scf_root)/import/libace/configure $@) - -ifndef %foreign% - -disfigure:: - $(call message,rm $(dcf_root)/import/libace/configuration-dynamic.make,\ -rm -f $(dcf_root)/import/libace/configuration-dynamic.make) - -endif diff --git a/build/import/libace/configure b/build/import/libace/configure deleted file mode 100755 index 36aec69..0000000 --- a/build/import/libace/configure +++ /dev/null @@ -1,56 +0,0 @@ -#! /usr/bin/env bash - -# file : build/import/libace/configure -# license : GNU GPL v2; see accompanying LICENSE file - - -# $1 - out config file -# -# bld_root - build root -# project_name - project name -# - -source $bld_root/dialog.bash - - -$echo -$echo "Configuring external dependency on 'ACE' for '$project_name'." -$echo - -$echo -$echo "Would you like to configure dependency on the installed version" -$echo "of 'ACE' as opposed to the development build?" -$echo - -installed=`read_y_n y` - -path= -type= - -if [ "$installed" = "n" ]; then - - $echo - $echo "Please enter the 'ACE' root directory (ACE_ROOT)." - $echo - - root=`read_path --directory --exist` - - $echo - $echo "Please select the library type you would like to use:" - $echo - $echo "(1) archive" - $echo "(2) shared object" - $echo - - type=`read_option "archive shared" "shared"` - -fi - -echo libace_installed := $installed >$1 - -if [ "$installed" = "n" ]; then - - echo libace_root := $root >>$1 - echo libace_type := $type >>$1 - -fi diff --git a/build/import/libace/rules.make b/build/import/libace/rules.make deleted file mode 100644 index f183051..0000000 --- a/build/import/libace/rules.make +++ /dev/null @@ -1,27 +0,0 @@ -# file : build/import/libace/rules.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(dcf_root)/import/libace/%: root := $(libace_root) - -ifeq ($(libace_type),archive) - -$(dcf_root)/import/libace/ace.l: $(libace_root)/lib/libACE.a - @echo $< >$@ -else - -$(dcf_root)/import/libace/ace.l: $(libace_root)/lib/libACE.so - @echo $< >$@ - @echo rpath:$(root)/lib >>$@ -endif - -$(dcf_root)/import/libace/ace.l.cpp-options: - @echo include: -I$(root) >$@ - -ifndef %foreign% - -disfigure:: - $(call message,rm $(dcf_root)/import/libace/ace.l,\ -rm -f $(dcf_root)/import/libace/ace.l) - $(call message,,rm -f $(dcf_root)/import/libace/ace.l.cpp-options) - -endif diff --git a/build/import/libace/stub.make b/build/import/libace/stub.make deleted file mode 100644 index fba22d5..0000000 --- a/build/import/libace/stub.make +++ /dev/null @@ -1,30 +0,0 @@ -# file : build/import/libace/stub.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(call include-once,$(scf_root)/import/libace/configuration-rules.make,$(dcf_root)) - -libace_installed := - -$(call -include,$(dcf_root)/import/libace/configuration-dynamic.make) - -ifdef libace_installed - -ifeq ($(libace_installed),y) - -$(call export,l: -lACE,cpp-options: ) - -else - -$(call include-once,$(scf_root)/import/libace/rules.make,$(dcf_root)) - -$(call export,\ - l: $(dcf_root)/import/libace/ace.l,\ - cpp-options: $(dcf_root)/import/libace/ace.l.cpp-options) - -endif - -else - -.NOTPARALLEL: - -endif diff --git a/build/import/libace/version b/build/import/libace/version deleted file mode 100644 index 0d91a54..0000000 --- a/build/import/libace/version +++ /dev/null @@ -1 +0,0 @@ -0.3.0 diff --git a/build/import/libboost/configuration-rules.make b/build/import/libboost/configuration-rules.make deleted file mode 100644 index dba014c..0000000 --- a/build/import/libboost/configuration-rules.make +++ /dev/null @@ -1,13 +0,0 @@ -# file : build/import/libboost/configuration-rules.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(dcf_root)/import/libboost/configuration-dynamic.make: | $(dcf_root)/import/libboost/. - $(call message,,$(scf_root)/import/libboost/configure $@) - -ifndef %foreign% - -disfigure:: - $(call message,rm $(dcf_root)/import/libboost/configuration-dynamic.make,\ -rm -f $(dcf_root)/import/libboost/configuration-dynamic.make) - -endif diff --git a/build/import/libboost/configure b/build/import/libboost/configure deleted file mode 100755 index 84d03b2..0000000 --- a/build/import/libboost/configure +++ /dev/null @@ -1,72 +0,0 @@ -#! /usr/bin/env bash - -# file : build/import/libboost/configure -# license : GNU GPL v2; see accompanying LICENSE file - - -# $1 - out config file -# -# bld_root - build root -# project_name - project name -# - -source $bld_root/dialog.bash - - -$echo -$echo "Configuring external dependency on 'boost libraries' for '$project_name'." -$echo - -$echo -$echo "Would you like to configure dependency on the installed version" -$echo "of 'boost libraries' as opposed to the development build?" -$echo - -installed=`read_y_n y` - -if [ "$installed" = "n" ]; then - - $echo - $echo "Please enter the 'boost' root directory." - $echo - - root=`read_path --directory --exist` - - $echo - $echo "Please select the library type you would like to use:" - $echo - $echo "(1) archive" - $echo "(2) shared object" - $echo - - type=`read_option "archive shared" "shared"` -fi - -$echo -$echo "Link explicitly to the boost system library? This library" -$echo "is available since boost 1.35.0 and linking to it explicitly" -$echo "may be required by newer linkers." -$echo - -link_system=`read_y_n y` - -$echo -$echo "Please enter optional suffix that may be embedded into the" -$echo "boost library names. For example, if your library names are in" -$echo "the libboost_regex-gcc41-mt-d.so form, then enter -gcc41-mt-d" -$echo "Otherwise leave this field blank." -$echo - -suffix= -read -e -p "[]: " suffix - -echo libboost_installed := $installed >$1 -echo libboost_suffix := $suffix >>$1 -echo libboost_system := $link_system >>$1 - -if [ "$installed" = "n" ]; then - - echo libboost_root := $root >>$1 - echo libboost_type := $type >>$1 - -fi diff --git a/build/import/libboost/date-time/rules.make b/build/import/libboost/date-time/rules.make deleted file mode 100644 index abc8819..0000000 --- a/build/import/libboost/date-time/rules.make +++ /dev/null @@ -1,49 +0,0 @@ -# file : build/import/libboost/date-time/rules.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(dcf_root)/import/libboost/%: root := $(libboost_root) - -$(dcf_root)/import/libboost/date-time/date-time.l: \ - | $(dcf_root)/import/libboost/date-time/. - -ifeq ($(libboost_type),archive) - -ifeq ($(libboost_system),y) -$(dcf_root)/import/libboost/date-time/date-time.l: \ - $(libboost_root)/stage/lib/libboost_date_time$(libboost_suffix).a \ - $(libboost_root)/stage/lib/libboost_system$(libboost_suffix).a -else -$(dcf_root)/import/libboost/date-time/date-time.l: \ - $(libboost_root)/stage/lib/libboost_date_time$(libboost_suffix).a -endif - @echo $^ >$@ - -else - -ifeq ($(libboost_system),y) -$(dcf_root)/import/libboost/date-time/date-time.l: \ - $(libboost_root)/stage/lib/libboost_date_time$(libboost_suffix).so \ - $(libboost_root)/stage/lib/libboost_system$(libboost_suffix).so -else -$(dcf_root)/import/libboost/date-time/date-time.l: \ - $(libboost_root)/stage/lib/libboost_date_time$(libboost_suffix).so -endif - @echo $^ >$@ - @echo rpath:$(root)/stage/lib >>$@ - -endif - - -$(dcf_root)/import/libboost/date-time/date-time.l.cpp-options: \ - | $(dcf_root)/import/libboost/date-time/. - @echo include: -I$(root) >$@ - -ifndef %foreign% - -disfigure:: - $(call message,rm $(dcf_root)/import/libboost/date-time/date-time.l,\ -rm -f $(dcf_root)/import/libboost/date-time/date-time.l) - $(call message,,\ -rm -f $(dcf_root)/import/libboost/date-time/date-time.l.cpp-options) - -endif diff --git a/build/import/libboost/date-time/stub.make b/build/import/libboost/date-time/stub.make deleted file mode 100644 index 6f3aad2..0000000 --- a/build/import/libboost/date-time/stub.make +++ /dev/null @@ -1,34 +0,0 @@ -# file : build/import/libboost/date-time/stub.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(call include-once,$(scf_root)/import/libboost/configuration-rules.make,$(dcf_root)) - -libboost_installed := - -$(call -include,$(dcf_root)/import/libboost/configuration-dynamic.make) - -ifdef libboost_installed - -ifeq ($(libboost_installed),y) - -ifeq ($(libboost_system),y) -$(call export,l: -lboost_date_time$(libboost_suffix) -lboost_system$(libboost_suffix),cpp_options: ) -else -$(call export,l: -lboost_date_time$(libboost_suffix),cpp_options: ) -endif - -else - -$(call include-once,$(scf_root)/import/libboost/date-time/rules.make,$(dcf_root)) - -$(call export,\ - l: $(dcf_root)/import/libboost/date-time/date-time.l,\ - cpp-options: $(dcf_root)/import/libboost/date-time/date-time.l.cpp-options) - -endif - -else - -.NOTPARALLEL: - -endif diff --git a/build/import/libboost/serialization/rules.make b/build/import/libboost/serialization/rules.make deleted file mode 100644 index f69c8bb..0000000 --- a/build/import/libboost/serialization/rules.make +++ /dev/null @@ -1,48 +0,0 @@ -# file : build/import/libboost/serialization/rules.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(dcf_root)/import/libboost/%: root := $(libboost_root) - -$(dcf_root)/import/libboost/serialization/serialization.l: \ - | $(dcf_root)/import/libboost/serialization/. - -ifeq ($(libboost_type),archive) - -ifeq ($(libboost_system),y) -$(dcf_root)/import/libboost/serialization/serialization.l: \ - $(libboost_root)/stage/lib/libboost_serialization$(libboost_suffix).a \ - $(libboost_root)/stage/lib/libboost_system$(libboost_suffix).a -else -$(dcf_root)/import/libboost/serialization/serialization.l: \ - $(libboost_root)/stage/lib/libboost_serialization$(libboost_suffix).a -endif - @echo $^ >$@ - -else - -ifeq ($(libboost_system),y) -$(dcf_root)/import/libboost/serialization/serialization.l: \ - $(libboost_root)/stage/lib/libboost_serialization$(libboost_suffix).so \ - $(libboost_root)/stage/lib/libboost_system$(libboost_suffix).so -else -$(dcf_root)/import/libboost/serialization/serialization.l: \ - $(libboost_root)/stage/lib/libboost_serialization$(libboost_suffix).so -endif - @echo $^ >$@ - @echo rpath:$(root)/stage/lib >>$@ - -endif - - -$(dcf_root)/import/libboost/serialization/serialization.l.cpp-options: \ - | $(dcf_root)/import/libboost/serialization/. - @echo include: -I$(root) >$@ - -ifndef %foreign% - -disfigure:: - $(call message,rm $(dcf_root)/import/libboost/serialization/serialization.l,\ -rm -f $(dcf_root)/import/libboost/serialization/serialization.l) - $(call message,,rm -f $(dcf_root)/import/libboost/serialization/serialization.l.cpp-options) - -endif diff --git a/build/import/libboost/serialization/stub.make b/build/import/libboost/serialization/stub.make deleted file mode 100644 index abb992a..0000000 --- a/build/import/libboost/serialization/stub.make +++ /dev/null @@ -1,34 +0,0 @@ -# file : build/import/libboost/serialization/stub.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(call include-once,$(scf_root)/import/libboost/configuration-rules.make,$(dcf_root)) - -libboost_installed := - -$(call -include,$(dcf_root)/import/libboost/configuration-dynamic.make) - -ifdef libboost_installed - -ifeq ($(libboost_installed),y) - -ifeq ($(libboost_system),y) -$(call export,l: -lboost_serialization$(libboost_suffix) -lboost_system$(libboost_suffix),cpp_options: ) -else -$(call export,l: -lboost_serialization$(libboost_suffix),cpp_options: ) -endif - -else - -$(call include-once,$(scf_root)/import/libboost/serialization/rules.make,$(dcf_root)) - -$(call export,\ - l: $(dcf_root)/import/libboost/serialization/serialization.l,\ - cpp-options: $(dcf_root)/import/libboost/serialization/serialization.l.cpp-options) - -endif - -else - -.NOTPARALLEL: - -endif diff --git a/build/import/libboost/version b/build/import/libboost/version deleted file mode 100644 index faef31a..0000000 --- a/build/import/libboost/version +++ /dev/null @@ -1 +0,0 @@ -0.7.0 diff --git a/build/import/libcutl/configuration-rules.make b/build/import/libcutl/configuration-rules.make deleted file mode 100644 index 4559510..0000000 --- a/build/import/libcutl/configuration-rules.make +++ /dev/null @@ -1,13 +0,0 @@ -# file : build/import/libcutl/configuration-rules.make -# license : MIT; see accompanying LICENSE file - -$(dcf_root)/import/libcutl/configuration-dynamic.make: | $(dcf_root)/import/libcutl/. - $(call message,,$(scf_root)/import/libcutl/configure $@) - -ifndef %foreign% - -$(dcf_root)/.disfigure:: - $(call message,rm $(dcf_root)/import/libcutl/configuration-dynamic.make,\ -rm -f $(dcf_root)/import/libcutl/configuration-dynamic.make) - -endif diff --git a/build/import/libcutl/configure b/build/import/libcutl/configure deleted file mode 100755 index 5c182e2..0000000 --- a/build/import/libcutl/configure +++ /dev/null @@ -1,53 +0,0 @@ -#! /usr/bin/env bash - -# file : build/import/libcutl/configure -# license : MIT; see accompanying LICENSE file - - -# $1 - out file -# -# bld_root - build root -# project_name - project name -# - -source $bld_root/dialog.bash - - -$echo -$echo "Configuring external dependency on 'libcutl' for '$project_name'." -$echo - -$echo -$echo "Would you like to configure dependency on the installed " -$echo "version of 'libcutl' as opposed to the development build?" -$echo - -installed=`read_y_n y` - -path= - -if [ "$installed" = "n" ]; then - -$echo -$echo "Please enter the src_root for 'libcutl'." -$echo - -src_root=`read_path --directory --exist` - -$echo -$echo "Please enter the out_root for 'libcutl'." -$echo - -out_root=`read_path --directory $src_root` - -fi - -echo libcutl_installed := $installed >$1 - -if [ "$installed" = "n" ]; then - -echo src_root := $src_root >>$1 -echo scf_root := \$\(src_root\)/build >>$1 -echo out_root := $out_root >>$1 - -fi diff --git a/build/import/libcutl/stub.make b/build/import/libcutl/stub.make deleted file mode 100644 index 11876f2..0000000 --- a/build/import/libcutl/stub.make +++ /dev/null @@ -1,28 +0,0 @@ -# file : build/import/libcutl/stub.make -# license : MIT; see accompanying LICENSE file - -$(call include-once,$(scf_root)/import/libcutl/configuration-rules.make,$(dcf_root)) - -libcutl_installed := - -$(call -include,$(dcf_root)/import/libcutl/configuration-dynamic.make) - -ifdef libcutl_installed - -ifeq ($(libcutl_installed),y) - -$(call export,l: -lcutl,cpp-options: ) - -else - -# Include export stub. -# -$(call include,$(scf_root)/export/libcutl/stub.make) - -endif - -else - -.NOTPARALLEL: - -endif diff --git a/build/import/libxerces-c/configuration-rules.make b/build/import/libxerces-c/configuration-rules.make deleted file mode 100644 index bda0a59..0000000 --- a/build/import/libxerces-c/configuration-rules.make +++ /dev/null @@ -1,13 +0,0 @@ -# file : build/import/libxerces-c/configuration-rules.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(dcf_root)/import/libxerces-c/configuration-dynamic.make: | $(dcf_root)/import/libxerces-c/. - $(call message,,$(scf_root)/import/libxerces-c/configure $@) - -ifndef %foreign% - -disfigure:: - $(call message,rm $(dcf_root)/import/libxerces-c/configuration-dynamic.make,\ -rm -f $(dcf_root)/import/libxerces-c/configuration-dynamic.make) - -endif diff --git a/build/import/libxerces-c/configure b/build/import/libxerces-c/configure deleted file mode 100755 index 3db09e5..0000000 --- a/build/import/libxerces-c/configure +++ /dev/null @@ -1,71 +0,0 @@ -#! /usr/bin/env bash - -# file : build/import/libxerces-c/configure -# license : GNU GPL v2; see accompanying LICENSE file - - -# $1 - out config file -# -# bld_root - build root -# project_name - project name -# - -source $bld_root/dialog.bash - - -$echo -$echo "Configuring external dependency on 'libxerces-c' for '$project_name'." -$echo - -$echo -$echo "Would you like to configure dependency on the installed version" -$echo "of 'libxerces-c' as opposed to the development build?" -$echo - -installed=`read_y_n y` - -path= -type= - -if [ "$installed" = "n" ]; then - - version= - - while [ -z "$version" ]; do - - $echo - $echo "Please enter the 'libxerces-c' root directory." - $echo - - root=`read_path --directory --exist` - - version=`sed -e 's/^VER=\([^_]*\)_\([^_]*\)_\([^_]*\)[ ]*$/\1.\2.\3/' \ --e t -e d $root/version.incl 2>/dev/null` - - if [ $? != 0 -o -z "$version" ]; then - - version= - echo "Unable to read version information from $root/version.incl" - fi - done - - $echo - $echo "Please select the library type you would like to use:" - $echo - $echo "(1) archive" - $echo "(2) shared object" - $echo - - type=`read_option "archive shared" "shared"` - -fi - -echo libxerces_c_installed := $installed >$1 - -if [ "$installed" = "n" ]; then - - echo libxerces_c_root := $root >>$1 - echo libxerces_c_type := $type >>$1 - echo libxerces_c_version := $version >>$1 - -fi diff --git a/build/import/libxerces-c/rules.make b/build/import/libxerces-c/rules.make deleted file mode 100644 index b094d22..0000000 --- a/build/import/libxerces-c/rules.make +++ /dev/null @@ -1,50 +0,0 @@ -# file : build/import/libxerces-c/rules.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(dcf_root)/import/libxerces-c/%: root := $(libxerces_c_root) - -ifneq ($(filter 3.%,$(libxerces_c_version)),) - -# 3.x.y -# -ifeq ($(libxerces_c_type),archive) - -$(dcf_root)/import/libxerces-c/xerces-c.l: $(libxerces_c_root)/src/.libs/libxerces-c.a - @echo $< >$@ -else - -$(dcf_root)/import/libxerces-c/xerces-c.l: $(libxerces_c_root)/src/.libs/libxerces-c.so - @echo $< >$@ - @echo rpath:$(root)/src/.libs >>$@ -endif - -$(dcf_root)/import/libxerces-c/xerces-c.l.cpp-options: - @echo include: -I$(root)/src >$@ -else - -# 2.x.y -# -ifeq ($(libxerces_c_type),archive) - -$(dcf_root)/import/libxerces-c/xerces-c.l: $(libxerces_c_root)/lib/libxerces-c.a - @echo $< >$@ -else - -$(dcf_root)/import/libxerces-c/xerces-c.l: $(libxerces_c_root)/lib/libxerces-c.so - @echo $< >$@ - @echo rpath:$(root)/lib >>$@ -endif - -$(dcf_root)/import/libxerces-c/xerces-c.l.cpp-options: - @echo include: -I$(root)/include >$@ -endif - - -ifndef %foreign% - -disfigure:: - $(call message,rm $(dcf_root)/import/libxerces-c/xerces-c.l,\ -rm -f $(dcf_root)/import/libxerces-c/xerces-c.l) - $(call message,,rm -f $(dcf_root)/import/libxerces-c/xerces-c.l.cpp-options) - -endif diff --git a/build/import/libxerces-c/stub.make b/build/import/libxerces-c/stub.make deleted file mode 100644 index f5bb440..0000000 --- a/build/import/libxerces-c/stub.make +++ /dev/null @@ -1,30 +0,0 @@ -# file : build/import/libxerces-c/stub.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(call include-once,$(scf_root)/import/libxerces-c/configuration-rules.make,$(dcf_root)) - -libxerces_c_installed := - -$(call -include,$(dcf_root)/import/libxerces-c/configuration-dynamic.make) - -ifdef libxerces_c_installed - -ifeq ($(libxerces_c_installed),y) - -$(call export,l: -lxerces-c,cpp-options: ) - -else - -$(call include-once,$(scf_root)/import/libxerces-c/rules.make,$(dcf_root)) - -$(call export,\ - l: $(dcf_root)/import/libxerces-c/xerces-c.l,\ - cpp-options: $(dcf_root)/import/libxerces-c/xerces-c.l.cpp-options) - -endif - -else - -.NOTPARALLEL: - -endif diff --git a/build/import/libxerces-c/version b/build/import/libxerces-c/version deleted file mode 100644 index a918a2a..0000000 --- a/build/import/libxerces-c/version +++ /dev/null @@ -1 +0,0 @@ -0.6.0 diff --git a/build/import/libxqilla/configuration-rules.make b/build/import/libxqilla/configuration-rules.make deleted file mode 100644 index c0e636e..0000000 --- a/build/import/libxqilla/configuration-rules.make +++ /dev/null @@ -1,13 +0,0 @@ -# file : build/import/libxqilla/configuration-rules.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(dcf_root)/import/libxqilla/configuration-dynamic.make: | $(dcf_root)/import/libxqilla/. - $(call message,,$(scf_root)/import/libxqilla/configure $@) - -ifndef %foreign% - -disfigure:: - $(call message,rm $(dcf_root)/import/libxqilla/configuration-dynamic.make,\ -rm -f $(dcf_root)/import/libxqilla/configuration-dynamic.make) - -endif diff --git a/build/import/libxqilla/configure b/build/import/libxqilla/configure deleted file mode 100755 index 5d21907..0000000 --- a/build/import/libxqilla/configure +++ /dev/null @@ -1,55 +0,0 @@ -#! /usr/bin/env bash - -# file : build/import/libxqilla/configure -# license : GNU GPL v2; see accompanying LICENSE file - - -# $1 - out config file -# -# bld_root - build root -# project_name - project name -# - -source $bld_root/dialog.bash - - -$echo -$echo "Configuring external dependency on 'libxqilla' for '$project_name'." -$echo - -$echo -$echo "Would you like to configure dependency on the installed version" -$echo "of 'libxqilla' as opposed to the development build?" -$echo - -installed=`read_y_n y` - -path= -type= - -if [ "$installed" = "n" ]; then - - $echo - $echo "Please enter the 'libxqilla' root directory." - $echo - - root=`read_path --directory --exist` - - $echo - $echo "Please select the library type you would like to use:" - $echo - $echo "(1) archive" - $echo "(2) shared object" - $echo - - type=`read_option "archive shared" "shared"` -fi - -echo libxqilla_installed := $installed >$1 - -if [ "$installed" = "n" ]; then - - echo libxqilla_root := $root >>$1 - echo libxqilla_type := $type >>$1 - -fi diff --git a/build/import/libxqilla/rules.make b/build/import/libxqilla/rules.make deleted file mode 100644 index d8a2c7a..0000000 --- a/build/import/libxqilla/rules.make +++ /dev/null @@ -1,28 +0,0 @@ -# file : build/import/libxqilla/rules.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(dcf_root)/import/libxqilla/%: root := $(libxqilla_root) - -ifeq ($(libxqilla_type),archive) - -$(dcf_root)/import/libxqilla/xqilla.l: $(libxqilla_root)/.libs/libxqilla.a - @echo $< >$@ -else - -$(dcf_root)/import/libxqilla/xqilla.l: $(libxqilla_root)/.libs/libxqilla.so - @echo $< >$@ - @echo rpath:$(root)/.libs >>$@ -endif - -$(dcf_root)/import/libxqilla/xqilla.l.cpp-options: - @echo include: -I$(root)/include >$@ - - -ifndef %foreign% - -disfigure:: - $(call message,rm $(dcf_root)/import/libxqilla/xqilla.l,\ -rm -f $(dcf_root)/import/libxqilla/xqilla.l) - $(call message,,rm -f $(dcf_root)/import/libxqilla/xqilla.l.cpp-options) - -endif diff --git a/build/import/libxqilla/stub.make b/build/import/libxqilla/stub.make deleted file mode 100644 index caccf97..0000000 --- a/build/import/libxqilla/stub.make +++ /dev/null @@ -1,30 +0,0 @@ -# file : build/import/libxqilla/stub.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(call include-once,$(scf_root)/import/libxqilla/configuration-rules.make,$(dcf_root)) - -libxqilla_installed := - -$(call -include,$(dcf_root)/import/libxqilla/configuration-dynamic.make) - -ifdef libxqilla_installed - -ifeq ($(libxqilla_installed),y) - -$(call export,l: -lxqilla,cpp-options: ) - -else - -$(call include-once,$(scf_root)/import/libxqilla/rules.make,$(dcf_root)) - -$(call export,\ - l: $(dcf_root)/import/libxqilla/xqilla.l,\ - cpp-options: $(dcf_root)/import/libxqilla/xqilla.l.cpp-options) - -endif - -else - -.NOTPARALLEL: - -endif diff --git a/build/import/libxqilla/version b/build/import/libxqilla/version deleted file mode 100644 index 6e8bf73..0000000 --- a/build/import/libxqilla/version +++ /dev/null @@ -1 +0,0 @@ -0.1.0 diff --git a/build/import/libxsd-frontend/configuration-rules.make b/build/import/libxsd-frontend/configuration-rules.make deleted file mode 100644 index b0b16e5..0000000 --- a/build/import/libxsd-frontend/configuration-rules.make +++ /dev/null @@ -1,13 +0,0 @@ -# file : build/import/libxsd-frontend/configuration-rules.make -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -$(dcf_root)/import/libxsd-frontend/configuration-dynamic.make: | $(dcf_root)/import/libxsd-frontend/. - $(call message,,$(scf_root)/import/libxsd-frontend/configure $@) - -ifndef %foreign% - -disfigure:: - $(call message,rm $(dcf_root)/import/libxsd-frontend/configuration-dynamic.make,\ -rm -f $(dcf_root)/import/libxsd-frontend/configuration-dynamic.make) - -endif diff --git a/build/import/libxsd-frontend/configure b/build/import/libxsd-frontend/configure deleted file mode 100755 index 1908830..0000000 --- a/build/import/libxsd-frontend/configure +++ /dev/null @@ -1,53 +0,0 @@ -#! /usr/bin/env bash - -# file : build/import/libxsd-frontend/configure -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - - -# $1 - out file -# -# bld_root - build root -# project_name - project name -# - -source $bld_root/dialog.bash - - -$echo -$echo "Configuring external dependency on 'libxsd-frontend' for '$project_name'." -$echo - -$echo -$echo "Would you like to configure dependency on the installed " -$echo "version of 'libxsd-frontend' as opposed to the development build?" -$echo - -installed=`read_y_n y` - -path= - -if [ "$installed" = "n" ]; then - -$echo -$echo "Please enter the src_root for 'libxsd-frontend'." -$echo - -src_root=`read_path --directory --exist` - -$echo -$echo "Please enter the out_root for 'libxsd-frontend'." -$echo - -out_root=`read_path --directory $src_root` - -fi - -echo libxsd_frontend_installed := $installed >$1 - -if [ "$installed" = "n" ]; then - -echo src_root := $src_root >>$1 -echo scf_root := \$\(src_root\)/build >>$1 -echo out_root := $out_root >>$1 - -fi diff --git a/build/import/libxsd-frontend/stub.make b/build/import/libxsd-frontend/stub.make deleted file mode 100644 index 9bf00e5..0000000 --- a/build/import/libxsd-frontend/stub.make +++ /dev/null @@ -1,28 +0,0 @@ -# file : build/import/libxsd-frontend/stub.make -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -$(call include-once,$(scf_root)/import/libxsd-frontend/configuration-rules.make,$(dcf_root)) - -libxsd_frontend_installed := - -$(call -include,$(dcf_root)/import/libxsd-frontend/configuration-dynamic.make) - -ifdef libxsd_frontend_installed - -ifeq ($(libxsd_frontend_installed),y) - -$(call export,l: -lxsd-frontend -lcutl -lxerces-c,cpp_options: ) - -else - -# Include export stub. -# -$(call include,$(scf_root)/export/libxsd-frontend/stub.make) - -endif - -else - -.NOTPARALLEL: - -endif diff --git a/build/import/libz/configuration-rules.make b/build/import/libz/configuration-rules.make deleted file mode 100644 index deabba0..0000000 --- a/build/import/libz/configuration-rules.make +++ /dev/null @@ -1,13 +0,0 @@ -# file : build/import/libz/configuration-rules.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(dcf_root)/import/libz/configuration-dynamic.make: | $(dcf_root)/import/libz/. - $(call message,,$(scf_root)/import/libz/configure $@) - -ifndef %foreign% - -disfigure:: - $(call message,rm $(dcf_root)/import/libz/configuration-dynamic.make,\ -rm -f $(dcf_root)/import/libz/configuration-dynamic.make) - -endif diff --git a/build/import/libz/configure b/build/import/libz/configure deleted file mode 100755 index a36fca3..0000000 --- a/build/import/libz/configure +++ /dev/null @@ -1,56 +0,0 @@ -#! /usr/bin/env bash - -# file : build/import/libz/configure -# license : GNU GPL v2; see accompanying LICENSE file - - -# $1 - out config file -# -# bld_root - build root -# project_name - project name -# - -source $bld_root/dialog.bash - - -$echo -$echo "Configuring external dependency on 'zlib' for '$project_name'." -$echo - -$echo -$echo "Would you like to configure dependency on the installed version" -$echo "of 'zlib' as opposed to the development build?" -$echo - -installed=`read_y_n y` - -path= -type= - -if [ "$installed" = "n" ]; then - - $echo - $echo "Please enter the 'zlib' root directory." - $echo - - root=`read_path --directory --exist` - - $echo - $echo "Please select the library type you would like to use:" - $echo - $echo "(1) archive" - $echo "(2) shared object" - $echo - - type=`read_option "archive shared" "shared"` - -fi - -echo libz_installed := $installed >$1 - -if [ "$installed" = "n" ]; then - - echo libz_root := $root >>$1 - echo libz_type := $type >>$1 - -fi diff --git a/build/import/libz/rules.make b/build/import/libz/rules.make deleted file mode 100644 index 5720a5e..0000000 --- a/build/import/libz/rules.make +++ /dev/null @@ -1,27 +0,0 @@ -# file : build/import/libz/rules.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(dcf_root)/import/libz/%: root := $(libz_root) - -ifeq ($(libz_type),archive) - -$(dcf_root)/import/libz/z.l: $(libz_root)/libz.a - @echo $< >$@ -else - -$(dcf_root)/import/libz/z.l: $(libz_root)/libz.so - @echo $< >$@ - @echo rpath:$(root) >>$@ -endif - -$(dcf_root)/import/libz/z.l.cpp-options: - @echo include: -I$(root) >$@ - -ifndef %foreign% - -disfigure:: - $(call message,rm $(dcf_root)/import/libz/z.l,\ -rm -f $(dcf_root)/import/libz/z.l) - $(call message,,rm -f $(dcf_root)/import/libz/z.l.cpp-options) - -endif diff --git a/build/import/libz/stub.make b/build/import/libz/stub.make deleted file mode 100644 index a50f288..0000000 --- a/build/import/libz/stub.make +++ /dev/null @@ -1,30 +0,0 @@ -# file : build/import/libz/stub.make -# license : GNU GPL v2; see accompanying LICENSE file - -$(call include-once,$(scf_root)/import/libz/configuration-rules.make,$(dcf_root)) - -libz_installed := - -$(call -include,$(dcf_root)/import/libz/configuration-dynamic.make) - -ifdef libz_installed - -ifeq ($(libz_installed),y) - -$(call export,l: -lz,cpp-options: ) - -else - -$(call include-once,$(scf_root)/import/libz/rules.make,$(dcf_root)) - -$(call export,\ - l: $(dcf_root)/import/libz/z.l,\ - cpp-options: $(dcf_root)/import/libz/z.l.cpp-options) - -endif - -else - -.NOTPARALLEL: - -endif diff --git a/build/import/libz/version b/build/import/libz/version deleted file mode 100644 index 6e8bf73..0000000 --- a/build/import/libz/version +++ /dev/null @@ -1 +0,0 @@ -0.1.0 diff --git a/build/xsd/parser/xsd-cxx.make b/build/xsd/parser/xsd-cxx.make deleted file mode 100644 index 62a4826..0000000 --- a/build/xsd/parser/xsd-cxx.make +++ /dev/null @@ -1,75 +0,0 @@ -# file : build/xsd/parser/xsd-cxx.make -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#@@ Need to use extensions from cxx config. -# - -# C++/Parser mapping. -# -ifeq ($(xsd_parser_skel_suffix),) -xsd_parser_skel_suffix := -pskel -endif - -xsd_parser_pattern := \ -$(out_base)/%$(xsd_parser_skel_suffix).cxx \ -$(out_base)/%$(xsd_parser_skel_suffix).hxx \ -$(out_base)/%$(xsd_parser_skel_suffix).ixx - -ifneq ($(xsd_parser_impl_suffix),) -xsd_parser_pattern += \ -$(out_base)/%$(xsd_parser_impl_suffix).cxx \ -$(out_base)/%$(xsd_parser_impl_suffix).hxx \ -$(out_base)/%-driver.cxx -endif - - -$(xsd_parser_pattern): xsd := xsd -$(xsd_parser_pattern): xsd_command := cxx-parser - -ops := --generate-inline --skel-file-suffix $(xsd_parser_skel_suffix) - -ifneq ($(xsd_pimpl_suffix),) -ops += --impl-file-suffix $(xsd_parser_impl_suffix) -endif - -$(xsd_parser_pattern): xsd_options := $(ops) - - -.PRECIOUS: $(xsd_parser_pattern) - -ifeq ($(out_base),$(src_base)) - -$(xsd_parser_pattern): $(src_base)/%.xsd - $(call message,xsd $<,$(xsd) $(xsd_command) $(xsd_options) --output-dir $(dir $@) $<) - -else - -$(xsd_parser_pattern): $(src_base)/%.xsd | $$(dir $$@). - $(call message,xsd $<,$(xsd) $(xsd_command) $(xsd_options) --output-dir $(dir $@) $<) - -$(xsd_parser_pattern): $(out_base)/%.xsd | $$(dir $$@). - $(call message,xsd $<,$(xsd) $(xsd_command) $(xsd_options) --output-dir $(dir $@) $<) - -endif - - -.PHONY: $(out_base)/%$(xsd_parser_skel_suffix).cxx.xsd.clean - -$(out_base)/%$(xsd_parser_skel_suffix).cxx.xsd.clean: - $(call message,rm $$1,rm -f $$1,$(@:.cxx.xsd.clean=.cxx)) - $(call message,rm $$1,rm -f $$1,$(@:.cxx.xsd.clean=.hxx)) - $(call message,rm $$1,rm -f $$1,$(@:.cxx.xsd.clean=.ixx)) - -ifneq ($(xsd_parser_impl_suffix),) -.PHONY: $(out_base)/%$(xsd_parser_impl_suffix).cxx.xsd.clean - -$(out_base)/%$(xsd_parser_impl_suffix).cxx.xsd.clean: - $(call message,rm $$1,rm -f $$1,$(@:.cxx.xsd.clean=.cxx)) - $(call message,rm $$1,rm -f $$1,$(@:.cxx.xsd.clean=.hxx)) - $(call message,rm $$1,rm -f $$1,$(out_base)/$*-driver.cxx) -endif - -# Reset the config variables so they won't take effect in other places. -# -xsd_parser_skel_suffix := -xsd_parser_impl_suffix := diff --git a/build/xsd/tree/xsd-cxx.make b/build/xsd/tree/xsd-cxx.make deleted file mode 100644 index 3ca45d1..0000000 --- a/build/xsd/tree/xsd-cxx.make +++ /dev/null @@ -1,46 +0,0 @@ -# file : build/xsd/tree/xsd-cxx.make -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#@@ Need to use extensions from cxx config. -# - -# C++/Tree mapping. -# -xsd_tree_pattern := \ -$(out_base)/%$(xsd_tree_suffix).cxx \ -$(out_base)/%$(xsd_tree_suffix).hxx \ -$(out_base)/%$(xsd_tree_suffix).ixx \ -$(out_base)/%$(xsd_tree_suffix)-fwd.hxx - -$(xsd_tree_pattern): xsd := xsd -$(xsd_tree_pattern): xsd_command := cxx-tree -$(xsd_tree_pattern): xsd_options := --generate-inline - -.PRECIOUS: $(xsd_tree_pattern) - -ifeq ($(out_base),$(src_base)) - -$(xsd_tree_pattern): $(src_base)/%.xsd - $(call message,xsd $<,$(xsd) $(xsd_command) $(xsd_options) --output-dir $(dir $@) $<) - -else - -$(xsd_tree_pattern): $(src_base)/%.xsd | $$(dir $$@). - $(call message,xsd $<,$(xsd) $(xsd_command) $(xsd_options) --output-dir $(dir $@) $<) - -$(xsd_tree_pattern): $(out_base)/%.xsd | $$(dir $$@). - $(call message,xsd $<,$(xsd) $(xsd_command) $(xsd_options) --output-dir $(dir $@) $<) - -endif - -.PHONY: $(out_base)/%$(xsd_tree_suffix).cxx.xsd.clean - -$(out_base)/%$(xsd_tree_suffix).cxx.xsd.clean: - $(call message,rm $(@:.cxx.xsd.clean=.cxx),rm -f $(@:.cxx.xsd.clean=.cxx)) - $(call message,rm $(@:.cxx.xsd.clean=.hxx),rm -f $(@:.cxx.xsd.clean=.hxx)) - $(call message,rm $(@:.cxx.xsd.clean=.ixx),rm -f $(@:.cxx.xsd.clean=.ixx)) - $(call message,rm $(@:.cxx.xsd.clean=-fwd.hxx),rm -f $(@:.cxx.xsd.clean=-fwd.hxx)) - -# Reset the config variables so they won't take effect in other places. -# -xsd_tree_suffix := diff --git a/buildfile b/buildfile new file mode 100644 index 0000000..856a678 --- /dev/null +++ b/buildfile @@ -0,0 +1,7 @@ +# file : buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Glue buildfile that "pulls" all the packages. + +import pkgs = */ +./: $pkgs diff --git a/dist/README-UNIX b/dist/README-UNIX deleted file mode 100644 index 9632744..0000000 --- a/dist/README-UNIX +++ /dev/null @@ -1,82 +0,0 @@ -This package contains precompiled binaries of CodeSynthesis XSD, a -W3C XML Schema to C++ Data Binding compiler. For more information -about XSD visit - -https://www.codesynthesis.com/products/xsd/ - -This README file describes how to start using XSD in UNIX or -UNIX-like (for example, Cygwin/Mingw) environments. - - -Prerequisites -------------- - -The XSD runtime library and the generated code depend on the underlying -XML parser which can be Xerces-C++ for the C++/Tree mapping and Xerces-C++ -or Expat for the C++/Parser mapping. - -Xerces-C++ can be obtained from http://xerces.apache.org/xerces-c/. Most -GNU/Linux distributions provide precompiled binary packages for Xerces-C++. -You can also download precompiled Xerces-C++ libraries for a wide range of -platforms and compilers from http://xerces.apache.org/xerces-c/download.cgi - -Expat can be obtained from http://www.libexpat.org/. Most GNU/Linux -distributions provide precompiled binary packages for Expat. - - -Building Examples ------------------ - -To build examples you will need GNU make. All examples in the examples/ -directory come with simple makefiles. For instance, to build a hello -example in examples/cxx/tree you could execute the following commands: - -$ cd examples/cxx/tree/hello -$ make - -The following make variables affect the compilation process and can -be overridden from the command line: - -CXX - C++ compiler, by default 'g++' -CXXFLAGS - C++ options -CPPFLAGS - C/C++ Preprocessor options - -LIBS - Libraries to link with, by default '-lxerces-c' for the - C++/Tree examples and either '-lxerces-c' or '-lexpat' for - the C++/Parser examples, depending on XML_PARSER -LDFLAGS - Linker options - -XSD - XSD compiler, by default path to the XSD binary -XSDFLAGS - XSD options - -WITH_ZLIB - Set this variable to 1 if you would like to build examples - that depend on the zlib library - -WITH_ACE - Set this variable to 1 if you would like to build examples - that depend on the ACE library - -WITH_XDR - Set this variable to 1 if you would like to build examples - that depend on the XDR API (available out of the box on - most GNU/Linux and UNIX systems) - -WITH_BOOST - Set this variable to 1 if you would like to build examples - that depend on the Boost date_time and serialization - libraries - -WITH_XQILLA - Set this variable to 1 if you would like to build examples - that depend on the XQilla library (XPath 2) - -Additionally, makefiles for the C++/Parser examples (examples/cxx/parser/) -allow you to choose the underlying XML parser: - -XML_PARSER - Underlying XML parser, can be 'xerces' (default) or 'expat' - - -For instance, if you would like to build an example using g++-4.0 instead -of the default g++ and would like to use Xerces-C++ from ~/xerces-c instead -of the default, system-wide installation, you could execute the following -command: - -$ make CXX=g++-4.0 \ - CPPFLAGS="-I ~/xerces-c/include" \ - LDFLAGS="-L ~/xerces-c/lib" diff --git a/dist/README-WINDOWS b/dist/README-WINDOWS deleted file mode 100644 index da44e79..0000000 --- a/dist/README-WINDOWS +++ /dev/null @@ -1,192 +0,0 @@ -This package contains precompiled binaries of CodeSynthesis XSD, a -W3C XML Schema to C++ Data Binding compiler, built for Microsoft -Windows. For more information about XSD visit - -https://www.codesynthesis.com/products/xsd/ - -This README file describes how to start using XSD in the Microsoft -Windows environment with Visual Studio 2005 (8.0), Visual Studio 2008 -(9.0), and Visual Studio 2010 (10.0), Visual Studio 2012 (11.0), and -Visual Studio 2013 (12.0). - - -Prerequisites -------------- - -The XSD runtime library and the generated code depend on the Xerces-C++ -XML parser which you can obtain from http://xerces.apache.org/xerces-c/. -You can also download precompiled Xerces-C++ libraries for Windows from: - -http://xerces.apache.org/xerces-c/download.cgi - -Note that the above download page may not contain Xerces-C++ libraries -for the latest Visual Studio releases. The Windows Installer package -(.msi) for XSD contains Xerces-C++ libraries for all of the above- -mentioned Visual Studio versions. - - -Environment ------------ - -Before you can start building examples or your applications that use XSD -you need to set include, library and executable search paths in the Visual -Studio IDE and the System Environment. - -1. Setting up Xerces-C++ - - First you need to set up Xerces-C++ include and library search paths. - If you already have Xerces-C++ set up in your development environment, - you can skip to the next step. Here we assume that your Xerces-C++ path - is C:\projects\xerces-c-x.y.z. If you have Xerces-C++ in a different - place, you will need to adjust the paths below accordingly. - - - a) For Visual Studio 2005 (8.0) and Visual Studio 2008 (9.0): - - In the Visual Studio IDE, select "Tools"/"Options"/"Projects and - Solution"/"VC++ Directories". - - Then, in the "Show directories for" field, select "Include files" and - create a new entry with the value "C:\projects\xerces-c-x.y.z\include". - - After that, in the "Show directories for" field, select "Library files" - and create a new entry with the value "C:\projects\xerces-c-x.y.z\lib". - - After that, in the "Show directories for" field, select "Executable files" - and create a new entry with the value "C:\projects\xerces-c-x.y.z\bin". - - If you are building the 64-bit version of your application, repeat the - above steps for the 64-bit version of Xerces-C++ while selecting x64 - in the "Platform" drop-down list in the VC++ Directories dialog (Visual - Studio keeps a separate set of paths for each platform). - - For Visual Studio 2010-2013 (10.0-12.0): - - 1. Open an existing or create a new C++ project (you can open one of - the example solutions that come with XSD). - - 2. Open the Property Manager view by selecting "View"->"Property - Manager" (or "View"->"Other Windows"->"Property Manager") menu - action. - - 3. Expand the property hierarchy for the project and find the - Microsoft.Cpp.Win32.user property sheet. - - 4. Right click on Microsoft.Cpp.Win32.user and select the "Properties" - menu action. - - 5. Select the VC++ Directories tab. - - 6. Add the "C:\projects\xerces-c-x.y.z\include" path to the "Include - Directories" field (the paths are separated by a semicolon). - - 7. Add the "C:\projects\xerces-c-x.y.z\lib" path to the "Library - Directories" field. - - 8. Add the "C:\projects\xerces-c-x.y.z\bin" path to the "Executable - Directories" field. - - 9. Click Ok to close the dialog and then click the Save button at the - top of the Property Manager view to save Microsoft.Cpp.Win32.user. - - If you are building the 64-bit version of your application, repeat - the above steps for the 64-bit version of Xerces-C++ but using the - Microsoft.Cpp.x64.user property sheet (Visual Studio keeps a separate - set of paths for each platform). - - - b) In the Control Panel, choose "System" and select the "Advanced" tab. - Click on the "Environment Variables" button. In the "System Variables" - list, select "Path" and add (via "Edit" button) the - ";C:\projects\xerces-c-x.y.z\bin" path at the end. - - -2. Setting up XSD - - Now you need to set up XSD executable and include search paths. Here we - assume that your XSD path is C:\projects\xsd-x.y.z. If you have XSD in - a different place, you will need to adjust the paths below accordingly. - - For Visual Studio 2005 (8.0) and Visual Studio 2008 (9.0): - - In the Visual Studio IDE, select "Tools"/"Options"/"Projects and - Solution"/"VC++ Directories". - - Then, in the "Show directories for" field, select "Include files" and - create a new entry with the value "C:\projects\xsd-x.y.z\libxsd". - - After that, in the "Show directories for" field, select "Executable - files" and create a new entry with the value "C:\projects\xsd-x.y.z\bin". - Make sure it is the first line in the list of directories (use the - "Up" button to move the new entry up, if necessary). - - If you are building the 64-bit version of your application, repeat the - above steps using the same paths while selecting x64 in the "Platform" - drop-down list in the VC++ Directories dialog (Visual Studio keeps a - separate set of paths for each platform). - - For Visual Studio 2010 (10.0): - - 1. Open an existing or create a new C++ project (you can open one of - the example solutions that come with XSD). - - 2. Open the Property Manager view by selecting "View"->"Property - Manager" (or "View"->"Other Windows"->"Property Manager") menu - action. - - 3. Expand the property hierarchy for the project and find the - Microsoft.Cpp.Win32.user property sheet. - - 4. Right click on Microsoft.Cpp.Win32.user and select the "Properties" - menu action. - - 5. Select the VC++ Directories tab. - - 6. Add the "C:\projects\xsd-x.y.z\libxsd" path to the "Include - Directories" field (the paths are separated by a semicolon). - - 7. Add the "C:\projects\xsd-x.y.z\bin" path to the "Executable - Directories" field and make sure it is the first path in the - the list of directories. - - 8. Click Ok to close the dialog and then click the Save button at the - top of the Property Manager view to save Microsoft.Cpp.Win32.user. - - If you are building the 64-bit version of your application, repeat the - above steps using the same paths but using the Microsoft.Cpp.x64.user - property sheet (Visual Studio keeps a separate set of paths for each - platform). - - -3. Restart the Visual Studio IDE. - - -Building Examples ------------------ - -Now you are ready to build examples. Simply open the solution file -found in the examples\cxx\tree (C++/Tree mapping examples) or -examples\cxx\parser (C++/Parser examples) directories. - -Some of the examples depend on additional third-party libraries or -show a specific feature of XSD and are not included in the solutions -above. They come with their individual solution files: - -examples/cxx/tree/embedded - example of schema embedding -examples/cxx/tree/custom - examples of type customization -examples/cxx/tree/custom/calendar - depends on the Boost date_time library -examples/cxx/tree/compression - depends on the zlib library -examples/cxx/tree/binary/boost - depends on the Boost serialization library -examples/cxx/tree/binary/cdr - depends on the ACE library -examples/cxx/tree/binary/xdr - requires a third-party XDR library -examples/cxx/tree/xpath - depends on the XQilla library (XPath 2) - - -Using XSD in Your Projects --------------------------- - -For various ways to integrate the XSD compiler with the Visual Studio IDE -as well as other Visual Studio-specific topics, refer to the Using XSD with -Microsoft Visual Studio Wiki page: - -http://wiki.codesynthesis.com/Using_XSD_with_Microsoft_Visual_Studio diff --git a/dist/etc/vc-1x.0/xsd-cxx-parser.props b/dist/etc/vc-1x.0/xsd-cxx-parser.props deleted file mode 100644 index b167a38..0000000 --- a/dist/etc/vc-1x.0/xsd-cxx-parser.props +++ /dev/null @@ -1,33 +0,0 @@ - - - - Midl - CustomBuild - - - _SelectedFiles;$(CXX_Parser_Mapping_RuleDependsOn) - - - - False - False - False - False - False - . - .hxx - .cxx - .ixx - -pskel - _pskel - 0 - 0 - 0 - xsd.exe cxx-parser [AllOptions] [AdditionalOptions] [Inputs] - xsd cxx-parser %(Identity) - false - - - diff --git a/dist/etc/vc-1x.0/xsd-cxx-parser.targets b/dist/etc/vc-1x.0/xsd-cxx-parser.targets deleted file mode 100644 index 62ad2b2..0000000 --- a/dist/etc/vc-1x.0/xsd-cxx-parser.targets +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - XsdCompile - - - - $(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml - - - - - - - - @(CXX_Parser_Mapping_Rule, '|') - - - - - - - - - @(CXX_Parser_Mapping_Rule->Metadata('OutDir')->Distinct())\@(CXX_Parser_Mapping_Rule->Metadata('Filename')->Distinct())@(CXX_Parser_Mapping_Rule->Metadata('SkelFileSuffix')->Distinct())@(CXX_Parser_Mapping_Rule->Metadata('HeaderSuffix')->Distinct());@(CXX_Parser_Mapping_Rule->Metadata('OutDir')->Distinct())\@(CXX_Parser_Mapping_Rule->Metadata('Filename')->Distinct())@(CXX_Parser_Mapping_Rule->Metadata('SkelFileSuffix')->Distinct())@(CXX_Parser_Mapping_Rule->Metadata('SourceSuffix')->Distinct());@(CXX_Parser_Mapping_Rule->Metadata('OutDir')->Distinct())\@(CXX_Parser_Mapping_Rule->Metadata('Filename')->Distinct())@(CXX_Parser_Mapping_Rule->Metadata('SkelFileSuffix')->Distinct())@(CXX_Parser_Mapping_Rule->Metadata('InlineSuffix')->Distinct()); - - - - %(CoreCppClean.FilePatternsToDelete);$(XsdCleanFilePatternsToDelete) - $(XsdCleanFilePatternsToDelete) - - - - - - - diff --git a/dist/etc/vc-1x.0/xsd-cxx-parser.xml b/dist/etc/vc-1x.0/xsd-cxx-parser.xml deleted file mode 100644 index 37202c6..0000000 --- a/dist/etc/vc-1x.0/xsd-cxx-parser.xml +++ /dev/null @@ -1,284 +0,0 @@ - - - - - - - - - - General - - - - - Command Line - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Execute Before - - - Specifies the targets for the build customization to run before. - - - - - - - - - - - Execute After - - - Specifies the targets for the build customization to run after. - - - - - - - - - - - - - Additional Options - - - Additional Options - - - - - - - diff --git a/dist/etc/vc-1x.0/xsd-cxx-tree.props b/dist/etc/vc-1x.0/xsd-cxx-tree.props deleted file mode 100644 index fc81c9b..0000000 --- a/dist/etc/vc-1x.0/xsd-cxx-tree.props +++ /dev/null @@ -1,47 +0,0 @@ - - - - Midl - CustomBuild - - - _SelectedFiles;$(CXX_Tree_Mapping_RuleDependsOn) - - - - False - 0 - False - False - False - False - False - False - False - False - False - False - False - False - False - False - False - False - False - . - .hxx - .cxx - .ixx - -fwd.hxx - 0 - 0 - 0 - 0 - xsd.exe cxx-tree [AllOptions] [AdditionalOptions] [Inputs] - xsd cxx-tree %(Identity) - false - - - diff --git a/dist/etc/vc-1x.0/xsd-cxx-tree.targets b/dist/etc/vc-1x.0/xsd-cxx-tree.targets deleted file mode 100644 index 6156ec2..0000000 --- a/dist/etc/vc-1x.0/xsd-cxx-tree.targets +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - XsdCompile - - - - $(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml - - - - - - - - @(CXX_Tree_Mapping_Rule, '|') - - - - - - - - - @(CXX_Tree_Mapping_Rule->Metadata('OutDir')->Distinct())\@(CXX_Tree_Mapping_Rule->Metadata('Filename')->Distinct())@(CXX_Tree_Mapping_Rule->Metadata('HeaderSuffix')->Distinct());@(CXX_Tree_Mapping_Rule->Metadata('OutDir')->Distinct())\@(CXX_Tree_Mapping_Rule->Metadata('Filename')->Distinct())@(CXX_Tree_Mapping_Rule->Metadata('SourceSuffix')->Distinct());@(CXX_Tree_Mapping_Rule->Metadata('OutDir')->Distinct())\@(CXX_Tree_Mapping_Rule->Metadata('Filename')->Distinct())@(CXX_Tree_Mapping_Rule->Metadata('InlineSuffix')->Distinct());@(CXX_Tree_Mapping_Rule->Metadata('OutDir')->Distinct())\@(CXX_Tree_Mapping_Rule->Metadata('Filename')->Distinct())@(CXX_Tree_Mapping_Rule->Metadata('ForwardSuffix')->Distinct()) - - - - %(CoreCppClean.FilePatternsToDelete);$(XsdCleanFilePatternsToDelete) - $(XsdCleanFilePatternsToDelete) - - - - - - - diff --git a/dist/etc/vc-1x.0/xsd-cxx-tree.xml b/dist/etc/vc-1x.0/xsd-cxx-tree.xml deleted file mode 100644 index e37eb1c..0000000 --- a/dist/etc/vc-1x.0/xsd-cxx-tree.xml +++ /dev/null @@ -1,411 +0,0 @@ - - - - - - - - - - General - - - - - Command Line - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Execute Before - - - Specifies the targets for the build customization to run before. - - - - - - - - - - - Execute After - - - Specifies the targets for the build customization to run after. - - - - - - - - - - - - - Additional Options - - - Additional Options - - - - - - - diff --git a/dist/etc/vc-8.0/xsd-cxx-parser.rules b/dist/etc/vc-8.0/xsd-cxx-parser.rules deleted file mode 100644 index a94a3ea..0000000 --- a/dist/etc/vc-8.0/xsd-cxx-parser.rules +++ /dev/null @@ -1,206 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/etc/vc-8.0/xsd-cxx-tree.rules b/dist/etc/vc-8.0/xsd-cxx-tree.rules deleted file mode 100644 index b3e921a..0000000 --- a/dist/etc/vc-8.0/xsd-cxx-tree.rules +++ /dev/null @@ -1,320 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/etc/vc-9.0/xsd-cxx-parser.rules b/dist/etc/vc-9.0/xsd-cxx-parser.rules deleted file mode 100644 index a94a3ea..0000000 --- a/dist/etc/vc-9.0/xsd-cxx-parser.rules +++ /dev/null @@ -1,206 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/etc/vc-9.0/xsd-cxx-tree.rules b/dist/etc/vc-9.0/xsd-cxx-tree.rules deleted file mode 100644 index d82d618..0000000 --- a/dist/etc/vc-9.0/xsd-cxx-tree.rules +++ /dev/null @@ -1,319 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/build/cxx/compilers.make b/dist/examples/build/cxx/compilers.make deleted file mode 100644 index a3a97be..0000000 --- a/dist/examples/build/cxx/compilers.make +++ /dev/null @@ -1,117 +0,0 @@ -# file : examples/build/cxx/compilers.make -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -CXX := g++ - -cxx_sign := $(shell t=`$(CXX) -V 2>&1`; if test $$? -eq 0; then echo $$t; fi) - -ifeq ($(cxx_sign),) -cxx_sign := $(shell t=`$(CXX) --version 2>&1`; if test $$? -eq 0; then echo $$t; fi) -endif - -# IBM XL C++ V7.0 returns error code when called with the -qversion option. This -# complicates our life quite a bit. -# -ifeq ($(cxx_sign),) -cxx_sign := $(shell t=`$(CXX) -qversion 2>/dev/null`; echo $$t) -ifneq ($(shell echo '$(cxx_sign)' | sed -e 's/^.*IBM XL C\/C.. .*$$//'),) -cxx_sign := -endif -endif - -cxx_id := - -ifneq ($(cxx_sign),) - -# GNU g++ (g++) -# -ifeq ($(cxx_id),) -ifeq ($(shell echo '$(cxx_sign)' | sed -e 's/^[^ ]* (GCC) .*$$//'),) -cxx_id := gnu -endif -endif - -# g++ 4.3 removed GCC for some reason so check for g++ also. -ifeq ($(cxx_id),) -ifeq ($(shell echo '$(cxx_sign)' | sed -e 's/^g++.*$$//'),) -cxx_id := gnu -endif -endif - -# Clang -# -ifeq ($(cxx_id),) -ifeq ($(shell echo '$(cxx_sign)' | sed -e 's/^.*clang.*$$//'),) -cxx_id := clang -endif -endif - -ifeq ($(cxx_id),) -ifeq ($(shell echo '$(cxx_sign)' | sed -e 's/^.*Clang.*$$//'),) -cxx_id := clang -endif -endif - -# Sun C++ (CC) -# -ifeq ($(cxx_id),) -ifeq ($(shell echo '$(cxx_sign)' | sed -e 's/^[^ ]* Sun C.. .*$$//'),) -cxx_id := sun -endif -endif - - -# HP C++ (aCC) -# -ifeq ($(cxx_id),) -ifeq ($(shell echo '$(cxx_sign)' | sed -e 's/^[^ ]* HP aC..\/ANSI C .* A\.06\..*$$//'),) -cxx_id := hp -endif -endif - -ifeq ($(cxx_id),) -ifeq ($(shell echo '$(cxx_sign)' | sed -e 's/^[^ ]* HP C\/aC.. .* A\.06\..*$$//'),) -cxx_id := hp -endif -endif - -# Intel C++ (icpc) -# - -# 9.x -ifeq ($(cxx_id),) -ifeq ($(shell echo '$(cxx_sign)' | sed -e 's/^Intel(R) C.. .*$$//'),) -cxx_id := intel -endif -endif - -# 8.x -ifeq ($(cxx_id),) -ifeq ($(shell echo '$(cxx_sign)' | sed -e 's/^8\..$$//'),) -cxx_id := intel -endif -endif - - -# IBM XL C++ -# -ifeq ($(cxx_id),) -ifeq ($(shell echo '$(cxx_sign)' | sed -e 's/^.*IBM XL C\/C.. .*$$//'),) -cxx_id := ibm -endif -endif - - -# Unknown -# -ifeq ($(cxx_id),) -$(warning unknown C++ compiler signature '$(cxx_sign)', continuing anyway) -endif - - -else -$(warning unable to obtain compiler signature for '$(CXX)', continuing anyway) -endif - -#$(warning $(cxx_sign)) -#$(warning $(cxx_id)) diff --git a/dist/examples/build/cxx/rules.make b/dist/examples/build/cxx/rules.make deleted file mode 100644 index 9f31128..0000000 --- a/dist/examples/build/cxx/rules.make +++ /dev/null @@ -1,57 +0,0 @@ -# file : examples/build/cxx/rules.make -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(root)/build/cxx/compilers.make - - -# GNU g++ -# -ifeq ($(cxx_id),gnu) - CXXFLAGS := -W -Wall -O3 -endif - -# Clang -# -ifeq ($(cxx_id),clang) - CXXFLAGS := -W -O3 -endif - -# Intel C++ -# -ifeq ($(cxx_id),intel) - CXXFLAGS := -w1 -O2 -endif - - -# Sun C++ -# -ifeq ($(cxx_id),sun) - CXXFLAGS := -O -endif - - -# HP aCC -# -ifeq ($(cxx_id),hp) - - # By default Xerces-C++ is built with -mt for aCC. - # 2334 no suitable copy constructor (e.g., for std::auto_ptr) - # - CXXFLAGS := -Aa -O -mt +W2334 -endif - - -# IBM XL C++ -# -ifeq ($(cxx_id),ibm) - CXXFLAGS := -qrtti -O -endif - - -# Rules. -# -%.o: %.cxx - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@ - -%: %.o - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) diff --git a/dist/examples/build/xsd/common.make b/dist/examples/build/xsd/common.make deleted file mode 100644 index ccd5a42..0000000 --- a/dist/examples/build/xsd/common.make +++ /dev/null @@ -1,9 +0,0 @@ -# file : examples/build/xsd/common.make -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -XSD := $(shell if test -x $(root)/../bin/xsd; \ - then echo $(root)/../bin/xsd; \ - else echo xsd; fi) - -override CPPFLAGS += $(shell if test -d $(root)/../libxsd; \ - then echo -I$(root)/../libxsd; fi) diff --git a/dist/examples/build/xsd/parser-rules.make b/dist/examples/build/xsd/parser-rules.make deleted file mode 100644 index 13addaa..0000000 --- a/dist/examples/build/xsd/parser-rules.make +++ /dev/null @@ -1,21 +0,0 @@ -# file : examples/build/xsd/parser-rules.make -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(root)/build/xsd/common.make - -XML_PARSER := xerces - -ifeq ($(XML_PARSER),xerces) -override LIBS := -lxerces-c $(LIBS) -else -override LIBS := -lexpat $(LIBS) -endif - -override XSDFLAGS += --xml-parser $(XML_PARSER) - -# Rules. -# -.PRECIOUS: %-pskel.hxx %-pskel.ixx %-pskel.cxx - -%-pskel.hxx %-pskel.ixx %-pskel.cxx: %.xsd - $(XSD) cxx-parser $(XSDFLAGS) $< diff --git a/dist/examples/build/xsd/tree-rules.make b/dist/examples/build/xsd/tree-rules.make deleted file mode 100644 index 2f188cc..0000000 --- a/dist/examples/build/xsd/tree-rules.make +++ /dev/null @@ -1,13 +0,0 @@ -# file : examples/build/xsd/tree-rules.make -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(root)/build/xsd/common.make - -override LIBS := -lxerces-c $(LIBS) - -# Rules. -# -.PRECIOUS: %.cxx %.hxx %.ixx - -%.cxx %.hxx %.ixx: %.xsd - $(XSD) cxx-tree $(XSDFLAGS) $< diff --git a/dist/examples/cxx/makefile b/dist/examples/cxx/makefile deleted file mode 100644 index 4882e9a..0000000 --- a/dist/examples/cxx/makefile +++ /dev/null @@ -1,11 +0,0 @@ -dirs := parser tree - -.PHONY: all $(dirs) - -all: $(dirs) - -$(dirs): - @$(MAKE) -C $@ $(MAKECMDGOALS) - -makefile: ; -% :: $(dirs) ; diff --git a/dist/examples/cxx/parser/generated/generated-vc10.vcxproj b/dist/examples/cxx/parser/generated/generated-vc10.vcxproj deleted file mode 100644 index c20e5be..0000000 --- a/dist/examples/cxx/parser/generated/generated-vc10.vcxproj +++ /dev/null @@ -1,203 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - generated - {4277B39A-C9FB-4F10-8223-8DD38053EDA0} - generated - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - xsd library.xsd - xsd cxx-parser --generate-print-impl --generate-test-driver --force-overwrite library.xsd - library-pskel.hxx;library-pskel.cxx;library-pimpl.hxx;library-pimpl.cxx;library-driver.cxx;%(Outputs) - xsd library.xsd - xsd cxx-parser --generate-print-impl --generate-test-driver --force-overwrite library.xsd - library-pskel.hxx;library-pskel.cxx;library-pimpl.hxx;library-pimpl.cxx;library-driver.cxx;%(Outputs) - xsd library.xsd - xsd cxx-parser --generate-print-impl --generate-test-driver --force-overwrite library.xsd - library-pskel.hxx;library-pskel.cxx;library-pimpl.hxx;library-pimpl.cxx;library-driver.cxx;%(Outputs) - xsd library.xsd - xsd cxx-parser --generate-print-impl --generate-test-driver --force-overwrite library.xsd - library-pskel.hxx;library-pskel.cxx;library-pimpl.hxx;library-pimpl.cxx;library-driver.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/generated/generated-vc10.vcxproj.filters b/dist/examples/cxx/parser/generated/generated-vc10.vcxproj.filters deleted file mode 100644 index b2cc277..0000000 --- a/dist/examples/cxx/parser/generated/generated-vc10.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - {6241A332-00FB-43D7-8E2D-4277B261F512} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {5F7B4073-4744-4C7E-9B74-B5B7D8628B23} - h;hpp;hxx;hm;inl;inc;xsd - - - {64b9ddc3-e796-405a-84e3-6e33b610b7ba} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/generated/generated-vc11.vcxproj b/dist/examples/cxx/parser/generated/generated-vc11.vcxproj deleted file mode 100644 index 1df7dd5..0000000 --- a/dist/examples/cxx/parser/generated/generated-vc11.vcxproj +++ /dev/null @@ -1,207 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - generated - {4277B39A-C9FB-4F10-8223-8DD38053EDA0} - generated - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - xsd library.xsd - xsd cxx-parser --generate-print-impl --generate-test-driver --force-overwrite library.xsd - library-pskel.hxx;library-pskel.cxx;library-pimpl.hxx;library-pimpl.cxx;library-driver.cxx;%(Outputs) - xsd library.xsd - xsd cxx-parser --generate-print-impl --generate-test-driver --force-overwrite library.xsd - library-pskel.hxx;library-pskel.cxx;library-pimpl.hxx;library-pimpl.cxx;library-driver.cxx;%(Outputs) - xsd library.xsd - xsd cxx-parser --generate-print-impl --generate-test-driver --force-overwrite library.xsd - library-pskel.hxx;library-pskel.cxx;library-pimpl.hxx;library-pimpl.cxx;library-driver.cxx;%(Outputs) - xsd library.xsd - xsd cxx-parser --generate-print-impl --generate-test-driver --force-overwrite library.xsd - library-pskel.hxx;library-pskel.cxx;library-pimpl.hxx;library-pimpl.cxx;library-driver.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/generated/generated-vc11.vcxproj.filters b/dist/examples/cxx/parser/generated/generated-vc11.vcxproj.filters deleted file mode 100644 index b2cc277..0000000 --- a/dist/examples/cxx/parser/generated/generated-vc11.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - {6241A332-00FB-43D7-8E2D-4277B261F512} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {5F7B4073-4744-4C7E-9B74-B5B7D8628B23} - h;hpp;hxx;hm;inl;inc;xsd - - - {64b9ddc3-e796-405a-84e3-6e33b610b7ba} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/generated/generated-vc12.vcxproj b/dist/examples/cxx/parser/generated/generated-vc12.vcxproj deleted file mode 100644 index 21bce27..0000000 --- a/dist/examples/cxx/parser/generated/generated-vc12.vcxproj +++ /dev/null @@ -1,211 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - generated - {4277B39A-C9FB-4F10-8223-8DD38053EDA0} - generated - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - xsd library.xsd - xsd cxx-parser --generate-print-impl --generate-test-driver --force-overwrite library.xsd - library-pskel.hxx;library-pskel.cxx;library-pimpl.hxx;library-pimpl.cxx;library-driver.cxx;%(Outputs) - xsd library.xsd - xsd cxx-parser --generate-print-impl --generate-test-driver --force-overwrite library.xsd - library-pskel.hxx;library-pskel.cxx;library-pimpl.hxx;library-pimpl.cxx;library-driver.cxx;%(Outputs) - xsd library.xsd - xsd cxx-parser --generate-print-impl --generate-test-driver --force-overwrite library.xsd - library-pskel.hxx;library-pskel.cxx;library-pimpl.hxx;library-pimpl.cxx;library-driver.cxx;%(Outputs) - xsd library.xsd - xsd cxx-parser --generate-print-impl --generate-test-driver --force-overwrite library.xsd - library-pskel.hxx;library-pskel.cxx;library-pimpl.hxx;library-pimpl.cxx;library-driver.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/generated/generated-vc12.vcxproj.filters b/dist/examples/cxx/parser/generated/generated-vc12.vcxproj.filters deleted file mode 100644 index b2cc277..0000000 --- a/dist/examples/cxx/parser/generated/generated-vc12.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - {6241A332-00FB-43D7-8E2D-4277B261F512} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {5F7B4073-4744-4C7E-9B74-B5B7D8628B23} - h;hpp;hxx;hm;inl;inc;xsd - - - {64b9ddc3-e796-405a-84e3-6e33b610b7ba} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/generated/generated-vc8.vcproj b/dist/examples/cxx/parser/generated/generated-vc8.vcproj deleted file mode 100644 index ee4e0f6..0000000 --- a/dist/examples/cxx/parser/generated/generated-vc8.vcproj +++ /dev/null @@ -1,427 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/parser/generated/generated-vc9.vcproj b/dist/examples/cxx/parser/generated/generated-vc9.vcproj deleted file mode 100644 index 2ffc6dd..0000000 --- a/dist/examples/cxx/parser/generated/generated-vc9.vcproj +++ /dev/null @@ -1,424 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/parser/generated/makefile b/dist/examples/cxx/parser/generated/makefile deleted file mode 100644 index b7bb4b8..0000000 --- a/dist/examples/cxx/parser/generated/makefile +++ /dev/null @@ -1,49 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/parser-rules.make - -override XSDFLAGS += --generate-print-impl --generate-test-driver - -# If you are basing your own code on this example and make changes -# to the sample implementation and/or test driver, make sure you -# remove this option or your changes will be lost forever. -# -override XSDFLAGS += --force-overwrite - -# Build -# -library-driver: library-driver.o library-pskel.o library-pimpl.o - -library-driver.o: library-driver.cxx library-pimpl.hxx library-pskel.hxx -library-pimpl.o: library-pimpl.cxx library-pimpl.hxx library-pskel.hxx -library-pskel.o: library-pskel.cxx library-pskel.hxx - -library-pskel.hxx \ -library-pskel.cxx \ -library-pimpl.hxx \ -library-pimpl.cxx \ -library-driver.cxx : library.xsd - -# Change the pattern rule from parser-rules.make to include the sample -# implementation and test driver. -# -.PRECIOUS: %-pskel.hxx %-pskel.cxx %-pimpl.hxx %-pimpl.cxx %-driver.cxx - -%-pskel.hxx %-pskel.cxx %-pimpl.hxx %-pimpl.cxx %-driver.cxx: %.xsd - $(XSD) cxx-parser $(XSDFLAGS) $< - - -# Test. -# -.PHONY: test -test: library-driver library.xml - ./library-driver library.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f library-driver.?xx library-pimpl.?xx library-pskel.?xx - rm -f library-driver.o library-pimpl.o library-pskel.o library-driver diff --git a/dist/examples/cxx/parser/hello/hello-vc10.vcxproj b/dist/examples/cxx/parser/hello/hello-vc10.vcxproj deleted file mode 100644 index 8478a29..0000000 --- a/dist/examples/cxx/parser/hello/hello-vc10.vcxproj +++ /dev/null @@ -1,201 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - hello - {683E9D46-FCC7-4163-984B-9F399169CF7F} - hello - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd hello.xsd - xsd cxx-parser hello.xsd - hello-pskel.hxx;hello-pskel.cxx;%(Outputs) - xsd hello.xsd - xsd cxx-parser hello.xsd - hello-pskel.hxx;hello-pskel.cxx;%(Outputs) - xsd hello.xsd - xsd cxx-parser hello.xsd - hello-pskel.hxx;hello-pskel.cxx;%(Outputs) - xsd hello.xsd - xsd cxx-parser hello.xsd - hello-pskel.hxx;hello-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/hello/hello-vc10.vcxproj.filters b/dist/examples/cxx/parser/hello/hello-vc10.vcxproj.filters deleted file mode 100644 index 26513bb..0000000 --- a/dist/examples/cxx/parser/hello/hello-vc10.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {E9BF8C86-0B39-4E45-81D2-35AD75F02C5C} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {3490E63E-27F8-4E29-996F-79F99714DDB3} - h;hpp;hxx;hm;inl;inc;xsd - - - {338ac052-a215-4fe4-a66b-f6be21b5ffa4} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/hello/hello-vc11.vcxproj b/dist/examples/cxx/parser/hello/hello-vc11.vcxproj deleted file mode 100644 index 48a41ac..0000000 --- a/dist/examples/cxx/parser/hello/hello-vc11.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - hello - {683E9D46-FCC7-4163-984B-9F399169CF7F} - hello - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd hello.xsd - xsd cxx-parser hello.xsd - hello-pskel.hxx;hello-pskel.cxx;%(Outputs) - xsd hello.xsd - xsd cxx-parser hello.xsd - hello-pskel.hxx;hello-pskel.cxx;%(Outputs) - xsd hello.xsd - xsd cxx-parser hello.xsd - hello-pskel.hxx;hello-pskel.cxx;%(Outputs) - xsd hello.xsd - xsd cxx-parser hello.xsd - hello-pskel.hxx;hello-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/hello/hello-vc11.vcxproj.filters b/dist/examples/cxx/parser/hello/hello-vc11.vcxproj.filters deleted file mode 100644 index 26513bb..0000000 --- a/dist/examples/cxx/parser/hello/hello-vc11.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {E9BF8C86-0B39-4E45-81D2-35AD75F02C5C} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {3490E63E-27F8-4E29-996F-79F99714DDB3} - h;hpp;hxx;hm;inl;inc;xsd - - - {338ac052-a215-4fe4-a66b-f6be21b5ffa4} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/hello/hello-vc12.vcxproj b/dist/examples/cxx/parser/hello/hello-vc12.vcxproj deleted file mode 100644 index 22ac525..0000000 --- a/dist/examples/cxx/parser/hello/hello-vc12.vcxproj +++ /dev/null @@ -1,209 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - hello - {683E9D46-FCC7-4163-984B-9F399169CF7F} - hello - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd hello.xsd - xsd cxx-parser hello.xsd - hello-pskel.hxx;hello-pskel.cxx;%(Outputs) - xsd hello.xsd - xsd cxx-parser hello.xsd - hello-pskel.hxx;hello-pskel.cxx;%(Outputs) - xsd hello.xsd - xsd cxx-parser hello.xsd - hello-pskel.hxx;hello-pskel.cxx;%(Outputs) - xsd hello.xsd - xsd cxx-parser hello.xsd - hello-pskel.hxx;hello-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/hello/hello-vc12.vcxproj.filters b/dist/examples/cxx/parser/hello/hello-vc12.vcxproj.filters deleted file mode 100644 index 26513bb..0000000 --- a/dist/examples/cxx/parser/hello/hello-vc12.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {E9BF8C86-0B39-4E45-81D2-35AD75F02C5C} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {3490E63E-27F8-4E29-996F-79F99714DDB3} - h;hpp;hxx;hm;inl;inc;xsd - - - {338ac052-a215-4fe4-a66b-f6be21b5ffa4} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/hello/hello-vc8.vcproj b/dist/examples/cxx/parser/hello/hello-vc8.vcproj deleted file mode 100644 index a19fb43..0000000 --- a/dist/examples/cxx/parser/hello/hello-vc8.vcproj +++ /dev/null @@ -1,419 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/parser/hello/hello-vc9.vcproj b/dist/examples/cxx/parser/hello/hello-vc9.vcproj deleted file mode 100644 index 9d0e755..0000000 --- a/dist/examples/cxx/parser/hello/hello-vc9.vcproj +++ /dev/null @@ -1,416 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/parser/hello/makefile b/dist/examples/cxx/parser/hello/makefile deleted file mode 100644 index 5746c6f..0000000 --- a/dist/examples/cxx/parser/hello/makefile +++ /dev/null @@ -1,28 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/parser-rules.make - - -# Build. -# -driver: driver.o hello-pskel.o - -driver.o: driver.cxx hello-pskel.hxx -hello-pskel.o: hello-pskel.cxx hello-pskel.hxx - -hello-pskel.hxx hello-pskel.cxx: hello.xsd - - -# Test. -# -.PHONY: test -test: driver hello.xml - ./driver hello.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f hello-pskel.?xx hello-pskel.o driver.o driver diff --git a/dist/examples/cxx/parser/library/library-vc10.vcxproj b/dist/examples/cxx/parser/library/library-vc10.vcxproj deleted file mode 100644 index c9046d7..0000000 --- a/dist/examples/cxx/parser/library/library-vc10.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - library - {D66DAC4D-133C-4DB5-923F-C88A961C3C51} - library - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - xsd library.xsd - xsd cxx-parser --generate-inline --type-map library.map library.xsd - library-pskel.hxx;library-pskel.ixx;library-pskel.cxx;%(Outputs) - xsd library.xsd - xsd cxx-parser --generate-inline --type-map library.map library.xsd - library-pskel.hxx;library-pskel.ixx;library-pskel.cxx;%(Outputs) - xsd library.xsd - xsd cxx-parser --generate-inline --type-map library.map library.xsd - library-pskel.hxx;library-pskel.ixx;library-pskel.cxx;%(Outputs) - xsd library.xsd - xsd cxx-parser --generate-inline --type-map library.map library.xsd - library-pskel.hxx;library-pskel.ixx;library-pskel.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/library/library-vc10.vcxproj.filters b/dist/examples/cxx/parser/library/library-vc10.vcxproj.filters deleted file mode 100644 index 30f473b..0000000 --- a/dist/examples/cxx/parser/library/library-vc10.vcxproj.filters +++ /dev/null @@ -1,54 +0,0 @@ - - - - - {4044D311-878E-4632-B816-7810045EF3F1} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {4F90DEB0-060B-4976-949A-66FFB902F598} - h;hpp;hxx;hm;inl;inc;xsd - - - {a31fd2f2-4ce6-4ee0-962d-68d213bc7b1b} - ixx - - - {8e9fd809-af45-49e4-95b8-d2becff77db5} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/library/library-vc11.vcxproj b/dist/examples/cxx/parser/library/library-vc11.vcxproj deleted file mode 100644 index daa5ef3..0000000 --- a/dist/examples/cxx/parser/library/library-vc11.vcxproj +++ /dev/null @@ -1,209 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - library - {D66DAC4D-133C-4DB5-923F-C88A961C3C51} - library - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - xsd library.xsd - xsd cxx-parser --generate-inline --type-map library.map library.xsd - library-pskel.hxx;library-pskel.ixx;library-pskel.cxx;%(Outputs) - xsd library.xsd - xsd cxx-parser --generate-inline --type-map library.map library.xsd - library-pskel.hxx;library-pskel.ixx;library-pskel.cxx;%(Outputs) - xsd library.xsd - xsd cxx-parser --generate-inline --type-map library.map library.xsd - library-pskel.hxx;library-pskel.ixx;library-pskel.cxx;%(Outputs) - xsd library.xsd - xsd cxx-parser --generate-inline --type-map library.map library.xsd - library-pskel.hxx;library-pskel.ixx;library-pskel.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/library/library-vc11.vcxproj.filters b/dist/examples/cxx/parser/library/library-vc11.vcxproj.filters deleted file mode 100644 index 30f473b..0000000 --- a/dist/examples/cxx/parser/library/library-vc11.vcxproj.filters +++ /dev/null @@ -1,54 +0,0 @@ - - - - - {4044D311-878E-4632-B816-7810045EF3F1} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {4F90DEB0-060B-4976-949A-66FFB902F598} - h;hpp;hxx;hm;inl;inc;xsd - - - {a31fd2f2-4ce6-4ee0-962d-68d213bc7b1b} - ixx - - - {8e9fd809-af45-49e4-95b8-d2becff77db5} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/library/library-vc12.vcxproj b/dist/examples/cxx/parser/library/library-vc12.vcxproj deleted file mode 100644 index 345226f..0000000 --- a/dist/examples/cxx/parser/library/library-vc12.vcxproj +++ /dev/null @@ -1,213 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - library - {D66DAC4D-133C-4DB5-923F-C88A961C3C51} - library - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - xsd library.xsd - xsd cxx-parser --generate-inline --type-map library.map library.xsd - library-pskel.hxx;library-pskel.ixx;library-pskel.cxx;%(Outputs) - xsd library.xsd - xsd cxx-parser --generate-inline --type-map library.map library.xsd - library-pskel.hxx;library-pskel.ixx;library-pskel.cxx;%(Outputs) - xsd library.xsd - xsd cxx-parser --generate-inline --type-map library.map library.xsd - library-pskel.hxx;library-pskel.ixx;library-pskel.cxx;%(Outputs) - xsd library.xsd - xsd cxx-parser --generate-inline --type-map library.map library.xsd - library-pskel.hxx;library-pskel.ixx;library-pskel.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/library/library-vc12.vcxproj.filters b/dist/examples/cxx/parser/library/library-vc12.vcxproj.filters deleted file mode 100644 index 30f473b..0000000 --- a/dist/examples/cxx/parser/library/library-vc12.vcxproj.filters +++ /dev/null @@ -1,54 +0,0 @@ - - - - - {4044D311-878E-4632-B816-7810045EF3F1} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {4F90DEB0-060B-4976-949A-66FFB902F598} - h;hpp;hxx;hm;inl;inc;xsd - - - {a31fd2f2-4ce6-4ee0-962d-68d213bc7b1b} - ixx - - - {8e9fd809-af45-49e4-95b8-d2becff77db5} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/library/library-vc8.vcproj b/dist/examples/cxx/parser/library/library-vc8.vcproj deleted file mode 100644 index f5bb549..0000000 --- a/dist/examples/cxx/parser/library/library-vc8.vcproj +++ /dev/null @@ -1,440 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/parser/library/library-vc9.vcproj b/dist/examples/cxx/parser/library/library-vc9.vcproj deleted file mode 100644 index 1348f83..0000000 --- a/dist/examples/cxx/parser/library/library-vc9.vcproj +++ /dev/null @@ -1,437 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/parser/library/makefile b/dist/examples/cxx/parser/library/makefile deleted file mode 100644 index f96353b..0000000 --- a/dist/examples/cxx/parser/library/makefile +++ /dev/null @@ -1,30 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/parser-rules.make - -override XSDFLAGS += --generate-inline --type-map library.map - -# Build -# -driver: driver.o library-pskel.o library-pimpl.o - -driver.o: driver.cxx library-pimpl.hxx library-pskel.hxx library.hxx -library-pimpl.o: library-pimpl.cxx library-pimpl.hxx library-pskel.hxx library.hxx -library-pskel.o: library-pskel.cxx library-pskel.hxx library.hxx - -library-pskel.hxx library-pskel.ixx library-pskel.cxx: library.xsd library.map - - -# Test. -# -.PHONY: test -test: driver library.xml - ./driver library.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f library-pskel.?xx library-pimpl.o library-pskel.o driver.o driver diff --git a/dist/examples/cxx/parser/makefile b/dist/examples/cxx/parser/makefile deleted file mode 100644 index b778cbd..0000000 --- a/dist/examples/cxx/parser/makefile +++ /dev/null @@ -1,12 +0,0 @@ -dirs := generated hello library mixin mixed multiroot performance \ -polymorphism polyroot wildcard - -.PHONY: all $(dirs) - -all: $(dirs) - -$(dirs): - @$(MAKE) -C $@ $(MAKECMDGOALS) - -makefile: ; -% :: $(dirs) ; diff --git a/dist/examples/cxx/parser/mixed/makefile b/dist/examples/cxx/parser/mixed/makefile deleted file mode 100644 index edd28b2..0000000 --- a/dist/examples/cxx/parser/mixed/makefile +++ /dev/null @@ -1,30 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/parser-rules.make - -override XSDFLAGS += --type-map text.map - -# Build. -# -driver: driver.o text-pskel.o - -driver.o: driver.cxx text-pskel.hxx anchor.hxx -text-pskel.o: text-pskel.cxx text-pskel.hxx anchor.hxx - -text-pskel.hxx text-pskel.cxx: text.xsd text.map - - -# Test. -# -.PHONY: test -test: driver text.xml - ./driver text.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f text-pskel.?xx text-pskel.o driver.o driver - diff --git a/dist/examples/cxx/parser/mixed/mixed-vc10.vcxproj b/dist/examples/cxx/parser/mixed/mixed-vc10.vcxproj deleted file mode 100644 index d940e8d..0000000 --- a/dist/examples/cxx/parser/mixed/mixed-vc10.vcxproj +++ /dev/null @@ -1,202 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mixed - {304FD6A7-6C73-41C3-B489-97FD5E635CCB} - mixed - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - xsd text.xsd - xsd cxx-parser --type-map text.map text.xsd - text-pskel.hxx;text-pskel.cxx;%(Outputs) - xsd text.xsd - xsd cxx-parser --type-map text.map text.xsd - text-pskel.hxx;text-pskel.cxx;%(Outputs) - xsd text.xsd - xsd cxx-parser --type-map text.map text.xsd - text-pskel.hxx;text-pskel.cxx;%(Outputs) - xsd text.xsd - xsd cxx-parser --type-map text.map text.xsd - text-pskel.hxx;text-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/mixed/mixed-vc10.vcxproj.filters b/dist/examples/cxx/parser/mixed/mixed-vc10.vcxproj.filters deleted file mode 100644 index 9d5bb36..0000000 --- a/dist/examples/cxx/parser/mixed/mixed-vc10.vcxproj.filters +++ /dev/null @@ -1,41 +0,0 @@ - - - - - {8E9A9B27-1882-4B49-9451-345FEED45AEE} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {0BDCEBD5-F78D-437D-BED5-4507831FA9E8} - h;hpp;hxx;hm;inl;inc;xsd - - - {748ddcb3-bd88-48b4-b396-d1d3fef8a4e6} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/mixed/mixed-vc11.vcxproj b/dist/examples/cxx/parser/mixed/mixed-vc11.vcxproj deleted file mode 100644 index 00b00a2..0000000 --- a/dist/examples/cxx/parser/mixed/mixed-vc11.vcxproj +++ /dev/null @@ -1,206 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mixed - {304FD6A7-6C73-41C3-B489-97FD5E635CCB} - mixed - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - xsd text.xsd - xsd cxx-parser --type-map text.map text.xsd - text-pskel.hxx;text-pskel.cxx;%(Outputs) - xsd text.xsd - xsd cxx-parser --type-map text.map text.xsd - text-pskel.hxx;text-pskel.cxx;%(Outputs) - xsd text.xsd - xsd cxx-parser --type-map text.map text.xsd - text-pskel.hxx;text-pskel.cxx;%(Outputs) - xsd text.xsd - xsd cxx-parser --type-map text.map text.xsd - text-pskel.hxx;text-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/mixed/mixed-vc11.vcxproj.filters b/dist/examples/cxx/parser/mixed/mixed-vc11.vcxproj.filters deleted file mode 100644 index 9d5bb36..0000000 --- a/dist/examples/cxx/parser/mixed/mixed-vc11.vcxproj.filters +++ /dev/null @@ -1,41 +0,0 @@ - - - - - {8E9A9B27-1882-4B49-9451-345FEED45AEE} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {0BDCEBD5-F78D-437D-BED5-4507831FA9E8} - h;hpp;hxx;hm;inl;inc;xsd - - - {748ddcb3-bd88-48b4-b396-d1d3fef8a4e6} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/mixed/mixed-vc12.vcxproj b/dist/examples/cxx/parser/mixed/mixed-vc12.vcxproj deleted file mode 100644 index d9e63ed..0000000 --- a/dist/examples/cxx/parser/mixed/mixed-vc12.vcxproj +++ /dev/null @@ -1,210 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mixed - {304FD6A7-6C73-41C3-B489-97FD5E635CCB} - mixed - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - xsd text.xsd - xsd cxx-parser --type-map text.map text.xsd - text-pskel.hxx;text-pskel.cxx;%(Outputs) - xsd text.xsd - xsd cxx-parser --type-map text.map text.xsd - text-pskel.hxx;text-pskel.cxx;%(Outputs) - xsd text.xsd - xsd cxx-parser --type-map text.map text.xsd - text-pskel.hxx;text-pskel.cxx;%(Outputs) - xsd text.xsd - xsd cxx-parser --type-map text.map text.xsd - text-pskel.hxx;text-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/mixed/mixed-vc12.vcxproj.filters b/dist/examples/cxx/parser/mixed/mixed-vc12.vcxproj.filters deleted file mode 100644 index 9d5bb36..0000000 --- a/dist/examples/cxx/parser/mixed/mixed-vc12.vcxproj.filters +++ /dev/null @@ -1,41 +0,0 @@ - - - - - {8E9A9B27-1882-4B49-9451-345FEED45AEE} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {0BDCEBD5-F78D-437D-BED5-4507831FA9E8} - h;hpp;hxx;hm;inl;inc;xsd - - - {748ddcb3-bd88-48b4-b396-d1d3fef8a4e6} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/mixed/mixed-vc8.vcproj b/dist/examples/cxx/parser/mixed/mixed-vc8.vcproj deleted file mode 100644 index 91906be..0000000 --- a/dist/examples/cxx/parser/mixed/mixed-vc8.vcproj +++ /dev/null @@ -1,423 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/parser/mixed/mixed-vc9.vcproj b/dist/examples/cxx/parser/mixed/mixed-vc9.vcproj deleted file mode 100644 index f2eb5f1..0000000 --- a/dist/examples/cxx/parser/mixed/mixed-vc9.vcproj +++ /dev/null @@ -1,420 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/parser/mixin/makefile b/dist/examples/cxx/parser/mixin/makefile deleted file mode 100644 index 551519d..0000000 --- a/dist/examples/cxx/parser/mixin/makefile +++ /dev/null @@ -1,30 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/parser-rules.make - -override XSDFLAGS += --type-map schema.map - - -# Build. -# -driver: driver.o schema-pskel.o - -driver.o: driver.cxx schema-pskel.hxx types.hxx -schema-pskel.o: schema-pskel.cxx schema-pskel.hxx types.hxx - -schema-pskel.hxx schema-pskel.cxx: schema.xsd schema.map - -# Test. -# -.PHONY: test -test: driver instance.xml - ./driver instance.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f schema-pskel.?xx schema-pskel.o driver.o driver - diff --git a/dist/examples/cxx/parser/mixin/mixin-vc10.vcxproj b/dist/examples/cxx/parser/mixin/mixin-vc10.vcxproj deleted file mode 100644 index 729240e..0000000 --- a/dist/examples/cxx/parser/mixin/mixin-vc10.vcxproj +++ /dev/null @@ -1,202 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mixin - {8CCA6181-F2CE-4E5E-A20E-4E1E53A35125} - mixin - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - xsd schema.xsd - xsd cxx-parser --type-map schema.map schema.xsd - schema-pskel.hxx;schema-pskel.cxx;%(Outputs) - xsd schema.xsd - xsd cxx-parser --type-map schema.map schema.xsd - schema-pskel.hxx;schema-pskel.cxx;%(Outputs) - xsd schema.xsd - xsd cxx-parser --type-map schema.map schema.xsd - schema-pskel.hxx;schema-pskel.cxx;%(Outputs) - xsd schema.xsd - xsd cxx-parser --type-map schema.map schema.xsd - schema-pskel.hxx;schema-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/mixin/mixin-vc10.vcxproj.filters b/dist/examples/cxx/parser/mixin/mixin-vc10.vcxproj.filters deleted file mode 100644 index 4fd62ea..0000000 --- a/dist/examples/cxx/parser/mixin/mixin-vc10.vcxproj.filters +++ /dev/null @@ -1,41 +0,0 @@ - - - - - {4BF1C3D0-33B1-4924-9F8C-4DD7B7765D82} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {A4012AA7-A8FE-4CE8-9BB0-1DBA14C2CEAD} - h;hpp;hxx;hm;inl;inc;xsd - - - {1772a873-01ce-415d-a4e7-b107ecfb3d0f} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/mixin/mixin-vc11.vcxproj b/dist/examples/cxx/parser/mixin/mixin-vc11.vcxproj deleted file mode 100644 index 7de773e..0000000 --- a/dist/examples/cxx/parser/mixin/mixin-vc11.vcxproj +++ /dev/null @@ -1,206 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mixin - {8CCA6181-F2CE-4E5E-A20E-4E1E53A35125} - mixin - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - xsd schema.xsd - xsd cxx-parser --type-map schema.map schema.xsd - schema-pskel.hxx;schema-pskel.cxx;%(Outputs) - xsd schema.xsd - xsd cxx-parser --type-map schema.map schema.xsd - schema-pskel.hxx;schema-pskel.cxx;%(Outputs) - xsd schema.xsd - xsd cxx-parser --type-map schema.map schema.xsd - schema-pskel.hxx;schema-pskel.cxx;%(Outputs) - xsd schema.xsd - xsd cxx-parser --type-map schema.map schema.xsd - schema-pskel.hxx;schema-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/mixin/mixin-vc11.vcxproj.filters b/dist/examples/cxx/parser/mixin/mixin-vc11.vcxproj.filters deleted file mode 100644 index 4fd62ea..0000000 --- a/dist/examples/cxx/parser/mixin/mixin-vc11.vcxproj.filters +++ /dev/null @@ -1,41 +0,0 @@ - - - - - {4BF1C3D0-33B1-4924-9F8C-4DD7B7765D82} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {A4012AA7-A8FE-4CE8-9BB0-1DBA14C2CEAD} - h;hpp;hxx;hm;inl;inc;xsd - - - {1772a873-01ce-415d-a4e7-b107ecfb3d0f} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/mixin/mixin-vc12.vcxproj b/dist/examples/cxx/parser/mixin/mixin-vc12.vcxproj deleted file mode 100644 index 83771b4..0000000 --- a/dist/examples/cxx/parser/mixin/mixin-vc12.vcxproj +++ /dev/null @@ -1,210 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mixin - {8CCA6181-F2CE-4E5E-A20E-4E1E53A35125} - mixin - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - xsd schema.xsd - xsd cxx-parser --type-map schema.map schema.xsd - schema-pskel.hxx;schema-pskel.cxx;%(Outputs) - xsd schema.xsd - xsd cxx-parser --type-map schema.map schema.xsd - schema-pskel.hxx;schema-pskel.cxx;%(Outputs) - xsd schema.xsd - xsd cxx-parser --type-map schema.map schema.xsd - schema-pskel.hxx;schema-pskel.cxx;%(Outputs) - xsd schema.xsd - xsd cxx-parser --type-map schema.map schema.xsd - schema-pskel.hxx;schema-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/mixin/mixin-vc12.vcxproj.filters b/dist/examples/cxx/parser/mixin/mixin-vc12.vcxproj.filters deleted file mode 100644 index 4fd62ea..0000000 --- a/dist/examples/cxx/parser/mixin/mixin-vc12.vcxproj.filters +++ /dev/null @@ -1,41 +0,0 @@ - - - - - {4BF1C3D0-33B1-4924-9F8C-4DD7B7765D82} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {A4012AA7-A8FE-4CE8-9BB0-1DBA14C2CEAD} - h;hpp;hxx;hm;inl;inc;xsd - - - {1772a873-01ce-415d-a4e7-b107ecfb3d0f} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/mixin/mixin-vc8.vcproj b/dist/examples/cxx/parser/mixin/mixin-vc8.vcproj deleted file mode 100644 index 384e122..0000000 --- a/dist/examples/cxx/parser/mixin/mixin-vc8.vcproj +++ /dev/null @@ -1,423 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/parser/mixin/mixin-vc9.vcproj b/dist/examples/cxx/parser/mixin/mixin-vc9.vcproj deleted file mode 100644 index 9cdccb3..0000000 --- a/dist/examples/cxx/parser/mixin/mixin-vc9.vcproj +++ /dev/null @@ -1,420 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/parser/multiroot/makefile b/dist/examples/cxx/parser/multiroot/makefile deleted file mode 100644 index c45e3f3..0000000 --- a/dist/examples/cxx/parser/multiroot/makefile +++ /dev/null @@ -1,32 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/parser-rules.make - -override XSDFLAGS += --type-map protocol.map - -# Build -# -driver: driver.o protocol-pskel.o protocol-pimpl.o - -driver.o: driver.cxx protocol-pimpl.hxx protocol-pskel.hxx protocol.hxx -protocol-pimpl.o: protocol-pimpl.cxx protocol-pimpl.hxx protocol-pskel.hxx protocol.hxx -protocol-pskel.o: protocol-pskel.cxx protocol-pskel.hxx protocol.hxx - -protocol-pskel.hxx protocol-pskel.cxx: protocol.xsd protocol.map - - -# Test. -# -.PHONY: test -test: driver balance.xml withdraw.xml deposit.xml - ./driver balance.xml - ./driver withdraw.xml - ./driver deposit.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f protocol-pskel.?xx protocol-pimpl.o protocol-pskel.o driver.o driver diff --git a/dist/examples/cxx/parser/multiroot/multiroot-vc10.vcxproj b/dist/examples/cxx/parser/multiroot/multiroot-vc10.vcxproj deleted file mode 100644 index dac752c..0000000 --- a/dist/examples/cxx/parser/multiroot/multiroot-vc10.vcxproj +++ /dev/null @@ -1,208 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - multiroot - {3AC187DF-4FDF-40B7-9E12-002DC0A15EDB} - multiroot - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - xsd protocol.xsd - xsd cxx-parser --type-map protocol.map protocol.xsd - protocol-pskel.hxx;protocol-pskel.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-parser --type-map protocol.map protocol.xsd - protocol-pskel.hxx;protocol-pskel.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-parser --type-map protocol.map protocol.xsd - protocol-pskel.hxx;protocol-pskel.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-parser --type-map protocol.map protocol.xsd - protocol-pskel.hxx;protocol-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/multiroot/multiroot-vc10.vcxproj.filters b/dist/examples/cxx/parser/multiroot/multiroot-vc10.vcxproj.filters deleted file mode 100644 index 2b80057..0000000 --- a/dist/examples/cxx/parser/multiroot/multiroot-vc10.vcxproj.filters +++ /dev/null @@ -1,47 +0,0 @@ - - - - - {5CA12033-B9C7-4B8D-95C9-BC1D88DFB211} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {5F7258C7-69F9-44AC-8651-7ABC08C70815} - h;hpp;hxx;hm;inl;inc;xsd - - - {8a01b14f-5199-4686-a4e8-419ab31b3ea3} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/multiroot/multiroot-vc11.vcxproj b/dist/examples/cxx/parser/multiroot/multiroot-vc11.vcxproj deleted file mode 100644 index 9a5497d..0000000 --- a/dist/examples/cxx/parser/multiroot/multiroot-vc11.vcxproj +++ /dev/null @@ -1,212 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - multiroot - {3AC187DF-4FDF-40B7-9E12-002DC0A15EDB} - multiroot - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - xsd protocol.xsd - xsd cxx-parser --type-map protocol.map protocol.xsd - protocol-pskel.hxx;protocol-pskel.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-parser --type-map protocol.map protocol.xsd - protocol-pskel.hxx;protocol-pskel.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-parser --type-map protocol.map protocol.xsd - protocol-pskel.hxx;protocol-pskel.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-parser --type-map protocol.map protocol.xsd - protocol-pskel.hxx;protocol-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/multiroot/multiroot-vc11.vcxproj.filters b/dist/examples/cxx/parser/multiroot/multiroot-vc11.vcxproj.filters deleted file mode 100644 index 2b80057..0000000 --- a/dist/examples/cxx/parser/multiroot/multiroot-vc11.vcxproj.filters +++ /dev/null @@ -1,47 +0,0 @@ - - - - - {5CA12033-B9C7-4B8D-95C9-BC1D88DFB211} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {5F7258C7-69F9-44AC-8651-7ABC08C70815} - h;hpp;hxx;hm;inl;inc;xsd - - - {8a01b14f-5199-4686-a4e8-419ab31b3ea3} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/multiroot/multiroot-vc12.vcxproj b/dist/examples/cxx/parser/multiroot/multiroot-vc12.vcxproj deleted file mode 100644 index a8a41dc..0000000 --- a/dist/examples/cxx/parser/multiroot/multiroot-vc12.vcxproj +++ /dev/null @@ -1,216 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - multiroot - {3AC187DF-4FDF-40B7-9E12-002DC0A15EDB} - multiroot - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - xsd protocol.xsd - xsd cxx-parser --type-map protocol.map protocol.xsd - protocol-pskel.hxx;protocol-pskel.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-parser --type-map protocol.map protocol.xsd - protocol-pskel.hxx;protocol-pskel.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-parser --type-map protocol.map protocol.xsd - protocol-pskel.hxx;protocol-pskel.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-parser --type-map protocol.map protocol.xsd - protocol-pskel.hxx;protocol-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/multiroot/multiroot-vc12.vcxproj.filters b/dist/examples/cxx/parser/multiroot/multiroot-vc12.vcxproj.filters deleted file mode 100644 index 2b80057..0000000 --- a/dist/examples/cxx/parser/multiroot/multiroot-vc12.vcxproj.filters +++ /dev/null @@ -1,47 +0,0 @@ - - - - - {5CA12033-B9C7-4B8D-95C9-BC1D88DFB211} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {5F7258C7-69F9-44AC-8651-7ABC08C70815} - h;hpp;hxx;hm;inl;inc;xsd - - - {8a01b14f-5199-4686-a4e8-419ab31b3ea3} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/multiroot/multiroot-vc8.vcproj b/dist/examples/cxx/parser/multiroot/multiroot-vc8.vcproj deleted file mode 100644 index a37ec06..0000000 --- a/dist/examples/cxx/parser/multiroot/multiroot-vc8.vcproj +++ /dev/null @@ -1,435 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/parser/multiroot/multiroot-vc9.vcproj b/dist/examples/cxx/parser/multiroot/multiroot-vc9.vcproj deleted file mode 100644 index 75ef5e6..0000000 --- a/dist/examples/cxx/parser/multiroot/multiroot-vc9.vcproj +++ /dev/null @@ -1,432 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/parser/performance/makefile b/dist/examples/cxx/parser/performance/makefile deleted file mode 100644 index a98e86a..0000000 --- a/dist/examples/cxx/parser/performance/makefile +++ /dev/null @@ -1,30 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/parser-rules.make - -override XSDFLAGS += --generate-inline - -# Build. -# -driver: driver.o test-pskel.o time.o - -driver.o: driver.cxx test-pskel.hxx test-pskel.ixx time.hxx -test-pskel.o: test-pskel.cxx test-pskel.hxx test-pskel.ixx -time.o: time.cxx time.hxx - -test-pskel.hxx test-pskel.ixx test-pskel.cxx: test.xsd - - -# Test. -# -.PHONY: test -test: driver test-50k.xml - ./driver test-50k.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f test-pskel.?xx test-pskel.o driver.o time.o driver diff --git a/dist/examples/cxx/parser/performance/performance-vc10.vcxproj b/dist/examples/cxx/parser/performance/performance-vc10.vcxproj deleted file mode 100644 index 42bc963..0000000 --- a/dist/examples/cxx/parser/performance/performance-vc10.vcxproj +++ /dev/null @@ -1,203 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - performance - {676CB1A8-1060-4B7F-86FA-5F8F01AB80BD} - performance - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - xsd test.xsd - xsd cxx-parser --generate-inline test.xsd - test-pskel.hxx;test-pskel.ixx;test-pskel.cxx;%(Outputs) - xsd test.xsd - xsd cxx-parser --generate-inline test.xsd - test-pskel.hxx;test-pskel.ixx;test-pskel.cxx;%(Outputs) - xsd test.xsd - xsd cxx-parser --generate-inline test.xsd - test-pskel.hxx;test-pskel.ixx;test-pskel.cxx;%(Outputs) - xsd test.xsd - xsd cxx-parser --generate-inline test.xsd - test-pskel.hxx;test-pskel.ixx;test-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/performance/performance-vc10.vcxproj.filters b/dist/examples/cxx/parser/performance/performance-vc10.vcxproj.filters deleted file mode 100644 index 43190f1..0000000 --- a/dist/examples/cxx/parser/performance/performance-vc10.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - {699BF138-9DA5-4EC4-9796-4033D1E443E8} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {6B5C0740-D0B1-4A08-8657-DA9977EBA68D} - h;hpp;hxx;hm;inl;inc;xsd - - - {d885db2b-37d2-476b-964e-0f50c5f851d4} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/performance/performance-vc11.vcxproj b/dist/examples/cxx/parser/performance/performance-vc11.vcxproj deleted file mode 100644 index 4d02641..0000000 --- a/dist/examples/cxx/parser/performance/performance-vc11.vcxproj +++ /dev/null @@ -1,207 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - performance - {676CB1A8-1060-4B7F-86FA-5F8F01AB80BD} - performance - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - xsd test.xsd - xsd cxx-parser --generate-inline test.xsd - test-pskel.hxx;test-pskel.ixx;test-pskel.cxx;%(Outputs) - xsd test.xsd - xsd cxx-parser --generate-inline test.xsd - test-pskel.hxx;test-pskel.ixx;test-pskel.cxx;%(Outputs) - xsd test.xsd - xsd cxx-parser --generate-inline test.xsd - test-pskel.hxx;test-pskel.ixx;test-pskel.cxx;%(Outputs) - xsd test.xsd - xsd cxx-parser --generate-inline test.xsd - test-pskel.hxx;test-pskel.ixx;test-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/performance/performance-vc11.vcxproj.filters b/dist/examples/cxx/parser/performance/performance-vc11.vcxproj.filters deleted file mode 100644 index 43190f1..0000000 --- a/dist/examples/cxx/parser/performance/performance-vc11.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - {699BF138-9DA5-4EC4-9796-4033D1E443E8} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {6B5C0740-D0B1-4A08-8657-DA9977EBA68D} - h;hpp;hxx;hm;inl;inc;xsd - - - {d885db2b-37d2-476b-964e-0f50c5f851d4} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/performance/performance-vc12.vcxproj b/dist/examples/cxx/parser/performance/performance-vc12.vcxproj deleted file mode 100644 index b9bdd1c..0000000 --- a/dist/examples/cxx/parser/performance/performance-vc12.vcxproj +++ /dev/null @@ -1,211 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - performance - {676CB1A8-1060-4B7F-86FA-5F8F01AB80BD} - performance - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - xsd test.xsd - xsd cxx-parser --generate-inline test.xsd - test-pskel.hxx;test-pskel.ixx;test-pskel.cxx;%(Outputs) - xsd test.xsd - xsd cxx-parser --generate-inline test.xsd - test-pskel.hxx;test-pskel.ixx;test-pskel.cxx;%(Outputs) - xsd test.xsd - xsd cxx-parser --generate-inline test.xsd - test-pskel.hxx;test-pskel.ixx;test-pskel.cxx;%(Outputs) - xsd test.xsd - xsd cxx-parser --generate-inline test.xsd - test-pskel.hxx;test-pskel.ixx;test-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/performance/performance-vc12.vcxproj.filters b/dist/examples/cxx/parser/performance/performance-vc12.vcxproj.filters deleted file mode 100644 index 43190f1..0000000 --- a/dist/examples/cxx/parser/performance/performance-vc12.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - {699BF138-9DA5-4EC4-9796-4033D1E443E8} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {6B5C0740-D0B1-4A08-8657-DA9977EBA68D} - h;hpp;hxx;hm;inl;inc;xsd - - - {d885db2b-37d2-476b-964e-0f50c5f851d4} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/performance/performance-vc8.vcproj b/dist/examples/cxx/parser/performance/performance-vc8.vcproj deleted file mode 100644 index 867ecbb..0000000 --- a/dist/examples/cxx/parser/performance/performance-vc8.vcproj +++ /dev/null @@ -1,427 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/parser/performance/performance-vc9.vcproj b/dist/examples/cxx/parser/performance/performance-vc9.vcproj deleted file mode 100644 index 3fd46c7..0000000 --- a/dist/examples/cxx/parser/performance/performance-vc9.vcproj +++ /dev/null @@ -1,424 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/parser/polymorphism/makefile b/dist/examples/cxx/parser/polymorphism/makefile deleted file mode 100644 index 935661d..0000000 --- a/dist/examples/cxx/parser/polymorphism/makefile +++ /dev/null @@ -1,30 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/parser-rules.make - -override XSDFLAGS += --generate-polymorphic - -# Build -# -driver: driver.o supermen-pskel.o supermen-pimpl.o - -driver.o: driver.cxx supermen-pimpl.hxx supermen-pskel.hxx -supermen-pimpl.o: supermen-pimpl.cxx supermen-pimpl.hxx supermen-pskel.hxx -supermen-pskel.o: supermen-pskel.cxx supermen-pskel.hxx - -supermen-pskel.hxx supermen-pskel.cxx: supermen.xsd - - -# Test. -# -.PHONY: test -test: driver supermen.xml - ./driver supermen.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f supermen-pskel.?xx supermen-pimpl.o supermen-pskel.o driver.o driver diff --git a/dist/examples/cxx/parser/polymorphism/polymorphism-vc10.vcxproj b/dist/examples/cxx/parser/polymorphism/polymorphism-vc10.vcxproj deleted file mode 100644 index 57c60a3..0000000 --- a/dist/examples/cxx/parser/polymorphism/polymorphism-vc10.vcxproj +++ /dev/null @@ -1,207 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - polymorphism - {E05F914A-490B-4780-9BAB-1ED225B3DBEE} - polymorphism - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/polymorphism/polymorphism-vc10.vcxproj.filters b/dist/examples/cxx/parser/polymorphism/polymorphism-vc10.vcxproj.filters deleted file mode 100644 index eb84ea1..0000000 --- a/dist/examples/cxx/parser/polymorphism/polymorphism-vc10.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - {1B970E5F-EBC0-44A7-A542-7EBFADBF1573} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {B49CCB93-BC13-4222-A005-6785C8220E30} - h;hpp;hxx;hm;inl;inc;xsd - - - {408b97b6-8a71-4f5b-976a-dc6c59b92362} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/polymorphism/polymorphism-vc11.vcxproj b/dist/examples/cxx/parser/polymorphism/polymorphism-vc11.vcxproj deleted file mode 100644 index 19e2659..0000000 --- a/dist/examples/cxx/parser/polymorphism/polymorphism-vc11.vcxproj +++ /dev/null @@ -1,211 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - polymorphism - {E05F914A-490B-4780-9BAB-1ED225B3DBEE} - polymorphism - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/polymorphism/polymorphism-vc11.vcxproj.filters b/dist/examples/cxx/parser/polymorphism/polymorphism-vc11.vcxproj.filters deleted file mode 100644 index eb84ea1..0000000 --- a/dist/examples/cxx/parser/polymorphism/polymorphism-vc11.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - {1B970E5F-EBC0-44A7-A542-7EBFADBF1573} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {B49CCB93-BC13-4222-A005-6785C8220E30} - h;hpp;hxx;hm;inl;inc;xsd - - - {408b97b6-8a71-4f5b-976a-dc6c59b92362} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/polymorphism/polymorphism-vc12.vcxproj b/dist/examples/cxx/parser/polymorphism/polymorphism-vc12.vcxproj deleted file mode 100644 index 775d69d..0000000 --- a/dist/examples/cxx/parser/polymorphism/polymorphism-vc12.vcxproj +++ /dev/null @@ -1,215 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - polymorphism - {E05F914A-490B-4780-9BAB-1ED225B3DBEE} - polymorphism - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/polymorphism/polymorphism-vc12.vcxproj.filters b/dist/examples/cxx/parser/polymorphism/polymorphism-vc12.vcxproj.filters deleted file mode 100644 index eb84ea1..0000000 --- a/dist/examples/cxx/parser/polymorphism/polymorphism-vc12.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - {1B970E5F-EBC0-44A7-A542-7EBFADBF1573} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {B49CCB93-BC13-4222-A005-6785C8220E30} - h;hpp;hxx;hm;inl;inc;xsd - - - {408b97b6-8a71-4f5b-976a-dc6c59b92362} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/polymorphism/polymorphism-vc8.vcproj b/dist/examples/cxx/parser/polymorphism/polymorphism-vc8.vcproj deleted file mode 100644 index fb4f951..0000000 --- a/dist/examples/cxx/parser/polymorphism/polymorphism-vc8.vcproj +++ /dev/null @@ -1,431 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/parser/polymorphism/polymorphism-vc9.vcproj b/dist/examples/cxx/parser/polymorphism/polymorphism-vc9.vcproj deleted file mode 100644 index 9759681..0000000 --- a/dist/examples/cxx/parser/polymorphism/polymorphism-vc9.vcproj +++ /dev/null @@ -1,428 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/parser/polyroot/makefile b/dist/examples/cxx/parser/polyroot/makefile deleted file mode 100644 index 487ad08..0000000 --- a/dist/examples/cxx/parser/polyroot/makefile +++ /dev/null @@ -1,31 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/parser-rules.make - -override XSDFLAGS += --generate-polymorphic - -# Build -# -driver: driver.o supermen-pskel.o supermen-pimpl.o - -driver.o: driver.cxx supermen-pimpl.hxx supermen-pskel.hxx -supermen-pimpl.o: supermen-pimpl.cxx supermen-pimpl.hxx supermen-pskel.hxx -supermen-pskel.o: supermen-pskel.cxx supermen-pskel.hxx - -supermen-pskel.hxx supermen-pskel.cxx: supermen.xsd - - -# Test. -# -.PHONY: test -test: driver person.xml superman.xml batman.xml - ./driver person.xml - ./driver superman.xml - ./driver batman.xml - -# Clean. -# -.PHONY: clean -clean: - rm -f supermen-pskel.?xx supermen-pimpl.o supermen-pskel.o driver.o driver diff --git a/dist/examples/cxx/parser/polyroot/polyroot-vc10.vcxproj b/dist/examples/cxx/parser/polyroot/polyroot-vc10.vcxproj deleted file mode 100644 index 897a3a1..0000000 --- a/dist/examples/cxx/parser/polyroot/polyroot-vc10.vcxproj +++ /dev/null @@ -1,207 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - polyroot - {FB2098FC-CE8C-4A6B-A064-E2705324A16A} - polyroot - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/polyroot/polyroot-vc10.vcxproj.filters b/dist/examples/cxx/parser/polyroot/polyroot-vc10.vcxproj.filters deleted file mode 100644 index 5b0ee29..0000000 --- a/dist/examples/cxx/parser/polyroot/polyroot-vc10.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - {00F2FCE3-0165-405E-B027-F51956F669D1} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {6F6E09B9-C59E-45EE-BC77-C2F22039A485} - h;hpp;hxx;hm;inl;inc;xsd - - - {91582f5b-59e2-4b82-9325-b99cf969649e} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/polyroot/polyroot-vc11.vcxproj b/dist/examples/cxx/parser/polyroot/polyroot-vc11.vcxproj deleted file mode 100644 index 86427ed..0000000 --- a/dist/examples/cxx/parser/polyroot/polyroot-vc11.vcxproj +++ /dev/null @@ -1,211 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - polyroot - {FB2098FC-CE8C-4A6B-A064-E2705324A16A} - polyroot - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/polyroot/polyroot-vc11.vcxproj.filters b/dist/examples/cxx/parser/polyroot/polyroot-vc11.vcxproj.filters deleted file mode 100644 index 5b0ee29..0000000 --- a/dist/examples/cxx/parser/polyroot/polyroot-vc11.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - {00F2FCE3-0165-405E-B027-F51956F669D1} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {6F6E09B9-C59E-45EE-BC77-C2F22039A485} - h;hpp;hxx;hm;inl;inc;xsd - - - {91582f5b-59e2-4b82-9325-b99cf969649e} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/polyroot/polyroot-vc12.vcxproj b/dist/examples/cxx/parser/polyroot/polyroot-vc12.vcxproj deleted file mode 100644 index 079305b..0000000 --- a/dist/examples/cxx/parser/polyroot/polyroot-vc12.vcxproj +++ /dev/null @@ -1,215 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - polyroot - {FB2098FC-CE8C-4A6B-A064-E2705324A16A} - polyroot - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - xsd supermen.xsd - xsd cxx-parser --generate-polymorphic supermen.xsd - supermen-pskel.hxx;supermen-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/polyroot/polyroot-vc12.vcxproj.filters b/dist/examples/cxx/parser/polyroot/polyroot-vc12.vcxproj.filters deleted file mode 100644 index 5b0ee29..0000000 --- a/dist/examples/cxx/parser/polyroot/polyroot-vc12.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - {00F2FCE3-0165-405E-B027-F51956F669D1} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {6F6E09B9-C59E-45EE-BC77-C2F22039A485} - h;hpp;hxx;hm;inl;inc;xsd - - - {91582f5b-59e2-4b82-9325-b99cf969649e} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/polyroot/polyroot-vc8.vcproj b/dist/examples/cxx/parser/polyroot/polyroot-vc8.vcproj deleted file mode 100644 index 322f814..0000000 --- a/dist/examples/cxx/parser/polyroot/polyroot-vc8.vcproj +++ /dev/null @@ -1,431 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/parser/polyroot/polyroot-vc9.vcproj b/dist/examples/cxx/parser/polyroot/polyroot-vc9.vcproj deleted file mode 100644 index fd72439..0000000 --- a/dist/examples/cxx/parser/polyroot/polyroot-vc9.vcproj +++ /dev/null @@ -1,428 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/parser/wildcard/makefile b/dist/examples/cxx/parser/wildcard/makefile deleted file mode 100644 index 924e937..0000000 --- a/dist/examples/cxx/parser/wildcard/makefile +++ /dev/null @@ -1,28 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/parser-rules.make - - -# Build. -# -driver: driver.o email-pskel.o - -driver.o: driver.cxx email-pskel.hxx -email-pskel.o: email-pskel.cxx email-pskel.hxx - -email-pskel.hxx email-pskel.cxx: email.xsd - - -# Test. -# -.PHONY: test -test: driver email.xml - ./driver email.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f email-pskel.?xx email-pskel.o driver.o driver diff --git a/dist/examples/cxx/parser/wildcard/wildcard-vc10.vcxproj b/dist/examples/cxx/parser/wildcard/wildcard-vc10.vcxproj deleted file mode 100644 index adb99cb..0000000 --- a/dist/examples/cxx/parser/wildcard/wildcard-vc10.vcxproj +++ /dev/null @@ -1,201 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - wildcard - {9832425B-38D5-44EC-AED6-3ED4353B24EA} - wildcard - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd email.xsd - xsd cxx-parser email.xsd - email-pskel.hxx;email-pskel.cxx;%(Outputs) - xsd email.xsd - xsd cxx-parser email.xsd - email-pskel.hxx;email-pskel.cxx;%(Outputs) - xsd email.xsd - xsd cxx-parser email.xsd - email-pskel.hxx;email-pskel.cxx;%(Outputs) - xsd email.xsd - xsd cxx-parser email.xsd - email-pskel.hxx;email-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/wildcard/wildcard-vc10.vcxproj.filters b/dist/examples/cxx/parser/wildcard/wildcard-vc10.vcxproj.filters deleted file mode 100644 index 756239f..0000000 --- a/dist/examples/cxx/parser/wildcard/wildcard-vc10.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {F05001BC-BAEB-4D9D-89E4-D19B208F34BF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {CDCB25B7-BCBA-4C74-828E-09B2D7860485} - h;hpp;hxx;hm;inl;inc;xsd - - - {1b27359f-6508-4bb0-96ed-b5a3fdb228c6} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/wildcard/wildcard-vc11.vcxproj b/dist/examples/cxx/parser/wildcard/wildcard-vc11.vcxproj deleted file mode 100644 index e422655..0000000 --- a/dist/examples/cxx/parser/wildcard/wildcard-vc11.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - wildcard - {9832425B-38D5-44EC-AED6-3ED4353B24EA} - wildcard - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd email.xsd - xsd cxx-parser email.xsd - email-pskel.hxx;email-pskel.cxx;%(Outputs) - xsd email.xsd - xsd cxx-parser email.xsd - email-pskel.hxx;email-pskel.cxx;%(Outputs) - xsd email.xsd - xsd cxx-parser email.xsd - email-pskel.hxx;email-pskel.cxx;%(Outputs) - xsd email.xsd - xsd cxx-parser email.xsd - email-pskel.hxx;email-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/wildcard/wildcard-vc11.vcxproj.filters b/dist/examples/cxx/parser/wildcard/wildcard-vc11.vcxproj.filters deleted file mode 100644 index 756239f..0000000 --- a/dist/examples/cxx/parser/wildcard/wildcard-vc11.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {F05001BC-BAEB-4D9D-89E4-D19B208F34BF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {CDCB25B7-BCBA-4C74-828E-09B2D7860485} - h;hpp;hxx;hm;inl;inc;xsd - - - {1b27359f-6508-4bb0-96ed-b5a3fdb228c6} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/wildcard/wildcard-vc12.vcxproj b/dist/examples/cxx/parser/wildcard/wildcard-vc12.vcxproj deleted file mode 100644 index e52e9dc..0000000 --- a/dist/examples/cxx/parser/wildcard/wildcard-vc12.vcxproj +++ /dev/null @@ -1,209 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - wildcard - {9832425B-38D5-44EC-AED6-3ED4353B24EA} - wildcard - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd email.xsd - xsd cxx-parser email.xsd - email-pskel.hxx;email-pskel.cxx;%(Outputs) - xsd email.xsd - xsd cxx-parser email.xsd - email-pskel.hxx;email-pskel.cxx;%(Outputs) - xsd email.xsd - xsd cxx-parser email.xsd - email-pskel.hxx;email-pskel.cxx;%(Outputs) - xsd email.xsd - xsd cxx-parser email.xsd - email-pskel.hxx;email-pskel.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/wildcard/wildcard-vc12.vcxproj.filters b/dist/examples/cxx/parser/wildcard/wildcard-vc12.vcxproj.filters deleted file mode 100644 index 756239f..0000000 --- a/dist/examples/cxx/parser/wildcard/wildcard-vc12.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {F05001BC-BAEB-4D9D-89E4-D19B208F34BF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {CDCB25B7-BCBA-4C74-828E-09B2D7860485} - h;hpp;hxx;hm;inl;inc;xsd - - - {1b27359f-6508-4bb0-96ed-b5a3fdb228c6} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/parser/wildcard/wildcard-vc8.vcproj b/dist/examples/cxx/parser/wildcard/wildcard-vc8.vcproj deleted file mode 100644 index c255eac..0000000 --- a/dist/examples/cxx/parser/wildcard/wildcard-vc8.vcproj +++ /dev/null @@ -1,419 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/parser/wildcard/wildcard-vc9.vcproj b/dist/examples/cxx/parser/wildcard/wildcard-vc9.vcproj deleted file mode 100644 index e481e43..0000000 --- a/dist/examples/cxx/parser/wildcard/wildcard-vc9.vcproj +++ /dev/null @@ -1,416 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/binary/boost/boost-vc10.vcxproj b/dist/examples/cxx/tree/binary/boost/boost-vc10.vcxproj deleted file mode 100644 index 8834226..0000000 --- a/dist/examples/cxx/tree/binary/boost/boost-vc10.vcxproj +++ /dev/null @@ -1,208 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - boost - {0C3A70E2-F673-46B7-B23D-9888266918D5} - boost - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree --generate-ostream --hxx-prologue-file library-prologue.hxx --generate-insertion boost::archive::text_oarchive --generate-extraction boost::archive::text_iarchive library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --hxx-prologue-file library-prologue.hxx --generate-insertion boost::archive::text_oarchive --generate-extraction boost::archive::text_iarchive library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --hxx-prologue-file library-prologue.hxx --generate-insertion boost::archive::text_oarchive --generate-extraction boost::archive::text_iarchive library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --hxx-prologue-file library-prologue.hxx --generate-insertion boost::archive::text_oarchive --generate-extraction boost::archive::text_iarchive library.xsd - library.hxx;library.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/binary/boost/boost-vc10.vcxproj.filters b/dist/examples/cxx/tree/binary/boost/boost-vc10.vcxproj.filters deleted file mode 100644 index edb71a3..0000000 --- a/dist/examples/cxx/tree/binary/boost/boost-vc10.vcxproj.filters +++ /dev/null @@ -1,47 +0,0 @@ - - - - - {22FBBBBD-3A62-471C-867C-8B6F5B3531A9} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {BB6813A9-25E1-49A2-8FCC-FAC9FC4C27FB} - h;hpp;hxx;hm;inl;inc;xsd - - - {458e67fd-1629-41ef-9a2b-66709e69a9bf} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/binary/boost/boost-vc11.vcxproj b/dist/examples/cxx/tree/binary/boost/boost-vc11.vcxproj deleted file mode 100644 index 73a65d5..0000000 --- a/dist/examples/cxx/tree/binary/boost/boost-vc11.vcxproj +++ /dev/null @@ -1,212 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - boost - {0C3A70E2-F673-46B7-B23D-9888266918D5} - boost - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree --generate-ostream --hxx-prologue-file library-prologue.hxx --generate-insertion boost::archive::text_oarchive --generate-extraction boost::archive::text_iarchive library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --hxx-prologue-file library-prologue.hxx --generate-insertion boost::archive::text_oarchive --generate-extraction boost::archive::text_iarchive library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --hxx-prologue-file library-prologue.hxx --generate-insertion boost::archive::text_oarchive --generate-extraction boost::archive::text_iarchive library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --hxx-prologue-file library-prologue.hxx --generate-insertion boost::archive::text_oarchive --generate-extraction boost::archive::text_iarchive library.xsd - library.hxx;library.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/binary/boost/boost-vc11.vcxproj.filters b/dist/examples/cxx/tree/binary/boost/boost-vc11.vcxproj.filters deleted file mode 100644 index edb71a3..0000000 --- a/dist/examples/cxx/tree/binary/boost/boost-vc11.vcxproj.filters +++ /dev/null @@ -1,47 +0,0 @@ - - - - - {22FBBBBD-3A62-471C-867C-8B6F5B3531A9} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {BB6813A9-25E1-49A2-8FCC-FAC9FC4C27FB} - h;hpp;hxx;hm;inl;inc;xsd - - - {458e67fd-1629-41ef-9a2b-66709e69a9bf} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/binary/boost/boost-vc12.vcxproj b/dist/examples/cxx/tree/binary/boost/boost-vc12.vcxproj deleted file mode 100644 index 8c7d2c5..0000000 --- a/dist/examples/cxx/tree/binary/boost/boost-vc12.vcxproj +++ /dev/null @@ -1,216 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - boost - {0C3A70E2-F673-46B7-B23D-9888266918D5} - boost - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree --generate-ostream --hxx-prologue-file library-prologue.hxx --generate-insertion boost::archive::text_oarchive --generate-extraction boost::archive::text_iarchive library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --hxx-prologue-file library-prologue.hxx --generate-insertion boost::archive::text_oarchive --generate-extraction boost::archive::text_iarchive library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --hxx-prologue-file library-prologue.hxx --generate-insertion boost::archive::text_oarchive --generate-extraction boost::archive::text_iarchive library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --hxx-prologue-file library-prologue.hxx --generate-insertion boost::archive::text_oarchive --generate-extraction boost::archive::text_iarchive library.xsd - library.hxx;library.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/binary/boost/boost-vc12.vcxproj.filters b/dist/examples/cxx/tree/binary/boost/boost-vc12.vcxproj.filters deleted file mode 100644 index edb71a3..0000000 --- a/dist/examples/cxx/tree/binary/boost/boost-vc12.vcxproj.filters +++ /dev/null @@ -1,47 +0,0 @@ - - - - - {22FBBBBD-3A62-471C-867C-8B6F5B3531A9} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {BB6813A9-25E1-49A2-8FCC-FAC9FC4C27FB} - h;hpp;hxx;hm;inl;inc;xsd - - - {458e67fd-1629-41ef-9a2b-66709e69a9bf} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/binary/boost/boost-vc8.vcproj b/dist/examples/cxx/tree/binary/boost/boost-vc8.vcproj deleted file mode 100644 index 82d23ae..0000000 --- a/dist/examples/cxx/tree/binary/boost/boost-vc8.vcproj +++ /dev/null @@ -1,435 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/binary/boost/boost-vc9.vcproj b/dist/examples/cxx/tree/binary/boost/boost-vc9.vcproj deleted file mode 100644 index f5369af..0000000 --- a/dist/examples/cxx/tree/binary/boost/boost-vc9.vcproj +++ /dev/null @@ -1,432 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/binary/boost/makefile b/dist/examples/cxx/tree/binary/boost/makefile deleted file mode 100644 index 7c35f02..0000000 --- a/dist/examples/cxx/tree/binary/boost/makefile +++ /dev/null @@ -1,37 +0,0 @@ -root := ../../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -override XSDFLAGS += --generate-ostream \ ---hxx-prologue-file library-prologue.hxx \ ---generate-insertion boost::archive::text_oarchive \ ---generate-extraction boost::archive::text_iarchive - - -override LIBS += -lboost_serialization - - -# Build. -# -driver: driver.o library.o - -library.o: library.cxx library.hxx boost-archive-insertion.hxx boost-archive-extraction.hxx -driver.o: driver.cxx library.hxx boost-archive-insertion.hxx boost-archive-extraction.hxx - -library.cxx library.hxx: library.xsd - - -# Test -# -.PHONY: test -test: driver library.xml - ./driver library.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f library.o library.?xx driver.o driver diff --git a/dist/examples/cxx/tree/binary/cdr/cdr-vc10.vcxproj b/dist/examples/cxx/tree/binary/cdr/cdr-vc10.vcxproj deleted file mode 100644 index 5acfa0e..0000000 --- a/dist/examples/cxx/tree/binary/cdr/cdr-vc10.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - cdr - {A8CC2814-5056-4953-8B4C-E52E72ADD36C} - cdr - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;ACEd.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;ACEd.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;ACE.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;ACE.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion ACE_OutputCDR --generate-extraction ACE_InputCDR library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion ACE_OutputCDR --generate-extraction ACE_InputCDR library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion ACE_OutputCDR --generate-extraction ACE_InputCDR library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion ACE_OutputCDR --generate-extraction ACE_InputCDR library.xsd - library.hxx;library.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/binary/cdr/cdr-vc10.vcxproj.filters b/dist/examples/cxx/tree/binary/cdr/cdr-vc10.vcxproj.filters deleted file mode 100644 index 92ff3ee..0000000 --- a/dist/examples/cxx/tree/binary/cdr/cdr-vc10.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {50AA6317-04BE-45AB-98DD-7A32AEB710CF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {E740B51E-A619-4888-B6B9-566A3C77C60B} - h;hpp;hxx;hm;inl;inc;xsd - - - {37283c57-4a32-48ed-823b-0efdf7cdcf51} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/binary/cdr/cdr-vc11.vcxproj b/dist/examples/cxx/tree/binary/cdr/cdr-vc11.vcxproj deleted file mode 100644 index c87aa4b..0000000 --- a/dist/examples/cxx/tree/binary/cdr/cdr-vc11.vcxproj +++ /dev/null @@ -1,209 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - cdr - {A8CC2814-5056-4953-8B4C-E52E72ADD36C} - cdr - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;ACEd.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;ACEd.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;ACE.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;ACE.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion ACE_OutputCDR --generate-extraction ACE_InputCDR library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion ACE_OutputCDR --generate-extraction ACE_InputCDR library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion ACE_OutputCDR --generate-extraction ACE_InputCDR library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion ACE_OutputCDR --generate-extraction ACE_InputCDR library.xsd - library.hxx;library.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/binary/cdr/cdr-vc11.vcxproj.filters b/dist/examples/cxx/tree/binary/cdr/cdr-vc11.vcxproj.filters deleted file mode 100644 index 92ff3ee..0000000 --- a/dist/examples/cxx/tree/binary/cdr/cdr-vc11.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {50AA6317-04BE-45AB-98DD-7A32AEB710CF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {E740B51E-A619-4888-B6B9-566A3C77C60B} - h;hpp;hxx;hm;inl;inc;xsd - - - {37283c57-4a32-48ed-823b-0efdf7cdcf51} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/binary/cdr/cdr-vc12.vcxproj b/dist/examples/cxx/tree/binary/cdr/cdr-vc12.vcxproj deleted file mode 100644 index e0d6496..0000000 --- a/dist/examples/cxx/tree/binary/cdr/cdr-vc12.vcxproj +++ /dev/null @@ -1,213 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - cdr - {A8CC2814-5056-4953-8B4C-E52E72ADD36C} - cdr - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;ACEd.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;ACEd.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;ACE.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;ACE.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion ACE_OutputCDR --generate-extraction ACE_InputCDR library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion ACE_OutputCDR --generate-extraction ACE_InputCDR library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion ACE_OutputCDR --generate-extraction ACE_InputCDR library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion ACE_OutputCDR --generate-extraction ACE_InputCDR library.xsd - library.hxx;library.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/binary/cdr/cdr-vc12.vcxproj.filters b/dist/examples/cxx/tree/binary/cdr/cdr-vc12.vcxproj.filters deleted file mode 100644 index 92ff3ee..0000000 --- a/dist/examples/cxx/tree/binary/cdr/cdr-vc12.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {50AA6317-04BE-45AB-98DD-7A32AEB710CF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {E740B51E-A619-4888-B6B9-566A3C77C60B} - h;hpp;hxx;hm;inl;inc;xsd - - - {37283c57-4a32-48ed-823b-0efdf7cdcf51} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/binary/cdr/cdr-vc8.vcproj b/dist/examples/cxx/tree/binary/cdr/cdr-vc8.vcproj deleted file mode 100644 index d35171a..0000000 --- a/dist/examples/cxx/tree/binary/cdr/cdr-vc8.vcproj +++ /dev/null @@ -1,423 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/binary/cdr/cdr-vc9.vcproj b/dist/examples/cxx/tree/binary/cdr/cdr-vc9.vcproj deleted file mode 100644 index f379d83..0000000 --- a/dist/examples/cxx/tree/binary/cdr/cdr-vc9.vcproj +++ /dev/null @@ -1,420 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/binary/cdr/makefile b/dist/examples/cxx/tree/binary/cdr/makefile deleted file mode 100644 index a2d9848..0000000 --- a/dist/examples/cxx/tree/binary/cdr/makefile +++ /dev/null @@ -1,35 +0,0 @@ -root := ../../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -override XSDFLAGS += --generate-ostream --generate-insertion ACE_OutputCDR \ ---generate-extraction ACE_InputCDR - - -override LIBS += -lACE - - -# Build. -# -driver: driver.o library.o - -library.o: library.cxx library.hxx -driver.o: driver.cxx library.hxx - -library.cxx library.hxx: library.xsd - - -# Test -# -.PHONY: test -test: driver library.xml - ./driver library.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f library.o library.?xx driver.o driver diff --git a/dist/examples/cxx/tree/binary/makefile b/dist/examples/cxx/tree/binary/makefile deleted file mode 100644 index d337eb5..0000000 --- a/dist/examples/cxx/tree/binary/makefile +++ /dev/null @@ -1,25 +0,0 @@ -dirs := - -ifeq ($(WITH_BOOST),1) -dirs += boost -endif - - -ifeq ($(WITH_ACE),1) -dirs += cdr -endif - -ifeq ($(WITH_XDR),1) -dirs += xdr -endif - - -.PHONY: all $(dirs) - -all: $(dirs) - -$(dirs): - @$(MAKE) -C $@ $(MAKECMDGOALS) - -makefile: ; -% :: $(dirs) ; diff --git a/dist/examples/cxx/tree/binary/xdr/makefile b/dist/examples/cxx/tree/binary/xdr/makefile deleted file mode 100644 index a9123d7..0000000 --- a/dist/examples/cxx/tree/binary/xdr/makefile +++ /dev/null @@ -1,35 +0,0 @@ -root := ../../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -override XSDFLAGS += --generate-ostream --generate-insertion XDR \ ---generate-extraction XDR - - -override LIBS += -lnsl - - -# Build. -# -driver: driver.o library.o - -library.o: library.cxx library.hxx -driver.o: driver.cxx library.hxx - -library.cxx library.hxx: library.xsd - - -# Test -# -.PHONY: test -test: driver library.xml - ./driver library.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f library.o library.?xx driver.o driver diff --git a/dist/examples/cxx/tree/binary/xdr/xdr-vc10.vcxproj b/dist/examples/cxx/tree/binary/xdr/xdr-vc10.vcxproj deleted file mode 100644 index a8cad53..0000000 --- a/dist/examples/cxx/tree/binary/xdr/xdr-vc10.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - xdr - {D9696808-1B73-43C9-A3BB-18DD29776EC5} - xdr - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion XDR --generate-extraction XDR library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion XDR --generate-extraction XDR library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion XDR --generate-extraction XDR library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion XDR --generate-extraction XDR library.xsd - library.hxx;library.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/binary/xdr/xdr-vc10.vcxproj.filters b/dist/examples/cxx/tree/binary/xdr/xdr-vc10.vcxproj.filters deleted file mode 100644 index c9e491f..0000000 --- a/dist/examples/cxx/tree/binary/xdr/xdr-vc10.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {C5A0E74B-63C1-41E3-B291-B85FCC86FDF7} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {FC110C72-7935-49D5-B25E-F96C87BA49E4} - h;hpp;hxx;hm;inl;inc;xsd - - - {b7ff65c1-ff9c-4e2d-869b-e4925d838adb} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/binary/xdr/xdr-vc11.vcxproj b/dist/examples/cxx/tree/binary/xdr/xdr-vc11.vcxproj deleted file mode 100644 index 5c9f9d5..0000000 --- a/dist/examples/cxx/tree/binary/xdr/xdr-vc11.vcxproj +++ /dev/null @@ -1,209 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - xdr - {D9696808-1B73-43C9-A3BB-18DD29776EC5} - xdr - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion XDR --generate-extraction XDR library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion XDR --generate-extraction XDR library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion XDR --generate-extraction XDR library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion XDR --generate-extraction XDR library.xsd - library.hxx;library.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/binary/xdr/xdr-vc11.vcxproj.filters b/dist/examples/cxx/tree/binary/xdr/xdr-vc11.vcxproj.filters deleted file mode 100644 index c9e491f..0000000 --- a/dist/examples/cxx/tree/binary/xdr/xdr-vc11.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {C5A0E74B-63C1-41E3-B291-B85FCC86FDF7} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {FC110C72-7935-49D5-B25E-F96C87BA49E4} - h;hpp;hxx;hm;inl;inc;xsd - - - {b7ff65c1-ff9c-4e2d-869b-e4925d838adb} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/binary/xdr/xdr-vc12.vcxproj b/dist/examples/cxx/tree/binary/xdr/xdr-vc12.vcxproj deleted file mode 100644 index e3be342..0000000 --- a/dist/examples/cxx/tree/binary/xdr/xdr-vc12.vcxproj +++ /dev/null @@ -1,213 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - xdr - {D9696808-1B73-43C9-A3BB-18DD29776EC5} - xdr - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion XDR --generate-extraction XDR library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion XDR --generate-extraction XDR library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion XDR --generate-extraction XDR library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-insertion XDR --generate-extraction XDR library.xsd - library.hxx;library.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/binary/xdr/xdr-vc12.vcxproj.filters b/dist/examples/cxx/tree/binary/xdr/xdr-vc12.vcxproj.filters deleted file mode 100644 index c9e491f..0000000 --- a/dist/examples/cxx/tree/binary/xdr/xdr-vc12.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {C5A0E74B-63C1-41E3-B291-B85FCC86FDF7} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {FC110C72-7935-49D5-B25E-F96C87BA49E4} - h;hpp;hxx;hm;inl;inc;xsd - - - {b7ff65c1-ff9c-4e2d-869b-e4925d838adb} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/binary/xdr/xdr-vc8.vcproj b/dist/examples/cxx/tree/binary/xdr/xdr-vc8.vcproj deleted file mode 100644 index f83c026..0000000 --- a/dist/examples/cxx/tree/binary/xdr/xdr-vc8.vcproj +++ /dev/null @@ -1,423 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/binary/xdr/xdr-vc9.vcproj b/dist/examples/cxx/tree/binary/xdr/xdr-vc9.vcproj deleted file mode 100644 index 34ca6b4..0000000 --- a/dist/examples/cxx/tree/binary/xdr/xdr-vc9.vcproj +++ /dev/null @@ -1,420 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/caching/caching-vc10.vcxproj b/dist/examples/cxx/tree/caching/caching-vc10.vcxproj deleted file mode 100644 index 7bb6670..0000000 --- a/dist/examples/cxx/tree/caching/caching-vc10.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - caching - {932D8CD0-4E11-4C3A-9084-4D30DE75C2B7} - caching - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree library.xsd - library.hxx;library.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/caching/caching-vc10.vcxproj.filters b/dist/examples/cxx/tree/caching/caching-vc10.vcxproj.filters deleted file mode 100644 index 07ab0e9..0000000 --- a/dist/examples/cxx/tree/caching/caching-vc10.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {8953E6CC-4E46-4D97-9704-CE8F76672843} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {AA1A2DB4-3798-4A0C-9339-FAA57753A0AC} - h;hpp;hxx;hm;inl;inc;xsd - - - {88b19602-75bf-44d6-a995-f5e213e36528} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/caching/caching-vc11.vcxproj b/dist/examples/cxx/tree/caching/caching-vc11.vcxproj deleted file mode 100644 index 1e8d543..0000000 --- a/dist/examples/cxx/tree/caching/caching-vc11.vcxproj +++ /dev/null @@ -1,209 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - caching - {932D8CD0-4E11-4C3A-9084-4D30DE75C2B7} - caching - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree library.xsd - library.hxx;library.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/caching/caching-vc11.vcxproj.filters b/dist/examples/cxx/tree/caching/caching-vc11.vcxproj.filters deleted file mode 100644 index 07ab0e9..0000000 --- a/dist/examples/cxx/tree/caching/caching-vc11.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {8953E6CC-4E46-4D97-9704-CE8F76672843} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {AA1A2DB4-3798-4A0C-9339-FAA57753A0AC} - h;hpp;hxx;hm;inl;inc;xsd - - - {88b19602-75bf-44d6-a995-f5e213e36528} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/caching/caching-vc12.vcxproj b/dist/examples/cxx/tree/caching/caching-vc12.vcxproj deleted file mode 100644 index 304d2c2..0000000 --- a/dist/examples/cxx/tree/caching/caching-vc12.vcxproj +++ /dev/null @@ -1,213 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - caching - {932D8CD0-4E11-4C3A-9084-4D30DE75C2B7} - caching - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree library.xsd - library.hxx;library.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/caching/caching-vc12.vcxproj.filters b/dist/examples/cxx/tree/caching/caching-vc12.vcxproj.filters deleted file mode 100644 index 07ab0e9..0000000 --- a/dist/examples/cxx/tree/caching/caching-vc12.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {8953E6CC-4E46-4D97-9704-CE8F76672843} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {AA1A2DB4-3798-4A0C-9339-FAA57753A0AC} - h;hpp;hxx;hm;inl;inc;xsd - - - {88b19602-75bf-44d6-a995-f5e213e36528} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/caching/caching-vc8.vcproj b/dist/examples/cxx/tree/caching/caching-vc8.vcproj deleted file mode 100644 index 3d75cb6..0000000 --- a/dist/examples/cxx/tree/caching/caching-vc8.vcproj +++ /dev/null @@ -1,423 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/caching/caching-vc9.vcproj b/dist/examples/cxx/tree/caching/caching-vc9.vcproj deleted file mode 100644 index b356172..0000000 --- a/dist/examples/cxx/tree/caching/caching-vc9.vcproj +++ /dev/null @@ -1,420 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/caching/makefile b/dist/examples/cxx/tree/caching/makefile deleted file mode 100644 index d8d33fd..0000000 --- a/dist/examples/cxx/tree/caching/makefile +++ /dev/null @@ -1,28 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -# Build. -# -driver: driver.o library.o - -library.o: library.cxx library.hxx -driver.o: driver.cxx library.hxx - -library.cxx library.hxx: library.xsd - - -# Test -# -.PHONY: test -test: driver library.xml - ./driver library.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f library.o library.?xx driver.o driver diff --git a/dist/examples/cxx/tree/compression/compression-vc10.vcxproj b/dist/examples/cxx/tree/compression/compression-vc10.vcxproj deleted file mode 100644 index 0f084fb..0000000 --- a/dist/examples/cxx/tree/compression/compression-vc10.vcxproj +++ /dev/null @@ -1,209 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - compression - {AA385EB4-7352-4865-9C5C-9F0DE7BA0060} - compression - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;zdll.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;zdll.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;zdll.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;zdll.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-serialization library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-serialization library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-serialization library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-serialization library.xsd - library.hxx;library.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/compression/compression-vc10.vcxproj.filters b/dist/examples/cxx/tree/compression/compression-vc10.vcxproj.filters deleted file mode 100644 index 0156a51..0000000 --- a/dist/examples/cxx/tree/compression/compression-vc10.vcxproj.filters +++ /dev/null @@ -1,50 +0,0 @@ - - - - - {E38C94E8-B473-4B88-9C42-BD34C81BC24B} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {408177AE-D480-4933-AED3-705D39F15C9F} - h;hpp;hxx;hm;inl;inc;xsd - - - {0e78ae69-359d-42ea-8a3c-c60040f3aa2c} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/compression/compression-vc11.vcxproj b/dist/examples/cxx/tree/compression/compression-vc11.vcxproj deleted file mode 100644 index 76c9887..0000000 --- a/dist/examples/cxx/tree/compression/compression-vc11.vcxproj +++ /dev/null @@ -1,213 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - compression - {AA385EB4-7352-4865-9C5C-9F0DE7BA0060} - compression - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;zdll.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;zdll.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;zdll.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;zdll.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-serialization library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-serialization library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-serialization library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-serialization library.xsd - library.hxx;library.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/compression/compression-vc11.vcxproj.filters b/dist/examples/cxx/tree/compression/compression-vc11.vcxproj.filters deleted file mode 100644 index 0156a51..0000000 --- a/dist/examples/cxx/tree/compression/compression-vc11.vcxproj.filters +++ /dev/null @@ -1,50 +0,0 @@ - - - - - {E38C94E8-B473-4B88-9C42-BD34C81BC24B} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {408177AE-D480-4933-AED3-705D39F15C9F} - h;hpp;hxx;hm;inl;inc;xsd - - - {0e78ae69-359d-42ea-8a3c-c60040f3aa2c} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/compression/compression-vc12.vcxproj b/dist/examples/cxx/tree/compression/compression-vc12.vcxproj deleted file mode 100644 index 1e7a3b7..0000000 --- a/dist/examples/cxx/tree/compression/compression-vc12.vcxproj +++ /dev/null @@ -1,217 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - compression - {AA385EB4-7352-4865-9C5C-9F0DE7BA0060} - compression - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;zdll.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;zdll.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;zdll.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;zdll.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-serialization library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-serialization library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-serialization library.xsd - library.hxx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-ostream --generate-serialization library.xsd - library.hxx;library.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/compression/compression-vc12.vcxproj.filters b/dist/examples/cxx/tree/compression/compression-vc12.vcxproj.filters deleted file mode 100644 index 0156a51..0000000 --- a/dist/examples/cxx/tree/compression/compression-vc12.vcxproj.filters +++ /dev/null @@ -1,50 +0,0 @@ - - - - - {E38C94E8-B473-4B88-9C42-BD34C81BC24B} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {408177AE-D480-4933-AED3-705D39F15C9F} - h;hpp;hxx;hm;inl;inc;xsd - - - {0e78ae69-359d-42ea-8a3c-c60040f3aa2c} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/compression/compression-vc8.vcproj b/dist/examples/cxx/tree/compression/compression-vc8.vcproj deleted file mode 100644 index 85b45d8..0000000 --- a/dist/examples/cxx/tree/compression/compression-vc8.vcproj +++ /dev/null @@ -1,435 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/compression/compression-vc9.vcproj b/dist/examples/cxx/tree/compression/compression-vc9.vcproj deleted file mode 100644 index 92ea1da..0000000 --- a/dist/examples/cxx/tree/compression/compression-vc9.vcproj +++ /dev/null @@ -1,432 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/compression/makefile b/dist/examples/cxx/tree/compression/makefile deleted file mode 100644 index f55c6ad..0000000 --- a/dist/examples/cxx/tree/compression/makefile +++ /dev/null @@ -1,37 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -override XSDFLAGS += --generate-ostream --generate-serialization - -override LIBS += -lz - -# Build. -# -driver: driver.o library.o compressed-format-target.o compressed-input-source.o - -library.o: library.cxx library.hxx -driver.o: driver.cxx library.hxx compressed-format-target.hxx \ -compressed-input-source.hxx -compressed-format-target.o: compressed-format-target.cxx -compressed-input-source.o: compressed-input-source.cxx - -library.cxx library.hxx: library.xsd - - -# Test -# -.PHONY: test -test: driver library.xml.gz - ./driver library.xml.gz - - -# Clean. -# -.PHONY: clean -clean: - rm -f library.o library.?xx driver.o compressed-format-target.o \ -compressed-input-source.o driver out.xml.gz - diff --git a/dist/examples/cxx/tree/custom/calendar/calendar-vc10.vcxproj b/dist/examples/cxx/tree/custom/calendar/calendar-vc10.vcxproj deleted file mode 100644 index 5d66876..0000000 --- a/dist/examples/cxx/tree/custom/calendar/calendar-vc10.vcxproj +++ /dev/null @@ -1,229 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - calendar - {2DB41EF7-0BED-45BA-A311-44D2719BFE09} - calendar - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --custom-type date --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --custom-type date --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --custom-type date --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --custom-type date --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - xsd calendar.xsd - xsd cxx-tree --generate-inline --extern-xml-schema xml-schema.xsd calendar.xsd - xml-schema.hxx;%(AdditionalInputs) - calendar.hxx;calendar.ixx;calendar.cxx;%(Outputs) - xsd calendar.xsd - xsd cxx-tree --generate-inline --extern-xml-schema xml-schema.xsd calendar.xsd - xml-schema.hxx;%(AdditionalInputs) - calendar.hxx;calendar.ixx;calendar.cxx;%(Outputs) - xsd calendar.xsd - xsd cxx-tree --generate-inline --extern-xml-schema xml-schema.xsd calendar.xsd - calendar.hxx;calendar.ixx;calendar.cxx;%(Outputs) - xsd calendar.xsd - xsd cxx-tree --generate-inline --extern-xml-schema xml-schema.xsd calendar.xsd - calendar.hxx;calendar.ixx;calendar.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/calendar/calendar-vc10.vcxproj.filters b/dist/examples/cxx/tree/custom/calendar/calendar-vc10.vcxproj.filters deleted file mode 100644 index 943a2dc..0000000 --- a/dist/examples/cxx/tree/custom/calendar/calendar-vc10.vcxproj.filters +++ /dev/null @@ -1,54 +0,0 @@ - - - - - {1F206676-7422-4DD5-94C3-7B9B2EC9C2D6} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {8D4FED5E-FA2A-44AB-94AC-C8F302E2E1F3} - h;hpp;hxx;hm;inl;inc;xsd - - - {5c4bcf4f-9ad2-4a82-adfb-91528fe6f2e5} - ixx - - - {df5d1e63-29c7-4626-853a-34fc5c7f7443} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/calendar/calendar-vc11.vcxproj b/dist/examples/cxx/tree/custom/calendar/calendar-vc11.vcxproj deleted file mode 100644 index aea4aab..0000000 --- a/dist/examples/cxx/tree/custom/calendar/calendar-vc11.vcxproj +++ /dev/null @@ -1,233 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - calendar - {2DB41EF7-0BED-45BA-A311-44D2719BFE09} - calendar - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --custom-type date --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --custom-type date --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --custom-type date --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --custom-type date --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - xsd calendar.xsd - xsd cxx-tree --generate-inline --extern-xml-schema xml-schema.xsd calendar.xsd - xml-schema.hxx;%(AdditionalInputs) - calendar.hxx;calendar.ixx;calendar.cxx;%(Outputs) - xsd calendar.xsd - xsd cxx-tree --generate-inline --extern-xml-schema xml-schema.xsd calendar.xsd - xml-schema.hxx;%(AdditionalInputs) - calendar.hxx;calendar.ixx;calendar.cxx;%(Outputs) - xsd calendar.xsd - xsd cxx-tree --generate-inline --extern-xml-schema xml-schema.xsd calendar.xsd - calendar.hxx;calendar.ixx;calendar.cxx;%(Outputs) - xsd calendar.xsd - xsd cxx-tree --generate-inline --extern-xml-schema xml-schema.xsd calendar.xsd - calendar.hxx;calendar.ixx;calendar.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/calendar/calendar-vc11.vcxproj.filters b/dist/examples/cxx/tree/custom/calendar/calendar-vc11.vcxproj.filters deleted file mode 100644 index 943a2dc..0000000 --- a/dist/examples/cxx/tree/custom/calendar/calendar-vc11.vcxproj.filters +++ /dev/null @@ -1,54 +0,0 @@ - - - - - {1F206676-7422-4DD5-94C3-7B9B2EC9C2D6} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {8D4FED5E-FA2A-44AB-94AC-C8F302E2E1F3} - h;hpp;hxx;hm;inl;inc;xsd - - - {5c4bcf4f-9ad2-4a82-adfb-91528fe6f2e5} - ixx - - - {df5d1e63-29c7-4626-853a-34fc5c7f7443} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/calendar/calendar-vc12.vcxproj b/dist/examples/cxx/tree/custom/calendar/calendar-vc12.vcxproj deleted file mode 100644 index d259aa3..0000000 --- a/dist/examples/cxx/tree/custom/calendar/calendar-vc12.vcxproj +++ /dev/null @@ -1,237 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - calendar - {2DB41EF7-0BED-45BA-A311-44D2719BFE09} - calendar - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --custom-type date --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --custom-type date --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --custom-type date --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --custom-type date --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - xsd calendar.xsd - xsd cxx-tree --generate-inline --extern-xml-schema xml-schema.xsd calendar.xsd - xml-schema.hxx;%(AdditionalInputs) - calendar.hxx;calendar.ixx;calendar.cxx;%(Outputs) - xsd calendar.xsd - xsd cxx-tree --generate-inline --extern-xml-schema xml-schema.xsd calendar.xsd - xml-schema.hxx;%(AdditionalInputs) - calendar.hxx;calendar.ixx;calendar.cxx;%(Outputs) - xsd calendar.xsd - xsd cxx-tree --generate-inline --extern-xml-schema xml-schema.xsd calendar.xsd - calendar.hxx;calendar.ixx;calendar.cxx;%(Outputs) - xsd calendar.xsd - xsd cxx-tree --generate-inline --extern-xml-schema xml-schema.xsd calendar.xsd - calendar.hxx;calendar.ixx;calendar.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/calendar/calendar-vc12.vcxproj.filters b/dist/examples/cxx/tree/custom/calendar/calendar-vc12.vcxproj.filters deleted file mode 100644 index 943a2dc..0000000 --- a/dist/examples/cxx/tree/custom/calendar/calendar-vc12.vcxproj.filters +++ /dev/null @@ -1,54 +0,0 @@ - - - - - {1F206676-7422-4DD5-94C3-7B9B2EC9C2D6} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {8D4FED5E-FA2A-44AB-94AC-C8F302E2E1F3} - h;hpp;hxx;hm;inl;inc;xsd - - - {5c4bcf4f-9ad2-4a82-adfb-91528fe6f2e5} - ixx - - - {df5d1e63-29c7-4626-853a-34fc5c7f7443} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/calendar/calendar-vc8.vcproj b/dist/examples/cxx/tree/custom/calendar/calendar-vc8.vcproj deleted file mode 100644 index ea4e64d..0000000 --- a/dist/examples/cxx/tree/custom/calendar/calendar-vc8.vcproj +++ /dev/null @@ -1,456 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/custom/calendar/calendar-vc9.vcproj b/dist/examples/cxx/tree/custom/calendar/calendar-vc9.vcproj deleted file mode 100644 index 6f0186e..0000000 --- a/dist/examples/cxx/tree/custom/calendar/calendar-vc9.vcproj +++ /dev/null @@ -1,453 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/custom/calendar/makefile b/dist/examples/cxx/tree/custom/calendar/makefile deleted file mode 100644 index 009d647..0000000 --- a/dist/examples/cxx/tree/custom/calendar/makefile +++ /dev/null @@ -1,42 +0,0 @@ -root := ../../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -override XSDFLAGS += --generate-inline --extern-xml-schema xml-schema.xsd - -override LIBS += -lboost_date_time - - -# Build. -# -driver: driver.o calendar.o xml-schema-custom.o - -driver.o: driver.cxx calendar.ixx calendar.hxx xml-schema.hxx xml-schema-custom.hxx -calendar.o: calendar.cxx calendar.ixx calendar.hxx xml-schema.hxx xml-schema-custom.hxx -xml-schema-custom.o: xml-schema.hxx xml-schema-custom.hxx - -calendar.cxx calendar.ixx calendar.hxx: calendar.xsd - -# Generate header for XML Schema namespace. -# -XML_SCHEMA_XSDFLAGS := --generate-xml-schema --custom-type date \ ---hxx-epilogue '\#include "xml-schema-custom.hxx"' - -xml-schema.hxx: - $(XSD) cxx-tree $(XML_SCHEMA_XSDFLAGS) xml-schema.xsd - - -# Test -# -.PHONY: test -test: driver calendar.xml - ./driver calendar.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f xml-schema.hxx xml-schema-custom.o calendar.o calendar.?xx driver.o driver diff --git a/dist/examples/cxx/tree/custom/comments/comments-vc10.vcxproj b/dist/examples/cxx/tree/custom/comments/comments-vc10.vcxproj deleted file mode 100644 index 3e7e6b4..0000000 --- a/dist/examples/cxx/tree/custom/comments/comments-vc10.vcxproj +++ /dev/null @@ -1,231 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - comments - {262E34D2-48D2-4657-9DB2-F01FFDCEA295} - comments - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type anyType=/type_base --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type anyType=/type_base --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type anyType=/type_base --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type anyType=/type_base --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - - - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd people.xsd - xml-schema.hxx;%(AdditionalInputs) - people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd people.xsd - xml-schema.hxx;%(AdditionalInputs) - people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd people.xsd - people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd people.xsd - people.hxx;people.ixx;people.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/comments/comments-vc10.vcxproj.filters b/dist/examples/cxx/tree/custom/comments/comments-vc10.vcxproj.filters deleted file mode 100644 index 934cabe..0000000 --- a/dist/examples/cxx/tree/custom/comments/comments-vc10.vcxproj.filters +++ /dev/null @@ -1,60 +0,0 @@ - - - - - {97CD019E-CFDE-4879-AB8C-97DB3B526F92} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {8E3E001B-1C7C-4383-A18D-B83AA525773F} - h;hpp;hxx;hm;inl;inc;xsd - - - {07ed52c5-d0a0-4659-9a65-2ee052612d2c} - ixx - - - {515a4811-9a34-429e-9c6d-3b771934d8db} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/comments/comments-vc11.vcxproj b/dist/examples/cxx/tree/custom/comments/comments-vc11.vcxproj deleted file mode 100644 index b96f28e..0000000 --- a/dist/examples/cxx/tree/custom/comments/comments-vc11.vcxproj +++ /dev/null @@ -1,235 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - comments - {262E34D2-48D2-4657-9DB2-F01FFDCEA295} - comments - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type anyType=/type_base --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type anyType=/type_base --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type anyType=/type_base --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type anyType=/type_base --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - - - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd people.xsd - xml-schema.hxx;%(AdditionalInputs) - people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd people.xsd - xml-schema.hxx;%(AdditionalInputs) - people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd people.xsd - people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd people.xsd - people.hxx;people.ixx;people.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/comments/comments-vc11.vcxproj.filters b/dist/examples/cxx/tree/custom/comments/comments-vc11.vcxproj.filters deleted file mode 100644 index 934cabe..0000000 --- a/dist/examples/cxx/tree/custom/comments/comments-vc11.vcxproj.filters +++ /dev/null @@ -1,60 +0,0 @@ - - - - - {97CD019E-CFDE-4879-AB8C-97DB3B526F92} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {8E3E001B-1C7C-4383-A18D-B83AA525773F} - h;hpp;hxx;hm;inl;inc;xsd - - - {07ed52c5-d0a0-4659-9a65-2ee052612d2c} - ixx - - - {515a4811-9a34-429e-9c6d-3b771934d8db} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/comments/comments-vc12.vcxproj b/dist/examples/cxx/tree/custom/comments/comments-vc12.vcxproj deleted file mode 100644 index e237ff8..0000000 --- a/dist/examples/cxx/tree/custom/comments/comments-vc12.vcxproj +++ /dev/null @@ -1,239 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - comments - {262E34D2-48D2-4657-9DB2-F01FFDCEA295} - comments - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type anyType=/type_base --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type anyType=/type_base --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type anyType=/type_base --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type anyType=/type_base --hxx-epilogue "#include \"xml-schema-custom.hxx\"" xml-schema.xsd - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - - - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd people.xsd - xml-schema.hxx;%(AdditionalInputs) - people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd people.xsd - xml-schema.hxx;%(AdditionalInputs) - people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd people.xsd - people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd people.xsd - people.hxx;people.ixx;people.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/comments/comments-vc12.vcxproj.filters b/dist/examples/cxx/tree/custom/comments/comments-vc12.vcxproj.filters deleted file mode 100644 index 934cabe..0000000 --- a/dist/examples/cxx/tree/custom/comments/comments-vc12.vcxproj.filters +++ /dev/null @@ -1,60 +0,0 @@ - - - - - {97CD019E-CFDE-4879-AB8C-97DB3B526F92} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {8E3E001B-1C7C-4383-A18D-B83AA525773F} - h;hpp;hxx;hm;inl;inc;xsd - - - {07ed52c5-d0a0-4659-9a65-2ee052612d2c} - ixx - - - {515a4811-9a34-429e-9c6d-3b771934d8db} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/comments/comments-vc8.vcproj b/dist/examples/cxx/tree/custom/comments/comments-vc8.vcproj deleted file mode 100644 index 2093acf..0000000 --- a/dist/examples/cxx/tree/custom/comments/comments-vc8.vcproj +++ /dev/null @@ -1,464 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/custom/comments/comments-vc9.vcproj b/dist/examples/cxx/tree/custom/comments/comments-vc9.vcproj deleted file mode 100644 index 43281c6..0000000 --- a/dist/examples/cxx/tree/custom/comments/comments-vc9.vcproj +++ /dev/null @@ -1,461 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/custom/comments/makefile b/dist/examples/cxx/tree/custom/comments/makefile deleted file mode 100644 index 442ab86..0000000 --- a/dist/examples/cxx/tree/custom/comments/makefile +++ /dev/null @@ -1,49 +0,0 @@ -root := ../../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -override XSDFLAGS += --generate-inline --generate-serialization \ ---extern-xml-schema xml-schema.xsd - - -# Build. -# -driver: driver.o people.o xml-schema-custom.o dom-parse.o - -driver.o: driver.cxx dom-parse.hxx people.ixx people.hxx xml-schema.hxx xml-schema-custom.hxx -people.o: people.cxx people.ixx people.hxx xml-schema.hxx xml-schema-custom.hxx -xml-schema-custom.o: xml-schema.hxx xml-schema-custom.hxx -dom-parse.o: dom-parse.cxx dom-parse.hxx - -people.cxx people.ixx people.hxx: people.xsd - -# Generate header for XML Schema namespace. -# -XML_SCHEMA_XSDFLAGS := --generate-xml-schema --generate-serialization \ ---hxx-epilogue '\#include "xml-schema-custom.hxx"' - -ifneq ($(shell uname -o 2>&1),Msys) -XML_SCHEMA_XSDFLAGS += --custom-type anyType=/type_base -else -# Prevent MSYS from converting / to Windows path. -XML_SCHEMA_XSDFLAGS += --custom-type anyType=//type_base -endif - -xml-schema.hxx: - $(XSD) cxx-tree $(XML_SCHEMA_XSDFLAGS) xml-schema.xsd - - -# Test -# -.PHONY: test -test: driver people.xml - ./driver people.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f xml-schema.hxx xml-schema-custom.o people.o people.?xx dom-parse.o driver.o driver diff --git a/dist/examples/cxx/tree/custom/contacts/contacts-vc10.vcxproj b/dist/examples/cxx/tree/custom/contacts/contacts-vc10.vcxproj deleted file mode 100644 index e43ef84..0000000 --- a/dist/examples/cxx/tree/custom/contacts/contacts-vc10.vcxproj +++ /dev/null @@ -1,208 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - contacts - {9FB807C1-53EE-4E71-812F-89E8BE6FCB43} - contacts - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - xsd contacts.xsd - xsd cxx-tree --generate-inline --custom-type contact=/contact_base --hxx-epilogue "#include \"contacts-custom.hxx\"" contacts.xsd - contacts.hxx;contacts.ixx;contacts.cxx;%(Outputs) - xsd contacts.xsd - xsd cxx-tree --generate-inline --custom-type contact=/contact_base --hxx-epilogue "#include \"contacts-custom.hxx\"" contacts.xsd - contacts.hxx;contacts.ixx;contacts.cxx;%(Outputs) - xsd contacts.xsd - xsd cxx-tree --generate-inline --custom-type contact=/contact_base --hxx-epilogue "#include \"contacts-custom.hxx\"" contacts.xsd - contacts.hxx;contacts.ixx;contacts.cxx;%(Outputs) - xsd contacts.xsd - xsd cxx-tree --generate-inline --custom-type contact=/contact_base --hxx-epilogue "#include \"contacts-custom.hxx\"" contacts.xsd - contacts.hxx;contacts.ixx;contacts.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/contacts/contacts-vc10.vcxproj.filters b/dist/examples/cxx/tree/custom/contacts/contacts-vc10.vcxproj.filters deleted file mode 100644 index 4435f19..0000000 --- a/dist/examples/cxx/tree/custom/contacts/contacts-vc10.vcxproj.filters +++ /dev/null @@ -1,51 +0,0 @@ - - - - - {2E28B5D5-6E1D-434A-BFE2-2162751B243B} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {92523A51-9884-450F-A581-5618AB14A9E3} - h;hpp;hxx;hm;inl;inc;xsd - - - {63214694-d62f-4e29-965b-bc5ecd1ac8b8} - ixx - - - {8b44177f-b842-4c6c-bfb8-c25e433bc0a3} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/contacts/contacts-vc11.vcxproj b/dist/examples/cxx/tree/custom/contacts/contacts-vc11.vcxproj deleted file mode 100644 index 0059939..0000000 --- a/dist/examples/cxx/tree/custom/contacts/contacts-vc11.vcxproj +++ /dev/null @@ -1,212 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - contacts - {9FB807C1-53EE-4E71-812F-89E8BE6FCB43} - contacts - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - xsd contacts.xsd - xsd cxx-tree --generate-inline --custom-type contact=/contact_base --hxx-epilogue "#include \"contacts-custom.hxx\"" contacts.xsd - contacts.hxx;contacts.ixx;contacts.cxx;%(Outputs) - xsd contacts.xsd - xsd cxx-tree --generate-inline --custom-type contact=/contact_base --hxx-epilogue "#include \"contacts-custom.hxx\"" contacts.xsd - contacts.hxx;contacts.ixx;contacts.cxx;%(Outputs) - xsd contacts.xsd - xsd cxx-tree --generate-inline --custom-type contact=/contact_base --hxx-epilogue "#include \"contacts-custom.hxx\"" contacts.xsd - contacts.hxx;contacts.ixx;contacts.cxx;%(Outputs) - xsd contacts.xsd - xsd cxx-tree --generate-inline --custom-type contact=/contact_base --hxx-epilogue "#include \"contacts-custom.hxx\"" contacts.xsd - contacts.hxx;contacts.ixx;contacts.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/contacts/contacts-vc11.vcxproj.filters b/dist/examples/cxx/tree/custom/contacts/contacts-vc11.vcxproj.filters deleted file mode 100644 index 4435f19..0000000 --- a/dist/examples/cxx/tree/custom/contacts/contacts-vc11.vcxproj.filters +++ /dev/null @@ -1,51 +0,0 @@ - - - - - {2E28B5D5-6E1D-434A-BFE2-2162751B243B} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {92523A51-9884-450F-A581-5618AB14A9E3} - h;hpp;hxx;hm;inl;inc;xsd - - - {63214694-d62f-4e29-965b-bc5ecd1ac8b8} - ixx - - - {8b44177f-b842-4c6c-bfb8-c25e433bc0a3} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/contacts/contacts-vc12.vcxproj b/dist/examples/cxx/tree/custom/contacts/contacts-vc12.vcxproj deleted file mode 100644 index f955bda..0000000 --- a/dist/examples/cxx/tree/custom/contacts/contacts-vc12.vcxproj +++ /dev/null @@ -1,216 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - contacts - {9FB807C1-53EE-4E71-812F-89E8BE6FCB43} - contacts - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - xsd contacts.xsd - xsd cxx-tree --generate-inline --custom-type contact=/contact_base --hxx-epilogue "#include \"contacts-custom.hxx\"" contacts.xsd - contacts.hxx;contacts.ixx;contacts.cxx;%(Outputs) - xsd contacts.xsd - xsd cxx-tree --generate-inline --custom-type contact=/contact_base --hxx-epilogue "#include \"contacts-custom.hxx\"" contacts.xsd - contacts.hxx;contacts.ixx;contacts.cxx;%(Outputs) - xsd contacts.xsd - xsd cxx-tree --generate-inline --custom-type contact=/contact_base --hxx-epilogue "#include \"contacts-custom.hxx\"" contacts.xsd - contacts.hxx;contacts.ixx;contacts.cxx;%(Outputs) - xsd contacts.xsd - xsd cxx-tree --generate-inline --custom-type contact=/contact_base --hxx-epilogue "#include \"contacts-custom.hxx\"" contacts.xsd - contacts.hxx;contacts.ixx;contacts.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/contacts/contacts-vc12.vcxproj.filters b/dist/examples/cxx/tree/custom/contacts/contacts-vc12.vcxproj.filters deleted file mode 100644 index 4435f19..0000000 --- a/dist/examples/cxx/tree/custom/contacts/contacts-vc12.vcxproj.filters +++ /dev/null @@ -1,51 +0,0 @@ - - - - - {2E28B5D5-6E1D-434A-BFE2-2162751B243B} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {92523A51-9884-450F-A581-5618AB14A9E3} - h;hpp;hxx;hm;inl;inc;xsd - - - {63214694-d62f-4e29-965b-bc5ecd1ac8b8} - ixx - - - {8b44177f-b842-4c6c-bfb8-c25e433bc0a3} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/contacts/contacts-vc8.vcproj b/dist/examples/cxx/tree/custom/contacts/contacts-vc8.vcproj deleted file mode 100644 index a7985ee..0000000 --- a/dist/examples/cxx/tree/custom/contacts/contacts-vc8.vcproj +++ /dev/null @@ -1,440 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/custom/contacts/contacts-vc9.vcproj b/dist/examples/cxx/tree/custom/contacts/contacts-vc9.vcproj deleted file mode 100644 index 6305933..0000000 --- a/dist/examples/cxx/tree/custom/contacts/contacts-vc9.vcproj +++ /dev/null @@ -1,437 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/custom/contacts/makefile b/dist/examples/cxx/tree/custom/contacts/makefile deleted file mode 100644 index 37f895a..0000000 --- a/dist/examples/cxx/tree/custom/contacts/makefile +++ /dev/null @@ -1,39 +0,0 @@ -root := ../../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -override XSDFLAGS += --generate-inline \ ---hxx-epilogue '\#include "contacts-custom.hxx"' - -ifneq ($(shell uname -o 2>&1),Msys) -override XSDFLAGS += --custom-type contact=/contact_base -else -# Prevent MSYS from converting / to Windows path. -override XSDFLAGS += --custom-type contact=//contact_base -endif - -# Build. -# -driver: driver.o contacts.o contacts-custom.o - -contacts.o: contacts.cxx contacts.ixx contacts.hxx contacts-custom.hxx -driver.o: driver.cxx contacts.ixx contacts.hxx contacts-custom.hxx -contacts-custom.o: contacts-custom.cxx contacts.ixx contacts.hxx contacts-custom.hxx - -contacts.cxx contacts.hxx contacts.ixx: contacts.xsd - - -# Test -# -.PHONY: test -test: driver contacts.xml - ./driver contacts.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f contacts-custom.o contacts.o contacts.?xx driver.o driver diff --git a/dist/examples/cxx/tree/custom/double/double-vc10.vcxproj b/dist/examples/cxx/tree/custom/double/double-vc10.vcxproj deleted file mode 100644 index fcedc48..0000000 --- a/dist/examples/cxx/tree/custom/double/double-vc10.vcxproj +++ /dev/null @@ -1,229 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - double - {CCE6AE91-39AC-49B6-8763-742B65FCD92E} - double - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type double=double --hxx-epilogue "#include \"double-custom.hxx\"" xml-schema.xsd - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type double=double --hxx-epilogue "#include \"double-custom.hxx\"" xml-schema.xsd - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type double=double --hxx-epilogue "#include \"double-custom.hxx\"" xml-schema.xsd - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type double=double --hxx-epilogue "#include \"double-custom.hxx\"" xml-schema.xsd - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - xsd order.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd order.xsd - xml-schema.hxx;%(AdditionalInputs) - order.hxx;order.ixx;order.cxx;%(Outputs) - xsd order.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd order.xsd - xml-schema.hxx;%(AdditionalInputs) - order.hxx;order.ixx;order.cxx;%(Outputs) - xsd order.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd order.xsd - order.hxx;order.ixx;order.cxx;%(Outputs) - xsd order.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd order.xsd - order.hxx;order.ixx;order.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/double/double-vc10.vcxproj.filters b/dist/examples/cxx/tree/custom/double/double-vc10.vcxproj.filters deleted file mode 100644 index b36f95b..0000000 --- a/dist/examples/cxx/tree/custom/double/double-vc10.vcxproj.filters +++ /dev/null @@ -1,54 +0,0 @@ - - - - - {9AB5F296-2836-4A71-A39E-8D63EECB86D8} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {CDC85F55-DEE6-4EB3-9B72-1CBDDA21CFBE} - h;hpp;hxx;hm;inl;inc;xsd - - - {69c0bc69-f38e-42f7-8c11-cd6c1a121574} - ixx - - - {bad36e63-36c2-4233-87a2-68af084d612a} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/double/double-vc11.vcxproj b/dist/examples/cxx/tree/custom/double/double-vc11.vcxproj deleted file mode 100644 index eebb33b..0000000 --- a/dist/examples/cxx/tree/custom/double/double-vc11.vcxproj +++ /dev/null @@ -1,233 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - double - {CCE6AE91-39AC-49B6-8763-742B65FCD92E} - double - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type double=double --hxx-epilogue "#include \"double-custom.hxx\"" xml-schema.xsd - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type double=double --hxx-epilogue "#include \"double-custom.hxx\"" xml-schema.xsd - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type double=double --hxx-epilogue "#include \"double-custom.hxx\"" xml-schema.xsd - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type double=double --hxx-epilogue "#include \"double-custom.hxx\"" xml-schema.xsd - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - xsd order.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd order.xsd - xml-schema.hxx;%(AdditionalInputs) - order.hxx;order.ixx;order.cxx;%(Outputs) - xsd order.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd order.xsd - xml-schema.hxx;%(AdditionalInputs) - order.hxx;order.ixx;order.cxx;%(Outputs) - xsd order.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd order.xsd - order.hxx;order.ixx;order.cxx;%(Outputs) - xsd order.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd order.xsd - order.hxx;order.ixx;order.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/double/double-vc11.vcxproj.filters b/dist/examples/cxx/tree/custom/double/double-vc11.vcxproj.filters deleted file mode 100644 index b36f95b..0000000 --- a/dist/examples/cxx/tree/custom/double/double-vc11.vcxproj.filters +++ /dev/null @@ -1,54 +0,0 @@ - - - - - {9AB5F296-2836-4A71-A39E-8D63EECB86D8} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {CDC85F55-DEE6-4EB3-9B72-1CBDDA21CFBE} - h;hpp;hxx;hm;inl;inc;xsd - - - {69c0bc69-f38e-42f7-8c11-cd6c1a121574} - ixx - - - {bad36e63-36c2-4233-87a2-68af084d612a} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/double/double-vc12.vcxproj b/dist/examples/cxx/tree/custom/double/double-vc12.vcxproj deleted file mode 100644 index 537153e..0000000 --- a/dist/examples/cxx/tree/custom/double/double-vc12.vcxproj +++ /dev/null @@ -1,237 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - double - {CCE6AE91-39AC-49B6-8763-742B65FCD92E} - double - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type double=double --hxx-epilogue "#include \"double-custom.hxx\"" xml-schema.xsd - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type double=double --hxx-epilogue "#include \"double-custom.hxx\"" xml-schema.xsd - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type double=double --hxx-epilogue "#include \"double-custom.hxx\"" xml-schema.xsd - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - xsd xml-schema.xsd - xsd cxx-tree --generate-xml-schema --generate-serialization --custom-type double=double --hxx-epilogue "#include \"double-custom.hxx\"" xml-schema.xsd - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - xsd order.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd order.xsd - xml-schema.hxx;%(AdditionalInputs) - order.hxx;order.ixx;order.cxx;%(Outputs) - xsd order.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd order.xsd - xml-schema.hxx;%(AdditionalInputs) - order.hxx;order.ixx;order.cxx;%(Outputs) - xsd order.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd order.xsd - order.hxx;order.ixx;order.cxx;%(Outputs) - xsd order.xsd - xsd cxx-tree --generate-inline --generate-serialization --extern-xml-schema xml-schema.xsd order.xsd - order.hxx;order.ixx;order.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/double/double-vc12.vcxproj.filters b/dist/examples/cxx/tree/custom/double/double-vc12.vcxproj.filters deleted file mode 100644 index b36f95b..0000000 --- a/dist/examples/cxx/tree/custom/double/double-vc12.vcxproj.filters +++ /dev/null @@ -1,54 +0,0 @@ - - - - - {9AB5F296-2836-4A71-A39E-8D63EECB86D8} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {CDC85F55-DEE6-4EB3-9B72-1CBDDA21CFBE} - h;hpp;hxx;hm;inl;inc;xsd - - - {69c0bc69-f38e-42f7-8c11-cd6c1a121574} - ixx - - - {bad36e63-36c2-4233-87a2-68af084d612a} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/double/double-vc8.vcproj b/dist/examples/cxx/tree/custom/double/double-vc8.vcproj deleted file mode 100644 index 39a1945..0000000 --- a/dist/examples/cxx/tree/custom/double/double-vc8.vcproj +++ /dev/null @@ -1,456 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/custom/double/double-vc9.vcproj b/dist/examples/cxx/tree/custom/double/double-vc9.vcproj deleted file mode 100644 index 8cb6e4e..0000000 --- a/dist/examples/cxx/tree/custom/double/double-vc9.vcproj +++ /dev/null @@ -1,453 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/custom/double/makefile b/dist/examples/cxx/tree/custom/double/makefile deleted file mode 100644 index 9480279..0000000 --- a/dist/examples/cxx/tree/custom/double/makefile +++ /dev/null @@ -1,42 +0,0 @@ -root := ../../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -override XSDFLAGS += --generate-inline --generate-serialization \ ---extern-xml-schema xml-schema.xsd - - -# Build. -# -driver: driver.o order.o double-custom.o - -driver.o: driver.cxx order.ixx order.hxx xml-schema.hxx double-custom.hxx -order.o: order.cxx order.ixx order.hxx xml-schema.hxx double-custom.hxx -double-custom.o: xml-schema.hxx double-custom.hxx - -order.cxx order.ixx order.hxx: order.xsd - -# Generate header for XML Schema namespace. -# -XML_SCHEMA_XSDFLAGS := --generate-xml-schema --generate-serialization \ ---custom-type double=double \ ---hxx-epilogue '\#include "double-custom.hxx"' - -xml-schema.hxx: - $(XSD) cxx-tree $(XML_SCHEMA_XSDFLAGS) xml-schema.xsd - - -# Test -# -.PHONY: test -test: driver - ./driver - - -# Clean. -# -.PHONY: clean -clean: - rm -f xml-schema.hxx double-custom.o order.o order.?xx driver.o driver diff --git a/dist/examples/cxx/tree/custom/makefile b/dist/examples/cxx/tree/custom/makefile deleted file mode 100644 index 584f599..0000000 --- a/dist/examples/cxx/tree/custom/makefile +++ /dev/null @@ -1,15 +0,0 @@ -dirs := comments contacts double mixed taxonomy wildcard - -ifeq ($(WITH_BOOST),1) -dirs += calendar -endif - -.PHONY: all $(dirs) - -all: $(dirs) - -$(dirs): - @$(MAKE) -C $@ $(MAKECMDGOALS) - -makefile: ; -% :: $(dirs) ; diff --git a/dist/examples/cxx/tree/custom/mixed/makefile b/dist/examples/cxx/tree/custom/mixed/makefile deleted file mode 100644 index 9c7974d..0000000 --- a/dist/examples/cxx/tree/custom/mixed/makefile +++ /dev/null @@ -1,40 +0,0 @@ -root := ../../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -override XSDFLAGS += --generate-inline --generate-serialization \ ---hxx-epilogue '\#include "people-custom.hxx"' - -ifneq ($(shell uname -o 2>&1),Msys) -override XSDFLAGS += --custom-type bio=/bio_base -else -# Prevent MSYS from converting / to Windows path. -override XSDFLAGS += --custom-type bio=//bio_base -endif - - -# Build. -# -driver: driver.o people.o people-custom.o - -people.o: people.cxx people.ixx people.hxx people-custom.hxx -driver.o: driver.cxx people.ixx people.hxx people-custom.hxx -people-custom.o: people-custom.cxx people.ixx people.hxx people-custom.hxx - -people.cxx people.hxx people.ixx: people.xsd - - -# Test -# -.PHONY: test -test: driver people.xml - ./driver people.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f people-custom.o people.o people.?xx driver.o driver diff --git a/dist/examples/cxx/tree/custom/mixed/mixed-vc10.vcxproj b/dist/examples/cxx/tree/custom/mixed/mixed-vc10.vcxproj deleted file mode 100644 index 86258d4..0000000 --- a/dist/examples/cxx/tree/custom/mixed/mixed-vc10.vcxproj +++ /dev/null @@ -1,208 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mixed - {26CE0C08-7621-403A-88A7-206E64F32C66} - mixed - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --custom-type bio=/bio_base --hxx-epilogue "#include \"people-custom.hxx\"" people.xsd - people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --custom-type bio=/bio_base --hxx-epilogue "#include \"people-custom.hxx\"" people.xsd - people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --custom-type bio=/bio_base --hxx-epilogue "#include \"people-custom.hxx\"" people.xsd - people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --custom-type bio=/bio_base --hxx-epilogue "#include \"people-custom.hxx\"" people.xsd - people.hxx;people.ixx;people.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/mixed/mixed-vc10.vcxproj.filters b/dist/examples/cxx/tree/custom/mixed/mixed-vc10.vcxproj.filters deleted file mode 100644 index 1f317e1..0000000 --- a/dist/examples/cxx/tree/custom/mixed/mixed-vc10.vcxproj.filters +++ /dev/null @@ -1,51 +0,0 @@ - - - - - {CBA3D0E2-DDB8-4ABE-8B5A-7A28191CA323} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {54846A6A-25CD-4C8C-A5F1-2DAC77554F47} - h;hpp;hxx;hm;inl;inc;xsd - - - {ba5c74eb-b935-4573-98b5-2987ed135ec6} - ixx - - - {b02fd6d3-59e2-4819-9c5b-66ef2b5834a0} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/mixed/mixed-vc11.vcxproj b/dist/examples/cxx/tree/custom/mixed/mixed-vc11.vcxproj deleted file mode 100644 index 9afcc81..0000000 --- a/dist/examples/cxx/tree/custom/mixed/mixed-vc11.vcxproj +++ /dev/null @@ -1,212 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mixed - {26CE0C08-7621-403A-88A7-206E64F32C66} - mixed - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --custom-type bio=/bio_base --hxx-epilogue "#include \"people-custom.hxx\"" people.xsd - people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --custom-type bio=/bio_base --hxx-epilogue "#include \"people-custom.hxx\"" people.xsd - people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --custom-type bio=/bio_base --hxx-epilogue "#include \"people-custom.hxx\"" people.xsd - people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --custom-type bio=/bio_base --hxx-epilogue "#include \"people-custom.hxx\"" people.xsd - people.hxx;people.ixx;people.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/mixed/mixed-vc11.vcxproj.filters b/dist/examples/cxx/tree/custom/mixed/mixed-vc11.vcxproj.filters deleted file mode 100644 index 1f317e1..0000000 --- a/dist/examples/cxx/tree/custom/mixed/mixed-vc11.vcxproj.filters +++ /dev/null @@ -1,51 +0,0 @@ - - - - - {CBA3D0E2-DDB8-4ABE-8B5A-7A28191CA323} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {54846A6A-25CD-4C8C-A5F1-2DAC77554F47} - h;hpp;hxx;hm;inl;inc;xsd - - - {ba5c74eb-b935-4573-98b5-2987ed135ec6} - ixx - - - {b02fd6d3-59e2-4819-9c5b-66ef2b5834a0} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/mixed/mixed-vc12.vcxproj b/dist/examples/cxx/tree/custom/mixed/mixed-vc12.vcxproj deleted file mode 100644 index a7b4f73..0000000 --- a/dist/examples/cxx/tree/custom/mixed/mixed-vc12.vcxproj +++ /dev/null @@ -1,216 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mixed - {26CE0C08-7621-403A-88A7-206E64F32C66} - mixed - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --custom-type bio=/bio_base --hxx-epilogue "#include \"people-custom.hxx\"" people.xsd - people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --custom-type bio=/bio_base --hxx-epilogue "#include \"people-custom.hxx\"" people.xsd - people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --custom-type bio=/bio_base --hxx-epilogue "#include \"people-custom.hxx\"" people.xsd - people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-serialization --custom-type bio=/bio_base --hxx-epilogue "#include \"people-custom.hxx\"" people.xsd - people.hxx;people.ixx;people.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/mixed/mixed-vc12.vcxproj.filters b/dist/examples/cxx/tree/custom/mixed/mixed-vc12.vcxproj.filters deleted file mode 100644 index 1f317e1..0000000 --- a/dist/examples/cxx/tree/custom/mixed/mixed-vc12.vcxproj.filters +++ /dev/null @@ -1,51 +0,0 @@ - - - - - {CBA3D0E2-DDB8-4ABE-8B5A-7A28191CA323} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {54846A6A-25CD-4C8C-A5F1-2DAC77554F47} - h;hpp;hxx;hm;inl;inc;xsd - - - {ba5c74eb-b935-4573-98b5-2987ed135ec6} - ixx - - - {b02fd6d3-59e2-4819-9c5b-66ef2b5834a0} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/mixed/mixed-vc8.vcproj b/dist/examples/cxx/tree/custom/mixed/mixed-vc8.vcproj deleted file mode 100644 index a02149b..0000000 --- a/dist/examples/cxx/tree/custom/mixed/mixed-vc8.vcproj +++ /dev/null @@ -1,440 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/custom/mixed/mixed-vc9.vcproj b/dist/examples/cxx/tree/custom/mixed/mixed-vc9.vcproj deleted file mode 100644 index 331c786..0000000 --- a/dist/examples/cxx/tree/custom/mixed/mixed-vc9.vcproj +++ /dev/null @@ -1,437 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/custom/taxonomy/makefile b/dist/examples/cxx/tree/custom/taxonomy/makefile deleted file mode 100644 index 11fa6ef..0000000 --- a/dist/examples/cxx/tree/custom/taxonomy/makefile +++ /dev/null @@ -1,39 +0,0 @@ -root := ../../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -override XSDFLAGS += --generate-inline --generate-forward \ ---generate-polymorphic \ ---polymorphic-type person \ ---custom-type "person=person_impl/person_base" \ ---custom-type "superman=superman_impl/superman_base" \ ---custom-type "batman=batman_impl/batman_base" \ ---fwd-prologue '\#include "people-custom-fwd.hxx"' \ ---hxx-prologue '\#include "people-custom.hxx"' - - -# Build. -# -driver: driver.o people.o people-custom.o - -people.o: people.cxx people.ixx people.hxx people-custom.hxx people-custom-fwd.hxx -driver.o: driver.cxx people.ixx people.hxx people-custom.hxx people-custom-fwd.hxx -people-custom.o: people-custom.cxx people.ixx people.hxx people-custom.hxx people-custom-fwd.hxx - -people.cxx people.ixx people.hxx people-fwd.hxx: people.xsd - - -# Test -# -.PHONY: test -test: driver people.xml - ./driver people.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f people-custom.o people.o people-fwd.hxx people.?xx driver.o driver diff --git a/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc10.vcxproj b/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc10.vcxproj deleted file mode 100644 index 24040c6..0000000 --- a/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc10.vcxproj +++ /dev/null @@ -1,210 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - taxonomy - {B3108E70-7B4E-4DDA-8872-0DC4AFDCB2D9} - taxonomy - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - - xsd people.xsd - xsd cxx-tree --generate-inline --generate-forward --generate-polymorphic --polymorphic-type person --custom-type "person=person_impl<person_base>/person_base" --custom-type "superman=superman_impl<superman_base>/superman_base" --custom-type "batman=batman_impl<batman_base>/batman_base" --fwd-prologue "#include \"people-custom-fwd.hxx\"" --hxx-prologue "#include \"people-custom.hxx\"" people.xsd - people-fwd.hxx;people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-forward --generate-polymorphic --polymorphic-type person --custom-type "person=person_impl<person_base>/person_base" --custom-type "superman=superman_impl<superman_base>/superman_base" --custom-type "batman=batman_impl<batman_base>/batman_base" --fwd-prologue "#include \"people-custom-fwd.hxx\"" --hxx-prologue "#include \"people-custom.hxx\"" people.xsd - people-fwd.hxx;people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-forward --generate-polymorphic --polymorphic-type person --custom-type "person=person_impl<person_base>/person_base" --custom-type "superman=superman_impl<superman_base>/superman_base" --custom-type "batman=batman_impl<batman_base>/batman_base" --fwd-prologue "#include \"people-custom-fwd.hxx\"" --hxx-prologue "#include \"people-custom.hxx\"" people.xsd - people-fwd.hxx;people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-forward --generate-polymorphic --polymorphic-type person --custom-type "person=person_impl<person_base>/person_base" --custom-type "superman=superman_impl<superman_base>/superman_base" --custom-type "batman=batman_impl<batman_base>/batman_base" --fwd-prologue "#include \"people-custom-fwd.hxx\"" --hxx-prologue "#include \"people-custom.hxx\"" people.xsd - people-fwd.hxx;people.hxx;people.ixx;people.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc10.vcxproj.filters b/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc10.vcxproj.filters deleted file mode 100644 index 78058c3..0000000 --- a/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc10.vcxproj.filters +++ /dev/null @@ -1,57 +0,0 @@ - - - - - {E2FFBF97-01E8-483D-8B32-D8D6F065E4C7} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {0B3DDFAD-4254-48B9-BB24-1FC92DD1E7F6} - h;hpp;hxx;hm;inl;inc;xsd - - - {a33f9d45-baba-483a-83c4-9421790f7d92} - ixx - - - {0c14530b-7a4b-4841-864e-e8da7ae18eea} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc11.vcxproj b/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc11.vcxproj deleted file mode 100644 index f10b12a..0000000 --- a/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc11.vcxproj +++ /dev/null @@ -1,214 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - taxonomy - {B3108E70-7B4E-4DDA-8872-0DC4AFDCB2D9} - taxonomy - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - - xsd people.xsd - xsd cxx-tree --generate-inline --generate-forward --generate-polymorphic --polymorphic-type person --custom-type "person=person_impl<person_base>/person_base" --custom-type "superman=superman_impl<superman_base>/superman_base" --custom-type "batman=batman_impl<batman_base>/batman_base" --fwd-prologue "#include \"people-custom-fwd.hxx\"" --hxx-prologue "#include \"people-custom.hxx\"" people.xsd - people-fwd.hxx;people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-forward --generate-polymorphic --polymorphic-type person --custom-type "person=person_impl<person_base>/person_base" --custom-type "superman=superman_impl<superman_base>/superman_base" --custom-type "batman=batman_impl<batman_base>/batman_base" --fwd-prologue "#include \"people-custom-fwd.hxx\"" --hxx-prologue "#include \"people-custom.hxx\"" people.xsd - people-fwd.hxx;people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-forward --generate-polymorphic --polymorphic-type person --custom-type "person=person_impl<person_base>/person_base" --custom-type "superman=superman_impl<superman_base>/superman_base" --custom-type "batman=batman_impl<batman_base>/batman_base" --fwd-prologue "#include \"people-custom-fwd.hxx\"" --hxx-prologue "#include \"people-custom.hxx\"" people.xsd - people-fwd.hxx;people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-forward --generate-polymorphic --polymorphic-type person --custom-type "person=person_impl<person_base>/person_base" --custom-type "superman=superman_impl<superman_base>/superman_base" --custom-type "batman=batman_impl<batman_base>/batman_base" --fwd-prologue "#include \"people-custom-fwd.hxx\"" --hxx-prologue "#include \"people-custom.hxx\"" people.xsd - people-fwd.hxx;people.hxx;people.ixx;people.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc11.vcxproj.filters b/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc11.vcxproj.filters deleted file mode 100644 index 78058c3..0000000 --- a/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc11.vcxproj.filters +++ /dev/null @@ -1,57 +0,0 @@ - - - - - {E2FFBF97-01E8-483D-8B32-D8D6F065E4C7} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {0B3DDFAD-4254-48B9-BB24-1FC92DD1E7F6} - h;hpp;hxx;hm;inl;inc;xsd - - - {a33f9d45-baba-483a-83c4-9421790f7d92} - ixx - - - {0c14530b-7a4b-4841-864e-e8da7ae18eea} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc12.vcxproj b/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc12.vcxproj deleted file mode 100644 index c5579d9..0000000 --- a/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc12.vcxproj +++ /dev/null @@ -1,218 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - taxonomy - {B3108E70-7B4E-4DDA-8872-0DC4AFDCB2D9} - taxonomy - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - - xsd people.xsd - xsd cxx-tree --generate-inline --generate-forward --generate-polymorphic --polymorphic-type person --custom-type "person=person_impl<person_base>/person_base" --custom-type "superman=superman_impl<superman_base>/superman_base" --custom-type "batman=batman_impl<batman_base>/batman_base" --fwd-prologue "#include \"people-custom-fwd.hxx\"" --hxx-prologue "#include \"people-custom.hxx\"" people.xsd - people-fwd.hxx;people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-forward --generate-polymorphic --polymorphic-type person --custom-type "person=person_impl<person_base>/person_base" --custom-type "superman=superman_impl<superman_base>/superman_base" --custom-type "batman=batman_impl<batman_base>/batman_base" --fwd-prologue "#include \"people-custom-fwd.hxx\"" --hxx-prologue "#include \"people-custom.hxx\"" people.xsd - people-fwd.hxx;people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-forward --generate-polymorphic --polymorphic-type person --custom-type "person=person_impl<person_base>/person_base" --custom-type "superman=superman_impl<superman_base>/superman_base" --custom-type "batman=batman_impl<batman_base>/batman_base" --fwd-prologue "#include \"people-custom-fwd.hxx\"" --hxx-prologue "#include \"people-custom.hxx\"" people.xsd - people-fwd.hxx;people.hxx;people.ixx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree --generate-inline --generate-forward --generate-polymorphic --polymorphic-type person --custom-type "person=person_impl<person_base>/person_base" --custom-type "superman=superman_impl<superman_base>/superman_base" --custom-type "batman=batman_impl<batman_base>/batman_base" --fwd-prologue "#include \"people-custom-fwd.hxx\"" --hxx-prologue "#include \"people-custom.hxx\"" people.xsd - people-fwd.hxx;people.hxx;people.ixx;people.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc12.vcxproj.filters b/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc12.vcxproj.filters deleted file mode 100644 index 78058c3..0000000 --- a/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc12.vcxproj.filters +++ /dev/null @@ -1,57 +0,0 @@ - - - - - {E2FFBF97-01E8-483D-8B32-D8D6F065E4C7} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {0B3DDFAD-4254-48B9-BB24-1FC92DD1E7F6} - h;hpp;hxx;hm;inl;inc;xsd - - - {a33f9d45-baba-483a-83c4-9421790f7d92} - ixx - - - {0c14530b-7a4b-4841-864e-e8da7ae18eea} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc8.vcproj b/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc8.vcproj deleted file mode 100644 index 74744f4..0000000 --- a/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc8.vcproj +++ /dev/null @@ -1,448 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc9.vcproj b/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc9.vcproj deleted file mode 100644 index 1ff90d3..0000000 --- a/dist/examples/cxx/tree/custom/taxonomy/taxonomy-vc9.vcproj +++ /dev/null @@ -1,445 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/custom/wildcard/makefile b/dist/examples/cxx/tree/custom/wildcard/makefile deleted file mode 100644 index 7473f00..0000000 --- a/dist/examples/cxx/tree/custom/wildcard/makefile +++ /dev/null @@ -1,40 +0,0 @@ -root := ../../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -override XSDFLAGS += --generate-inline --generate-ostream \ ---generate-serialization --hxx-epilogue '\#include "wildcard-custom.hxx"' - -ifneq ($(shell uname -o 2>&1),Msys) -override XSDFLAGS += --custom-type data=/data_base -else -# Prevent MSYS from converting / to Windows path. -override XSDFLAGS += --custom-type data=//data_base -endif - - -# Build. -# -driver: driver.o wildcard.o wildcard-custom.o - -wildcard.o: wildcard.cxx wildcard.ixx wildcard.hxx wildcard-custom.hxx -driver.o: driver.cxx wildcard.ixx wildcard.hxx wildcard-custom.hxx -wildcard-custom.o: wildcard-custom.cxx wildcard.ixx wildcard.hxx wildcard-custom.hxx - -wildcard.cxx wildcard.hxx wildcard.ixx: wildcard.xsd - - -# Test -# -.PHONY: test -test: driver wildcard.xml - ./driver wildcard.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f wildcard-custom.o wildcard.o wildcard.?xx driver.o driver diff --git a/dist/examples/cxx/tree/custom/wildcard/wildcard-vc10.vcxproj b/dist/examples/cxx/tree/custom/wildcard/wildcard-vc10.vcxproj deleted file mode 100644 index 7076dd6..0000000 --- a/dist/examples/cxx/tree/custom/wildcard/wildcard-vc10.vcxproj +++ /dev/null @@ -1,208 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - wildcard - {6CE6CDEC-F8DE-42D0-80F8-E71C0DD8F897} - wildcard - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - xsd wildcard.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization --custom-type data=/data_base --hxx-epilogue "#include \"wildcard-custom.hxx\"" wildcard.xsd - wildcard.hxx;wildcard.ixx;wildcard.cxx;%(Outputs) - xsd wildcard.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization --custom-type data=/data_base --hxx-epilogue "#include \"wildcard-custom.hxx\"" wildcard.xsd - wildcard.hxx;wildcard.ixx;wildcard.cxx;%(Outputs) - xsd wildcard.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization --custom-type data=/data_base --hxx-epilogue "#include \"wildcard-custom.hxx\"" wildcard.xsd - wildcard.hxx;wildcard.ixx;wildcard.cxx;%(Outputs) - xsd wildcard.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization --custom-type data=/data_base --hxx-epilogue "#include \"wildcard-custom.hxx\"" wildcard.xsd - wildcard.hxx;wildcard.ixx;wildcard.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/wildcard/wildcard-vc10.vcxproj.filters b/dist/examples/cxx/tree/custom/wildcard/wildcard-vc10.vcxproj.filters deleted file mode 100644 index b67a77a..0000000 --- a/dist/examples/cxx/tree/custom/wildcard/wildcard-vc10.vcxproj.filters +++ /dev/null @@ -1,51 +0,0 @@ - - - - - {426B0A1E-659E-40E5-B93B-EF76EBBE0C0A} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {42AF0399-9A66-43B2-94AA-DBF9BEEF1E92} - h;hpp;hxx;hm;inl;inc;xsd - - - {0e336f4b-1f4c-4838-9a6a-183c80df8b67} - ixx - - - {228a47a0-93d7-4c99-9486-a589705ee401} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/wildcard/wildcard-vc11.vcxproj b/dist/examples/cxx/tree/custom/wildcard/wildcard-vc11.vcxproj deleted file mode 100644 index da17a00..0000000 --- a/dist/examples/cxx/tree/custom/wildcard/wildcard-vc11.vcxproj +++ /dev/null @@ -1,212 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - wildcard - {6CE6CDEC-F8DE-42D0-80F8-E71C0DD8F897} - wildcard - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - xsd wildcard.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization --custom-type data=/data_base --hxx-epilogue "#include \"wildcard-custom.hxx\"" wildcard.xsd - wildcard.hxx;wildcard.ixx;wildcard.cxx;%(Outputs) - xsd wildcard.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization --custom-type data=/data_base --hxx-epilogue "#include \"wildcard-custom.hxx\"" wildcard.xsd - wildcard.hxx;wildcard.ixx;wildcard.cxx;%(Outputs) - xsd wildcard.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization --custom-type data=/data_base --hxx-epilogue "#include \"wildcard-custom.hxx\"" wildcard.xsd - wildcard.hxx;wildcard.ixx;wildcard.cxx;%(Outputs) - xsd wildcard.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization --custom-type data=/data_base --hxx-epilogue "#include \"wildcard-custom.hxx\"" wildcard.xsd - wildcard.hxx;wildcard.ixx;wildcard.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/wildcard/wildcard-vc11.vcxproj.filters b/dist/examples/cxx/tree/custom/wildcard/wildcard-vc11.vcxproj.filters deleted file mode 100644 index b67a77a..0000000 --- a/dist/examples/cxx/tree/custom/wildcard/wildcard-vc11.vcxproj.filters +++ /dev/null @@ -1,51 +0,0 @@ - - - - - {426B0A1E-659E-40E5-B93B-EF76EBBE0C0A} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {42AF0399-9A66-43B2-94AA-DBF9BEEF1E92} - h;hpp;hxx;hm;inl;inc;xsd - - - {0e336f4b-1f4c-4838-9a6a-183c80df8b67} - ixx - - - {228a47a0-93d7-4c99-9486-a589705ee401} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/wildcard/wildcard-vc12.vcxproj b/dist/examples/cxx/tree/custom/wildcard/wildcard-vc12.vcxproj deleted file mode 100644 index a6ff440..0000000 --- a/dist/examples/cxx/tree/custom/wildcard/wildcard-vc12.vcxproj +++ /dev/null @@ -1,216 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - wildcard - {6CE6CDEC-F8DE-42D0-80F8-E71C0DD8F897} - wildcard - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - xsd wildcard.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization --custom-type data=/data_base --hxx-epilogue "#include \"wildcard-custom.hxx\"" wildcard.xsd - wildcard.hxx;wildcard.ixx;wildcard.cxx;%(Outputs) - xsd wildcard.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization --custom-type data=/data_base --hxx-epilogue "#include \"wildcard-custom.hxx\"" wildcard.xsd - wildcard.hxx;wildcard.ixx;wildcard.cxx;%(Outputs) - xsd wildcard.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization --custom-type data=/data_base --hxx-epilogue "#include \"wildcard-custom.hxx\"" wildcard.xsd - wildcard.hxx;wildcard.ixx;wildcard.cxx;%(Outputs) - xsd wildcard.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization --custom-type data=/data_base --hxx-epilogue "#include \"wildcard-custom.hxx\"" wildcard.xsd - wildcard.hxx;wildcard.ixx;wildcard.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/wildcard/wildcard-vc12.vcxproj.filters b/dist/examples/cxx/tree/custom/wildcard/wildcard-vc12.vcxproj.filters deleted file mode 100644 index b67a77a..0000000 --- a/dist/examples/cxx/tree/custom/wildcard/wildcard-vc12.vcxproj.filters +++ /dev/null @@ -1,51 +0,0 @@ - - - - - {426B0A1E-659E-40E5-B93B-EF76EBBE0C0A} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {42AF0399-9A66-43B2-94AA-DBF9BEEF1E92} - h;hpp;hxx;hm;inl;inc;xsd - - - {0e336f4b-1f4c-4838-9a6a-183c80df8b67} - ixx - - - {228a47a0-93d7-4c99-9486-a589705ee401} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/custom/wildcard/wildcard-vc8.vcproj b/dist/examples/cxx/tree/custom/wildcard/wildcard-vc8.vcproj deleted file mode 100644 index 917fddd..0000000 --- a/dist/examples/cxx/tree/custom/wildcard/wildcard-vc8.vcproj +++ /dev/null @@ -1,440 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/custom/wildcard/wildcard-vc9.vcproj b/dist/examples/cxx/tree/custom/wildcard/wildcard-vc9.vcproj deleted file mode 100644 index 16cab0c..0000000 --- a/dist/examples/cxx/tree/custom/wildcard/wildcard-vc9.vcproj +++ /dev/null @@ -1,437 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/embedded/embedded-vc10.sln b/dist/examples/cxx/tree/embedded/embedded-vc10.sln deleted file mode 100644 index 0204487..0000000 --- a/dist/examples/cxx/tree/embedded/embedded-vc10.sln +++ /dev/null @@ -1,38 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xsdbin", "xsdbin-vc10.vcxproj", "{A3F6E060-D536-4A43-AF4B-89063F65DE91}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "embedded", "embedded-vc10.vcxproj", "{9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|Win32.ActiveCfg = Debug|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|Win32.Build.0 = Debug|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|x64.ActiveCfg = Debug|x64 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|x64.Build.0 = Debug|x64 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|Win32.ActiveCfg = Release|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|Win32.Build.0 = Release|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|x64.ActiveCfg = Release|x64 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|x64.Build.0 = Release|x64 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|Win32.ActiveCfg = Debug|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|Win32.Build.0 = Debug|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|x64.ActiveCfg = Debug|x64 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|x64.Build.0 = Debug|x64 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|Win32.ActiveCfg = Release|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|Win32.Build.0 = Release|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|x64.ActiveCfg = Release|x64 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|x64.Build.0 = Release|x64 - - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/dist/examples/cxx/tree/embedded/embedded-vc10.vcxproj b/dist/examples/cxx/tree/embedded/embedded-vc10.vcxproj deleted file mode 100644 index 859b20b..0000000 --- a/dist/examples/cxx/tree/embedded/embedded-vc10.vcxproj +++ /dev/null @@ -1,215 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - embedded - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429} - embedded - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree library.xsd && xsdbin.exe library.xsd - library.hxx;library.cxx;library-schema.hxx;library-schema.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree library.xsd && xsdbin.exe library.xsd - library.hxx;library.cxx;library-schema.hxx;library-schema.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree library.xsd && xsdbin.exe library.xsd - library.hxx;library.cxx;library-schema.hxx;library-schema.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree library.xsd && xsdbin.exe library.xsd - library.hxx;library.cxx;library-schema.hxx;library-schema.cxx;%(Outputs) - - - - - - - - {a3f6e060-d536-4a43-af4b-89063f65de91} - false - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/embedded/embedded-vc10.vcxproj.filters b/dist/examples/cxx/tree/embedded/embedded-vc10.vcxproj.filters deleted file mode 100644 index 42beedc..0000000 --- a/dist/examples/cxx/tree/embedded/embedded-vc10.vcxproj.filters +++ /dev/null @@ -1,50 +0,0 @@ - - - - - {1D046D9C-4D20-4084-A1F4-90488E0B0669} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {E2D458FA-56FA-4268-998B-BF3934169712} - h;hpp;hxx;hm;inl;inc;xsd - - - {a57574af-3c36-408f-9f8e-5140fe6abbf6} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/embedded/embedded-vc11.sln b/dist/examples/cxx/tree/embedded/embedded-vc11.sln deleted file mode 100644 index dc8273d..0000000 --- a/dist/examples/cxx/tree/embedded/embedded-vc11.sln +++ /dev/null @@ -1,38 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xsdbin", "xsdbin-vc11.vcxproj", "{A3F6E060-D536-4A43-AF4B-89063F65DE91}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "embedded", "embedded-vc11.vcxproj", "{9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|Win32.ActiveCfg = Debug|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|Win32.Build.0 = Debug|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|x64.ActiveCfg = Debug|x64 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|x64.Build.0 = Debug|x64 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|Win32.ActiveCfg = Release|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|Win32.Build.0 = Release|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|x64.ActiveCfg = Release|x64 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|x64.Build.0 = Release|x64 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|Win32.ActiveCfg = Debug|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|Win32.Build.0 = Debug|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|x64.ActiveCfg = Debug|x64 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|x64.Build.0 = Debug|x64 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|Win32.ActiveCfg = Release|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|Win32.Build.0 = Release|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|x64.ActiveCfg = Release|x64 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|x64.Build.0 = Release|x64 - - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/dist/examples/cxx/tree/embedded/embedded-vc11.vcxproj b/dist/examples/cxx/tree/embedded/embedded-vc11.vcxproj deleted file mode 100644 index 4fcc53a..0000000 --- a/dist/examples/cxx/tree/embedded/embedded-vc11.vcxproj +++ /dev/null @@ -1,219 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - embedded - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429} - embedded - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree library.xsd && xsdbin.exe library.xsd - library.hxx;library.cxx;library-schema.hxx;library-schema.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree library.xsd && xsdbin.exe library.xsd - library.hxx;library.cxx;library-schema.hxx;library-schema.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree library.xsd && xsdbin.exe library.xsd - library.hxx;library.cxx;library-schema.hxx;library-schema.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree library.xsd && xsdbin.exe library.xsd - library.hxx;library.cxx;library-schema.hxx;library-schema.cxx;%(Outputs) - - - - - - - - {a3f6e060-d536-4a43-af4b-89063f65de91} - false - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/embedded/embedded-vc11.vcxproj.filters b/dist/examples/cxx/tree/embedded/embedded-vc11.vcxproj.filters deleted file mode 100644 index 42beedc..0000000 --- a/dist/examples/cxx/tree/embedded/embedded-vc11.vcxproj.filters +++ /dev/null @@ -1,50 +0,0 @@ - - - - - {1D046D9C-4D20-4084-A1F4-90488E0B0669} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {E2D458FA-56FA-4268-998B-BF3934169712} - h;hpp;hxx;hm;inl;inc;xsd - - - {a57574af-3c36-408f-9f8e-5140fe6abbf6} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/embedded/embedded-vc12.sln b/dist/examples/cxx/tree/embedded/embedded-vc12.sln deleted file mode 100644 index 1a70889..0000000 --- a/dist/examples/cxx/tree/embedded/embedded-vc12.sln +++ /dev/null @@ -1,40 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xsdbin", "xsdbin-vc12.vcxproj", "{A3F6E060-D536-4A43-AF4B-89063F65DE91}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "embedded", "embedded-vc12.vcxproj", "{9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|Win32.ActiveCfg = Debug|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|Win32.Build.0 = Debug|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|x64.ActiveCfg = Debug|x64 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|x64.Build.0 = Debug|x64 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|Win32.ActiveCfg = Release|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|Win32.Build.0 = Release|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|x64.ActiveCfg = Release|x64 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|x64.Build.0 = Release|x64 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|Win32.ActiveCfg = Debug|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|Win32.Build.0 = Debug|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|x64.ActiveCfg = Debug|x64 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|x64.Build.0 = Debug|x64 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|Win32.ActiveCfg = Release|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|Win32.Build.0 = Release|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|x64.ActiveCfg = Release|x64 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|x64.Build.0 = Release|x64 - - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/dist/examples/cxx/tree/embedded/embedded-vc12.vcxproj b/dist/examples/cxx/tree/embedded/embedded-vc12.vcxproj deleted file mode 100644 index bc2682f..0000000 --- a/dist/examples/cxx/tree/embedded/embedded-vc12.vcxproj +++ /dev/null @@ -1,223 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - embedded - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429} - embedded - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree library.xsd && xsdbin.exe library.xsd - library.hxx;library.cxx;library-schema.hxx;library-schema.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree library.xsd && xsdbin.exe library.xsd - library.hxx;library.cxx;library-schema.hxx;library-schema.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree library.xsd && xsdbin.exe library.xsd - library.hxx;library.cxx;library-schema.hxx;library-schema.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree library.xsd && xsdbin.exe library.xsd - library.hxx;library.cxx;library-schema.hxx;library-schema.cxx;%(Outputs) - - - - - - - - {a3f6e060-d536-4a43-af4b-89063f65de91} - false - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/embedded/embedded-vc12.vcxproj.filters b/dist/examples/cxx/tree/embedded/embedded-vc12.vcxproj.filters deleted file mode 100644 index 42beedc..0000000 --- a/dist/examples/cxx/tree/embedded/embedded-vc12.vcxproj.filters +++ /dev/null @@ -1,50 +0,0 @@ - - - - - {1D046D9C-4D20-4084-A1F4-90488E0B0669} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {E2D458FA-56FA-4268-998B-BF3934169712} - h;hpp;hxx;hm;inl;inc;xsd - - - {a57574af-3c36-408f-9f8e-5140fe6abbf6} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/embedded/embedded-vc8.sln b/dist/examples/cxx/tree/embedded/embedded-vc8.sln deleted file mode 100644 index 29a7c60..0000000 --- a/dist/examples/cxx/tree/embedded/embedded-vc8.sln +++ /dev/null @@ -1,41 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xsdbin", "xsdbin-vc8.vcproj", "{A3F6E060-D536-4A43-AF4B-89063F65DE91}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "embedded", "embedded-vc8.vcproj", "{9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}" - ProjectSection(ProjectDependencies) = postProject - {A3F6E060-D536-4A43-AF4B-89063F65DE91} = {A3F6E060-D536-4A43-AF4B-89063F65DE91} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|Win32.ActiveCfg = Debug|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|Win32.Build.0 = Debug|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|Win32.ActiveCfg = Release|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|Win32.Build.0 = Release|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|x64.ActiveCfg = Debug|x64 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|x64.Build.0 = Debug|x64 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|x64.ActiveCfg = Release|x64 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|x64.Build.0 = Release|x64 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|Win32.ActiveCfg = Debug|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|Win32.Build.0 = Debug|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|Win32.ActiveCfg = Release|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|Win32.Build.0 = Release|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|x64.ActiveCfg = Debug|x64 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|x64.Build.0 = Debug|x64 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|x64.ActiveCfg = Release|x64 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|x64.Build.0 = Release|x64 - - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/dist/examples/cxx/tree/embedded/embedded-vc8.vcproj b/dist/examples/cxx/tree/embedded/embedded-vc8.vcproj deleted file mode 100644 index d0df22c..0000000 --- a/dist/examples/cxx/tree/embedded/embedded-vc8.vcproj +++ /dev/null @@ -1,439 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/embedded/embedded-vc9.sln b/dist/examples/cxx/tree/embedded/embedded-vc9.sln deleted file mode 100644 index 96f10ed..0000000 --- a/dist/examples/cxx/tree/embedded/embedded-vc9.sln +++ /dev/null @@ -1,41 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xsdbin", "xsdbin-vc9.vcproj", "{A3F6E060-D536-4A43-AF4B-89063F65DE91}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "embedded", "embedded-vc9.vcproj", "{9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}" - ProjectSection(ProjectDependencies) = postProject - {A3F6E060-D536-4A43-AF4B-89063F65DE91} = {A3F6E060-D536-4A43-AF4B-89063F65DE91} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|Win32.ActiveCfg = Debug|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|Win32.Build.0 = Debug|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|x64.ActiveCfg = Debug|x64 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Debug|x64.Build.0 = Debug|x64 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|Win32.ActiveCfg = Release|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|Win32.Build.0 = Release|Win32 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|x64.ActiveCfg = Release|x64 - {A3F6E060-D536-4A43-AF4B-89063F65DE91}.Release|x64.Build.0 = Release|x64 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|Win32.ActiveCfg = Debug|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|Win32.Build.0 = Debug|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|x64.ActiveCfg = Debug|x64 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Debug|x64.Build.0 = Debug|x64 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|Win32.ActiveCfg = Release|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|Win32.Build.0 = Release|Win32 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|x64.ActiveCfg = Release|x64 - {9C8C2AA4-DF31-4884-B3B9-A6A36F3CB429}.Release|x64.Build.0 = Release|x64 - - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/dist/examples/cxx/tree/embedded/embedded-vc9.vcproj b/dist/examples/cxx/tree/embedded/embedded-vc9.vcproj deleted file mode 100644 index bf5498c..0000000 --- a/dist/examples/cxx/tree/embedded/embedded-vc9.vcproj +++ /dev/null @@ -1,436 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/embedded/makefile b/dist/examples/cxx/tree/embedded/makefile deleted file mode 100644 index 0879da9..0000000 --- a/dist/examples/cxx/tree/embedded/makefile +++ /dev/null @@ -1,36 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -# Build. -# -driver: driver.o library.o library-schema.o grammar-input-stream.o -xsdbin: xsdbin.o - -library.o: library.cxx library.hxx -driver.o: driver.cxx library.hxx library-schema.hxx -library-schema.o: library-schema.cxx library-schema.hxx -grammar-input-stream.o: grammar-input-stream.cxx grammar-input-stream.hxx - -library.cxx library.hxx: library.xsd -library-schema.cxx library-schema.hxx: library.xsd - -.PRECIOUS: %-schema.cxx %-schema.hxx -%-schema.cxx %-schema.hxx: %.xsd xsdbin - ./xsdbin $< - -# Test -# -.PHONY: test -test: driver library.xml - ./driver library.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f library.o library.?xx library-schema.?xx driver.o \ -library-schema.o grammar-input-stream.o xsdbin.o xsdbin driver diff --git a/dist/examples/cxx/tree/embedded/xsdbin-vc10.vcxproj b/dist/examples/cxx/tree/embedded/xsdbin-vc10.vcxproj deleted file mode 100644 index a57a876..0000000 --- a/dist/examples/cxx/tree/embedded/xsdbin-vc10.vcxproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - xsdbin - {A3F6E060-D536-4A43-AF4B-89063F65DE91} - xsdbin - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - xsdbin - xsdbin - xsdbin - xsdbin - $(ProjectDir) - Debug\xsdbin\ - true - $(ProjectDir) - $(Platform)\$(Configuration)\xsdbin\ - true - $(ProjectDir) - Release\xsdbin\ - false - $(ProjectDir) - $(Platform)\$(Configuration)\xsdbin\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)xsdbin.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)xsdbin.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/embedded/xsdbin-vc10.vcxproj.filters b/dist/examples/cxx/tree/embedded/xsdbin-vc10.vcxproj.filters deleted file mode 100644 index 27abb01..0000000 --- a/dist/examples/cxx/tree/embedded/xsdbin-vc10.vcxproj.filters +++ /dev/null @@ -1,14 +0,0 @@ - - - - - {D9727125-E5B7-4777-8EB3-6EE957552516} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/embedded/xsdbin-vc11.vcxproj b/dist/examples/cxx/tree/embedded/xsdbin-vc11.vcxproj deleted file mode 100644 index 1cfce63..0000000 --- a/dist/examples/cxx/tree/embedded/xsdbin-vc11.vcxproj +++ /dev/null @@ -1,186 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - xsdbin - {A3F6E060-D536-4A43-AF4B-89063F65DE91} - xsdbin - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - xsdbin - xsdbin - xsdbin - xsdbin - $(ProjectDir) - Debug\xsdbin\ - true - $(ProjectDir) - $(Platform)\$(Configuration)\xsdbin\ - true - $(ProjectDir) - Release\xsdbin\ - false - $(ProjectDir) - $(Platform)\$(Configuration)\xsdbin\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)xsdbin.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)xsdbin.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/embedded/xsdbin-vc11.vcxproj.filters b/dist/examples/cxx/tree/embedded/xsdbin-vc11.vcxproj.filters deleted file mode 100644 index 27abb01..0000000 --- a/dist/examples/cxx/tree/embedded/xsdbin-vc11.vcxproj.filters +++ /dev/null @@ -1,14 +0,0 @@ - - - - - {D9727125-E5B7-4777-8EB3-6EE957552516} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/embedded/xsdbin-vc12.vcxproj b/dist/examples/cxx/tree/embedded/xsdbin-vc12.vcxproj deleted file mode 100644 index eb66e81..0000000 --- a/dist/examples/cxx/tree/embedded/xsdbin-vc12.vcxproj +++ /dev/null @@ -1,190 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - xsdbin - {A3F6E060-D536-4A43-AF4B-89063F65DE91} - xsdbin - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - xsdbin - xsdbin - xsdbin - xsdbin - $(ProjectDir) - Debug\xsdbin\ - true - $(ProjectDir) - $(Platform)\$(Configuration)\xsdbin\ - true - $(ProjectDir) - Release\xsdbin\ - false - $(ProjectDir) - $(Platform)\$(Configuration)\xsdbin\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)xsdbin.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)xsdbin.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/embedded/xsdbin-vc12.vcxproj.filters b/dist/examples/cxx/tree/embedded/xsdbin-vc12.vcxproj.filters deleted file mode 100644 index 27abb01..0000000 --- a/dist/examples/cxx/tree/embedded/xsdbin-vc12.vcxproj.filters +++ /dev/null @@ -1,14 +0,0 @@ - - - - - {D9727125-E5B7-4777-8EB3-6EE957552516} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/embedded/xsdbin-vc8.vcproj b/dist/examples/cxx/tree/embedded/xsdbin-vc8.vcproj deleted file mode 100644 index 095024f..0000000 --- a/dist/examples/cxx/tree/embedded/xsdbin-vc8.vcproj +++ /dev/null @@ -1,356 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/embedded/xsdbin-vc9.vcproj b/dist/examples/cxx/tree/embedded/xsdbin-vc9.vcproj deleted file mode 100644 index 1cb2ead..0000000 --- a/dist/examples/cxx/tree/embedded/xsdbin-vc9.vcproj +++ /dev/null @@ -1,353 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/hello/hello-vc10.vcxproj b/dist/examples/cxx/tree/hello/hello-vc10.vcxproj deleted file mode 100644 index a9e0544..0000000 --- a/dist/examples/cxx/tree/hello/hello-vc10.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - hello - {538CCAB6-984B-4602-B0D0-985E8FD4FEB9} - hello - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd hello.xsd - xsd.exe cxx-tree hello.xsd - hello.cxx;hello.hxx;%(Outputs) - xsd hello.xsd - xsd.exe cxx-tree hello.xsd - hello.cxx;hello.hxx;%(Outputs) - xsd hello.xsd - xsd.exe cxx-tree hello.xsd - hello.cxx;hello.hxx;%(Outputs) - xsd hello.xsd - xsd.exe cxx-tree hello.xsd - hello.cxx;hello.hxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/hello/hello-vc10.vcxproj.filters b/dist/examples/cxx/tree/hello/hello-vc10.vcxproj.filters deleted file mode 100644 index 732378a..0000000 --- a/dist/examples/cxx/tree/hello/hello-vc10.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {D512D9C4-9DDD-4830-A487-1D87DB0643D5} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/hello/hello-vc11.vcxproj b/dist/examples/cxx/tree/hello/hello-vc11.vcxproj deleted file mode 100644 index c3f4c4f..0000000 --- a/dist/examples/cxx/tree/hello/hello-vc11.vcxproj +++ /dev/null @@ -1,209 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - hello - {538CCAB6-984B-4602-B0D0-985E8FD4FEB9} - hello - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd hello.xsd - xsd.exe cxx-tree hello.xsd - hello.cxx;hello.hxx;%(Outputs) - xsd hello.xsd - xsd.exe cxx-tree hello.xsd - hello.cxx;hello.hxx;%(Outputs) - xsd hello.xsd - xsd.exe cxx-tree hello.xsd - hello.cxx;hello.hxx;%(Outputs) - xsd hello.xsd - xsd.exe cxx-tree hello.xsd - hello.cxx;hello.hxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/hello/hello-vc11.vcxproj.filters b/dist/examples/cxx/tree/hello/hello-vc11.vcxproj.filters deleted file mode 100644 index 732378a..0000000 --- a/dist/examples/cxx/tree/hello/hello-vc11.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {D512D9C4-9DDD-4830-A487-1D87DB0643D5} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/hello/hello-vc12.vcxproj b/dist/examples/cxx/tree/hello/hello-vc12.vcxproj deleted file mode 100644 index 031c47e..0000000 --- a/dist/examples/cxx/tree/hello/hello-vc12.vcxproj +++ /dev/null @@ -1,213 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - hello - {538CCAB6-984B-4602-B0D0-985E8FD4FEB9} - hello - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd hello.xsd - xsd.exe cxx-tree hello.xsd - hello.cxx;hello.hxx;%(Outputs) - xsd hello.xsd - xsd.exe cxx-tree hello.xsd - hello.cxx;hello.hxx;%(Outputs) - xsd hello.xsd - xsd.exe cxx-tree hello.xsd - hello.cxx;hello.hxx;%(Outputs) - xsd hello.xsd - xsd.exe cxx-tree hello.xsd - hello.cxx;hello.hxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/hello/hello-vc12.vcxproj.filters b/dist/examples/cxx/tree/hello/hello-vc12.vcxproj.filters deleted file mode 100644 index 732378a..0000000 --- a/dist/examples/cxx/tree/hello/hello-vc12.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {D512D9C4-9DDD-4830-A487-1D87DB0643D5} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/hello/hello-vc8.vcproj b/dist/examples/cxx/tree/hello/hello-vc8.vcproj deleted file mode 100644 index c961754..0000000 --- a/dist/examples/cxx/tree/hello/hello-vc8.vcproj +++ /dev/null @@ -1,423 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/hello/hello-vc9.vcproj b/dist/examples/cxx/tree/hello/hello-vc9.vcproj deleted file mode 100644 index 20eed13..0000000 --- a/dist/examples/cxx/tree/hello/hello-vc9.vcproj +++ /dev/null @@ -1,420 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/hello/makefile b/dist/examples/cxx/tree/hello/makefile deleted file mode 100644 index 7886049..0000000 --- a/dist/examples/cxx/tree/hello/makefile +++ /dev/null @@ -1,29 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -# Build. -# -driver: driver.o hello.o - -hello.o: hello.cxx hello.hxx -driver.o: driver.cxx hello.hxx - -hello.cxx hello.hxx: hello.xsd - - -# Test. -# -.PHONY: test -test: driver hello.xml - ./driver hello.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f hello.o hello.?xx driver.o driver - diff --git a/dist/examples/cxx/tree/library/library-vc10.vcxproj b/dist/examples/cxx/tree/library/library-vc10.vcxproj deleted file mode 100644 index 0d82e98..0000000 --- a/dist/examples/cxx/tree/library/library-vc10.vcxproj +++ /dev/null @@ -1,206 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - library - {D661AD5B-5FF4-4AFD-A656-429BA348E9EF} - library - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization library.xsd - library.hxx;library.ixx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization library.xsd - library.hxx;library.ixx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization library.xsd - library.hxx;library.ixx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization library.xsd - library.hxx;library.ixx;library.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/library/library-vc10.vcxproj.filters b/dist/examples/cxx/tree/library/library-vc10.vcxproj.filters deleted file mode 100644 index e5e21e6..0000000 --- a/dist/examples/cxx/tree/library/library-vc10.vcxproj.filters +++ /dev/null @@ -1,45 +0,0 @@ - - - - - {E7CF4BC5-B0CB-4799-B64E-5AF3B67A6F0E} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {FDC2B8B2-1264-427A-9D4E-5577BF295A64} - h;hpp;hxx;hm;inl;inc;xsd - - - {8b40f964-53f9-4b8c-a52b-3fbe8bcfe092} - ixx - - - {50e811c7-6a8b-428b-8c92-0fb6c830a337} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/library/library-vc11.vcxproj b/dist/examples/cxx/tree/library/library-vc11.vcxproj deleted file mode 100644 index 498e9e9..0000000 --- a/dist/examples/cxx/tree/library/library-vc11.vcxproj +++ /dev/null @@ -1,210 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - library - {D661AD5B-5FF4-4AFD-A656-429BA348E9EF} - library - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization library.xsd - library.hxx;library.ixx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization library.xsd - library.hxx;library.ixx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization library.xsd - library.hxx;library.ixx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization library.xsd - library.hxx;library.ixx;library.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/library/library-vc11.vcxproj.filters b/dist/examples/cxx/tree/library/library-vc11.vcxproj.filters deleted file mode 100644 index e5e21e6..0000000 --- a/dist/examples/cxx/tree/library/library-vc11.vcxproj.filters +++ /dev/null @@ -1,45 +0,0 @@ - - - - - {E7CF4BC5-B0CB-4799-B64E-5AF3B67A6F0E} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {FDC2B8B2-1264-427A-9D4E-5577BF295A64} - h;hpp;hxx;hm;inl;inc;xsd - - - {8b40f964-53f9-4b8c-a52b-3fbe8bcfe092} - ixx - - - {50e811c7-6a8b-428b-8c92-0fb6c830a337} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/library/library-vc12.vcxproj b/dist/examples/cxx/tree/library/library-vc12.vcxproj deleted file mode 100644 index 80fd4ae..0000000 --- a/dist/examples/cxx/tree/library/library-vc12.vcxproj +++ /dev/null @@ -1,214 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - library - {D661AD5B-5FF4-4AFD-A656-429BA348E9EF} - library - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - xsd library.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization library.xsd - library.hxx;library.ixx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization library.xsd - library.hxx;library.ixx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization library.xsd - library.hxx;library.ixx;library.cxx;%(Outputs) - xsd library.xsd - xsd cxx-tree --generate-inline --generate-ostream --generate-serialization library.xsd - library.hxx;library.ixx;library.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/library/library-vc12.vcxproj.filters b/dist/examples/cxx/tree/library/library-vc12.vcxproj.filters deleted file mode 100644 index e5e21e6..0000000 --- a/dist/examples/cxx/tree/library/library-vc12.vcxproj.filters +++ /dev/null @@ -1,45 +0,0 @@ - - - - - {E7CF4BC5-B0CB-4799-B64E-5AF3B67A6F0E} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {FDC2B8B2-1264-427A-9D4E-5577BF295A64} - h;hpp;hxx;hm;inl;inc;xsd - - - {8b40f964-53f9-4b8c-a52b-3fbe8bcfe092} - ixx - - - {50e811c7-6a8b-428b-8c92-0fb6c830a337} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/library/library-vc8.vcproj b/dist/examples/cxx/tree/library/library-vc8.vcproj deleted file mode 100644 index 79e3f7e..0000000 --- a/dist/examples/cxx/tree/library/library-vc8.vcproj +++ /dev/null @@ -1,432 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/library/library-vc9.vcproj b/dist/examples/cxx/tree/library/library-vc9.vcproj deleted file mode 100644 index d616bff..0000000 --- a/dist/examples/cxx/tree/library/library-vc9.vcproj +++ /dev/null @@ -1,429 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/library/makefile b/dist/examples/cxx/tree/library/makefile deleted file mode 100644 index 2f9bb6a..0000000 --- a/dist/examples/cxx/tree/library/makefile +++ /dev/null @@ -1,32 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -override XSDFLAGS += --generate-inline --generate-ostream --generate-serialization - - -# Build. -# -driver: driver.o library.o - -library.o: library.cxx library.hxx library.ixx -driver.o: driver.cxx library.hxx library.ixx - -library.cxx library.hxx library.ixx: library.xsd - - -# Test -# -.PHONY: test -test: driver library.xml - ./driver library.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f library.o library.?xx driver.o driver - diff --git a/dist/examples/cxx/tree/makefile b/dist/examples/cxx/tree/makefile deleted file mode 100644 index 32b44de..0000000 --- a/dist/examples/cxx/tree/makefile +++ /dev/null @@ -1,20 +0,0 @@ -dirs := binary caching embedded custom hello library messaging mixed \ -multiroot order performance polymorphism secure streaming wildcard - -ifeq ($(WITH_ZLIB),1) -dirs += compression -endif - -ifeq ($(WITH_XQILLA),1) -dirs += xpath -endif - -.PHONY: all $(dirs) - -all: $(dirs) - -$(dirs): - @$(MAKE) -C $@ $(MAKECMDGOALS) - -makefile: ; -% :: $(dirs) ; diff --git a/dist/examples/cxx/tree/messaging/makefile b/dist/examples/cxx/tree/messaging/makefile deleted file mode 100644 index 0557a7c..0000000 --- a/dist/examples/cxx/tree/messaging/makefile +++ /dev/null @@ -1,35 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - -override XSDFLAGS += --root-element-all --generate-element-type \ ---generate-element-map --generate-serialization - - -# Build. -# -driver: driver.o dom-parse.o dom-serialize.o protocol.o - -protocol.o: protocol.cxx protocol.hxx -dom-parse.o: dom-parse.cxx dom-parse.hxx -dom-serialize.o: dom-serialize.cxx dom-serialize.hxx -driver.o: driver.cxx dom-parse.hxx dom-serialize.hxx protocol.hxx - -protocol.cxx protocol.hxx: protocol.xsd - - -# Test -# -.PHONY: test -test: driver balance.xml withdraw.xml deposit.xml - ./driver balance.xml - ./driver withdraw.xml - ./driver deposit.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f protocol.o protocol.?xx dom-parse.o dom-serialize.o driver.o driver diff --git a/dist/examples/cxx/tree/messaging/messaging-vc10.vcxproj b/dist/examples/cxx/tree/messaging/messaging-vc10.vcxproj deleted file mode 100644 index 6016f46..0000000 --- a/dist/examples/cxx/tree/messaging/messaging-vc10.vcxproj +++ /dev/null @@ -1,209 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - messaging - {F7696252-45B5-438B-B14F-0510137704F0} - messaging - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - xsd protocol.xsd - xsd cxx-tree --root-element-all --generate-element-type --generate-element-map --generate-serialization protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-tree --root-element-all --generate-element-type --generate-element-map --generate-serialization protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-tree --root-element-all --generate-element-type --generate-element-map --generate-serialization protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-tree --root-element-all --generate-element-type --generate-element-map --generate-serialization protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/messaging/messaging-vc10.vcxproj.filters b/dist/examples/cxx/tree/messaging/messaging-vc10.vcxproj.filters deleted file mode 100644 index c94955d..0000000 --- a/dist/examples/cxx/tree/messaging/messaging-vc10.vcxproj.filters +++ /dev/null @@ -1,50 +0,0 @@ - - - - - {0BA0A3D7-40AF-4307-8033-5BE39B33ABE5} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {F7AC5A29-8CF7-4882-89B6-1B5B81AA00F2} - h;hpp;hxx;hm;inl;inc;xsd - - - {945e9234-36d7-4bbb-a5f2-97af87338c49} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/messaging/messaging-vc11.vcxproj b/dist/examples/cxx/tree/messaging/messaging-vc11.vcxproj deleted file mode 100644 index d3403c2..0000000 --- a/dist/examples/cxx/tree/messaging/messaging-vc11.vcxproj +++ /dev/null @@ -1,213 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - messaging - {F7696252-45B5-438B-B14F-0510137704F0} - messaging - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - xsd protocol.xsd - xsd cxx-tree --root-element-all --generate-element-type --generate-element-map --generate-serialization protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-tree --root-element-all --generate-element-type --generate-element-map --generate-serialization protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-tree --root-element-all --generate-element-type --generate-element-map --generate-serialization protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-tree --root-element-all --generate-element-type --generate-element-map --generate-serialization protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/messaging/messaging-vc11.vcxproj.filters b/dist/examples/cxx/tree/messaging/messaging-vc11.vcxproj.filters deleted file mode 100644 index c94955d..0000000 --- a/dist/examples/cxx/tree/messaging/messaging-vc11.vcxproj.filters +++ /dev/null @@ -1,50 +0,0 @@ - - - - - {0BA0A3D7-40AF-4307-8033-5BE39B33ABE5} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {F7AC5A29-8CF7-4882-89B6-1B5B81AA00F2} - h;hpp;hxx;hm;inl;inc;xsd - - - {945e9234-36d7-4bbb-a5f2-97af87338c49} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/messaging/messaging-vc12.vcxproj b/dist/examples/cxx/tree/messaging/messaging-vc12.vcxproj deleted file mode 100644 index 35b8763..0000000 --- a/dist/examples/cxx/tree/messaging/messaging-vc12.vcxproj +++ /dev/null @@ -1,217 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - messaging - {F7696252-45B5-438B-B14F-0510137704F0} - messaging - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - xsd protocol.xsd - xsd cxx-tree --root-element-all --generate-element-type --generate-element-map --generate-serialization protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-tree --root-element-all --generate-element-type --generate-element-map --generate-serialization protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-tree --root-element-all --generate-element-type --generate-element-map --generate-serialization protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-tree --root-element-all --generate-element-type --generate-element-map --generate-serialization protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/messaging/messaging-vc12.vcxproj.filters b/dist/examples/cxx/tree/messaging/messaging-vc12.vcxproj.filters deleted file mode 100644 index c94955d..0000000 --- a/dist/examples/cxx/tree/messaging/messaging-vc12.vcxproj.filters +++ /dev/null @@ -1,50 +0,0 @@ - - - - - {0BA0A3D7-40AF-4307-8033-5BE39B33ABE5} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {F7AC5A29-8CF7-4882-89B6-1B5B81AA00F2} - h;hpp;hxx;hm;inl;inc;xsd - - - {945e9234-36d7-4bbb-a5f2-97af87338c49} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/messaging/messaging-vc8.vcproj b/dist/examples/cxx/tree/messaging/messaging-vc8.vcproj deleted file mode 100644 index f006365..0000000 --- a/dist/examples/cxx/tree/messaging/messaging-vc8.vcproj +++ /dev/null @@ -1,439 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/messaging/messaging-vc9.vcproj b/dist/examples/cxx/tree/messaging/messaging-vc9.vcproj deleted file mode 100644 index debd0a3..0000000 --- a/dist/examples/cxx/tree/messaging/messaging-vc9.vcproj +++ /dev/null @@ -1,436 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/mixed/makefile b/dist/examples/cxx/tree/mixed/makefile deleted file mode 100644 index 594821c..0000000 --- a/dist/examples/cxx/tree/mixed/makefile +++ /dev/null @@ -1,28 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -# Build. -# -driver: driver.o text.o - -text.o: text.cxx text.hxx -driver.o: driver.cxx text.hxx - -text.cxx text.hxx: text.xsd - - -# Test. -# -.PHONY: test -test: driver text.xml - ./driver text.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f text.o text.?xx driver.o driver diff --git a/dist/examples/cxx/tree/mixed/mixed-vc10.vcxproj b/dist/examples/cxx/tree/mixed/mixed-vc10.vcxproj deleted file mode 100644 index c625d2c..0000000 --- a/dist/examples/cxx/tree/mixed/mixed-vc10.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mixed - {6EF7868E-AA58-4615-9C1A-06B010CB4209} - mixed - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd text.xsd - xsd.exe cxx-tree text.xsd - text.cxx;text.hxx;%(Outputs) - xsd text.xsd - xsd.exe cxx-tree text.xsd - text.cxx;text.hxx;%(Outputs) - xsd text.xsd - xsd.exe cxx-tree text.xsd - text.cxx;text.hxx;%(Outputs) - xsd text.xsd - xsd.exe cxx-tree text.xsd - text.cxx;text.hxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/mixed/mixed-vc10.vcxproj.filters b/dist/examples/cxx/tree/mixed/mixed-vc10.vcxproj.filters deleted file mode 100644 index 992400e..0000000 --- a/dist/examples/cxx/tree/mixed/mixed-vc10.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {590B5830-837E-4D7F-984C-173456EE7E70} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {3B7C0CD8-48D5-4244-A1FB-B60D510C2359} - h;hpp;hxx;hm;inl;inc;xsd - - - {ba06cc21-c20a-4656-89ab-0a7b56f50871} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/mixed/mixed-vc11.vcxproj b/dist/examples/cxx/tree/mixed/mixed-vc11.vcxproj deleted file mode 100644 index 1380e1c..0000000 --- a/dist/examples/cxx/tree/mixed/mixed-vc11.vcxproj +++ /dev/null @@ -1,209 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mixed - {6EF7868E-AA58-4615-9C1A-06B010CB4209} - mixed - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd text.xsd - xsd.exe cxx-tree text.xsd - text.cxx;text.hxx;%(Outputs) - xsd text.xsd - xsd.exe cxx-tree text.xsd - text.cxx;text.hxx;%(Outputs) - xsd text.xsd - xsd.exe cxx-tree text.xsd - text.cxx;text.hxx;%(Outputs) - xsd text.xsd - xsd.exe cxx-tree text.xsd - text.cxx;text.hxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/mixed/mixed-vc11.vcxproj.filters b/dist/examples/cxx/tree/mixed/mixed-vc11.vcxproj.filters deleted file mode 100644 index 992400e..0000000 --- a/dist/examples/cxx/tree/mixed/mixed-vc11.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {590B5830-837E-4D7F-984C-173456EE7E70} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {3B7C0CD8-48D5-4244-A1FB-B60D510C2359} - h;hpp;hxx;hm;inl;inc;xsd - - - {ba06cc21-c20a-4656-89ab-0a7b56f50871} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/mixed/mixed-vc12.vcxproj b/dist/examples/cxx/tree/mixed/mixed-vc12.vcxproj deleted file mode 100644 index 7726386..0000000 --- a/dist/examples/cxx/tree/mixed/mixed-vc12.vcxproj +++ /dev/null @@ -1,213 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mixed - {6EF7868E-AA58-4615-9C1A-06B010CB4209} - mixed - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd text.xsd - xsd.exe cxx-tree text.xsd - text.cxx;text.hxx;%(Outputs) - xsd text.xsd - xsd.exe cxx-tree text.xsd - text.cxx;text.hxx;%(Outputs) - xsd text.xsd - xsd.exe cxx-tree text.xsd - text.cxx;text.hxx;%(Outputs) - xsd text.xsd - xsd.exe cxx-tree text.xsd - text.cxx;text.hxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/mixed/mixed-vc12.vcxproj.filters b/dist/examples/cxx/tree/mixed/mixed-vc12.vcxproj.filters deleted file mode 100644 index 992400e..0000000 --- a/dist/examples/cxx/tree/mixed/mixed-vc12.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {590B5830-837E-4D7F-984C-173456EE7E70} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {3B7C0CD8-48D5-4244-A1FB-B60D510C2359} - h;hpp;hxx;hm;inl;inc;xsd - - - {ba06cc21-c20a-4656-89ab-0a7b56f50871} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/mixed/mixed-vc8.vcproj b/dist/examples/cxx/tree/mixed/mixed-vc8.vcproj deleted file mode 100644 index d446891..0000000 --- a/dist/examples/cxx/tree/mixed/mixed-vc8.vcproj +++ /dev/null @@ -1,423 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/mixed/mixed-vc9.vcproj b/dist/examples/cxx/tree/mixed/mixed-vc9.vcproj deleted file mode 100644 index 5c5843a..0000000 --- a/dist/examples/cxx/tree/mixed/mixed-vc9.vcproj +++ /dev/null @@ -1,420 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/multiroot/makefile b/dist/examples/cxx/tree/multiroot/makefile deleted file mode 100644 index d94da7f..0000000 --- a/dist/examples/cxx/tree/multiroot/makefile +++ /dev/null @@ -1,33 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - -override XSDFLAGS += --root-element-all - - -# Build. -# -driver: driver.o dom-parse.o protocol.o - -protocol.o: protocol.cxx protocol.hxx -dom-parse.o: dom-parse.cxx dom-parse.hxx -driver.o: driver.cxx dom-parse.hxx protocol.hxx - -protocol.cxx protocol.hxx: protocol.xsd - - -# Test -# -.PHONY: test -test: driver balance.xml withdraw.xml deposit.xml - ./driver balance.xml - ./driver withdraw.xml - ./driver deposit.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f protocol.o protocol.?xx dom-parse.o driver.o driver diff --git a/dist/examples/cxx/tree/multiroot/multiroot-vc10.vcxproj b/dist/examples/cxx/tree/multiroot/multiroot-vc10.vcxproj deleted file mode 100644 index 3a10c32..0000000 --- a/dist/examples/cxx/tree/multiroot/multiroot-vc10.vcxproj +++ /dev/null @@ -1,207 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - multiroot - {1CFBC9C5-5F9C-4B60-A2A3-0A79BCDD2670} - multiroot - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - xsd protocol.xsd - xsd cxx-tree --root-element-all protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-tree --root-element-all protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-tree --root-element-all protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-tree --root-element-all protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/multiroot/multiroot-vc10.vcxproj.filters b/dist/examples/cxx/tree/multiroot/multiroot-vc10.vcxproj.filters deleted file mode 100644 index 148c832..0000000 --- a/dist/examples/cxx/tree/multiroot/multiroot-vc10.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - {761DEBB9-455C-4599-A11D-66D602C486C3} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {AAF07268-FD5E-485F-8EB8-1AFDDE8BFD57} - h;hpp;hxx;hm;inl;inc;xsd - - - {770136e0-0d08-4ab1-b67b-eabbde953e47} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/multiroot/multiroot-vc11.vcxproj b/dist/examples/cxx/tree/multiroot/multiroot-vc11.vcxproj deleted file mode 100644 index 61c6a44..0000000 --- a/dist/examples/cxx/tree/multiroot/multiroot-vc11.vcxproj +++ /dev/null @@ -1,211 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - multiroot - {1CFBC9C5-5F9C-4B60-A2A3-0A79BCDD2670} - multiroot - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - xsd protocol.xsd - xsd cxx-tree --root-element-all protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-tree --root-element-all protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-tree --root-element-all protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-tree --root-element-all protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/multiroot/multiroot-vc11.vcxproj.filters b/dist/examples/cxx/tree/multiroot/multiroot-vc11.vcxproj.filters deleted file mode 100644 index 148c832..0000000 --- a/dist/examples/cxx/tree/multiroot/multiroot-vc11.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - {761DEBB9-455C-4599-A11D-66D602C486C3} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {AAF07268-FD5E-485F-8EB8-1AFDDE8BFD57} - h;hpp;hxx;hm;inl;inc;xsd - - - {770136e0-0d08-4ab1-b67b-eabbde953e47} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/multiroot/multiroot-vc12.vcxproj b/dist/examples/cxx/tree/multiroot/multiroot-vc12.vcxproj deleted file mode 100644 index 1b0e268..0000000 --- a/dist/examples/cxx/tree/multiroot/multiroot-vc12.vcxproj +++ /dev/null @@ -1,215 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - multiroot - {1CFBC9C5-5F9C-4B60-A2A3-0A79BCDD2670} - multiroot - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - xsd protocol.xsd - xsd cxx-tree --root-element-all protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-tree --root-element-all protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-tree --root-element-all protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - xsd protocol.xsd - xsd cxx-tree --root-element-all protocol.xsd - protocol.hxx;protocol.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/multiroot/multiroot-vc12.vcxproj.filters b/dist/examples/cxx/tree/multiroot/multiroot-vc12.vcxproj.filters deleted file mode 100644 index 148c832..0000000 --- a/dist/examples/cxx/tree/multiroot/multiroot-vc12.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - {761DEBB9-455C-4599-A11D-66D602C486C3} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {AAF07268-FD5E-485F-8EB8-1AFDDE8BFD57} - h;hpp;hxx;hm;inl;inc;xsd - - - {770136e0-0d08-4ab1-b67b-eabbde953e47} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/multiroot/multiroot-vc8.vcproj b/dist/examples/cxx/tree/multiroot/multiroot-vc8.vcproj deleted file mode 100644 index 54e196d..0000000 --- a/dist/examples/cxx/tree/multiroot/multiroot-vc8.vcproj +++ /dev/null @@ -1,431 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/multiroot/multiroot-vc9.vcproj b/dist/examples/cxx/tree/multiroot/multiroot-vc9.vcproj deleted file mode 100644 index 95aa025..0000000 --- a/dist/examples/cxx/tree/multiroot/multiroot-vc9.vcproj +++ /dev/null @@ -1,428 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/order/element/makefile b/dist/examples/cxx/tree/order/element/makefile deleted file mode 100644 index 31f5ec5..0000000 --- a/dist/examples/cxx/tree/order/element/makefile +++ /dev/null @@ -1,31 +0,0 @@ -root := ../../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -override XSDFLAGS += --generate-serialization --generate-wildcard --ordered-type batch - - -# Build. -# -driver: driver.o transactions.o - -transactions.o: transactions.cxx transactions.hxx -driver.o: driver.cxx transactions.hxx - -transactions.cxx transactions.hxx: transactions.xsd - - -# Test -# -.PHONY: test -test: driver transactions.xml - ./driver transactions.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f transactions.o transactions.?xx driver.o driver diff --git a/dist/examples/cxx/tree/order/element/order-element-vc10.vcxproj b/dist/examples/cxx/tree/order/element/order-element-vc10.vcxproj deleted file mode 100644 index 100f0e8..0000000 --- a/dist/examples/cxx/tree/order/element/order-element-vc10.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - order-element - {9488E872-8E09-4B68-9715-AF68534164C4} - order-element - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd transactions.xsd - xsd.exe cxx-tree --generate-serialization --generate-wildcard --ordered-type batch transactions.xsd - transactions.cxx;transactions.hxx;%(Outputs) - xsd transactions.xsd - xsd.exe cxx-tree --generate-serialization --generate-wildcard --ordered-type batch transactions.xsd - transactions.cxx;transactions.hxx;%(Outputs) - xsd transactions.xsd - xsd.exe cxx-tree --generate-serialization --generate-wildcard --ordered-type batch transactions.xsd - transactions.cxx;transactions.hxx;%(Outputs) - xsd transactions.xsd - xsd.exe cxx-tree --generate-serialization --generate-wildcard --ordered-type batch transactions.xsd - transactions.cxx;transactions.hxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/order/element/order-element-vc10.vcxproj.filters b/dist/examples/cxx/tree/order/element/order-element-vc10.vcxproj.filters deleted file mode 100644 index aefc2be..0000000 --- a/dist/examples/cxx/tree/order/element/order-element-vc10.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {FF0C69B7-2DFB-402A-9AEB-A13D354EB9D2} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {9761A910-7322-4EBD-AD00-4FCC4C4F6586} - h;hpp;hxx;hm;inl;inc;xsd - - - {2264FACD-618F-417C-B291-7E2A1BD11536} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/order/element/order-element-vc11.vcxproj b/dist/examples/cxx/tree/order/element/order-element-vc11.vcxproj deleted file mode 100644 index da8304c..0000000 --- a/dist/examples/cxx/tree/order/element/order-element-vc11.vcxproj +++ /dev/null @@ -1,209 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - order-element - {9488E872-8E09-4B68-9715-AF68534164C4} - order-element - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd transactions.xsd - xsd.exe cxx-tree --generate-serialization --generate-wildcard --ordered-type batch transactions.xsd - transactions.cxx;transactions.hxx;%(Outputs) - xsd transactions.xsd - xsd.exe cxx-tree --generate-serialization --generate-wildcard --ordered-type batch transactions.xsd - transactions.cxx;transactions.hxx;%(Outputs) - xsd transactions.xsd - xsd.exe cxx-tree --generate-serialization --generate-wildcard --ordered-type batch transactions.xsd - transactions.cxx;transactions.hxx;%(Outputs) - xsd transactions.xsd - xsd.exe cxx-tree --generate-serialization --generate-wildcard --ordered-type batch transactions.xsd - transactions.cxx;transactions.hxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/order/element/order-element-vc11.vcxproj.filters b/dist/examples/cxx/tree/order/element/order-element-vc11.vcxproj.filters deleted file mode 100644 index aefc2be..0000000 --- a/dist/examples/cxx/tree/order/element/order-element-vc11.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {FF0C69B7-2DFB-402A-9AEB-A13D354EB9D2} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {9761A910-7322-4EBD-AD00-4FCC4C4F6586} - h;hpp;hxx;hm;inl;inc;xsd - - - {2264FACD-618F-417C-B291-7E2A1BD11536} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/order/element/order-element-vc12.vcxproj b/dist/examples/cxx/tree/order/element/order-element-vc12.vcxproj deleted file mode 100644 index 2364e27..0000000 --- a/dist/examples/cxx/tree/order/element/order-element-vc12.vcxproj +++ /dev/null @@ -1,213 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - order-element - {9488E872-8E09-4B68-9715-AF68534164C4} - order-element - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd transactions.xsd - xsd.exe cxx-tree --generate-serialization --generate-wildcard --ordered-type batch transactions.xsd - transactions.cxx;transactions.hxx;%(Outputs) - xsd transactions.xsd - xsd.exe cxx-tree --generate-serialization --generate-wildcard --ordered-type batch transactions.xsd - transactions.cxx;transactions.hxx;%(Outputs) - xsd transactions.xsd - xsd.exe cxx-tree --generate-serialization --generate-wildcard --ordered-type batch transactions.xsd - transactions.cxx;transactions.hxx;%(Outputs) - xsd transactions.xsd - xsd.exe cxx-tree --generate-serialization --generate-wildcard --ordered-type batch transactions.xsd - transactions.cxx;transactions.hxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/order/element/order-element-vc12.vcxproj.filters b/dist/examples/cxx/tree/order/element/order-element-vc12.vcxproj.filters deleted file mode 100644 index aefc2be..0000000 --- a/dist/examples/cxx/tree/order/element/order-element-vc12.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {FF0C69B7-2DFB-402A-9AEB-A13D354EB9D2} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {9761A910-7322-4EBD-AD00-4FCC4C4F6586} - h;hpp;hxx;hm;inl;inc;xsd - - - {2264FACD-618F-417C-B291-7E2A1BD11536} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/order/element/order-element-vc8.vcproj b/dist/examples/cxx/tree/order/element/order-element-vc8.vcproj deleted file mode 100644 index 06dd76d..0000000 --- a/dist/examples/cxx/tree/order/element/order-element-vc8.vcproj +++ /dev/null @@ -1,423 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/order/element/order-element-vc9.vcproj b/dist/examples/cxx/tree/order/element/order-element-vc9.vcproj deleted file mode 100644 index 74a0266..0000000 --- a/dist/examples/cxx/tree/order/element/order-element-vc9.vcproj +++ /dev/null @@ -1,420 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/order/makefile b/dist/examples/cxx/tree/order/makefile deleted file mode 100644 index 2713b6e..0000000 --- a/dist/examples/cxx/tree/order/makefile +++ /dev/null @@ -1,11 +0,0 @@ -dirs := element mixed - -.PHONY: all $(dirs) - -all: $(dirs) - -$(dirs): - @$(MAKE) -C $@ $(MAKECMDGOALS) - -makefile: ; -% :: $(dirs) ; diff --git a/dist/examples/cxx/tree/order/mixed/makefile b/dist/examples/cxx/tree/order/mixed/makefile deleted file mode 100644 index b7929d9..0000000 --- a/dist/examples/cxx/tree/order/mixed/makefile +++ /dev/null @@ -1,32 +0,0 @@ -root := ../../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -override XSDFLAGS += --generate-serialization --ordered-type-mixed - - -# Build. -# -driver: driver.o text.o - -text.o: text.cxx text.hxx -driver.o: driver.cxx text.hxx - -text.cxx text.hxx: text.xsd - - -# Test -# -.PHONY: test -test: driver text.xml - ./driver text.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f text.o text.?xx driver.o driver - diff --git a/dist/examples/cxx/tree/order/mixed/order-mixed-vc10.vcxproj b/dist/examples/cxx/tree/order/mixed/order-mixed-vc10.vcxproj deleted file mode 100644 index 69ed120..0000000 --- a/dist/examples/cxx/tree/order/mixed/order-mixed-vc10.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - order-mixed - {94A74673-C980-426B-B5BB-00744559EAD1} - order-mixed - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd text.xsd - xsd.exe cxx-tree --generate-serialization --ordered-type-mixed text.xsd - text.cxx;text.hxx;%(Outputs) - xsd text.xsd - xsd.exe cxx-tree --generate-serialization --ordered-type-mixed text.xsd - text.cxx;text.hxx;%(Outputs) - xsd text.xsd - xsd.exe cxx-tree --generate-serialization --ordered-type-mixed text.xsd - text.cxx;text.hxx;%(Outputs) - xsd text.xsd - xsd.exe cxx-tree --generate-serialization --ordered-type-mixed text.xsd - text.cxx;text.hxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/order/mixed/order-mixed-vc10.vcxproj.filters b/dist/examples/cxx/tree/order/mixed/order-mixed-vc10.vcxproj.filters deleted file mode 100644 index 422115b..0000000 --- a/dist/examples/cxx/tree/order/mixed/order-mixed-vc10.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {02F42C11-BDFB-4E9B-8E93-745AE1451A73} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {789E7294-E4D2-41DC-BDDA-4A333C3C2ED7} - h;hpp;hxx;hm;inl;inc;xsd - - - {BF59FE93-D0AC-48C0-998A-7AB994AFD9FE} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/order/mixed/order-mixed-vc11.vcxproj b/dist/examples/cxx/tree/order/mixed/order-mixed-vc11.vcxproj deleted file mode 100644 index 6f4ba84..0000000 --- a/dist/examples/cxx/tree/order/mixed/order-mixed-vc11.vcxproj +++ /dev/null @@ -1,209 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - order-mixed - {94A74673-C980-426B-B5BB-00744559EAD1} - order-mixed - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd text.xsd - xsd.exe cxx-tree --generate-serialization --ordered-type-mixed text.xsd - text.cxx;text.hxx;%(Outputs) - xsd text.xsd - xsd.exe cxx-tree --generate-serialization --ordered-type-mixed text.xsd - text.cxx;text.hxx;%(Outputs) - xsd text.xsd - xsd.exe cxx-tree --generate-serialization --ordered-type-mixed text.xsd - text.cxx;text.hxx;%(Outputs) - xsd text.xsd - xsd.exe cxx-tree --generate-serialization --ordered-type-mixed text.xsd - text.cxx;text.hxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/order/mixed/order-mixed-vc11.vcxproj.filters b/dist/examples/cxx/tree/order/mixed/order-mixed-vc11.vcxproj.filters deleted file mode 100644 index 422115b..0000000 --- a/dist/examples/cxx/tree/order/mixed/order-mixed-vc11.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {02F42C11-BDFB-4E9B-8E93-745AE1451A73} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {789E7294-E4D2-41DC-BDDA-4A333C3C2ED7} - h;hpp;hxx;hm;inl;inc;xsd - - - {BF59FE93-D0AC-48C0-998A-7AB994AFD9FE} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/order/mixed/order-mixed-vc12.vcxproj b/dist/examples/cxx/tree/order/mixed/order-mixed-vc12.vcxproj deleted file mode 100644 index 7408bef..0000000 --- a/dist/examples/cxx/tree/order/mixed/order-mixed-vc12.vcxproj +++ /dev/null @@ -1,213 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - order-mixed - {94A74673-C980-426B-B5BB-00744559EAD1} - order-mixed - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd text.xsd - xsd.exe cxx-tree --generate-serialization --ordered-type-mixed text.xsd - text.cxx;text.hxx;%(Outputs) - xsd text.xsd - xsd.exe cxx-tree --generate-serialization --ordered-type-mixed text.xsd - text.cxx;text.hxx;%(Outputs) - xsd text.xsd - xsd.exe cxx-tree --generate-serialization --ordered-type-mixed text.xsd - text.cxx;text.hxx;%(Outputs) - xsd text.xsd - xsd.exe cxx-tree --generate-serialization --ordered-type-mixed text.xsd - text.cxx;text.hxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/order/mixed/order-mixed-vc12.vcxproj.filters b/dist/examples/cxx/tree/order/mixed/order-mixed-vc12.vcxproj.filters deleted file mode 100644 index 422115b..0000000 --- a/dist/examples/cxx/tree/order/mixed/order-mixed-vc12.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {02F42C11-BDFB-4E9B-8E93-745AE1451A73} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {789E7294-E4D2-41DC-BDDA-4A333C3C2ED7} - h;hpp;hxx;hm;inl;inc;xsd - - - {BF59FE93-D0AC-48C0-998A-7AB994AFD9FE} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/order/mixed/order-mixed-vc8.vcproj b/dist/examples/cxx/tree/order/mixed/order-mixed-vc8.vcproj deleted file mode 100644 index 20cfe65..0000000 --- a/dist/examples/cxx/tree/order/mixed/order-mixed-vc8.vcproj +++ /dev/null @@ -1,423 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/order/mixed/order-mixed-vc9.vcproj b/dist/examples/cxx/tree/order/mixed/order-mixed-vc9.vcproj deleted file mode 100644 index c6861d9..0000000 --- a/dist/examples/cxx/tree/order/mixed/order-mixed-vc9.vcproj +++ /dev/null @@ -1,420 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/performance/makefile b/dist/examples/cxx/tree/performance/makefile deleted file mode 100644 index 80bf4be..0000000 --- a/dist/examples/cxx/tree/performance/makefile +++ /dev/null @@ -1,34 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -override XSDFLAGS += --generate-inline --generate-serialization - - -# Build. -# -driver: driver.o parsing.o serialization.o test.o time.o - -driver.o: driver.cxx -test.o: test.cxx test.hxx test.ixx -parsing.o: parsing.cxx test.hxx test.ixx time.hxx -serialization.o: serialization.cxx test.hxx test.ixx time.hxx -time.o: time.cxx time.hxx - -test.cxx test.hxx test.ixx: test.xsd - - -# Test -# -.PHONY: test -test: driver test-50k.xml - ./driver test-50k.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f test.o test.?xx driver.o parsing.o serialization.o time.o driver diff --git a/dist/examples/cxx/tree/performance/performance-vc10.vcxproj b/dist/examples/cxx/tree/performance/performance-vc10.vcxproj deleted file mode 100644 index 6651012..0000000 --- a/dist/examples/cxx/tree/performance/performance-vc10.vcxproj +++ /dev/null @@ -1,210 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - performance - {C60700D1-DB4B-4EFF-8EE9-97BD716BCB89} - performance - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - - xsd test.xsd - xsd cxx-tree --generate-inline --generate-serialization test.xsd - test.hxx;test.ixx;test.cxx;%(Outputs) - xsd test.xsd - xsd cxx-tree --generate-inline --generate-serialization test.xsd - test.hxx;test.ixx;test.cxx;%(Outputs) - xsd test.xsd - xsd cxx-tree --generate-inline --generate-serialization test.xsd - test.hxx;test.ixx;test.cxx;%(Outputs) - xsd test.xsd - xsd cxx-tree --generate-inline --generate-serialization test.xsd - test.hxx;test.ixx;test.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/performance/performance-vc10.vcxproj.filters b/dist/examples/cxx/tree/performance/performance-vc10.vcxproj.filters deleted file mode 100644 index 6fc7fa3..0000000 --- a/dist/examples/cxx/tree/performance/performance-vc10.vcxproj.filters +++ /dev/null @@ -1,57 +0,0 @@ - - - - - {4BF3D33D-891D-402D-A26F-AEBC35E127DE} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {FD93B741-02F9-48B5-BE59-E5DD2C73CC7A} - h;hpp;hxx;hm;inl;inc;xsd - - - {e0558eb1-4ecb-42e8-b50b-e07487e59072} - ixx - - - {47ef7335-e3a1-4832-bff0-c59ac4d25088} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/performance/performance-vc11.vcxproj b/dist/examples/cxx/tree/performance/performance-vc11.vcxproj deleted file mode 100644 index 8e3aa7c..0000000 --- a/dist/examples/cxx/tree/performance/performance-vc11.vcxproj +++ /dev/null @@ -1,214 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - performance - {C60700D1-DB4B-4EFF-8EE9-97BD716BCB89} - performance - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - - xsd test.xsd - xsd cxx-tree --generate-inline --generate-serialization test.xsd - test.hxx;test.ixx;test.cxx;%(Outputs) - xsd test.xsd - xsd cxx-tree --generate-inline --generate-serialization test.xsd - test.hxx;test.ixx;test.cxx;%(Outputs) - xsd test.xsd - xsd cxx-tree --generate-inline --generate-serialization test.xsd - test.hxx;test.ixx;test.cxx;%(Outputs) - xsd test.xsd - xsd cxx-tree --generate-inline --generate-serialization test.xsd - test.hxx;test.ixx;test.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/performance/performance-vc11.vcxproj.filters b/dist/examples/cxx/tree/performance/performance-vc11.vcxproj.filters deleted file mode 100644 index 6fc7fa3..0000000 --- a/dist/examples/cxx/tree/performance/performance-vc11.vcxproj.filters +++ /dev/null @@ -1,57 +0,0 @@ - - - - - {4BF3D33D-891D-402D-A26F-AEBC35E127DE} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {FD93B741-02F9-48B5-BE59-E5DD2C73CC7A} - h;hpp;hxx;hm;inl;inc;xsd - - - {e0558eb1-4ecb-42e8-b50b-e07487e59072} - ixx - - - {47ef7335-e3a1-4832-bff0-c59ac4d25088} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/performance/performance-vc12.vcxproj b/dist/examples/cxx/tree/performance/performance-vc12.vcxproj deleted file mode 100644 index 38193f7..0000000 --- a/dist/examples/cxx/tree/performance/performance-vc12.vcxproj +++ /dev/null @@ -1,218 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - performance - {C60700D1-DB4B-4EFF-8EE9-97BD716BCB89} - performance - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - - xsd test.xsd - xsd cxx-tree --generate-inline --generate-serialization test.xsd - test.hxx;test.ixx;test.cxx;%(Outputs) - xsd test.xsd - xsd cxx-tree --generate-inline --generate-serialization test.xsd - test.hxx;test.ixx;test.cxx;%(Outputs) - xsd test.xsd - xsd cxx-tree --generate-inline --generate-serialization test.xsd - test.hxx;test.ixx;test.cxx;%(Outputs) - xsd test.xsd - xsd cxx-tree --generate-inline --generate-serialization test.xsd - test.hxx;test.ixx;test.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/performance/performance-vc12.vcxproj.filters b/dist/examples/cxx/tree/performance/performance-vc12.vcxproj.filters deleted file mode 100644 index 6fc7fa3..0000000 --- a/dist/examples/cxx/tree/performance/performance-vc12.vcxproj.filters +++ /dev/null @@ -1,57 +0,0 @@ - - - - - {4BF3D33D-891D-402D-A26F-AEBC35E127DE} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {FD93B741-02F9-48B5-BE59-E5DD2C73CC7A} - h;hpp;hxx;hm;inl;inc;xsd - - - {e0558eb1-4ecb-42e8-b50b-e07487e59072} - ixx - - - {47ef7335-e3a1-4832-bff0-c59ac4d25088} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/performance/performance-vc8.vcproj b/dist/examples/cxx/tree/performance/performance-vc8.vcproj deleted file mode 100644 index e49587d..0000000 --- a/dist/examples/cxx/tree/performance/performance-vc8.vcproj +++ /dev/null @@ -1,445 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/performance/performance-vc9.vcproj b/dist/examples/cxx/tree/performance/performance-vc9.vcproj deleted file mode 100644 index fa23a74..0000000 --- a/dist/examples/cxx/tree/performance/performance-vc9.vcproj +++ /dev/null @@ -1,442 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/polymorphism/makefile b/dist/examples/cxx/tree/polymorphism/makefile deleted file mode 100644 index 282266e..0000000 --- a/dist/examples/cxx/tree/polymorphism/makefile +++ /dev/null @@ -1,30 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - -override XSDFLAGS += --generate-polymorphic --generate-serialization --root-element-last - - -# Build. -# -driver: driver.o supermen.o - -supermen.o: supermen.cxx supermen.hxx -driver.o: driver.cxx supermen.hxx - -supermen.cxx supermen.hxx: supermen.xsd - - -# Test. -# -.PHONY: test -test: driver supermen.xml - ./driver supermen.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f supermen.o supermen.?xx driver.o driver diff --git a/dist/examples/cxx/tree/polymorphism/polymorphism-vc10.vcxproj b/dist/examples/cxx/tree/polymorphism/polymorphism-vc10.vcxproj deleted file mode 100644 index 4a693ec..0000000 --- a/dist/examples/cxx/tree/polymorphism/polymorphism-vc10.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - polymorphism - {03224289-FD3C-4A58-A6D7-E8D658B0E45A} - polymorphism - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd supermen.xsd - xsd.exe cxx-tree --generate-polymorphic --generate-serialization --root-element-last supermen.xsd - supermen.cxx;supermen.hxx;%(Outputs) - xsd supermen.xsd - xsd.exe cxx-tree --generate-polymorphic --generate-serialization --root-element-last supermen.xsd - supermen.cxx;supermen.hxx;%(Outputs) - xsd supermen.xsd - xsd.exe cxx-tree --generate-polymorphic --generate-serialization --root-element-last supermen.xsd - supermen.cxx;supermen.hxx;%(Outputs) - xsd supermen.xsd - xsd.exe cxx-tree --generate-polymorphic --generate-serialization --root-element-last supermen.xsd - supermen.cxx;supermen.hxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/polymorphism/polymorphism-vc10.vcxproj.filters b/dist/examples/cxx/tree/polymorphism/polymorphism-vc10.vcxproj.filters deleted file mode 100644 index 4459d2c..0000000 --- a/dist/examples/cxx/tree/polymorphism/polymorphism-vc10.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {A02BB28E-3A7B-4E9E-A2AC-AA264C62525C} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {6B2184D0-2125-48EB-AE80-64E24055DCE4} - h;hpp;hxx;hm;inl;inc;xsd - - - {e32c9352-17dd-4c6c-b9fa-fadaf6eee928} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/polymorphism/polymorphism-vc11.vcxproj b/dist/examples/cxx/tree/polymorphism/polymorphism-vc11.vcxproj deleted file mode 100644 index d8f0aa0..0000000 --- a/dist/examples/cxx/tree/polymorphism/polymorphism-vc11.vcxproj +++ /dev/null @@ -1,209 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - polymorphism - {03224289-FD3C-4A58-A6D7-E8D658B0E45A} - polymorphism - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd supermen.xsd - xsd.exe cxx-tree --generate-polymorphic --generate-serialization --root-element-last supermen.xsd - supermen.cxx;supermen.hxx;%(Outputs) - xsd supermen.xsd - xsd.exe cxx-tree --generate-polymorphic --generate-serialization --root-element-last supermen.xsd - supermen.cxx;supermen.hxx;%(Outputs) - xsd supermen.xsd - xsd.exe cxx-tree --generate-polymorphic --generate-serialization --root-element-last supermen.xsd - supermen.cxx;supermen.hxx;%(Outputs) - xsd supermen.xsd - xsd.exe cxx-tree --generate-polymorphic --generate-serialization --root-element-last supermen.xsd - supermen.cxx;supermen.hxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/polymorphism/polymorphism-vc11.vcxproj.filters b/dist/examples/cxx/tree/polymorphism/polymorphism-vc11.vcxproj.filters deleted file mode 100644 index 4459d2c..0000000 --- a/dist/examples/cxx/tree/polymorphism/polymorphism-vc11.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {A02BB28E-3A7B-4E9E-A2AC-AA264C62525C} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {6B2184D0-2125-48EB-AE80-64E24055DCE4} - h;hpp;hxx;hm;inl;inc;xsd - - - {e32c9352-17dd-4c6c-b9fa-fadaf6eee928} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/polymorphism/polymorphism-vc12.vcxproj b/dist/examples/cxx/tree/polymorphism/polymorphism-vc12.vcxproj deleted file mode 100644 index 040d657..0000000 --- a/dist/examples/cxx/tree/polymorphism/polymorphism-vc12.vcxproj +++ /dev/null @@ -1,213 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - polymorphism - {03224289-FD3C-4A58-A6D7-E8D658B0E45A} - polymorphism - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - xsd supermen.xsd - xsd.exe cxx-tree --generate-polymorphic --generate-serialization --root-element-last supermen.xsd - supermen.cxx;supermen.hxx;%(Outputs) - xsd supermen.xsd - xsd.exe cxx-tree --generate-polymorphic --generate-serialization --root-element-last supermen.xsd - supermen.cxx;supermen.hxx;%(Outputs) - xsd supermen.xsd - xsd.exe cxx-tree --generate-polymorphic --generate-serialization --root-element-last supermen.xsd - supermen.cxx;supermen.hxx;%(Outputs) - xsd supermen.xsd - xsd.exe cxx-tree --generate-polymorphic --generate-serialization --root-element-last supermen.xsd - supermen.cxx;supermen.hxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/polymorphism/polymorphism-vc12.vcxproj.filters b/dist/examples/cxx/tree/polymorphism/polymorphism-vc12.vcxproj.filters deleted file mode 100644 index 4459d2c..0000000 --- a/dist/examples/cxx/tree/polymorphism/polymorphism-vc12.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {A02BB28E-3A7B-4E9E-A2AC-AA264C62525C} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {6B2184D0-2125-48EB-AE80-64E24055DCE4} - h;hpp;hxx;hm;inl;inc;xsd - - - {e32c9352-17dd-4c6c-b9fa-fadaf6eee928} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/polymorphism/polymorphism-vc8.vcproj b/dist/examples/cxx/tree/polymorphism/polymorphism-vc8.vcproj deleted file mode 100644 index d146d0e..0000000 --- a/dist/examples/cxx/tree/polymorphism/polymorphism-vc8.vcproj +++ /dev/null @@ -1,423 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/polymorphism/polymorphism-vc9.vcproj b/dist/examples/cxx/tree/polymorphism/polymorphism-vc9.vcproj deleted file mode 100644 index 3d56cf8..0000000 --- a/dist/examples/cxx/tree/polymorphism/polymorphism-vc9.vcproj +++ /dev/null @@ -1,420 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/secure/makefile b/dist/examples/cxx/tree/secure/makefile deleted file mode 100644 index 4898a10..0000000 --- a/dist/examples/cxx/tree/secure/makefile +++ /dev/null @@ -1,28 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - -# Build. -# -driver: driver.o secure-dom-parser.o library.o - -library.o: library.cxx library.hxx -secure-dom-parser.o: secure-dom-parser.cxx secure-dom-parser.hxx -driver.o: driver.cxx secure-dom-parser.hxx library.hxx - -library.cxx library.hxx: library.xsd - - -# Test -# -.PHONY: test -test: driver library.xml - ./driver library.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f library.o library.?xx secure-dom-parser.o driver.o driver diff --git a/dist/examples/cxx/tree/streaming/makefile b/dist/examples/cxx/tree/streaming/makefile deleted file mode 100644 index 4c7acd2..0000000 --- a/dist/examples/cxx/tree/streaming/makefile +++ /dev/null @@ -1,34 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -override XSDFLAGS += --generate-serialization - - -# Build. -# -driver: driver.o parser.o serializer.o grammar-input-stream.o position.o - -position.o: position.cxx position.hxx -driver.o: driver.cxx position.hxx parser.hxx serializer.hxx -parser.o: parser.cxx parser.hxx -serializer.o: serializer.cxx serializer.hxx -grammar-input-stream.o: grammar-input-stream.cxx grammar-input-stream.hxx - -position.cxx position.hxx: position.xsd - - -# Test -# -.PHONY: test -test: driver position.xml - ./driver position.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f position.o position.?xx parser.o serializer.o grammar-input-stream.o driver.o driver out.xml diff --git a/dist/examples/cxx/tree/streaming/streaming-vc10.vcxproj b/dist/examples/cxx/tree/streaming/streaming-vc10.vcxproj deleted file mode 100644 index cf23e2a..0000000 --- a/dist/examples/cxx/tree/streaming/streaming-vc10.vcxproj +++ /dev/null @@ -1,211 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - streaming - {3950B11C-AEB1-4E9C-BCB3-2E7133818C79} - streaming - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - xsd position.xsd - xsd.exe cxx-tree --generate-serialization position.xsd - position.cxx;position.hxx;%(Outputs) - xsd position.xsd - xsd.exe cxx-tree --generate-serialization position.xsd - position.cxx;position.hxx;%(Outputs) - xsd position.xsd - xsd.exe cxx-tree --generate-serialization position.xsd - position.cxx;position.hxx;%(Outputs) - xsd position.xsd - xsd.exe cxx-tree --generate-serialization position.xsd - position.cxx;position.hxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/streaming/streaming-vc10.vcxproj.filters b/dist/examples/cxx/tree/streaming/streaming-vc10.vcxproj.filters deleted file mode 100644 index 3597703..0000000 --- a/dist/examples/cxx/tree/streaming/streaming-vc10.vcxproj.filters +++ /dev/null @@ -1,56 +0,0 @@ - - - - - {4F684AD4-DFB2-4488-BA73-8625AECC91A3} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {94F3375D-5EB8-4D2C-8739-4D47E9AB7072} - h;hpp;hxx;hm;inl;inc;xsd - - - {b73125d6-60b1-4f32-9cfb-d11e709d0d14} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/streaming/streaming-vc11.vcxproj b/dist/examples/cxx/tree/streaming/streaming-vc11.vcxproj deleted file mode 100644 index 28f008c..0000000 --- a/dist/examples/cxx/tree/streaming/streaming-vc11.vcxproj +++ /dev/null @@ -1,215 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - streaming - {3950B11C-AEB1-4E9C-BCB3-2E7133818C79} - streaming - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - xsd position.xsd - xsd.exe cxx-tree --generate-serialization position.xsd - position.cxx;position.hxx;%(Outputs) - xsd position.xsd - xsd.exe cxx-tree --generate-serialization position.xsd - position.cxx;position.hxx;%(Outputs) - xsd position.xsd - xsd.exe cxx-tree --generate-serialization position.xsd - position.cxx;position.hxx;%(Outputs) - xsd position.xsd - xsd.exe cxx-tree --generate-serialization position.xsd - position.cxx;position.hxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/streaming/streaming-vc11.vcxproj.filters b/dist/examples/cxx/tree/streaming/streaming-vc11.vcxproj.filters deleted file mode 100644 index 3597703..0000000 --- a/dist/examples/cxx/tree/streaming/streaming-vc11.vcxproj.filters +++ /dev/null @@ -1,56 +0,0 @@ - - - - - {4F684AD4-DFB2-4488-BA73-8625AECC91A3} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {94F3375D-5EB8-4D2C-8739-4D47E9AB7072} - h;hpp;hxx;hm;inl;inc;xsd - - - {b73125d6-60b1-4f32-9cfb-d11e709d0d14} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/streaming/streaming-vc12.vcxproj b/dist/examples/cxx/tree/streaming/streaming-vc12.vcxproj deleted file mode 100644 index 5e69c30..0000000 --- a/dist/examples/cxx/tree/streaming/streaming-vc12.vcxproj +++ /dev/null @@ -1,219 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - streaming - {3950B11C-AEB1-4E9C-BCB3-2E7133818C79} - streaming - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - - xsd position.xsd - xsd.exe cxx-tree --generate-serialization position.xsd - position.cxx;position.hxx;%(Outputs) - xsd position.xsd - xsd.exe cxx-tree --generate-serialization position.xsd - position.cxx;position.hxx;%(Outputs) - xsd position.xsd - xsd.exe cxx-tree --generate-serialization position.xsd - position.cxx;position.hxx;%(Outputs) - xsd position.xsd - xsd.exe cxx-tree --generate-serialization position.xsd - position.cxx;position.hxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/streaming/streaming-vc12.vcxproj.filters b/dist/examples/cxx/tree/streaming/streaming-vc12.vcxproj.filters deleted file mode 100644 index 3597703..0000000 --- a/dist/examples/cxx/tree/streaming/streaming-vc12.vcxproj.filters +++ /dev/null @@ -1,56 +0,0 @@ - - - - - {4F684AD4-DFB2-4488-BA73-8625AECC91A3} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {94F3375D-5EB8-4D2C-8739-4D47E9AB7072} - h;hpp;hxx;hm;inl;inc;xsd - - - {b73125d6-60b1-4f32-9cfb-d11e709d0d14} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/streaming/streaming-vc8.vcproj b/dist/examples/cxx/tree/streaming/streaming-vc8.vcproj deleted file mode 100644 index 354c0ff..0000000 --- a/dist/examples/cxx/tree/streaming/streaming-vc8.vcproj +++ /dev/null @@ -1,441 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/streaming/streaming-vc9.vcproj b/dist/examples/cxx/tree/streaming/streaming-vc9.vcproj deleted file mode 100644 index e6b75f3..0000000 --- a/dist/examples/cxx/tree/streaming/streaming-vc9.vcproj +++ /dev/null @@ -1,438 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/wildcard/makefile b/dist/examples/cxx/tree/wildcard/makefile deleted file mode 100644 index 148b800..0000000 --- a/dist/examples/cxx/tree/wildcard/makefile +++ /dev/null @@ -1,32 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - - -override XSDFLAGS += --generate-inline --generate-serialization \ ---generate-wildcard --root-element message - - -# Build. -# -driver: driver.o email.o - -email.o: email.cxx email.hxx email.ixx -driver.o: driver.cxx email.hxx email.ixx - -email.cxx email.hxx email.ixx: email.xsd - - -# Test -# -.PHONY: test -test: driver email.xml - ./driver email.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f email.o email.?xx driver.o driver diff --git a/dist/examples/cxx/tree/wildcard/wildcard-vc10.vcxproj b/dist/examples/cxx/tree/wildcard/wildcard-vc10.vcxproj deleted file mode 100644 index 6d5b02e..0000000 --- a/dist/examples/cxx/tree/wildcard/wildcard-vc10.vcxproj +++ /dev/null @@ -1,206 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - wildcard - {13C21A83-CC75-459E-9B01-E9EC36D1524B} - wildcard - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - xsd email.xsd - xsd cxx-tree --generate-inline --generate-serialization --generate-wildcard --root-element message email.xsd - email.hxx;email.ixx;email.cxx;%(Outputs) - xsd email.xsd - xsd cxx-tree --generate-inline --generate-serialization --generate-wildcard --root-element message email.xsd - email.hxx;email.ixx;email.cxx;%(Outputs) - xsd email.xsd - xsd cxx-tree --generate-inline --generate-serialization --generate-wildcard --root-element message email.xsd - email.hxx;email.ixx;email.cxx;%(Outputs) - xsd email.xsd - xsd cxx-tree --generate-inline --generate-serialization --generate-wildcard --root-element message email.xsd - email.hxx;email.ixx;email.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/wildcard/wildcard-vc10.vcxproj.filters b/dist/examples/cxx/tree/wildcard/wildcard-vc10.vcxproj.filters deleted file mode 100644 index 541b946..0000000 --- a/dist/examples/cxx/tree/wildcard/wildcard-vc10.vcxproj.filters +++ /dev/null @@ -1,45 +0,0 @@ - - - - - {C8C63C87-F9B5-4EDF-B4BF-2701982EFCE6} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {E8933542-EAF8-45F5-94AE-AE8D55E47565} - h;hpp;hxx;hm;inl;inc;xsd - - - {79291748-08c5-4298-a090-a210ea0e7161} - ixx - - - {e83a7a6b-3537-4eea-bf81-494a6fcee412} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/wildcard/wildcard-vc11.vcxproj b/dist/examples/cxx/tree/wildcard/wildcard-vc11.vcxproj deleted file mode 100644 index 8043842..0000000 --- a/dist/examples/cxx/tree/wildcard/wildcard-vc11.vcxproj +++ /dev/null @@ -1,210 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - wildcard - {13C21A83-CC75-459E-9B01-E9EC36D1524B} - wildcard - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - xsd email.xsd - xsd cxx-tree --generate-inline --generate-serialization --generate-wildcard --root-element message email.xsd - email.hxx;email.ixx;email.cxx;%(Outputs) - xsd email.xsd - xsd cxx-tree --generate-inline --generate-serialization --generate-wildcard --root-element message email.xsd - email.hxx;email.ixx;email.cxx;%(Outputs) - xsd email.xsd - xsd cxx-tree --generate-inline --generate-serialization --generate-wildcard --root-element message email.xsd - email.hxx;email.ixx;email.cxx;%(Outputs) - xsd email.xsd - xsd cxx-tree --generate-inline --generate-serialization --generate-wildcard --root-element message email.xsd - email.hxx;email.ixx;email.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/wildcard/wildcard-vc11.vcxproj.filters b/dist/examples/cxx/tree/wildcard/wildcard-vc11.vcxproj.filters deleted file mode 100644 index 541b946..0000000 --- a/dist/examples/cxx/tree/wildcard/wildcard-vc11.vcxproj.filters +++ /dev/null @@ -1,45 +0,0 @@ - - - - - {C8C63C87-F9B5-4EDF-B4BF-2701982EFCE6} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {E8933542-EAF8-45F5-94AE-AE8D55E47565} - h;hpp;hxx;hm;inl;inc;xsd - - - {79291748-08c5-4298-a090-a210ea0e7161} - ixx - - - {e83a7a6b-3537-4eea-bf81-494a6fcee412} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/wildcard/wildcard-vc12.vcxproj b/dist/examples/cxx/tree/wildcard/wildcard-vc12.vcxproj deleted file mode 100644 index e324659..0000000 --- a/dist/examples/cxx/tree/wildcard/wildcard-vc12.vcxproj +++ /dev/null @@ -1,214 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - wildcard - {13C21A83-CC75-459E-9B01-E9EC36D1524B} - wildcard - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - xsd email.xsd - xsd cxx-tree --generate-inline --generate-serialization --generate-wildcard --root-element message email.xsd - email.hxx;email.ixx;email.cxx;%(Outputs) - xsd email.xsd - xsd cxx-tree --generate-inline --generate-serialization --generate-wildcard --root-element message email.xsd - email.hxx;email.ixx;email.cxx;%(Outputs) - xsd email.xsd - xsd cxx-tree --generate-inline --generate-serialization --generate-wildcard --root-element message email.xsd - email.hxx;email.ixx;email.cxx;%(Outputs) - xsd email.xsd - xsd cxx-tree --generate-inline --generate-serialization --generate-wildcard --root-element message email.xsd - email.hxx;email.ixx;email.cxx;%(Outputs) - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/wildcard/wildcard-vc12.vcxproj.filters b/dist/examples/cxx/tree/wildcard/wildcard-vc12.vcxproj.filters deleted file mode 100644 index 541b946..0000000 --- a/dist/examples/cxx/tree/wildcard/wildcard-vc12.vcxproj.filters +++ /dev/null @@ -1,45 +0,0 @@ - - - - - {C8C63C87-F9B5-4EDF-B4BF-2701982EFCE6} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {E8933542-EAF8-45F5-94AE-AE8D55E47565} - h;hpp;hxx;hm;inl;inc;xsd - - - {79291748-08c5-4298-a090-a210ea0e7161} - ixx - - - {e83a7a6b-3537-4eea-bf81-494a6fcee412} - xsd - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - Inline Files - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/wildcard/wildcard-vc8.vcproj b/dist/examples/cxx/tree/wildcard/wildcard-vc8.vcproj deleted file mode 100644 index 046230a..0000000 --- a/dist/examples/cxx/tree/wildcard/wildcard-vc8.vcproj +++ /dev/null @@ -1,432 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/wildcard/wildcard-vc9.vcproj b/dist/examples/cxx/tree/wildcard/wildcard-vc9.vcproj deleted file mode 100644 index 08c2b1d..0000000 --- a/dist/examples/cxx/tree/wildcard/wildcard-vc9.vcproj +++ /dev/null @@ -1,429 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/xpath/makefile b/dist/examples/cxx/tree/xpath/makefile deleted file mode 100644 index d5f2833..0000000 --- a/dist/examples/cxx/tree/xpath/makefile +++ /dev/null @@ -1,30 +0,0 @@ -root := ../../.. - -include $(root)/build/cxx/rules.make -include $(root)/build/xsd/tree-rules.make - -override LIBS += -lxqilla - -# Build. -# -driver: driver.o people.o dom-parse.o - -people.o: people.cxx people.hxx -driver.o: driver.cxx people.hxx dom-parse.hxx -people.o: dom-parse.cxx dom-parse.hxx - -people.cxx people.hxx: people.xsd - - -# Test -# -.PHONY: test -test: driver people.xml - ./driver people.xml - - -# Clean. -# -.PHONY: clean -clean: - rm -f people.o people.?xx driver.o dom-parse.o driver diff --git a/dist/examples/cxx/tree/xpath/xpath-vc10.vcxproj b/dist/examples/cxx/tree/xpath/xpath-vc10.vcxproj deleted file mode 100644 index 60ef726..0000000 --- a/dist/examples/cxx/tree/xpath/xpath-vc10.vcxproj +++ /dev/null @@ -1,207 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - xpath - {EC26ACF9-0103-48D2-B7BA-0222C2175B28} - xpath - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;xqilla22d.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;xqilla22d.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;xqilla22.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;xqilla22.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - xsd people.xsd - xsd cxx-tree people.xsd - people.hxx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree people.xsd - people.hxx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree people.xsd - people.hxx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree people.xsd - people.hxx;people.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/xpath/xpath-vc10.vcxproj.filters b/dist/examples/cxx/tree/xpath/xpath-vc10.vcxproj.filters deleted file mode 100644 index d038587..0000000 --- a/dist/examples/cxx/tree/xpath/xpath-vc10.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - {0A690AC0-4B5A-4FCA-B2CC-A61C00F01283} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {19387534-A72F-4C3F-A9FB-F5B8909AEB29} - h;hpp;hxx;hm;inl;inc;xsd - - - {807745b4-2087-4ccb-8fdc-8160206a3042} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/xpath/xpath-vc11.vcxproj b/dist/examples/cxx/tree/xpath/xpath-vc11.vcxproj deleted file mode 100644 index b758594..0000000 --- a/dist/examples/cxx/tree/xpath/xpath-vc11.vcxproj +++ /dev/null @@ -1,211 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - xpath - {EC26ACF9-0103-48D2-B7BA-0222C2175B28} - xpath - Win32Proj - - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - Application - v110 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;xqilla22d.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - - - xerces-c_3D.lib;xqilla22d.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;xqilla22.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - - - xerces-c_3.lib;xqilla22.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - xsd people.xsd - xsd cxx-tree people.xsd - people.hxx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree people.xsd - people.hxx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree people.xsd - people.hxx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree people.xsd - people.hxx;people.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/xpath/xpath-vc11.vcxproj.filters b/dist/examples/cxx/tree/xpath/xpath-vc11.vcxproj.filters deleted file mode 100644 index d038587..0000000 --- a/dist/examples/cxx/tree/xpath/xpath-vc11.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - {0A690AC0-4B5A-4FCA-B2CC-A61C00F01283} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {19387534-A72F-4C3F-A9FB-F5B8909AEB29} - h;hpp;hxx;hm;inl;inc;xsd - - - {807745b4-2087-4ccb-8fdc-8160206a3042} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/xpath/xpath-vc12.vcxproj b/dist/examples/cxx/tree/xpath/xpath-vc12.vcxproj deleted file mode 100644 index ff81b9e..0000000 --- a/dist/examples/cxx/tree/xpath/xpath-vc12.vcxproj +++ /dev/null @@ -1,215 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - xpath - {EC26ACF9-0103-48D2-B7BA-0222C2175B28} - xpath - Win32Proj - - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - - - - - driver - driver - driver - driver - Debug\ - Debug\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - Release\ - Release\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;xqilla22d.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - true - - - xerces-c_3D.lib;xqilla22d.lib;%(AdditionalDependencies) - $(TargetPath) - true - $(OutDir)driver.pdb - Console - false - - - MachineX64 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;xqilla22.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - true - - - xerces-c_3.lib;xqilla22.lib;%(AdditionalDependencies) - $(TargetPath) - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - xsd people.xsd - xsd cxx-tree people.xsd - people.hxx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree people.xsd - people.hxx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree people.xsd - people.hxx;people.cxx;%(Outputs) - xsd people.xsd - xsd cxx-tree people.xsd - people.hxx;people.cxx;%(Outputs) - - - - - - - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/xpath/xpath-vc12.vcxproj.filters b/dist/examples/cxx/tree/xpath/xpath-vc12.vcxproj.filters deleted file mode 100644 index d038587..0000000 --- a/dist/examples/cxx/tree/xpath/xpath-vc12.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - {0A690AC0-4B5A-4FCA-B2CC-A61C00F01283} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {19387534-A72F-4C3F-A9FB-F5B8909AEB29} - h;hpp;hxx;hm;inl;inc;xsd - - - {807745b4-2087-4ccb-8fdc-8160206a3042} - xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - - - - - - Schema Files - - - \ No newline at end of file diff --git a/dist/examples/cxx/tree/xpath/xpath-vc8.vcproj b/dist/examples/cxx/tree/xpath/xpath-vc8.vcproj deleted file mode 100644 index 3900265..0000000 --- a/dist/examples/cxx/tree/xpath/xpath-vc8.vcproj +++ /dev/null @@ -1,431 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/cxx/tree/xpath/xpath-vc9.vcproj b/dist/examples/cxx/tree/xpath/xpath-vc9.vcproj deleted file mode 100644 index b21a65e..0000000 --- a/dist/examples/cxx/tree/xpath/xpath-vc9.vcproj +++ /dev/null @@ -1,428 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/examples/makefile b/dist/examples/makefile deleted file mode 100644 index 5b8947e..0000000 --- a/dist/examples/makefile +++ /dev/null @@ -1,11 +0,0 @@ -dirs := cxx - -.PHONY: all $(dirs) - -all: $(dirs) - -$(dirs): - $(MAKE) -C $@ $(MAKECMDGOALS) - -makefile: ; -% :: $(dirs) ; diff --git a/dist/examples/test.bat b/dist/examples/test.bat deleted file mode 100644 index 1ca7779..0000000 --- a/dist/examples/test.bat +++ /dev/null @@ -1,73 +0,0 @@ -@echo off -rem file : examples/test.bat -rem license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -setlocal - -set "tests=__path__(dirs)" -set "confs=__path__(configurations)" -set "plats=__path__(platforms)" -set "curdir=%CD%" -set "topdir=%curdir%\..\.." -set "failed=" - -goto start - -rem -rem %1 - test directory -rem %2 - configuration -rem %3 - platform -rem -:run_test - cd %1 - - if "_%3_" == "_Win32_" ( - set "dir=%2" - ) else ( - set "dir=%3\%2" - ) - - if exist %dir%\driver.exe ( - echo %1\%3\%2 - call %topdir%\tester.bat %2 %3 - if errorlevel 1 ( - set "failed=%failed% %1\%3\%2" - ) - ) - - cd %curdir% -goto :eof - -:start - -for %%t in (%tests%) do ( - for %%c in (%confs%) do ( - for %%p in (%plats%) do ( - call :run_test %%t %%c %%p - ) - ) -) - -if not "_%failed%_" == "__" goto error - -echo. -echo ALL EXAMPLES PASSED -echo. -goto end - -:usage -echo. -echo usage: test.bat -echo. - -:error -if not "_%failed%_" == "__" ( - echo. - for %%t in (%failed%) do echo FAILED: %%t - echo. -) -endlocal -exit /b 1 - -:end -endlocal diff --git a/dist/examples/tester.bat b/dist/examples/tester.bat deleted file mode 100644 index 372d90a..0000000 --- a/dist/examples/tester.bat +++ /dev/null @@ -1,46 +0,0 @@ -@echo off -rem file : examples/tester.bat -rem license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -rem -rem Run example. The example directory is the current directory. -rem -rem %1 configuration, for example, Debug or Release -rem %2 platform, for example Win32 or x64 -rem - -setlocal - -if "_%DIFF%_" == "__" set DIFF=fc - -if "_%2_" == "_Win32_" ( - set "dir=%1" -) else ( - set "dir=%2\%1" -) - -rem Globbing returns files in alphabetic order. We also need to cover -rem compressed XML files (.xml.gz). -rem -if exist *.xml* ( - for %%f in (*.xml*) do ( - if NOT "%%f" == "out.xml" ( - if NOT "%%f" == "out.xml.gz" ( - %dir%\driver.exe %%f - if errorlevel 1 goto error - ) - ) - ) -) else ( - %dir%\driver.exe - if errorlevel 1 goto error -) - -goto end - -:error -endlocal -exit /b 1 - -:end -endlocal diff --git a/dist/template-vc10.sln b/dist/template-vc10.sln deleted file mode 100644 index 9a5dc32..0000000 --- a/dist/template-vc10.sln +++ /dev/null @@ -1,15 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -__projects__ -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution -__solution_configurations__ - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution -__project_configurations__ - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/dist/template-vc11.sln b/dist/template-vc11.sln deleted file mode 100644 index 436eeea..0000000 --- a/dist/template-vc11.sln +++ /dev/null @@ -1,15 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -__projects__ -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution -__solution_configurations__ - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution -__project_configurations__ - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/dist/template-vc12.sln b/dist/template-vc12.sln deleted file mode 100644 index 446d701..0000000 --- a/dist/template-vc12.sln +++ /dev/null @@ -1,17 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 -MinimumVisualStudioVersion = 10.0.40219.1 -__projects__ -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution -__solution_configurations__ - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution -__project_configurations__ - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/dist/template-vc8.sln b/dist/template-vc8.sln deleted file mode 100644 index f38bad2..0000000 --- a/dist/template-vc8.sln +++ /dev/null @@ -1,15 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -__projects__ -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution -__solution_configurations__ - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution -__project_configurations__ - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/dist/template-vc9.sln b/dist/template-vc9.sln deleted file mode 100644 index 2ec9432..0000000 --- a/dist/template-vc9.sln +++ /dev/null @@ -1,15 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -__projects__ -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution -__solution_configurations__ - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution -__project_configurations__ - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/doc/custom-literals.xsd b/doc/custom-literals.xsd deleted file mode 100644 index c6f7613..0000000 --- a/doc/custom-literals.xsd +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/doc/cxx/makefile b/doc/cxx/makefile deleted file mode 100644 index 1395edc..0000000 --- a/doc/cxx/makefile +++ /dev/null @@ -1,20 +0,0 @@ -# file : doc/cxx/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make - -docs := parser tree - -default := $(out_base)/ -install := $(out_base)/.install -dist := $(out_base)/.dist -dist-win := $(out_base)/.dist-win -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(docs))) -$(install): $(addprefix $(out_base)/,$(addsuffix /.install,$(docs))) -$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(docs))) -$(dist-win): $(addprefix $(out_base)/,$(addsuffix /.dist-win,$(docs))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(docs))) - -$(foreach m,$(docs),$(call import,$(src_base)/$m/makefile)) diff --git a/doc/cxx/parser/guide/figure-1.png b/doc/cxx/parser/guide/figure-1.png deleted file mode 100644 index 15d1723..0000000 Binary files a/doc/cxx/parser/guide/figure-1.png and /dev/null differ diff --git a/doc/cxx/parser/guide/figure-1.svg b/doc/cxx/parser/guide/figure-1.svg deleted file mode 100644 index d994a79..0000000 --- a/doc/cxx/parser/guide/figure-1.svg +++ /dev/null @@ -1,373 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - class people_pimpl{ void person ();}; - - - - class person_pimpl{ void first_name (string); void last_name (string); void gender (); void age (short); void post_person ();}; - - - - class string_pimpl{ string post_string ();}; - - - class short_pimpl{ short post_short ();}; - - - class gender_pimpl{ void post_gender ();}; - - - - - - - diff --git a/doc/cxx/parser/guide/guide.html2ps b/doc/cxx/parser/guide/guide.html2ps deleted file mode 100644 index af5e0f2..0000000 --- a/doc/cxx/parser/guide/guide.html2ps +++ /dev/null @@ -1,65 +0,0 @@ -@html2ps { - option { - toc: hb; - colour: 1; - hyphenate: 1; - titlepage: 1; - } - - datefmt: "%B %Y"; - - titlepage { - content: " -
-

C++/Parser Mapping

-

Getting Started Guide

-

 

-

 

-

 

-

 

-

 

-

 

-
-

Copyright © 2009-2020 Code Synthesis Tools CC.

- -

Permission is granted to copy, distribute and/or modify this - document under the terms of the - GNU Free - Documentation License, version 1.2; with no Invariant Sections, - no Front-Cover Texts and no Back-Cover Texts. -

- -

This document is available in the following formats: - XHTML, - PDF, and - PostScript.

"; - } - - toc { - indent: 2em; - } - - header { - odd-right: $H; - even-left: $H; - } - - footer { - odd-left: $D; - odd-center: $T; - odd-right: $N; - - even-left: $N; - even-center: $T; - even-right: $D; - } -} - -body { - font-size: 12pt; - text-align: justify; -} - -pre { - font-size: 10pt; -} diff --git a/doc/cxx/parser/guide/index.xhtml b/doc/cxx/parser/guide/index.xhtml deleted file mode 100644 index 1399214..0000000 --- a/doc/cxx/parser/guide/index.xhtml +++ /dev/null @@ -1,4158 +0,0 @@ - - - - - - C++/Parser Mapping Getting Started Guide - - - - - - - - - - - - - -
-
- -
- -
-
C++/Parser Mapping
-
Getting Started Guide
- -

Copyright © 2009-2020 Code Synthesis Tools CC.

- -

Permission is granted to copy, distribute and/or modify this - document under the terms of the - GNU Free - Documentation License, version 1.2; with no Invariant Sections, - no Front-Cover Texts and no Back-Cover Texts. -

- -

This document is available in the following formats: - XHTML, - PDF, and - PostScript.

- -
- -

Table of Contents

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Preface - - - -
About This Document
More Information
-
1Introduction - - - -
1.1Mapping Overview
1.2Benefits
-
2Hello World Example - - - - - -
2.1Writing XML Document and Schema
2.2Translating Schema to C++
2.3Implementing Application Logic
2.4Compiling and Running
-
3Parser Skeletons - - - - - -
3.1Implementing the Gender Parser
3.2Implementing the Person Parser
3.3Implementing the People Parser
3.4Connecting the Parsers Together
-
4Type Maps - - - - -
4.1Object Model
4.2Type Map File Format
4.3Parser Implementations
-
5Mapping Configuration - - - - - - -
5.1C++ Standard
5.2Character Type and Encoding
5.3Underlying XML Parser
5.4XML Schema Validation
5.5Support for Polymorphism
-
6Built-In XML Schema Type Parsers - - - - - - - - - - - - - - -
6.1QName Parser
6.2NMTOKENS and IDREFS Parsers
6.3base64Binary and hexBinary Parsers
6.4Time Zone Representation
6.5date Parser
6.6dateTime Parser
6.7duration Parser
6.8gDay Parser
6.9gMonth Parser
6.10gMonthDay Parser
6.11gYear Parser
6.12gYearMonth Parser
6.13time Parser
-
7Document Parser and Error Handling - - - - -
7.1Xerces-C++ Document Parser
7.2Expat Document Parser
7.3Error Handling
-
Appendix A — Supported XML Schema Constructs
-
- -

Preface

- -

About This Document

- -

The goal of this document is to provide you with an understanding of - the C++/Parser programming model and allow you to efficiently evaluate - XSD against your project's technical requirements. As such, this - document is intended for C++ developers and software architects - who are looking for an XML processing solution. Prior experience - with XML and C++ is required to understand this document. Basic - understanding of XML Schema is advantageous but not expected - or required. -

- - -

More Information

- -

Beyond this guide, you may also find the following sources of - information useful:

- -
    -
  • XSD - Compiler Command Line Manual
  • - -
  • The examples/cxx/parser/ directory in the XSD - distribution contains a collection of examples and a README - file with an overview of each example.
  • - -
  • The README file in the XSD distribution explains - how to compile the examples on various platforms.
  • - -
  • The xsd-users - mailing list is the place to ask technical questions about XSD and the C++/Parser mapping. - Furthermore, the archives - may already have answers to some of your questions.
  • - -
- - - -

1 Introduction

- -

Welcome to CodeSynthesis XSD and the C++/Parser mapping. XSD is a - cross-platform W3C XML Schema to C++ data binding compiler. C++/Parser - is a W3C XML Schema to C++ mapping that represents an XML vocabulary - as a set of parser skeletons which you can implement to perform XML - processing as required by your application logic. -

- -

1.1 Mapping Overview

- -

The C++/Parser mapping provides event-driven, stream-oriented - XML parsing, XML Schema validation, and C++ data binding. It was - specifically designed and optimized for high performance and - small footprint. Based on the static analysis of the schemas, XSD - generates compact, highly-optimized hierarchical state machines - that combine data extraction, validation, and even dispatching - in a single step. As a result, the generated code is typically - 2-10 times faster than general-purpose validating XML parsers - while maintaining the lowest static and dynamic memory footprints. -

- -

To speed up application development, the C++/Parser mapping - can be instructed to generate sample parser implementations - and a test driver which can then be filled with the application - logic code. The mapping also provides a wide range of - mechanisms for controlling and customizing the generated code.

- -

The next chapter shows how to create a simple application that uses - the C++/Parser mapping to parse, validate, and extract data from a - simple XML document. The following chapters show how to - use the C++/Parser mapping in more detail.

- -

1.2 Benefits

- -

Traditional XML access APIs such as Document Object Model (DOM) - or Simple API for XML (SAX) have a number of drawbacks that - make them less suitable for creating robust and maintainable - XML processing applications. These drawbacks include: -

- -
    -
  • Generic representation of XML in terms of elements, attributes, - and text forces an application developer to write a substantial - amount of bridging code that identifies and transforms pieces - of information encoded in XML to a representation more suitable - for consumption by the application logic.
  • - -
  • String-based flow control defers error detection to runtime. - It also reduces code readability and maintainability.
  • - -
  • Lack of type safety because the data is represented - as text.
  • - -
  • Resulting applications are hard to debug, change, and - maintain.
  • -
- -

In contrast, statically-typed, vocabulary-specific parser - skeletons produced by the C++/Parser mapping allow you to - operate in your domain terms instead of the generic elements, - attributes, and text. Static typing helps catch errors at - compile-time rather than at run-time. Automatic code generation - frees you for more interesting tasks (such as doing something - useful with the information stored in the XML documents) and - minimizes the effort needed to adapt your applications to - changes in the document structure. To summarize, the C++/Parser - mapping has the following key advantages over generic XML - access APIs:

- -
    -
  • Ease of use. The generated code hides all the complexity - associated with recreating the document structure, maintaining the - dispatch state, and converting the data from the text representation - to data types suitable for manipulation by the application logic. - Parser skeletons also provide a convenient mechanism for building - custom in-memory representations.
  • - -
  • Natural representation. The generated parser skeletons - implement parser callbacks as virtual functions with names - corresponding to elements and attributes in XML. As a result, - you process the XML data using your domain vocabulary instead - of generic elements, attributes, and text. -
  • - -
  • Concise code. With a separate parser skeleton for each - XML Schema type, the application implementation is - simpler and thus easier to read and understand.
  • - -
  • Safety. The XML data is delivered to parser callbacks as - statically typed objects. The parser callbacks themselves are virtual - functions. This helps catch programming errors at compile-time - rather than at runtime.
  • - -
  • Maintainability. Automatic code generation minimizes the - effort needed to adapt the application to changes in the - document structure. With static typing, the C++ compiler - can pin-point the places in the application code that need to be - changed.
  • - -
  • Efficiency. The generated parser skeletons combine - data extraction, validation, and even dispatching in a single - step. This makes them much more efficient than traditional - architectures with separate stages for validation and data - extraction/dispatch.
  • -
- - - - -

2 Hello World Example

- -

In this chapter we will examine how to parse a very simple XML - document using the XSD-generated C++/Parser skeletons. - The code presented in this chapter is based on the hello - example which can be found in the examples/cxx/parser/ - directory of the XSD distribution.

- -

2.1 Writing XML Document and Schema

- -

First, we need to get an idea about the structure - of the XML documents we are going to process. Our - hello.xml, for example, could look like this:

- -
-<?xml version="1.0"?>
-<hello>
-
-  <greeting>Hello</greeting>
-
-  <name>sun</name>
-  <name>moon</name>
-  <name>world</name>
-
-</hello>
-  
- -

Then we can write a description of the above XML in the - XML Schema language and save it into hello.xsd:

- -
-<?xml version="1.0"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
-
-  <xs:complexType name="hello">
-    <xs:sequence>
-      <xs:element name="greeting" type="xs:string"/>
-      <xs:element name="name" type="xs:string" maxOccurs="unbounded"/>
-    </xs:sequence>
-  </xs:complexType>
-
-  <xs:element name="hello" type="hello"/>
-
-</xs:schema>
-  
- -

Even if you are not familiar with XML Schema, it - should be easy to connect declarations in hello.xsd - to elements in hello.xml. The hello type - is defined as a sequence of the nested greeting and - name elements. Note that the term sequence in XML - Schema means that elements should appear in a particular order - as opposed to appearing multiple times. The name - element has its maxOccurs property set to - unbounded which means it can appear multiple times - in an XML document. Finally, the globally-defined hello - element prescribes the root element for our vocabulary. For an - easily-approachable introduction to XML Schema refer to - XML Schema Part 0: - Primer.

- -

The above schema is a specification of our XML vocabulary; it tells - everybody what valid documents of our XML-based language should look - like. The next step is to compile this schema to generate - the object model and parsing functions.

- -

2.2 Translating Schema to C++

- -

Now we are ready to translate our hello.xsd to C++ parser - skeletons. To do this we invoke the XSD compiler from a terminal - (UNIX) or a command prompt (Windows): -

- -
-$ xsd cxx-parser --xml-parser expat hello.xsd
-  
- -

The --xml-parser option indicates that we want to - use Expat as the underlying XML parser (see Section - 5.3, "Underlying XML Parser"). The XSD compiler produces two - C++ files: hello-pskel.hxx and hello-pskel.cxx. - The following code fragment is taken from hello-pskel.hxx; - it should give you an idea about what gets generated: -

- -
-class hello_pskel
-{
-public:
-  // Parser callbacks. Override them in your implementation.
-  //
-  virtual void
-  pre ();
-
-  virtual void
-  greeting (const std::string&);
-
-  virtual void
-  name (const std::string&);
-
-  virtual void
-  post_hello ();
-
-  // Parser construction API.
-  //
-  void
-  greeting_parser (xml_schema::string_pskel&);
-
-  void
-  name_parser (xml_schema::string_pskel&);
-
-  void
-  parsers (xml_schema::string_pskel& /* greeting */,
-           xml_schema::string_pskel& /* name */);
-
-private:
-  ...
-};
-  
- -

The first four member functions shown above are called parser - callbacks. You would normally override them in your implementation - of the parser to do something useful. Let's go through all of - them one by one.

- -

The pre() function is an initialization callback. It is - called when a new element of type hello is about - to be parsed. You would normally use this function to allocate a new - instance of the resulting type or clear accumulators that are used - to gather information during parsing. The default implementation - of this function does nothing.

- -

The post_hello() function is a finalization callback. Its - name is constructed by adding the parser skeleton name to the - post_ prefix. The finalization callback is called when - parsing of the element is complete and the result, if any, should - be returned. Note that in our case the return type of - post_hello() is void which means there - is nothing to return. More on parser return types later. -

- -

You may be wondering why the finalization callback is called - post_hello() instead of post() just - like pre(). The reason for this is that - finalization callbacks can have different return types and - result in function signature clashes across inheritance - hierarchies. To prevent this the signatures of finalization - callbacks are made unique by adding the type name to their names.

- -

The greeting() and name() functions are - called when the greeting and name elements - have been parsed, respectively. Their arguments are of type - std::string and contain the data extracted from XML.

- -

The last three functions are for connecting parsers to each other. - For example, there is a predefined parser for built-in XML Schema type - string in the XSD runtime. We will be using - it to parse the contents of greeting and - name elements, as shown in the next section.

- -

2.3 Implementing Application Logic

- -

At this point we have all the parts we need to do something useful - with the information stored in our XML document. The first step is - to implement the parser: -

- -
-#include <iostream>
-#include "hello-pskel.hxx"
-
-class hello_pimpl: public hello_pskel
-{
-public:
-  virtual void
-  greeting (const std::string& g)
-  {
-    greeting_ = g;
-  }
-
-  virtual void
-  name (const std::string& n)
-  {
-    std::cout << greeting_ << ", " << n << "!" << std::endl;
-  }
-
-private:
-  std::string greeting_;
-};
-  
- -

We left both pre() and post_hello() with the - default implementations; we don't have anything to initialize or - return. The rest is pretty straightforward: we store the greeting - in a member variable and later, when parsing names, use it to - say hello.

- -

An observant reader my ask what happens if the name - element comes before greeting? Don't we need to - make sure greeting_ was initialized and report - an error otherwise? The answer is no, we don't have to do - any of this. The hello_pskel parser skeleton - performs validation of XML according to the schema from which - it was generated. As a result, it will check the order - of the greeting and name elements - and report an error if it is violated.

- -

Now it is time to put this parser implementation to work:

- -
-using namespace std;
-
-int
-main (int argc, char* argv[])
-{
-  try
-  {
-    // Construct the parser.
-    //
-    xml_schema::string_pimpl string_p;
-    hello_pimpl hello_p;
-
-    hello_p.greeting_parser (string_p);
-    hello_p.name_parser (string_p);
-
-    // Parse the XML instance.
-    //
-    xml_schema::document doc_p (hello_p, "hello");
-
-    hello_p.pre ();
-    doc_p.parse (argv[1]);
-    hello_p.post_hello ();
-  }
-  catch (const xml_schema::exception& e)
-  {
-    cerr << e << endl;
-    return 1;
-  }
-}
-  
- -

The first part of this code snippet instantiates individual parsers - and assembles them into a complete vocabulary parser. - xml_schema::string_pimpl is an implementation of a parser - for built-in XML Schema type string. It is provided by - the XSD runtime along with parsers for other built-in types (for - more information on the built-in parsers see Chapter 6, - "Built-In XML Schema Type Parsers"). We use string_pimpl - to parse the greeting and name elements as - indicated by the calls to greeting_parser() and - name_parser(). -

- -

Then we instantiate a document parser (doc_p). The - first argument to its constructor is the parser for - the root element (hello_p in our case). The - second argument is the root element name. -

- -

The final piece is the calls to pre(), parse(), - and post_hello(). The call to parse() - perform the actual XML parsing while the calls to pre() and - post_hello() make sure that the parser for the root - element can perform proper initialization and cleanup.

- -

While our parser implementation and test driver are pretty small and - easy to write by hand, for bigger XML vocabularies it can be a - substantial effort. To help with this task XSD can automatically - generate sample parser implementations and a test driver from your - schemas. You can request the generation of a sample implementation with - empty function bodies by specifying the --generate-noop-impl - option. Or you can generate a sample implementation that prints the - data store in XML by using the --generate-print-impl - option. To request the generation of a test driver you can use the - --generate-test-driver option. For more information - on these options refer to the - XSD - Compiler Command Line Manual. The 'generated' example - in the XSD distribution shows the sample implementation generation - feature in action.

- - -

2.4 Compiling and Running

- -

After saving all the parts from the previous section in - driver.cxx, we are ready to compile our first - application and run it on the test XML document. On a UNIX - system this can be done with the following commands: -

- -
-$ c++ -I.../libxsd -c driver.cxx hello-pskel.cxx
-$ c++ -o driver driver.o hello-pskel.o -lexpat
-$ ./driver hello.xml
-Hello, sun!
-Hello, moon!
-Hello, world!
-  
- -

Here .../libxsd represents the path to the - libxsd directory in the XSD distribution. - We can also test the error handling. To test XML well-formedness - checking, we can try to parse hello-pskel.hxx:

- -
-$ ./driver hello-pskel.hxx
-hello-pskel.hxx:1:0: not well-formed (invalid token)
-  
- -

We can also try to parse a valid XML but not from our - vocabulary, for example hello.xsd:

- -
-$ ./driver hello.xsd
-hello.xsd:2:0: expected element 'hello' instead of
-'http://www.w3.org/2001/XMLSchema#schema'
-  
- - - - - -

3 Parser Skeletons

- -

As we have seen in the previous chapter, the XSD compiler generates - a parser skeleton class for each type defined in XML Schema. In - this chapter we will take a closer look at different functions - that comprise a parser skeleton as well as the way to connect - our implementations of these parser skeletons to create a complete - parser.

- -

In this and subsequent chapters we will use the following schema - that describes a collection of person records. We save it in - people.xsd:

- -
-<?xml version="1.0"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
-
-  <xs:simpleType name="gender">
-    <xs:restriction base="xs:string">
-      <xs:enumeration value="male"/>
-      <xs:enumeration value="female"/>
-    </xs:restriction>
-  </xs:simpleType>
-
-  <xs:complexType name="person">
-    <xs:sequence>
-      <xs:element name="first-name" type="xs:string"/>
-      <xs:element name="last-name" type="xs:string"/>
-      <xs:element name="gender" type="gender"/>
-      <xs:element name="age" type="xs:short"/>
-    </xs:sequence>
-  </xs:complexType>
-
-  <xs:complexType name="people">
-    <xs:sequence>
-      <xs:element name="person" type="person" maxOccurs="unbounded"/>
-    </xs:sequence>
-  </xs:complexType>
-
-  <xs:element name="people" type="people"/>
-
-</xs:schema>
-  
- -

A sample XML instance to go along with this schema is saved - in people.xml:

- -
-<?xml version="1.0"?>
-<people>
-  <person>
-    <first-name>John</first-name>
-    <last-name>Doe</last-name>
-    <gender>male</gender>
-    <age>32</age>
-  </person>
-  <person>
-    <first-name>Jane</first-name>
-    <last-name>Doe</last-name>
-    <gender>female</gender>
-    <age>28</age>
-  </person>
-</people>
-  
- -

Compiling people.xsd with the XSD compiler results - in three parser skeletons being generated: gender_pskel, - person_pskel, and people_pskel. We are going - to examine and implement each of them in the subsequent sections.

- -

3.1 Implementing the Gender Parser

- -

The generated gender_pskel parser skeleton looks like - this:

- -
-class gender_pskel: public virtual xml_schema::string_pskel
-{
-public:
-  // Parser callbacks. Override them in your implementation.
-  //
-  virtual void
-  pre ();
-
-  virtual void
-  post_gender ();
-};
-  
- -

Notice that gender_pskel inherits from - xml_schema::string_skel which is a parser skeleton - for built-in XML Schema type string and is - predefined in the XSD runtime library. This is an example - of the general rule that parser skeletons follow: if a type - in XML Schema inherits from another then there will be an - equivalent inheritance between the corresponding parser - skeleton classes.

- -

The pre() and post_gender() callbacks - should look familiar from the previous chapter. Let's now - implement the parser. Our implementation will simply print - the gender to cout:

- - -
-class gender_pimpl: public gender_pskel,
-                    public xml_schema::string_pimpl
-{
-public:
-  virtual void
-  post_gender ()
-  {
-    std::string s = post_string ();
-    cout << "gender: " << s << endl;
-  }
-};
-  
- -

While the code is quite short, there is a lot going on. First, - notice that we are inheriting from gender_pskel and - from xml_schema::string_pimpl. We've encountered - xml_schema::string_pimpl already; it is an - implementation of the xml_schema::string_pskel parser - skeleton for built-in XML Schema type string.

- -

This is another common theme in the C++/Parser programming model: - reusing implementations of the base parsers in the derived ones with - the C++ mixin idiom. In our case, string_pimpl will - do all the dirty work of extracting the data and we can just get - it at the end with the call to post_string().

- -

In case you are curious, here is what - xml_schema::string_pskel and - xml_schema::string_pimpl look like:

- -
-namespace xml_schema
-{
-  class string_pskel: public simple_content
-  {
-  public:
-    virtual std::string
-    post_string () = 0;
-  };
-
-  class string_pimpl: public virtual string_pskel
-  {
-  public:
-    virtual void
-    _pre ();
-
-    virtual void
-    _characters (const xml_schema::ro_string&);
-
-    virtual std::string
-    post_string ();
-
-  protected:
-    std::string str_;
-  };
-}
-  
- -

There are three new pieces in this code that we haven't seen yet. - They are the simple_content class as well as - the _pre() and _characters() functions. - The simple_content class is defined in the XSD - runtime and is a base class for all parser skeletons that conform - to the simple content model in XML Schema. Types with the - simple content model cannot have nested elements—only text - and attributes. There is also the complex_content - class which corresponds to the complex content mode (types with - nested elements, for example, person from - people.xsd).

- -

The _pre() function is a parser callback. Remember we - talked about the pre() and post_*() callbacks - in the previous chapter? There are actually two more callbacks - with similar roles: _pre() and _post (). - As a result, each parser skeleton has four special callbacks:

- -
-  virtual void
-  pre ();
-
-  virtual void
-  _pre ();
-
-  virtual void
-  _post ();
-
-  virtual void
-  post_name ();
-  
- -

pre() and _pre() are initialization - callbacks. They get called in that order before a new instance of the type - is about to be parsed. The difference between pre() and - _pre() is conventional: pre() can - be completely overridden by a derived parser. The derived - parser can also override _pre() but has to always call - the original version. This allows you to partition initialization - into customizable and required parts.

- -

Similarly, _post() and post_name() are - finalization callbacks with exactly the same semantics: - post_name() can be completely overridden by the derived - parser while the original _post() should always be called. -

- -

The final bit we need to discuss in this section is the - _characters() function. As you might have guessed, it - is also a callback. A low-level one that delivers raw character content - for the type being parsed. You will seldom need to use this callback - directly. Using implementations for the built-in parsers provided by - the XSD runtime is usually a simpler and more convenient - alternative.

- -

At this point you might be wondering why some post_*() - callbacks, for example post_string(), return some data - while others, for example post_gender(), have - void as a return type. This is a valid concern - and it will be addressed in the next chapter.

- -

3.2 Implementing the Person Parser

- -

The generated person_pskel parser skeleton looks like - this:

- -
-class person_pskel: public xml_schema::complex_content
-{
-public:
-  // Parser callbacks. Override them in your implementation.
-  //
-  virtual void
-  pre ();
-
-  virtual void
-  first_name (const std::string&);
-
-  virtual void
-  last_name (const std::string&);
-
-  virtual void
-  gender ();
-
-  virtual void
-  age (short);
-
-  virtual void
-  post_person ();
-
-  // Parser construction API.
-  //
-  void
-  first_name_parser (xml_schema::string_pskel&);
-
-  void
-  last_name_parser (xml_schema::string_pskel&);
-
-  void
-  gender_parser (gender_pskel&);
-
-  void
-  age_parser (xml_schema::short_pskel&);
-
-  void
-  parsers (xml_schema::string_pskel& /* first-name */,
-           xml_schema::string_pskel& /* last-name */,
-           gender_pskel&             /* gender */,
-           xml_schema::short_pskel&  /* age */);
-};
-  
- - -

As you can see, we have a parser callback for each of the nested - elements found in the person XML Schema type. - The implementation of this parser is straightforward:

- -
-class person_pimpl: public person_pskel
-{
-public:
-  virtual void
-  first_name (const std::string& n)
-  {
-    cout << "first: " << f << endl;
-  }
-
-  virtual void
-  last_name (const std::string& l)
-  {
-    cout << "last: " << l << endl;
-  }
-
-  virtual void
-  age (short a)
-  {
-    cout << "age: " << a << endl;
-  }
-};
-  
- -

Notice that we didn't override the gender() callback - because all the printing is done by gender_pimpl.

- - -

3.3 Implementing the People Parser

- -

The generated people_pskel parser skeleton looks like - this:

- -
-class people_pskel: public xml_schema::complex_content
-{
-public:
-  // Parser callbacks. Override them in your implementation.
-  //
-  virtual void
-  pre ();
-
-  virtual void
-  person ();
-
-  virtual void
-  post_people ();
-
-  // Parser construction API.
-  //
-  void
-  person_parser (person_pskel&);
-
-  void
-  parsers (person_pskel& /* person */);
-};
-  
- -

The person() callback will be called after parsing each - person element. While person_pimpl does - all the printing, one useful thing we can do in this callback is to - print an extra newline after each person record so that our - output is more readable:

- -
-class people_pimpl: public people_pskel
-{
-public:
-  virtual void
-  person ()
-  {
-    cout << endl;
-  }
-};
-  
- -

Now it is time to put everything together.

- - -

3.4 Connecting the Parsers Together

- -

At this point we have all the individual parsers implemented - and can proceed to assemble them into a complete parser - for our XML vocabulary. The first step is to instantiate - all the individual parsers that we will need:

- -
-xml_schema::short_pimpl short_p;
-xml_schema::string_pimpl string_p;
-
-gender_pimpl gender_p;
-person_pimpl person_p;
-people_pimpl people_p;
-  
- -

Notice that our schema uses two built-in XML Schema types: - string for the first-name and - last-name elements as well as short - for age. We will use predefined parsers that - come with the XSD runtime to handle these types. The next - step is to connect all the individual parsers. We do this - with the help of functions defined in the parser - skeletons and marked with the "Parser Construction API" - comment. One way to do it is to connect each individual - parser by calling the *_parser() functions:

- -
-person_p.first_name_parser (string_p);
-person_p.last_name_parser (string_p);
-person_p.gender_parser (gender_p);
-person_p.age_parser (short_p);
-
-people_p.person_parser (person_p);
-  
- -

You might be wondering what happens if you do not provide - a parser by not calling one of the *_parser() functions. - In that case the corresponding XML content will be skipped, - including validation. This is an efficient way to ignore parts - of the document that you are not interested in.

- - -

An alternative, shorter, way to connect the parsers is by using - the parsers() functions which connects all the parsers - for a given type at once:

- -
-person_p.parsers (string_p, string_p, gender_p, short_p);
-people_p.parsers (person_p);
-  
- -

The following figure illustrates the resulting connections. Notice - the correspondence between return types of the post_*() - functions and argument types of element callbacks that are connected - by the arrows.

- - -
- -

The last step is the construction of the document parser and - invocation of the complete parser on our sample XML instance:

- -
-xml_schema::document doc_p (people_p, "people");
-
-people_p.pre ();
-doc_p.parse ("people.xml");
-people_p.post_people ();
-  
- -

Let's consider xml_schema::document in - more detail. While the exact definition of this class - varies depending on the underlying parser selected, - here is the common part:

- -
-namespace xml_schema
-{
-  class document
-  {
-  public:
-    document (xml_schema::parser_base&,
-              const std::string& root_element_name,
-              bool polymorphic = false);
-
-    document (xml_schema::parser_base&,
-              const std::string& root_element_namespace,
-              const std::string& root_element_name,
-              bool polymorphic = false);
-
-    void
-    parse (const std::string& file);
-
-    void
-    parse (std::istream&);
-
-    ...
-
-  };
-}
-  
- -

xml_schema::document is a root parser for - the vocabulary. The first argument to its constructors is the - parser for the type of the root element (people_impl - in our case). Because a type parser is only concerned with - the element's content and not with the element's name, we need - to specify the root element's name somewhere. That's - what is passed as the second and third arguments to the - document's constructors.

- -

There are also two overloaded parse() functions - defined in the document class (there are actually - more but the others are specific to the underlying XML parser). - The first version parses a local file identified by a name. The - second version reads the data from an input stream. For more - information on the xml_schema::document class - refer to Chapter 7, "Document Parser and Error - Handling".

- -

Let's now consider a step-by-step list of actions that happen - as we parse through people.xml. The content of - people.xml is repeated below for convenience.

- -
-<?xml version="1.0"?>
-<people>
-  <person>
-    <first-name>John</first-name>
-    <last-name>Doe</last-name>
-    <gender>male</gender>
-    <age>32</age>
-  </person>
-  <person>
-    <first-name>Jane</first-name>
-    <last-name>Doe</last-name>
-    <gender>female</gender>
-    <age>28</age>
-  </person>
-</people>
-  
- - -
    -
  1. people_p.pre() is called from - main(). We did not provide any implementation - for this callback so this call is a no-op.
  2. - -
  3. doc_p.parse("people.xml") is called from - main(). The parser opens the file and starts - parsing its content.
  4. - -
  5. The parser encounters the root element. doc_p - verifies that the root element is correct and calls - _pre() on people_p which is also - a no-op. Parsing is now delegated to people_p.
  6. - -
  7. The parser encounters the person element. - people_p determines that person_p - is responsible for parsing this element. pre() - and _pre() callbacks are called on person_p. - Parsing is now delegated to person_p.
  8. - -
  9. The parser encounters the first-name element. - person_p determines that string_p - is responsible for parsing this element. pre() - and _pre() callbacks are called on string_p. - Parsing is now delegated to string_p.
  10. - -
  11. The parser encounters character content consisting of - "John". The _characters() callback is - called on string_p.
  12. - -
  13. The parser encounters the end of first-name - element. The _post() and post_string() - callbacks are called on string_p. The - first_name() callback is called on person_p - with the return value of post_string(). The - first_name() implementation prints - "first: John" to cout. - Parsing is now returned to person_p.
  14. - -
  15. Steps analogous to 5-7 are performed for the last-name, - gender, and age elements.
  16. - -
  17. The parser encounters the end of person - element. The _post() and post_person() - callbacks are called on person_p. The - person() callback is called on people_p. - The person() implementation prints a new line - to cout. Parsing is now returned to - people_p.
  18. - -
  19. Steps 4-9 are performed for the second person - element.
  20. - -
  21. The parser encounters the end of people - element. The _post() callback is called on - people_p. The doc_p.parse("people.xml") - call returns to main().
  22. - -
  23. people_p.post_people() is called from - main() which is a no-op.
  24. - -
- - - - - -

4 Type Maps

- -

There are many useful things you can do inside parser callbacks as they - are right now. There are, however, times when you want to propagate - some information from one parser to another or to the caller of the - parser. One common task that would greatly benefit from such a - possibility is building a tree-like in-memory object model of the - data stored in XML. During execution, each individual sub-parser - would create a sub-tree and return it to its parent parser - which can then incorporate this sub-tree into the whole tree.

- -

In this chapter we will discuss the mechanisms offered by the - C++/Parser mapping for returning information from individual - parsers and see how to use them to build an object model - of our people vocabulary.

- -

4.1 Object Model

- -

An object model for our person record example could - look like this (saved in the people.hxx file):

- -
-#include <string>
-#include <vector>
-
-enum gender
-{
-  male,
-  female
-};
-
-class person
-{
-public:
-  person (const std::string& first,
-          const std::string& last,
-          ::gender gender,
-          short age)
-    : first_ (first), last_ (last),
-      gender_ (gender), age_ (age)
-  {
-  }
-
-  const std::string&
-  first () const
-  {
-    return first_;
-  }
-
-  const std::string&
-  last () const
-  {
-    return last_;
-  }
-
-  ::gender
-  gender () const
-  {
-    return gender_;
-  }
-
-  short
-  age () const
-  {
-    return age_;
-  }
-
-private:
-  std::string first_;
-  std::string last_;
-  ::gender gender_;
-  short age_;
-};
-
-typedef std::vector<person> people;
-  
- -

While it is clear which parser is responsible for which part of - the object model, it is not exactly clear how, for - example, gender_pimpl will deliver gender - to person_pimpl. You might have noticed that - string_pimpl manages to deliver its value to the - first_name() callback of person_pimpl. Let's - see how we can utilize the same mechanism to propagate our - own data.

- -

There is a way to tell the XSD compiler that you want to - exchange data between parsers. More precisely, for each - type defined in XML Schema, you can tell the compiler two things. - First, the return type of the post_*() callback - in the parser skeleton generated for this type. And, second, - the argument type for callbacks corresponding to elements and - attributes of this type. For example, for XML Schema type - gender we can specify the return type for - post_gender() in the gender_pskel - skeleton and the argument type for the gender() callback - in the person_pskel skeleton. As you might have guessed, - the generated code will then pass the return value from the - post_*() callback as an argument to the element or - attribute callback.

- -

The way to tell the XSD compiler about these XML Schema to - C++ mappings is with type map files. Here is a simple type - map for the gender type from the previous paragraph:

- -
-include "people.hxx";
-gender ::gender ::gender;
-  
- -

The first line indicates that the generated code must include - people.hxx in order to get the definition for the - gender type. The second line specifies that both - argument and return types for the gender - XML Schema type should be the ::gender C++ enum - (we use fully-qualified C++ names to avoid name clashes). - The next section will describe the type map format in detail. - We save this type map in people.map and - then translate our schemas with the --type-map - option to let the XSD compiler know about our type map:

- -
-$ xsd cxx-parser --type-map people.map people.xsd
-  
- -

If we now look at the generated people-pskel.hxx, - we will see the following changes in the gender_pskel and - person_pskel skeletons:

- -
-#include "people.hxx"
-
-class gender_pskel: public virtual xml_schema::string_pskel
-{
-  virtual ::gender
-  post_gender () = 0;
-
-  ...
-};
-
-class person_pskel: public xml_schema::complex_content
-{
-  virtual void
-  gender (::gender);
-
-  ...
-};
-  
- -

Notice that #include "people.hxx" was added to - the generated header file from the type map to provide the - definition for the gender enum.

- -

4.2 Type Map File Format

- -

Type map files are used to define a mapping between XML Schema - and C++ types. The compiler uses this information - to determine return types of post_*() - callbacks in parser skeletons corresponding to XML Schema - types as well as argument types for callbacks corresponding - to elements and attributes of these types.

- -

The compiler has a set of predefined mapping rules that map - the built-in XML Schema types to suitable C++ types (discussed - below) and all other types to void. - By providing your own type maps you can override these predefined - rules. The format of the type map file is presented below: -

- -
-namespace <schema-namespace> [<cxx-namespace>]
-{
-  (include <file-name>;)*
-  ([type] <schema-type> <cxx-ret-type> [<cxx-arg-type>];)*
-}
-  
- -

Both <schema-namespace> and - <schema-type> are regex patterns while - <cxx-namespace>, - <cxx-ret-type>, and - <cxx-arg-type> are regex pattern - substitutions. All names can be optionally enclosed in - " ", for example, to include white-spaces.

- -

<schema-namespace> determines XML - Schema namespace. Optional <cxx-namespace> - is prefixed to every C++ type name in this namespace declaration. - <cxx-ret-type> is a C++ type name that is - used as a return type for the post_*() callback. - Optional <cxx-arg-type> is an argument - type for callbacks corresponding to elements and attributes - of this type. If <cxx-arg-type> is not - specified, it defaults to <cxx-ret-type> - if <cxx-ret-type> ends with * or - & (that is, it is a pointer or a reference) and - const <cxx-ret-type>& - otherwise. - <file-name> is a file name either in the - " " or < > format - and is added with the #include directive to - the generated code.

- -

The # character starts a comment that ends - with a new line or end of file. To specify a name that contains - # enclose it in " ". - For example:

- -
-namespace http://www.example.com/xmlns/my my
-{
-  include "my.hxx";
-
-  # Pass apples by value.
-  #
-  apple apple;
-
-  # Pass oranges as pointers.
-  #
-  orange orange_t*;
-}
-  
- -

In the example above, for the - http://www.example.com/xmlns/my#orange - XML Schema type, the my::orange_t* C++ type will - be used as both return and argument types.

- -

Several namespace declarations can be specified in a single - file. The namespace declaration can also be completely - omitted to map types in a schema without a namespace. For - instance:

- -
-include "my.hxx";
-apple apple;
-
-namespace http://www.example.com/xmlns/my
-{
-  orange "const orange_t*";
-}
-  
- -

The compiler has a number of predefined mapping rules for - the built-in XML Schema types which can be presented as the - following map files. The string-based XML Schema types are - mapped to either std::string or - std::wstring depending on the character type - selected (see Section 5.2, "Character Type and - Encoding" for more information). The binary XML Schema - types are mapped to either std::auto_ptr<xml_schema::buffer> - or std::unique_ptr<xml_schema::buffer> - depending on the C++ standard selected (C++98 or C++11, - respectively; refer to the --std XSD compiler - command line option for details).

- -
-namespace http://www.w3.org/2001/XMLSchema
-{
-  boolean bool bool;
-
-  byte "signed char" "signed char";
-  unsignedByte "unsigned char" "unsigned char";
-
-  short short short;
-  unsignedShort "unsigned short" "unsigned short";
-
-  int int int;
-  unsignedInt "unsigned int" "unsigned int";
-
-  long "long long" "long long";
-  unsignedLong "unsigned long long" "unsigned long long";
-
-  integer "long long" "long long";
-
-  negativeInteger "long long" "long long";
-  nonPositiveInteger "long long" "long long";
-
-  positiveInteger "unsigned long long" "unsigned long long";
-  nonNegativeInteger "unsigned long long" "unsigned long long";
-
-  float float float;
-  double double double;
-  decimal double double;
-
-  string std::string;
-  normalizedString std::string;
-  token std::string;
-  Name std::string;
-  NMTOKEN std::string;
-  NCName std::string;
-  ID std::string;
-  IDREF std::string;
-  language std::string;
-  anyURI std::string;
-
-  NMTOKENS xml_schema::string_sequence;
-  IDREFS xml_schema::string_sequence;
-
-  QName xml_schema::qname;
-
-  base64Binary std::[auto|unique]_ptr<xml_schema::buffer>
-               std::[auto|unique]_ptr<xml_schema::buffer>;
-  hexBinary std::[auto|unique]_ptr<xml_schema::buffer>
-            std::[auto|unique]_ptr<xml_schema::buffer>;
-
-  date xml_schema::date;
-  dateTime xml_schema::date_time;
-  duration xml_schema::duration;
-  gDay xml_schema::gday;
-  gMonth xml_schema::gmonth;
-  gMonthDay xml_schema::gmonth_day;
-  gYear xml_schema::gyear;
-  gYearMonth xml_schema::gyear_month;
-  time xml_schema::time;
-}
-  
- -

For more information about the mapping of the built-in XML Schema types - to C++ types refer to Chapter 6, "Built-In XML Schema Type - Parsers". The last predefined rule maps anything that wasn't - mapped by previous rules to void:

- -
-namespace .*
-{
-  .* void void;
-}
-  
- - -

When you provide your own type maps with the - --type-map option, they are evaluated first. This - allows you to selectively override any of the predefined rules. - Note also that if you change the mapping - of a built-in XML Schema type then it becomes your responsibility - to provide the corresponding parser skeleton and implementation - in the xml_schema namespace. You can include the - custom definitions into the generated header file using the - --hxx-prologue-* options.

- -

4.3 Parser Implementations

- -

With the knowledge from the previous section, we can proceed - with creating a type map that maps types in the people.xsd - schema to our object model classes in - people.hxx. In fact, we already have the beginning - of our type map file in people.map. Let's extend - it with the rest of the types:

- -
-include "people.hxx";
-
-gender ::gender ::gender;
-person ::person;
-people ::people;
-  
- -

There are a few things to note about this type map. We did not - provide the argument types for person and - people because the default constant reference is - exactly what we need. We also did not provide any mappings - for built-in XML Schema types string and - short because they are handled by the predefined - rules and we are happy with the result. Note also that - all C++ types are fully qualified. This is done to avoid - potential name conflicts in the generated code. Now we can - recompile our schema and move on to implementing the parsers:

- -
-$ xsd cxx-parser --xml-parser expat --type-map people.map people.xsd
-  
- -

Here is the implementation of our three parsers in full. One - way to save typing when implementing your own parsers is - to open the generated code and copy the signatures of parser - callbacks into your code. Or you could always auto generate the - sample implementations and fill them with your code.

- - -
-#include "people-pskel.hxx"
-
-class gender_pimpl: public gender_pskel,
-                    public xml_schema::string_pimpl
-{
-public:
-  virtual ::gender
-  post_gender ()
-  {
-    return post_string () == "male" ? male : female;
-  }
-};
-
-class person_pimpl: public person_pskel
-{
-public:
-  virtual void
-  first_name (const std::string& f)
-  {
-    first_ = f;
-  }
-
-  virtual void
-  last_name (const std::string& l)
-  {
-    last_ = l;
-  }
-
-  virtual void
-  gender (::gender g)
-  {
-    gender_ = g;
-  }
-
-  virtual void
-  age (short a)
-  {
-    age_ = a;
-  }
-
-  virtual ::person
-  post_person ()
-  {
-    return ::person (first_, last_, gender_, age_);
-  }
-
-private:
-  std::string first_;
-  std::string last_;
-  ::gender gender_;
-  short age_;
-};
-
-class people_pimpl: public people_pskel
-{
-public:
-  virtual void
-  person (const ::person& p)
-  {
-    people_.push_back (p);
-  }
-
-  virtual ::people
-  post_people ()
-  {
-    ::people r;
-    r.swap (people_);
-    return r;
-  }
-
-private:
-  ::people people_;
-};
-  
- -

This code fragment should look familiar by now. Just note that - all the post_*() callbacks now have return types instead - of void. Here is the implementation of the test - driver for this example:

- -
-#include <iostream>
-
-using namespace std;
-
-int
-main (int argc, char* argv[])
-{
-  // Construct the parser.
-  //
-  xml_schema::short_pimpl short_p;
-  xml_schema::string_pimpl string_p;
-
-  gender_pimpl gender_p;
-  person_pimpl person_p;
-  people_pimpl people_p;
-
-  person_p.parsers (string_p, string_p, gender_p, short_p);
-  people_p.parsers (person_p);
-
-  // Parse the document to obtain the object model.
-  //
-  xml_schema::document doc_p (people_p, "people");
-
-  people_p.pre ();
-  doc_p.parse (argv[1]);
-  people ppl = people_p.post_people ();
-
-  // Print the object model.
-  //
-  for (people::iterator i (ppl.begin ()); i != ppl.end (); ++i)
-  {
-    cout << "first:  " << i->first () << endl
-         << "last:   " << i->last () << endl
-         << "gender: " << (i->gender () == male ? "male" : "female") << endl
-         << "age:    " << i->age () << endl
-         << endl;
-  }
-}
-  
- -

The parser creation and assembly part is exactly the same as in - the previous chapter. The parsing part is a bit different: - post_people() now has a return value which is the - complete object model. We store it in the - ppl variable. The last bit of the code simply iterates - over the people vector and prints the information - for each person. We save the last two code fragments to - driver.cxx and proceed to compile and test - our new application:

- - -
-$ c++ -I.../libxsd -c driver.cxx people-pskel.cxx
-$ c++ -o driver driver.o people-pskel.o -lexpat
-$ ./driver people.xml
-first:  John
-last:   Doe
-gender: male
-age:    32
-
-first:  Jane
-last:   Doe
-gender: female
-age:    28
-  
- - - - - -

5 Mapping Configuration

- -

The C++/Parser mapping has a number of configuration parameters that - determine the overall properties and behavior of the generated code. - Configuration parameters are specified with the XSD command line - options and include the C++ standard, the character type that is used - by the generated code, the underlying XML parser, whether the XML Schema - validation is performed in the generated code, and support for XML Schema - polymorphism. This chapter describes these configuration - parameters in more detail. For more ways to configure the generated - code refer to the - XSD - Compiler Command Line Manual. -

- -

5.1 C++ Standard

- -

The C++/Parser mapping provides support for ISO/IEC C++ 1998/2003 (C++98) - and ISO/IEC C++ 2011 (C++11). To select the C++ standard for the - generated code we use the --std XSD compiler command - line option. While the majority of the examples in this guide use - C++98, support for the new functionality and library components - introduced in C++11 are discussed throughout the document.

- -

5.2 Character Type and Encoding

- -

The C++/Parser mapping has built-in support for two character types: - char and wchar_t. You can select the - character type with the --char-type command line - option. The default character type is char. The - string-based built-in XML Schema types are returned as either - std::string or std::wstring depending - on the character type selected.

- -

Another aspect of the mapping that depends on the character type - is character encoding. For the char character type - the default encoding is UTF-8. Other supported encodings are - ISO-8859-1, Xerces-C++ Local Code Page (LPC), as well as - custom encodings. You can select which encoding should be used - in the object model with the --char-encoding command - line option.

- -

For the wchar_t character type the encoding is - automatically selected between UTF-16 and UTF-32/UCS-4 depending - on the size of the wchar_t type. On some platforms - (for example, Windows with Visual C++ and AIX with IBM XL C++) - wchar_t is 2 bytes long. For these platforms the - encoding is UTF-16. On other platforms wchar_t is 4 bytes - long and UTF-32/UCS-4 is used.

- -

Note also that the character encoding that is used in the object model - is independent of the encodings used in input and output XML. In fact, - all three (object mode, input XML, and output XML) can have different - encodings.

- -

5.3 Underlying XML Parser

- -

The C++/Parser mapping can be used with either Xerces-C++ or Expat - as the underlying XML parser. You can select the XML parser with - the --xml-parser command line option. Valid values - for this option are xerces and expat. - The default XML parser is Xerces-C++.

- -

The generated code is identical for both parsers except for the - xml_schema::document class in which some of the - parse() functions are parser-specific as described - in Chapter 7, "Document Parser and Error Handling".

- - -

5.4 XML Schema Validation

- -

The C++/Parser mapping provides support for validating a - commonly-used subset of W3C XML Schema in the generated code. - For the list of supported XML Schema constructs refer to - Appendix A, "Supported XML Schema Constructs".

- -

By default validation in the generated code is disabled if - the underlying XML parser is validating (Xerces-C++) and - enabled otherwise (Expat). See Section 5.3, - "Underlying XML Parser" for more information about - the underlying XML parser. You can override the default - behavior with the --generate-validation - and --suppress-validation command line options.

- - -

5.5 Support for Polymorphism

- -

By default the XSD compiler generates non-polymorphic code. If your - vocabulary uses XML Schema polymorphism in the form of xsi:type - and/or substitution groups, then you will need to compile your schemas - with the --generate-polymorphic option to produce - polymorphism-aware code as well as pass true as the last - argument to the xml_schema::document's constructors.

- -

When using the polymorphism-aware generated code, you can specify - several parsers for a single element by passing a parser map - instead of an individual parser to the parser connection function - for the element. One of the parsers will then be looked up and used - depending on the xsi:type attribute value or an element - name from a substitution group. Consider the following schema as an - example:

- -
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
-
-  <xs:complexType name="person">
-    <xs:sequence>
-      <xs:element name="name" type="xs:string"/>
-    </xs:sequence>
-  </xs:complexType>
-
-  <!-- substitution group root -->
-  <xs:element name="person" type="person"/>
-
-  <xs:complexType name="superman">
-    <xs:complexContent>
-      <xs:extension base="person">
-        <xs:attribute name="can-fly" type="xs:boolean"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:element name="superman"
-              type="superman"
-              substitutionGroup="person"/>
-
-  <xs:complexType name="batman">
-    <xs:complexContent>
-      <xs:extension base="superman">
-        <xs:attribute name="wing-span" type="xs:unsignedInt"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:element name="batman"
-              type="batman"
-              substitutionGroup="superman"/>
-
-  <xs:complexType name="supermen">
-    <xs:sequence>
-      <xs:element ref="person" maxOccurs="unbounded"/>
-    </xs:sequence>
-  </xs:complexType>
-
-  <xs:element name="supermen" type="supermen"/>
-
-</xs:schema>
-  
- -

Conforming XML documents can use the superman - and batman types in place of the person - type either by specifying the type with the xsi:type - attributes or by using the elements from the substitution - group, for instance:

- - -
-<supermen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-
-  <person>
-    <name>John Doe</name>
-  </person>
-
-  <superman can-fly="false">
-    <name>James "007" Bond</name>
-  </superman>
-
-  <superman can-fly="true" wing-span="10" xsi:type="batman">
-    <name>Bruce Wayne</name>
-  </superman>
-
-</supermen>
-  
- -

To print the data stored in such XML documents we can implement - the parsers as follows:

- -
-class person_pimpl: public virtual person_pskel
-{
-public:
-  virtual void
-  pre ()
-  {
-    cout << "starting to parse person" << endl;
-  }
-
-  virtual void
-  name (const std::string& v)
-  {
-    cout << "name: " << v << endl;
-  }
-
-  virtual void
-  post_person ()
-  {
-    cout << "finished parsing person" << endl;
-  }
-};
-
-class superman_pimpl: public virtual superman_pskel,
-                      public person_pimpl
-{
-public:
-  virtual void
-  pre ()
-  {
-    cout << "starting to parse superman" << endl;
-  }
-
-  virtual void
-  can_fly (bool v)
-  {
-    cout << "can-fly: " << v << endl;
-  }
-
-  virtual void
-  post_person ()
-  {
-    post_superman ();
-  }
-
-  virtual void
-  post_superman ()
-  {
-    cout << "finished parsing superman" << endl
-  }
-};
-
-class batman_pimpl: public virtual batman_pskel,
-                    public superman_pimpl
-{
-public:
-  virtual void
-  pre ()
-  {
-    cout << "starting to parse batman" << endl;
-  }
-
-  virtual void
-  wing_span (unsigned int v)
-  {
-    cout << "wing-span: " << v << endl;
-  }
-
-  virtual void
-  post_superman ()
-  {
-    post_batman ();
-  }
-
-  virtual void
-  post_batman ()
-  {
-    cout << "finished parsing batman" << endl;
-  }
-};
-  
- -

Note that because the derived type parsers (superman_pskel - and batman_pskel) are called via the person_pskel - interface, we have to override the post_person() - virtual function in superman_pimpl to call - post_superman() and the post_superman() - virtual function in batman_pimpl to call - post_batman().

- -

The following code fragment shows how to connect the parsers together. - Notice that for the person element in the supermen_p - parser we specify a parser map instead of a specific parser and we pass - true as the last argument to the document parser constructor - to indicate that we are parsing potentially-polymorphic XML documents:

- -
-int
-main (int argc, char* argv[])
-{
-  // Construct the parser.
-  //
-  xml_schema::string_pimpl string_p;
-  xml_schema::boolean_pimpl boolean_p;
-  xml_schema::unsigned_int_pimpl unsigned_int_p;
-
-  person_pimpl person_p;
-  superman_pimpl superman_p;
-  batman_pimpl batman_p;
-
-  xml_schema::parser_map_impl person_map;
-  supermen_pimpl supermen_p;
-
-  person_p.parsers (string_p);
-  superman_p.parsers (string_p, boolean_p);
-  batman_p.parsers (string_p, boolean_p, unsigned_int_p);
-
-  // Here we are specifying a parser map which containes several
-  // parsers that can be used to parse the person element.
-  //
-  person_map.insert (person_p);
-  person_map.insert (superman_p);
-  person_map.insert (batman_p);
-
-  supermen_p.person_parser (person_map);
-
-  // Parse the XML document. The last argument to the document's
-  // constructor indicates that we are parsing polymorphic XML
-  // documents.
-  //
-  xml_schema::document doc_p (supermen_p, "supermen", true);
-
-  supermen_p.pre ();
-  doc_p.parse (argv[1]);
-  supermen_p.post_supermen ();
-}
-  
- -

When polymorphism-aware code is generated, each element's - *_parser() function is overloaded to also accept - an object of the xml_schema::parser_map type. - For example, the supermen_pskel class from the - above example looks like this:

- -
-class supermen_pskel: public xml_schema::parser_complex_content
-{
-public:
-
-  ...
-
-  // Parser construction API.
-  //
-  void
-  parsers (person_pskel&);
-
-  // Individual element parsers.
-  //
-  void
-  person_parser (person_pskel&);
-
-  void
-  person_parser (const xml_schema::parser_map&);
-
-  ...
-};
-  
- -

Note that you can specify both the individual (static) parser and - the parser map. The individual parser will be used when the static - element type and the dynamic type of the object being parsed are - the same. This is the case, for example, when there is no - xsi:type attribute and the element hasn't been - substituted. Because the individual parser for an element is - cached and no map lookup is necessary, it makes sense to specify - both the individual parser and the parser map when most of the - objects being parsed are of the static type and optimal - performance is important. The following code fragment shows - how to change the above example to set both the individual - parser and the parser map:

- -
-int
-main (int argc, char* argv[])
-{
-  ...
-
-  person_map.insert (superman_p);
-  person_map.insert (batman_p);
-
-  supermen_p.person_parser (person_p);
-  supermen_p.person_parser (person_map);
-
-  ...
-}
-  
- - -

The xml_schema::parser_map interface and the - xml_schema::parser_map_impl default implementation - are presented below:

- -
-namespace xml_schema
-{
-  class parser_map
-  {
-  public:
-    virtual parser_base*
-    find (const ro_string* type) const = 0;
-  };
-
-  class parser_map_impl: public parser_map
-  {
-  public:
-    void
-    insert (parser_base&);
-
-    virtual parser_base*
-    find (const ro_string* type) const;
-
-  private:
-    parser_map_impl (const parser_map_impl&);
-
-    parser_map_impl&
-    operator= (const parser_map_impl&);
-
-    ...
-  };
-}
-  
- -

The type argument in the find() virtual - function is the type name and namespace from the xsi:type attribute - (the namespace prefix is resolved to the actual XML namespace) - or the type of an element from the substitution group in the form - "<name> <namespace>" with the space and the - namespace part absent if the type does not have a namespace. - You can obtain a parser's dynamic type in the same format - using the _dynamic_type() function. The static - type can be obtained by calling the static _static_type() - function, for example person_pskel::_static_type(). - Both functions return a C string (const char* or - const wchar_t*, depending on the character type - used) which is valid for as long as the application is running. - The following example shows how we can implement our own parser - map using std::map:

- - -
-#include <map>
-#include <string>
-
-class parser_map: public xml_schema::parser_map
-{
-public:
- void
- insert (xml_schema::parser_base& p)
- {
-   map_[p._dynamic_type ()] = &p;
- }
-
- virtual xml_schema::parser_base*
- find (const xml_schema::ro_string* type) const
- {
-   map::const_iterator i = map_.find (type);
-   return i != map_.end () ? i->second : 0;
- }
-
-private:
-  typedef std::map<std::string, xml_schema::parser_base*> map;
-  map map_;
-};
-  
- -

Most of code presented in this section is taken from the - polymorphism example which can be found in the - examples/cxx/parser/ directory of the XSD distribution. - Handling of xsi:type and substitution groups when used - on root elements requires a number of special actions as shown in - the polyroot example.

- - - - - -

6 Built-In XML Schema Type Parsers

- -

The XSD runtime provides parser implementations for all built-in - XML Schema types as summarized in the following table. Declarations - for these types are automatically included into each generated - header file. As a result you don't need to include any headers - to gain access to these parser implementations. Note that some - parsers return either std::string or - std::wstring depending on the character type selected.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XML Schema typeParser implementation in the xml_schema namespaceParser return type
anyType and anySimpleType types
anyTypeany_type_pimplvoid
anySimpleTypeany_simple_type_pimplvoid
fixed-length integral types
bytebyte_pimplsigned char
unsignedByteunsigned_byte_pimplunsigned char
shortshort_pimplshort
unsignedShortunsigned_short_pimplunsigned short
intint_pimplint
unsignedIntunsigned_int_pimplunsigned int
longlong_pimpllong long
unsignedLongunsigned_long_pimplunsigned long long
arbitrary-length integral types
integerinteger_pimpllong long
nonPositiveIntegernon_positive_integer_pimpllong long
nonNegativeIntegernon_negative_integer_pimplunsigned long long
positiveIntegerpositive_integer_pimplunsigned long long
negativeIntegernegative_integer_pimpllong long
boolean types
booleanboolean_pimplbool
fixed-precision floating-point types
floatfloat_pimplfloat
doubledouble_pimpldouble
arbitrary-precision floating-point types
decimaldecimal_pimpldouble
string-based types
stringstring_pimplstd::string or std::wstring
normalizedStringnormalized_string_pimplstd::string or std::wstring
tokentoken_pimplstd::string or std::wstring
Namename_pimplstd::string or std::wstring
NMTOKENnmtoken_pimplstd::string or std::wstring
NCNamencname_pimplstd::string or std::wstring
languagelanguage_pimplstd::string or std::wstring
qualified name
QNameqname_pimplxml_schema::qname
Section 6.1, - "QName Parser"
ID/IDREF types
IDid_pimplstd::string or std::wstring
IDREFidref_pimplstd::string or std::wstring
list types
NMTOKENSnmtokens_pimplxml_schema::string_sequence
Section - 6.2, "NMTOKENS and IDREFS Parsers"
IDREFSidrefs_pimplxml_schema::string_sequence
Section - 6.2, "NMTOKENS and IDREFS Parsers"
URI types
anyURIuri_pimplstd::string or std::wstring
binary types
base64Binarybase64_binary_pimplstd::[auto|unique]_ptr< xml_schema::buffer>
- Section 6.3, "base64Binary and - hexBinary Parsers"
hexBinaryhex_binary_pimplstd::[auto|unique]_ptr< xml_schema::buffer>
- Section 6.3, "base64Binary and - hexBinary Parsers"
date/time types
datedate_pimplxml_schema::date
Section 6.5, - "date Parser"
dateTimedate_time_pimplxml_schema::date_time
Section 6.6, - "dateTime Parser"
durationduration_pimplxml_schema::duration
Section 6.7, - "duration Parser"
gDaygday_pimplxml_schema::gday
Section 6.8, - "gDay Parser"
gMonthgmonth_pimplxml_schema::gmonth
Section 6.9, - "gMonth Parser"
gMonthDaygmonth_day_pimplxml_schema::gmonth_day
Section 6.10, - "gMonthDay Parser"
gYeargyear_pimplxml_schema::gyear
Section 6.11, - "gYear Parser"
gYearMonthgyear_month_pimplxml_schema::gyear_month
Section - 6.12, "gYearMonth Parser"
timetime_pimplxml_schema::time
Section 6.13, - "time Parser"
- -

6.1 QName Parser

- -

The return type of the qname_pimpl parser implementation - is xml_schema::qname which represents an XML qualified - name. Its interface is presented below. - Note that the std::string type in the interface becomes - std::wstring if the selected character type is - wchar_t.

- -
-namespace xml_schema
-{
-  class qname
-  {
-  public:
-    explicit
-    qname (const std::string& name);
-    qname (const std::string& prefix, const std::string& name);
-
-    const std::string&
-    prefix () const;
-
-    void
-    prefix (const std::string&);
-
-    const std::string&
-    name () const;
-
-    void
-    name (const std::string&);
-  };
-
-  bool
-  operator== (const qname&, const qname&);
-
-  bool
-  operator!= (const qname&, const qname&);
-}
-  
- - -

6.2 NMTOKENS and IDREFS Parsers

- -

The return type of the nmtokens_pimpl and - idrefs_pimpl parser implementations is - xml_schema::string_sequence which represents a - sequence of strings. Its interface is presented below. - Note that the std::string type in the interface becomes - std::wstring if the selected character type is - wchar_t.

- -
-namespace xml_schema
-{
-  class string_sequence: public std::vector<std::string>
-  {
-  public:
-    string_sequence ();
-
-    explicit
-    string_sequence (std::vector<std::string>::size_type n,
-                     const std::string& x = std::string ());
-
-    template <typename I>
-    string_sequence (const I& begin, const I& end);
-  };
-
-  bool
-  operator== (const string_sequence&, const string_sequence&);
-
-  bool
-  operator!= (const string_sequence&, const string_sequence&);
-}
-  
- - -

6.3 base64Binary and hexBinary Parsers

- -

The return type of the base64_binary_pimpl and - hex_binary_pimpl parser implementations is either - std::auto_ptr<xml_schema::buffer> (C++98) or - std::unique_ptr<xml_schema::buffer> (C++11), - depending on the C++ standard selected (--std XSD - compiler option). The xml_schema::buffer type - represents a binary buffer and its interface is presented below.

- -
-namespace xml_schema
-{
-  class buffer
-  {
-  public:
-    typedef std::size_t size_t;
-
-    class bounds {}; // Out of bounds exception.
-
-  public:
-    explicit
-    buffer (size_t size = 0);
-    buffer (size_t size, size_t capacity);
-    buffer (const void* data, size_t size);
-    buffer (const void* data, size_t size, size_t capacity);
-    buffer (void* data,
-            size_t size,
-            size_t capacity,
-            bool assume_ownership);
-
-  public:
-    buffer (const buffer&);
-
-    buffer&
-    operator= (const buffer&);
-
-    void
-    swap (buffer&);
-
-  public:
-    size_t
-    capacity () const;
-
-    bool
-    capacity (size_t);
-
-  public:
-    size_t
-    size () const;
-
-    bool
-    size (size_t);
-
-  public:
-    const char*
-    data () const;
-
-    char*
-    data ();
-
-    const char*
-    begin () const;
-
-    char*
-    begin ();
-
-    const char*
-    end () const;
-
-    char*
-    end ();
-  };
-
-  bool
-  operator== (const buffer&, const buffer&);
-
-  bool
-  operator!= (const buffer&, const buffer&);
-}
-  
- -

If the assume_ownership argument to the constructor - is true, the instance assumes the ownership of the - memory block pointed to by the data argument and will - eventually release it by calling operator delete(). The - capacity() and size() modifier functions - return true if the underlying buffer has moved. -

- -

The bounds exception is thrown if the constructor - arguments violate the (size <= capacity) - constraint.

- - -

6.4 Time Zone Representation

- -

The date, dateTime, gDay, - gMonth, gMonthDay, gYear, - gYearMonth, and time XML Schema built-in - types all include an optional time zone component. The following - xml_schema::time_zone base class is used to represent - this information:

- -
-namespace xml_schema
-{
-  class time_zone
-  {
-  public:
-    time_zone ();
-    time_zone (short hours, short minutes);
-
-    bool
-    zone_present () const;
-
-    void
-    zone_reset ();
-
-    short
-    zone_hours () const;
-
-    void
-    zone_hours (short);
-
-    short
-    zone_minutes () const;
-
-    void
-    zone_minutes (short);
-  };
-
-  bool
-  operator== (const time_zone&, const time_zone&);
-
-  bool
-  operator!= (const time_zone&, const time_zone&);
-}
-  
- -

The zone_present() accessor function returns true - if the time zone is specified. The zone_reset() modifier - function resets the time zone object to the not specified - state. If the time zone offset is negative then both hours and - minutes components are represented as negative integers.

- - -

6.5 date Parser

- -

The return type of the date_pimpl parser implementation - is xml_schema::date which represents a year, a day, and a month - with an optional time zone. Its interface is presented below. - For more information on the base xml_schema::time_zone - class refer to Section 6.4, "Time Zone - Representation".

- -
-namespace xml_schema
-{
-  class date
-  {
-  public:
-    date (int year, unsigned short month, unsigned short day);
-    date (int year, unsigned short month, unsigned short day,
-          short zone_hours, short zone_minutes);
-
-    int
-    year () const;
-
-    void
-    year (int);
-
-    unsigned short
-    month () const;
-
-    void
-    month (unsigned short);
-
-    unsigned short
-    day () const;
-
-    void
-    day (unsigned short);
-  };
-
-  bool
-  operator== (const date&, const date&);
-
-  bool
-  operator!= (const date&, const date&);
-}
-  
- -

6.6 dateTime Parser

- -

The return type of the date_time_pimpl parser implementation - is xml_schema::date_time which represents a year, a month, a day, - hours, minutes, and seconds with an optional time zone. Its interface - is presented below. - For more information on the base xml_schema::time_zone - class refer to Section 6.4, "Time Zone - Representation".

- -
-namespace xml_schema
-{
-  class date_time
-  {
-  public:
-    date_time (int year, unsigned short month, unsigned short day,
-               unsigned short hours, unsigned short minutes,
-               double seconds);
-
-    date_time (int year, unsigned short month, unsigned short day,
-               unsigned short hours, unsigned short minutes,
-               double seconds, short zone_hours, short zone_minutes);
-
-    int
-    year () const;
-
-    void
-    year (int);
-
-    unsigned short
-    month () const;
-
-    void
-    month (unsigned short);
-
-    unsigned short
-    day () const;
-
-    void
-    day (unsigned short);
-
-    unsigned short
-    hours () const;
-
-    void
-    hours (unsigned short);
-
-    unsigned short
-    minutes () const;
-
-    void
-    minutes (unsigned short);
-
-    double
-    seconds () const;
-
-    void
-    seconds (double);
-  };
-
-  bool
-  operator== (const date_time&, const date_time&);
-
-  bool
-  operator!= (const date_time&, const date_time&);
-}
-  
- -

6.7 duration Parser

- -

The return type of the duration_pimpl parser implementation - is xml_schema::duration which represents a potentially - negative duration in the form of years, months, days, hours, minutes, - and seconds. Its interface is presented below.

- -
-namespace xml_schema
-{
-  class duration
-  {
-  public:
-    duration (bool negative,
-              unsigned int years, unsigned int months, unsigned int days,
-              unsigned int hours, unsigned int minutes, double seconds);
-
-    bool
-    negative () const;
-
-    void
-    negative (bool);
-
-    unsigned int
-    years () const;
-
-    void
-    years (unsigned int);
-
-    unsigned int
-    months () const;
-
-    void
-    months (unsigned int);
-
-    unsigned int
-    days () const;
-
-    void
-    days (unsigned int);
-
-    unsigned int
-    hours () const;
-
-    void
-    hours (unsigned int);
-
-    unsigned int
-    minutes () const;
-
-    void
-    minutes (unsigned int);
-
-    double
-    seconds () const;
-
-    void
-    seconds (double);
-  };
-
-  bool
-  operator== (const duration&, const duration&);
-
-  bool
-  operator!= (const duration&, const duration&);
-}
-  
- - -

6.8 gDay Parser

- -

The return type of the gday_pimpl parser implementation - is xml_schema::gday which represents a day of the month with - an optional time zone. Its interface is presented below. - For more information on the base xml_schema::time_zone - class refer to Section 6.4, "Time Zone - Representation".

- -
-namespace xml_schema
-{
-  class gday
-  {
-  public:
-    explicit
-    gday (unsigned short day);
-    gday (unsigned short day, short zone_hours, short zone_minutes);
-
-    unsigned short
-    day () const;
-
-    void
-    day (unsigned short);
-  };
-
-  bool
-  operator== (const gday&, const gday&);
-
-  bool
-  operator!= (const gday&, const gday&);
-}
-  
- -

6.9 gMonth Parser

- -

The return type of the gmonth_pimpl parser implementation - is xml_schema::gmonth which represents a month of the year - with an optional time zone. Its interface is presented below. - For more information on the base xml_schema::time_zone - class refer to Section 6.4, "Time Zone - Representation".

- -
-namespace xml_schema
-{
-  class gmonth
-  {
-  public:
-    explicit
-    gmonth (unsigned short month);
-    gmonth (unsigned short month, short zone_hours, short zone_minutes);
-
-    unsigned short
-    month () const;
-
-    void
-    month (unsigned short);
-  };
-
-  bool
-  operator== (const gmonth&, const gmonth&);
-
-  bool
-  operator!= (const gmonth&, const gmonth&);
-}
-  
- -

6.10 gMonthDay Parser

- -

The return type of the gmonth_day_pimpl parser implementation - is xml_schema::gmonth_day which represents a day and a month - of the year with an optional time zone. Its interface is presented below. - For more information on the base xml_schema::time_zone - class refer to Section 6.4, "Time Zone - Representation".

- -
-namespace xml_schema
-{
-  class gmonth_day
-  {
-  public:
-    gmonth_day (unsigned short month, unsigned short day);
-    gmonth_day (unsigned short month, unsigned short day,
-                short zone_hours, short zone_minutes);
-
-    unsigned short
-    month () const;
-
-    void
-    month (unsigned short);
-
-    unsigned short
-    day () const;
-
-    void
-    day (unsigned short);
-  };
-
-  bool
-  operator== (const gmonth_day&, const gmonth_day&);
-
-  bool
-  operator!= (const gmonth_day&, const gmonth_day&);
-}
-  
- -

6.11 gYear Parser

- -

The return type of the gyear_pimpl parser implementation - is xml_schema::gyear which represents a year with - an optional time zone. Its interface is presented below. - For more information on the base xml_schema::time_zone - class refer to Section 6.4, "Time Zone - Representation".

- -
-namespace xml_schema
-{
-  class gyear
-  {
-  public:
-    explicit
-    gyear (int year);
-    gyear (int year, short zone_hours, short zone_minutes);
-
-    int
-    year () const;
-
-    void
-    year (int);
-  };
-
-  bool
-  operator== (const gyear&, const gyear&);
-
-  bool
-  operator!= (const gyear&, const gyear&);
-}
-  
- -

6.12 gYearMonth Parser

- -

The return type of the gyear_month_pimpl parser implementation - is xml_schema::gyear_month which represents a year and a month - with an optional time zone. Its interface is presented below. - For more information on the base xml_schema::time_zone - class refer to Section 6.4, "Time Zone - Representation".

- -
-namespace xml_schema
-{
-  class gyear_month
-  {
-  public:
-    gyear_month (int year, unsigned short month);
-    gyear_month (int year, unsigned short month,
-                 short zone_hours, short zone_minutes);
-
-    int
-    year () const;
-
-    void
-    year (int);
-
-    unsigned short
-    month () const;
-
-    void
-    month (unsigned short);
-  };
-
-  bool
-  operator== (const gyear_month&, const gyear_month&);
-
-  bool
-  operator!= (const gyear_month&, const gyear_month&);
-}
-  
- - -

6.13 time Parser

- -

The return type of the time_pimpl parser implementation - is xml_schema::time which represents hours, minutes, - and seconds with an optional time zone. Its interface is presented below. - For more information on the base xml_schema::time_zone - class refer to Section 6.4, "Time Zone - Representation".

- -
-namespace xml_schema
-{
-  class time
-  {
-  public:
-    time (unsigned short hours, unsigned short minutes, double seconds);
-    time (unsigned short hours, unsigned short minutes, double seconds,
-          short zone_hours, short zone_minutes);
-
-    unsigned short
-    hours () const;
-
-    void
-    hours (unsigned short);
-
-    unsigned short
-    minutes () const;
-
-    void
-    minutes (unsigned short);
-
-    double
-    seconds () const;
-
-    void
-    seconds (double);
-  };
-
-  bool
-  operator== (const time&, const time&);
-
-  bool
-  operator!= (const time&, const time&);
-}
-  
- - - - - -

7 Document Parser and Error Handling

- -

In this chapter we will discuss the xml_schema::document - type as well as the error handling mechanisms provided by the mapping - in more detail. As mentioned in Section 3.4, - "Connecting the Parsers Together", the interface of - xml_schema::document depends on the underlying XML - parser selected (Section 5.3, "Underlying XML - Parser"). The following sections describe the - document type interface for Xerces-C++ and - Expat as underlying parsers.

- -

7.1 Xerces-C++ Document Parser

- -

When Xerces-C++ is used as the underlying XML parser, the - document type has the following interface. Note that - if the character type is wchar_t, then the string type - in the interface becomes std::wstring - (see Section 5.2, "Character Type and Encoding").

- -
-namespace xml_schema
-{
-  class parser_base;
-  class error_handler;
-
-  class flags
-  {
-  public:
-    // Do not validate XML documents with the Xerces-C++ validator.
-    //
-    static const unsigned long dont_validate;
-
-    // Do not initialize the Xerces-C++ runtime.
-    //
-    static const unsigned long dont_initialize;
-
-    // Disable handling of subsequent imports for the same namespace
-    // in Xerces-C++ 3.1.0 and later.
-    //
-    static const unsigned long no_multiple_imports;
-  };
-
-  class properties
-  {
-  public:
-    // Add a location for a schema with a target namespace.
-    //
-    void
-    schema_location (const std::string& namespace_,
-                     const std::string& location);
-
-    // Add a location for a schema without a target namespace.
-    //
-    void
-    no_namespace_schema_location (const std::string& location);
-  };
-
-  class document
-  {
-  public:
-    document (parser_base& root,
-              const std::string& root_element_name,
-	      bool polymorphic = false);
-
-    document (parser_base& root,
-              const std::string& root_element_namespace,
-              const std::string& root_element_name,
-	      bool polymorphic = false);
-
-  public:
-    // Parse URI or a local file.
-    //
-    void
-    parse (const std::string& uri,
-           flags = 0,
-           const properties& = properties ());
-
-    // Parse URI or a local file with a user-provided error_handler
-    // object.
-    //
-    void
-    parse (const std::string& uri,
-           error_handler&,
-           flags = 0,
-           const properties& = properties ());
-
-    // Parse URI or a local file with a user-provided ErrorHandler
-    // object. Note that you must initialize the Xerces-C++ runtime
-    // before calling this function.
-    //
-    void
-    parse (const std::string& uri,
-           xercesc::ErrorHandler&,
-           flags = 0,
-           const properties& = properties ());
-
-    // Parse URI or a local file using a user-provided SAX2XMLReader
-    // object. Note that you must initialize the Xerces-C++ runtime
-    // before calling this function.
-    //
-    void
-    parse (const std::string& uri,
-           xercesc::SAX2XMLReader&,
-           flags = 0,
-           const properties& = properties ());
-
-  public:
-    // Parse std::istream.
-    //
-    void
-    parse (std::istream&,
-           flags = 0,
-           const properties& = properties ());
-
-    // Parse std::istream with a user-provided error_handler object.
-    //
-    void
-    parse (std::istream&,
-           error_handler&,
-           flags = 0,
-           const properties& = properties ());
-
-    // Parse std::istream with a user-provided ErrorHandler object.
-    // Note that you must initialize the Xerces-C++ runtime before
-    // calling this function.
-    //
-    void
-    parse (std::istream&,
-           xercesc::ErrorHandler&,
-           flags = 0,
-           const properties& = properties ());
-
-    // Parse std::istream using a user-provided SAX2XMLReader object.
-    // Note that you must initialize the Xerces-C++ runtime before
-    // calling this function.
-    //
-    void
-    parse (std::istream&,
-           xercesc::SAX2XMLReader&,
-           flags = 0,
-           const properties& = properties ());
-
-  public:
-    // Parse std::istream with a system id.
-    //
-    void
-    parse (std::istream&,
-           const std::string& system_id,
-           flags = 0,
-           const properties& = properties ());
-
-    // Parse std::istream with a system id and a user-provided
-    // error_handler object.
-    //
-    void
-    parse (std::istream&,
-           const std::string& system_id,
-           error_handler&,
-           flags = 0,
-           const properties& = properties ());
-
-    // Parse std::istream with a system id and a user-provided
-    // ErrorHandler object. Note that you must initialize the
-    // Xerces-C++ runtime before calling this function.
-    //
-    void
-    parse (std::istream&,
-           const std::string& system_id,
-           xercesc::ErrorHandler&,
-           flags = 0,
-           const properties& = properties ());
-
-    // Parse std::istream with a system id using a user-provided
-    // SAX2XMLReader object. Note that you must initialize the
-    // Xerces-C++ runtime before calling this function.
-    //
-    void
-    parse (std::istream&,
-           const std::string& system_id,
-           xercesc::SAX2XMLReader&,
-           flags = 0,
-           const properties& = properties ());
-
-  public:
-    // Parse std::istream with system and public ids.
-    //
-    void
-    parse (std::istream&,
-           const std::string& system_id,
-           const std::string& public_id,
-           flags = 0,
-           const properties& = properties ());
-
-    // Parse std::istream with system and public ids and a user-provided
-    // error_handler object.
-    //
-    void
-    parse (std::istream&,
-           const std::string& system_id,
-           const std::string& public_id,
-           error_handler&,
-           flags = 0,
-           const properties& = properties ());
-
-    // Parse std::istream with system and public ids and a user-provided
-    // ErrorHandler object. Note that you must initialize the Xerces-C++
-    // runtime before calling this function.
-    //
-    void
-    parse (std::istream&,
-           const std::string& system_id,
-           const std::string& public_id,
-           xercesc::ErrorHandler&,
-           flags = 0,
-           const properties& = properties ());
-
-    // Parse std::istream with system and public ids using a user-
-    // provided SAX2XMLReader object. Note that you must initialize
-    // the Xerces-C++ runtime before calling this function.
-    //
-    void
-    parse (std::istream&,
-           const std::string& system_id,
-           const std::string& public_id,
-           xercesc::SAX2XMLReader&,
-           flags = 0,
-           const properties& = properties ());
-
-  public:
-    // Parse InputSource. Note that you must initialize the Xerces-C++
-    // runtime before calling this function.
-    //
-    void
-    parse (const xercesc::InputSource&,
-           flags = 0,
-           const properties& = properties ());
-
-    // Parse InputSource with a user-provided error_handler object.
-    // Note that you must initialize the Xerces-C++ runtime before
-    // calling this function.
-    //
-    void
-    parse (const xercesc::InputSource&,
-           error_handler&,
-           flags = 0,
-           const properties& = properties ());
-
-    // Parse InputSource with a user-provided ErrorHandler object.
-    // Note that you must initialize the Xerces-C++ runtime before
-    // calling this function.
-    //
-    void
-    parse (const xercesc::InputSource&,
-           xercesc::ErrorHandler&,
-           flags = 0,
-           const properties& = properties ());
-
-    // Parse InputSource using a user-provided SAX2XMLReader object.
-    // Note that you must initialize the Xerces-C++ runtime before
-    // calling this function.
-    //
-    void
-    parse (const xercesc::InputSource&,
-           xercesc::SAX2XMLReader&,
-           flags = 0,
-           const properties& = properties ());
-  };
-}
-  
- -

The document class is a root parser for - the vocabulary. The first argument to its constructors is the - parser for the type of the root element. The parser_base - class is the base type for all parser skeletons. The second and - third arguments to the document's constructors are - the root element's name and namespace. The last argument, - polymorphic, specifies whether the XML documents - being parsed use polymorphism. For more information on support - for XML Schema polymorphism in the C++/Parser mapping refer - to Section 5.5, "Support for Polymorphism".

- -

The rest of the document interface consists of overloaded - parse() functions. The last two arguments in each of these - functions are flags and properties. The - flags argument allows you to modify the default behavior - of the parsing functions. The properties argument allows - you to override the schema location attributes specified in XML - documents. Note that the schema location paths are relative to an - XML document unless they are complete URIs. For example if you want - to use a local schema file then you will need to use a URI in the - form file:///absolute/path/to/your/schema.

- -

A number of overloaded parse() functions have the - system_id and public_id arguments. The - system id is a system identifier of the resources being - parsed (for example, URI or a full file path). The public id is a - public identifier of the resource (for example, an - application-specific name or a relative file path). The system id - is used to resolve relative paths (for example, schema paths). In - diagnostics messages the public id is used if it is available. - Otherwise the system id is used.

- -

The error handling mechanisms employed by the document - parser are described in Section 7.3, "Error - Handling".

- -

7.2 Expat Document Parser

- -

When Expat is used as the underlying XML parser, the - document type has the following interface. Note that - if the character type is wchar_t, then the string type - in the interface becomes std::wstring - (see Section 5.2, "Character Type and Encoding").

- -
-namespace xml_schema
-{
-  class parser_base;
-  class error_handler;
-
-  class document
-  {
-  public:
-    document (parser_base&,
-              const std::string& root_element_name,
-              bool polymorphic = false);
-
-    document (parser_base&,
-              const std::string& root_element_namespace,
-              const std::string& root_element_name,
-              bool polymorphic = false);
-
-  public:
-    // Parse a local file. The file is accessed with std::ifstream
-    // in binary mode. The std::ios_base::failure exception is used
-    // to report io errors (badbit and failbit).
-    void
-    parse (const std::string& file);
-
-    // Parse a local file with a user-provided error_handler
-    // object. The file is accessed with std::ifstream in binary
-    // mode. The std::ios_base::failure exception is used to report
-    // io errors (badbit and failbit).
-    //
-    void
-    parse (const std::string& file, error_handler&);
-
-  public:
-    // Parse std::istream.
-    //
-    void
-    parse (std::istream&);
-
-    // Parse std::istream with a user-provided error_handler object.
-    //
-    void
-    parse (std::istream&, error_handler&);
-
-    // Parse std::istream with a system id.
-    //
-    void
-    parse (std::istream&, const std::string& system_id);
-
-    // Parse std::istream with a system id and a user-provided
-    // error_handler object.
-    //
-    void
-    parse (std::istream&,
-           const std::string& system_id,
-           error_handler&);
-
-    // Parse std::istream with system and public ids.
-    //
-    void
-    parse (std::istream&,
-           const std::string& system_id,
-           const std::string& public_id);
-
-    // Parse std::istream with system and public ids and a user-provided
-    // error_handler object.
-    //
-    void
-    parse (std::istream&,
-           const std::string& system_id,
-           const std::string& public_id,
-           error_handler&);
-
-  public:
-    // Parse a chunk of input. You can call these functions multiple
-    // times with the last call having the last argument true.
-    //
-    void
-    parse (const void* data, std::size_t size, bool last);
-
-    void
-    parse (const void* data, std::size_t size, bool last,
-           error_handler&);
-
-    void
-    parse (const void* data, std::size_t size, bool last,
-           const std::string& system_id);
-
-    void
-    parse (const void* data, std::size_t size, bool last,
-           const std::string& system_id,
-           error_handler&);
-
-    void
-    parse (const void* data, std::size_t size, bool last,
-           const std::string& system_id,
-           const std::string& public_id);
-
-    void
-    parse (const void* data, std::size_t size, bool last,
-           const std::string& system_id,
-           const std::string& public_id,
-           error_handler&);
-
-  public:
-    // Low-level Expat-specific parsing API.
-    //
-    void
-    parse_begin (XML_Parser);
-
-    void
-    parse_begin (XML_Parser, const std::string& public_id);
-
-    void
-    parse_begin (XML_Parser, error_handler&);
-
-    void
-    parse_begin (XML_Parser,
-                 const std::string& public_id,
-                 error_handler&);
-    void
-    parse_end ();
-  };
-}
-  
- -

The document class is a root parser for - the vocabulary. The first argument to its constructors is the - parser for the type of the root element. The parser_base - class is the base type for all parser skeletons. The second and - third arguments to the document's constructors are - the root element's name and namespace. The last argument, - polymorphic, specifies whether the XML documents - being parsed use polymorphism. For more information on support - for XML Schema polymorphism in the C++/Parser mapping refer - to Section 5.5, "Support for Polymorphism".

- -

A number of overloaded parse() functions have the - system_id and public_id arguments. The - system id is a system identifier of the resources being - parsed (for example, URI or a full file path). The public id is a - public identifier of the resource (for example, an - application-specific name or a relative file path). The system id - is used to resolve relative paths. In diagnostics messages the - public id is used if it is available. Otherwise the system id - is used.

- -

The parse_begin() and parse_end() functions - present a low-level, Expat-specific parsing API for maximum control. - A typical use-case would look like this (pseudo-code):

- -
-xxx_pimpl root_p;
-document doc_p (root_p, "root");
-
-root_p.pre ();
-doc_p.parse_begin (xml_parser, "file.xml");
-
-while (more_data_to_parse)
-{
-  // Call XML_Parse or XML_ParseBuffer.
-
-  if (status == XML_STATUS_ERROR)
-    break;
-}
-
-// Call parse_end even in case of an error to translate
-// XML and Schema errors to exceptions or error_handler
-// calls.
-//
-doc.parse_end ();
-result_type result (root_p.post_xxx ());
-  
- -

Note that if your vocabulary uses XML namespaces, the - XML_ParserCreateNS() functions should be used to create - the XML parser. Space (XML_Char (' ')) should be used - as a separator (the second argument to XML_ParserCreateNS()). -

- -

The error handling mechanisms employed by the document - parser are described in Section 7.3, "Error - Handling".

- - -

7.3 Error Handling

- -

There are three categories of errors that can result from running - a parser on an XML document: System, XML, and Application. - The System category contains memory allocation and file/stream - operation errors. The XML category covers XML parsing and - well-formedness checking as well as XML Schema validation errors. - Finally, the Application category is for application logic errors - that you may want to propagate from parser implementations to the - caller of the parser. -

- -

The System errors are mapped to the standard exceptions. The - out of memory condition is indicated by throwing an instance - of std::bad_alloc. The stream operation errors - are reported either by throwing an instance of - std::ios_base::failure if exceptions are enabled - or by setting the stream state.

- -

Note that if you are parsing std::istream on - which exceptions are not enabled, then you will need to - check the stream state before calling the post() - callback, as shown in the following example:

- -
-int
-main (int argc, char* argv[])
-{
-  ...
-
-  std::ifstream ifs (argv[1]);
-
-  if (ifs.fail ())
-  {
-    cerr << argv[1] << ": unable to open" << endl;
-    return 1;
-  }
-
-  root_p.pre ();
-  doc_p.parse (ifs);
-
-  if (ifs.fail ())
-  {
-    cerr << argv[1] << ": io failure" << endl;
-    return 1;
-  }
-
-  result_type result (root_p.post_xxx ());
-}
-  
- -

The above example can be rewritten to use exceptions - as shown below:

- -
-int
-main (int argc, char* argv[])
-{
-  try
-  {
-    ...
-
-    std::ifstream ifs;
-    ifs.exceptions (std::ifstream::badbit | std::ifstream::failbit);
-    ifs.open (argv[1]);
-
-    root_p.pre ();
-    doc_p.parse (ifs);
-    result_type result (root_p.post_xxx ());
-  }
-  catch (const std::ifstream::failure&)
-  {
-    cerr << argv[1] << ": unable to open or io failure" << endl;
-    return 1;
-  }
-}
-  
- - -

For reporting application errors from parsing callbacks, you - can throw any exceptions of your choice. They are propagated to - the caller of the parser without any alterations.

- -

The XML errors can be reported either by throwing the - xml_schema::parsing exception or by a callback - to the xml_schema::error_handler object (and - xercesc::ErrorHandler object in case of Xerces-C++).

- -

The xml_schema::parsing exception contains - a list of warnings and errors that were accumulated during - parsing. Note that this exception is thrown only if there - was an error. This makes it impossible to obtain warnings - from an otherwise successful parsing using this mechanism. - The following listing shows the definition of - xml_schema::parsing exception. Note that if the - character type is wchar_t, then the string type - and output stream type in the definition become - std::wstring and std::wostream, - respectively (see Section 5.2, "Character Type - and Encoding").

- -
-namespace xml_schema
-{
-  class exception: public std::exception
-  {
-  protected:
-    virtual void
-    print (std::ostream&) const = 0;
-  };
-
-  inline std::ostream&
-  operator<< (std::ostream& os, const exception& e)
-  {
-    e.print (os);
-    return os;
-  }
-
-
-  class severity
-  {
-  public:
-    enum value
-    {
-      warning,
-      error
-    };
-  };
-
-
-  class error
-  {
-  public:
-    error (xml_schema::severity,
-           const std::string& id,
-           unsigned long line,
-           unsigned long column,
-           const std::string& message);
-
-    xml_schema::severity
-    severity () const;
-
-    const std::string&
-    id () const;
-
-    unsigned long
-    line () const;
-
-    unsigned long
-    column () const;
-
-    const std::string&
-    message () const;
-  };
-
-  std::ostream&
-  operator<< (std::ostream&, const error&);
-
-
-  class diagnostics: public std::vector<error>
-  {
-  };
-
-  std::ostream&
-  operator<< (std::ostream&, const diagnostics&);
-
-
-  class parsing: public exception
-  {
-  public:
-    parsing ();
-    parsing (const xml_schema::diagnostics&);
-
-    const xml_schema::diagnostics&
-    diagnostics () const;
-
-    virtual const char*
-    what () const throw ();
-
-  protected:
-    virtual void
-    print (std::ostream&) const;
-  };
-}
-  
- -

The following example shows how we can catch and print this - exception. The code will print diagnostics messages one per line - in case of an error.

- -
-int
-main (int argc, char* argv[])
-{
-  try
-  {
-    // Parse.
-  }
-  catch (const xml_schema::parsing& e)
-  {
-    cerr << e << endl;
-    return 1;
-  }
-}
-  
- -

With the error_handler approach the diagnostics - messages are delivered as parsing progresses. The following - listing presents the definition of the error_handler - interface. Note that if the character type is wchar_t, - then the string type in the interface becomes std::wstring - (see Section 5.2, "Character Type and Encoding").

- -
-namespace xml_schema
-{
-  class error_handler
-  {
-  public:
-    class severity
-    {
-    public:
-      enum value
-      {
-        warning,
-        error,
-        fatal
-      };
-    };
-
-    virtual bool
-    handle (const std::string& id,
-            unsigned long line,
-            unsigned long column,
-            severity,
-            const std::string& message) = 0;
-  };
-}
-  
- -

The return value of the handle() function indicates whether - parsing should continue if possible. The error with the fatal severity - level terminates the parsing process regardless of the returned value. - At the end of the parsing process with an error that was reported via - the error_handler object, an empty - xml_schema::parsing exception is thrown to indicate - the failure to the caller. You can alter this behavior by throwing - your own exception from the handle() function.

- - - - - -

Appendix A — Supported XML Schema Constructs

- -

The C++/Parser mapping supports validation of the following W3C XML - Schema constructs in the generated code.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ConstructNotes
Structure
element
attribute
any
anyAttribute
all
sequence
choice
complex type, empty content
complex type, mixed content
complex type, simple content extension
complex type, simple content restrictionSimple type facets are not validated.
complex type, complex content extension
complex type, complex content restriction
list
Datatypes
byte
unsignedByte
short
unsignedShort
int
unsignedInt
long
unsignedLong
integer
nonPositiveInteger
nonNegativeInteger
positiveInteger
negativeInteger
boolean
float
double
decimal
string
normalizedString
token
Name
NMTOKEN
NCName
language
anyURI
IDIdentity constraint is not enforced.
IDREFIdentity constraint is not enforced.
NMTOKENS
IDREFSIdentity constraint is not enforced.
QName
base64Binary
hexBinary
date
dateTime
duration
gDay
gMonth
gMonthDay
gYear
gYearMonth
time
- - -
-
- - - diff --git a/doc/cxx/parser/guide/makefile b/doc/cxx/parser/guide/makefile deleted file mode 100644 index 4fca5e9..0000000 --- a/doc/cxx/parser/guide/makefile +++ /dev/null @@ -1,55 +0,0 @@ -# file : doc/cxx/parser/guide/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -default := $(out_base)/ -install := $(out_base)/.install -dist := $(out_base)/.dist -dist-win := $(out_base)/.dist-win -clean := $(out_base)/.clean - -# Build. -# -$(default): $(out_base)/cxx-parser-guide.ps $(out_base)/cxx-parser-guide.pdf - -$(out_base)/cxx-parser-guide.ps: $(src_base)/index.xhtml \ - $(src_base)/figure-1.png \ - $(src_base)/guide.html2ps \ - | $(out_base)/. - $(call message,html2ps $<,html2ps -f $(src_base)/guide.html2ps -o $@ $<) - -$(out_base)/cxx-parser-guide.pdf: $(out_base)/cxx-parser-guide.ps | $(out_base)/. - $(call message,ps2pdf $<,ps2pdf14 $< $@) - -# Install & Dist. -# -$(install): path := $(subst $(src_root)/doc/,,$(src_base)) -$(dist): path := $(subst $(src_root)/,,$(src_base)) - -$(install): $(out_base)/cxx-parser-guide.ps $(out_base)/cxx-parser-guide.pdf - $(call install-data,$(src_base)/figure-1.png,$(install_doc_dir)/xsd/$(path)/figure-1.png) - $(call install-data,$(src_base)/index.xhtml,$(install_doc_dir)/xsd/$(path)/index.xhtml) - $(call install-data,$(out_base)/cxx-parser-guide.ps,$(install_doc_dir)/xsd/$(path)/cxx-parser-guide.ps) - $(call install-data,$(out_base)/cxx-parser-guide.pdf,$(install_doc_dir)/xsd/$(path)/cxx-parser-guide.pdf) - -$(dist): $(out_base)/cxx-parser-guide.ps $(out_base)/cxx-parser-guide.pdf - $(call install-data,$(src_base)/figure-1.png,$(dist_prefix)/$(path)/figure-1.png) - $(call install-data,$(src_base)/index.xhtml,$(dist_prefix)/$(path)/index.xhtml) - $(call install-data,$(out_base)/cxx-parser-guide.ps,$(dist_prefix)/$(path)/cxx-parser-guide.ps) - $(call install-data,$(out_base)/cxx-parser-guide.pdf,$(dist_prefix)/$(path)/cxx-parser-guide.pdf) - -$(dist-win): $(dist) - - -# Clean -# -$(clean): -ifneq ($(xsd_clean_gen),n) - $(call message,rm $$1,rm -f $$1,$(out_base)/cxx-parser-guide.ps) - $(call message,rm $$1,rm -f $$1,$(out_base)/cxx-parser-guide.pdf) -endif - -# How to. -# -$(call include,$(bld_root)/install.make) diff --git a/doc/cxx/parser/makefile b/doc/cxx/parser/makefile deleted file mode 100644 index 7ed09eb..0000000 --- a/doc/cxx/parser/makefile +++ /dev/null @@ -1,20 +0,0 @@ -# file : doc/cxx/parser/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make - -docs := guide - -default := $(out_base)/ -install := $(out_base)/.install -dist := $(out_base)/.dist -dist-win := $(out_base)/.dist-win -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(docs))) -$(install): $(addprefix $(out_base)/,$(addsuffix /.install,$(docs))) -$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(docs))) -$(dist-win): $(addprefix $(out_base)/,$(addsuffix /.dist-win,$(docs))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(docs))) - -$(foreach m,$(docs),$(call import,$(src_base)/$m/makefile)) diff --git a/doc/cxx/tree/guide/guide.html2ps b/doc/cxx/tree/guide/guide.html2ps deleted file mode 100644 index 4606eb4..0000000 --- a/doc/cxx/tree/guide/guide.html2ps +++ /dev/null @@ -1,65 +0,0 @@ -@html2ps { - option { - toc: hb; - colour: 1; - hyphenate: 1; - titlepage: 1; - } - - datefmt: "%B %Y"; - - titlepage { - content: " -
-

C++/Tree Mapping

-

Getting Started Guide

-

 

-

 

-

 

-

 

-

 

-

 

-
-

Copyright © 2009-2020 Code Synthesis Tools CC.

- -

Permission is granted to copy, distribute and/or modify this - document under the terms of the - GNU Free - Documentation License, version 1.2; with no Invariant Sections, - no Front-Cover Texts and no Back-Cover Texts. -

- -

This document is available in the following formats: - XHTML, - PDF, and - PostScript.

"; - } - - toc { - indent: 2em; - } - - header { - odd-right: $H; - even-left: $H; - } - - footer { - odd-left: $D; - odd-center: $T; - odd-right: $N; - - even-left: $N; - even-center: $T; - even-right: $D; - } -} - -body { - font-size: 12pt; - text-align: justify; -} - -pre { - font-size: 10pt; -} diff --git a/doc/cxx/tree/guide/index.xhtml b/doc/cxx/tree/guide/index.xhtml deleted file mode 100644 index 6465776..0000000 --- a/doc/cxx/tree/guide/index.xhtml +++ /dev/null @@ -1,2732 +0,0 @@ - - - - - - C++/Tree Mapping Getting Started Guide - - - - - - - - - - - - - -
-
- -
- -
-
C++/Tree Mapping
-
Getting Started Guide
- -

Copyright © 2009-2020 Code Synthesis Tools CC.

- -

Permission is granted to copy, distribute and/or modify this - document under the terms of the - GNU Free - Documentation License, version 1.2; with no Invariant Sections, - no Front-Cover Texts and no Back-Cover Texts. -

- -

This document is available in the following formats: - XHTML, - PDF, and - PostScript.

- -
- -

Table of Contents

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Preface - - - -
About This Document
More Information
-
1Introduction - - - -
1.1Mapping Overview
1.2Benefits
-
2Hello World Example - - - - - - - - -
2.1Writing XML Document and Schema
2.2Translating Schema to C++
2.3Implementing Application Logic
2.4Compiling and Running
2.5Adding Serialization
2.6Selecting Naming Convention
2.7Generating Documentation
-
3Overall Mapping Configuration - - - - - - -
3.1C++ Standard
3.2Character Type and Encoding
3.3Support for Polymorphism
3.4Namespace Mapping
3.5Thread Safety
-
4Working with Object Models - - - - - - -
4.1Attribute and Element Cardinalities
4.2Accessing the Object Model
4.3Modifying the Object Model
4.4Creating the Object Model from Scratch
4.5Mapping for the Built-in XML Schema Types
-
5Parsing - - - -
5.1XML Schema Validation and Searching
5.2Error Handling
-
6Serialization - - - -
6.1Namespace and Schema Information
6.2Error Handling
-
-
- -

Preface

- -

About This Document

- -

The goal of this document is to provide you with an understanding of - the C++/Tree programming model and allow you to efficiently evaluate - XSD against your project's technical requirements. As such, this - document is intended for C++ developers and software architects - who are looking for an XML processing solution. For a more in-depth - description of the C++/Tree mapping refer to the - C++/Tree - Mapping User Manual.

- -

Prior experience with XML and C++ is required to understand this - document. Basic understanding of XML Schema is advantageous but - not expected or required. -

- - -

More Information

- -

Beyond this guide, you may also find the following sources of - information useful:

- - - - - -

1 Introduction

- -

Welcome to CodeSynthesis XSD and the C++/Tree mapping. XSD is a - cross-platform W3C XML Schema to C++ data binding compiler. C++/Tree - is a W3C XML Schema to C++ mapping that represents the data stored - in XML as a statically-typed, vocabulary-specific object model. -

- -

1.1 Mapping Overview

- -

Based on a formal description of an XML vocabulary (schema), the - C++/Tree mapping produces a tree-like data structure suitable for - in-memory processing. The core of the mapping consists of C++ - classes that constitute the object model and are derived from - types defined in XML Schema as well as XML parsing and - serialization code.

- -

Besides the core features, C++/Tree provide a number of additional - mapping elements that can be useful in some applications. These - include serialization and extraction to/from formats others than - XML, such as unstructured text (useful for debugging) and binary - representations such as XDR and CDR for high-speed data processing - as well as automatic documentation generation. The C++/Tree mapping - also provides a wide range of mechanisms for controlling and - customizing the generated code.

- -

A typical application that uses C++/Tree for XML processing usually - performs the following three steps: it first reads (parses) an XML - document to an in-memory object model, it then performs some useful - computations on that object model which may involve modification - of the model, and finally it may write (serialize) the modified - object model back to XML.

- -

The next chapter presents a simple application that performs these - three steps. The following chapters show how to use the C++/Tree - mapping in more detail.

- -

1.2 Benefits

- -

Traditional XML access APIs such as Document Object Model (DOM) - or Simple API for XML (SAX) have a number of drawbacks that - make them less suitable for creating robust and maintainable - XML processing applications. These drawbacks include: -

- -
    -
  • Generic representation of XML in terms of elements, attributes, - and text forces an application developer to write a substantial - amount of bridging code that identifies and transforms pieces - of information encoded in XML to a representation more suitable - for consumption by the application logic.
  • - -
  • String-based flow control defers error detection to runtime. - It also reduces code readability and maintainability.
  • - -
  • Lack of type safety because the data is represented as text.
  • - -
  • Resulting applications are hard to debug, change, and - maintain.
  • -
- -

In contrast, statically-typed, vocabulary-specific object model - produced by the C++/Tree mapping allows you to operate in your - domain terms instead of the generic elements, attributes, and - text. Static typing helps catch errors at compile-time rather - than at run-time. Automatic code generation frees you for more - interesting tasks (such as doing something useful with the - information stored in the XML documents) and minimizes the - effort needed to adapt your applications to changes in the - document structure. To summarize, the C++/Tree object model has - the following key advantages over generic XML access APIs:

- -
    -
  • Ease of use. The generated code hides all the complexity - associated with parsing and serializing XML. This includes navigating - the structure and converting between the text representation and - data types suitable for manipulation by the application - logic.
  • - -
  • Natural representation. The object representation allows - you to access the XML data using your domain vocabulary instead - of generic elements, attributes, and text.
  • - -
  • Concise code. With the object representation the - application implementation is simpler and thus easier - to read and understand.
  • - -
  • Safety. The generated object model is statically - typed and uses functions instead of strings to access the - information. This helps catch programming errors at compile-time - rather than at runtime.
  • - -
  • Maintainability. Automatic code generation minimizes the - effort needed to adapt the application to changes in the - document structure. With static typing, the C++ compiler - can pin-point the places in the client code that need to be - changed.
  • - -
  • Compatibility. Sequences of elements are represented in - the object model as containers conforming to the standard C++ - sequence requirements. This makes it possible to use standard - C++ algorithms on the object representation and frees you from - learning yet another container interface, as is the case with - DOM.
  • - -
  • Efficiency. If the application makes repetitive use - of the data extracted from XML, then the C++/Tree object model - is more efficient because the navigation is performed using - function calls rather than string comparisons and the XML - data is extracted only once. Furthermore, the runtime memory - usage is reduced due to more efficient data storage - (for instance, storing numeric data as integers instead of - strings) as well as the static knowledge of cardinality - constraints.
  • -
- - - - - -

2 Hello World Example

- -

In this chapter we will examine how to parse, access, modify, and - serialize a very simple XML document using the XSD-generated - C++/Tree object model. The code presented in this chapter is - based on the hello example which can be found in - the examples/cxx/tree/ directory of the XSD - distribution.

- -

2.1 Writing XML Document and Schema

- -

First, we need to get an idea about the structure - of the XML documents we are going to process. Our - hello.xml, for example, could look like this:

- -
-<?xml version="1.0"?>
-<hello>
-
-  <greeting>Hello</greeting>
-
-  <name>sun</name>
-  <name>moon</name>
-  <name>world</name>
-
-</hello>
-  
- -

Then we can write a description of the above XML in the - XML Schema language and save it into hello.xsd:

- -
-<?xml version="1.0"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
-
-  <xs:complexType name="hello_t">
-    <xs:sequence>
-      <xs:element name="greeting" type="xs:string"/>
-      <xs:element name="name" type="xs:string" maxOccurs="unbounded"/>
-    </xs:sequence>
-  </xs:complexType>
-
-  <xs:element name="hello" type="hello_t"/>
-
-</xs:schema>
-  
- -

Even if you are not familiar with XML Schema, it - should be easy to connect declarations in hello.xsd - to elements in hello.xml. The hello_t type - is defined as a sequence of the nested greeting and - name elements. Note that the term sequence in XML - Schema means that elements should appear in a particular order - as opposed to appearing multiple times. The name - element has its maxOccurs property set to - unbounded which means it can appear multiple times - in an XML document. Finally, the globally-defined hello - element prescribes the root element for our vocabulary. For an - easily-approachable introduction to XML Schema refer to - XML Schema Part 0: - Primer.

- -

The above schema is a specification of our XML vocabulary; it tells - everybody what valid documents of our XML-based language should look - like. We can also update our hello.xml to include the - information about the schema so that XML parsers can validate - our document:

- -
-<?xml version="1.0"?>
-<hello xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:noNamespaceSchemaLocation="hello.xsd">
-
-  <greeting>Hello</greeting>
-
-  <name>sun</name>
-  <name>moon</name>
-  <name>world</name>
-
-</hello>
-      
- - -

The next step is to compile the schema to generate the object - model and parsing functions.

- -

2.2 Translating Schema to C++

- -

Now we are ready to translate our hello.xsd to C++. - To do this we invoke the XSD compiler from a terminal (UNIX) or - a command prompt (Windows): -

- -
-$ xsd cxx-tree hello.xsd
-  
- -

The XSD compiler produces two C++ files: hello.hxx and - hello.cxx. The following code fragment is taken from - hello.hxx; it should give you an idea about what gets - generated: -

- -
-class hello_t
-{
-public:
-  // greeting
-  //
-  typedef xml_schema::string greeting_type;
-
-  const greeting_type&
-  greeting () const;
-
-  greeting_type&
-  greeting ();
-
-  void
-  greeting (const greeting_type& x);
-
-  // name
-  //
-  typedef xml_schema::string name_type;
-  typedef xsd::sequence<name_type> name_sequence;
-  typedef name_sequence::iterator name_iterator;
-  typedef name_sequence::const_iterator name_const_iterator;
-
-  const name_sequence&
-  name () const;
-
-  name_sequence&
-  name ();
-
-  void
-  name (const name_sequence& s);
-
-  // Constructor.
-  //
-  hello_t (const greeting_type&);
-
-  ...
-
-};
-
-std::auto_ptr<hello_t>
-hello (const std::string& uri);
-
-std::auto_ptr<hello_t>
-hello (std::istream&);
-  
- -

The hello_t C++ class corresponds to the - hello_t XML Schema type. For each element - in this type a set of C++ type definitions as well as - accessor and modifier functions are generated inside the - hello_t class. Note that the type definitions - and member functions for the greeting and - name elements are different because of the - cardinality differences between these two elements - (greeting is a required single element and - name is a sequence of elements).

- -

The xml_schema::string type used in the type - definitions is a C++ class provided by the XSD runtime - that corresponds to built-in XML Schema type - string. The xml_schema::string - is based on std::string and can be used as - such. Similarly, the sequence class template - that is used in the name_sequence type - definition is based on and has the same interface as - std::vector. The mapping between the built-in - XML Schema types and C++ types is described in more detail in - Section 4.5, "Mapping for the Built-in XML Schema - Types". The hello_t class also includes a - constructor with an initializer for the required - greeting element as its argument.

- -

The hello overloaded global functions correspond - to the hello global element in XML Schema. A - global element in XML Schema is a valid document root. - By default XSD generated a set of parsing functions for each - global element defined in XML Schema (this can be overridden - with the --root-element-* options). Parsing - functions return a dynamically allocated object model as an - automatic pointer. The actual pointer used depends on the - C++ standard selected. For C++98 it is std::auto_ptr - as shown above. For C++11 it is std::unique_ptr. - For example, if we modify our XSD compiler invocation to - select C++11:

- -
-$ xsd cxx-tree --std c++11 hello.xsd
-  
- -

Then the parsing function signatures will become:

- -
-std::unique_ptr<hello_t>
-hello (const std::string& uri);
-
-std::unique_ptr<hello_t>
-hello (std::istream&);
-  
- -

For more information on parsing functions see Chapter 5, - "Parsing".

- -

2.3 Implementing Application Logic

- -

At this point we have all the parts we need to do something useful - with the information stored in our XML document: -

- -
-#include <iostream>
-#include "hello.hxx"
-
-using namespace std;
-
-int
-main (int argc, char* argv[])
-{
-  try
-  {
-    auto_ptr<hello_t> h (hello (argv[1]));
-
-    for (hello_t::name_const_iterator i (h->name ().begin ());
-         i != h->name ().end ();
-         ++i)
-    {
-      cerr << h->greeting () << ", " << *i << "!" << endl;
-    }
-  }
-  catch (const xml_schema::exception& e)
-  {
-    cerr << e << endl;
-    return 1;
-  }
-}
-  
- -

The first part of our application calls one of the parsing - functions to parser an XML file specified in the command line. - We then use the returned object model to iterate over names - and print a greeting line for each of them. Finally, we - catch and print the xml_schema::exception - exception in case something goes wrong. This exception - is the root of the exception hierarchy used by the - XSD-generated code. -

- - -

2.4 Compiling and Running

- -

After saving our application from the previous section in - driver.cxx, we are ready to compile our first - program and run it on the test XML document. On a UNIX - system this can be done with the following commands: -

- -
-$ c++ -I.../libxsd -c driver.cxx hello.cxx
-$ c++ -o driver driver.o hello.o -lxerces-c
-$ ./driver hello.xml
-Hello, sun!
-Hello, moon!
-Hello, world!
-  
- -

Here .../libxsd represents the path to the - libxsd directory in the XSD distribution. - Note also that we are required to link our application - with the Xerces-C++ library because the generated code - uses it as the underlying XML parser.

- -

2.5 Adding Serialization

- -

While parsing and accessing the XML data may be everything - you need, there are applications that require creating new - or modifying existing XML documents. By default XSD does - not produce serialization code. We will need to request - it with the --generate-serialization options:

- -
-$ xsd cxx-tree --generate-serialization hello.xsd
-  
- -

If we now examine the generated hello.hxx file, - we will find a set of overloaded serialization functions, - including the following version:

- -
-void
-hello (std::ostream&,
-       const hello_t&,
-       const xml_schema::namespace_infomap& =
-         xml_schema::namespace_infomap ());
-
-  
- -

Just like with parsing functions, XSD generates serialization - functions for each global element unless instructed otherwise - with one of the --root-element-* options. For more - information on serialization functions see Chapter 6, - "Serialization".

- -

We first examine an application that modifies an existing - object model and serializes it back to XML:

- -
-#include <iostream>
-#include "hello.hxx"
-
-using namespace std;
-
-int
-main (int argc, char* argv[])
-{
-  try
-  {
-    auto_ptr<hello_t> h (hello (argv[1]));
-
-    // Change the greeting phrase.
-    //
-    h->greeting ("Hi");
-
-    // Add another entry to the name sequence.
-    //
-    h->name ().push_back ("mars");
-
-    // Serialize the modified object model to XML.
-    //
-    xml_schema::namespace_infomap map;
-    map[""].name = "";
-    map[""].schema = "hello.xsd";
-
-    hello (cout, *h, map);
-  }
-  catch (const xml_schema::exception& e)
-  {
-    cerr << e << endl;
-    return 1;
-  }
-}
-  
- -

First, our application parses an XML document and obtains its - object model as in the previous example. Then it changes the - greeting string and adds another entry to the list of names. - Finally, it serializes the object model back to XML by calling - the serialization function.

- -

The first argument we pass to the serialization function is - cout which results in the XML being written to - the standard output for us to inspect. We could have also - written the result to a file or memory buffer by creating an - instance of std::ofstream or std::ostringstream - and passing it instead of cout. The second argument is the - object model we want to serialize. The final argument is an optional - namespace information map for our vocabulary. It captures information - such as namespaces, namespace prefixes to which they should be mapped, - and schemas associated with these namespaces. If we don't provide - this argument then generic namespace prefixes (p1, - p2, etc.) will be automatically assigned to XML namespaces - and no schema information will be added to the resulting document - (see Chapter 6, "Serialization" for details). - In our case, the prefix (map key) and namespace name are empty - because our vocabulary does not use XML namespaces.

- -

If we now compile and run this application we will see the - output as shown in the following listing:

- -
-<?xml version="1.0"?>
-<hello xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:noNamespaceSchemaLocation="hello.xsd">
-
-  <greeting>Hi</greeting>
-
-  <name>sun</name>
-  <name>moon</name>
-  <name>world</name>
-  <name>mars</name>
-
-</hello>
-  
- -

We can also create and serialize an object model from scratch - as shown in the following example:

- -
-#include <iostream>
-#include <fstream>
-#include "hello.hxx"
-
-using namespace std;
-
-int
-main (int argc, char* argv[])
-{
-  try
-  {
-    hello_t h ("Hi");
-
-    hello_t::name_sequence& ns (h.name ());
-
-    ns.push_back ("Jane");
-    ns.push_back ("John");
-
-    // Serialize the object model to XML.
-    //
-    xml_schema::namespace_infomap map;
-    map[""].name = "";
-    map[""].schema = "hello.xsd";
-
-    std::ofstream ofs (argv[1]);
-    hello (ofs, h, map);
-  }
-  catch (const xml_schema::exception& e)
-  {
-    cerr << e << endl;
-    return 1;
-  }
-}
-  
- -

In this example we used the generated constructor to create - an instance of type hello_t. To reduce typing, - we obtained a reference to the name sequence which we then - used to add a few names. The serialization part is identical - to the previous example except this time we are writing to - a file. If we compile and run this program, it produces the - following XML file:

- -
-<?xml version="1.0"?>
-<hello xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:noNamespaceSchemaLocation="hello.xsd">
-
-  <greeting>Hi</greeting>
-
-  <name>Jane</name>
-  <name>John</name>
-
-</hello>
-  
- -

2.6 Selecting Naming Convention

- -

By default XSD uses the so-called K&R (Kernighan and Ritchie) - identifier naming convention in the generated code. In this - convention both type and function names are in lower case and - words are separated by underscores. If your application code or - schemas use a different notation, you may want to change the - naming convention used in the generated code for consistency. - XSD supports a set of widely-used naming conventions - that you can select with the --type-naming and - --function-naming options. You can also further - refine one of the predefined conventions or create a completely - custom naming scheme by using the --*-regex options.

- -

As an example, let's assume that our "Hello World" application - uses the so-called upper-camel-case naming convention for types - (that is, each word in a type name is capitalized) and the K&R - convention for function names. Since K&R is the default - convention for both type and function names, we only need to - change the type naming scheme:

- -
-$ xsd cxx-tree --type-naming ucc hello.xsd
-  
- -

The ucc argument to the --type-naming - options stands for upper-camel-case. If we now examine the - generated hello.hxx, we will see the following - changes compared to the declarations shown in the previous - sections:

- -
-class Hello_t
-{
-public:
-  // greeting
-  //
-  typedef xml_schema::String GreetingType;
-
-  const GreetingType&
-  greeting () const;
-
-  GreetingType&
-  greeting ();
-
-  void
-  greeting (const GreetingType& x);
-
-  // name
-  //
-  typedef xml_schema::String NameType;
-  typedef xsd::sequence<NameType> NameSequence;
-  typedef NameSequence::iterator NameIterator;
-  typedef NameSequence::const_iterator NameConstIterator;
-
-  const NameSequence&
-  name () const;
-
-  NameSequence&
-  name ();
-
-  void
-  name (const NameSequence& s);
-
-  // Constructor.
-  //
-  Hello_t (const GreetingType&);
-
-  ...
-
-};
-
-std::auto_ptr<Hello_t>
-hello (const std::string& uri);
-
-std::auto_ptr<Hello_t>
-hello (std::istream&);
-  
- -

Notice that the type names in the xml_schema namespace, - for example xml_schema::String, now also use the - upper-camel-case naming convention. The only thing that we may - be unhappy about in the above code is the _t - suffix in Hello_t. If we are not in a position - to change the schema, we can touch-up the ucc - convention with a custom translation rule using the - --type-regex option:

- -
-$ xsd cxx-tree --type-naming ucc --type-regex '/ (.+)_t/\u$1/' hello.xsd
-  
- -

This results in the following changes to the generated code:

- -
-class Hello
-{
-public:
-  // greeting
-  //
-  typedef xml_schema::String GreetingType;
-
-  const GreetingType&
-  greeting () const;
-
-  GreetingType&
-  greeting ();
-
-  void
-  greeting (const GreetingType& x);
-
-  // name
-  //
-  typedef xml_schema::String NameType;
-  typedef xsd::sequence<NameType> NameSequence;
-  typedef NameSequence::iterator NameIterator;
-  typedef NameSequence::const_iterator NameConstIterator;
-
-  const NameSequence&
-  name () const;
-
-  NameSequence&
-  name ();
-
-  void
-  name (const NameSequence& s);
-
-  // Constructor.
-  //
-  Hello (const GreetingType&);
-
-  ...
-
-};
-
-std::auto_ptr<Hello>
-hello (const std::string& uri);
-
-std::auto_ptr<Hello>
-hello (std::istream&);
-  
- -

For more detailed information on the --type-naming, - --function-naming, --type-regex, and - other --*-regex options refer to the NAMING - CONVENTION section in the XSD - Compiler Command Line Manual.

- -

2.7 Generating Documentation

- -

While our object model is quite simple, real-world vocabularies - can be quite complex with hundreds of types, elements, and - attributes. For such vocabularies figuring out which types - provide which member functions by studying the generated - source code or schemas can be a daunting task. To provide - application developers with a more accessible way of - understanding the generated object models, the XSD compiler - can be instructed to produce source code with documentation - comments in the Doxygen format. Then the source code can be - processed with the Doxygen - documentation system to extract this information and produce - documentation in various formats. -

- -

In this section we will see how to generate documentation - for our "Hello World" vocabulary. To showcase the full power - of the XSD documentation facilities, we will first document - our schema. The XSD compiler will then transfer - this information from the schema to the generated code and - then to the object model documentation. Note that the - documentation in the schema is not required for XSD to - generate useful documentation. Below you will find - our hello.xsd with added documentation:

- -
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
-
-  <xs:complexType name="hello_t">
-
-    <xs:annotation>
-      <xs:documentation>
-        The hello_t type consists of a greeting phrase and a
-        collection of names to which this greeting applies.
-      </xs:documentation>
-    </xs:annotation>
-
-    <xs:sequence>
-
-      <xs:element name="greeting" type="xs:string">
-        <xs:annotation>
-          <xs:documentation>
-            The greeting element contains the greeting phrase
-            for this hello object.
-          </xs:documentation>
-        </xs:annotation>
-      </xs:element>
-
-      <xs:element name="name" type="xs:string" maxOccurs="unbounded">
-        <xs:annotation>
-          <xs:documentation>
-            The name elements contains names to be greeted.
-          </xs:documentation>
-        </xs:annotation>
-      </xs:element>
-
-    </xs:sequence>
-  </xs:complexType>
-
-  <xs:element name="hello" type="hello_t">
-    <xs:annotation>
-      <xs:documentation>
-        The hello element is a root of the Hello XML vocabulary.
-        Every conforming document should start with this element.
-      </xs:documentation>
-    </xs:annotation>
-  </xs:element>
-
-</xs:schema>
-  
- -

The first step in obtaining the documentation is to recompile - our schema with the --generate-doxygen option:

- -
-$ xsd cxx-tree --generate-serialization --generate-doxygen hello.xsd
-  
- -

Now the generated hello.hxx file contains comments - in the Doxygen format. The next step is to process this file - with the Doxygen documentation system. If your project does - not use Doxygen then you first need to create a configuration - file for your project:

- -
-$ doxygen -g hello.doxygen
-  
- -

You only need to perform this step once. Now we can generate - the documentation by executing the following command in the - directory with the generated source code:

- -
-$ doxygen hello.doxygen
-  
- -

While the generated documentation can be useful as is, we can - go one step further and link (using the Doxygen tags mechanism) - the documentation for our object model with the documentation - for the XSD runtime library which defines C++ classes for the - built-in XML Schema types. This way we can seamlessly browse - between documentation for the hello_t class which - is generated by the XSD compiler and the xml_schema::string - class which is defined in the XSD runtime library. The Doxygen - configuration file for the XSD runtime is provided with the XSD - distribution.

- -

You can view the result of the steps described in this section - on the Hello - Example Documentation page.

- - - - -

3 Overall Mapping Configuration

- -

The C++/Tree mapping has a number of configuration parameters that - determine the overall properties and behavior of the generated code. - Configuration parameters are specified with the XSD command line - options. This chapter describes configuration aspects that are most - commonly encountered by application developers. These include: the - C++ standard, the character type that is used by the generated code, - handling of vocabularies that use XML Schema polymorphism, XML Schema - to C++ namespace mapping, and thread safety. For more ways to configure - the generated code refer to the - XSD - Compiler Command Line Manual. -

- -

3.1 C++ Standard

- -

The C++/Tree mapping provides support for ISO/IEC C++ 1998/2003 (C++98) - and ISO/IEC C++ 2011 (C++11). To select the C++ standard for the - generated code we use the --std XSD compiler command - line option. While the majority of the examples in this guide use - C++98, support for the new functionality and library components - introduced in C++11 are discussed throughout the document.

- -

3.2 Character Type and Encoding

- -

The C++/Tree mapping has built-in support for two character types: - char and wchar_t. You can select the - character type with the --char-type command line - option. The default character type is char. The - character type affects all string and string-based types that - are used in the mapping. These include the string-based built-in - XML Schema types, exception types, stream types, etc.

- -

Another aspect of the mapping that depends on the character type - is character encoding. For the char character type - the default encoding is UTF-8. Other supported encodings are - ISO-8859-1, Xerces-C++ Local Code Page (LPC), as well as - custom encodings. You can select which encoding should be used - in the object model with the --char-encoding command - line option.

- -

For the wchar_t character type the encoding is - automatically selected between UTF-16 and UTF-32/UCS-4 depending - on the size of the wchar_t type. On some platforms - (for example, Windows with Visual C++ and AIX with IBM XL C++) - wchar_t is 2 bytes long. For these platforms the - encoding is UTF-16. On other platforms wchar_t is 4 bytes - long and UTF-32/UCS-4 is used.

- -

Note also that the character encoding that is used in the object model - is independent of the encodings used in input and output XML. In fact, - all three (object mode, input XML, and output XML) can have different - encodings.

- -

3.3 Support for Polymorphism

- -

By default XSD generates non-polymorphic code. If your vocabulary - uses XML Schema polymorphism in the form of xsi:type - and/or substitution groups, then you will need to compile - your schemas with the --generate-polymorphic option - to produce polymorphism-aware code. For more information on - working with polymorphic object models, refer to - Section 2.11, - "Mapping for xsi:type and Substitution Groups" in - the C++/Tree Mapping User Manual.

- -

3.4 Namespace Mapping

- -

XSD maps XML namespaces specified in the targetNamespace - attribute in XML Schema to one or more nested C++ namespaces. By - default, a namespace URI is mapped to a sequence of C++ namespace - names by removing the protocol and host parts and splitting the - rest into a sequence of names with '/' as the name - separator.

- -

The default mapping of namespace URIs to C++ namespaces - can be altered using the --namespace-map and - --namespace-regex compiler options. For example, - to map namespace URI https://www.codesynthesis.com/my to - C++ namespace cs::my, we can use the following option:

- -
---namespace-map https://www.codesynthesis.com/my=cs::my
-  
- -

A vocabulary without a namespace is mapped to the global scope. This - also can be altered with the above options by using an empty name - for the XML namespace:

- -
---namespace-map =cs
-  
- -

3.5 Thread Safety

- -

XSD-generated code is thread-safe in the sense that you can - use different instantiations of the object model in several - threads concurrently. This is possible due to the generated - code not relying on any writable global variables. If you need - to share the same object between several threads then you will - need to provide some form of synchronization. One approach would - be to use the generated code customization mechanisms to embed - synchronization primitives into the generated C++ classes. For more - information on generated code customization refer to the - C++/Tree - Mapping Customization Guide.

- -

If you also would like to call parsing and/or serialization - functions from several threads potentially concurrently, then - you will need to make sure the Xerces-C++ runtime is initialized - and terminated only once. The easiest way to do this is to - initialize/terminate Xerces-C++ from main() when - there are no threads yet/anymore:

- -
-#include <xercesc/util/PlatformUtils.hpp>
-
-int
-main ()
-{
-  xercesc::XMLPlatformUtils::Initialize ();
-
-  {
-    // Start/terminate threads and parse/serialize here.
-  }
-
-  xercesc::XMLPlatformUtils::Terminate ();
-}
-  
- -

Because you initialize the Xerces-C++ runtime yourself you should - also pass the xml_schema::flags::dont_initialize flag - to parsing and serialization functions. See Chapter 5, - "Parsing" and Chapter 6, "Serialization" for - more information.

- - - - - -

4 Working with Object Models

- -

As we have seen in the previous chapters, the XSD compiler generates - a C++ class for each type defined in XML Schema. Together these classes - constitute an object model for an XML vocabulary. In this chapter we - will take a closer look at different elements that comprise an - object model class as well as how to create, access, and modify - object models.

- -

In this and subsequent chapters we will use the following schema - that describes a collection of person records. We save it in - people.xsd:

- -
-<?xml version="1.0"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
-
-  <xs:simpleType name="gender_t">
-    <xs:restriction base="xs:string">
-      <xs:enumeration value="male"/>
-      <xs:enumeration value="female"/>
-    </xs:restriction>
-  </xs:simpleType>
-
-  <xs:complexType name="person_t">
-    <xs:sequence>
-      <xs:element name="first-name" type="xs:string"/>
-      <xs:element name="middle-name" type="xs:string" minOccurs="0"/>
-      <xs:element name="last-name" type="xs:string"/>
-      <xs:element name="gender" type="gender_t"/>
-      <xs:element name="age" type="xs:short"/>
-    </xs:sequence>
-    <xs:attribute name="id" type="xs:unsignedInt" use="required"/>
-  </xs:complexType>
-
-  <xs:complexType name="people_t">
-    <xs:sequence>
-      <xs:element name="person" type="person_t" maxOccurs="unbounded"/>
-    </xs:sequence>
-  </xs:complexType>
-
-  <xs:element name="people" type="people_t"/>
-
-</xs:schema>
-  
- -

A sample XML instance to go along with this schema is saved - in people.xml:

- -
-<?xml version="1.0"?>
-<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-        xsi:noNamespaceSchemaLocation="people.xsd">
-
-  <person id="1">
-    <first-name>John</first-name>
-    <last-name>Doe</last-name>
-    <gender>male</gender>
-    <age>32</age>
-  </person>
-
-  <person id="2">
-    <first-name>Jane</first-name>
-    <middle-name>Mary</middle-name>
-    <last-name>Doe</last-name>
-    <gender>female</gender>
-    <age>28</age>
-  </person>
-
-</people>
-  
- -

Compiling people.xsd with the XSD compiler results - in three generated C++ classes: gender_t, - person_t, and people_t. - The gender_t class is modelled after the C++ - enum type. Its definition is presented below:

- -
-class gender_t: public xml_schema::string
-{
-public:
-  enum value
-  {
-    male,
-    female
-  };
-
-  gender_t (value);
-  gender_t (const xml_schema::string&);
-
-  gender_t&
-  operator= (value);
-
-  operator value () const;
-};
-  
- -

The following listing shows how we can use this type:

- -
-gender_t m (gender_t::male);
-gender_t f ("female");
-
-if (m == "female" || f == gender_t::male)
-{
-  ...
-}
-
-switch (m)
-{
-case gender_t::male:
-  {
-    ...
-  }
-case gender_t::female:
-  {
-    ...
-  }
-}
-  
- -

The other two classes will be examined in detail in the subsequent - sections.

- -

4.1 Attribute and Element Cardinalities

- -

As we have seen in the previous chapters, XSD generates a different - set of type definitions and member functions for elements with - different cardinalities. The C++/Tree mapping divides all the possible - element and attribute cardinalities into three cardinality classes: - one, optional, and sequence.

- -

The one cardinality class covers all elements that should - occur exactly once as well as required attributes. In our - example, the first-name, last-name, - gender, and age elements as well as - the id attribute belong to this cardinality class. - The following code fragment shows type definitions as well as the - accessor and modifier functions that are generated for the - gender element in the person_t class:

- -
-class person_t
-{
-  // gender
-  //
-  typedef gender_t gender_type;
-
-  const gender_type&
-  gender () const;
-
-  gender_type&
-  gender ();
-
-  void
-  gender (const gender_type&);
-};
-  
- -

The gender_type type is an alias for the element's type. - The first two accessor functions return read-only (constant) and - read-write references to the element's value, respectively. The - modifier function sets the new value for the element.

- -

The optional cardinality class covers all elements that - can occur zero or one time as well as optional attributes. In our - example, the middle-name element belongs to this - cardinality class. The following code fragment shows the type - definitions as well as the accessor and modifier functions that - are generated for this element in the person_t class:

- -
-class person_t
-{
-  // middle-name
-  //
-  typedef xml_schema::string middle_name_type;
-  typedef xsd::optional<middle_name_type> middle_name_optional;
-
-  const middle_name_optional&
-  middle_name () const;
-
-  middle_name_optional&
-  middle_name ();
-
-  void
-  middle_name (const middle_name_type&);
-
-  void
-  middle_name (const middle_name_optional&);
-};
-  
- -

As with the gender element, middle_name_type - is an alias for the element's type. The middle_name_optional - type is a container for the element's optional value. It can be queried - for the presence of the value using the present() function. - The value itself can be retrieved using the get() - accessor and set using the set() modifier. The container - can be reverted to the value not present state with the call to the - reset() function. The following example shows how we - can use this container:

- -
-person_t::middle_name_optional n ("John");
-
-if (n.present ())
-{
-  cout << n.get () << endl;
-}
-
-n.set ("Jane");
-n.reset ();
-  
- - -

Unlike the one cardinality class, the accessor functions - for the optional class return read-only (constant) and - read-write references to the container instead of the element's - value directly. The modifier functions set the new value for the - element.

- -

Finally, the sequence cardinality class covers all elements - that can occur more than once. In our example, the - person element in the people_t type - belongs to this cardinality class. The following code fragment shows - the type definitions as well as the accessor and modifier functions - that are generated for this element in the people_t - class:

- -
-class people_t
-{
-  // person
-  //
-  typedef person_t person_type;
-  typedef xsd::sequence<person_type> person_sequence;
-  typedef person_sequence::iterator person_iterator;
-  typedef person_sequence::const_iterator person_const_iterator;
-
-  const person_sequence&
-  person () const;
-
-  person_sequence&
-  person ();
-
-  void
-  person (const person_sequence&);
-};
-  
- -

Identical to the other cardinality classes, person_type - is an alias for the element's type. The person_sequence - type is a sequence container for the element's values. It is based - on and has the same interface as std::vector and - therefore can be used in similar ways. The person_iterator - and person_const_iterator types are read-only - (constant) and read-write iterators for the person_sequence - container.

- -

Similar to the optional cardinality class, the - accessor functions for the sequence class return - read-only (constant) and read-write references to the sequence - container. The modifier functions copies the entries from - the passed sequence.

- -

C++/Tree is a "flattening" mapping in a sense that many levels of - nested compositors (choice and sequence), - all potentially with their own cardinalities, are in the end mapped - to a flat set of elements with one of the three cardinality classes - discussed above. While this results in a simple and easy to use API - for most types, in certain cases, the order of elements in the actual - XML documents is not preserved once parsed into the object model. To - overcome this limitation we can mark certain schema types, for which - content order is not sufficiently preserved, as ordered. For more - information on this functionality refer to - Section - 2.8.4, "Element Order" in the C++/Tree Mapping User Manual.

- -

For complex schemas with many levels of nested compositors - (choice and sequence) it can also - be hard to deduce the cardinality class of a particular element. - The generated Doxygen documentation can greatly help with - this task. For each element and attribute the documentation - clearly identifies its cardinality class. Alternatively, you - can study the generated header files to find out the cardinality - class of a particular attribute or element.

- -

In the next sections we will examine how to access and modify - information stored in an object model using accessor and modifier - functions described in this section.

- -

4.2 Accessing the Object Model

- -

In this section we will learn how to get to the information - stored in the object model for our person records vocabulary. - The following application accesses and prints the contents - of the people.xml file:

- -
-#include <iostream>
-#include "people.hxx"
-
-using namespace std;
-
-int
-main ()
-{
-  auto_ptr<people_t> ppl (people ("people.xml"));
-
-  // Iterate over individual person records.
-  //
-  people_t::person_sequence& ps (ppl->person ());
-
-  for (people_t::person_iterator i (ps.begin ()); i != ps.end (); ++i)
-  {
-    person_t& p (*i);
-
-    // Print names: first-name and last-name are required elements,
-    // middle-name is optional.
-    //
-    cout << "name:   " << p.first_name () << " ";
-
-    if (p.middle_name ().present ())
-      cout << p.middle_name ().get () << " ";
-
-    cout << p.last_name () << endl;
-
-    // Print gender, age, and id which are all required.
-    //
-    cout << "gender: " << p.gender () << endl
-         << "age:    " << p.age () << endl
-         << "id:     " << p.id () << endl
-         << endl;
-  }
-}
-  
- -

This code shows common patterns of accessing elements and attributes - with different cardinality classes. For the sequence element - (person in people_t) we first obtain a - reference to the container and then iterate over individual - records. The values of elements and attributes with the - one cardinality class (first-name, - last-name, gender, age, - and id) can be obtained directly by calling the - corresponding accessor functions. For the optional element - middle-name we first check if the value is present - and only then call get() to retrieve it.

- -

Note that when we want to reduce typing by creating a variable - representing a fragment of the object model that we are currently - working with (ps and p above), we obtain - a reference to that fragment instead of making a potentially - expensive copy. This is generally a good rule to follow when - creating high-performance applications.

- -

If we run the above application on our sample - people.xml, the output looks as follows:

- -
-name:   John Doe
-gender: male
-age:    32
-id:     1
-
-name:   Jane Mary Doe
-gender: female
-age:    28
-id:     2
-  
- - -

4.3 Modifying the Object Model

- -

In this section we will learn how to modify the information - stored in the object model for our person records vocabulary. - The following application changes the contents of the - people.xml file:

- -
-#include <iostream>
-#include "people.hxx"
-
-using namespace std;
-
-int
-main ()
-{
-  auto_ptr<people_t> ppl (people ("people.xml"));
-
-  // Iterate over individual person records and increment
-  // the age.
-  //
-  people_t::person_sequence& ps (ppl->person ());
-
-  for (people_t::person_iterator i (ps.begin ()); i != ps.end (); ++i)
-  {
-    // Alternative way: i->age ()++;
-    //
-    i->age (i->age () + 1);
-  }
-
-  // Add middle-name to the first record and remove it from
-  // the second.
-  //
-  person_t& john (ps[0]);
-  person_t& jane (ps[1]);
-
-  john.middle_name ("Mary");
-  jane.middle_name ().reset ();
-
-  // Add another John record.
-  //
-  ps.push_back (john);
-
-  // Serialize the modified object model to XML.
-  //
-  xml_schema::namespace_infomap map;
-  map[""].name = "";
-  map[""].schema = "people.xsd";
-
-  people (cout, *ppl, map);
-}
-  
- -

The first modification the above application performs is iterating - over person records and incrementing the age value. This code - fragment shows how to modify the value of a required attribute - or element. The next modification shows how to set a new value - for the optional middle-name element as well - as clear its value. Finally the example adds a copy of the - John Doe record to the person element sequence.

- -

Note that in this case using references for the ps, - john, and jane variables is no longer - a performance improvement but a requirement for the application - to function correctly. If we hadn't used references, all our changes - would have been made on copies without affecting the object model.

- -

If we run the above application on our sample people.xml, - the output looks as follows:

- -
-<?xml version="1.0"?>
-<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-        xsi:noNamespaceSchemaLocation="people.xsd">
-
-  <person id="1">
-    <first-name>John</first-name>
-    <middle-name>Mary</middle-name>
-    <last-name>Doe</last-name>
-    <gender>male</gender>
-    <age>33</age>
-  </person>
-
-  <person id="2">
-    <first-name>Jane</first-name>
-    <last-name>Doe</last-name>
-    <gender>female</gender>
-    <age>29</age>
-  </person>
-
-  <person id="1">
-    <first-name>John</first-name>
-    <middle-name>Mary</middle-name>
-    <last-name>Doe</last-name>
-    <gender>male</gender>
-    <age>33</age>
-  </person>
-
-</people>
-  
- - -

4.4 Creating the Object Model from Scratch

- -

In this section we will learn how to create a new object model - for our person records vocabulary. The following application - recreates the content of the original people.xml - file:

- -
-#include <iostream>
-#include "people.hxx"
-
-using namespace std;
-
-int
-main ()
-{
-  people_t ppl;
-  people_t::person_sequence& ps (ppl.person ());
-
-  // Add the John Doe record.
-  //
-  ps.push_back (
-    person_t ("John",         // first-name
-              "Doe",          // last-name
-              gender_t::male, // gender
-              32,             // age
-              1));
-
-  // Add the Jane Doe record.
-  //
-  ps.push_back (
-    person_t ("Jane",           // first-name
-              "Doe",            // last-name
-              gender_t::female, // gender
-              28,               // age
-              2));              // id
-
-  // Add middle name to the Jane Doe record.
-  //
-  person_t& jane (ps.back ());
-  jane.middle_name ("Mary");
-
-  // Serialize the object model to XML.
-  //
-  xml_schema::namespace_infomap map;
-  map[""].name = "";
-  map[""].schema = "people.xsd";
-
-  people (cout, ppl, map);
-}
-  
- -

The only new part in the above application is the calls - to the people_t and person_t - constructors. As a general rule, for each C++ class - XSD generates a constructor with initializers - for each element and attribute belonging to the one - cardinality class. For our vocabulary, the following - constructors are generated:

- -
-class person_t
-{
-  person_t (const first_name_type&,
-            const last_name_type&,
-            const gender_type&,
-            const age_type&,
-            const id_type&);
-};
-
-class people_t
-{
-  people_t ();
-};
-  
- -

Note also that we set the middle-name element - on the Jane Doe record by obtaining a reference to that record - in the object model and setting the middle-name - value on it. This is a general rule that should be followed - in order to obtain the best performance: if possible, - direct modifications to the object model should be preferred - to modifications on temporaries with subsequent copying. The - following code fragment shows a semantically equivalent but - slightly slower version:

- -
-// Add the Jane Doe record.
-//
-person_t jane ("Jane",           // first-name
-               "Doe",            // last-name
-               gender_t::female, // gender
-               28,               // age
-               2);               // id
-
-jane.middle_name ("Mary");
-
-ps.push_back (jane);
-  
- -

We can also go one step further to reduce copying and improve - the performance of our application by using the non-copying - push_back() function which assumes ownership - of the passed objects:

- -
-// Add the John Doe record. C++98 version.
-//
-auto_ptr<person_t> john_p (
-  new person_t ("John",           // first-name
-                "Doe",            // last-name
-                gender_t::male,   // gender
-                32,               // age
-                1));
-ps.push_back (john_p); // assumes ownership
-
-// Add the Jane Doe record. C++11 version
-//
-unique_ptr<person_t> jane_p (
-  new person_t ("Jane",           // first-name
-                "Doe",            // last-name
-                gender_t::female, // gender
-                28,               // age
-                2));              // id
-ps.push_back (std::move (jane_p)); // assumes ownership
-  
- -

For more information on the non-copying modifier functions refer to - Section - 2.8, "Mapping for Local Elements and Attributes" in the C++/Tree Mapping - User Manual. The above application produces the following output:

- -
-<?xml version="1.0" ?>
-<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-        xsi:noNamespaceSchemaLocation="people.xsd">
-
-  <person id="1">
-    <first-name>John</first-name>
-    <last-name>Doe</last-name>
-    <gender>male</gender>
-    <age>32</age>
-  </person>
-
-  <person id="2">
-    <first-name>Jane</first-name>
-    <middle-name>Mary</middle-name>
-    <last-name>Doe</last-name>
-    <gender>female</gender>
-    <age>28</age>
-  </person>
-
-</people>
-  
- -

4.5 Mapping for the Built-in XML Schema Types

- -

Our person record vocabulary uses several built-in XML Schema - types: string, short, and - unsignedInt. Until now we haven't talked about - the mapping of built-in XML Schema types to C++ types and how - to work with them. This section provides an overview - of the built-in types. For more detailed information refer - to Section - 2.5, "Mapping for Built-in Data Types" in the C++/Tree Mapping - User Manual.

- -

In XML Schema, built-in types are defined in the XML Schema namespace. - By default, the C++/Tree mapping maps this namespace to C++ - namespace xml_schema (this mapping can be altered - with the --namespace-map option). The following table - summarizes the mapping of XML Schema built-in types to C++ types:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XML Schema typeAlias in the xml_schema namespaceC++ type
fixed-length integral types
bytebytesigned char
unsignedByteunsigned_byteunsigned char
shortshort_short
unsignedShortunsigned_shortunsigned short
intint_int
unsignedIntunsigned_intunsigned int
longlong_long long
unsignedLongunsigned_longunsigned long long
arbitrary-length integral types
integerintegerlong long
nonPositiveIntegernon_positive_integerlong long
nonNegativeIntegernon_negative_integerunsigned long long
positiveIntegerpositive_integerunsigned long long
negativeIntegernegative_integerlong long
boolean types
booleanbooleanbool
fixed-precision floating-point types
floatfloat_float
doubledouble_double
arbitrary-precision floating-point types
decimaldecimaldouble
string types
stringstringtype derived from std::basic_string
normalizedStringnormalized_stringtype derived from string
tokentokentype derived from normalized_string
Namenametype derived from token
NMTOKENnmtokentype derived from token
NMTOKENSnmtokenstype derived from sequence<nmtoken>
NCNamencnametype derived from name
languagelanguagetype derived from token
qualified name
QNameqnamexml_schema::qname
ID/IDREF types
IDidtype derived from ncname
IDREFidreftype derived from ncname
IDREFSidrefstype derived from sequence<idref>
URI types
anyURIuritype derived from std::basic_string
binary types
base64Binarybase64_binaryxml_schema::base64_binary
hexBinaryhex_binaryxml_schema::hex_binary
date/time types
datedatexml_schema::date
dateTimedate_timexml_schema::date_time
durationdurationxml_schema::duration
gDaygdayxml_schema::gday
gMonthgmonthxml_schema::gmonth
gMonthDaygmonth_dayxml_schema::gmonth_day
gYeargyearxml_schema::gyear
gYearMonthgyear_monthxml_schema::gyear_month
timetimexml_schema::time
entity types
ENTITYentitytype derived from name
ENTITIESentitiestype derived from sequence<entity>
- -

As you can see from the table above a number of built-in - XML Schema types are mapped to fundamental C++ types such - as int or bool. All string-based - XML Schema types are mapped to C++ types that are derived - from either std::string or - std::wstring, depending on the character - type selected. For access and modification purposes these - types can be treated as std::string. A number - of built-in types, such as qname, the binary - types, and the date/time types do not have suitable - fundamental or standard C++ types to map to. As a result, - these types are implemented from scratch in the XSD runtime. - For more information on their interfaces refer to - Section - 2.5, "Mapping for Built-in Data Types" in the C++/Tree Mapping - User Manual.

- - - - - -

5 Parsing

- -

We have already seen how to parse XML to an object model in this guide - before. In this chapter we will discuss the parsing topic in more - detail.

- -

By default, the C++/Tree mapping provides a total of 14 overloaded - parsing functions. They differ in the input methods used to - read XML as well as the error reporting mechanisms. It is also possible - to generate types for root elements instead of parsing and serialization - functions. This may be useful if your XML vocabulary has multiple - root elements. For more information on element types refer to - Section - 2.9, "Mapping for Global Elements" in the C++/Tree Mapping User - Manual.

- - -

In this section we will discuss the most commonly used versions of - the parsing functions. For a comprehensive description of parsing - refer to Chapter - 3, "Parsing" in the C++/Tree Mapping User Manual. For the people - global element from our person record vocabulary, we will concentrate - on the following three parsing functions:

- -
-std::[auto|unique]_ptr<people_t>
-people (const std::string& uri,
-	xml_schema::flags f = 0,
-	const xml_schema::properties& p = xml_schema::properties ());
-
-std::[auto|unique]_ptr<people_t>
-people (std::istream& is,
-        xml_schema::flags f = 0,
-        const xml_schema::properties& p = xml_schema::properties ());
-
-std::[auto|unique]_ptr<people_t>
-people (std::istream& is,
-        const std::string& resource_id,
-        xml_schema::flags f = 0,
-        const xml_schema::properties& p = ::xml_schema::properties ());
-  
- -

The first function parses a local file or a URI. We have already - used this parsing function in the previous chapters. The second - and third functions read XML from a standard input stream. The - last function also requires a resource id. This id is used to - identify the XML document being parser in diagnostics messages - as well as to resolve relative paths to other documents (for example, - schemas) that might be referenced from the XML document.

- -

The last two arguments to all three parsing functions are parsing - flags and properties. The flags argument provides a number of ways - to fine-tune the parsing process. The properties argument allows - to pass additional information to the parsing functions. We will - use these two arguments in Section 5.1, "XML Schema - Validation and Searching" below. All three functions return - the object model as either std::auto_ptr (C++98) or - std::unique_ptr (C++11), depending on the C++ standard - selected (--std XSD compiler option). The following - example shows how we can use the above parsing functions:

- -
-using std::auto_ptr;
-
-// Parse a local file or URI.
-//
-auto_ptr<people_t> p1 (people ("people.xml"));
-auto_ptr<people_t> p2 (people ("http://example.com/people.xml"));
-
-// Parse a local file via ifstream.
-//
-std::ifstream ifs ("people.xml");
-auto_ptr<people_t> p3 (people (ifs, "people.xml"));
-
-// Parse an XML string.
-//
-std::string str ("..."); // XML in a string.
-std::istringstream iss (str);
-auto_ptr<people_t> p4 (people (iss));
-  
- - -

5.1 XML Schema Validation and Searching

- -

The C++/Tree mapping relies on the underlying Xerces-C++ XML - parser for full XML document validation. The XML Schema - validation is enabled by default and can be disabled by - passing the xml_schema::flags::dont_validate - flag to the parsing functions, for example:

- -
-auto_ptr<people_t> p (
-  people ("people.xml", xml_schema::flags::dont_validate));
-  
- -

Even when XML Schema validation is disabled, the generated - code still performs a number of checks to prevent - construction of an inconsistent object model (for example, an - object model with missing required attributes or elements).

- -

When XML Schema validation is enabled, the XML parser needs - to locate a schema to validate against. There are several - methods to provide the schema location information to the - parser. The easiest and most commonly used method is to - specify schema locations in the XML document itself - with the schemaLocation or - noNamespaceSchemaLocation attributes, for example:

- -
-<?xml version="1.0" ?>
-<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-        xsi:noNamespaceSchemaLocation="people.xsd"
-        xsi:schemaLocation="http://www.w3.org/XML/1998/namespace xml.xsd">
-  
- -

As you might have noticed, we used this method in all the sample XML - documents presented in this guide up until now. Note that the - schema locations specified with these two attributes are relative - to the document's path unless they are absolute URIs (that is - start with http://, file://, etc.). - In particular, if you specify just file names as your schema - locations, as we did above, then the schemas should reside in - the same directory as the XML document itself.

- -

Another method of providing the schema location information - is via the xml_schema::properties argument, as - shown in the following example:

- -
-xml_schema::properties props;
-props.no_namespace_schema_location ("people.xsd");
-props.schema_location ("http://www.w3.org/XML/1998/namespace", "xml.xsd");
-
-auto_ptr<people_t> p (people ("people.xml", 0, props));
-  
- -

The schema locations provided with this method overrides - those specified in the XML document. As with the previous - method, the schema locations specified this way are - relative to the document's path unless they are absolute URIs. - In particular, if you want to use local schemas that are - not related to the document being parsed, then you will - need to use the file:// URI. The following - example shows how to use schemas that reside in the current - working directory:

- -
-#include <unistd.h> // getcwd
-#include <limits.h> // PATH_MAX
-
-char cwd[PATH_MAX];
-if (getcwd (cwd, PATH_MAX) == 0)
-{
-  // Buffer too small?
-}
-
-xml_schema::properties props;
-
-props.no_namespace_schema_location (
-  "file:///" + std::string (cwd) + "/people.xsd");
-
-props.schema_location (
-  "http://www.w3.org/XML/1998/namespace",
-  "file:///" + std::string (cwd) + "/xml.xsd");
-
-auto_ptr<people_t> p (people ("people.xml", 0, props));
-  
- -

A third method is the most useful if you are planning to parse - several XML documents of the same vocabulary. In that case - it may be beneficial to pre-parse and cache the schemas in - the XML parser which can then be used to parse all documents - without re-parsing the schemas. For more information on - this method refer to the caching example in the - examples/cxx/tree/ directory of the XSD - distribution. It is also possible to convert the schemas into - a pre-compiled binary representation and embed this representation - directly into the application executable. With this approach your - application can perform XML Schema validation without depending on - any external schema files. For more information on how to achieve - this refer to the embedded example in the - examples/cxx/tree/ directory of the XSD distribution.

- -

When the XML parser cannot locate a schema for the - XML document, the validation fails and XML document - elements and attributes for which schema definitions could - not be located are reported in the diagnostics. For - example, if we remove the noNamespaceSchemaLocation - attribute in people.xml from the previous chapter, - then we will get the following diagnostics if we try to parse - this file with validation enabled:

- -
-people.xml:2:63 error: no declaration found for element 'people'
-people.xml:4:18 error: no declaration found for element 'person'
-people.xml:4:18 error: attribute 'id' is not declared for element 'person'
-people.xml:5:17 error: no declaration found for element 'first-name'
-people.xml:6:18 error: no declaration found for element 'middle-name'
-people.xml:7:16 error: no declaration found for element 'last-name'
-people.xml:8:13 error: no declaration found for element 'gender'
-people.xml:9:10 error: no declaration found for element 'age'
-  
- -

5.2 Error Handling

- -

The parsing functions offer a number of ways to handle error conditions - with the C++ exceptions being the most commonly used mechanism. All - C++/Tree exceptions derive from common base xml_schema::exception - which in turn derives from std::exception. The easiest - way to uniformly handle all possible C++/Tree exceptions and print - detailed information about the error is to catch and print - xml_schema::exception, as shown in the following - example:

- -
-try
-{
-  auto_ptr<people_t> p (people ("people.xml"));
-}
-catch (const xml_schema::exception& e)
-{
-  cerr << e << endl;
-}
-  
- -

Each individual C++/Tree exception also allows you to obtain - error details programmatically. For example, the - xml_schema::parsing exception is thrown when - the XML parsing and validation in the underlying XML parser - fails. It encapsulates various diagnostics information - such as the file name, line and column numbers, as well as the - error or warning message for each entry. For more information - about this and other exceptions that can be thrown during - parsing, refer to - Section - 3.3, "Error Handling" in the C++/Tree Mapping - User Manual.

- -

Note that if you are parsing std::istream on which - exceptions are not enabled, then you will need to check the - stream state after the call to the parsing function in order - to detect any possible stream failures, for example:

- -
-std::ifstream ifs ("people.xml");
-
-if (ifs.fail ())
-{
-  cerr << "people.xml: unable to open" << endl;
-  return 1;
-}
-
-auto_ptr<people_t> p (people (ifs, "people.xml"));
-
-if (ifs.fail ())
-{
-  cerr << "people.xml: read error" << endl;
-  return 1;
-}
-  
- -

The above example can be rewritten to use exceptions as - shown below:

- -
-try
-{
-  std::ifstream ifs;
-  ifs.exceptions (std::ifstream::badbit | std::ifstream::failbit);
-  ifs.open ("people.xml");
-
-  auto_ptr<people_t> p (people (ifs, "people.xml"));
-}
-catch (const std::ifstream::failure&)
-{
-  cerr << "people.xml: unable to open or read error" << endl;
-  return 1;
-}
-  
- - - - - -

6 Serialization

- -

We have already seen how to serialize an object model back to XML - in this guide before. In this chapter we will discuss the - serialization topic in more detail.

- -

By default, the C++/Tree mapping provides a total of 8 overloaded - serialization functions. They differ in the output methods used to write - XML as well as the error reporting mechanisms. It is also possible to - generate types for root elements instead of parsing and serialization - functions. This may be useful if your XML vocabulary has multiple - root elements. For more information on element types refer to - Section - 2.9, "Mapping for Global Elements" in the C++/Tree Mapping User - Manual.

- - -

In this section we will discuss the most commonly - used version of serialization functions. For a comprehensive description - of serialization refer to - Chapter - 4, "Serialization" in the C++/Tree Mapping User Manual. For the - people global element from our person record vocabulary, - we will concentrate on the following serialization function:

- -
-void
-people (std::ostream& os,
-        const people_t& x,
-        const xml_schema::namespace_infomap& map =
-          xml_schema::namespace_infomap (),
-        const std::string& encoding = "UTF-8",
-        xml_schema::flags f = 0);
-  
- -

This function serializes the object model passed as the second - argument to the standard output stream passed as the first - argument. The third argument is a namespace information map - which we will discuss in more detail in the next section. - The fourth argument is a character encoding that the resulting - XML document should be in. Possible valid values for this - argument are "US-ASCII", "ISO8859-1", "UTF-8", "UTF-16BE", - "UTF-16LE", "UCS-4BE", and "UCS-4LE". Finally, the flags - argument allows fine-tuning of the serialization process. - The following example shows how we can use the above serialization - function:

- -
-people_t& p = ...
-
-xml_schema::namespace_infomap map;
-map[""].schema = "people.xsd";
-
-// Serialize to stdout.
-//
-people (std::cout, p, map);
-
-// Serialize to a file.
-//
-std::ofstream ofs ("people.xml");
-people (ofs, p, map);
-
-// Serialize to a string.
-//
-std::ostringstream oss;
-people (oss, p, map);
-std::string xml (oss.str ());
-  
- - -

6.1 Namespace and Schema Information

- -

While XML serialization can be done just from the object - model alone, it is often desirable to assign meaningful - prefixes to XML namespaces used in the vocabulary as - well as to provide the schema location information. - This is accomplished by passing the namespace information - map to the serialization function. The key in this map is - a namespace prefix that should be assigned to an XML namespace - specified in the name variable of the - map value. You can also assign an optional schema location for - this namespace in the schema variable. Based - on each key-value entry in this map, the serialization - function adds two attributes to the resulting XML document: - the namespace-prefix mapping attribute and schema location - attribute. The empty prefix indicates that the namespace - should be mapped without a prefix. For example, the following - map:

- -
-xml_schema::namespace_infomap map;
-
-map[""].name = "http://www.example.com/example";
-map[""].schema = "example.xsd";
-
-map["x"].name = "http://www.w3.org/XML/1998/namespace";
-map["x"].schema = "xml.xsd";
-  
- -

Results in the following XML document:

- -
-<?xml version="1.0" ?>
-<example
-  xmlns="http://www.example.com/example"
-  xmlns:x="http://www.w3.org/XML/1998/namespace"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://www.example.com/example example.xsd
-                      http://www.w3.org/XML/1998/namespace xml.xsd">
-  
- -

The empty namespace indicates that the vocabulary has no target - namespace. For example, the following map results in only the - noNamespaceSchemaLocation attribute being added:

- -
-xml_schema::namespace_infomap map;
-
-map[""].name = "";
-map[""].schema = "example.xsd";
-  
- -

6.2 Error Handling

- -

Similar to the parsing functions, the serialization functions offer a - number of ways to handle error conditions with the C++ exceptions being - the most commonly used mechanisms. As with parsing, the easiest way to - uniformly handle all possible serialization exceptions and print - detailed information about the error is to catch and print - xml_schema::exception:

- -
-try
-{
-  people_t& p = ...
-
-  xml_schema::namespace_infomap map;
-  map[""].schema = "people.xsd";
-
-  people (std::cout, p, map));
-}
-catch (const xml_schema::exception& e)
-{
-  cerr << e << endl;
-}
-  
- -

The most commonly encountered serialization exception is - xml_schema::serialization. It is thrown - when the XML serialization in the underlying XML writer - fails. It encapsulates various diagnostics information - such as the file name, line and column numbers, as well as the - error or warning message for each entry. For more information - about this and other exceptions that can be thrown during - serialization, refer to - Section - 4.4, "Error Handling" in the C++/Tree Mapping - User Manual.

- -

Note that if you are serializing to std::ostream on - which exceptions are not enabled, then you will need to check the - stream state after the call to the serialization function in order - to detect any possible stream failures, for example:

- -
-std::ofstream ofs ("people.xml");
-
-if (ofs.fail ())
-{
-  cerr << "people.xml: unable to open" << endl;
-  return 1;
-}
-
-people (ofs, p, map));
-
-if (ofs.fail ())
-{
-  cerr << "people.xml: write error" << endl;
-  return 1;
-}
-  
- -

The above example can be rewritten to use exceptions as - shown below:

- -
-try
-{
-  std::ofstream ofs;
-  ofs.exceptions (std::ofstream::badbit | std::ofstream::failbit);
-  ofs.open ("people.xml");
-
-  people (ofs, p, map));
-}
-catch (const std::ofstream::failure&)
-{
-  cerr << "people.xml: unable to open or write error" << endl;
-  return 1;
-}
-  
- -
-
- - - diff --git a/doc/cxx/tree/guide/makefile b/doc/cxx/tree/guide/makefile deleted file mode 100644 index 3b95fff..0000000 --- a/doc/cxx/tree/guide/makefile +++ /dev/null @@ -1,53 +0,0 @@ -# file : doc/cxx/tree/guide/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -default := $(out_base)/ -install := $(out_base)/.install -dist := $(out_base)/.dist -dist-win := $(out_base)/.dist-win -clean := $(out_base)/.clean - -# Build. -# -$(default): $(out_base)/cxx-tree-guide.ps $(out_base)/cxx-tree-guide.pdf - - -$(out_base)/cxx-tree-guide.ps: $(src_base)/index.xhtml \ - $(src_base)/guide.html2ps \ - | $(out_base)/. - $(call message,html2ps $<,html2ps -f $(src_base)/guide.html2ps -o $@ $<) - -$(out_base)/cxx-tree-guide.pdf: $(out_base)/cxx-tree-guide.ps | $(out_base)/. - $(call message,ps2pdf $<,ps2pdf14 $< $@) - -# Install & Dist. -# -$(install): path := $(subst $(src_root)/doc/,,$(src_base)) -$(dist): path := $(subst $(src_root)/,,$(src_base)) - -$(install): $(out_base)/cxx-tree-guide.ps $(out_base)/cxx-tree-guide.pdf - $(call install-data,$(src_base)/index.xhtml,$(install_doc_dir)/xsd/$(path)/index.xhtml) - $(call install-data,$(out_base)/cxx-tree-guide.ps,$(install_doc_dir)/xsd/$(path)/cxx-tree-guide.ps) - $(call install-data,$(out_base)/cxx-tree-guide.pdf,$(install_doc_dir)/xsd/$(path)/cxx-tree-guide.pdf) - -$(dist): $(out_base)/cxx-tree-guide.ps $(out_base)/cxx-tree-guide.pdf - $(call install-data,$(src_base)/index.xhtml,$(dist_prefix)/$(path)/index.xhtml) - $(call install-data,$(out_base)/cxx-tree-guide.ps,$(dist_prefix)/$(path)/cxx-tree-guide.ps) - $(call install-data,$(out_base)/cxx-tree-guide.pdf,$(dist_prefix)/$(path)/cxx-tree-guide.pdf) - -$(dist-win): $(dist) - - -# Clean -# -$(clean): -ifneq ($(xsd_clean_gen),n) - $(call message,rm $$1,rm -f $$1,$(out_base)/cxx-tree-guide.ps) - $(call message,rm $$1,rm -f $$1,$(out_base)/cxx-tree-guide.pdf) -endif - -# How to. -# -$(call include,$(bld_root)/install.make) diff --git a/doc/cxx/tree/makefile b/doc/cxx/tree/makefile deleted file mode 100644 index deb254c..0000000 --- a/doc/cxx/tree/makefile +++ /dev/null @@ -1,40 +0,0 @@ -# file : doc/cxx/tree/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make - -docs := guide manual - -default := $(out_base)/ -install := $(out_base)/.install -dist := $(out_base)/.dist -dist-win := $(out_base)/.dist-win -clean := $(out_base)/.clean - -# Build. -# -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(docs))) - -# Install & Dist. -# -dist-common := $(out_base)/.dist-common - -$(install): path := $(subst $(src_root)/doc/,,$(src_base)) -$(dist-common): path := $(subst $(src_root)/,,$(src_base)) - -$(install): $(addprefix $(out_base)/,$(addsuffix /.install,$(docs))) - $(call install-dir,$(src_base)/reference,$(install_doc_dir)/xsd/$(path)/reference) - -$(dist-common): - $(call install-dir,$(src_base)/reference,$(dist_prefix)/$(path)/reference) - -$(dist): $(dist-common) $(addprefix $(out_base)/,$(addsuffix /.dist,$(docs))) -$(dist-win): $(dist-common) $(addprefix $(out_base)/,$(addsuffix /.dist-win,$(docs))) - -# Clean. -# -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(docs))) - -$(call include,$(bld_root)/install.make) - -$(foreach m,$(docs),$(call import,$(src_base)/$m/makefile)) diff --git a/doc/cxx/tree/manual/index.xhtml b/doc/cxx/tree/manual/index.xhtml deleted file mode 100644 index 550c07e..0000000 --- a/doc/cxx/tree/manual/index.xhtml +++ /dev/null @@ -1,6822 +0,0 @@ - - - - - - C++/Tree Mapping User Manual - - - - - - - - - - - - - - -
-
- -
- -
-
C++/Tree Mapping User Manual
- -

Copyright © 2009-2020 Code Synthesis Tools CC.

- -

Permission is granted to copy, distribute and/or modify this - document under the terms of the - GNU Free - Documentation License, version 1.2; with no Invariant Sections, - no Front-Cover Texts and no Back-Cover Texts. -

- -

This document is available in the following formats: - XHTML, - PDF, and - PostScript.

-
- -

Table of Contents

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Preface - - - -
About This Document
More Information
-
1Introduction
2C++/Tree Mapping - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2.1Preliminary Information - - - - - - -
2.1.1C++ Standard
2.1.2Identifiers
2.1.3Character Type and Encoding
2.1.4XML Schema Namespace
2.1.5Anonymous Types
-
2.2Error Handling - - -
2.2.1xml_schema::duplicate_id
-
2.3Mapping for import and include - - - - -
2.3.1Import
2.3.2Inclusion with Target Namespace
2.3.3Inclusion without Target Namespace
-
2.4Mapping for Namespaces
2.5Mapping for Built-in Data Types - - - - - - - - - - - - - - - - - -
2.5.1Inheritance from Built-in Data Types
2.5.2Mapping for anyType
2.5.3Mapping for anySimpleType
2.5.4Mapping for QName
2.5.5Mapping for IDREF
2.5.6Mapping for base64Binary and hexBinary
2.5.7Time Zone Representation
2.5.8Mapping for date
2.5.9Mapping for dateTime
2.5.10Mapping for duration
2.5.11Mapping for gDay
2.5.12Mapping for gMonth
2.5.13Mapping for gMonthDay
2.5.14Mapping for gYear
2.5.15Mapping for gYearMonth
2.5.16Mapping for time
-
2.6Mapping for Simple Types - - - - - -
2.6.1Mapping for Derivation by Restriction
2.6.2Mapping for Enumerations
2.6.3Mapping for Derivation by List
2.6.4Mapping for Derivation by Union
-
2.7Mapping for Complex Types - - - -
2.7.1Mapping for Derivation by Extension
2.7.2Mapping for Derivation by Restriction
-
2.8Mapping for Local Elements and Attributes - - - - - -
2.8.1Mapping for Members with the One Cardinality Class
2.8.2Mapping for Members with the Optional Cardinality Class
2.8.3Mapping for Members with the Sequence Cardinality Class
2.8.4Element Order
-
2.9Mapping for Global Elements - - - -
2.9.1Element Types
2.9.2Element Map
-
2.10Mapping for Global Attributes
2.11Mapping for xsi:type and Substitution Groups
2.12Mapping for any and anyAttribute - - - - - - -
2.12.1Mapping for any with the One Cardinality Class
2.12.2Mapping for any with the Optional Cardinality Class
2.12.3Mapping for any with the Sequence Cardinality Class
2.12.4Element Wildcard Order
2.12.5Mapping for anyAttribute
-
2.13Mapping for Mixed Content Models
-
3Parsing - - - - - - - - - - - - - - - - - - - - - - -
3.1Initializing the Xerces-C++ Runtime
3.2Flags and Properties
3.3Error Handling - - - - - - - - - - -
3.3.1xml_schema::parsing
3.3.2xml_schema::expected_element
3.3.3xml_schema::unexpected_element
3.3.4xml_schema::expected_attribute
3.3.5xml_schema::unexpected_enumerator
3.3.6xml_schema::expected_text_content
3.3.7xml_schema::no_type_info
3.3.8xml_schema::not_derived
3.3.9xml_schema::not_prefix_mapping
-
3.4Reading from a Local File or URI
3.5Reading from std::istream
3.6Reading from xercesc::InputSource
3.7Reading from DOM
-
4Serialization - - - - - - - - - - - - - - - - - - - - - - -
4.1Initializing the Xerces-C++ Runtime
4.2Namespace Infomap and Character Encoding
4.3Flags
4.4Error Handling - - - - -
4.4.1xml_schema::serialization
4.4.2xml_schema::unexpected_element
4.4.3xml_schema::no_type_info
-
4.5Serializing to std::ostream
4.6Serializing to xercesc::XMLFormatTarget
4.7Serializing to DOM
-
5Additional Functionality - - - - - - - -
5.1DOM Association
5.2Binary Serialization
-
Appendix A — Default and Fixed Values
-
- -

Preface

- -

About This Document

- -

This document describes the mapping of W3C XML Schema - to the C++ programming language as implemented by - CodeSynthesis - XSD - an XML Schema to C++ data binding compiler. The mapping - represents information stored in XML instance documents as a - statically-typed, tree-like in-memory data structure and is - called C++/Tree. -

- -

Revision 4.1.0
- This revision of the manual describes the C++/Tree - mapping as implemented by CodeSynthesis XSD version 4.1.0. -

- -

This document is available in the following formats: - XHTML, - PDF, and - PostScript.

- -

More Information

- -

Beyond this manual, you may also find the following sources of - information useful:

- - - - -

1 Introduction

- -

C++/Tree is a W3C XML Schema to C++ mapping that represents the - data stored in XML as a statically-typed, vocabulary-specific - object model. Based on a formal description of an XML vocabulary - (schema), the C++/Tree mapping produces a tree-like data structure - suitable for in-memory processing as well as XML parsing and - serialization code.

- -

A typical application that processes XML documents usually - performs the following three steps: it first reads (parses) an XML - instance document to an object model, it then performs - some useful computations on that model which may involve - modification of the model, and finally it may write (serialize) - the modified object model back to XML. -

- -

The C++/Tree mapping consists of C++ types that represent the - given vocabulary (Chapter 2, "C++/Tree Mapping"), - a set of parsing functions that convert XML documents to - a tree-like in-memory data structure (Chapter 3, - "Parsing"), and a set of serialization functions that convert - the object model back to XML (Chapter 4, - "Serialization"). Furthermore, the mapping provides a number - of additional features, such as DOM association and binary - serialization, that can be useful in some applications - (Chapter 5, "Additional Functionality"). -

- - - - - -

2 C++/Tree Mapping

- -

2.1 Preliminary Information

- -

2.1.1 C++ Standard

- -

The C++/Tree mapping provides support for ISO/IEC C++ 1998/2003 (C++98) - and ISO/IEC C++ 2011 (C++11). To select the C++ standard for the - generated code we use the --std XSD compiler command - line option. While the majority of the examples in this manual use - C++98, support for the new functionality and library components - introduced in C++11 are discussed throughout the document.

- -

2.1.2 Identifiers

- -

XML Schema names may happen to be reserved C++ keywords or contain - characters that are illegal in C++ identifiers. To avoid C++ compilation - problems, such names are changed (escaped) when mapped to C++. If an - XML Schema name is a C++ keyword, the "_" suffix is added to it. All - character of an XML Schema name that are not allowed in C++ identifiers - are replaced with "_". -

- -

For example, XML Schema name try will be mapped to - C++ identifier try_. Similarly, XML Schema name - strange.na-me will be mapped to C++ identifier - strange_na_me. -

- -

Furthermore, conflicts between type names and function names in the - same scope are resolved using name escaping. Such conflicts include - both a global element (which is mapped to a set of parsing and/or - serialization functions or element types, see Section - 2.9, "Mapping for Global Elements") and a global type sharing the - same name as well as a local element or attribute inside a type having - the same name as the type itself.

- -

For example, if we had a global type catalog - and a global element with the same name then the type would be - mapped to a C++ class with name catalog while the - parsing functions corresponding to the global element would have - their names escaped as catalog_. -

- -

By default the mapping uses the so-called K&R (Kernighan and - Ritchie) identifier naming convention which is also used throughout - this manual. In this convention both type and function names are in - lower case and words are separated by underscores. If your application - code or schemas use a different notation, you may want to change the - naming convention used by the mapping for consistency. - The compiler supports a set of widely-used naming conventions - that you can select with the --type-naming and - --function-naming options. You can also further - refine one of the predefined conventions or create a completely - custom naming scheme by using the --*-regex options. - For more detailed information on these options refer to the NAMING - CONVENTION section in the XSD - Compiler Command Line Manual.

- -

2.1.3 Character Type and Encoding

- -

The code that implements the mapping, depending on the - --char-type option, is generated using either - char or wchar_t as the character - type. In this document code samples use symbol C - to refer to the character type you have selected when translating - your schemas, for example std::basic_string<C>. -

- -

Another aspect of the mapping that depends on the character type - is character encoding. For the char character type - the default encoding is UTF-8. Other supported encodings are - ISO-8859-1, Xerces-C++ Local Code Page (LPC), as well as - custom encodings and can be selected with the - --char-encoding command line option.

- -

For the wchar_t character type the encoding is - automatically selected between UTF-16 and UTF-32/UCS-4 depending - on the size of the wchar_t type. On some platforms - (for example, Windows with Visual C++ and AIX with IBM XL C++) - wchar_t is 2 bytes long. For these platforms the - encoding is UTF-16. On other platforms wchar_t is 4 bytes - long and UTF-32/UCS-4 is used.

- -

2.1.4 XML Schema Namespace

- -

The mapping relies on some predefined types, classes, and functions - that are logically defined in the XML Schema namespace reserved for - the XML Schema language (http://www.w3.org/2001/XMLSchema). - By default, this namespace is mapped to C++ namespace - xml_schema. It is automatically accessible - from a C++ compilation unit that includes a header file generated - from an XML Schema definition. -

- -

Note that, if desired, the default mapping of this namespace can be - changed as described in Section 2.4, "Mapping for - Namespaces". -

- - -

2.1.5 Anonymous Types

- -

For the purpose of code generation, anonymous types defined in - XML Schema are automatically assigned names that are derived - from enclosing attributes and elements. Otherwise, such types - follows standard mapping rules for simple and complex type - definitions (see Section 2.6, "Mapping for Simple Types" - and Section 2.7, "Mapping for Complex Types"). - For example, in the following schema fragment: -

- -
-<element name="object">
-  <complexType>
-    ...
-  </complexType>
-</element>
-  
- -

The anonymous type defined inside element object will - be given name object. The compiler has a number of - options that control the process of anonymous type naming. For more - information refer to the XSD - Compiler Command Line Manual.

- - -

2.2 Error Handling

- -

The mapping uses the C++ exception handling mechanism as a primary way - of reporting error conditions. All exceptions that are specified in - this mapping derive from xml_schema::exception which - itself is derived from std::exception: -

- -
-struct exception: virtual std::exception
-{
-  friend
-  std::basic_ostream<C>&
-  operator<< (std::basic_ostream<C>& os, const exception& e)
-  {
-    e.print (os);
-    return os;
-  }
-
-protected:
-  virtual void
-  print (std::basic_ostream<C>&) const = 0;
-};
-  
- -

The exception hierarchy supports "virtual" operator<< - which allows you to obtain diagnostics corresponding to the thrown - exception using the base exception interface. For example:

- -
-try
-{
-  ...
-}
-catch (const xml_schema::exception& e)
-{
-  cerr << e << endl;
-}
-  
- -

The following sub-sections describe exceptions thrown by the - types that constitute the object model. - Section 3.3, "Error Handling" of - Chapter 3, "Parsing" describes exceptions - and error handling mechanisms specific to the parsing functions. - Section 4.4, "Error Handling" of - Chapter 4, "Serialization" describes exceptions - and error handling mechanisms specific to the serialization functions. -

- - -

2.2.1 xml_schema::duplicate_id

- -
-struct duplicate_id: virtual exception
-{
-  duplicate_id (const std::basic_string<C>& id);
-
-  const std::basic_string<C>&
-  id () const;
-
-  virtual const char*
-  what () const throw ();
-};
-  
- -

The xml_schema::duplicate_id is thrown when - a conflicting instance of xml_schema::id (see - Section 2.5, "Mapping for Built-in Data Types") - is added to a tree. The offending ID value can be obtained using - the id function. -

- -

2.3 Mapping for import and include

- -

2.3.1 Import

- -

The XML Schema import element is mapped to the C++ - Preprocessor #include directive. The value of - the schemaLocation attribute is used to derive - the name of the header file that appears in the #include - directive. For instance: -

- -
-<import namespace="https://www.codesynthesis.com/test"
-        schemaLocation="test.xsd"/>
-  
- -

is mapped to:

- -
-#include "test.hxx"
-  
- -

Note that you will need to compile imported schemas separately - in order to produce corresponding header files.

- -

2.3.2 Inclusion with Target Namespace

- -

The XML Schema include element which refers to a schema - with a target namespace or appears in a schema without a target namespace - follows the same mapping rules as the import element, - see Section 2.3.1, "Import". -

- -

2.3.3 Inclusion without Target Namespace

- -

For the XML Schema include element which refers to a schema - without a target namespace and appears in a schema with a target - namespace (such inclusion sometimes called "chameleon inclusion"), - declarations and definitions from the included schema are generated - in-line in the namespace of the including schema as if they were - declared and defined there verbatim. For example, consider the - following two schemas: -

- -
-<-- common.xsd -->
-<schema>
-  <complexType name="type">
-  ...
-  </complexType>
-</schema>
-
-<-- test.xsd -->
-<schema targetNamespace="https://www.codesynthesis.com/test">
-  <include schemaLocation="common.xsd"/>
-</schema>
-  
- -

The fragment of interest from the generated header file for - text.xsd would look like this:

- -
-// test.hxx
-namespace test
-{
-  class type
-  {
-    ...
-  };
-}
-  
- -

2.4 Mapping for Namespaces

- -

An XML Schema namespace is mapped to one or more nested C++ - namespaces. XML Schema namespaces are identified by URIs. - By default, a namespace URI is mapped to a sequence of - C++ namespace names by removing the protocol and host parts - and splitting the rest into a sequence of names with '/' - as the name separator. For instance: -

- -
-<schema targetNamespace="https://www.codesynthesis.com/system/test">
-  ...
-</schema>
-  
- -

is mapped to:

- -
-namespace system
-{
-  namespace test
-  {
-    ...
-  }
-}
-  
- -

The default mapping of namespace URIs to C++ namespace names can be - altered using the --namespace-map and - --namespace-regex options. See the - XSD - Compiler Command Line Manual for more information. -

- -

2.5 Mapping for Built-in Data Types

- -

The mapping of XML Schema built-in data types to C++ types is - summarized in the table below.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XML Schema typeAlias in the xml_schema namespaceC++ type
anyType and anySimpleType types
anyTypetypeSection 2.5.2, "Mapping for anyType"
anySimpleTypesimple_typeSection 2.5.3, "Mapping for anySimpleType"
fixed-length integral types
bytebytesigned char
unsignedByteunsigned_byteunsigned char
shortshort_short
unsignedShortunsigned_shortunsigned short
intint_int
unsignedIntunsigned_intunsigned int
longlong_long long
unsignedLongunsigned_longunsigned long long
arbitrary-length integral types
integerintegerlong long
nonPositiveIntegernon_positive_integerlong long
nonNegativeIntegernon_negative_integerunsigned long long
positiveIntegerpositive_integerunsigned long long
negativeIntegernegative_integerlong long
boolean types
booleanbooleanbool
fixed-precision floating-point types
floatfloat_float
doubledouble_double
arbitrary-precision floating-point types
decimaldecimaldouble
string types
stringstringtype derived from std::basic_string
normalizedStringnormalized_stringtype derived from string
tokentokentype derived from normalized_string
Namenametype derived from token
NMTOKENnmtokentype derived from token
NMTOKENSnmtokenstype derived from sequence<nmtoken>
NCNamencnametype derived from name
languagelanguagetype derived from token
qualified name
QNameqnameSection 2.5.4, "Mapping for QName"
ID/IDREF types
IDidtype derived from ncname
IDREFidrefSection 2.5.5, "Mapping for IDREF"
IDREFSidrefstype derived from sequence<idref>
URI types
anyURIuritype derived from std::basic_string
binary types
base64Binarybase64_binarySection 2.5.6, "Mapping for - base64Binary and hexBinary"
hexBinaryhex_binary
date/time types
datedateSection 2.5.8, "Mapping for - date"
dateTimedate_timeSection 2.5.9, "Mapping for - dateTime"
durationdurationSection 2.5.10, "Mapping for - duration"
gDaygdaySection 2.5.11, "Mapping for - gDay"
gMonthgmonthSection 2.5.12, "Mapping for - gMonth"
gMonthDaygmonth_daySection 2.5.13, "Mapping for - gMonthDay"
gYeargyearSection 2.5.14, "Mapping for - gYear"
gYearMonthgyear_monthSection 2.5.15, "Mapping for - gYearMonth"
timetimeSection 2.5.16, "Mapping for - time"
entity types
ENTITYentitytype derived from name
ENTITIESentitiestype derived from sequence<entity>
- -

All XML Schema built-in types are mapped to C++ classes that are - derived from the xml_schema::simple_type class except - where the mapping is to a fundamental C++ type.

- -

The sequence class template is defined in an - implementation-specific namespace. It conforms to the - sequence interface as defined by the ISO/ANSI Standard for - C++ (ISO/IEC 14882:1998, Section 23.1.1, "Sequences"). - Practically, this means that you can treat such a sequence - as if it was std::vector. One notable extension - to the standard interface that is available only for - sequences of non-fundamental C++ types is the addition of - the overloaded push_back and insert - member functions which instead of the constant reference - to the element type accept automatic pointer (std::auto_ptr - or std::unique_ptr, depending on the C++ standard - selected) to the element type. These functions assume ownership - of the pointed to object and reset the passed automatic pointer. -

- -

2.5.1 Inheritance from Built-in Data Types

- -

In cases where the mapping calls for an inheritance from a built-in - type which is mapped to a fundamental C++ type, a proxy type is - used instead of the fundamental C++ type (C++ does not allow - inheritance from fundamental types). For instance:

- -
-<simpleType name="my_int">
-  <restriction base="int"/>
-</simpleType>
-  
- -

is mapped to:

- -
-class my_int: public fundamental_base<int>
-{
-  ...
-};
-  
- -

The fundamental_base class template provides a close - emulation (though not exact) of a fundamental C++ type. - It is defined in an implementation-specific namespace and has the - following interface:

- -
-template <typename X>
-class fundamental_base: public simple_type
-{
-public:
-  fundamental_base ();
-  fundamental_base (X)
-  fundamental_base (const fundamental_base&)
-
-public:
-  fundamental_base&
-  operator= (const X&);
-
-public:
-  operator const X & () const;
-  operator X& ();
-
-  template <typename Y>
-  operator Y () const;
-
-  template <typename Y>
-  operator Y ();
-};
-  
- -

2.5.2 Mapping for anyType

- -

The XML Schema anyType built-in data type is mapped to the - xml_schema::type C++ class:

- -
-class type
-{
-public:
-  virtual
-  ~type ();
-
-  type ();
-  type (const type&);
-
-  type&
-  operator= (const type&);
-
-  virtual type*
-  _clone () const;
-
-  // anyType DOM content.
-  //
-public:
-  typedef element_optional dom_content_optional;
-
-  const dom_content_optional&
-  dom_content () const;
-
-  dom_content_optional&
-  dom_content ();
-
-  void
-  dom_content (const xercesc::DOMElement&);
-
-  void
-  dom_content (xercesc::DOMElement*);
-
-  void
-  dom_content (const dom_content_optional&);
-
-  const xercesc::DOMDocument&
-  dom_content_document () const;
-
-  xercesc::DOMDocument&
-  dom_content_document ();
-
-  bool
-  null_content () const;
-
-  // DOM association.
-  //
-public:
-  const xercesc::DOMNode*
-  _node () const;
-
-  xercesc::DOMNode*
-  _node ();
-};
-  
- -

When xml_schema::type is used to create an instance - (as opposed to being a base of a derived type), it represents - the XML Schema anyType type. anyType - allows any attributes and any content in any order. In the - C++/Tree mapping this content can be represented as a DOM - fragment, similar to XML Schema wildcards (Section - 2.12, "Mapping for any and - anyAttribute").

- -

To enable automatic extraction of anyType content - during parsing, the --generate-any-type option must be - specified. Because the DOM API is used to access such content, the - Xerces-C++ runtime should be initialized by the application prior to - parsing and should remain initialized for the lifetime of objects - with the DOM content. For more information on the Xerces-C++ runtime - initialization see Section 3.1, "Initializing the - Xerces-C++ Runtime".

- -

The DOM content is stored as the optional DOM element container - and the DOM content accessors and modifiers presented above are - identical to those generated for an optional element wildcard. - Refer to Section 2.12.2, "Mapping for any - with the Optional Cardinality Class" for details on their - semantics.

- -

The dom_content_document() function returns the - DOM document used to store the raw XML content corresponding - to the anyType instance. It is equivalent to the - dom_document() function generated for types - with wildcards.

- -

The null_content() accessor is an optimization function - that allows us to check for the lack of content without actually - creating its empty representation, that is, empty DOM document for - anyType or empty string for anySimpleType - (see the following section for details on anySimpleType).

- -

For more information on DOM association refer to - Section 5.1, "DOM Association".

- -

2.5.3 Mapping for anySimpleType

- -

The XML Schema anySimpleType built-in data type is mapped - to the xml_schema::simple_type C++ class:

- -
-class simple_type: public type
-{
-public:
-  simple_type ();
-  simple_type (const C*);
-  simple_type (const std::basic_string<C>&);
-
-  simple_type (const simple_type&);
-
-  simple_type&
-  operator= (const simple_type&);
-
-  virtual simple_type*
-  _clone () const;
-
-  // anySimpleType text content.
-  //
-public:
-  const std::basic_string<C>&
-  text_content () const;
-
-  std::basic_string<C>&
-  text_content ();
-
-  void
-  text_content (const std::basic_string<C>&);
-};
-  
- -

When xml_schema::simple_type is used to create an instance - (as opposed to being a base of a derived type), it represents - the XML Schema anySimpleType type. anySimpleType - allows any simple content. In the C++/Tree mapping this content can - be represented as a string and accessed or modified with the - text_content() functions shown above.

- -

2.5.4 Mapping for QName

- -

The XML Schema QName built-in data type is mapped to the - xml_schema::qname C++ class:

- -
-class qname: public simple_type
-{
-public:
-  qname (const ncname&);
-  qname (const uri&, const ncname&);
-  qname (const qname&);
-
-public:
-  qname&
-  operator= (const qname&);
-
-public:
-  virtual qname*
-  _clone () const;
-
-public:
-  bool
-  qualified () const;
-
-  const uri&
-  namespace_ () const;
-
-  const ncname&
-  name () const;
-};
-  
- -

The qualified accessor function can be used to determine - if the name is qualified.

- -

2.5.5 Mapping for IDREF

- -

The XML Schema IDREF built-in data type is mapped to the - xml_schema::idref C++ class. This class implements the - smart pointer C++ idiom:

- -
-class idref: public ncname
-{
-public:
-  idref (const C* s);
-  idref (const C* s, std::size_t n);
-  idref (std::size_t n, C c);
-  idref (const std::basic_string<C>&);
-  idref (const std::basic_string<C>&,
-         std::size_t pos,
-         std::size_t n = npos);
-
-public:
-  idref (const idref&);
-
-public:
-  virtual idref*
-  _clone () const;
-
-public:
-  idref&
-  operator= (C c);
-
-  idref&
-  operator= (const C* s);
-
-  idref&
-  operator= (const std::basic_string<C>&)
-
-  idref&
-  operator= (const idref&);
-
-public:
-  const type*
-  operator-> () const;
-
-  type*
-  operator-> ();
-
-  const type&
-  operator* () const;
-
-  type&
-  operator* ();
-
-  const type*
-  get () const;
-
-  type*
-  get ();
-
-  // Conversion to bool.
-  //
-public:
-  typedef void (idref::*bool_convertible)();
-  operator bool_convertible () const;
-};
-  
- -

The object, idref instance refers to, is the immediate - container of the matching id instance. For example, - with the following instance document and schema: -

- - -
-<!-- test.xml -->
-<root>
-  <object id="obj-1" text="hello"/>
-  <reference>obj-1</reference>
-</root>
-
-<!-- test.xsd -->
-<schema>
-  <complexType name="object_type">
-    <attribute name="id" type="ID"/>
-    <attribute name="text" type="string"/>
-  </complexType>
-
-  <complexType name="root_type">
-    <sequence>
-      <element name="object" type="object_type"/>
-      <element name="reference" type="IDREF"/>
-    </sequence>
-  </complexType>
-
-  <element name="root" type="root_type"/>
-</schema>
-  
- -

The ref instance in the code below will refer to - an object of type object_type:

- -
-root_type& root = ...;
-xml_schema::idref& ref (root.reference ());
-object_type& obj (dynamic_cast<object_type&> (*ref));
-cout << obj.text () << endl;
-  
- -

The smart pointer interface of the idref class always - returns a pointer or reference to xml_schema::type. - This means that you will need to manually cast such pointer or - reference to its real (dynamic) type before you can use it (unless - all you need is the base interface provided by - xml_schema::type). As a special extension to the XML - Schema language, the mapping supports static typing of idref - references by employing the refType extension attribute. - The following example illustrates this mechanism: -

- -
-<!-- test.xsd -->
-<schema
-  xmlns:xse="https://www.codesynthesis.com/xmlns/xml-schema-extension">
-
-  ...
-
-      <element name="reference" type="IDREF" xse:refType="object_type"/>
-
-  ...
-
-</schema>
-  
- -

With this modification we do not need to do manual casting anymore: -

- -
-root_type& root = ...;
-root_type::reference_type& ref (root.reference ());
-object_type& obj (*ref);
-cout << ref->text () << endl;
-  
- - -

2.5.6 Mapping for base64Binary and - hexBinary

- -

The XML Schema base64Binary and hexBinary - built-in data types are mapped to the - xml_schema::base64_binary and - xml_schema::hex_binary C++ classes, respectively. The - base64_binary and hex_binary classes - support a simple buffer abstraction by inheriting from the - xml_schema::buffer class: -

- -
-class bounds: public virtual exception
-{
-public:
-  virtual const char*
-  what () const throw ();
-};
-
-class buffer
-{
-public:
-  typedef std::size_t size_t;
-
-public:
-  buffer (size_t size = 0);
-  buffer (size_t size, size_t capacity);
-  buffer (const void* data, size_t size);
-  buffer (const void* data, size_t size, size_t capacity);
-  buffer (void* data,
-          size_t size,
-          size_t capacity,
-          bool assume_ownership);
-
-public:
-  buffer (const buffer&);
-
-  buffer&
-  operator= (const buffer&);
-
-  void
-  swap (buffer&);
-
-public:
-  size_t
-  capacity () const;
-
-  bool
-  capacity (size_t);
-
-public:
-  size_t
-  size () const;
-
-  bool
-  size (size_t);
-
-public:
-  const char*
-  data () const;
-
-  char*
-  data ();
-
-  const char*
-  begin () const;
-
-  char*
-  begin ();
-
-  const char*
-  end () const;
-
-  char*
-  end ();
-};
-  
- -

The last overloaded constructor reuses an existing data buffer instead - of making a copy. If the assume_ownership argument is - true, the instance assumes ownership of the - memory block pointed to by the data argument and will - eventually release it by calling operator delete. The - capacity and size modifier functions return - true if the underlying buffer has moved. -

- -

The bounds exception is thrown if the constructor - arguments violate the (size <= capacity) - constraint.

- -

The base64_binary and hex_binary classes - support the buffer interface and perform automatic - decoding/encoding from/to the Base64 and Hex formats, respectively: -

- -
-class base64_binary: public simple_type, public buffer
-{
-public:
-  base64_binary (size_t size = 0);
-  base64_binary (size_t size, size_t capacity);
-  base64_binary (const void* data, size_t size);
-  base64_binary (const void* data, size_t size, size_t capacity);
-  base64_binary (void* data,
-                 size_t size,
-                 size_t capacity,
-                 bool assume_ownership);
-
-public:
-  base64_binary (const base64_binary&);
-
-  base64_binary&
-  operator= (const base64_binary&);
-
-  virtual base64_binary*
-  _clone () const;
-
-public:
-  std::basic_string<C>
-  encode () const;
-};
-  
- -
-class hex_binary: public simple_type, public buffer
-{
-public:
-  hex_binary (size_t size = 0);
-  hex_binary (size_t size, size_t capacity);
-  hex_binary (const void* data, size_t size);
-  hex_binary (const void* data, size_t size, size_t capacity);
-  hex_binary (void* data,
-              size_t size,
-              size_t capacity,
-              bool assume_ownership);
-
-public:
-  hex_binary (const hex_binary&);
-
-  hex_binary&
-  operator= (const hex_binary&);
-
-  virtual hex_binary*
-  _clone () const;
-
-public:
-  std::basic_string<C>
-  encode () const;
-};
-  
- - -

2.5.7 Time Zone Representation

- -

The date, dateTime, gDay, - gMonth, gMonthDay, gYear, - gYearMonth, and time XML Schema built-in - types all include an optional time zone component. The following - xml_schema::time_zone base class is used to represent - this information:

- -
-class time_zone
-{
-public:
-  time_zone ();
-  time_zone (short hours, short minutes);
-
-  bool
-  zone_present () const;
-
-  void
-  zone_reset ();
-
-  short
-  zone_hours () const;
-
-  void
-  zone_hours (short);
-
-  short
-  zone_minutes () const;
-
-  void
-  zone_minutes (short);
-};
-
-bool
-operator== (const time_zone&, const time_zone&);
-
-bool
-operator!= (const time_zone&, const time_zone&);
-  
- -

The zone_present() accessor function returns true - if the time zone is specified. The zone_reset() modifier - function resets the time zone object to the not specified - state. If the time zone offset is negative then both hours and - minutes components are represented as negative integers.

- - -

2.5.8 Mapping for date

- -

The XML Schema date built-in data type is mapped to the - xml_schema::date C++ class which represents a year, a day, - and a month with an optional time zone. Its interface is presented - below. For more information on the base xml_schema::time_zone - class refer to Section 2.5.7, "Time Zone - Representation".

- -
-class date: public simple_type, public time_zone
-{
-public:
-  date (int year, unsigned short month, unsigned short day);
-  date (int year, unsigned short month, unsigned short day,
-        short zone_hours, short zone_minutes);
-
-public:
-  date (const date&);
-
-  date&
-  operator= (const date&);
-
-  virtual date*
-  _clone () const;
-
-public:
-  int
-  year () const;
-
-  void
-  year (int);
-
-  unsigned short
-  month () const;
-
-  void
-  month (unsigned short);
-
-  unsigned short
-  day () const;
-
-  void
-  day (unsigned short);
-};
-
-bool
-operator== (const date&, const date&);
-
-bool
-operator!= (const date&, const date&);
-  
- -

2.5.9 Mapping for dateTime

- -

The XML Schema dateTime built-in data type is mapped to the - xml_schema::date_time C++ class which represents a year, a month, - a day, hours, minutes, and seconds with an optional time zone. Its interface - is presented below. For more information on the base - xml_schema::time_zone class refer to Section - 2.5.7, "Time Zone Representation".

- -
-class date_time: public simple_type, public time_zone
-{
-public:
-  date_time (int year, unsigned short month, unsigned short day,
-             unsigned short hours, unsigned short minutes,
-             double seconds);
-
-  date_time (int year, unsigned short month, unsigned short day,
-             unsigned short hours, unsigned short minutes,
-             double seconds, short zone_hours, short zone_minutes);
-public:
-  date_time (const date_time&);
-
-  date_time&
-  operator= (const date_time&);
-
-  virtual date_time*
-  _clone () const;
-
-public:
-  int
-  year () const;
-
-  void
-  year (int);
-
-  unsigned short
-  month () const;
-
-  void
-  month (unsigned short);
-
-  unsigned short
-  day () const;
-
-  void
-  day (unsigned short);
-
-  unsigned short
-  hours () const;
-
-  void
-  hours (unsigned short);
-
-  unsigned short
-  minutes () const;
-
-  void
-  minutes (unsigned short);
-
-  double
-  seconds () const;
-
-  void
-  seconds (double);
-};
-
-bool
-operator== (const date_time&, const date_time&);
-
-bool
-operator!= (const date_time&, const date_time&);
-  
- - -

2.5.10 Mapping for duration

- -

The XML Schema duration built-in data type is mapped to the - xml_schema::duration C++ class which represents a potentially - negative duration in the form of years, months, days, hours, minutes, - and seconds. Its interface is presented below.

- -
-class duration: public simple_type
-{
-public:
-  duration (bool negative,
-            unsigned int years, unsigned int months, unsigned int days,
-            unsigned int hours, unsigned int minutes, double seconds);
-public:
-  duration (const duration&);
-
-  duration&
-  operator= (const duration&);
-
-  virtual duration*
-  _clone () const;
-
-public:
-  bool
-  negative () const;
-
-  void
-  negative (bool);
-
-  unsigned int
-  years () const;
-
-  void
-  years (unsigned int);
-
-  unsigned int
-  months () const;
-
-  void
-  months (unsigned int);
-
-  unsigned int
-  days () const;
-
-  void
-  days (unsigned int);
-
-  unsigned int
-  hours () const;
-
-  void
-  hours (unsigned int);
-
-  unsigned int
-  minutes () const;
-
-  void
-  minutes (unsigned int);
-
-  double
-  seconds () const;
-
-  void
-  seconds (double);
-};
-
-bool
-operator== (const duration&, const duration&);
-
-bool
-operator!= (const duration&, const duration&);
-  
- - -

2.5.11 Mapping for gDay

- -

The XML Schema gDay built-in data type is mapped to the - xml_schema::gday C++ class which represents a day of the - month with an optional time zone. Its interface is presented below. - For more information on the base xml_schema::time_zone - class refer to Section 2.5.7, "Time Zone - Representation".

- -
-class gday: public simple_type, public time_zone
-{
-public:
-  explicit
-  gday (unsigned short day);
-  gday (unsigned short day, short zone_hours, short zone_minutes);
-
-public:
-  gday (const gday&);
-
-  gday&
-  operator= (const gday&);
-
-  virtual gday*
-  _clone () const;
-
-public:
-  unsigned short
-  day () const;
-
-  void
-  day (unsigned short);
-};
-
-bool
-operator== (const gday&, const gday&);
-
-bool
-operator!= (const gday&, const gday&);
-  
- - -

2.5.12 Mapping for gMonth

- -

The XML Schema gMonth built-in data type is mapped to the - xml_schema::gmonth C++ class which represents a month of the - year with an optional time zone. Its interface is presented below. - For more information on the base xml_schema::time_zone - class refer to Section 2.5.7, "Time Zone - Representation".

- -
-class gmonth: public simple_type, public time_zone
-{
-public:
-  explicit
-  gmonth (unsigned short month);
-  gmonth (unsigned short month,
-          short zone_hours, short zone_minutes);
-
-public:
-  gmonth (const gmonth&);
-
-  gmonth&
-  operator= (const gmonth&);
-
-  virtual gmonth*
-  _clone () const;
-
-public:
-  unsigned short
-  month () const;
-
-  void
-  month (unsigned short);
-};
-
-bool
-operator== (const gmonth&, const gmonth&);
-
-bool
-operator!= (const gmonth&, const gmonth&);
-  
- - -

2.5.13 Mapping for gMonthDay

- -

The XML Schema gMonthDay built-in data type is mapped to the - xml_schema::gmonth_day C++ class which represents a day and - a month of the year with an optional time zone. Its interface is presented - below. For more information on the base xml_schema::time_zone - class refer to Section 2.5.7, "Time Zone - Representation".

- -
-class gmonth_day: public simple_type, public time_zone
-{
-public:
-  gmonth_day (unsigned short month, unsigned short day);
-  gmonth_day (unsigned short month, unsigned short day,
-              short zone_hours, short zone_minutes);
-
-public:
-  gmonth_day (const gmonth_day&);
-
-  gmonth_day&
-  operator= (const gmonth_day&);
-
-  virtual gmonth_day*
-  _clone () const;
-
-public:
-  unsigned short
-  month () const;
-
-  void
-  month (unsigned short);
-
-  unsigned short
-  day () const;
-
-  void
-  day (unsigned short);
-};
-
-bool
-operator== (const gmonth_day&, const gmonth_day&);
-
-bool
-operator!= (const gmonth_day&, const gmonth_day&);
-  
- - -

2.5.14 Mapping for gYear

- -

The XML Schema gYear built-in data type is mapped to the - xml_schema::gyear C++ class which represents a year with - an optional time zone. Its interface is presented below. For more - information on the base xml_schema::time_zone class refer - to Section 2.5.7, "Time Zone Representation".

- -
-class gyear: public simple_type, public time_zone
-{
-public:
-  explicit
-  gyear (int year);
-  gyear (int year, short zone_hours, short zone_minutes);
-
-public:
-  gyear (const gyear&);
-
-  gyear&
-  operator= (const gyear&);
-
-  virtual gyear*
-  _clone () const;
-
-public:
-  int
-  year () const;
-
-  void
-  year (int);
-};
-
-bool
-operator== (const gyear&, const gyear&);
-
-bool
-operator!= (const gyear&, const gyear&);
-  
- - -

2.5.15 Mapping for gYearMonth

- -

The XML Schema gYearMonth built-in data type is mapped to - the xml_schema::gyear_month C++ class which represents - a year and a month with an optional time zone. Its interface is presented - below. For more information on the base xml_schema::time_zone - class refer to Section 2.5.7, "Time Zone - Representation".

- -
-class gyear_month: public simple_type, public time_zone
-{
-public:
-  gyear_month (int year, unsigned short month);
-  gyear_month (int year, unsigned short month,
-               short zone_hours, short zone_minutes);
-public:
-  gyear_month (const gyear_month&);
-
-  gyear_month&
-  operator= (const gyear_month&);
-
-  virtual gyear_month*
-  _clone () const;
-
-public:
-  int
-  year () const;
-
-  void
-  year (int);
-
-  unsigned short
-  month () const;
-
-  void
-  month (unsigned short);
-};
-
-bool
-operator== (const gyear_month&, const gyear_month&);
-
-bool
-operator!= (const gyear_month&, const gyear_month&);
-  
- - -

2.5.16 Mapping for time

- -

The XML Schema time built-in data type is mapped to - the xml_schema::time C++ class which represents hours, - minutes, and seconds with an optional time zone. Its interface is - presented below. For more information on the base - xml_schema::time_zone class refer to - Section 2.5.7, "Time Zone Representation".

- -
-class time: public simple_type, public time_zone
-{
-public:
-  time (unsigned short hours, unsigned short minutes, double seconds);
-  time (unsigned short hours, unsigned short minutes, double seconds,
-        short zone_hours, short zone_minutes);
-
-public:
-  time (const time&);
-
-  time&
-  operator= (const time&);
-
-  virtual time*
-  _clone () const;
-
-public:
-  unsigned short
-  hours () const;
-
-  void
-  hours (unsigned short);
-
-  unsigned short
-  minutes () const;
-
-  void
-  minutes (unsigned short);
-
-  double
-  seconds () const;
-
-  void
-  seconds (double);
-};
-
-bool
-operator== (const time&, const time&);
-
-bool
-operator!= (const time&, const time&);
-  
- - - - -

2.6 Mapping for Simple Types

- -

An XML Schema simple type is mapped to a C++ class with the same - name as the simple type. The class defines a public copy constructor, - a public copy assignment operator, and a public virtual - _clone function. The _clone function is - declared const, does not take any arguments, and returns - a pointer to a complete copy of the instance allocated in the free - store. The _clone function shall be used to make copies - when static type and dynamic type of the instance may differ (see - Section 2.11, "Mapping for xsi:type - and Substitution Groups"). For instance:

- -
-<simpleType name="object">
-  ...
-</simpleType>
-  
- -

is mapped to:

- -
-class object: ...
-{
-public:
-  object (const object&);
-
-public:
-  object&
-  operator= (const object&);
-
-public:
-  virtual object*
-  _clone () const;
-
-  ...
-
-};
-  
- -

The base class specification and the rest of the class definition - depend on the type of derivation used to define the simple type.

- - -

2.6.1 Mapping for Derivation by Restriction

- -

XML Schema derivation by restriction is mapped to C++ public - inheritance. The base type of the restriction becomes the base - type for the resulting C++ class. In addition to the members described - in Section 2.6, "Mapping for Simple Types", the - resulting C++ class defines a public constructor with the base type - as its single argument. For instance:

- -
-<simpleType name="object">
-  <restriction base="base">
-    ...
-  </restriction>
-</simpleType>
-  
- -

is mapped to:

- -
-class object: public base
-{
-public:
-  object (const base&);
-  object (const object&);
-
-public:
-  object&
-  operator= (const object&);
-
-public:
-  virtual object*
-  _clone () const;
-};
-  
- - -

2.6.2 Mapping for Enumerations

- -

XML Schema restriction by enumeration is mapped to a C++ class - with semantics similar to C++ enum. Each XML Schema - enumeration element is mapped to a C++ enumerator with the - name derived from the value attribute and defined - in the class scope. In addition to the members - described in Section 2.6, "Mapping for Simple Types", - the resulting C++ class defines a public constructor that can be called - with one of the enumerators as its single argument, a public constructor - that can be called with enumeration's base value as its single - argument, a public assignment operator that can be used to assign the - value of one of the enumerators, and a public implicit conversion - operator to the underlying C++ enum type.

- -

Furthermore, for string-based enumeration types, the resulting C++ - class defines a public constructor with a single argument of type - const C* and a public constructor with a single - argument of type const std::basic_string<C>&. - For instance:

- -
-<simpleType name="color">
-  <restriction base="string">
-    <enumeration value="red"/>
-    <enumeration value="green"/>
-    <enumeration value="blue"/>
-  </restriction>
-</simpleType>
-  
- -

is mapped to:

- -
-class color: public xml_schema::string
-{
-public:
-  enum value
-  {
-    red,
-    green,
-    blue
-  };
-
-public:
-  color (value);
-  color (const C*);
-  color (const std::basic_string<C>&);
-  color (const xml_schema::string&);
-  color (const color&);
-
-public:
-  color&
-  operator= (value);
-
-  color&
-  operator= (const color&);
-
-public:
-  virtual color*
-  _clone () const;
-
-public:
-  operator value () const;
-};
-  
- -

2.6.3 Mapping for Derivation by List

- -

XML Schema derivation by list is mapped to C++ public - inheritance from xml_schema::simple_type - (Section 2.5.3, "Mapping for - anySimpleType") and a suitable sequence type. - The list item type becomes the element type of the sequence. - In addition to the members described in Section 2.6, - "Mapping for Simple Types", the resulting C++ class defines - a public default constructor, a public constructor - with the first argument of type size_type and - the second argument of list item type that creates - a list object with the specified number of copies of the specified - element value, and a public constructor with the two arguments - of an input iterator type that creates a list object from an - iterator range. For instance: -

- -
-<simpleType name="int_list">
-  <list itemType="int"/>
-</simpleType>
-  
- -

is mapped to:

- -
-class int_list: public simple_type,
-                public sequence<int>
-{
-public:
-  int_list ();
-  int_list (size_type n, int x);
-
-  template <typename I>
-  int_list (const I& begin, const I& end);
-  int_list (const int_list&);
-
-public:
-  int_list&
-  operator= (const int_list&);
-
-public:
-  virtual int_list*
-  _clone () const;
-};
-  
- -

The sequence class template is defined in an - implementation-specific namespace. It conforms to the - sequence interface as defined by the ISO/ANSI Standard for - C++ (ISO/IEC 14882:1998, Section 23.1.1, "Sequences"). - Practically, this means that you can treat such a sequence - as if it was std::vector. One notable extension - to the standard interface that is available only for - sequences of non-fundamental C++ types is the addition of - the overloaded push_back and insert - member functions which instead of the constant reference - to the element type accept automatic pointer (std::auto_ptr - or std::unique_ptr, depending on the C++ standard - selected) to the element type. These functions assume ownership - of the pointed to object and reset the passed automatic pointer. -

- -

2.6.4 Mapping for Derivation by Union

- -

XML Schema derivation by union is mapped to C++ public - inheritance from xml_schema::simple_type - (Section 2.5.3, "Mapping for - anySimpleType") and std::basic_string<C>. - In addition to the members described in Section 2.6, - "Mapping for Simple Types", the resulting C++ class defines a - public constructor with a single argument of type const C* - and a public constructor with a single argument of type - const std::basic_string<C>&. For instance: -

- -
-<simpleType name="int_string_union">
-  <xsd:union memberTypes="xsd:int xsd:string"/>
-</simpleType>
-  
- -

is mapped to:

- -
-class int_string_union: public simple_type,
-                        public std::basic_string<C>
-{
-public:
-  int_string_union (const C*);
-  int_string_union (const std::basic_string<C>&);
-  int_string_union (const int_string_union&);
-
-public:
-  int_string_union&
-  operator= (const int_string_union&);
-
-public:
-  virtual int_string_union*
-  _clone () const;
-};
-  
- -

2.7 Mapping for Complex Types

- -

An XML Schema complex type is mapped to a C++ class with the same - name as the complex type. The class defines a public copy constructor, - a public copy assignment operator, and a public virtual - _clone function. The _clone function is - declared const, does not take any arguments, and returns - a pointer to a complete copy of the instance allocated in the free - store. The _clone function shall be used to make copies - when static type and dynamic type of the instance may differ (see - Section 2.11, "Mapping for xsi:type - and Substitution Groups").

- -

Additionally, the resulting C++ class - defines two public constructors that take an initializer for each - member of the complex type and all its base types that belongs to - the One cardinality class (see Section 2.8, "Mapping - for Local Elements and Attributes"). In the first constructor, - the arguments are passed as constant references and the newly created - instance is initialized with copies of the passed objects. In the - second constructor, arguments that are complex types (that is, - they themselves contain elements or attributes) are passed as - either std::auto_ptr (C++98) or std::unique_ptr - (C++11), depending on the C++ standard selected. In this case the newly - created instance is directly initialized with and assumes ownership - of the pointed to objects and the std::[auto|unique]_ptr - arguments are reset to 0. For instance:

- -
-<complexType name="complex">
-  <sequence>
-    <element name="a" type="int"/>
-    <element name="b" type="string"/>
-  </sequence>
-</complexType>
-
-<complexType name="object">
-  <sequence>
-    <element name="s-one" type="boolean"/>
-    <element name="c-one" type="complex"/>
-    <element name="optional" type="int" minOccurs="0"/>
-    <element name="sequence" type="string" maxOccurs="unbounded"/>
-  </sequence>
-</complexType>
-  
- -

is mapped to:

- -
-class complex: public xml_schema::type
-{
-public:
-  object (const int& a, const xml_schema::string& b);
-  object (const complex&);
-
-public:
-  object&
-  operator= (const complex&);
-
-public:
-  virtual complex*
-  _clone () const;
-
-  ...
-
-};
-
-class object: public xml_schema::type
-{
-public:
-  object (const bool& s_one, const complex& c_one);
-  object (const bool& s_one, std::[auto|unique]_ptr<complex> c_one);
-  object (const object&);
-
-public:
-  object&
-  operator= (const object&);
-
-public:
-  virtual object*
-  _clone () const;
-
-  ...
-
-};
-  
- -

Notice that the generated complex class does not - have the second (std::[auto|unique]_ptr) version of the - constructor since all its required members are of simple types.

- -

If an XML Schema complex type has an ultimate base which is an XML - Schema simple type then the resulting C++ class also defines a public - constructor that takes an initializer for the base type as well as - for each member of the complex type and all its base types that - belongs to the One cardinality class. For instance:

- -
-<complexType name="object">
-  <simpleContent>
-    <extension base="date">
-      <attribute name="lang" type="language" use="required"/>
-    </extension>
-  </simpleContent>
-</complexType>
-  
- -

is mapped to:

- -
-class object: public xml_schema::string
-{
-public:
-  object (const xml_schema::language& lang);
-
-  object (const xml_schema::date& base,
-          const xml_schema::language& lang);
-
-  ...
-
-};
-  
- -

Furthermore, for string-based XML Schema complex types, the resulting C++ - class also defines two public constructors with the first arguments - of type const C* and std::basic_string<C>&, - respectively, followed by arguments for each member of the complex - type and all its base types that belongs to the One cardinality - class. For enumeration-based complex types the resulting C++ - class also defines a public constructor with the first arguments - of the underlying enum type followed by arguments for each member - of the complex type and all its base types that belongs to the One - cardinality class. For instance:

- -
-<simpleType name="color">
-  <restriction base="string">
-    <enumeration value="red"/>
-    <enumeration value="green"/>
-    <enumeration value="blue"/>
-  </restriction>
-</simpleType>
-
-<complexType name="object">
-  <simpleContent>
-    <extension base="color">
-      <attribute name="lang" type="language" use="required"/>
-    </extension>
-  </simpleContent>
-</complexType>
-  
- -

is mapped to:

- -
-class color: public xml_schema::string
-{
-public:
-  enum value
-  {
-    red,
-    green,
-    blue
-  };
-
-public:
-  color (value);
-  color (const C*);
-  color (const std::basic_string<C>&);
-
-  ...
-
-};
-
-class object: color
-{
-public:
-  object (const color& base,
-          const xml_schema::language& lang);
-
-  object (const color::value& base,
-          const xml_schema::language& lang);
-
-  object (const C* base,
-          const xml_schema::language& lang);
-
-  object (const std::basic_string<C>& base,
-          const xml_schema::language& lang);
-
-  ...
-
-};
-  
- -

Additional constructors can be requested with the - --generate-default-ctor and - --generate-from-base-ctor options. See the - XSD - Compiler Command Line Manual for details.

- -

If an XML Schema complex type is not explicitly derived from any type, - the resulting C++ class is derived from xml_schema::type. - In cases where an XML Schema complex type is defined using derivation - by extension or restriction, the resulting C++ base class specification - depends on the type of derivation and is described in the subsequent - sections. -

- -

The mapping for elements and attributes that are defined in a complex - type is described in Section 2.8, "Mapping for Local - Elements and Attributes". -

- -

2.7.1 Mapping for Derivation by Extension

- -

XML Schema derivation by extension is mapped to C++ public - inheritance. The base type of the extension becomes the base - type for the resulting C++ class. -

- -

2.7.2 Mapping for Derivation by Restriction

- -

XML Schema derivation by restriction is mapped to C++ public - inheritance. The base type of the restriction becomes the base - type for the resulting C++ class. XML Schema elements and - attributes defined within restriction do not result in any - definitions in the resulting C++ class. Instead, corresponding - (unrestricted) definitions are inherited from the base class. - In the future versions of this mapping, such elements and - attributes may result in redefinitions of accessors and - modifiers to reflect their restricted semantics. -

- - - -

2.8 Mapping for Local Elements and Attributes

- -

XML Schema element and attribute definitions are called local - if they appear within a complex type definition, an element group - definition, or an attribute group definitions. -

- -

Local XML Schema element and attribute definitions have the same - C++ mapping. Therefore, in this section, local elements and - attributes are collectively called members. -

- -

While there are many different member cardinality combinations - (determined by the use attribute for attributes and - the minOccurs and maxOccurs attributes - for elements), the mapping divides all possible cardinality - combinations into three cardinality classes: -

- -
-
one
-
attributes: use == "required"
-
attributes: use == "optional" and has default or fixed value
-
elements: minOccurs == "1" and maxOccurs == "1"
- -
optional
-
attributes: use == "optional" and doesn't have default or fixed value
-
elements: minOccurs == "0" and maxOccurs == "1"
- -
sequence
-
elements: maxOccurs > "1"
-
- -

An optional attribute with a default or fixed value acquires this value - if the attribute hasn't been specified in an instance document (see - Appendix A, "Default and Fixed Values"). This - mapping places such optional attributes to the One cardinality - class.

- -

A member is mapped to a set of public type definitions - (typedefs) and a set of public accessor and modifier - functions. Type definitions have names derived from the member's - name. The accessor and modifier functions have the same name as the - member. For example: -

- -
-<complexType name="object">
-  <sequence>
-    <element name="member" type="string"/>
-  </sequence>
-</complexType>
-  
- -

is mapped to:

- -
-class object: public xml_schema::type
-{
-public:
-  typedef xml_schema::string member_type;
-
-  const member_type&
-  member () const;
-
-  ...
-
-};
-  
- -

In addition, if a member has a default or fixed value, a static - accessor function is generated that returns this value. For - example:

- -
-<complexType name="object">
-  <attribute name="data" type="string" default="test"/>
-</complexType>
-  
- -

is mapped to:

- -
-class object: public xml_schema::type
-{
-public:
-  typedef xml_schema::string data_type;
-
-  const data_type&
-  data () const;
-
-  static const data_type&
-  data_default_value ();
-
-  ...
-
-};
-  
- -

Names and semantics of type definitions for the member as well - as signatures of the accessor and modifier functions depend on - the member's cardinality class and are described in the following - sub-sections. -

- - -

2.8.1 Mapping for Members with the One Cardinality Class

- -

For the One cardinality class, the type definitions consist of - an alias for the member's type with the name created by appending - the _type suffix to the member's name. -

- -

The accessor functions come in constant and non-constant versions. - The constant accessor function returns a constant reference to the - member and can be used for read-only access. The non-constant - version returns an unrestricted reference to the member and can - be used for read-write access. -

- -

The first modifier function expects an argument of type reference to - constant of the member's type. It makes a deep copy of its argument. - Except for member's types that are mapped to fundamental C++ types, - the second modifier function is provided that expects an argument - of type automatic pointer (std::auto_ptr or - std::unique_ptr, depending on the C++ standard selected) - to the member's type. It assumes ownership of the pointed to object - and resets the passed automatic pointer. For instance:

- -
-<complexType name="object">
-  <sequence>
-    <element name="member" type="string"/>
-  </sequence>
-</complexType>
-  
- -

is mapped to:

- -
-class object: public xml_schema::type
-{
-public:
-  // Type definitions.
-  //
-  typedef xml_schema::string member_type;
-
-  // Accessors.
-  //
-  const member_type&
-  member () const;
-
-  member_type&
-  member ();
-
-  // Modifiers.
-  //
-  void
-  member (const member_type&);
-
-  void
-  member (std::[auto|unique]_ptr<member_type>);
-  ...
-
-};
-  
- -

In addition, if requested by specifying the --generate-detach - option and only for members of non-fundamental C++ types, the mapping - provides a detach function that returns an automatic pointer to the - member's type, for example:

- -
-class object: public xml_schema::type
-{
-public:
-  ...
-
-  std::[auto|unique]_ptr<member_type>
-  detach_member ();
-  ...
-
-};
-  
- -

This function detaches the value from the tree leaving the member - value uninitialized. Accessing such an uninitialized value prior to - re-initializing it results in undefined behavior.

- -

The following code shows how one could use this mapping:

- -
-void
-f (object& o)
-{
-  using xml_schema::string;
-
-  string s (o.member ());                // get
-  object::member_type& sr (o.member ()); // get
-
-  o.member ("hello");           // set, deep copy
-  o.member () = "hello";        // set, deep copy
-
-  // C++98 version.
-  //
-  std::auto_ptr<string> p (new string ("hello"));
-  o.member (p);                 // set, assumes ownership
-  p = o.detach_member ();       // detach, member is uninitialized
-  o.member (p);                 // re-attach
-
-  // C++11 version.
-  //
-  std::unique_ptr<string> p (new string ("hello"));
-  o.member (std::move (p));     // set, assumes ownership
-  p = o.detach_member ();       // detach, member is uninitialized
-  o.member (std::move (p));     // re-attach
-}
-  
- - -

2.8.2 Mapping for Members with the Optional Cardinality Class

- -

For the Optional cardinality class, the type definitions consist of - an alias for the member's type with the name created by appending - the _type suffix to the member's name and an alias for - the container type with the name created by appending the - _optional suffix to the member's name. -

- -

Unlike accessor functions for the One cardinality class, accessor - functions for the Optional cardinality class return references to - corresponding containers rather than directly to members. The - accessor functions come in constant and non-constant versions. - The constant accessor function returns a constant reference to - the container and can be used for read-only access. The non-constant - version returns an unrestricted reference to the container - and can be used for read-write access. -

- -

The modifier functions are overloaded for the member's - type and the container type. The first modifier function - expects an argument of type reference to constant of the - member's type. It makes a deep copy of its argument. - Except for member's types that are mapped to fundamental C++ types, - the second modifier function is provided that expects an argument - of type automatic pointer (std::auto_ptr or - std::unique_ptr, depending on the C++ standard selected) - to the member's type. It assumes ownership of the pointed to object - and resets the passed automatic pointer. The last modifier function - expects an argument of type reference to constant of the container - type. It makes a deep copy of its argument. For instance: -

- -
-<complexType name="object">
-  <sequence>
-    <element name="member" type="string" minOccurs="0"/>
-  </sequence>
-</complexType>
-  
- -

is mapped to:

- -
-class object: public xml_schema::type
-{
-public:
-  // Type definitions.
-  //
-  typedef xml_schema::string member_type;
-  typedef optional<member_type> member_optional;
-
-  // Accessors.
-  //
-  const member_optional&
-  member () const;
-
-  member_optional&
-  member ();
-
-  // Modifiers.
-  //
-  void
-  member (const member_type&);
-
-  void
-  member (std::[auto|unique]_ptr<member_type>);
-
-  void
-  member (const member_optional&);
-
-  ...
-
-};
-  
- - -

The optional class template is defined in an - implementation-specific namespace and has the following - interface. The [auto|unique]_ptr-based constructor - and modifier function are only available if the template - argument is not a fundamental C++ type. -

- -
-template <typename X>
-class optional
-{
-public:
-  optional ();
-
-  // Makes a deep copy.
-  //
-  explicit
-  optional (const X&);
-
-  // Assumes ownership.
-  //
-  explicit
-  optional (std::[auto|unique]_ptr<X>);
-
-  optional (const optional&);
-
-public:
-  optional&
-  operator= (const X&);
-
-  optional&
-  operator= (const optional&);
-
-  // Pointer-like interface.
-  //
-public:
-  const X*
-  operator-> () const;
-
-  X*
-  operator-> ();
-
-  const X&
-  operator* () const;
-
-  X&
-  operator* ();
-
-  typedef void (optional::*bool_convertible) ();
-  operator bool_convertible () const;
-
-  // Get/set interface.
-  //
-public:
-  bool
-  present () const;
-
-  const X&
-  get () const;
-
-  X&
-  get ();
-
-  // Makes a deep copy.
-  //
-  void
-  set (const X&);
-
-  // Assumes ownership.
-  //
-  void
-  set (std::[auto|unique]_ptr<X>);
-
-  // Detach and return the contained value.
-  //
-  std::[auto|unique]_ptr<X>
-  detach ();
-
-  void
-  reset ();
-};
-
-template <typename X>
-bool
-operator== (const optional<X>&, const optional<X>&);
-
-template <typename X>
-bool
-operator!= (const optional<X>&, const optional<X>&);
-
-template <typename X>
-bool
-operator< (const optional<X>&, const optional<X>&);
-
-template <typename X>
-bool
-operator> (const optional<X>&, const optional<X>&);
-
-template <typename X>
-bool
-operator<= (const optional<X>&, const optional<X>&);
-
-template <typename X>
-bool
-operator>= (const optional<X>&, const optional<X>&);
-  
- - -

The following code shows how one could use this mapping:

- -
-void
-f (object& o)
-{
-  using xml_schema::string;
-
-  if (o.member ().present ())       // test
-  {
-    string& s (o.member ().get ()); // get
-    o.member ("hello");             // set, deep copy
-    o.member ().set ("hello");      // set, deep copy
-    o.member ().reset ();           // reset
-  }
-
-  // Same as above but using pointer notation:
-  //
-  if (o.member ())                  // test
-  {
-    string& s (*o.member ());       // get
-    o.member ("hello");             // set, deep copy
-    *o.member () = "hello";         // set, deep copy
-    o.member ().reset ();           // reset
-  }
-
-  // C++98 version.
-  //
-  std::auto_ptr<string> p (new string ("hello"));
-  o.member (p);                     // set, assumes ownership
-
-  p = new string ("hello");
-  o.member ().set (p);              // set, assumes ownership
-
-  p = o.member ().detach ();        // detach, member is reset
-  o.member ().set (p);              // re-attach
-
-  // C++11 version.
-  //
-  std::unique_ptr<string> p (new string ("hello"));
-  o.member (std::move (p));         // set, assumes ownership
-
-  p.reset (new string ("hello"));
-  o.member ().set (std::move (p));  // set, assumes ownership
-
-  p = o.member ().detach ();        // detach, member is reset
-  o.member ().set (std::move (p));  // re-attach
-}
-  
- - -

2.8.3 Mapping for Members with the Sequence Cardinality Class

- -

For the Sequence cardinality class, the type definitions consist of an - alias for the member's type with the name created by appending - the _type suffix to the member's name, an alias of - the container type with the name created by appending the - _sequence suffix to the member's name, an alias of - the iterator type with the name created by appending the - _iterator suffix to the member's name, and an alias - of the constant iterator type with the name created by appending the - _const_iterator suffix to the member's name. -

- -

The accessor functions come in constant and non-constant versions. - The constant accessor function returns a constant reference to the - container and can be used for read-only access. The non-constant - version returns an unrestricted reference to the container and can - be used for read-write access. -

- -

The modifier function expects an argument of type reference to - constant of the container type. The modifier function - makes a deep copy of its argument. For instance: -

- - -
-<complexType name="object">
-  <sequence>
-    <element name="member" type="string" minOccurs="unbounded"/>
-  </sequence>
-</complexType>
-  
- -

is mapped to:

- -
-class object: public xml_schema::type
-{
-public:
-  // Type definitions.
-  //
-  typedef xml_schema::string member_type;
-  typedef sequence<member_type> member_sequence;
-  typedef member_sequence::iterator member_iterator;
-  typedef member_sequence::const_iterator member_const_iterator;
-
-  // Accessors.
-  //
-  const member_sequence&
-  member () const;
-
-  member_sequence&
-  member ();
-
-  // Modifier.
-  //
-  void
-  member (const member_sequence&);
-
-  ...
-
-};
-  
- -

The sequence class template is defined in an - implementation-specific namespace. It conforms to the - sequence interface as defined by the ISO/ANSI Standard for - C++ (ISO/IEC 14882:1998, Section 23.1.1, "Sequences"). - Practically, this means that you can treat such a sequence - as if it was std::vector. Two notable extensions - to the standard interface that are available only for - sequences of non-fundamental C++ types are the addition of - the overloaded push_back and insert - as well as the detach_back and detach - member functions. The additional push_back and - insert functions accept an automatic pointer - (std::auto_ptr or std::unique_ptr, - depending on the C++ standard selected) to the - element type instead of the constant reference. They assume - ownership of the pointed to object and reset the passed - automatic pointer. The detach_back and - detach functions detach the element - value from the sequence container and, by default, remove - the element from the sequence. These additional functions - have the following signatures:

- -
-template <typename X>
-class sequence
-{
-public:
-  ...
-
-  void
-  push_back (std::[auto|unique]_ptr<X>)
-
-  iterator
-  insert (iterator position, std::[auto|unique]_ptr<X>)
-
-  std::[auto|unique]_ptr<X>
-  detach_back (bool pop = true);
-
-  iterator
-  detach (iterator position,
-          std::[auto|unique]_ptr<X>& result,
-          bool erase = true)
-
-  ...
-}
-  
- -

The following code shows how one could use this mapping:

- -
-void
-f (object& o)
-{
-  using xml_schema::string;
-
-  object::member_sequence& s (o.member ());
-
-  // Iteration.
-  //
-  for (object::member_iterator i (s.begin ()); i != s.end (); ++i)
-  {
-    string& value (*i);
-  }
-
-  // Modification.
-  //
-  s.push_back ("hello");  // deep copy
-
-  // C++98 version.
-  //
-  std::auto_ptr<string> p (new string ("hello"));
-  s.push_back (p);        // assumes ownership
-  p = s.detach_back ();   // detach and pop
-  s.push_back (p);        // re-append
-
-  // C++11 version.
-  //
-  std::unique_ptr<string> p (new string ("hello"));
-  s.push_back (std::move (p)); // assumes ownership
-  p = s.detach_back ();        // detach and pop
-  s.push_back (std::move (p)); // re-append
-
-  // Setting a new container.
-  //
-  object::member_sequence n;
-  n.push_back ("one");
-  n.push_back ("two");
-  o.member (n);           // deep copy
-}
-  
- -

2.8.4 Element Order

- -

C++/Tree is a "flattening" mapping in a sense that many levels of - nested compositors (choice and sequence), - all potentially with their own cardinalities, are in the end mapped - to a flat set of elements with one of the three cardinality classes - discussed in the previous sections. While this results in a simple - and easy to use API for most types, in certain cases, the order of - elements in the actual XML documents is not preserved once parsed - into the object model. And sometimes such order has - application-specific significance. As an example, consider a schema - that defines a batch of bank transactions:

- -
-<complexType name="withdraw">
-  <sequence>
-    <element name="account" type="unsignedInt"/>
-    <element name="amount" type="unsignedInt"/>
-  </sequence>
-</complexType>
-
-<complexType name="deposit">
-  <sequence>
-    <element name="account" type="unsignedInt"/>
-    <element name="amount" type="unsignedInt"/>
-  </sequence>
-</complexType>
-
-<complexType name="batch">
-  <choice minOccurs="0" maxOccurs="unbounded">
-    <element name="withdraw" type="withdraw"/>
-    <element name="deposit" type="deposit"/>
-  </choice>
-</complexType>
-  
- -

The batch can contain any number of transactions in any order - but the order of transactions in each actual batch is significant. - For instance, consider what could happen if we reorder the - transactions and apply all the withdrawals before deposits.

- -

For the batch schema type defined above the default - C++/Tree mapping will produce a C++ class that contains a pair of - sequence containers, one for each of the two elements. While this - will capture the content (transactions), the order of this content - as it appears in XML will be lost. Also, if we try to serialize the - batch we just loaded back to XML, all the withdrawal transactions - will appear before deposits.

- -

To overcome this limitation of a flattening mapping, C++/Tree - allows us to mark certain XML Schema types, for which content - order is important, as ordered.

- -

There are several command line options that control which - schema types are treated as ordered. To make an individual - type ordered, we use the --ordered-type option, - for example:

- -
---ordered-type batch
-  
- -

To automatically treat all the types that are derived from an ordered - type also ordered, we use the --ordered-type-derived - option. This is primarily useful if you would like to iterate - over the complete hierarchy's content using the content order - sequence (discussed below).

- -

Ordered types are also useful for handling mixed content. To - automatically mark all the types with mixed content as ordered - we use the --ordered-type-mixed option. For more - information on handling mixed content see Section - 2.13, "Mapping for Mixed Content Models".

- -

Finally, we can mark all the types in the schema we are - compiling with the --ordered-type-all option. - You should only resort to this option if all the types in - your schema truly suffer from the loss of content - order since, as we will discuss shortly, ordered types - require extra effort to access and, especially, modify. - See the - XSD - Compiler Command Line Manual for more information on - these options.

- -

Once a type is marked ordered, C++/Tree alters its mapping - in several ways. Firstly, for each local element, element - wildcard (Section 2.12.4, "Element Wildcard - Order"), and mixed content text (Section - 2.13, "Mapping for Mixed Content Models") in this type, a - content id constant is generated. Secondly, an addition sequence - is added to the class that captures the content order. Here - is how the mapping of our batch class changes - once we make it ordered:

- -
-class batch: public xml_schema::type
-{
-public:
-  // withdraw
-  //
-  typedef withdraw withdraw_type;
-  typedef sequence<withdraw_type> withdraw_sequence;
-  typedef withdraw_sequence::iterator withdraw_iterator;
-  typedef withdraw_sequence::const_iterator withdraw_const_iterator;
-
-  static const std::size_t withdraw_id = 1;
-
-  const withdraw_sequence&
-  withdraw () const;
-
-  withdraw_sequence&
-  withdraw ();
-
-  void
-  withdraw (const withdraw_sequence&);
-
-  // deposit
-  //
-  typedef deposit deposit_type;
-  typedef sequence<deposit_type> deposit_sequence;
-  typedef deposit_sequence::iterator deposit_iterator;
-  typedef deposit_sequence::const_iterator deposit_const_iterator;
-
-  static const std::size_t deposit_id = 2;
-
-  const deposit_sequence&
-  deposit () const;
-
-  deposit_sequence&
-  deposit ();
-
-  void
-  deposit (const deposit_sequence&);
-
-  // content_order
-  //
-  typedef xml_schema::content_order content_order_type;
-  typedef std::vector<content_order_type> content_order_sequence;
-  typedef content_order_sequence::iterator content_order_iterator;
-  typedef content_order_sequence::const_iterator content_order_const_iterator;
-
-  const content_order_sequence&
-  content_order () const;
-
-  content_order_sequence&
-  content_order ();
-
-  void
-  content_order (const content_order_sequence&);
-
-  ...
-};
-  
- -

Notice the withdraw_id and deposit_id - content ids as well as the extra content_order - sequence that does not correspond to any element in the - schema definition. The other changes to the mapping for ordered - types has to do with XML parsing and serialization code. During - parsing the content order is captured in the content_order - sequence while during serialization this sequence is used to - determine the order in which content is serialized. The - content_order sequence is also copied during - copy construction and assigned during copy assignment. It is also - taken into account during comparison.

- -

The entry type of the content_order sequence is the - xml_schema::content_order type that has the following - interface:

- -
-namespace xml_schema
-{
-  struct content_order
-  {
-    content_order (std::size_t id, std::size_t index = 0);
-
-    std::size_t id;
-    std::size_t index;
-  };
-
-  bool
-  operator== (const content_order&, const content_order&);
-
-  bool
-  operator!= (const content_order&, const content_order&);
-
-  bool
-  operator< (const content_order&, const content_order&);
-}
-  
- -

The content_order sequence describes the order of - content (elements, including wildcards, as well as mixed content - text). Each entry in this sequence consists of the content id - (for example, withdraw_id or deposit_id - in our case) as well as, for elements of the sequence cardinality - class, an index into the corresponding sequence container (the - index is unused for the one and optional cardinality classes). - For example, in our case, if the content id is withdraw_id, - then the index will point into the withdraw element - sequence.

- -

With all this information we can now examine how to iterate over - transaction in the batch in content order:

- -
-batch& b = ...
-
-for (batch::content_order_const_iterator i (b.content_order ().begin ());
-     i != b.content_order ().end ();
-     ++i)
-{
-  switch (i->id)
-  {
-  case batch::withdraw_id:
-    {
-      const withdraw& t (b.withdraw ()[i->index]);
-      cerr << t.account () << " withdraw " << t.amount () << endl;
-      break;
-    }
-  case batch::deposit_id:
-    {
-      const deposit& t (b.deposit ()[i->index]);
-      cerr << t.account () << " deposit " << t.amount () << endl;
-      break;
-    }
-  default:
-    {
-      assert (false); // Unknown content id.
-    }
-  }
-}
-  
- -

If we serialized our batch back to XML, we would also see that the - order of transactions in the output is exactly the same as in the - input rather than all the withdrawals first followed by all the - deposits.

- -

The most complex aspect of working with ordered types is - modifications. Now we not only need to change the content, - but also remember to update the order information corresponding - to this change. As a first example, we add a deposit transaction - to the batch:

- -
-using xml_schema::content_order;
-
-batch::deposit_sequence& d (b.deposit ());
-batch::withdraw_sequence& w (b.withdraw ());
-batch::content_order_sequence& co (b.content_order ());
-
-d.push_back (deposit (123456789, 100000));
-co.push_back (content_order (batch::deposit_id, d.size () - 1));
-  
- -

In the above example we first added the content (deposit - transaction) and then updated the content order information - by adding an entry with deposit_id content - id and the index of the just added deposit transaction.

- -

Removing the last transaction can be easy if we know which - transaction (deposit or withdrawal) is last:

- -
-d.pop_back ();
-co.pop_back ();
-  
- -

If, however, we do not know which transaction is last, then - things get a bit more complicated:

- -
-switch (co.back ().id)
-{
-case batch::withdraw_id:
-  {
-    d.pop_back ();
-    break;
-  }
-case batch::deposit_id:
-  {
-    w.pop_back ();
-    break;
-  }
-}
-
-co.pop_back ();
-  
- -

The following example shows how to add a transaction at the - beginning of the batch:

- -
-w.push_back (withdraw (123456789, 100000));
-co.insert (co.begin (),
-           content_order (batch::withdraw_id, w.size () - 1));
-  
- -

Note also that when we merely modify the content of one - of the elements in place, we do not need to update its - order since it doesn't change. For example, here is how - we can change the amount in the first withdrawal:

- -
-w[0].amount (10000);
-  
- -

For the complete working code shown in this section refer to the - order/element example in the - examples/cxx/tree/ directory in the XSD distribution.

- -

If both the base and derived types are ordered, then the - content order sequence is only added to the base and the content - ids are unique within the whole hierarchy. In this case - the content order sequence for the derived type contains - ordering information for both base and derived content.

- -

In some applications we may need to perform more complex - content processing. For example, in our case, we may need - to remove all the withdrawal transactions. The default - container, std::vector, is not particularly - suitable for such operations. What may be required by - some applications is a multi-index container that not - only allows us to iterate in content order similar to - std::vector but also search by the content - id as well as the content id and index pair.

- -

While C++/Tree does not provide this functionality by - default, it allows us to specify a custom container - type for content order with the --order-container - command line option. The only requirement from the - generated code side for such a container is to provide - the vector-like push_back(), - size(), and const iteration interfaces.

- -

As an example, here is how we can use the Boost Multi-Index - container for content order. First we create the - content-order-container.hxx header with the - following definition (in C++11, use the alias template - instead):

- -
-#ifndef CONTENT_ORDER_CONTAINER
-#define CONTENT_ORDER_CONTAINER
-
-#include <cstddef> // std::size_t
-
-#include <boost/multi_index_container.hpp>
-#include <boost/multi_index/member.hpp>
-#include <boost/multi_index/identity.hpp>
-#include <boost/multi_index/ordered_index.hpp>
-#include <boost/multi_index/random_access_index.hpp>
-
-struct by_id {};
-struct by_id_index {};
-
-template <typename T>
-struct content_order_container:
-  boost::multi_index::multi_index_container<
-    T,
-    boost::multi_index::indexed_by<
-      boost::multi_index::random_access<>,
-      boost::multi_index::ordered_unique<
-        boost::multi_index::tag<by_id_index>,
-        boost::multi_index::identity<T>
-      >,
-      boost::multi_index::ordered_non_unique<
-        boost::multi_index::tag<by_id>,
-        boost::multi_index::member<T, std::size_t, &T::id>
-      >
-    >
-  >
-{};
-
-#endif
-  
- -

Next we add the following two XSD compiler options to include - this header into every generated header file and to use the - custom container type (see the XSD compiler command line manual - for more information on shell quoting for the first option):

- -
---hxx-prologue '#include "content-order-container.hxx"'
---order-container content_order_container
-  
- -

With these changes we can now use the multi-index functionality, - for example, to search for a specific content id:

- -
-typedef batch::content_order_sequence::index<by_id>::type id_set;
-typedef id_set::iterator id_iterator;
-
-const id_set& ids (b.content_order ().get<by_id> ());
-
-std::pair<id_iterator, id_iterator> r (
-  ids.equal_range (std::size_t (batch::deposit_id));
-
-for (id_iterator i (r.first); i != r.second; ++i)
-{
-  const deposit& t (b.deposit ()[i->index]);
-  cerr << t.account () << " deposit " << t.amount () << endl;
-}
-  
- -

2.9 Mapping for Global Elements

- -

An XML Schema element definition is called global if it appears - directly under the schema element. - A global element is a valid root of an instance document. By - default, a global element is mapped to a set of overloaded - parsing and, optionally, serialization functions with the - same name as the element. It is also possible to generate types - for root elements instead of parsing and serialization functions. - This is primarily useful to distinguish object models with the - same root type but with different root elements. See - Section 2.9.1, "Element Types" for details. - It is also possible to request the generation of an element map - which allows uniform parsing and serialization of multiple root - elements. See Section 2.9.2, "Element Map" - for details. -

- -

The parsing functions read XML instance documents and return - corresponding object models as an automatic pointer - (std::auto_ptr or std::unique_ptr, - depending on the C++ standard selected). Their signatures - have the following pattern (type denotes - element's type and name denotes element's - name): -

- -
-std::[auto|unique]_ptr<type>
-name (....);
-  
- -

The process of parsing, including the exact signatures of the parsing - functions, is the subject of Chapter 3, "Parsing". -

- -

The serialization functions write object models back to XML instance - documents. Their signatures have the following pattern: -

- -
-void
-name (<stream type>&, const type&, ....);
-  
- -

The process of serialization, including the exact signatures of the - serialization functions, is the subject of Chapter 4, - "Serialization". -

- - -

2.9.1 Element Types

- -

The generation of element types is requested with the - --generate-element-type option. With this option - each global element is mapped to a C++ class with the - same name as the element. Such a class is derived from - xml_schema::element_type and contains the same set - of type definitions, constructors, and member function as would a - type containing a single element with the One cardinality class - named "value". In addition, the element type also - contains a set of member functions for accessing the element - name and namespace as well as its value in a uniform manner. - For example:

- -
-<complexType name="type">
-  <sequence>
-    ...
-  </sequence>
-</complexType>
-
-<element name="root" type="type"/>
-  
- -

is mapped to:

- -
-class type
-{
-  ...
-};
-
-class root: public xml_schema::element_type
-{
-public:
-  // Element value.
-  //
-  typedef type value_type;
-
-  const value_type&
-  value () const;
-
-  value_type&
-  value ();
-
-  void
-  value (const value_type&);
-
-  void
-  value (std::[auto|unique]_ptr<value_type>);
-
-  // Constructors.
-  //
-  root (const value_type&);
-
-  root (std::[auto|unique]_ptr<value_type>);
-
-  root (const xercesc::DOMElement&, xml_schema::flags = 0);
-
-  root (const root&, xml_schema::flags = 0);
-
-  virtual root*
-  _clone (xml_schema::flags = 0) const;
-
-  // Element name and namespace.
-  //
-  static const std::string&
-  name ();
-
-  static const std::string&
-  namespace_ ();
-
-  virtual const std::string&
-  _name () const;
-
-  virtual const std::string&
-  _namespace () const;
-
-  // Element value as xml_schema::type.
-  //
-  virtual const xml_schema::type*
-  _value () const;
-
-  virtual xml_schema::type*
-  _value ();
-};
-
-void
-operator<< (xercesc::DOMElement&, const root&);
-  
- -

The xml_schema::element_type class is a common - base type for all element types and is defined as follows:

- -
-namespace xml_schema
-{
-  class element_type
-  {
-  public:
-    virtual
-    ~element_type ();
-
-    virtual element_type*
-    _clone (flags f = 0) const = 0;
-
-    virtual const std::basic_string<C>&
-    _name () const = 0;
-
-    virtual const std::basic_string<C>&
-    _namespace () const = 0;
-
-    virtual xml_schema::type*
-    _value () = 0;
-
-    virtual const xml_schema::type*
-    _value () const = 0;
-  };
-}
-  
- -

The _value() member function returns a pointer to - the element value or 0 if the element is of a fundamental C++ - type and therefore is not derived from xml_schema::type. -

- -

Unlike parsing and serialization functions, element types - are only capable of parsing and serializing from/to a - DOMElement object. This means that the application - will need to perform its own XML-to-DOM parsing and DOM-to-XML - serialization. The following section describes a mechanism - provided by the mapping to uniformly parse and serialize - multiple root elements.

- - -

2.9.2 Element Map

- -

When element types are generated for root elements it is also - possible to request the generation of an element map with the - --generate-element-map option. The element map - allows uniform parsing and serialization of multiple root - elements via the common xml_schema::element_type - base type. The xml_schema::element_map class is - defined as follows:

- -
-namespace xml_schema
-{
-  class element_map
-  {
-  public:
-    static std::[auto|unique]_ptr<xml_schema::element_type>
-    parse (const xercesc::DOMElement&, flags = 0);
-
-    static void
-    serialize (xercesc::DOMElement&, const element_type&);
-  };
-}
-  
- -

The parse() function creates the corresponding - element type object based on the element name and namespace - and returns it as an automatic pointer (std::auto_ptr - or std::unique_ptr, depending on the C++ standard - selected) to xml_schema::element_type. - The serialize() function serializes the passed element - object to DOMElement. Note that in case of - serialize(), the DOMElement object - should have the correct name and namespace. If no element type is - available for an element, both functions throw the - xml_schema::no_element_info exception:

- -
-struct no_element_info: virtual exception
-{
-  no_element_info (const std::basic_string<C>& element_name,
-                   const std::basic_string<C>& element_namespace);
-
-  const std::basic_string<C>&
-  element_name () const;
-
-  const std::basic_string<C>&
-  element_namespace () const;
-
-  virtual const char*
-  what () const throw ();
-};
-  
- -

The application can discover the actual type of the element - object returned by parse() either using - dynamic_cast or by comparing element names and - namespaces. The following code fragments illustrate how the - element map can be used:

- -
-// Parsing.
-//
-DOMElement& e = ... // Parse XML to DOM.
-
-auto_ptr<xml_schema::element_type> r (
-  xml_schema::element_map::parse (e));
-
-if (root1 r1 = dynamic_cast<root1*> (r.get ()))
-{
-  ...
-}
-else if (r->_name == root2::name () &&
-         r->_namespace () == root2::namespace_ ())
-{
-  root2& r2 (static_cast<root2&> (*r));
-
-  ...
-}
-  
- -
-// Serialization.
-//
-xml_schema::element_type& r = ...
-
-string name (r._name ());
-string ns (r._namespace ());
-
-DOMDocument& doc = ... // Create a new DOMDocument with name and ns.
-DOMElement& e (*doc->getDocumentElement ());
-
-xml_schema::element_map::serialize (e, r);
-
-// Serialize DOMDocument to XML.
-  
- - - -

2.10 Mapping for Global Attributes

- -

An XML Schema attribute definition is called global if it appears - directly under the schema element. A global - attribute does not have any mapping. -

- - - -

2.11 Mapping for xsi:type and Substitution - Groups

- -

The mapping provides optional support for the XML Schema polymorphism - features (xsi:type and substitution groups) which can - be requested with the --generate-polymorphic option. - When used, the dynamic type of a member may be different from - its static type. Consider the following schema definition and - instance document: -

- -
-<!-- test.xsd -->
-<schema>
-  <complexType name="base">
-    <attribute name="text" type="string"/>
-  </complexType>
-
-  <complexType name="derived">
-    <complexContent>
-      <extension base="base">
-        <attribute name="extra-text" type="string"/>
-      </extension>
-    </complexContent>
-  </complexType>
-
-  <complexType name="root_type">
-    <sequence>
-      <element name="item" type="base" maxOccurs="unbounded"/>
-    </sequence>
-  </complexType>
-
-  <element name="root" type="root_type"/>
-</schema>
-
-<!-- test.xml -->
-<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-  <item text="hello"/>
-  <item text="hello" extra-text="world" xsi:type="derived"/>
-</root>
-  
- -

In the resulting object model, the container for - the root::item member will have two elements: - the first element's type will be base while - the second element's (dynamic) type will be - derived. This can be discovered using the - dynamic_cast operator as shown in the following - example: -

- -
-void
-f (root& r)
-{
-  for (root::item_const_iterator i (r.item ().begin ());
-       i != r.item ().end ()
-       ++i)
-  {
-    if (derived* d = dynamic_cast<derived*> (&(*i)))
-    {
-      // derived
-    }
-    else
-    {
-      // base
-    }
-  }
-}
-  
- -

The _clone virtual function should be used instead of - copy constructors to make copies of members that might use - polymorphism: -

- -
-void
-f (root& r)
-{
-  for (root::item_const_iterator i (r.item ().begin ());
-       i != r.item ().end ()
-       ++i)
-  {
-    std::auto_ptr<base> c (i->_clone ());
-  }
-}
-  
- -

The mapping can often automatically determine which types are - polymorphic based on the substitution group declarations. However, - if your XML vocabulary is not using substitution groups or if - substitution groups are defined in a separate schema, then you will - need to use the --polymorphic-type option to specify - which types are polymorphic. When using this option you only need - to specify the root of a polymorphic type hierarchy and the mapping - will assume that all the derived types are also polymorphic. - Also note that you need to specify this option when compiling every - schema file that references the polymorphic type. Consider the following - two schemas as an example:

- -
-<!-- base.xsd -->
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
-
-  <xs:complexType name="base">
-    <xs:sequence>
-      <xs:element name="b" type="xs:int"/>
-    </xs:sequence>
-  </xs:complexType>
-
-  <!-- substitution group root -->
-  <xs:element name="base" type="base"/>
-
-</xs:schema>
-  
- -
-<!-- derived.xsd -->
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
-
-  <include schemaLocation="base.xsd"/>
-
-  <xs:complexType name="derived">
-    <xs:complexContent>
-      <xs:extension base="base">
-        <xs:sequence>
-          <xs:element name="d" type="xs:string"/>
-        </xs:sequence>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:element name="derived" type="derived" substitutionGroup="base"/>
-
-</xs:schema>
-  
- -

In this example we need to specify "--polymorphic-type base" - when compiling both schemas because the substitution group is declared - in a schema other than the one defining type base.

- -

You can also indicate that all types should be treated as polymorphic - with the --polymorphic-type-all. However, this may result - in slower generated code with a greater footprint.

- - - - - -

2.12 Mapping for any and anyAttribute

- -

For the XML Schema any and anyAttribute - wildcards an optional mapping can be requested with the - --generate-wildcard option. The mapping represents - the content matched by wildcards as DOM fragments. Because the - DOM API is used to access such content, the Xerces-C++ runtime - should be initialized by the application prior to parsing and - should remain initialized for the lifetime of objects with - the wildcard content. For more information on the Xerces-C++ - runtime initialization see Section 3.1, - "Initializing the Xerces-C++ Runtime". -

- -

The mapping for any is similar to the mapping for - local elements (see Section 2.8, "Mapping for Local - Elements and Attributes") except that the type used in the - wildcard mapping is xercesc::DOMElement. As with local - elements, the mapping divides all possible cardinality combinations - into three cardinality classes: one, optional, and - sequence. -

- -

The mapping for anyAttribute represents the attributes - matched by this wildcard as a set of xercesc::DOMAttr - objects with a key being the attribute's name and namespace.

- -

Similar to local elements and attributes, the any and - anyAttribute wildcards are mapped to a set of public type - definitions (typedefs) and a set of public accessor and modifier - functions. Type definitions have names derived from "any" - for the any wildcard and "any_attribute" - for the anyAttribute wildcard. The accessor and modifier - functions are named "any" for the any wildcard - and "any_attribute" for the anyAttribute - wildcard. Subsequent wildcards in the same type have escaped names - such as "any1" or "any_attribute1". -

- -

Because Xerces-C++ DOM nodes always belong to a DOMDocument, - each type with a wildcard has an associated DOMDocument - object. The reference to this object can be obtained using the accessor - function called dom_document. The access to the document - object from the application code may be necessary to create or modify - the wildcard content. For example: -

- -
-<complexType name="object">
-  <sequence>
-    <any namespace="##other"/>
-  </sequence>
-  <anyAttribute namespace="##other"/>
-</complexType>
-  
- -

is mapped to:

- -
-class object: public xml_schema::type
-{
-public:
-  // any
-  //
-  const xercesc::DOMElement&
-  any () const;
-
-  void
-  any (const xercesc::DOMElement&);
-
-  ...
-
-  // any_attribute
-  //
-  typedef attribute_set any_attribute_set;
-  typedef any_attribute_set::iterator any_attribute_iterator;
-  typedef any_attribute_set::const_iterator any_attribute_const_iterator;
-
-  const any_attribute_set&
-  any_attribute () const;
-
-  any_attribute_set&
-  any_attribute ();
-
-  ...
-
-  // DOMDocument object for wildcard content.
-  //
-  const xercesc::DOMDocument&
-  dom_document () const;
-
-  xercesc::DOMDocument&
-  dom_document ();
-
-  ...
-};
-  
- - -

Names and semantics of type definitions for the wildcards as well - as signatures of the accessor and modifier functions depend on the - wildcard type as well as the cardinality class for the any - wildcard. They are described in the following sub-sections. -

- - -

2.12.1 Mapping for any with the One Cardinality Class

- -

For any with the One cardinality class, - there are no type definitions. The accessor functions come in - constant and non-constant versions. The constant accessor function - returns a constant reference to xercesc::DOMElement and - can be used for read-only access. The non-constant version returns - an unrestricted reference to xercesc::DOMElement and can - be used for read-write access. -

- -

The first modifier function expects an argument of type reference - to constant xercesc::DOMElement and makes a deep copy - of its argument. The second modifier function expects an argument of - type pointer to xercesc::DOMElement. This modifier - function assumes ownership of its argument and expects the element - object to be created using the DOM document associated with this - instance. For example: -

- -
-<complexType name="object">
-  <sequence>
-    <any namespace="##other"/>
-  </sequence>
-</complexType>
-  
- -

is mapped to:

- -
-class object: public xml_schema::type
-{
-public:
-  // Accessors.
-  //
-  const xercesc::DOMElement&
-  any () const;
-
-  xercesc::DOMElement&
-  any ();
-
-  // Modifiers.
-  //
-  void
-  any (const xercesc::DOMElement&);
-
-  void
-  any (xercesc::DOMElement*);
-
-  ...
-
-};
-  
- - -

The following code shows how one could use this mapping:

- -
-void
-f (object& o, const xercesc::DOMElement& e)
-{
-  using namespace xercesc;
-
-  DOMElement& e1 (o.any ());             // get
-  o.any (e)                              // set, deep copy
-  DOMDocument& doc (o.dom_document ());
-  o.any (doc.createElement (...));       // set, assumes ownership
-}
-  
- -

2.12.2 Mapping for any with the Optional Cardinality Class

- -

For any with the Optional cardinality class, the type - definitions consist of an alias for the container type with name - any_optional (or any1_optional, etc., for - subsequent wildcards in the type definition). -

- -

Unlike accessor functions for the One cardinality class, accessor - functions for the Optional cardinality class return references to - corresponding containers rather than directly to DOMElement. - The accessor functions come in constant and non-constant versions. - The constant accessor function returns a constant reference to - the container and can be used for read-only access. The non-constant - version returns an unrestricted reference to the container - and can be used for read-write access. -

- -

The modifier functions are overloaded for xercesc::DOMElement - and the container type. The first modifier function expects an argument of - type reference to constant xercesc::DOMElement and - makes a deep copy of its argument. The second modifier function - expects an argument of type pointer to xercesc::DOMElement. - This modifier function assumes ownership of its argument and expects - the element object to be created using the DOM document associated - with this instance. The third modifier function expects an argument - of type reference to constant of the container type and makes a - deep copy of its argument. For instance: -

- -
-<complexType name="object">
-  <sequence>
-    <any namespace="##other" minOccurs="0"/>
-  </sequence>
-</complexType>
-  
- -

is mapped to:

- -
-class object: public xml_schema::type
-{
-public:
-  // Type definitions.
-  //
-  typedef element_optional any_optional;
-
-  // Accessors.
-  //
-  const any_optional&
-  any () const;
-
-  any_optional&
-  any ();
-
-  // Modifiers.
-  //
-  void
-  any (const xercesc::DOMElement&);
-
-  void
-  any (xercesc::DOMElement*);
-
-  void
-  any (const any_optional&);
-
-  ...
-
-};
-  
- - -

The element_optional container is a - specialization of the optional class template described - in Section 2.8.2, "Mapping for Members with the Optional - Cardinality Class". Its interface is presented below: -

- -
-class element_optional
-{
-public:
-  explicit
-  element_optional (xercesc::DOMDocument&);
-
-  // Makes a deep copy.
-  //
-  element_optional (const xercesc::DOMElement&, xercesc::DOMDocument&);
-
-  // Assumes ownership.
-  //
-  element_optional (xercesc::DOMElement*, xercesc::DOMDocument&);
-
-  element_optional (const element_optional&, xercesc::DOMDocument&);
-
-public:
-  element_optional&
-  operator= (const xercesc::DOMElement&);
-
-  element_optional&
-  operator= (const element_optional&);
-
-  // Pointer-like interface.
-  //
-public:
-  const xercesc::DOMElement*
-  operator-> () const;
-
-  xercesc::DOMElement*
-  operator-> ();
-
-  const xercesc::DOMElement&
-  operator* () const;
-
-  xercesc::DOMElement&
-  operator* ();
-
-  typedef void (element_optional::*bool_convertible) ();
-  operator bool_convertible () const;
-
-  // Get/set interface.
-  //
-public:
-  bool
-  present () const;
-
-  const xercesc::DOMElement&
-  get () const;
-
-  xercesc::DOMElement&
-  get ();
-
-  // Makes a deep copy.
-  //
-  void
-  set (const xercesc::DOMElement&);
-
-  // Assumes ownership.
-  //
-  void
-  set (xercesc::DOMElement*);
-
-  void
-  reset ();
-};
-
-bool
-operator== (const element_optional&, const element_optional&);
-
-bool
-operator!= (const element_optional&, const element_optional&);
-  
- - -

The following code shows how one could use this mapping:

- -
-void
-f (object& o, const xercesc::DOMElement& e)
-{
-  using namespace xercesc;
-
-  DOMDocument& doc (o.dom_document ());
-
-  if (o.any ().present ())                  // test
-  {
-    DOMElement& e1 (o.any ().get ());       // get
-    o.any ().set (e);                       // set, deep copy
-    o.any ().set (doc.createElement (...)); // set, assumes ownership
-    o.any ().reset ();                      // reset
-  }
-
-  // Same as above but using pointer notation:
-  //
-  if (o.member ())                          // test
-  {
-    DOMElement& e1 (*o.any ());             // get
-    o.any (e);                              // set, deep copy
-    o.any (doc.createElement (...));        // set, assumes ownership
-    o.any ().reset ();                      // reset
-  }
-}
-  
- - - -

2.12.3 Mapping for any with the Sequence Cardinality Class

- -

For any with the Sequence cardinality class, the type - definitions consist of an alias of the container type with name - any_sequence (or any1_sequence, etc., for - subsequent wildcards in the type definition), an alias of the iterator - type with name any_iterator (or any1_iterator, - etc., for subsequent wildcards in the type definition), and an alias - of the constant iterator type with name any_const_iterator - (or any1_const_iterator, etc., for subsequent wildcards - in the type definition). -

- -

The accessor functions come in constant and non-constant versions. - The constant accessor function returns a constant reference to the - container and can be used for read-only access. The non-constant - version returns an unrestricted reference to the container and can - be used for read-write access. -

- -

The modifier function expects an argument of type reference to - constant of the container type. The modifier function makes - a deep copy of its argument. For instance: -

- - -
-<complexType name="object">
-  <sequence>
-    <any namespace="##other" minOccurs="unbounded"/>
-  </sequence>
-</complexType>
-  
- -

is mapped to:

- -
-class object: public xml_schema::type
-{
-public:
-  // Type definitions.
-  //
-  typedef element_sequence any_sequence;
-  typedef any_sequence::iterator any_iterator;
-  typedef any_sequence::const_iterator any_const_iterator;
-
-  // Accessors.
-  //
-  const any_sequence&
-  any () const;
-
-  any_sequence&
-  any ();
-
-  // Modifier.
-  //
-  void
-  any (const any_sequence&);
-
-  ...
-
-};
-  
- -

The element_sequence container is a - specialization of the sequence class template described - in Section 2.8.3, "Mapping for Members with the - Sequence Cardinality Class". Its interface is similar to - the sequence interface as defined by the ISO/ANSI Standard for - C++ (ISO/IEC 14882:1998, Section 23.1.1, "Sequences") and is - presented below: -

- -
-class element_sequence
-{
-public:
-  typedef xercesc::DOMElement        value_type;
-  typedef xercesc::DOMElement*       pointer;
-  typedef const xercesc::DOMElement* const_pointer;
-  typedef xercesc::DOMElement&       reference;
-  typedef const xercesc::DOMElement& const_reference;
-
-  typedef <implementation-defined>   iterator;
-  typedef <implementation-defined>   const_iterator;
-  typedef <implementation-defined>   reverse_iterator;
-  typedef <implementation-defined>   const_reverse_iterator;
-
-  typedef <implementation-defined>   size_type;
-  typedef <implementation-defined>   difference_type;
-  typedef <implementation-defined>   allocator_type;
-
-public:
-  explicit
-  element_sequence (xercesc::DOMDocument&);
-
-  // DOMElement cannot be default-constructed.
-  //
-  // explicit
-  // element_sequence (size_type n);
-
-  element_sequence (size_type n,
-                    const xercesc::DOMElement&,
-                    xercesc::DOMDocument&);
-
-  template <typename I>
-  element_sequence (const I& begin,
-                    const I& end,
-                    xercesc::DOMDocument&);
-
-  element_sequence (const element_sequence&, xercesc::DOMDocument&);
-
-  element_sequence&
-  operator= (const element_sequence&);
-
-public:
-  void
-  assign (size_type n, const xercesc::DOMElement&);
-
-  template <typename I>
-  void
-  assign (const I& begin, const I& end);
-
-public:
-  // This version of resize can only be used to shrink the
-  // sequence because DOMElement cannot be default-constructed.
-  //
-  void
-  resize (size_type);
-
-  void
-  resize (size_type, const xercesc::DOMElement&);
-
-public:
-  size_type
-  size () const;
-
-  size_type
-  max_size () const;
-
-  size_type
-  capacity () const;
-
-  bool
-  empty () const;
-
-  void
-  reserve (size_type);
-
-  void
-  clear ();
-
-public:
-  const_iterator
-  begin () const;
-
-  const_iterator
-  end () const;
-
-  iterator
-  begin ();
-
-  iterator
-  end ();
-
-  const_reverse_iterator
-  rbegin () const;
-
-  const_reverse_iterator
-  rend () const
-
-    reverse_iterator
-  rbegin ();
-
-  reverse_iterator
-  rend ();
-
-public:
-  xercesc::DOMElement&
-  operator[] (size_type);
-
-  const xercesc::DOMElement&
-  operator[] (size_type) const;
-
-  xercesc::DOMElement&
-  at (size_type);
-
-  const xercesc::DOMElement&
-  at (size_type) const;
-
-  xercesc::DOMElement&
-  front ();
-
-  const xercesc::DOMElement&
-  front () const;
-
-  xercesc::DOMElement&
-  back ();
-
-  const xercesc::DOMElement&
-  back () const;
-
-public:
-  // Makes a deep copy.
-  //
-  void
-  push_back (const xercesc::DOMElement&);
-
-  // Assumes ownership.
-  //
-  void
-  push_back (xercesc::DOMElement*);
-
-  void
-  pop_back ();
-
-  // Makes a deep copy.
-  //
-  iterator
-  insert (iterator position, const xercesc::DOMElement&);
-
-  // Assumes ownership.
-  //
-  iterator
-  insert (iterator position, xercesc::DOMElement*);
-
-  void
-  insert (iterator position, size_type n, const xercesc::DOMElement&);
-
-  template <typename I>
-  void
-  insert (iterator position, const I& begin, const I& end);
-
-  iterator
-  erase (iterator position);
-
-  iterator
-  erase (iterator begin, iterator end);
-
-public:
-  // Note that the DOMDocument object of the two sequences being
-  // swapped should be the same.
-  //
-  void
-  swap (sequence& x);
-};
-
-inline bool
-operator== (const element_sequence&, const element_sequence&);
-
-inline bool
-operator!= (const element_sequence&, const element_sequence&);
-  
- - -

The following code shows how one could use this mapping:

- -
-void
-f (object& o, const xercesc::DOMElement& e)
-{
-  using namespace xercesc;
-
-  object::any_sequence& s (o.any ());
-
-  // Iteration.
-  //
-  for (object::any_iterator i (s.begin ()); i != s.end (); ++i)
-  {
-    DOMElement& e (*i);
-  }
-
-  // Modification.
-  //
-  s.push_back (e);                       // deep copy
-  DOMDocument& doc (o.dom_document ());
-  s.push_back (doc.createElement (...)); // assumes ownership
-}
-  
- -

2.12.4 Element Wildcard Order

- -

Similar to elements, element wildcards in ordered types - (Section 2.8.4, "Element Order") are assigned - content ids and are included in the content order sequence. - Continuing with the bank transactions example started in Section - 2.8.4, we can extend the batch by allowing custom transactions:

- -
-<complexType name="batch">
-  <choice minOccurs="0" maxOccurs="unbounded">
-    <element name="withdraw" type="withdraw"/>
-    <element name="deposit" type="deposit"/>
-    <any namespace="##other" processContents="lax"/>
-  </choice>
-</complexType>
-  
- -

This will lead to the following changes in the generated - batch C++ class:

- -
-class batch: public xml_schema::type
-{
-public:
-  ...
-
-  // any
-  //
-  typedef element_sequence any_sequence;
-  typedef any_sequence::iterator any_iterator;
-  typedef any_sequence::const_iterator any_const_iterator;
-
-  static const std::size_t any_id = 3UL;
-
-  const any_sequence&
-  any () const;
-
-  any_sequence&
-  any ();
-
-  void
-  any (const any_sequence&);
-
-  ...
-};
-  
- -

With this change we also need to update the iteration code to handle - the new content id:

- -
-for (batch::content_order_const_iterator i (b.content_order ().begin ());
-     i != b.content_order ().end ();
-     ++i)
-{
-  switch (i->id)
-  {
-    ...
-
-  case batch::any_id:
-    {
-      const DOMElement& e (b.any ()[i->index]);
-      ...
-      break;
-    }
-
-    ...
-  }
-}
-  
- -

For the complete working code that shows the use of wildcards in - ordered types refer to the order/element example in - the examples/cxx/tree/ directory in the XSD - distribution.

- -

2.12.5 Mapping for anyAttribute

- -

For anyAttribute the type definitions consist of an alias - of the container type with name any_attribute_set - (or any1_attribute_set, etc., for subsequent wildcards - in the type definition), an alias of the iterator type with name - any_attribute_iterator (or any1_attribute_iterator, - etc., for subsequent wildcards in the type definition), and an alias - of the constant iterator type with name any_attribute_const_iterator - (or any1_attribute_const_iterator, etc., for subsequent - wildcards in the type definition). -

- -

The accessor functions come in constant and non-constant versions. - The constant accessor function returns a constant reference to the - container and can be used for read-only access. The non-constant - version returns an unrestricted reference to the container and can - be used for read-write access. -

- -

The modifier function expects an argument of type reference to - constant of the container type. The modifier function makes - a deep copy of its argument. For instance: -

- - -
-<complexType name="object">
-  <sequence>
-    ...
-  </sequence>
-  <anyAttribute namespace="##other"/>
-</complexType>
-  
- -

is mapped to:

- -
-class object: public xml_schema::type
-{
-public:
-  // Type definitions.
-  //
-  typedef attribute_set any_attribute_set;
-  typedef any_attribute_set::iterator any_attribute_iterator;
-  typedef any_attribute_set::const_iterator any_attribute_const_iterator;
-
-  // Accessors.
-  //
-  const any_attribute_set&
-  any_attribute () const;
-
-  any_attribute_set&
-  any_attribute ();
-
-  // Modifier.
-  //
-  void
-  any_attribute (const any_attribute_set&);
-
-  ...
-
-};
-  
- -

The attribute_set class is an associative container - similar to the std::set class template as defined by - the ISO/ANSI Standard for C++ (ISO/IEC 14882:1998, Section 23.3.3, - "Class template set") with the key being the attribute's name - and namespace. Unlike std::set, attribute_set - allows searching using names and namespaces instead of - xercesc::DOMAttr objects. It is defined in an - implementation-specific namespace and its interface is presented - below: -

- -
-class attribute_set
-{
-public:
-  typedef xercesc::DOMAttr         key_type;
-  typedef xercesc::DOMAttr         value_type;
-  typedef xercesc::DOMAttr*        pointer;
-  typedef const xercesc::DOMAttr*  const_pointer;
-  typedef xercesc::DOMAttr&        reference;
-  typedef const xercesc::DOMAttr&  const_reference;
-
-  typedef <implementation-defined> iterator;
-  typedef <implementation-defined> const_iterator;
-  typedef <implementation-defined> reverse_iterator;
-  typedef <implementation-defined> const_reverse_iterator;
-
-  typedef <implementation-defined> size_type;
-  typedef <implementation-defined> difference_type;
-  typedef <implementation-defined> allocator_type;
-
-public:
-  attribute_set (xercesc::DOMDocument&);
-
-  template <typename I>
-  attribute_set (const I& begin, const I& end, xercesc::DOMDocument&);
-
-  attribute_set (const attribute_set&, xercesc::DOMDocument&);
-
-  attribute_set&
-  operator= (const attribute_set&);
-
-public:
-  const_iterator
-  begin () const;
-
-  const_iterator
-  end () const;
-
-  iterator
-  begin ();
-
-  iterator
-  end ();
-
-  const_reverse_iterator
-  rbegin () const;
-
-  const_reverse_iterator
-  rend () const;
-
-  reverse_iterator
-  rbegin ();
-
-  reverse_iterator
-  rend ();
-
-public:
-  size_type
-  size () const;
-
-  size_type
-  max_size () const;
-
-  bool
-  empty () const;
-
-  void
-  clear ();
-
-public:
-  // Makes a deep copy.
-  //
-  std::pair<iterator, bool>
-  insert (const xercesc::DOMAttr&);
-
-  // Assumes ownership.
-  //
-  std::pair<iterator, bool>
-  insert (xercesc::DOMAttr*);
-
-  // Makes a deep copy.
-  //
-  iterator
-  insert (iterator position, const xercesc::DOMAttr&);
-
-  // Assumes ownership.
-  //
-  iterator
-  insert (iterator position, xercesc::DOMAttr*);
-
-  template <typename I>
-  void
-  insert (const I& begin, const I& end);
-
-public:
-  void
-  erase (iterator position);
-
-  size_type
-  erase (const std::basic_string<C>& name);
-
-  size_type
-  erase (const std::basic_string<C>& namespace_,
-         const std::basic_string<C>& name);
-
-  size_type
-  erase (const XMLCh* name);
-
-  size_type
-  erase (const XMLCh* namespace_, const XMLCh* name);
-
-  void
-  erase (iterator begin, iterator end);
-
-public:
-  size_type
-  count (const std::basic_string<C>& name) const;
-
-  size_type
-  count (const std::basic_string<C>& namespace_,
-         const std::basic_string<C>& name) const;
-
-  size_type
-  count (const XMLCh* name) const;
-
-  size_type
-  count (const XMLCh* namespace_, const XMLCh* name) const;
-
-  iterator
-  find (const std::basic_string<C>& name);
-
-  iterator
-  find (const std::basic_string<C>& namespace_,
-        const std::basic_string<C>& name);
-
-  iterator
-  find (const XMLCh* name);
-
-  iterator
-  find (const XMLCh* namespace_, const XMLCh* name);
-
-  const_iterator
-  find (const std::basic_string<C>& name) const;
-
-  const_iterator
-  find (const std::basic_string<C>& namespace_,
-        const std::basic_string<C>& name) const;
-
-  const_iterator
-  find (const XMLCh* name) const;
-
-  const_iterator
-  find (const XMLCh* namespace_, const XMLCh* name) const;
-
-public:
-  // Note that the DOMDocument object of the two sets being
-  // swapped should be the same.
-  //
-  void
-  swap (attribute_set&);
-};
-
-bool
-operator== (const attribute_set&, const attribute_set&);
-
-bool
-operator!= (const attribute_set&, const attribute_set&);
-  
- -

The following code shows how one could use this mapping:

- -
-void
-f (object& o, const xercesc::DOMAttr& a)
-{
-  using namespace xercesc;
-
-  object::any_attribute_set& s (o.any_attribute ());
-
-  // Iteration.
-  //
-  for (object::any_attribute_iterator i (s.begin ()); i != s.end (); ++i)
-  {
-    DOMAttr& a (*i);
-  }
-
-  // Modification.
-  //
-  s.insert (a);                         // deep copy
-  DOMDocument& doc (o.dom_document ());
-  s.insert (doc.createAttribute (...)); // assumes ownership
-
-  // Searching.
-  //
-  object::any_attribute_iterator i (s.find ("name"));
-  i = s.find ("http://www.w3.org/XML/1998/namespace", "lang");
-}
-  
- - - -

2.13 Mapping for Mixed Content Models

- -

For XML Schema types with mixed content models C++/Tree provides - mapping support only if the type is marked as ordered - (Section 2.8.4, "Element Order"). Use the - --ordered-type-mixed XSD compiler option to - automatically mark all types with mixed content as ordered.

- -

For an ordered type with mixed content, C++/Tree adds an extra - text content sequence that is used to store the text fragments. - This text content sequence is also assigned the content id and - its entries are included in the content order sequence, just - like elements. As a result, it is possible to capture the order - between elements and text fragments.

- -

As an example, consider the following schema that describes text - with embedded links:

- -
-<complexType name="anchor">
-  <simpleContent>
-    <extension base="string">
-      <attribute name="href" type="anyURI" use="required"/>
-    </extension>
-  </simpleContent>
-</complexType>
-
-<complexType name="text" mixed="true">
-  <sequence>
-    <element name="a" type="anchor" minOccurs="0" maxOccurs="unbounded"/>
-  </sequence>
-</complexType>
-  
- -

The generated text C++ class will provide the following - API (assuming it is marked as ordered):

- -
-class text: public xml_schema::type
-{
-public:
-  // a
-  //
-  typedef anchor a_type;
-  typedef sequence<a_type> a_sequence;
-  typedef a_sequence::iterator a_iterator;
-  typedef a_sequence::const_iterator a_const_iterator;
-
-  static const std::size_t a_id = 1UL;
-
-  const a_sequence&
-  a () const;
-
-  a_sequence&
-  a ();
-
-  void
-  a (const a_sequence&);
-
-  // text_content
-  //
-  typedef xml_schema::string text_content_type;
-  typedef sequence<text_content_type> text_content_sequence;
-  typedef text_content_sequence::iterator text_content_iterator;
-  typedef text_content_sequence::const_iterator text_content_const_iterator;
-
-  static const std::size_t text_content_id = 2UL;
-
-  const text_content_sequence&
-  text_content () const;
-
-  text_content_sequence&
-  text_content ();
-
-  void
-  text_content (const text_content_sequence&);
-
-  // content_order
-  //
-  typedef xml_schema::content_order content_order_type;
-  typedef std::vector<content_order_type> content_order_sequence;
-  typedef content_order_sequence::iterator content_order_iterator;
-  typedef content_order_sequence::const_iterator content_order_const_iterator;
-
-  const content_order_sequence&
-  content_order () const;
-
-  content_order_sequence&
-  content_order ();
-
-  void
-  content_order (const content_order_sequence&);
-
-  ...
-};
-  
- -

Given this interface we can iterate over both link elements - and text in content order. The following code fragment converts - our format to plain text with references.

- -
-const text& t = ...
-
-for (text::content_order_const_iterator i (t.content_order ().begin ());
-     i != t.content_order ().end ();
-     ++i)
-{
-  switch (i->id)
-  {
-  case text::a_id:
-    {
-      const anchor& a (t.a ()[i->index]);
-      cerr << a << "[" << a.href () << "]";
-      break;
-    }
-  case text::text_content_id:
-    {
-      const xml_schema::string& s (t.text_content ()[i->index]);
-      cerr << s;
-      break;
-    }
-  default:
-    {
-      assert (false); // Unknown content id.
-    }
-  }
-}
-  
- -

For the complete working code that shows the use of mixed content - in ordered types refer to the order/mixed example in - the examples/cxx/tree/ directory in the XSD - distribution.

- - - - -

3 Parsing

- -

This chapter covers various aspects of parsing XML instance - documents in order to obtain corresponding tree-like object - model. -

- -

Each global XML Schema element in the form:

- -
-<element name="name" type="type"/>
-  
- -

is mapped to 14 overloaded C++ functions in the form:

- -
-// Read from a URI or a local file.
-//
-
-std::[auto|unique]_ptr<type>
-name (const std::basic_string<C>& uri,
-      xml_schema::flags = 0,
-      const xml_schema::properties& = xml_schema::properties ());
-
-std::[auto|unique]_ptr<type>
-name (const std::basic_string<C>& uri,
-      xml_schema::error_handler&,
-      xml_schema::flags = 0,
-      const xml_schema::properties& = xml_schema::properties ());
-
-std::[auto|unique]_ptr<type>
-name (const std::basic_string<C>& uri,
-      xercesc::DOMErrorHandler&,
-      xml_schema::flags = 0,
-      const xml_schema::properties& = xml_schema::properties ());
-
-
-// Read from std::istream.
-//
-
-std::[auto|unique]_ptr<type>
-name (std::istream&,
-      xml_schema::flags = 0,
-      const xml_schema::properties& = xml_schema::properties ());
-
-std::[auto|unique]_ptr<type>
-name (std::istream&,
-      xml_schema::error_handler&,
-      xml_schema::flags = 0,
-      const xml_schema::properties& = xml_schema::properties ());
-
-std::[auto|unique]_ptr<type>
-name (std::istream&,
-      xercesc::DOMErrorHandler&,
-      xml_schema::flags = 0,
-      const xml_schema::properties& = xml_schema::properties ());
-
-
-std::[auto|unique]_ptr<type>
-name (std::istream&,
-      const std::basic_string<C>& id,
-      xml_schema::flags = 0,
-      const xml_schema::properties& = xml_schema::properties ());
-
-std::[auto|unique]_ptr<type>
-name (std::istream&,
-      const std::basic_string<C>& id,
-      xml_schema::error_handler&,
-      xml_schema::flags = 0,
-      const xml_schema::properties& = xml_schema::properties ());
-
-std::[auto|unique]_ptr<type>
-name (std::istream&,
-      const std::basic_string<C>& id,
-      xercesc::DOMErrorHandler&,
-      xml_schema::flags = 0,
-      const xml_schema::properties& = xml_schema::properties ());
-
-
-// Read from InputSource.
-//
-
-std::[auto|unique]_ptr<type>
-name (xercesc::InputSource&,
-      xml_schema::flags = 0,
-      const xml_schema::properties& = xml_schema::properties ());
-
-std::[auto|unique]_ptr<type>
-name (xercesc::InputSource&,
-      xml_schema::error_handler&,
-      xml_schema::flags = 0,
-      const xml_schema::properties& = xml_schema::properties ());
-
-std::[auto|unique]_ptr<type>
-name (xercesc::InputSource&,
-      xercesc::DOMErrorHandler&,
-      xml_schema::flags = 0,
-      const xml_schema::properties& = xml_schema::properties ());
-
-
-// Read from DOM.
-//
-
-std::[auto|unique]_ptr<type>
-name (const xercesc::DOMDocument&,
-      xml_schema::flags = 0,
-      const xml_schema::properties& = xml_schema::properties ());
-
-std::[auto|unique]_ptr<type>
-name (xml_schema::dom::[auto|unique]_ptr<xercesc::DOMDocument>,
-      xml_schema::flags = 0,
-      const xml_schema::properties& = xml_schema::properties ());
-  
- -

You can choose between reading an XML instance from a local file, - URI, std::istream, xercesc::InputSource, - or a pre-parsed DOM instance in the form of - xercesc::DOMDocument. All the parsing functions - return a dynamically allocated object model as either - std::auto_ptr or std::unique_ptr, - depending on the C++ standard selected. Each of these parsing - functions is discussed in more detail in the following sections. -

- -

3.1 Initializing the Xerces-C++ Runtime

- -

Some parsing functions expect you to initialize the Xerces-C++ - runtime while others initialize and terminate it as part of their - work. The general rule is as follows: if a function has any arguments - or return a value that is an instance of a Xerces-C++ type, then - this function expects you to initialize the Xerces-C++ runtime. - Otherwise, the function initializes and terminates the runtime for - you. Note that it is legal to have nested calls to the Xerces-C++ - initialize and terminate functions as long as the calls are balanced. -

- -

You can instruct parsing functions that initialize and terminate - the runtime not to do so by passing the - xml_schema::flags::dont_initialize flag (see - Section 3.2, "Flags and Properties"). -

- - -

3.2 Flags and Properties

- -

Parsing flags and properties are the last two arguments of every - parsing function. They allow you to fine-tune the process of - instance validation and parsing. Both arguments are optional. -

- - -

The following flags are recognized by the parsing functions:

- -
-
xml_schema::flags::keep_dom
-
Keep association between DOM nodes and the resulting - object model nodes. For more information about DOM association - refer to Section 5.1, "DOM Association".
- -
xml_schema::flags::own_dom
-
Assume ownership of the DOM document passed. This flag only - makes sense together with the keep_dom flag in - the call to the parsing function with the - xml_schema::dom::[auto|unique]_ptr<DOMDocument> - argument.
- -
xml_schema::flags::dont_validate
-
Do not validate instance documents against schemas.
- -
xml_schema::flags::dont_initialize
-
Do not initialize the Xerces-C++ runtime.
-
- -

You can pass several flags by combining them using the bit-wise OR - operator. For example:

- -
-using xml_schema::flags;
-
-std::auto_ptr<type> r (
-  name ("test.xml", flags::keep_dom | flags::dont_validate));
-  
- -

By default, validation of instance documents is turned on even - though parsers generated by XSD do not assume instance - documents are valid. They include a number of checks that prevent - construction of inconsistent object models. This, - however, does not mean that an instance document that was - successfully parsed by the XSD-generated parsers is - valid per the corresponding schema. If an instance document is not - "valid enough" for the generated parsers to construct consistent - object model, one of the exceptions defined in - xml_schema namespace is thrown (see - Section 3.3, "Error Handling"). -

- -

For more information on the Xerces-C++ runtime initialization - refer to Section 3.1, "Initializing the Xerces-C++ - Runtime". -

- -

The xml_schema::properties class allows you to - programmatically specify schema locations to be used instead - of those specified with the xsi::schemaLocation - and xsi::noNamespaceSchemaLocation attributes - in instance documents. The interface of the properties - class is presented below: -

- -
-class properties
-{
-public:
-  void
-  schema_location (const std::basic_string<C>& namespace_,
-                   const std::basic_string<C>& location);
-  void
-  no_namespace_schema_location (const std::basic_string<C>& location);
-};
-  
- -

Note that all locations are relative to an instance document unless - they are URIs. For example, if you want to use a local file as your - schema, then you will need to pass - file:///absolute/path/to/your/schema as the location - argument. -

- -

3.3 Error Handling

- -

As discussed in Section 2.2, "Error Handling", - the mapping uses the C++ exception handling mechanism as its primary - way of reporting error conditions. However, to handle recoverable - parsing and validation errors and warnings, a callback interface maybe - preferred by the application.

- -

To better understand error handling and reporting strategies employed - by the parsing functions, it is useful to know that the - transformation of an XML instance document to a statically-typed - tree happens in two stages. The first stage, performed by Xerces-C++, - consists of parsing an XML document into a DOM instance. For short, - we will call this stage the XML-DOM stage. Validation, if not disabled, - happens during this stage. The second stage, - performed by the generated parsers, consist of parsing the DOM - instance into the statically-typed tree. We will call this stage - the DOM-Tree stage. Additional checks are performed during this - stage in order to prevent construction of inconsistent tree which - could otherwise happen when validation is disabled, for example.

- -

All parsing functions except the one that operates on a DOM instance - come in overloaded triples. The first function in such a triple - reports error conditions exclusively by throwing exceptions. It - accumulates all the parsing and validation errors of the XML-DOM - stage and throws them in a single instance of the - xml_schema::parsing exception (described below). - The second and the third functions in the triple use callback - interfaces to report parsing and validation errors and warnings. - The two callback interfaces are xml_schema::error_handler - and xercesc::DOMErrorHandler. For more information - on the xercesc::DOMErrorHandler interface refer to - the Xerces-C++ documentation. The xml_schema::error_handler - interface is presented below: -

- -
-class error_handler
-{
-public:
-  struct severity
-  {
-    enum value
-    {
-      warning,
-      error,
-      fatal
-    };
-  };
-
-  virtual bool
-  handle (const std::basic_string<C>& id,
-          unsigned long line,
-          unsigned long column,
-          severity,
-          const std::basic_string<C>& message) = 0;
-
-  virtual
-  ~error_handler ();
-};
-  
- -

The id argument of the error_handler::handle - function identifies the resource being parsed (e.g., a file name or - URI). -

- -

By returning true from the handle function - you instruct the parser to recover and continue parsing. Returning - false results in termination of the parsing process. - An error with the fatal severity level results in - termination of the parsing process no matter what is returned from - the handle function. It is safe to throw an exception - from the handle function. -

- -

The DOM-Tree stage reports error conditions exclusively by throwing - exceptions. Individual exceptions thrown by the parsing functions - are described in the following sub-sections. -

- - -

3.3.1 xml_schema::parsing

- -
-struct severity
-{
-  enum value
-  {
-    warning,
-    error
-  };
-
-  severity (value);
-  operator value () const;
-};
-
-struct error
-{
-  error (severity,
-         const std::basic_string<C>& id,
-         unsigned long line,
-         unsigned long column,
-         const std::basic_string<C>& message);
-
-  severity
-  severity () const;
-
-  const std::basic_string<C>&
-  id () const;
-
-  unsigned long
-  line () const;
-
-  unsigned long
-  column () const;
-
-  const std::basic_string<C>&
-  message () const;
-};
-
-std::basic_ostream<C>&
-operator<< (std::basic_ostream<C>&, const error&);
-
-struct diagnostics: std::vector<error>
-{
-};
-
-std::basic_ostream<C>&
-operator<< (std::basic_ostream<C>&, const diagnostics&);
-
-struct parsing: virtual exception
-{
-  parsing ();
-  parsing (const diagnostics&);
-
-  const diagnostics&
-  diagnostics () const;
-
-  virtual const char*
-  what () const throw ();
-};
-  
- -

The xml_schema::parsing exception is thrown if there - were parsing or validation errors reported during the XML-DOM stage. - If no callback interface was provided to the parsing function, the - exception contains a list of errors and warnings accessible using - the diagnostics function. The usual conditions when - this exception is thrown include malformed XML instances and, if - validation is turned on, invalid instance documents. -

- -

3.3.2 xml_schema::expected_element

- -
-struct expected_element: virtual exception
-{
-  expected_element (const std::basic_string<C>& name,
-                    const std::basic_string<C>& namespace_);
-
-
-  const std::basic_string<C>&
-  name () const;
-
-  const std::basic_string<C>&
-  namespace_ () const;
-
-
-  virtual const char*
-  what () const throw ();
-};
-  
- -

The xml_schema::expected_element exception is thrown - when an expected element is not encountered by the DOM-Tree stage. - The name and namespace of the expected element can be obtained using - the name and namespace_ functions respectively. -

- - -

3.3.3 xml_schema::unexpected_element

- -
-struct unexpected_element: virtual exception
-{
-  unexpected_element (const std::basic_string<C>& encountered_name,
-                      const std::basic_string<C>& encountered_namespace,
-                      const std::basic_string<C>& expected_name,
-                      const std::basic_string<C>& expected_namespace)
-
-
-  const std::basic_string<C>&
-  encountered_name () const;
-
-  const std::basic_string<C>&
-  encountered_namespace () const;
-
-
-  const std::basic_string<C>&
-  expected_name () const;
-
-  const std::basic_string<C>&
-  expected_namespace () const;
-
-
-  virtual const char*
-  what () const throw ();
-};
-  
- -

The xml_schema::unexpected_element exception is thrown - when an unexpected element is encountered by the DOM-Tree stage. - The name and namespace of the encountered element can be obtained - using the encountered_name and - encountered_namespace functions respectively. If an - element was expected instead of the encountered one, its name - and namespace can be obtained using the expected_name and - expected_namespace functions respectively. Otherwise - these functions return empty strings. -

- -

3.3.4 xml_schema::expected_attribute

- -
-struct expected_attribute: virtual exception
-{
-  expected_attribute (const std::basic_string<C>& name,
-                      const std::basic_string<C>& namespace_);
-
-
-  const std::basic_string<C>&
-  name () const;
-
-  const std::basic_string<C>&
-  namespace_ () const;
-
-
-  virtual const char*
-  what () const throw ();
-};
-  
- -

The xml_schema::expected_attribute exception is thrown - when an expected attribute is not encountered by the DOM-Tree stage. - The name and namespace of the expected attribute can be obtained using - the name and namespace_ functions respectively. -

- - -

3.3.5 xml_schema::unexpected_enumerator

- -
-struct unexpected_enumerator: virtual exception
-{
-  unexpected_enumerator (const std::basic_string<C>& enumerator);
-
-  const std::basic_string<C>&
-  enumerator () const;
-
-  virtual const char*
-  what () const throw ();
-};
-  
- -

The xml_schema::unexpected_enumerator exception is thrown - when an unexpected enumerator is encountered by the DOM-Tree stage. - The enumerator can be obtained using the enumerator - functions. -

- -

3.3.6 xml_schema::expected_text_content

- -
-struct expected_text_content: virtual exception
-{
-  virtual const char*
-  what () const throw ();
-};
-  
- -

The xml_schema::expected_text_content exception is thrown - when a content other than text is encountered and the text content was - expected by the DOM-Tree stage. -

- -

3.3.7 xml_schema::no_type_info

- -
-struct no_type_info: virtual exception
-{
-  no_type_info (const std::basic_string<C>& type_name,
-                const std::basic_string<C>& type_namespace);
-
-  const std::basic_string<C>&
-  type_name () const;
-
-  const std::basic_string<C>&
-  type_namespace () const;
-
-  virtual const char*
-  what () const throw ();
-};
-  
- -

The xml_schema::no_type_info exception is thrown - when there is no type information associated with a type specified - by the xsi:type attribute. This exception is thrown - by the DOM-Tree stage. The name and namespace of the type in question - can be obtained using the type_name and - type_namespace functions respectively. Usually, catching - this exception means that you haven't linked the code generated - from the schema defining the type in question with your application - or this schema has been compiled without the - --generate-polymorphic option. -

- - -

3.3.8 xml_schema::not_derived

- -
-struct not_derived: virtual exception
-{
-  not_derived (const std::basic_string<C>& base_type_name,
-               const std::basic_string<C>& base_type_namespace,
-               const std::basic_string<C>& derived_type_name,
-               const std::basic_string<C>& derived_type_namespace);
-
-  const std::basic_string<C>&
-  base_type_name () const;
-
-  const std::basic_string<C>&
-  base_type_namespace () const;
-
-
-  const std::basic_string<C>&
-  derived_type_name () const;
-
-  const std::basic_string<C>&
-  derived_type_namespace () const;
-
-  virtual const char*
-  what () const throw ();
-};
-  
- -

The xml_schema::not_derived exception is thrown - when a type specified by the xsi:type attribute is - not derived from the expected base type. This exception is thrown - by the DOM-Tree stage. The name and namespace of the expected - base type can be obtained using the base_type_name and - base_type_namespace functions respectively. The name - and namespace of the offending type can be obtained using the - derived_type_name and - derived_type_namespace functions respectively. -

- -

3.3.9 xml_schema::no_prefix_mapping

- -
-struct no_prefix_mapping: virtual exception
-{
-  no_prefix_mapping (const std::basic_string<C>& prefix);
-
-  const std::basic_string<C>&
-  prefix () const;
-
-  virtual const char*
-  what () const throw ();
-};
-  
- -

The xml_schema::no_prefix_mapping exception is thrown - during the DOM-Tree stage if a namespace prefix is encountered for - which a prefix-namespace mapping hasn't been provided. The namespace - prefix in question can be obtained using the prefix - function. -

- -

3.4 Reading from a Local File or URI

- -

Using a local file or URI is the simplest way to parse an XML instance. - For example:

- -
-using std::auto_ptr;
-
-auto_ptr<type> r1 (name ("test.xml"));
-auto_ptr<type> r2 (name ("https://www.codesynthesis.com/test.xml"));
-  
- -

Or, in the C++11 mode:

- -
-using std::unique_ptr;
-
-unique_ptr<type> r1 (name ("test.xml"));
-unique_ptr<type> r2 (name ("https://www.codesynthesis.com/test.xml"));
-  
- -

3.5 Reading from std::istream

- -

When using an std::istream instance, you may also - pass an optional resource id. This id is used to identify the - resource (for example in error messages) as well as to resolve - relative paths. For instance:

- -
-using std::auto_ptr;
-
-{
-  std::ifstream ifs ("test.xml");
-  auto_ptr<type> r (name (ifs, "test.xml"));
-}
-
-{
-  std::string str ("..."); // Some XML fragment.
-  std::istringstream iss (str);
-  auto_ptr<type> r (name (iss));
-}
-  
- -

3.6 Reading from xercesc::InputSource

- -

Reading from a xercesc::InputSource instance - is similar to the std::istream case except - the resource id is maintained by the InputSource - object. For instance:

- -
-xercesc::StdInInputSource is;
-std::auto_ptr<type> r (name (is));
-  
- -

3.7 Reading from DOM

- -

Reading from a xercesc::DOMDocument instance allows - you to setup a custom XML-DOM stage. Things like DOM - parser reuse, schema pre-parsing, and schema caching can be achieved - with this approach. For more information on how to obtain DOM - representation from an XML instance refer to the Xerces-C++ - documentation. In addition, the - C++/Tree Mapping - FAQ shows how to parse an XML instance to a Xerces-C++ - DOM document using the XSD runtime utilities. -

- -

The last parsing function is useful when you would like to perform - your own XML-to-DOM parsing and associate the resulting DOM document - with the object model nodes. The automatic DOMDocument - pointer is reset and the resulting object model assumes ownership - of the DOM document passed. For example:

- -
-// C++98 version.
-//
-xml_schema::dom::auto_ptr<xercesc::DOMDocument> doc = ...
-
-std::auto_ptr<type> r (
-  name (doc, xml_schema::flags::keep_dom | xml_schema::flags::own_dom));
-
-// At this point doc is reset to 0.
-
-// C++11 version.
-//
-xml_schema::dom::unique_ptr<xercesc::DOMDocument> doc = ...
-
-std::unique_ptr<type> r (
-  name (std::move (doc),
-        xml_schema::flags::keep_dom | xml_schema::flags::own_dom));
-
-// At this point doc is reset to 0.
-  
- -

4 Serialization

- -

This chapter covers various aspects of serializing a - tree-like object model to DOM or XML. - In this regard, serialization is complimentary to the reverse - process of parsing a DOM or XML instance into an object model - which is discussed in Chapter 3, - "Parsing". Note that the generation of the serialization code - is optional and should be explicitly requested with the - --generate-serialization option. See the - XSD - Compiler Command Line Manual for more information. -

- -

Each global XML Schema element in the form: -

- - -
-<xsd:element name="name" type="type"/>
-  
- -

is mapped to 8 overloaded C++ functions in the form:

- -
-// Serialize to std::ostream.
-//
-void
-name (std::ostream&,
-      const type&,
-      const xml_schema::namespace_fomap& =
-        xml_schema::namespace_infomap (),
-      const std::basic_string<C>& encoding = "UTF-8",
-      xml_schema::flags = 0);
-
-void
-name (std::ostream&,
-      const type&,
-      xml_schema::error_handler&,
-      const xml_schema::namespace_infomap& =
-        xml_schema::namespace_infomap (),
-      const std::basic_string<C>& encoding = "UTF-8",
-      xml_schema::flags = 0);
-
-void
-name (std::ostream&,
-      const type&,
-      xercesc::DOMErrorHandler&,
-      const xml_schema::namespace_infomap& =
-        xml_schema::namespace_infomap (),
-      const std::basic_string<C>& encoding = "UTF-8",
-      xml_schema::flags = 0);
-
-
-// Serialize to XMLFormatTarget.
-//
-void
-name (xercesc::XMLFormatTarget&,
-      const type&,
-      const xml_schema::namespace_infomap& =
-        xml_schema::namespace_infomap (),
-      const std::basic_string<C>& encoding = "UTF-8",
-      xml_schema::flags = 0);
-
-void
-name (xercesc::XMLFormatTarget&,
-      const type&,
-      xml_schema::error_handler&,
-      const xml_schema::namespace_infomap& =
-        xml_schema::namespace_infomap (),
-      const std::basic_string<C>& encoding = "UTF-8",
-      xml_schema::flags = 0);
-
-void
-name (xercesc::XMLFormatTarget&,
-      const type&,
-      xercesc::DOMErrorHandler&,
-      const xml_schema::namespace_infomap& =
-        xml_schema::namespace_infomap (),
-      const std::basic_string<C>& encoding = "UTF-8",
-      xml_schema::flags = 0);
-
-
-// Serialize to DOM.
-//
-xml_schema::dom::[auto|unique]_ptr<xercesc::DOMDocument>
-name (const type&,
-      const xml_schema::namespace_infomap&
-        xml_schema::namespace_infomap (),
-      xml_schema::flags = 0);
-
-void
-name (xercesc::DOMDocument&,
-      const type&,
-      xml_schema::flags = 0);
-  
- -

You can choose between writing XML to std::ostream or - xercesc::XMLFormatTarget and creating a DOM instance - in the form of xercesc::DOMDocument. Serialization - to ostream or XMLFormatTarget requires a - considerably less work while serialization to DOM provides - for greater flexibility. Each of these serialization functions - is discussed in more detail in the following sections. -

- - -

4.1 Initializing the Xerces-C++ Runtime

- -

Some serialization functions expect you to initialize the Xerces-C++ - runtime while others initialize and terminate it as part of their - work. The general rule is as follows: if a function has any arguments - or return a value that is an instance of a Xerces-C++ type, then - this function expects you to initialize the Xerces-C++ runtime. - Otherwise, the function initializes and terminates the runtime for - you. Note that it is legal to have nested calls to the Xerces-C++ - initialize and terminate functions as long as the calls are balanced. -

- -

You can instruct serialization functions that initialize and terminate - the runtime not to do so by passing the - xml_schema::flags::dont_initialize flag (see - Section 4.3, "Flags"). -

- -

4.2 Namespace Infomap and Character Encoding

- -

When a document being serialized uses XML namespaces, custom - prefix-namespace associations can to be established. If custom - prefix-namespace mapping is not provided then generic prefixes - (p1, p2, etc) are automatically assigned - to namespaces as needed. Also, if - you would like the resulting instance document to contain the - schemaLocation or noNamespaceSchemaLocation - attributes, you will need to provide namespace-schema associations. - The xml_schema::namespace_infomap class is used - to capture this information:

- -
-struct namespace_info
-{
-  namespace_info ();
-  namespace_info (const std::basic_string<C>& name,
-                  const std::basic_string<C>& schema);
-
-  std::basic_string<C> name;
-  std::basic_string<C> schema;
-};
-
-// Map of namespace prefix to namespace_info.
-//
-struct namespace_infomap: public std::map<std::basic_string<C>,
-                                          namespace_info>
-{
-};
-  
- -

Consider the following associations as an example:

- -
-xml_schema::namespace_infomap map;
-
-map["t"].name = "https://www.codesynthesis.com/test";
-map["t"].schema = "test.xsd";
-  
- -

This map, if passed to one of the serialization functions, - could result in the following XML fragment:

- -
-<?xml version="1.0" ?>
-<t:name xmlns:t="https://www.codesynthesis.com/test"
-        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-        xsi:schemaLocation="https://www.codesynthesis.com/test test.xsd">
-  
- -

As you can see, the serialization function automatically added namespace - mapping for the xsi prefix. You can change this by - providing your own prefix:

- -
-xml_schema::namespace_infomap map;
-
-map["xsn"].name = "http://www.w3.org/2001/XMLSchema-instance";
-
-map["t"].name = "https://www.codesynthesis.com/test";
-map["t"].schema = "test.xsd";
-  
- -

This could result in the following XML fragment:

- -
-<?xml version="1.0" ?>
-<t:name xmlns:t="https://www.codesynthesis.com/test"
-        xmlns:xsn="http://www.w3.org/2001/XMLSchema-instance"
-        xsn:schemaLocation="https://www.codesynthesis.com/test test.xsd">
-  
- -

To specify the location of a schema without a namespace you can use - an empty prefix as in the example below:

- -
-xml_schema::namespace_infomap map;
-
-map[""].schema = "test.xsd";
-  
- -

This would result in the following XML fragment:

- -
-<?xml version="1.0" ?>
-<name xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-      xsi:noNamespaceSchemaLocation="test.xsd">
-  
- -

To make a particular namespace default you can use an empty - prefix, for example:

- -
-xml_schema::namespace_infomap map;
-
-map[""].name = "https://www.codesynthesis.com/test";
-map[""].schema = "test.xsd";
-  
- -

This could result in the following XML fragment:

- -
-<?xml version="1.0" ?>
-<name xmlns="https://www.codesynthesis.com/test"
-      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-      xsi:schemaLocation="https://www.codesynthesis.com/test test.xsd">
-  
- - -

Another bit of information that you can pass to the serialization - functions is the character encoding method that you would like to use. - Common values for this argument are "US-ASCII", - "ISO8859-1", "UTF-8", - "UTF-16BE", "UTF-16LE", - "UCS-4BE", and "UCS-4LE". The default - encoding is "UTF-8". For more information on - encoding methods see the - "Character - Encoding" article from Wikipedia. -

- -

4.3 Flags

- -

Serialization flags are the last argument of every serialization - function. They allow you to fine-tune the process of serialization. - The flags argument is optional. -

- - -

The following flags are recognized by the serialization - functions:

- -
-
xml_schema::flags::dont_initialize
-
Do not initialize the Xerces-C++ runtime.
- -
xml_schema::flags::dont_pretty_print
-
Do not add extra spaces or new lines that make the resulting XML - slightly bigger but easier to read.
- -
xml_schema::flags::no_xml_declaration
-
Do not write XML declaration (<?xml ... ?>).
-
- -

You can pass several flags by combining them using the bit-wise OR - operator. For example:

- -
-std::auto_ptr<type> r = ...
-std::ofstream ofs ("test.xml");
-xml_schema::namespace_infomap map;
-name (ofs,
-      *r,
-      map,
-      "UTF-8",
-      xml_schema::flags::no_xml_declaration |
-      xml_schema::flags::dont_pretty_print);
-  
- -

For more information on the Xerces-C++ runtime initialization - refer to Section 4.1, "Initializing the Xerces-C++ - Runtime". -

- -

4.4 Error Handling

- -

As with the parsing functions (see Section 3.3, - "Error Handling"), to better understand error handling and - reporting strategies employed by the serialization functions, it - is useful to know that the transformation of a statically-typed - tree to an XML instance document happens in two stages. The first - stage, performed by the generated code, consist of building a DOM - instance from the statically-typed tree . For short, we will call - this stage the Tree-DOM stage. The second stage, performed by - Xerces-C++, consists of serializing the DOM instance into the XML - document. We will call this stage the DOM-XML stage. -

- -

All serialization functions except the two that serialize into - a DOM instance come in overloaded triples. The first function - in such a triple reports error conditions exclusively by throwing - exceptions. It accumulates all the serialization errors of the - DOM-XML stage and throws them in a single instance of the - xml_schema::serialization exception (described below). - The second and the third functions in the triple use callback - interfaces to report serialization errors and warnings. The two - callback interfaces are xml_schema::error_handler and - xercesc::DOMErrorHandler. The - xml_schema::error_handler interface is described in - Section 3.3, "Error Handling". For more information - on the xercesc::DOMErrorHandler interface refer to the - Xerces-C++ documentation. -

- -

The Tree-DOM stage reports error conditions exclusively by throwing - exceptions. Individual exceptions thrown by the serialization functions - are described in the following sub-sections. -

- -

4.4.1 xml_schema::serialization

- -
-struct serialization: virtual exception
-{
-  serialization ();
-  serialization (const diagnostics&);
-
-  const diagnostics&
-  diagnostics () const;
-
-  virtual const char*
-  what () const throw ();
-};
-  
- -

The xml_schema::diagnostics class is described in - Section 3.3.1, "xml_schema::parsing". - The xml_schema::serialization exception is thrown if - there were serialization errors reported during the DOM-XML stage. - If no callback interface was provided to the serialization function, - the exception contains a list of errors and warnings accessible using - the diagnostics function. -

- - -

4.4.2 xml_schema::unexpected_element

- -

The xml_schema::unexpected_element exception is - described in Section 3.3.3, - "xml_schema::unexpected_element". It is thrown - by the serialization functions during the Tree-DOM stage if the - root element name of the provided DOM instance does not match with - the name of the element this serialization function is for. -

- -

4.4.3 xml_schema::no_type_info

- -

The xml_schema::no_type_info exception is - described in Section 3.3.7, - "xml_schema::no_type_info". It is thrown - by the serialization functions during the Tree-DOM stage when there - is no type information associated with a dynamic type of an - element. Usually, catching this exception means that you haven't - linked the code generated from the schema defining the type in - question with your application or this schema has been compiled - without the --generate-polymorphic option. -

- -

4.5 Serializing to std::ostream

- -

In order to serialize to std::ostream you will need - an object model, an output stream and, optionally, a namespace - infomap. For instance:

- -
-// Obtain the object model.
-//
-std::auto_ptr<type> r = ...
-
-// Prepare namespace mapping and schema location information.
-//
-xml_schema::namespace_infomap map;
-
-map["t"].name = "https://www.codesynthesis.com/test";
-map["t"].schema = "test.xsd";
-
-// Write it out.
-//
-name (std::cout, *r, map);
-  
- -

Note that the output stream is treated as a binary stream. This - becomes important when you use a character encoding that is wider - than 8-bit char, for instance UTF-16 or UCS-4. For - example, things will most likely break if you try to serialize - to std::ostringstream with UTF-16 or UCS-4 as an - encoding. This is due to the special value, - '\0', that will most likely occur as part of such - serialization and it won't have the special meaning assumed by - std::ostringstream. -

- - -

4.6 Serializing to xercesc::XMLFormatTarget

- -

Serializing to an xercesc::XMLFormatTarget instance - is similar the std::ostream case. For instance: -

- -
-using std::auto_ptr;
-
-// Obtain the object model.
-//
-auto_ptr<type> r = ...
-
-// Prepare namespace mapping and schema location information.
-//
-xml_schema::namespace_infomap map;
-
-map["t"].name = "https://www.codesynthesis.com/test";
-map["t"].schema = "test.xsd";
-
-using namespace xercesc;
-
-XMLPlatformUtils::Initialize ();
-
-{
-  // Choose a target.
-  //
-  auto_ptr<XMLFormatTarget> ft;
-
-  if (argc != 2)
-  {
-    ft = auto_ptr<XMLFormatTarget> (new StdOutFormatTarget ());
-  }
-  else
-  {
-    ft = auto_ptr<XMLFormatTarget> (
-      new LocalFileFormatTarget (argv[1]));
-  }
-
-  // Write it out.
-  //
-  name (*ft, *r, map);
-}
-
-XMLPlatformUtils::Terminate ();
-  
- -

Note that we had to initialize the Xerces-C++ runtime before we - could call this serialization function.

- -

4.7 Serializing to DOM

- -

The mapping provides two overloaded functions that implement - serialization to a DOM instance. The first creates a DOM instance - for you and the second serializes to an existing DOM instance. - While serializing to a new DOM instance is similar to serializing - to std::ostream or xercesc::XMLFormatTarget, - serializing to an existing DOM instance requires quite a bit of work - from your side. You will need to set all the custom namespace mapping - attributes as well as the schemaLocation and/or - noNamespaceSchemaLocation attributes. The following - listing should give you an idea about what needs to be done: -

- -
-// Obtain the object model.
-//
-std::auto_ptr<type> r = ...
-
-using namespace xercesc;
-
-XMLPlatformUtils::Initialize ();
-
-{
-  // Create a DOM instance. Set custom namespace mapping and schema
-  // location attributes.
-  //
-  DOMDocument& doc = ...
-
-  // Serialize to DOM.
-  //
-  name (doc, *r);
-
-  // Serialize the DOM document to XML.
-  //
-  ...
-}
-
-XMLPlatformUtils::Terminate ();
-  
- -

For more information on how to create and serialize a DOM instance - refer to the Xerces-C++ documentation. In addition, the - C++/Tree Mapping - FAQ shows how to implement these operations using the XSD - runtime utilities. -

- -

5 Additional Functionality

- -

The C++/Tree mapping provides a number of optional features - that can be useful in certain situations. They are described - in the following sections.

- -

5.1 DOM Association

- -

Normally, after parsing is complete, the DOM document which - was used to extract the data is discarded. However, the parsing - functions can be instructed to preserve the DOM document - and create an association between the DOM nodes and object model - nodes. When there is an association between the DOM and - object model nodes, you can obtain the corresponding DOM element - or attribute node from an object model node as well as perform - the reverse transition: obtain the corresponding object model - from a DOM element or attribute node.

- -

Maintaining DOM association is normally useful when the application - needs access to XML constructs that are not preserved in the - object model, for example, XML comments. - Another useful aspect of DOM association is the ability of the - application to navigate the document tree using the generic DOM - interface (for example, with the help of an XPath processor) - and then move back to the statically-typed object model. Note - also that while you can change the underlying DOM document, - these changes are not reflected in the object model and will - be ignored during serialization. If you need to not only access - but also modify some aspects of XML that are not preserved in - the object model, then type customization with custom parsing - constructors and serialization operators should be used instead.

- -

To request DOM association you will need to pass the - xml_schema::flags::keep_dom flag to one of the - parsing functions (see Section 3.2, - "Flags and Properties" for more information). In this case the - DOM document is retained and will be released when the object model - is deleted. Note that since DOM nodes "out-live" the parsing function - call, you need to initialize the Xerces-C++ runtime before calling - one of the parsing functions with the keep_dom flag and - terminate it after the object model is destroyed (see - Section 3.1, "Initializing the Xerces-C++ Runtime").

- -

If the keep_dom flag is passed - as the second argument to the copy constructor and the copy - being made is of a complete tree, then the DOM association - is also maintained in the copy by cloning the underlying - DOM document and reestablishing the associations. For example:

- -
-using namespace xercesc;
-
-XMLPlatformUtils::Initialize ();
-
-{
-  // Parse XML to object model.
-  //
-  std::auto_ptr<type> r (root (
-    "root.xml",
-     xml_schema::flags::keep_dom |
-     xml_schema::flags::dont_initialize));
-
-   // Copy without DOM association.
-   //
-   type copy1 (*r);
-
-   // Copy with DOM association.
-   //
-   type copy2 (*r, xml_schema::flags::keep_dom);
-}
-
-XMLPlatformUtils::Terminate ();
-  
- - -

To obtain the corresponding DOM node from an object model node - you will need to call the _node accessor function - which returns a pointer to DOMNode. You can then query - this DOM node's type and cast it to either DOMAttr* - or DOMElement*. To obtain the corresponding object - model node from a DOM node, the DOM user data API is used. The - xml_schema::dom::tree_node_key variable contains - the key for object model nodes. The following schema and code - fragment show how to navigate from DOM to object model nodes - and in the opposite direction:

- -
-<complexType name="object">
-  <sequence>
-    <element name="a" type="string"/>
-  </sequence>
-</complexType>
-
-<element name="root" type="object"/>
-  
- -
-using namespace xercesc;
-
-XMLPlatformUtils::Initialize ();
-
-{
-  // Parse XML to object model.
-  //
-  std::auto_ptr<type> r (root (
-    "root.xml",
-     xml_schema::flags::keep_dom |
-     xml_schema::flags::dont_initialize));
-
-  DOMNode* n = r->_node ();
-  assert (n->getNodeType () == DOMNode::ELEMENT_NODE);
-  DOMElement* re = static_cast<DOMElement*> (n);
-
-  // Get the 'a' element. Note that it is not necessarily the
-  // first child node of 'root' since there could be whitespace
-  // nodes before it.
-  //
-  DOMElement* ae;
-
-  for (n = re->getFirstChild (); n != 0; n = n->getNextSibling ())
-  {
-    if (n->getNodeType () == DOMNode::ELEMENT_NODE)
-    {
-      ae = static_cast<DOMElement*> (n);
-      break;
-    }
-  }
-
-  // Get from the 'a' DOM element to xml_schema::string object model
-  // node.
-  //
-  xml_schema::type& t (
-    *reinterpret_cast<xml_schema::type*> (
-       ae->getUserData (xml_schema::dom::tree_node_key)));
-
-  xml_schema::string& a (dynamic_cast<xml_schema::string&> (t));
-}
-
-XMLPlatformUtils::Terminate ();
-  
- -

The 'mixed' example which can be found in the XSD distribution - shows how to handle the mixed content using DOM association.

- -

5.2 Binary Serialization

- -

Besides reading from and writing to XML, the C++/Tree mapping - also allows you to save the object model to and load it from a - number of predefined as well as custom data representation - formats. The predefined binary formats are CDR (Common Data - Representation) and XDR (eXternal Data Representation). A - custom format can easily be supported by providing - insertion and extraction operators for basic types.

- -

Binary serialization saves only the data without any meta - information or markup. As a result, saving to and loading - from a binary representation can be an order of magnitude - faster than parsing and serializing the same data in XML. - Furthermore, the resulting representation is normally several - times smaller than the equivalent XML representation. These - properties make binary serialization ideal for internal data - exchange and storage. A typical application that uses this - facility stores the data and communicates within the - system using a binary format and reads/writes the data - in XML when communicating with the outside world.

- -

In order to request the generation of insertion operators and - extraction constructors for a specific predefined or custom - data representation stream, you will need to use the - --generate-insertion and --generate-extraction - compiler options. See the - XSD - Compiler Command Line Manual for more information.

- -

Once the insertion operators and extraction constructors are - generated, you can use the xml_schema::istream - and xml_schema::ostream wrapper stream templates - to save the object model to and load it from a specific format. - The following code fragment shows how to do this using ACE - (Adaptive Communication Environment) CDR streams as an example:

- -
-<complexType name="object">
-  <sequence>
-    <element name="a" type="string"/>
-    <element name="b" type="int"/>
-  </sequence>
-</complexType>
-
-<element name="root" type="object"/>
-  
- -
-// Parse XML to object model.
-//
-std::auto_ptr<type> r (root ("root.xml"));
-
-// Save to a CDR stream.
-//
-ACE_OutputCDR ace_ocdr;
-xml_schema::ostream<ACE_OutputCDR> ocdr (ace_ocdr);
-
-ocdr << *r;
-
-// Load from a CDR stream.
-//
-ACE_InputCDR ace_icdr (buf, size);
-xml_schema::istream<ACE_InputCDR> icdr (ace_icdr);
-
-std::auto_ptr<object> copy (new object (icdr));
-
-// Serialize to XML.
-//
-root (std::cout, *copy);
-  
- -

The XSD distribution contains a number of examples that - show how to save the object model to and load it from - CDR, XDR, and a custom format.

- - - - -

Appendix A — Default and Fixed Values

- -

The following table summarizes the effect of default and fixed - values (specified with the default and fixed - attributes, respectively) on attribute and element values. The - default and fixed attributes are mutually - exclusive. It is also worthwhile to note that the fixed value semantics - is a superset of the default value semantics. -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
defaultfixed
elementnot presentoptionalrequiredoptionalrequired
not presentinvalid instancenot presentinvalid instance
emptydefault value is usedfixed value is used
valuevalue is usedvalue is used provided it's the same as fixed
attributenot presentoptionalrequiredoptionalrequired
default value is usedinvalid schemafixed value is usedinvalid instance
emptyempty value is usedempty value is used provided it's the same as fixed
valuevalue is usedvalue is used provided it's the same as fixed
- -
-
- - - - diff --git a/doc/cxx/tree/manual/makefile b/doc/cxx/tree/manual/makefile deleted file mode 100644 index 7d46c91..0000000 --- a/doc/cxx/tree/manual/makefile +++ /dev/null @@ -1,53 +0,0 @@ -# file : doc/cxx/tree/manual/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -default := $(out_base)/ -install := $(out_base)/.install -dist := $(out_base)/.dist -dist-win := $(out_base)/.dist-win -clean := $(out_base)/.clean - -# Build. -# -$(default): $(out_base)/cxx-tree-manual.ps $(out_base)/cxx-tree-manual.pdf - - -$(out_base)/cxx-tree-manual.ps: $(src_base)/index.xhtml \ - $(src_base)/manual.html2ps \ - | $(out_base)/. - $(call message,html2ps $<,html2ps -f $(src_base)/manual.html2ps -o $@ $<) - -$(out_base)/cxx-tree-manual.pdf: $(out_base)/cxx-tree-manual.ps | $(out_base)/. - $(call message,ps2pdf $<,ps2pdf14 $< $@) - -# Install & Dist. -# -$(install): path := $(subst $(src_root)/doc/,,$(src_base)) -$(dist): path := $(subst $(src_root)/,,$(src_base)) - -$(install): $(out_base)/cxx-tree-manual.ps $(out_base)/cxx-tree-manual.pdf - $(call install-data,$(src_base)/index.xhtml,$(install_doc_dir)/xsd/$(path)/index.xhtml) - $(call install-data,$(out_base)/cxx-tree-manual.ps,$(install_doc_dir)/xsd/$(path)/cxx-tree-manual.ps) - $(call install-data,$(out_base)/cxx-tree-manual.pdf,$(install_doc_dir)/xsd/$(path)/cxx-tree-manual.pdf) - -$(dist): $(out_base)/cxx-tree-manual.ps $(out_base)/cxx-tree-manual.pdf - $(call install-data,$(src_base)/index.xhtml,$(dist_prefix)/$(path)/index.xhtml) - $(call install-data,$(out_base)/cxx-tree-manual.ps,$(dist_prefix)/$(path)/cxx-tree-manual.ps) - $(call install-data,$(out_base)/cxx-tree-manual.pdf,$(dist_prefix)/$(path)/cxx-tree-manual.pdf) - -$(dist-win): $(dist) - - -# Clean -# -$(clean): -ifneq ($(xsd_clean_gen),n) - $(call message,rm $$1,rm -f $$1,$(out_base)/cxx-tree-manual.ps) - $(call message,rm $$1,rm -f $$1,$(out_base)/cxx-tree-manual.pdf) -endif - -# How to. -# -$(call include,$(bld_root)/install.make) diff --git a/doc/cxx/tree/manual/manual.html2ps b/doc/cxx/tree/manual/manual.html2ps deleted file mode 100644 index a4b4491..0000000 --- a/doc/cxx/tree/manual/manual.html2ps +++ /dev/null @@ -1,66 +0,0 @@ -@html2ps { - option { - toc: hb; - colour: 1; - hyphenate: 1; - titlepage: 1; - } - - datefmt: "%B %Y"; - - titlepage { - content: " -
-

C++/Tree Mapping User Manual

-

 

-

 

-

 

-

 

-

 

-

 

-

 

-
-

Revision $[revision]     $D

-

Copyright © 2009-2020 Code Synthesis Tools CC.

- -

Permission is granted to copy, distribute and/or modify this - document under the terms of the - GNU Free - Documentation License, version 1.2; with no Invariant Sections, - no Front-Cover Texts and no Back-Cover Texts. -

- -

This document is available in the following formats: - XHTML, - PDF, and - PostScript.

"; - } - - toc { - indent: 2em; - } - - header { - odd-right: $H; - even-left: $H; - } - - footer { - odd-left: $D; - odd-center: $T, v$[revision]; - odd-right: $N; - - even-left: $N; - even-center: $T, v$[revision]; - even-right: $D; - } -} - -body { - font-size: 12pt; - text-align: justify; -} - -pre { - font-size: 10pt; -} diff --git a/doc/cxx/tree/reference/footer.html b/doc/cxx/tree/reference/footer.html deleted file mode 100644 index 53291d6..0000000 --- a/doc/cxx/tree/reference/footer.html +++ /dev/null @@ -1,6 +0,0 @@ -
-
- Copyright © 2009-2020 Code Synthesis Tools CC. -
- - diff --git a/doc/cxx/tree/reference/libxsd.doxygen b/doc/cxx/tree/reference/libxsd.doxygen deleted file mode 100644 index b98074a..0000000 --- a/doc/cxx/tree/reference/libxsd.doxygen +++ /dev/null @@ -1,1291 +0,0 @@ -# Doxyfile 1.5.4 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file that -# follow. The default is UTF-8 which is also the encoding used for all text before -# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into -# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of -# possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = "C++/Tree Mapping Runtime Library" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, -# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, -# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, -# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = NO - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to -# include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = YES - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct (or union) is -# documented as struct with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code where the coding convention is that all structs are -# typedef'ed and only the typedef is referenced never the struct's name. - -TYPEDEF_HIDES_STRUCT = NO - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be extracted -# and appear in the documentation as a namespace called 'anonymous_namespace{file}', -# where file will be replaced with the base name of the file that contains the anonymous -# namespace. By default anonymous namespace are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = YES - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = NO - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = \ -../../../../libxsd/xsd/cxx/tree/buffer.hxx \ -../../../../libxsd/xsd/cxx/tree/types.hxx \ -../../../../libxsd/xsd/cxx/tree/date-time.hxx \ -../../../../libxsd/xsd/cxx/tree/elements.hxx \ -../../../../libxsd/xsd/cxx/tree/element-map.hxx \ -../../../../libxsd/xsd/cxx/tree/exceptions.hxx - -# This tag can be used to specify the character encoding of the source files that -# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default -# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. -# See http://www.gnu.org/software/libiconv for the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the output. -# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, -# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. If you have enabled CALL_GRAPH or CALLER_GRAPH -# then you must also enable this option. If you don't then doxygen will produce -# a warning and turn it on anyway - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentstion. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = footer.html - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). - -HTML_DYNAMIC_SECTIONS = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = YES - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = YES - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -# C++98 version. -# -PREDEFINED = XSD_AUTO_PTR=std::auto_ptr - -# C++11 version. -# -# PREDEFINED = XSD_AUTO_PTR=std::unique_ptr - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = libxsd.doxytag - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to -# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to -# specify the directory where the mscgen tool resides. If left empty the tool is assumed to -# be found in the default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will -# generate a caller dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable caller graphs for selected -# functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the number -# of direct children of the root node in a graph is already larger than -# MAX_DOT_GRAPH_NOTES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). - -DOT_TRANSPARENT = YES - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff --git a/doc/cxx/tree/reference/makefile b/doc/cxx/tree/reference/makefile deleted file mode 100644 index 5df62c9..0000000 --- a/doc/cxx/tree/reference/makefile +++ /dev/null @@ -1,18 +0,0 @@ -.PHONY: all -all: libxsd.doxytag - -headers := \ -../../../../libxsd/xsd/cxx/tree/buffer.hxx \ -../../../../libxsd/xsd/cxx/tree/types.hxx \ -../../../../libxsd/xsd/cxx/tree/date-time.hxx \ -../../../../libxsd/xsd/cxx/tree/elements.hxx \ -../../../../libxsd/xsd/cxx/tree/exceptions.hxx - -libxsd.doxytag: libxsd.doxygen footer.html $(headers) - doxygen $< - -.PHONY: clean -clean: - rm -f libxsd.doxytag - rm -rf html - diff --git a/doc/default.css b/doc/default.css deleted file mode 100644 index bb3805b..0000000 --- a/doc/default.css +++ /dev/null @@ -1,319 +0,0 @@ -html { - margin : 0; - padding : 0; - background : white; -} - -body { - font-family : "Lucida Grande", Verdana, "Bitstream Vera Sans", sans-serif; - font-weight : normal; - font-size : 13px; - line-height : 19px; - - color : black; - - margin : 0 2em 0 2em; - padding : 0; -} - - -body { - min-width: 40em; -} - -#container { - max-width : 46em; - margin : 0 auto; - padding : 0 1em 0 1em; -} - - - -/* - * Footer - * - */ -#footer { - color : #3a84a7; - - padding : 1em 0 0.5em 0; - - font-size : 10px; - line-height : 15px; - - text-align: center; -} - -#footer a:link, #footer a:visited { - - color:#1d6699; - text-decoration: underline; -} - -#footer a { - margin-left: 0.7em; - margin-right: 0.7em; -} - -#footer p { - padding: 0; - margin: 0.3em 0 0 0; -} - -/* Distribution terms. */ -#footer #terms { - text-align: justify; - - font-size : 110%; - font-family : monospace; - - padding : 1em 0 0.5em 0; -} - - -/* - * Content - * - */ - -#content { - padding : 0em 0.1em 0 1.3em; - margin : 1.4em 0 0 0; -} - -#content p, -#content ol, -#content ul, -#content dl { - text-align: justify; -} - -#content h1 { - margin-left: -0.89em; -} - -a:link { - color:#0536d2; -} - - -/* - * Headings - * - */ - -h1, h2, h3, h4, h5, h6 { - font-weight : 500; -} - -h1 { font-size : 155%; } -h2 { font-size : 130%; } -h3 { font-size : 125%; } -h4 { font-size : 110%; } -h5 { font-size : 106%; } -h6 { font-size : 100%; } - -h1 { margin : 1.8em 0 0.8em 0;} -h2 { margin-top : 1.4em;} -h3 { margin-top : 1em;} - -p.indent { - margin-left : 1.5em; -} - - -/* - * Fix for IE 5.5 table font problem - * - */ - -table { - font-size : 13px; -} - - -/* - * table of content - * - */ - -ul.toc li { - padding : .4em 0em 0em 0em; -} - - -/* Toc links don't need to show when they are visited. */ -.toc a:visited { - color:#0536d2; -} - - -/* - * lists - * - */ - - -/* list of links */ -ul.menu { - list-style-type : none; -} - -ul.menu li { - padding-top : 0.3em; - padding-bottom : 0.3em; -} - - - -/* @@ I should probably use child selector here */ -/* list with multiline list-elements */ -ul.multiline li, ol.multiline li, dl.multiline dd { - padding-top : 0.16em; - padding-bottom : 0.16em; - - font-size : 11px; - line-height : 15px; -} - - - -/* C++ code snippet */ -pre.cxx { - margin-top : 0em; - margin-bottom : 2em; - - margin-left : 1em; -} - - - -/* make code snippet */ -pre.make { - margin-top : 0em; - margin-bottom : 2em; - - margin-left : 1em; -} - - - -/* terminal output */ -pre.term { - margin-top : 0em; - margin-bottom : 2em; - - margin-left : 1em; -} - - -/* Images */ -div.center { - text-align: center; -} - -/* Document info. */ -#docinfo { - margin-top: 4em; - border-top: 1px dashed #000000; - font-size: 70%; -} - - -/* Footnote */ - -#footnote { - margin-top : 2.5em; -} - -#footnote hr, hr.footnote { - margin-left: 0; - margin-bottom: 0.6em; - width: 8em; - border-top: 1px solid #000000; - border-right: none; - border-bottom: none; - border-left: none; - -} - -#footnote ol { - margin-left: 0; - padding-left: 1.45em; -} - -#footnote li { - text-align : left; - font-size : 11px; - line-height : 15px; - - padding : .4em 0 .4em 0; -} - - -/* Normal table with borders, etc. */ - -table.std { - margin: 2em 0 2em 0; - - border-collapse : collapse; - border : 1px solid; - border-color : #000000; - - font-size : 11px; - line-height : 14px; -} - -table.std th, table.std td { - border : 1px solid; - padding : 0.6em 0.8em 0.6em 0.8em; -} - -table.std th { - background : #cde8f6; -} - -table.std td { - text-align: left; -} - - -/* - * "item | description" table. - * - */ - -table.description { - border-style : none; - border-collapse : separate; - border-spacing : 0; - - font-size : 13px; - - margin : 0.6em 0 0.6em 0; - padding : 0 0 0 0; -} - -table.description tr { - padding : 0 0 0 0; - margin : 0 0 0 0; -} - -table.description * td, table.description * th { - border-style : none; - margin : 0 0 0 0; - vertical-align : top; -} - -table.description * th { - font-weight : normal; - padding : 0.4em 1em 0.4em 0; - text-align : left; - white-space : nowrap; - background : none; -} - -table.description * td { - padding : 0.4em 0 0.4em 1em; - text-align : justify; -} diff --git a/doc/doc.sh b/doc/doc.sh deleted file mode 100755 index 36528fd..0000000 --- a/doc/doc.sh +++ /dev/null @@ -1,105 +0,0 @@ -#! /usr/bin/env bash - -version=4.1.0.a11 - -trap 'exit 1' ERR -set -o errtrace # Trap in functions. - -function info () { echo "$*" 1>&2; } -function error () { info "$*"; exit 1; } - -date="$(date +"%B %Y")" -copyright="$(sed -n -re 's%^Copyright \(c\) (.+)\.$%\1%p' ../LICENSE)" - -while [ $# -gt 0 ]; do - case $1 in - --clean) - rm -f xsd.xhtml xsd.1 - rm -f cxx/parser/guide/cxx-parser-guide.{ps,pdf} - rm -f cxx/tree/guide/cxx-tree-guide.{ps,pdf} - rm -f cxx/tree/manual/cxx-tree-manual.{ps,pdf} - exit 0 - ;; - *) - error "unexpected $1" - ;; - esac -done - -ops=(\ --v project="xsd" \ --v version="$version" \ --v date="$date" \ --v copyright="$copyright" \ --I ../xsd \ ---stdout \ ---suppress-undocumented \ ---exclude-base) - -# XHTML -# -# Common options. -# -cli "${ops[@]}" --generate-html --class CXX::options --class options \ ---html-prologue-file xsd-prologue.xhtml \ -../xsd/cxx/options.cli >xsd.xhtml - -# C++/Tree options. -# -cli "${ops[@]}" --generate-html \ ---html-prologue-file xsd-tree-header.xhtml \ -../xsd/cxx/tree/options.cli >>xsd.xhtml - -# C++/Parser options. -# -cli "${ops[@]}" --generate-html \ ---html-prologue-file xsd-parser-header.xhtml \ ---html-epilogue-file xsd-epilogue.xhtml \ -../xsd/cxx/parser/options.cli >>xsd.xhtml - -# MAN -# -# Common options. -# -cli "${ops[@]}" --generate-man --class CXX::options --class options \ ---man-prologue-file xsd-prologue.1 \ -../xsd/cxx/options.cli >xsd.1 - -# C++/Tree options. -# -cli "${ops[@]}" --generate-man \ ---man-prologue-file xsd-tree-header.1 \ -../xsd/cxx/tree/options.cli >>xsd.1 - -# C++/Parser options. -# -cli "${ops[@]}" --generate-man \ ---man-prologue-file xsd-parser-header.1 \ ---man-epilogue-file xsd-epilogue.1 \ -../xsd/cxx/parser/options.cli >>xsd.1 - -# PS, PDF -# -# C++/Parser guide. -# -html2ps -f cxx/parser/guide/guide.html2ps \ --o cxx/parser/guide/cxx-parser-guide.ps cxx/parser/guide/index.xhtml - -ps2pdf14 -dOptimize=true -dEmbedAllFonts=true \ -cxx/parser/guide/cxx-parser-guide.ps cxx/parser/guide/cxx-parser-guide.pdf - -# C++/Tree guide. -# -html2ps -f cxx/tree/guide/guide.html2ps \ --o cxx/tree/guide/cxx-tree-guide.ps cxx/tree/guide/index.xhtml - -ps2pdf14 -dOptimize=true -dEmbedAllFonts=true \ -cxx/tree/guide/cxx-tree-guide.ps cxx/tree/guide/cxx-tree-guide.pdf - -# C++/Tree manual. -# -html2ps -f cxx/tree/manual/manual.html2ps \ --o cxx/tree/manual/cxx-tree-manual.ps cxx/tree/manual/index.xhtml - -ps2pdf14 -dOptimize=true -dEmbedAllFonts=true \ -cxx/tree/manual/cxx-tree-manual.ps cxx/tree/manual/cxx-tree-manual.pdf diff --git a/doc/makefile b/doc/makefile deleted file mode 100644 index fcce4f7..0000000 --- a/doc/makefile +++ /dev/null @@ -1,142 +0,0 @@ -# file : doc/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make - -default := $(out_base)/ -install := $(out_base)/.install -dist := $(out_base)/.dist -dist-win := $(out_base)/.dist-win -clean := $(out_base)/.clean - -# Import. -# -$(call import,\ - $(scf_root)/import/cli/stub.make,\ - cli: cli,cli-rules: cli_rules) - -# Build. -# -$(default): \ -$(out_base)/cxx/ \ -$(out_base)/xsd.xhtml \ -$(out_base)/xsd.1 - -# Man/html pages. -# -$(out_base)/xsd.xhtml $(out_base)/xsd.1: cli := $(cli) -$(out_base)/xsd.xhtml $(out_base)/xsd.1: cli_options += -I $(src_root)/xsd - -$(out_base)/xsd.xhtml $(out_base)/xsd.1: \ -$(src_root)/xsd/options.cli \ -$(src_root)/xsd/cxx/options.cli \ -$(src_root)/xsd/cxx/tree/options.cli \ -$(src_root)/xsd/cxx/parser/options.cli - -# Assemble the options from different files in a specific order. -# - -# XHTML -# -$(out_base)/xsd.xhtml: $(src_base)/xsd-prologue.xhtml \ - $(src_base)/xsd-epilogue.xhtml \ - $(src_base)/xsd-tree-header.xhtml \ - $(src_base)/xsd-parser-header.xhtml \ - | $(out_base)/. -# Common options. -# - $(call message,cli-html $$1,$(cli) $(cli_options) --generate-html \ ---stdout --suppress-undocumented --exclude-base --class CXX::options \ ---class options --html-prologue-file $(src_base)/xsd-prologue.xhtml \ -$$1 >$@, $(src_root)/xsd/cxx/options.cli) - -# C++/Tree options. -# - $(call message,cli-html $$1,$(cli) $(cli_options) --generate-html \ ---stdout --suppress-undocumented --exclude-base \ ---html-prologue-file $(src_base)/xsd-tree-header.xhtml \ -$$1 >>$@, $(src_root)/xsd/cxx/tree/options.cli) - -# C++/Parser options. -# - $(call message,cli-html $$1,$(cli) $(cli_options) --generate-html \ ---stdout --suppress-undocumented --exclude-base \ ---html-prologue-file $(src_base)/xsd-parser-header.xhtml \ ---html-epilogue-file $(src_base)/xsd-epilogue.xhtml \ -$$1 >>$@, $(src_root)/xsd/cxx/parser/options.cli) - -# MAN -# -$(out_base)/xsd.1: $(src_base)/xsd-prologue.1 \ - $(src_base)/xsd-epilogue.1 \ - $(src_base)/xsd-tree-header.1 \ - $(src_base)/xsd-parser-header.1 \ - | $(out_base)/. -# Common options. -# - $(call message,cli-man $$1,$(cli) $(cli_options) --generate-man \ ---stdout --suppress-undocumented --exclude-base --class CXX::options \ ---class options --man-prologue-file $(src_base)/xsd-prologue.1 \ -$$1 >$@, $(src_root)/xsd/cxx/options.cli) - -# C++/Tree options. -# - $(call message,cli-man $$1,$(cli) $(cli_options) --generate-man \ ---stdout --suppress-undocumented --exclude-base \ ---man-prologue-file $(src_base)/xsd-tree-header.1 \ -$$1 >>$@, $(src_root)/xsd/cxx/tree/options.cli) - -# C++/Parser options. -# - $(call message,cli-man $$1,$(cli) $(cli_options) --generate-man \ ---stdout --suppress-undocumented --exclude-base \ ---man-prologue-file $(src_base)/xsd-parser-header.1 \ ---man-epilogue-file $(src_base)/xsd-epilogue.1 \ -$$1 >>$@, $(src_root)/xsd/cxx/parser/options.cli) - - -# Install. -# -$(install): $(out_base)/cxx/.install \ - $(out_base)/xsd.xhtml \ - $(out_base)/xsd.1 - $(call install-data,$(src_base)/default.css,$(install_doc_dir)/xsd/default.css) - $(call install-data,$(out_base)/xsd.xhtml,$(install_doc_dir)/xsd/xsd.xhtml) - $(call install-data,$(src_base)/custom-literals.xsd,$(install_doc_dir)/xsd/custom-literals.xsd) - $(call install-data,$(out_base)/xsd.1,$(install_man_dir)/man1/xsd.1) - -# Dist. -# -dist-common := $(out_base)/.dist-common - -$(dist-common): $(out_base)/xsd.xhtml \ - $(out_base)/xsd.1 - $(call install-data,$(src_base)/default.css,$(dist_prefix)/doc/default.css) - $(call install-data,$(out_base)/xsd.xhtml,$(dist_prefix)/doc/xsd.xhtml) - $(call install-data,$(out_base)/xsd.1,$(dist_prefix)/doc/xsd.1) - $(call install-data,$(src_base)/custom-literals.xsd,$(dist_prefix)/doc/custom-literals.xsd) - -$(dist): $(dist-common) $(out_base)/cxx/.dist -$(dist-win): $(dist-common) $(out_base)/cxx/.dist-win - -# Clean. -# -$(clean): $(out_base)/cxx/.clean -ifneq ($(xsd_clean_gen),n) - $(call message,rm $$1,rm -f $$1,$(out_base)/xsd.1) - $(call message,rm $$1,rm -f $$1,$(out_base)/xsd.xhtml) -endif - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(out_base)/xsd.xhtml $(out_base)/xsd.1: | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := xsd.1 xsd.xhtml -$(clean): $(out_base)/.gitignore.clean - -$(call include,$(bld_root)/git/gitignore.make) -endif - -$(call include,$(bld_root)/install.make) -$(call import,$(src_base)/cxx/makefile) diff --git a/doc/xsd-epilogue.1 b/doc/xsd-epilogue.1 deleted file mode 100644 index 192880c..0000000 --- a/doc/xsd-epilogue.1 +++ /dev/null @@ -1,566 +0,0 @@ -\" -\" NAMING CONVENTION -\" - -.SH NAMING CONVENTION -The compiler can be instructed to use a particular naming convention in -the generated code. A number of widely-used conventions can be selected -using the -.B --type-naming -and -.B --function-naming -options. A custom naming convention can be achieved using the -.BR --type-regex , -.BR --accessor-regex , -.BR --one-accessor-regex , -.BR --opt-accessor-regex , -.BR --seq-accessor-regex , -.BR --modifier-regex , -.BR --one-modifier-regex , -.BR --opt-modifier-regex , -.BR --seq-modifier-regex , -.BR --parser-regex , -.BR --serializer-regex , -.BR --const-regex , -.BR --enumerator-regex , -and -.B --element-type-regex -options. - -The -.B --type-naming -option specifies the convention that should be used for naming C++ types. -Possible values for this option are -.B knr -(default), -.BR ucc , -and -.BR java . -The -.B knr -value (stands for K&R) signifies the standard, lower-case naming convention -with the underscore used as a word delimiter, for example: foo, foo_bar. -The -.B ucc -(stands for upper-camel-case) and -.B java -values a synonyms for the same naming convention where the first letter -of each word in the name is capitalized, for example: Foo, FooBar. - -Similarly, the -.B --function-naming -option specifies the convention that should be used for naming C++ functions. -Possible values for this option are -.B knr -(default), -.BR lcc , -and -.BR java . -The -.B knr -value (stands for K&R) signifies the standard, lower-case naming convention -with the underscore used as a word delimiter, for example: foo(), foo_bar(). -The -.B lcc -value (stands for lower-camel-case) signifies a naming convention where the -first letter of each word except the first is capitalized, for example: foo(), -fooBar(). The -.B java -naming convention is similar to the lower-camel-case one except that accessor -functions are prefixed with get, modifier functions are prefixed with set, -parsing functions are prefixed with parse, and serialization functions are -prefixed with serialize, for example: getFoo(), setFooBar(), parseRoot(), -serializeRoot(). - -Note that the naming conventions specified with the -.B --type-naming -and -.B --function-naming -options perform only limited transformations on the -names that come from the schema in the form of type, attribute, and element -names. In other words, to get consistent results, your schemas should follow -a similar naming convention as the one you would like to have in the generated -code. Alternatively, you can use the -.B --*-regex -options (discussed below) to perform further transformations on the names -that come from the schema. - -The -.BR --type-regex , -.BR --accessor-regex , -.BR --one-accessor-regex , -.BR --opt-accessor-regex , -.BR --seq-accessor-regex , -.BR --modifier-regex , -.BR --one-modifier-regex , -.BR --opt-modifier-regex , -.BR --seq-modifier-regex , -.BR --parser-regex , -.BR --serializer-regex , -.BR --const-regex , -.BR --enumerator-regex , -and -.B --element-type-regex -options allow you to specify extra regular expressions for each name -category in addition to the predefined set that is added depending on -the -.B --type-naming -and -.B --function-naming -options. Expressions that are provided with the -.B --*-regex -options are evaluated prior to any predefined expressions. This allows -you to selectively override some or all of the predefined transformations. -When debugging your own expressions, it is often useful to see which -expressions match which names. The -.B --name-regex-trace -option allows you to trace the process of applying -regular expressions to names. - -The value for the -.B --*-regex -options should be a perl-like regular expression in the form -.BI / pattern / replacement /\fR. -Any character can be used as a delimiter instead of -.BR / . -Escaping of the delimiter character in -.I pattern -or -.I replacement -is not supported. All the regular expressions for each category are pushed -into a category-specific stack with the last specified expression -considered first. The first match that succeeds is used. For the -.B --one-accessor-regex -(accessors with cardinality one), -.B --opt-accessor-regex -(accessors with cardinality optional), and -.B --seq-accessor-regex -(accessors with cardinality sequence) categories the -.B --accessor-regex -expressions are used as a fallback. For the -.BR --one-modifier-regex , -.BR --opt-modifier-regex , -and -.B --seq-modifier-regex -categories the -.B --modifier-regex -expressions are used as a fallback. For the -.B --element-type-regex -category the -.B --type-regex -expressions are used as a fallback. - -The type name expressions -.RB ( --type-regex ) -are evaluated on the name string that has the following format: - -[\fInamespace \fR]\fIname\fR[\fB,\fIname\fR][\fB,\fIname\fR][\fB,\fIname\fR] - -The element type name expressions -.RB ( --element-type-regex ), -effective only when the -.B --generate-element-type -option is specified, are evaluated on the name string that has the following -format: - -.I namespace name - -In the type name format the -.I namespace -part followed by a space is only present for global type names. For global -types and elements defined in schemas without a target namespace, the -.I namespace -part is empty but the space is still present. In the type name format after -the initial -.I name -component, up to three additional -.I name -components can be present, separated by commas. For example: - -.B http://example.com/hello type - -.B foo - -.B foo,iterator - -.B foo,const,iterator - -The following set of predefined regular expressions is used to transform -type names when the upper-camel-case naming convention is selected: - -.B /(?:[^ ]* )?([^,]+)/\\\\u$1/ - -.B /(?:[^ ]* )?([^,]+),([^,]+)/\\\\u$1\\\\u$2/ - -.B /(?:[^ ]* )?([^,]+),([^,]+),([^,]+)/\\\\u$1\\\\u$2\\\\u$3/ - -.B /(?:[^ ]* )?([^,]+),([^,]+),([^,]+),([^,]+)/\\\\u$1\\\\u$2\\\\u$3\\\\u$4/ - -The accessor and modifier expressions -.RB ( --*accessor-regex -and -.BR --*modifier-regex ) -are evaluated on the name string that has the following format: - -\fIname\fR[\fB,\fIname\fR][\fB,\fIname\fR] - -After the initial -.I name -component, up to two additional -.I name -components can be present, separated by commas. For example: - -.B foo - -.B dom,document - -.B foo,default,value - -The following set of predefined regular expressions is used to transform -accessor names when the -.B java -naming convention is selected: - -.B /([^,]+)/get\\\\u$1/ - -.B /([^,]+),([^,]+)/get\\\\u$1\\\\u$2/ - -.B /([^,]+),([^,]+),([^,]+)/get\\\\u$1\\\\u$2\\\\u$3/ - -For the parser, serializer, and enumerator categories, the corresponding -regular expressions are evaluated on local names of elements and on -enumeration values, respectively. For example, the following predefined -regular expression is used to transform parsing function names when the -.B java -naming convention is selected: - -.B /(.+)/parse\\\\u$1/ - -The const category is used to create C++ constant names for the -element/wildcard/text content ids in ordered types. - -See also the REGEX AND SHELL QUOTING section below. - -\" -\" TYPE MAP -\" -.SH TYPE MAP -Type map files are used in C++/Parser to define a mapping between XML -Schema and C++ types. The compiler uses this information to determine -the return types of -.B post_* -functions in parser skeletons corresponding to XML Schema types -as well as argument types for callbacks corresponding to elements -and attributes of these types. - -The compiler has a set of predefined mapping rules that map built-in -XML Schema types to suitable C++ types (discussed below) and all -other types to -.BR void . -By providing your own type maps you can override these predefined rules. -The format of the type map file is presented below: - -.RS -.B namespace -.I schema-namespace -[ -.I cxx-namespace -] -.br -.B { -.br - ( -.B include -.IB file-name ; -)* -.br - ([ -.B type -] -.I schema-type cxx-ret-type -[ -.I cxx-arg-type -.RB ] ; -)* -.br -.B } -.br -.RE - -Both -.I schema-namespace -and -.I schema-type -are regex patterns while -.IR cxx-namespace , -.IR cxx-ret-type , -and -.I cxx-arg-type -are regex pattern substitutions. All names can be optionally enclosed -in \fR" "\fR, for example, to include white-spaces. - -.I schema-namespace -determines XML Schema namespace. Optional -.I cxx-namespace -is prefixed to every C++ type name in this namespace declaration. -.I cxx-ret-type -is a C++ type name that is used as a return type for the -.B post_* -functions. Optional -.I cxx-arg-type -is an argument type for callback functions corresponding to elements and -attributes of this type. If -.I cxx-arg-type -is not specified, it defaults to -.I cxx-ret-type -if -.I cxx-ret-type -ends with -.B * -or -.B & -(that is, it is a pointer or a reference) and -.B const -\fIcxx-ret-type\fB&\fR otherwise. -.I file-name -is a file name either in the \fR" "\fR or < > format and is added with the -.B #include -directive to the generated code. - -The \fB#\fR character starts a comment that ends with a new line or end of -file. To specify a name that contains \fB#\fR enclose it in \fR" "\fR. For -example: - -.RS -namespace http://www.example.com/xmlns/my my -.br -{ -.br - include "my.hxx"; -.br - - # Pass apples by value. - # - apple apple; -.br - - # Pass oranges as pointers. - # - orange orange_t*; -.br -} -.br -.RE - -In the example above, for the -.B http://www.example.com/xmlns/my#orange -XML Schema type, the -.B my::orange_t* -C++ type will be used as both return and argument types. - -Several namespace declarations can be specified in a single file. -The namespace declaration can also be completely omitted to map -types in a schema without a namespace. For instance: - -.RS -include "my.hxx"; -.br -apple apple; -.br - -namespace http://www.example.com/xmlns/my -.br -{ -.br - orange "const orange_t*"; -.br -} -.br -.RE - - -The compiler has a number of predefined mapping rules that can be -presented as the following map files. The string-based XML Schema -built-in types are mapped to either -.B std::string -or -.B std::wstring -depending on the character type selected with the -.B --char-type -option -.RB ( char -by default). - -.RS -namespace http://www.w3.org/2001/XMLSchema -.br -{ -.br - boolean bool bool; -.br - - byte "signed char" "signed char"; -.br - unsignedByte "unsigned char" "unsigned char"; -.br - - short short short; -.br - unsignedShort "unsigned short" "unsigned short"; -.br - - int int int; -.br - unsignedInt "unsigned int" "unsigned int"; -.br - - long "long long" "long long"; -.br - unsignedLong "unsigned long long" "unsigned long long"; -.br - - integer "long long" "long long"; -.br - - negativeInteger "long long" "long long"; -.br - nonPositiveInteger "long long" "long long"; -.br - - positiveInteger "unsigned long long" "unsigned long long"; -.br - nonNegativeInteger "unsigned long long" "unsigned long long"; -.br - - float float float; -.br - double double double; -.br - decimal double double; -.br - - string std::string; -.br - normalizedString std::string; -.br - token std::string; -.br - Name std::string; -.br - NMTOKEN std::string; -.br - NCName std::string; -.br - ID std::string; -.br - IDREF std::string; -.br - language std::string; -.br - anyURI std::string; -.br - - NMTOKENS xml_schema::string_sequence; -.br - IDREFS xml_schema::string_sequence; -.br - - QName xml_schema::qname; -.br - - base64Binary std::auto_ptr -.br - std::auto_ptr; -.br - hexBinary std::auto_ptr -.br - std::auto_ptr; -.br - - date xml_schema::date; -.br - dateTime xml_schema::date_time; -.br - duration xml_schema::duration; -.br - gDay xml_schema::gday; -.br - gMonth xml_schema::gmonth; -.br - gMonthDay xml_schema::gmonth_day; -.br - gYear xml_schema::gyear; -.br - gYearMonth xml_schema::gyear_month; -.br - time xml_schema::time; -.br -} -.br -.RE - - -The last predefined rule maps anything that wasn't mapped by previous -rules to -.BR void : - -.RS -namespace .* -.br -{ -.br - .* void void; -.br -} -.br -.RE - -When you provide your own type maps with the -.B --type-map -option, they are evaluated first. This allows you to selectively override -predefined rules. - -.\" -.\" REGEX AND SHELL QUOTING -.\" -.SH REGEX AND SHELL QUOTING -When entering a regular expression argument in the shell command line -it is often necessary to use quoting (enclosing the argument in " " -or ' ') in order to prevent the shell from interpreting certain -characters, for example, spaces as argument separators and $ as -variable expansions. - -Unfortunately it is hard to achieve this in a manner that is portable -across POSIX shells, such as those found on GNU/Linux and UNIX, and -Windows shell. For example, if you use " " for quoting you will get -a wrong result with POSIX shells if your expression contains $. The -standard way of dealing with this on POSIX systems is to use ' ' -instead. Unfortunately, Windows shell does not remove ' ' from -arguments when they are passed to applications. As a result you may -have to use ' ' for POSIX and " " for Windows ($ is not treated as -a special character on Windows). - -Alternatively, you can save regular expression options into a file, -one option per line, and use this file with the -.B --options-file -option. With this approach you don't need to worry about shell quoting. - -.\" -.\" DIAGNOSTICS -.\" -.SH DIAGNOSTICS -If the input file is not a valid W3C XML Schema definition, -.B xsd -will issue diagnostic messages to -.B STDERR -and exit with non-zero exit code. -.SH BUGS -Send bug reports to the xsd-users@codesynthesis.com mailing list. -.SH COPYRIGHT -Copyright (c) $copyright$. - -Permission is granted to copy, distribute and/or modify this -document under the terms of the GNU Free Documentation License, -version 1.2; with no Invariant Sections, no Front-Cover Texts and -no Back-Cover Texts. Copy of the license can be obtained from -https://www.codesynthesis.com/licenses/fdl-1.2.txt diff --git a/doc/xsd-epilogue.xhtml b/doc/xsd-epilogue.xhtml deleted file mode 100644 index aef0418..0000000 --- a/doc/xsd-epilogue.xhtml +++ /dev/null @@ -1,422 +0,0 @@ -

NAMING CONVENTION

- -

The compiler can be instructed to use a particular naming - convention in the generated code. A number of widely-used - conventions can be selected using the --type-naming - and --function-naming options. A custom - naming convention can be achieved using the - --type-regex, - --accessor-regex, - --one-accessor-regex, - --opt-accessor-regex, - --seq-accessor-regex, - --modifier-regex, - --one-modifier-regex, - --opt-modifier-regex, - --seq-modifier-regex, - --parser-regex, - --serializer-regex, - --const-regex, - --enumerator-regex, and - --element-type-regex options. -

- -

The --type-naming option specifies the - convention that should be used for naming C++ types. Possible - values for this option are knr (default), - ucc, and java. The - knr value (stands for K&R) signifies - the standard, lower-case naming convention with the underscore - used as a word delimiter, for example: foo, - foo_bar. The ucc (stands - for upper-camel-case) and - java values a synonyms for the same - naming convention where the first letter of each word in the - name is capitalized, for example: Foo, - FooBar.

- -

Similarly, the --function-naming option - specifies the convention that should be used for naming C++ - functions. Possible values for this option are knr - (default), lcc, and java. The - knr value (stands for K&R) signifies - the standard, lower-case naming convention with the underscore - used as a word delimiter, for example: foo(), - foo_bar(). The lcc value - (stands for lower-camel-case) signifies a naming convention - where the first letter of each word except the first is - capitalized, for example: foo(), fooBar(). - The java naming convention is similar to - the lower-camel-case one except that accessor functions are prefixed - with get, modifier functions are prefixed - with set, parsing functions are prefixed - with parse, and serialization functions are - prefixed with serialize, for example: - getFoo(), setFooBar(), - parseRoot(), serializeRoot().

- -

Note that the naming conventions specified with the - --type-naming and - --function-naming options perform only limited - transformations on the names that come from the schema in the - form of type, attribute, and element names. In other words, to - get consistent results, your schemas should follow a similar - naming convention as the one you would like to have in the - generated code. Alternatively, you can use the - --*-regex options (discussed below) - to perform further transformations on the names that come from - the schema.

- -

The - --type-regex, - --accessor-regex, - --one-accessor-regex, - --opt-accessor-regex, - --seq-accessor-regex, - --modifier-regex, - --one-modifier-regex, - --opt-modifier-regex, - --seq-modifier-regex, - --parser-regex, - --serializer-regex, - --const-regex, - --enumerator-regex, and - --element-type-regex options allow you to - specify extra regular expressions for each name category in - addition to the predefined set that is added depending on - the --type-naming and - --function-naming options. Expressions - that are provided with the --*-regex - options are evaluated prior to any predefined expressions. - This allows you to selectively override some or all of the - predefined transformations. When debugging your own expressions, - it is often useful to see which expressions match which names. - The --name-regex-trace option allows you - to trace the process of applying regular expressions to - names.

- -

The value for the --*-regex options should be - a perl-like regular expression in the form - /pattern/replacement/. - Any character can be used as a delimiter instead of /. - Escaping of the delimiter character in pattern or - replacement is not supported. - All the regular expressions for each category are pushed into a - category-specific stack with the last specified expression - considered first. The first match that succeeds is used. For the - --one-accessor-regex (accessors with cardinality one), - --opt-accessor-regex (accessors with cardinality optional), and - --seq-accessor-regex (accessors with cardinality sequence) - categories the --accessor-regex expressions are - used as a fallback. For the - --one-modifier-regex, - --opt-modifier-regex, and - --seq-modifier-regex - categories the --modifier-regex expressions are - used as a fallback. For the --element-type-regex - category the --type-regex expressions are - used as a fallback.

- -

The type name expressions (--type-regex) - are evaluated on the name string that has the following - format:

- -

[namespace ]name[,name][,name][,name]

- -

The element type name expressions - (--element-type-regex), effective only when - the --generate-element-type option is specified, - are evaluated on the name string that has the following - format:

- -

namespace name

- -

In the type name format the namespace part - followed by a space is only present for global type names. For - global types and elements defined in schemas without a target - namespace, the namespace part is empty but - the space is still present. In the type name format after the - initial name component, up to three additional - name components can be present, separated - by commas. For example:

- -

http://example.com/hello type

-

foo

-

foo,iterator

-

foo,const,iterator

- -

The following set of predefined regular expressions is used to - transform type names when the upper-camel-case naming convention - is selected:

- -

/(?:[^ ]* )?([^,]+)/\u$1/

-

/(?:[^ ]* )?([^,]+),([^,]+)/\u$1\u$2/

-

/(?:[^ ]* )?([^,]+),([^,]+),([^,]+)/\u$1\u$2\u$3/

-

/(?:[^ ]* )?([^,]+),([^,]+),([^,]+),([^,]+)/\u$1\u$2\u$3\u$4/

- -

The accessor and modifier expressions - (--*accessor-regex and - --*modifier-regex) are evaluated on the name string - that has the following format:

- -

name[,name][,name]

- -

After the initial name component, up to two - additional name components can be present, - separated by commas. For example:

- -

foo

-

dom,document

-

foo,default,value

- -

The following set of predefined regular expressions is used to - transform accessor names when the java naming - convention is selected:

- -

/([^,]+)/get\u$1/

-

/([^,]+),([^,]+)/get\u$1\u$2/

-

/([^,]+),([^,]+),([^,]+)/get\u$1\u$2\u$3/

- -

For the parser, serializer, and enumerator categories, the - corresponding regular expressions are evaluated on local names of - elements and on enumeration values, respectively. For example, the - following predefined regular expression is used to transform parsing - function names when the java naming convention - is selected:

- -

/(.+)/parse\u$1/

- -

The const category is used to create C++ constant names for the - element/wildcard/text content ids in ordered types.

- -

See also the REGEX AND SHELL QUOTING section below.

- -

TYPE MAP

- -

Type map files are used in C++/Parser to define a mapping between - XML Schema and C++ types. The compiler uses this information - to determine the return types of post_* - functions in parser skeletons corresponding to XML Schema - types as well as argument types for callbacks corresponding - to elements and attributes of these types.

- -

The compiler has a set of predefined mapping rules that map - built-in XML Schema types to suitable C++ types (discussed - below) and all other types to void. - By providing your own type maps you can override these predefined - rules. The format of the type map file is presented below: -

- -
-namespace <schema-namespace> [<cxx-namespace>]
-{
-  (include <file-name>;)*
-  ([type] <schema-type> <cxx-ret-type> [<cxx-arg-type>];)*
-}
-  
- -

Both <schema-namespace> and - <schema-type> are regex patterns while - <cxx-namespace>, - <cxx-ret-type>, and - <cxx-arg-type> are regex pattern - substitutions. All names can be optionally enclosed in - " ", for example, to include white-spaces.

- -

<schema-namespace> determines XML - Schema namespace. Optional <cxx-namespace> - is prefixed to every C++ type name in this namespace declaration. - <cxx-ret-type> is a C++ type name that is - used as a return type for the post_* functions. - Optional <cxx-arg-type> is an argument - type for callback functions corresponding to elements and attributes - of this type. If - <cxx-arg-type> is not specified, it defaults - to <cxx-ret-type> if <cxx-ret-type> - ends with * or & (that is, - it is a pointer or a reference) and - const <cxx-ret-type>& - otherwise. - <file-name> is a file name either in the - " " or < > format - and is added with the #include directive to - the generated code.

- -

The # character starts a comment that ends - with a new line or end of file. To specify a name that contains - # enclose it in " ". - For example:

- -
-namespace http://www.example.com/xmlns/my my
-{
-  include "my.hxx";
-
-  # Pass apples by value.
-  #
-  apple apple;
-
-  # Pass oranges as pointers.
-  #
-  orange orange_t*;
-}
-  
- -

In the example above, for the - http://www.example.com/xmlns/my#orange - XML Schema type, the my::orange_t* C++ type will - be used as both return and argument types.

- -

Several namespace declarations can be specified in a single - file. The namespace declaration can also be completely - omitted to map types in a schema without a namespace. For - instance:

- -
-include "my.hxx";
-apple apple;
-
-namespace http://www.example.com/xmlns/my
-{
-  orange "const orange_t*";
-}
-  
- -

The compiler has a number of predefined mapping rules that can be - presented as the following map files. The string-based XML Schema - built-in types are mapped to either std::string - or std::wstring depending on the character type - selected with the --char-type option - (char by default).

- -
-namespace http://www.w3.org/2001/XMLSchema
-{
-  boolean bool bool;
-
-  byte "signed char" "signed char";
-  unsignedByte "unsigned char" "unsigned char";
-
-  short short short;
-  unsignedShort "unsigned short" "unsigned short";
-
-  int int int;
-  unsignedInt "unsigned int" "unsigned int";
-
-  long "long long" "long long";
-  unsignedLong "unsigned long long" "unsigned long long";
-
-  integer "long long" "long long";
-
-  negativeInteger "long long" "long long";
-  nonPositiveInteger "long long" "long long";
-
-  positiveInteger "unsigned long long" "unsigned long long";
-  nonNegativeInteger "unsigned long long" "unsigned long long";
-
-  float float float;
-  double double double;
-  decimal double double;
-
-  string std::string;
-  normalizedString std::string;
-  token std::string;
-  Name std::string;
-  NMTOKEN std::string;
-  NCName std::string;
-  ID std::string;
-  IDREF std::string;
-  language std::string;
-  anyURI std::string;
-
-  NMTOKENS xml_schema::string_sequence;
-  IDREFS xml_schema::string_sequence;
-
-  QName xml_schema::qname;
-
-  base64Binary std::auto_ptr<xml_schema::buffer>
-               std::auto_ptr<xml_schema::buffer>;
-  hexBinary std::auto_ptr<xml_schema::buffer>
-            std::auto_ptr<xml_schema::buffer>;
-
-  date xml_schema::date;
-  dateTime xml_schema::date_time;
-  duration xml_schema::duration;
-  gDay xml_schema::gday;
-  gMonth xml_schema::gmonth;
-  gMonthDay xml_schema::gmonth_day;
-  gYear xml_schema::gyear;
-  gYearMonth xml_schema::gyear_month;
-  time xml_schema::time;
-}
-  
- -

The last predefined rule maps anything that wasn't mapped by - previous rules to void:

- -
-namespace .*
-{
-  .* void void;
-}
-  
- - -

When you provide your own type maps with the - --type-map option, they are evaluated first. - This allows you to selectively override predefined rules.

- -

REGEX AND SHELL QUOTING

- -

When entering a regular expression argument in the shell - command line it is often necessary to use quoting (enclosing - the argument in " " or - ' ') in order to prevent the shell - from interpreting certain characters, for example, spaces as - argument separators and $ as variable - expansions.

- -

Unfortunately it is hard to achieve this in a manner that is - portable across POSIX shells, such as those found on - GNU/Linux and UNIX, and Windows shell. For example, if you - use " " for quoting you will get a - wrong result with POSIX shells if your expression contains - $. The standard way of dealing with this - on POSIX systems is to use ' ' instead. - Unfortunately, Windows shell does not remove ' ' - from arguments when they are passed to applications. As a result you - may have to use ' ' for POSIX and - " " for Windows ($ is - not treated as a special character on Windows).

- -

Alternatively, you can save regular expression options into - a file, one option per line, and use this file with the - --options-file option. With this approach - you don't need to worry about shell quoting.

- -

DIAGNOSTICS

- -

If the input file is not a valid W3C XML Schema definition, - xsd will issue diagnostic messages to STDERR - and exit with non-zero exit code.

- -

BUGS

- -

Send bug reports to the - xsd-users@codesynthesis.com mailing list.

- - - - - - diff --git a/doc/xsd-parser-header.1 b/doc/xsd-parser-header.1 deleted file mode 100644 index e0cf84e..0000000 --- a/doc/xsd-parser-header.1 +++ /dev/null @@ -1,4 +0,0 @@ -\" -\" C++/Parser -\" -.SS cxx-parser command options diff --git a/doc/xsd-parser-header.xhtml b/doc/xsd-parser-header.xhtml deleted file mode 100644 index 94fa2c1..0000000 --- a/doc/xsd-parser-header.xhtml +++ /dev/null @@ -1 +0,0 @@ -

CXX-PARSER COMMAND OPTIONS

diff --git a/doc/xsd-prologue.1 b/doc/xsd-prologue.1 deleted file mode 100644 index 50872b4..0000000 --- a/doc/xsd-prologue.1 +++ /dev/null @@ -1,119 +0,0 @@ -.\" Process this file with -.\" groff -man -Tascii xsd.1 -.\" -.TH XSD 1 "July 2014" "XSD 4.1.0" -.SH NAME -xsd \- W3C XML Schema to C++ Compiler -.\" -.\" -.\" -.\"-------------------------------------------------------------------- -.SH SYNOPSIS -.\"-------------------------------------------------------------------- -.B xsd -.I command -.B [ -.I options -.B ] -.I file -.B [ -.I file -.B ...] -.in -.B xsd help -.B [ -.I command -.B ] -.in -.B xsd version -.\" -.\" -.\" -.\"-------------------------------------------------------------------- -.SH DESCRIPTION -.\"-------------------------------------------------------------------- -.B xsd -generates vocabulary-specific, statically-typed C++ mapping from W3C XML -Schema definitions. Particular mapping to produce is selected by a -.IR command . -Each mapping has a number of mapping-specific -.I options -that should appear, if any, after the -.IR command . -Input files should be W3C XML Schema definitions. The exact set of the -generated files depends on the selected mapping and options. -.\" -.\" -.\" -.\"-------------------------------------------------------------------- -.SH COMMANDS -.\"-------------------------------------------------------------------- -.IP \fBcxx-tree\fR -Generate the C++/Tree mapping. For each input file in the form -.B name.xsd -the following C++ files are generated: -.B name.hxx -(header file), -.B name.ixx -(inline file, generated only if the -.B --generate-inline -option is specified), -.B name.cxx -(source file), and -.B name-fwd.hxx -(forward declaration file, generated only if the -.B --generate-forward -option is specified). - -.IP \fBcxx-parser\fR -Generate the C++/Parser mapping. For each input file in the form -.B name.xsd -the following C++ files are generated: -.B name-pskel.hxx -(parser skeleton header file), -.B name-pskel.ixx -(parser skeleton inline file, generated only if the -.B --generate-inline -option is specified), and -.B name-pskel.cxx -(parser skeleton source file). If the -.B --generate-noop-impl -or -.B --generate-print-impl -option is specified, the following additional sample implementation files -are generated: -.B name-pimpl.hxx -(parser implementation header file) and -.B name-pimpl.cxx -(parser implementation source file). If the -.B --generate-test-driver -option is specified, the additional -.B name-driver.cxx -test driver file is generated. - -.IP \fBhelp\fR -Print usage information and exit. Use -.PP -.RS -.RS 3 -.B xsd help -.I command -.RE -.PP -for command-specific help. -.RE -.IP \fBversion\fR -Print version and exit. -.\"-------------------------------------------------------------------- -.SH OPTIONS -.\"-------------------------------------------------------------------- -Command-specific -.IR options , -if any, should appear after the corresponding -.IR command . - -.\" -.\" Common options. -.\" -.SS common options -. diff --git a/doc/xsd-prologue.xhtml b/doc/xsd-prologue.xhtml deleted file mode 100644 index 6facbe8..0000000 --- a/doc/xsd-prologue.xhtml +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - XSD 4.1.0 Compiler Command Line Manual - - - - - - - - - - - -
-
- -

NAME

- -

xsd - W3C XML Schema to C++ Compiler

- -

SYNOPSIS

- -
-
xsd command [options] file [file ...]
-
xsd help [command]
-
xsd version
-
- -

DESCRIPTION

- -

xsd generates vocabulary-specific, statically-typed - C++ mapping from W3C XML Schema definitions. Particular mapping to - produce is selected by a command. Each mapping has - a number of mapping-specific options that should - appear, if any, after the command. Input files should - be W3C XML Schema definitions. The exact set of the generated files depends - on the selected mapping and options.

- -

COMMANDS

- -
-
cxx-tree
-
Generate the C++/Tree mapping. For each input file in the form - name.xsd the following C++ files are generated: - name.hxx (header file), - name.ixx (inline file, generated only if the - --generate-inline option is specified), - name.cxx (source file), and - name-fwd.hxx (forward declaration file, generated - only if the --generate-forward option is - specified).
- -
cxx-parser
-
Generate the C++/Parser mapping. For each input file in the form - name.xsd the following C++ files are generated: - name-pskel.hxx (parser skeleton header file), - name-pskel.ixx (parser skeleton inline file, - generated only if the --generate-inline - option is specified), and - name-pskel.cxx (parser skeleton source file). - If the --generate-noop-impl or - --generate-print-impl option is specified, - the following additional sample implementation files are generated: - name-pimpl.hxx (parser implementation header - file) and - name-pimpl.cxx (parser implementation source - file). If the --generate-test-driver option - is specified, the additional name-driver.cxx - test driver file is generated.
- -
help
-
Print usage information and exit. Use -

xsd help command

- for command-specific help. -
- -
version
-
Print version and exit.
-
- -

OPTIONS

- -

Command-specific options, if any, should appear - after the corresponding command.

- -

COMMON OPTIONS

diff --git a/doc/xsd-tree-header.1 b/doc/xsd-tree-header.1 deleted file mode 100644 index b9146a7..0000000 --- a/doc/xsd-tree-header.1 +++ /dev/null @@ -1,4 +0,0 @@ -.\" -.\" C++/Tree options. -.\" -.SS cxx-tree command options diff --git a/doc/xsd-tree-header.xhtml b/doc/xsd-tree-header.xhtml deleted file mode 100644 index 73f9c99..0000000 --- a/doc/xsd-tree-header.xhtml +++ /dev/null @@ -1 +0,0 @@ -

CXX-TREE COMMAND OPTIONS

diff --git a/examples/cxx/parser/README b/examples/cxx/parser/README deleted file mode 100644 index 01906c7..0000000 --- a/examples/cxx/parser/README +++ /dev/null @@ -1,45 +0,0 @@ -This directory contains a number of examples that show how to use -the C++/Parser mapping. The following list gives an overview of -each example. See the README files in example directories for -more information on each example. - -hello - A simple "Hello, world!" example that shows how to parse XML - documents. - -generated - Shows how to use the sample implementation and test driver - generation feature. This example does not have any hand-written - C++ code; everything is generated by the XSD compiler. - -library - Shows how to handle more complex data structures and construct - a custom in-memory object model. - -mixin - Shows how to reuse implementations of base parsers in derived - parsers using the mixin C++ idiom. - -wildcard - Shows how to parse the XML data matched by XML Schema wildcards - (any and anyAttribute). - -multiroot - Shows how to handle XML vocabularies with multiple root elements. - -polymorphism - Shows how to use XML Schema polymorphism features such as the - xsi:type attribute and substitution groups. - -polyroot - Shows how to handle the xsi:type attribute when it is used on root - elements. - -performance - Measures the performance of XML parsing. This example also shows how - to structure your code to achieve the maximum performance for this - operation. - -mixed - Shows how to handle raw, "type-less content" such as mixed content - models, anyType/anySimpleType, and any/anyAttribute. \ No newline at end of file diff --git a/examples/cxx/parser/generated/README b/examples/cxx/parser/generated/README deleted file mode 100644 index ca56974..0000000 --- a/examples/cxx/parser/generated/README +++ /dev/null @@ -1,32 +0,0 @@ -This example shows how to use the sample implementation and test -driver generation feature of the C++/Parser mapping. This example -does not have any hand-written C++ code; everything is generated -by the XSD compiler. - -The example consists of the following files: - -library.xsd - XML Schema which describes a library of books. - -library.xml - Sample XML instance document. - -library-pskel.hxx -library-pskel.cxx - Parser skeletons generated by XSD from library.xsd. - -library-pimpl.hxx -library-pimpl.cxx - Sample parser implementations that print the XML data to STDOUT. - These are generated by XSD from library.xsd with the - --generate-print-impl option. - -library-driver.cxx - Sample driver for the example. It is generated by XSD from - library.xsd with the --generate-test-driver option. - - -To run the example on the sample XML instance document simply -execute: - -$ ./library-driver library.xml diff --git a/examples/cxx/parser/generated/library.xml b/examples/cxx/parser/generated/library.xml deleted file mode 100644 index b1ac98c..0000000 --- a/examples/cxx/parser/generated/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/parser/generated/library.xsd b/examples/cxx/parser/generated/library.xsd deleted file mode 100644 index 71e4005..0000000 --- a/examples/cxx/parser/generated/library.xsd +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/parser/generated/makefile b/examples/cxx/parser/generated/makefile deleted file mode 100644 index cfce1a7..0000000 --- a/examples/cxx/parser/generated/makefile +++ /dev/null @@ -1,109 +0,0 @@ -# file : examples/cxx/parser/generated/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := library.xsd - -obj := $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.o) $(xsd:.xsd=-pimpl.o) $(xsd:.xsd=-driver.o)) -dep := $(obj:.o=.o.d) - - -driver := $(out_base)/$(xsd:.xsd=-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) \ - $(xsd:.xsd=-pimpl.hxx) \ - $(xsd:.xsd=-pimpl.cxx) \ - $(xsd:.xsd=-driver.cxx) - -gen := $(addprefix $(out_base)/,$(genf)) - - -$(gen): xsd := $(out_root)/xsd/xsd -$(gen): xsd_options += --generate-print-impl --generate-test-driver \ ---force-overwrite -$(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)/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)/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): $(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)) \ - $(addprefix $(out_base)/,$(xsd:.xsd=-pimpl.cxx.xsd.clean)) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(gen): | $(out_base)/.gitignore -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := $(xsd:.xsd=-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) - -xsd_parser_impl_suffix := -pimpl -$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/examples/cxx/parser/hello/README b/examples/cxx/parser/hello/README deleted file mode 100644 index 97449de..0000000 --- a/examples/cxx/parser/hello/README +++ /dev/null @@ -1,28 +0,0 @@ -This is a "Hello, world!" example that shows how to use the -C++/Parser mapping to parse XML instance documents. - -The example consists of the following files: - -hello.xsd - XML Schema which describes "hello" instance documents. - -hello.xml - Sample XML instance document. - -hello-pskel.hxx -hello-pskel.cxx - Parser skeletons generated by XSD from hello.xsd. - -driver.cxx - A parser implementation and a driver for the example. The - parser implementation simply prints the data to STDERR. - The driver first constructs a parser instance from the - parser implementation mentioned above and a couple of - predefined parsers for the XML Schema built-in types. - In then invokes this parser instance to parse the input - file. - -To run the example on the sample XML instance document simply -execute: - -$ ./driver hello.xml diff --git a/examples/cxx/parser/hello/driver.cxx b/examples/cxx/parser/hello/driver.cxx deleted file mode 100644 index e261e10..0000000 --- a/examples/cxx/parser/hello/driver.cxx +++ /dev/null @@ -1,67 +0,0 @@ -// file : examples/cxx/parser/hello/driver.cxx -// copyright : not copyrighted - public domain - -#include -#include - -#include "hello-pskel.hxx" - -using namespace std; - -struct hello_pimpl: hello_pskel -{ - virtual void - greeting (const string& greeting) - { - greeting_ = greeting; - } - - virtual void - name (const string& name) - { - cout << greeting_ << ", " << name << "!" << endl; - } - -private: - string greeting_; -}; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " hello.xml" << endl; - return 1; - } - - try - { - // Construct the parser. - // - xml_schema::string_pimpl string_p; - hello_pimpl hello_p; - - hello_p.greeting_parser (string_p); - hello_p.name_parser (string_p); - - // Parse the XML instance document. The second argument to the - // document's constructor is the document's root element name. - // - xml_schema::document doc_p (hello_p, "hello"); - - hello_p.pre (); - doc_p.parse (argv[1]); - hello_p.post_hello (); - } - 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/hello/hello.xml b/examples/cxx/parser/hello/hello.xml deleted file mode 100644 index dd0c13d..0000000 --- a/examples/cxx/parser/hello/hello.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - Hello - - sun - moon - world - - diff --git a/examples/cxx/parser/hello/hello.xsd b/examples/cxx/parser/hello/hello.xsd deleted file mode 100644 index be69957..0000000 --- a/examples/cxx/parser/hello/hello.xsd +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/examples/cxx/parser/hello/makefile b/examples/cxx/parser/hello/makefile deleted file mode 100644 index 9317315..0000000 --- a/examples/cxx/parser/hello/makefile +++ /dev/null @@ -1,100 +0,0 @@ -# file : examples/cxx/parser/hello/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := hello.xsd -cxx := driver.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): $(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)/hello.xsd,$(install_doc_dir)/xsd/$(path)/hello.xsd) - $(call install-data,$(src_base)/hello.xml,$(install_doc_dir)/xsd/$(path)/hello.xml) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/hello.xsd,$(dist_prefix)/$(path)/hello.xsd) - $(call install-data,$(src_base)/hello.xml,$(dist_prefix)/$(path)/hello.xml) - -$(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/library/README b/examples/cxx/parser/library/README deleted file mode 100644 index 3f515f6..0000000 --- a/examples/cxx/parser/library/README +++ /dev/null @@ -1,44 +0,0 @@ -This example shows how to use the C++/Parser mapping to construct -a custom in-memory object model from XML instance documents. - -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 - Types that describe a library of books in C++. These are - hand-written. - -library.map - Type map. It maps XML Schema types defined in library.xsd - to the C++ types defined in library.hxx. - -library-pskel.hxx -library-pskel.ixx -library-pskel.cxx - Parser skeletons generated by XSD from library.xsd and - library.map. - -library-pimpl.hxx -library-pimpl.cxx - Parser implementations that construct the custom in-memory - object model from an XML instance using the types from - library.hxx. These are hand-written implementations of - the parser skeletons defined in library-pskel.hxx. - -driver.cxx - Driver for the example. It first constructs a parser - instance from all the individual parsers found in - library-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 - in-memory object model to STDERR. - -To run the example on the sample XML instance document simply -execute: - -$ ./driver library.xml diff --git a/examples/cxx/parser/library/driver.cxx b/examples/cxx/parser/library/driver.cxx deleted file mode 100644 index 3b63801..0000000 --- a/examples/cxx/parser/library/driver.cxx +++ /dev/null @@ -1,109 +0,0 @@ -// file : examples/cxx/parser/library/driver.cxx -// copyright : not copyrighted - public domain - -#include - -#include "library.hxx" -#include "library-pimpl.hxx" - -using std::cerr; -using std::endl; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " library.xml" << endl; - return 1; - } - - try - { - using namespace library; - - - // Construct the parser. - // - xml_schema::id_pimpl id_p; - xml_schema::idref_pimpl idref_p; - xml_schema::string_pimpl string_p; - xml_schema::boolean_pimpl boolean_p; - - isbn_pimpl isbn_p; - - title_pimpl title_p; - title_p.lang_parser (string_p); - - genre_pimpl genre_p; - - author_pimpl author_p; - author_p.parsers (string_p, // name - string_p, // born - string_p, // died - idref_p); // recommends - - book_pimpl book_p; - book_p.parsers (isbn_p, // isbn - title_p, // title - genre_p, // genre - author_p, // author - boolean_p, // available - id_p); // id - - catalog_pimpl catalog_p; - catalog_p.book_parser (book_p); - - - // Parse the XML instance document. - // - xml_schema::document doc_p ( - catalog_p, - "http://www.codesynthesis.com/library", // root element namespace - "catalog"); // root element name - - catalog_p.pre (); - doc_p.parse (argv[1]); - catalog c (catalog_p.post_catalog ()); - - - // Let's print what we've got. - // - for (catalog::const_iterator bi (c.begin ()); bi != c.end (); ++bi) - { - cerr << endl - << "ID : " << bi->id () << endl - << "ISBN : " << bi->isbn () << endl - << "Title : " << bi->title () << endl - << "Genre : " << bi->genre () << endl; - - for (book::authors::const_iterator ai (bi->author ().begin ()); - ai != bi->author ().end (); - ++ai) - { - cerr << "Author : " << ai->name () << endl; - cerr << " Born : " << ai->born () << endl; - - if (!ai->died ().empty ()) - cerr << " Died : " << ai->died () << endl; - - if (!ai->recommends ().empty ()) - { - cerr << " Recommends : " << ai->recommends () << endl; - } - } - - cerr << "Available : " << std::boolalpha << bi->available () << 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/library/library-pimpl.cxx b/examples/cxx/parser/library/library-pimpl.cxx deleted file mode 100644 index 7a1e484..0000000 --- a/examples/cxx/parser/library/library-pimpl.cxx +++ /dev/null @@ -1,183 +0,0 @@ -// file : examples/cxx/parser/library/library-pimpl.cxx -// copyright : not copyrighted - public domain - -#include "library-pimpl.hxx" - -namespace library -{ - // isbn_impl - // - isbn isbn_pimpl:: - post_isbn () - { - return post_unsigned_int (); - } - - // title_pimpl - // - void title_pimpl:: - _pre () - { - title_.lang (""); - } - - void title_pimpl:: - lang (const std::string& lang) - { - title_.lang (lang); - } - - title title_pimpl:: - post_title () - { - title_.assign (post_string ()); - return title_; - } - - // genre_pimpl - // - genre genre_pimpl:: - post_genre () - { - genre r (romance); - std::string v (post_string ()); - - if (v == "romance") r = romance; else - if (v == "fiction") r = fiction; else - if (v == "horror") r = horror; else - if (v == "history") r = history; else - if (v == "philosophy") r = philosophy; - - return r; - } - - // person_pimpl - // - void person_pimpl:: - _pre () - { - person_.died (""); - } - - void person_pimpl:: - name (const std::string& name) - { - person_.name (name); - } - - void person_pimpl:: - born (const std::string& born) - { - person_.born (born); - } - - void person_pimpl:: - died (const std::string& died) - { - person_.died (died); - } - - person person_pimpl:: - post_person () - { - return person_; - } - - // author_pimpl - // - void author_pimpl:: - _pre () - { - person_pimpl::_pre (); - author_.recommends (""); - } - - void author_pimpl:: - recommends (const std::string& recommends) - { - author_.recommends (recommends); - } - - author author_pimpl:: - post_author () - { - person p (post_person ()); - - author_.name (p.name ()); - author_.born (p.born ()); - author_.died (p.died ()); - - return author_; - } - - // book_pimpl - // - void book_pimpl:: - _pre () - { - book_.author ().clear (); - } - - void book_pimpl:: - isbn (library::isbn isbn) - { - book_.isbn (isbn); - } - - void book_pimpl:: - title (const library::title& title) - { - book_.title (title); - } - - void book_pimpl:: - genre (library::genre genre) - { - book_.genre (genre); - } - - void book_pimpl:: - author (const library::author& author) - { - book_.author ().push_back (author); - } - - void book_pimpl:: - available (bool available) - { - book_.available (available); - } - - void book_pimpl:: - id (const std::string& id) - { - book_.id (id); - } - - book book_pimpl:: - post_book () - { - return book_; - } - - // catalog_pimpl - // - void catalog_pimpl:: - _pre () - { - catalog_.clear (); - } - - void catalog_pimpl:: - book (const library::book& book) - { - catalog_.push_back (book); - } - - catalog catalog_pimpl:: - post_catalog () - { - return catalog_; - } -} - diff --git a/examples/cxx/parser/library/library-pimpl.hxx b/examples/cxx/parser/library/library-pimpl.hxx deleted file mode 100644 index 5d0dcc1..0000000 --- a/examples/cxx/parser/library/library-pimpl.hxx +++ /dev/null @@ -1,135 +0,0 @@ -// file : examples/cxx/parser/library/library-pimpl.hxx -// copyright : not copyrighted - public domain - -#ifndef LIBRARY_PIMPL_HXX -#define LIBRARY_PIMPL_HXX - -#include "library.hxx" -#include "library-pskel.hxx" - -namespace library -{ - // - // - struct isbn_pimpl: isbn_pskel, xml_schema::unsigned_int_pimpl - { - virtual isbn - post_isbn (); - }; - - // - // - struct title_pimpl: title_pskel, xml_schema::string_pimpl - { - virtual void - _pre (); - - virtual void - lang (const std::string&); - - virtual title - post_title (); - - private: - title title_; - }; - - // - // - struct genre_pimpl: genre_pskel, xml_schema::string_pimpl - { - virtual genre - post_genre (); - }; - - // - // - struct person_pimpl: virtual person_pskel - { - virtual void - _pre (); - - virtual void - name (const std::string&); - - virtual void - born (const std::string&); - - virtual void - died (const std::string&); - - virtual person - post_person (); - - private: - person person_; - }; - - // - // - struct author_pimpl: author_pskel, person_pimpl - { - virtual void - _pre (); - - virtual void - recommends (const std::string&); - - virtual author - post_author (); - - private: - author author_; - }; - - // - // - struct book_pimpl: book_pskel - { - virtual void - _pre (); - - virtual void - isbn (library::isbn); - - virtual void - title (const library::title&); - - virtual void - genre (library::genre); - - virtual void - author (const library::author&); - - virtual void - available (bool); - - virtual void - id (const std::string&); - - virtual book - post_book (); - - private: - book book_; - }; - - // - // - struct catalog_pimpl: catalog_pskel - { - virtual void - _pre (); - - virtual void - book (const library::book&); - - virtual catalog - post_catalog (); - - private: - catalog catalog_; - }; -} - -#endif // LIBRARY_PIMPL_HXX diff --git a/examples/cxx/parser/library/library.hxx b/examples/cxx/parser/library/library.hxx deleted file mode 100644 index 552e7a5..0000000 --- a/examples/cxx/parser/library/library.hxx +++ /dev/null @@ -1,241 +0,0 @@ -// file : examples/cxx/parser/library/library.hxx -// copyright : not copyrighted - public domain - -#ifndef LIBRARY_HXX -#define LIBRARY_HXX - -#include -#include - -namespace library -{ - // - // - typedef unsigned int isbn; - - - // - // - struct title: std::string - { - // lang - // - const std::string& - lang () const - { - return lang_; - } - - void - lang (const std::string& lang) - { - lang_ = lang; - } - - private: - std::string lang_; - }; - - - // - // - enum genre - { - romance, - fiction, - horror, - history, - philosophy - }; - - - // - // - struct person - { - // name - // - const std::string& - name () const - { - return name_; - } - - void - name (const std::string& name) - { - name_ = name; - } - - // born - // - const std::string& - born () const - { - return born_; - } - - void - born (const std::string& born) - { - born_ = born; - } - - - // died - // - const std::string& - died () const - { - return died_; - } - - void - died (const std::string& died) - { - died_ = died; - } - - private: - std::string name_; - std::string born_; - std::string died_; - }; - - - // - // - struct author: person - { - // recommends - // - const std::string& - recommends () const - { - return recommends_; - } - - void - recommends (const std::string& recommends) - { - recommends_ = recommends; - } - - private: - std::string recommends_; - }; - - - // - // - struct book - { - // isbn - // - library::isbn - isbn () const - { - return isbn_; - } - - void - isbn (const library::isbn& isbn) - { - isbn_ = isbn; - } - - - // title - // - library::title - title () const - { - return title_; - } - - void - title (const library::title& title) - { - title_ = title; - } - - - // genre - // - library::genre - genre () const - { - return genre_; - } - - void - genre (const library::genre& genre) - { - genre_ = genre; - } - - - // author - // - typedef std::vector authors; - - const authors& - author () const - { - return author_; - } - - authors& - author () - { - return author_; - } - - - // available - // - bool - available () const - { - return available_; - } - - void - available (bool available) - { - available_ = available; - } - - - // id - // - const std::string& - id () const - { - return id_; - } - - void - id (const std::string& id) - { - id_ = id; - } - - private: - library::isbn isbn_; - library::title title_; - library::genre genre_; - - authors author_; - - bool available_; - std::string id_; - }; - - - // - // - typedef std::vector catalog; -} - -#endif // LIBRARY_HXX diff --git a/examples/cxx/parser/library/library.map b/examples/cxx/parser/library/library.map deleted file mode 100644 index 3a49b49..0000000 --- a/examples/cxx/parser/library/library.map +++ /dev/null @@ -1,15 +0,0 @@ -# file : examples/cxx/parser/library/library.map -# copyright : not copyrighted - public domain - -namespace http://www.codesynthesis.com/library ::library -{ - include "library.hxx"; - - isbn isbn isbn; - title title; - genre genre genre; - person person; - author author; - book book; - catalog catalog; -} diff --git a/examples/cxx/parser/library/library.xml b/examples/cxx/parser/library/library.xml deleted file mode 100644 index b1ac98c..0000000 --- a/examples/cxx/parser/library/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/parser/library/library.xsd b/examples/cxx/parser/library/library.xsd deleted file mode 100644 index 71e4005..0000000 --- a/examples/cxx/parser/library/library.xsd +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/parser/library/makefile b/examples/cxx/parser/library/makefile deleted file mode 100644 index fc6cdaf..0000000 --- a/examples/cxx/parser/library/makefile +++ /dev/null @@ -1,109 +0,0 @@ -# file : examples/cxx/parser/library/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := library.xsd -cxx := driver.cxx library-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 += --generate-inline --type-map $(src_base)/library.map -$(gen): $(out_root)/xsd/xsd $(src_base)/library.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)/library.xsd,$(install_doc_dir)/xsd/$(path)/library.xsd) - $(call install-data,$(src_base)/library.xml,$(install_doc_dir)/xsd/$(path)/library.xml) - $(call install-data,$(src_base)/library.map,$(install_doc_dir)/xsd/$(path)/library.map) - $(call install-data,$(src_base)/library.hxx,$(install_doc_dir)/xsd/$(path)/library.hxx) - $(call install-data,$(src_base)/library-pimpl.hxx,$(install_doc_dir)/xsd/$(path)/library-pimpl.hxx) - $(call install-data,$(src_base)/library-pimpl.cxx,$(install_doc_dir)/xsd/$(path)/library-pimpl.cxx) - -$(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) - $(call install-data,$(src_base)/library.map,$(dist_prefix)/$(path)/library.map) - $(call install-data,$(src_base)/library.hxx,$(dist_prefix)/$(path)/library.hxx) - $(call install-data,$(src_base)/library-pimpl.hxx,$(dist_prefix)/$(path)/library-pimpl.hxx) - $(call install-data,$(src_base)/library-pimpl.cxx,$(dist_prefix)/$(path)/library-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/makefile b/examples/cxx/parser/makefile deleted file mode 100644 index 449557a..0000000 --- a/examples/cxx/parser/makefile +++ /dev/null @@ -1,55 +0,0 @@ -# file : examples/cxx/parser/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make - -examples := generated hello library mixin mixed multiroot performance \ -polymorphism polyroot wildcard - -default := $(out_base)/ -install := $(out_base)/.install -dist := $(out_base)/.dist -dist-win := $(out_base)/.dist-win -clean := $(out_base)/.clean - -# Build -# -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(examples))) - - -# Install & Dist. -# -$(install) $(dist) $(dist-win): path := $(subst $(src_root)/,,$(src_base)) - -$(install): $(addprefix $(out_base)/,$(addsuffix /.install,$(examples))) - $(call install-data,$(src_base)/README,$(install_doc_dir)/xsd/$(path)/README) - -$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(examples))) - $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README) - -$(dist-win): export dirs := $(examples) -$(dist-win): |$(out_root)/.dist-pre -$(dist-win): $(addprefix $(out_base)/,$(addsuffix /.dist-win,$(examples))) - $(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,parser-vc8.sln) - $(call meta-vc9sln,$(src_root)/dist/template-vc9.sln,parser-vc9.sln) - $(call meta-vc10sln,$(src_root)/dist/template-vc10.sln,parser-vc10.sln) - $(call meta-vc11sln,$(src_root)/dist/template-vc11.sln,parser-vc11.sln) - $(call meta-vc12sln,$(src_root)/dist/template-vc12.sln,parser-vc12.sln) - $(call meta-vctest,parser-vc8.sln,$(src_root)/dist/examples/test.bat,test.bat) - -# Clean -# -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(examples))) - -$(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) -$(call include,$(bld_root)/meta/vctest.make) - - -$(foreach e,$(examples),$(call import,$(src_base)/$e/makefile)) diff --git a/examples/cxx/parser/mixed/README b/examples/cxx/parser/mixed/README deleted file mode 100644 index 23ace6f..0000000 --- a/examples/cxx/parser/mixed/README +++ /dev/null @@ -1,49 +0,0 @@ -This example shows how to handle raw, "type-less content" such as -mixed content models, anyType/anySimpleType, and any/anyAttribute -in the C++/Parser mapping. - -In this example we use mixed content model to describe text -with embedded links, e.g., - - This paragraph talks about time. - -The example transforms such text into plain text with -references, e.g., - - This paragraph talks about time[0]. - - [0] uri - -The example consists of the following files: - -text.xsd - XML Schema which describes "text with links" instance - documents. - -text.xml - Sample XML instance document. - -anchor.hxx - Anchor type that captures the information about a link. - -text.map - Type map. It maps XML Schema anchor types defined in - text.xsd to C++ anchor class defined in anchor.hxx. - -text-pskel.hxx -text-pskel.cxx - Parser skeletons generated by XSD from text.xsd and - text.map. - -driver.cxx - A parser implementation and a driver for the example. The - parser implementation prints the transformed text to STDOUT. - The driver first constructs a parser instance from the parser - implementation mentioned above and a couple of predefined - parsers for the XML Schema built-in types. In then invokes - this parser instance to parse the input file. - -To run the example on the sample XML instance document simply -execute: - -$ ./driver text.xml diff --git a/examples/cxx/parser/mixed/anchor.hxx b/examples/cxx/parser/mixed/anchor.hxx deleted file mode 100644 index 3adc90b..0000000 --- a/examples/cxx/parser/mixed/anchor.hxx +++ /dev/null @@ -1,33 +0,0 @@ -// file : examples/cxx/parser/mixed/anchor.hxx -// copyright : not copyrighted - public domain - -#ifndef ANCHOR_HXX -#define ANCHOR_HXX - -#include - -struct anchor -{ - anchor (const std::string& text, const std::string& uri) - : uri_ (uri), text_ (text) - { - } - - const std::string& - text () const - { - return text_; - } - - const std::string& - uri () const - { - return uri_; - } - -private: - std::string uri_; - std::string text_; -}; - -#endif // ANCHOR_HXX diff --git a/examples/cxx/parser/mixed/driver.cxx b/examples/cxx/parser/mixed/driver.cxx deleted file mode 100644 index 3f3cc65..0000000 --- a/examples/cxx/parser/mixed/driver.cxx +++ /dev/null @@ -1,100 +0,0 @@ -// file : examples/cxx/parser/mixed/driver.cxx -// copyright : not copyrighted - public domain - -#include -#include -#include - -#include "anchor.hxx" -#include "text-pskel.hxx" - -using namespace std; - -struct anchor_pimpl: anchor_pskel, xml_schema::string_pimpl -{ - virtual void - href (const std::string& uri) - { - uri_ = uri; - } - - virtual anchor - post_anchor () - { - return anchor (post_string (), uri_); - } - -private: - std::string uri_; -}; - - -struct text_pimpl: text_pskel -{ - virtual void - a (const anchor& a) - { - cout << a.text () << "[" << anchors_.size () << "]"; - anchors_.push_back (a); - } - - virtual void - _any_characters (const xml_schema::ro_string& s) - { - cout << s; - } - - virtual void - post_text () - { - for (anchors::const_iterator i (anchors_.begin ()); - i != anchors_.end (); - ++i) - { - cout << "[" << i - anchors_.begin () << "] " << i->uri () << endl; - } - } - -private: - typedef vector anchors; - anchors anchors_; -}; - - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " text.xml" << endl; - return 1; - } - - try - { - // Construct the parser. - // - xml_schema::string_pimpl string_p; - anchor_pimpl anchor_p; - text_pimpl text_p; - - anchor_p.href_parser (string_p); - text_p.a_parser (anchor_p); - - xml_schema::document doc_p (text_p, "text"); - - text_p.pre (); - doc_p.parse (argv[1]); - text_p.post_text (); - } - 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/mixed/makefile b/examples/cxx/parser/mixed/makefile deleted file mode 100644 index 7104250..0000000 --- a/examples/cxx/parser/mixed/makefile +++ /dev/null @@ -1,106 +0,0 @@ -# file : examples/cxx/parser/mixed/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := text.xsd -cxx := driver.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)/text.map -$(gen): $(out_root)/xsd/xsd $(src_base)/text.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)/text.xsd,$(install_doc_dir)/xsd/$(path)/text.xsd) - $(call install-data,$(src_base)/text.xml,$(install_doc_dir)/xsd/$(path)/text.xml) - $(call install-data,$(src_base)/text.map,$(install_doc_dir)/xsd/$(path)/text.map) - $(call install-data,$(src_base)/anchor.hxx,$(install_doc_dir)/xsd/$(path)/anchor.hxx) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/text.xsd,$(dist_prefix)/$(path)/text.xsd) - $(call install-data,$(src_base)/text.xml,$(dist_prefix)/$(path)/text.xml) - $(call install-data,$(src_base)/text.map,$(dist_prefix)/$(path)/text.map) - $(call install-data,$(src_base)/anchor.hxx,$(dist_prefix)/$(path)/anchor.hxx) - -$(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/mixed/text.map b/examples/cxx/parser/mixed/text.map deleted file mode 100644 index 85971c4..0000000 --- a/examples/cxx/parser/mixed/text.map +++ /dev/null @@ -1,6 +0,0 @@ -# file : examples/cxx/parser/mixed/text.map -# copyright : not copyrighted - public domain - -include "anchor.hxx"; - -anchor ::anchor; diff --git a/examples/cxx/parser/mixed/text.xml b/examples/cxx/parser/mixed/text.xml deleted file mode 100644 index bfdc881..0000000 --- a/examples/cxx/parser/mixed/text.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - -The first paragraph of this text talks about time. - -And this paragraph talks about space. - - diff --git a/examples/cxx/parser/mixed/text.xsd b/examples/cxx/parser/mixed/text.xsd deleted file mode 100644 index 92e300c..0000000 --- a/examples/cxx/parser/mixed/text.xsd +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/parser/mixin/README b/examples/cxx/parser/mixin/README deleted file mode 100644 index 343e379..0000000 --- a/examples/cxx/parser/mixin/README +++ /dev/null @@ -1,34 +0,0 @@ -This example shows how to reuse implementations of base parsers -in derived parsers using the mixin C++ idiom. - -The example consists of the following files: - -schema.xsd - XML Schema which defined two data types: base and - derived. - -instance.xml - Sample XML instance document. - -types.hxx - C++ classes that correspond to the base and derived - types in schema.xsd. - -schema.map - Type map. It maps XML Schema types defined in schema.xsd - to C++ types defined in types.hxx. - -schema-pskel.hxx -schema-pskel.cxx - Parser skeletons generated by XSD from schema.xsd and - schema.map. - -driver.cxx - Parser implementations and a driver for the example. It - shows how to mix the implementation of the base parser - into the derived parser. - -To run the example on the sample XML instance document simply -execute: - -$ ./driver instance.xml diff --git a/examples/cxx/parser/mixin/driver.cxx b/examples/cxx/parser/mixin/driver.cxx deleted file mode 100644 index 04466a1..0000000 --- a/examples/cxx/parser/mixin/driver.cxx +++ /dev/null @@ -1,103 +0,0 @@ -// file : examples/cxx/parser/mixin/driver.cxx -// copyright : not copyrighted - public domain - -#include -#include - -#include "types.hxx" -#include "schema-pskel.hxx" - -using namespace std; - -struct base_pimpl: virtual base_pskel -{ - virtual void - pre () - { - base_.reset (new ::base); - } - - virtual void - a (bool v) - { - base_->a (v); - } - - virtual base* - post_base () - { - return base_.release (); - } - -protected: - auto_ptr base_; -}; - -// Implement derived parser by mixing-in base's implementation. -// -struct derived_pimpl: derived_pskel, base_pimpl -{ - virtual void - pre () - { - // Override base's pre() with the new implementation that - // instantiates derived instead of base. - // - base_.reset (new ::derived); - } - - virtual void - b (int v) - { - // We could also store a pointer to derived in derived_impl to - // avoid casting. - // - static_cast< ::derived* > (base_.get ())->b (v); - } - - virtual derived* - post_derived () - { - return static_cast (base_.release ()); - } -}; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " instance.xml" << endl; - return 1; - } - - try - { - // Construct the parser. - // - xml_schema::boolean_pimpl bool_p; - xml_schema::int_pimpl int_p; - derived_pimpl derived_p; - - derived_p.parsers (bool_p, int_p); - - xml_schema::document doc_p (derived_p, "root"); - - derived_p.pre (); - doc_p.parse (argv[1]); - auto_ptr d (derived_p.post_derived ()); - - cerr << "a: " << boolalpha << d->a () << endl; - cerr << "b: " << d->b () << 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/mixin/instance.xml b/examples/cxx/parser/mixin/instance.xml deleted file mode 100644 index 253f348..0000000 --- a/examples/cxx/parser/mixin/instance.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - true - 1 - - diff --git a/examples/cxx/parser/mixin/makefile b/examples/cxx/parser/mixin/makefile deleted file mode 100644 index c4203d8..0000000 --- a/examples/cxx/parser/mixin/makefile +++ /dev/null @@ -1,106 +0,0 @@ -# file : examples/cxx/parser/mixin/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := schema.xsd -cxx := driver.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)/schema.map -$(gen): $(out_root)/xsd/xsd $(src_base)/schema.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)/schema.xsd,$(install_doc_dir)/xsd/$(path)/schema.xsd) - $(call install-data,$(src_base)/instance.xml,$(install_doc_dir)/xsd/$(path)/instance.xml) - $(call install-data,$(src_base)/schema.map,$(install_doc_dir)/xsd/$(path)/schema.map) - $(call install-data,$(src_base)/types.hxx,$(install_doc_dir)/xsd/$(path)/types.hxx) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/schema.xsd,$(dist_prefix)/$(path)/schema.xsd) - $(call install-data,$(src_base)/instance.xml,$(dist_prefix)/$(path)/instance.xml) - $(call install-data,$(src_base)/schema.map,$(dist_prefix)/$(path)/schema.map) - $(call install-data,$(src_base)/types.hxx,$(dist_prefix)/$(path)/types.hxx) - -$(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/mixin/schema.map b/examples/cxx/parser/mixin/schema.map deleted file mode 100644 index a93c881..0000000 --- a/examples/cxx/parser/mixin/schema.map +++ /dev/null @@ -1,7 +0,0 @@ -# file : examples/cxx/parser/mixin/schema.map -# copyright : not copyrighted - public domain - -include "types.hxx"; - -base ::base*; -derived ::derived*; diff --git a/examples/cxx/parser/mixin/schema.xsd b/examples/cxx/parser/mixin/schema.xsd deleted file mode 100644 index d2d195d..0000000 --- a/examples/cxx/parser/mixin/schema.xsd +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/parser/mixin/types.hxx b/examples/cxx/parser/mixin/types.hxx deleted file mode 100644 index 930033d..0000000 --- a/examples/cxx/parser/mixin/types.hxx +++ /dev/null @@ -1,43 +0,0 @@ -// file : examples/cxx/parser/mixin/types.hxx -// copyright : not copyrighted - public domain - -#ifndef TYPES_HXX -#define TYPES_HXX - -struct base -{ - bool - a () const - { - return a_; - } - - void - a (bool v) - { - a_ = v; - } - -private: - bool a_; -}; - -struct derived: base -{ - int - b () const - { - return b_; - } - - void - b (int v) - { - b_ = v; - } - -private: - int b_; -}; - -#endif // TYPES_HXX 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 - - diff --git a/examples/cxx/parser/performance/README b/examples/cxx/parser/performance/README deleted file mode 100644 index 39aecca..0000000 --- a/examples/cxx/parser/performance/README +++ /dev/null @@ -1,42 +0,0 @@ -This example measures the performance of XML parsing in the C++/Parser -mapping. It also shows how to structure your code to achieve the maximum -performance for this operation. - -The example consists of the following files: - -test.xsd - XML Schema which describes the test vocabulary. - -test-50k.xml - Test XML document. - -gen.cxx - Program to generate a test document of desired size. - -time.hxx -time.cxx - Class definition that represents time. - -test-pskel.hxx -test-pskel.ixx -test-pskel.cxx - Parser skeletons generated by the XSD compiler from test.xsd. - -driver.cxx - Driver for the example. It first parses the command line arguments - and reads the entire document into a memory buffer. It then creates - a SAX parser and pre-parses and caches the schema if validation is - enabled (Xerces-C++ only). Finally, it runs the performance - measurement loop which on each iteration parses the XML document - from the in-memory buffer. - -To run the example on a test XML document simply execute: - -$ ./driver test-50k.xml - -The -v option can be used to turn on validation in the underlying XML -parser (only makes sense for Xerces-C++, off by default). The -i option -can be used to specify the number of parsing iterations (1000 by default). -For example: - -$ ./driver -v -i 100 test-50k.xml diff --git a/examples/cxx/parser/performance/driver.cxx b/examples/cxx/parser/performance/driver.cxx deleted file mode 100644 index 302464e..0000000 --- a/examples/cxx/parser/performance/driver.cxx +++ /dev/null @@ -1,341 +0,0 @@ -// file : examples/cxx/parser/performance/driver.cxx -// copyright : not copyrighted - public domain - -#include -#include // std::auto_ptr -#include // std::size_t -#include -#include -#include - -#include "time.hxx" -#include "test-pskel.hxx" - -#ifdef _XERCES_VERSION -# include -# include -# include -# include -# include -# include - -# include -# include -#endif - -// No-op parser implementation. -// -namespace test -{ - struct enum_pimpl: enum_pskel, xml_schema::string_pimpl - { - virtual void - post_enum () - { - } - }; - - struct record_pimpl: record_pskel - { - virtual void - int_ (unsigned int) - { - } - - virtual void - double_ (double) - { - } - - virtual void - name (const std::string&) - { - } - - virtual void - string (const std::string&) - { - } - - virtual void - choice1 (const std::string&) - { - } - - virtual void - choice2 (const std::string&) - { - } - - virtual void - choice3 (const std::string&) - { - } - - virtual void - choice4 (const std::string&) - { - } - - virtual void - apple (bool) - { - } - - virtual void - orange (unsigned long long) - { - } - }; - - struct root_pimpl: root_pskel - { - }; -} - -using namespace std; - -int -main (int argc, char* argv[]) -{ - if (argc < 2) - { - cerr << "usage: " << argv[0] << " [-v] [-i ] test.xml" << endl - << "\t -v turn on validation (default is off)" << endl - << "\t -i number of iterations to perform (default is 1000)" << endl; - return 1; - } - - bool validate (false); - unsigned long iter (1000); - const char* file (0); - - // Parse command line arguments. - // - for (int i (1); i < argc; ++i) - { - string arg (argv[i]); - - if (arg == "-v") - { - validate = true; - } - else if (arg == "-i") - { - if (++i == argc) - { - cerr << "argument expected for the -i option" << endl; - return 1; - } - - iter = 0; - istringstream is (argv[i]); - is >> iter; - - if (iter == 0) - { - cerr << "invalid argument for the -i option" << endl; - return 1; - } - } - else - { - file = argv[i]; - break; - } - } - - if (file == 0) - { - cerr << "no input file specified" << endl; - return 1; - } - - try - { - // Instantiate and connect parsers. - // - xml_schema::unsigned_int_pimpl unsigned_int_p; - xml_schema::double_pimpl double_p; - xml_schema::ncname_pimpl ncname_p; - xml_schema::string_pimpl string_p; - xml_schema::boolean_pimpl boolean_p; - xml_schema::unsigned_long_pimpl unsigned_long_p; - - test::enum_pimpl enum_p; - test::record_pimpl record_p; - test::root_pimpl root_p; - - record_p.parsers (unsigned_int_p, - double_p, - ncname_p, - string_p, - string_p, - string_p, - string_p, - string_p, - enum_p, - boolean_p, - unsigned_long_p); - - root_p.parsers (record_p); - - // Read the fine into in-memory buffer. - // - ifstream ifs; - ifs.exceptions (ios_base::failbit); - ifs.open (file, ios::in | ios::ate); - - size_t size (ifs.tellg ()); - ifs.seekg (0, ios::beg); - - char* buf = new char[size]; - ifs.read (buf, size); - ifs.close (); - - cerr << "document size: " << size << " bytes" << endl - << "iterations: " << iter << endl; - - os::time time (0); - xml_schema::document doc (root_p, "test", "root"); - -#ifdef _XERCES_VERSION - - // Xerces-C++ as the underlying XML parser. - // - using namespace xercesc; - - namespace xml = xsd::cxx::xml; - namespace parser = xsd::cxx::parser; - - XMLPlatformUtils::Initialize (); - - { - MemBufInputSource is ( - reinterpret_cast (buf), size, file, false); - is.setCopyBufToStream (false); - - auto_ptr parser (XMLReaderFactory::createXMLReader ()); - - parser->setFeature (XMLUni::fgSAX2CoreNameSpaces, true); - parser->setFeature (XMLUni::fgSAX2CoreNameSpacePrefixes, true); - parser->setFeature (XMLUni::fgXercesValidationErrorAsFatal, true); - - if (validate) - { - parser->setFeature (XMLUni::fgSAX2CoreValidation, true); - parser->setFeature (XMLUni::fgXercesSchema, true); - parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); - - // Xerces-C++ 3.1.0 is the first version with working multi import - // support. - // -#if _XERCES_VERSION >= 30100 - parser->setFeature (XMLUni::fgXercesHandleMultipleImports, true); -#endif - - // Initialize the schema cache. To detect schema errors we will - // need an error handler. - // - parser::error_handler eh; - xml::sax::bits::error_handler_proxy ehp (eh); - parser->setErrorHandler (&ehp); - - if (!parser->loadGrammar ("test.xsd", Grammar::SchemaGrammarType, true)) - { - // In Xerces-C++ grammar loading failure results in just a warning. - // Make it a fatal error. - // - eh.handle ("test.xsd", 0, 0, - parser::error_handler::severity::fatal, - "unable to load schema"); - } - - eh.throw_if_failed (); - parser->setFeature (XMLUni::fgXercesUseCachedGrammarInParse, true); - -#if _XERCES_VERSION >= 30100 - parser->setFeature (XMLUni::fgXercesLoadSchema, false); -#endif - } - else - { - parser->setFeature (XMLUni::fgSAX2CoreValidation, false); - parser->setFeature (XMLUni::fgXercesSchema, false); - parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); - } - - os::time start; - - for (unsigned long i (0); i < iter; ++i) - { - root_p.pre (); - doc.parse (is, *parser); - root_p.post_root (); - } - - os::time end; - time = end - start; - } - - XMLPlatformUtils::Terminate (); - -#else - - // Expat as the underlying XML parser. - // - XML_Parser xml_parser (XML_ParserCreateNS (0, ' ')); - string public_id (file); - - os::time start; - - for (unsigned long i (0); i < iter; ++i) - { - // Using the low-level Expat-specific API to parse the memory - // buffer. - // - root_p.pre (); - doc.parse_begin (xml_parser, public_id); - - XML_Parse (xml_parser, buf, size, 1); - - doc.parse_end (); - root_p.post_root (); - - XML_ParserReset (xml_parser, 0); - } - - os::time end; - time = end - start; - - XML_ParserFree (xml_parser); - -#endif - - delete[] buf; - - cerr << "time: " << time << " sec" << endl; - - double ms (time.sec () * 1000000ULL + time.nsec () / 1000ULL); - - // Calculate throughput in documents/sec. - // - double tpd ((iter / ms) * 1000000); - cerr << "throughput: " << tpd << " documents/sec" << endl; - - // Calculate throughput in MBytes/sec. - // - double tpb (((size * iter) / ms) * 1000000/(1024*1024)); - cerr << "throughput: " << tpb << " MBytes/sec" << endl; - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - return 1; - } - catch (std::ios_base::failure const&) - { - cerr << "io failure" << endl; - return 1; - } -} diff --git a/examples/cxx/parser/performance/gen.cxx b/examples/cxx/parser/performance/gen.cxx deleted file mode 100644 index b6392c0..0000000 --- a/examples/cxx/parser/performance/gen.cxx +++ /dev/null @@ -1,76 +0,0 @@ -#include -#include -#include - -using namespace std; - -static const char* enums[] = -{ - "romance", - "fiction", - "horror", - "history", - "philosophy" -}; - -int -main (int argc, char* argv[]) -{ - if (argc != 3) - { - cerr << "usage: " << argv[0] << " " << endl; - return 1; - } - - unsigned long n (0); - istringstream is (argv[1]); - is >> n; - - if (n == 0) - { - cerr << "record count argument should be a positive number" << endl; - return 1; - } - - ofstream ofs (argv[2]); - - if (!ofs.is_open ()) - { - cerr << "unable to open '" << argv[2] << "' in write mode" << endl; - return 1; - } - - ofs << ""; - - unsigned short ch (1), en (0); - - for (unsigned long i (0); i < n; ++i) - { - ofs << "" - << "42" - << "42345.4232" - << "name123_45"; - - if (i % 2 == 1) - ofs << "one two three"; - - ofs << "" << ch << " choice" - << "" << enums[en] << "" - << ""; - - if (++ch > 4) - ch = 1; - - if (++en > 4) - en = 0; - } - - ofs << ""; -} diff --git a/examples/cxx/parser/performance/makefile b/examples/cxx/parser/performance/makefile deleted file mode 100644 index 9a7a26b..0000000 --- a/examples/cxx/parser/performance/makefile +++ /dev/null @@ -1,108 +0,0 @@ -# file : examples/cxx/parser/performance/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx time.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 += --generate-inline -$(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)/test.xsd,$(install_doc_dir)/xsd/$(path)/test.xsd) - $(call install-data,$(src_base)/test-50k.xml,$(install_doc_dir)/xsd/$(path)/test-50k.xml) - $(call install-data,$(src_base)/time.hxx,$(install_doc_dir)/xsd/$(path)/time.hxx) - $(call install-data,$(src_base)/time.cxx,$(install_doc_dir)/xsd/$(path)/time.cxx) - $(call install-data,$(src_base)/gen.cxx,$(install_doc_dir)/xsd/$(path)/gen.cxx) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/test.xsd,$(dist_prefix)/$(path)/test.xsd) - $(call install-data,$(src_base)/test-50k.xml,$(dist_prefix)/$(path)/test-50k.xml) - $(call install-data,$(src_base)/time.hxx,$(dist_prefix)/$(path)/time.hxx) - $(call install-data,$(src_base)/time.cxx,$(dist_prefix)/$(path)/time.cxx) - $(call install-data,$(src_base)/gen.cxx,$(dist_prefix)/$(path)/gen.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/performance/test-50k.xml b/examples/cxx/parser/performance/test-50k.xml deleted file mode 100644 index 42e22f3..0000000 --- a/examples/cxx/parser/performance/test-50k.xml +++ /dev/null @@ -1 +0,0 @@ -4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction \ No newline at end of file diff --git a/examples/cxx/parser/performance/test.xsd b/examples/cxx/parser/performance/test.xsd deleted file mode 100644 index bb59c2a..0000000 --- a/examples/cxx/parser/performance/test.xsd +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/parser/performance/time.cxx b/examples/cxx/parser/performance/time.cxx deleted file mode 100644 index aca5c74..0000000 --- a/examples/cxx/parser/performance/time.cxx +++ /dev/null @@ -1,46 +0,0 @@ -// file : examples/cxx/parser/performance/time.cxx -// copyright : not copyrighted - public domain - -#include "time.hxx" - -#if defined (WIN32) || defined (__WIN32__) -# define WIN32_LEAN_AND_MEAN -# include // GetSystemTimeAsFileTime -#else -# include // gettimeofday -# include // timeval -#endif - -#include // std::ostream -#include // std::setfill, std::setw - -namespace os -{ - time:: - time () - { -#if defined (WIN32) || defined (__WIN32__) - FILETIME ft; - GetSystemTimeAsFileTime (&ft); - unsigned long long v ( - ((unsigned long long) (ft.dwHighDateTime) << 32) + ft.dwLowDateTime); - - sec_ = static_cast (v / 10000000ULL); - nsec_ = static_cast ((v % 10000000ULL) * 100); -#else - timeval tv; - if (gettimeofday(&tv, 0) != 0) - throw failed (); - - sec_ = static_cast (tv.tv_sec); - nsec_ = static_cast (tv.tv_usec * 1000); -#endif - } - - std::ostream& - operator<< (std::ostream& o, time const& t) - { - return o << t.sec () << '.' - << std::setfill ('0') << std::setw (9) << t.nsec (); - } -} diff --git a/examples/cxx/parser/performance/time.hxx b/examples/cxx/parser/performance/time.hxx deleted file mode 100644 index 3b2f040..0000000 --- a/examples/cxx/parser/performance/time.hxx +++ /dev/null @@ -1,110 +0,0 @@ -// file : examples/cxx/parser/performance/time.hxx -// copyright : not copyrighted - public domain - -#ifndef TIME_HXX -#define TIME_HXX - -#include // std::ostream& - -namespace os -{ - class time - { - public: - class failed {}; - - // Create a time object representing the current time. - // - time (); - - time (unsigned long long nsec) - { - sec_ = static_cast (nsec / 1000000000ULL); - nsec_ = static_cast (nsec % 1000000000ULL); - } - - time (unsigned long sec, unsigned long nsec) - { - sec_ = sec; - nsec_ = nsec; - } - - public: - unsigned long - sec () const - { - return sec_; - } - - unsigned long - nsec () const - { - return nsec_; - } - - public: - class overflow {}; - class underflow {}; - - time - operator+= (time const& b) - { - unsigned long long tmp = 0ULL + nsec_ + b.nsec_; - - sec_ += static_cast (b.sec_ + tmp / 1000000000ULL); - nsec_ = static_cast (tmp % 1000000000ULL); - - return *this; - } - - time - operator-= (time const& b) - { - if (*this < b) - throw underflow (); - - sec_ -= b.sec_; - - if (nsec_ < b.nsec_) - { - --sec_; - nsec_ += 1000000000ULL - b.nsec_; - } - else - nsec_ -= b.nsec_; - - return *this; - } - - friend time - operator+ (time const& a, time const& b) - { - time r (a); - r += b; - return r; - } - - friend time - operator- (time const& a, time const& b) - { - time r (a); - r -= b; - return r; - } - - friend bool - operator < (time const& a, time const& b) - { - return (a.sec_ < b.sec_) || (a.sec_ == b.sec_ && a.nsec_ < b.nsec_); - } - - private: - unsigned long sec_; - unsigned long nsec_; - }; - - std::ostream& - operator<< (std::ostream&, time const&); -} - -#endif // TIME_HXX diff --git a/examples/cxx/parser/polymorphism/README b/examples/cxx/parser/polymorphism/README deleted file mode 100644 index 60a97e9..0000000 --- a/examples/cxx/parser/polymorphism/README +++ /dev/null @@ -1,30 +0,0 @@ -This example shows how to handle XML Schema polymorphism features such -as xsi:type attributes and substitution groups in the C++/Parser mapping. -The case when xsi:type is used on root elements is covered in the -polyroot examples. - -The example consists of the following files: - -supermen.xsd - XML Schema which describes the "supermen" instance documents. - -supermen.xml - Sample XML instance document. - -supermen-pskel.hxx -supermen-pskel.cxx - Parser skeletons generated by the XSD compiler from supermen.xsd. - Note the use of the --generate-polymorphic command line option. - -supermen-pimpl.hxx -supermen-pimpl.cxx - Parser implementations that print the XML data to STDOUT. - -driver.cxx - Driver for the example. It first constructs a parser instance from - all the individual parsers found in supermen-pimpl.hxx. It then invokes - this parser instance to parse the input file. - -To run the example on the sample XML instance document simply execute: - -$ ./driver supermen.xml diff --git a/examples/cxx/parser/polymorphism/driver.cxx b/examples/cxx/parser/polymorphism/driver.cxx deleted file mode 100644 index ffbe48b..0000000 --- a/examples/cxx/parser/polymorphism/driver.cxx +++ /dev/null @@ -1,70 +0,0 @@ -// file : examples/cxx/parser/polymorphism/driver.cxx -// copyright : not copyrighted - public domain - -#include - -#include "supermen-pimpl.hxx" - -using std::cerr; -using std::endl; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " supermen.xml" << endl; - return 1; - } - - try - { - // Construct the parser. - // - xml_schema::string_pimpl string_p; - xml_schema::boolean_pimpl boolean_p; - xml_schema::unsigned_int_pimpl unsigned_int_p; - - person_pimpl person_p; - superman_pimpl superman_p; - batman_pimpl batman_p; - - xml_schema::parser_map_impl person_map; - - supermen_pimpl supermen_p; - - - person_p.parsers (string_p); - superman_p.parsers (string_p, boolean_p); - batman_p.parsers (string_p, boolean_p, unsigned_int_p); - - // Here we are specifying a parser map which containes several parsers - // that can be used to parse the person element. - // - person_map.insert (person_p); - person_map.insert (superman_p); - person_map.insert (batman_p); - - supermen_p.person_parser (person_map); - - // Parse the XML document. The last argument to the document's - // constructor indicates that we are parsing polymorphic XML - // documents. - // - xml_schema::document doc_p (supermen_p, "supermen", true); - - supermen_p.pre (); - doc_p.parse (argv[1]); - supermen_p.post_supermen (); - } - 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/polymorphism/makefile b/examples/cxx/parser/polymorphism/makefile deleted file mode 100644 index 918c283..0000000 --- a/examples/cxx/parser/polymorphism/makefile +++ /dev/null @@ -1,105 +0,0 @@ -# file : examples/cxx/parser/polymorphism/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := supermen.xsd -cxx := driver.cxx supermen-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 += --generate-polymorphic -$(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)/supermen.xsd,$(install_doc_dir)/xsd/$(path)/supermen.xsd) - $(call install-data,$(src_base)/supermen.xml,$(install_doc_dir)/xsd/$(path)/supermen.xml) - $(call install-data,$(src_base)/supermen-pimpl.hxx,$(install_doc_dir)/xsd/$(path)/supermen-pimpl.hxx) - $(call install-data,$(src_base)/supermen-pimpl.cxx,$(install_doc_dir)/xsd/$(path)/supermen-pimpl.cxx) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/supermen.xsd,$(dist_prefix)/$(path)/supermen.xsd) - $(call install-data,$(src_base)/supermen.xml,$(dist_prefix)/$(path)/supermen.xml) - $(call install-data,$(src_base)/supermen-pimpl.hxx,$(dist_prefix)/$(path)/supermen-pimpl.hxx) - $(call install-data,$(src_base)/supermen-pimpl.cxx,$(dist_prefix)/$(path)/supermen-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/polymorphism/supermen-pimpl.cxx b/examples/cxx/parser/polymorphism/supermen-pimpl.cxx deleted file mode 100644 index f4b3bc6..0000000 --- a/examples/cxx/parser/polymorphism/supermen-pimpl.cxx +++ /dev/null @@ -1,85 +0,0 @@ -// file : examples/cxx/parser/polymorphism/supermen-pimpl.cxx -// copyright : not copyrighted - public domain -// - -#include - -#include "supermen-pimpl.hxx" - -using std::cout; -using std::endl; - -// person_pimpl -// -void person_pimpl:: -pre () -{ - cout << "starting to parse person" << endl; -} - -void person_pimpl:: -name (const std::string& v) -{ - cout << "name: " << v << endl; -} - -void person_pimpl:: -post_person () -{ - cout << "finished parsing person" << endl - << endl; -} - -// superman_pimpl -// -void superman_pimpl:: -pre () -{ - cout << "starting to parse superman" << endl; -} - -void superman_pimpl:: -can_fly (bool v) -{ - cout << "can-fly: " << v << endl; -} - -void superman_pimpl:: -post_person () -{ - post_superman (); -} - -void superman_pimpl:: -post_superman () -{ - cout << "finished parsing superman" << endl - << endl; -} - -// batman_pimpl -// -void batman_pimpl:: -pre () -{ - cout << "starting to parse batman" << endl; -} - -void batman_pimpl:: -wing_span (unsigned int v) -{ - cout << "wing-span: " << v << endl; -} - -void batman_pimpl:: -post_superman () -{ - post_batman (); -} - -void batman_pimpl:: -post_batman () -{ - cout << "finished parsing batman" << endl - << endl; -} diff --git a/examples/cxx/parser/polymorphism/supermen-pimpl.hxx b/examples/cxx/parser/polymorphism/supermen-pimpl.hxx deleted file mode 100644 index eaf81e5..0000000 --- a/examples/cxx/parser/polymorphism/supermen-pimpl.hxx +++ /dev/null @@ -1,68 +0,0 @@ -// file : examples/cxx/parser/polymorphism/supermen-pimpl.hxx -// copyright : not copyrighted - public domain - -#ifndef SUPERMEN_PIMPL_HXX -#define SUPERMEN_PIMPL_HXX - -#include "supermen-pskel.hxx" - -class person_pimpl: public virtual person_pskel -{ -public: - virtual void - pre (); - - virtual void - name (const std::string&); - - virtual void - post_person (); -}; - -class superman_pimpl: public virtual superman_pskel, - public person_pimpl -{ -public: - virtual void - pre (); - - virtual void - can_fly (bool); - - // By default, post_superman() calls post_person(). In case of - // polymorphic parsing we want the opposite: post_person() calls - // post_superman(). - // - virtual void - post_person (); - - virtual void - post_superman (); -}; - -class batman_pimpl: public virtual batman_pskel, - public superman_pimpl -{ -public: - virtual void - pre (); - - virtual void - wing_span (unsigned int); - - // By default, post_batman() calls post_superman(). In case of - // polymorphic parsing we want the opposite: post_superman() - // calls post_batman(). - // - virtual void - post_superman (); - - virtual void - post_batman (); -}; - -class supermen_pimpl: public supermen_pskel -{ -}; - -#endif // SUPERMEN_PIMPL_HXX diff --git a/examples/cxx/parser/polymorphism/supermen.xml b/examples/cxx/parser/polymorphism/supermen.xml deleted file mode 100644 index 15054fa..0000000 --- a/examples/cxx/parser/polymorphism/supermen.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - John Doe - - - - James "007" Bond - - - - Bruce Wayne - - - diff --git a/examples/cxx/parser/polymorphism/supermen.xsd b/examples/cxx/parser/polymorphism/supermen.xsd deleted file mode 100644 index c9029da..0000000 --- a/examples/cxx/parser/polymorphism/supermen.xsd +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/parser/polyroot/README b/examples/cxx/parser/polyroot/README deleted file mode 100644 index f41b91c..0000000 --- a/examples/cxx/parser/polyroot/README +++ /dev/null @@ -1,36 +0,0 @@ -This example shows how to handle the xsi:type attributes when it is used -on root elements. For general coverage of XML Schema polymorphism handling -in the C++/Parser mapping see the polymorphism example. - -The example consists of the following files: - -supermen.xsd - XML Schema which describes the "supermen" instance documents. - -person.xml -superman.xml -batman.xml - Sample XML instance documents. - -supermen-pskel.hxx -supermen-pskel.cxx - Parser skeletons generated by the XSD compiler from supermen.xsd. - Note the use of the --generate-polymorphic command line option. - -supermen-pimpl.hxx -supermen-pimpl.cxx - Parser implementations that print the XML data to STDOUT. - -driver.cxx - Driver for the example. It implements a custom document parser - that determines which XML Schema type is being parsed and uses - the corresponding parser implementation. The driver first - constructs a parser instance from all the individual parsers - found in supermen-pimpl.hxx. In then invokes this parser instance - to parse the input file. - -To run the example on the sample XML instance documents simply execute: - -$ ./driver person.xml -$ ./driver superman.xml -$ ./driver batman.xml diff --git a/examples/cxx/parser/polyroot/batman.xml b/examples/cxx/parser/polyroot/batman.xml deleted file mode 100644 index fad0b71..0000000 --- a/examples/cxx/parser/polyroot/batman.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - Bruce Wayne - - diff --git a/examples/cxx/parser/polyroot/driver.cxx b/examples/cxx/parser/polyroot/driver.cxx deleted file mode 100644 index 1c9c778..0000000 --- a/examples/cxx/parser/polyroot/driver.cxx +++ /dev/null @@ -1,138 +0,0 @@ -// file : examples/cxx/parser/polyroot/driver.cxx -// copyright : not copyrighted - public domain - -#include -#include -#include - -#include "supermen-pimpl.hxx" - -using std::cerr; -using std::endl; -using xml_schema::ro_string; - -// Customize the xml_schema::document object to handle polymorphic -// root element. For more information see the multiroot example. -// -class document: public xml_schema::document -{ -public: - document (const xml_schema::parser_map& parser_map) - : xml_schema::document (true), // Indicate polymorphic parsing. - parser_map_ (parser_map) - { - } - -protected: - // This function is called to obtain the root element type parser. - // If the returned pointer is 0 then the whole document content - // is ignored. The type argument contains the XML Schema type - // if xsi:type attribute was specified for this element and 0 - // otherwise. - // - virtual xml_schema::parser_base* - start_root_element (const ro_string& ns, - const ro_string& name, - const ro_string* type) - { - if (name != "person" || !ns.empty ()) - return 0; - - xml_schema::parser_base* base; - - // Search the parser map. - // - if (type == 0) - { - // No xsi:type. Static type should be used. - // - ro_string st (person_pskel::_static_type ()); - base = parser_map_.find (st); - } - else - { - base = parser_map_.find (*type); - } - - if (base != 0) - { - parser_used_ = dynamic_cast (base); - parser_used_->pre (); - } - else - parser_used_ = 0; // No parser for this type. - - return parser_used_; - } - - // 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 */) - { - // Instead of caching the current parser in parser_used_, we - // could also dynamic_cast the parser argument to the person_pskel - // type. - // - if (parser_used_) - parser_used_->post_person (); - } - - -private: - const xml_schema::parser_map& parser_map_; - person_pskel* parser_used_; -}; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " instance.xml" << endl; - return 1; - } - - try - { - // Construct the parser. - // - xml_schema::string_pimpl string_p; - xml_schema::boolean_pimpl boolean_p; - xml_schema::unsigned_int_pimpl unsigned_int_p; - - person_pimpl person_p; - superman_pimpl superman_p; - batman_pimpl batman_p; - - person_p.parsers (string_p); - superman_p.parsers (string_p, boolean_p); - batman_p.parsers (string_p, boolean_p, unsigned_int_p); - - // Parse the XML document. - // - xml_schema::parser_map_impl person_map; - - person_map.insert (person_p); - person_map.insert (superman_p); - person_map.insert (batman_p); - - document doc_p (person_map); - - doc_p.parse (argv[1]); - } - 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/polyroot/makefile b/examples/cxx/parser/polyroot/makefile deleted file mode 100644 index 08ceec3..0000000 --- a/examples/cxx/parser/polyroot/makefile +++ /dev/null @@ -1,109 +0,0 @@ -# file : examples/cxx/parser/polyroot/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := supermen.xsd -cxx := driver.cxx supermen-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 += --generate-polymorphic -$(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)/supermen.xsd,$(install_doc_dir)/xsd/$(path)/supermen.xsd) - $(call install-data,$(src_base)/batman.xml,$(install_doc_dir)/xsd/$(path)/batman.xml) - $(call install-data,$(src_base)/person.xml,$(install_doc_dir)/xsd/$(path)/person.xml) - $(call install-data,$(src_base)/superman.xml,$(install_doc_dir)/xsd/$(path)/superman.xml) - $(call install-data,$(src_base)/supermen-pimpl.hxx,$(install_doc_dir)/xsd/$(path)/supermen-pimpl.hxx) - $(call install-data,$(src_base)/supermen-pimpl.cxx,$(install_doc_dir)/xsd/$(path)/supermen-pimpl.cxx) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/supermen.xsd,$(dist_prefix)/$(path)/supermen.xsd) - $(call install-data,$(src_base)/batman.xml,$(dist_prefix)/$(path)/batman.xml) - $(call install-data,$(src_base)/person.xml,$(dist_prefix)/$(path)/person.xml) - $(call install-data,$(src_base)/superman.xml,$(dist_prefix)/$(path)/superman.xml) - $(call install-data,$(src_base)/supermen-pimpl.hxx,$(dist_prefix)/$(path)/supermen-pimpl.hxx) - $(call install-data,$(src_base)/supermen-pimpl.cxx,$(dist_prefix)/$(path)/supermen-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/polyroot/person.xml b/examples/cxx/parser/polyroot/person.xml deleted file mode 100644 index f463bea..0000000 --- a/examples/cxx/parser/polyroot/person.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - John Doe - - diff --git a/examples/cxx/parser/polyroot/superman.xml b/examples/cxx/parser/polyroot/superman.xml deleted file mode 100644 index c831f6c..0000000 --- a/examples/cxx/parser/polyroot/superman.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - James "007" Bond - - diff --git a/examples/cxx/parser/polyroot/supermen-pimpl.cxx b/examples/cxx/parser/polyroot/supermen-pimpl.cxx deleted file mode 100644 index 62289e9..0000000 --- a/examples/cxx/parser/polyroot/supermen-pimpl.cxx +++ /dev/null @@ -1,85 +0,0 @@ -// file : examples/cxx/parser/polyroot/supermen-pimpl.cxx -// copyright : not copyrighted - public domain -// - -#include - -#include "supermen-pimpl.hxx" - -using std::cout; -using std::endl; - -// person_pimpl -// -void person_pimpl:: -pre () -{ - cout << "starting to parse person" << endl; -} - -void person_pimpl:: -name (const std::string& v) -{ - cout << "name: " << v << endl; -} - -void person_pimpl:: -post_person () -{ - cout << "finished parsing person" << endl - << endl; -} - -// superman_pimpl -// -void superman_pimpl:: -pre () -{ - cout << "starting to parse superman" << endl; -} - -void superman_pimpl:: -can_fly (bool v) -{ - cout << "can-fly: " << v << endl; -} - -void superman_pimpl:: -post_person () -{ - post_superman (); -} - -void superman_pimpl:: -post_superman () -{ - cout << "finished parsing superman" << endl - << endl; -} - -// batman_pimpl -// -void batman_pimpl:: -pre () -{ - cout << "starting to parse batman" << endl; -} - -void batman_pimpl:: -wing_span (unsigned int v) -{ - cout << "wing-span: " << v << endl; -} - -void batman_pimpl:: -post_superman () -{ - post_batman (); -} - -void batman_pimpl:: -post_batman () -{ - cout << "finished parsing batman" << endl - << endl; -} diff --git a/examples/cxx/parser/polyroot/supermen-pimpl.hxx b/examples/cxx/parser/polyroot/supermen-pimpl.hxx deleted file mode 100644 index 49e8c74..0000000 --- a/examples/cxx/parser/polyroot/supermen-pimpl.hxx +++ /dev/null @@ -1,64 +0,0 @@ -// file : examples/cxx/parser/polyroot/supermen-pimpl.hxx -// copyright : not copyrighted - public domain - -#ifndef SUPERMEN_PIMPL_HXX -#define SUPERMEN_PIMPL_HXX - -#include "supermen-pskel.hxx" - -class person_pimpl: public virtual person_pskel -{ -public: - virtual void - pre (); - - virtual void - name (const std::string&); - - virtual void - post_person (); -}; - -class superman_pimpl: public virtual superman_pskel, - public person_pimpl -{ -public: - virtual void - pre (); - - virtual void - can_fly (bool); - - // By default, post_superman() calls post_person(). In case of - // polymorphic parsing we want the opposite: post_person() calls - // post_superman(). - // - virtual void - post_person (); - - virtual void - post_superman (); -}; - -class batman_pimpl: public virtual batman_pskel, - public superman_pimpl -{ -public: - virtual void - pre (); - - virtual void - wing_span (unsigned int); - - // By default, post_batman() calls post_superman(). In case of - // polymorphic parsing we want the opposite: post_superman() - // calls post_batman(). - // - virtual void - post_superman (); - - virtual void - post_batman (); -}; - -#endif // SUPERMEN_PIMPL_HXX diff --git a/examples/cxx/parser/polyroot/supermen.xsd b/examples/cxx/parser/polyroot/supermen.xsd deleted file mode 100644 index dc5d439..0000000 --- a/examples/cxx/parser/polyroot/supermen.xsd +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/parser/wildcard/README b/examples/cxx/parser/wildcard/README deleted file mode 100644 index 89f9aa9..0000000 --- a/examples/cxx/parser/wildcard/README +++ /dev/null @@ -1,27 +0,0 @@ -This example shows how to parse the XML data matched by XML Schema -wildcards (any and anyAttribute) in the C++/Parser mapping. The -example consists of the following files: - -email.xsd - XML Schema which describes a simple email format with the - extensible envelope type. - -email.xml - Sample email message. - -email-pskel.hxx -email-pskel.cxx - Parser skeletons generated by XSD from email.xsd. - -driver.cxx - Parser implementations and a driver for the example. The - parser implementations simply print the data to STDERR. - The driver first constructs parser instances from the - parser implementations mentioned above and a couple of - predefined parsers for the XML Schema built-in types. - In then invokes the parser instances to parse the input - file. - -To run the example on the sample XML instance document simply execute: - -$ ./driver email.xml diff --git a/examples/cxx/parser/wildcard/driver.cxx b/examples/cxx/parser/wildcard/driver.cxx deleted file mode 100644 index fa82ec0..0000000 --- a/examples/cxx/parser/wildcard/driver.cxx +++ /dev/null @@ -1,239 +0,0 @@ -// file : examples/cxx/parser/wildcard/driver.cxx -// copyright : not copyrighted - public domain - -#include -#include -#include - -#include "email-pskel.hxx" - -using namespace std; -using xml_schema::ro_string; - -class binary_pimpl: public email::binary_pskel, - public xml_schema::base64_binary_pimpl -{ -public: - virtual void - name (const string& n) - { - cerr << "binary: " << n << endl; - } - - virtual void - mime (const string& t) - { - cerr << "type: " << t << endl - << endl; - } - - virtual void - post_binary () - { - auto_ptr buf (post_base64_binary ()); - - cerr << "size: " << buf->size () << endl - << endl; - } -}; - -class envelope_pimpl: public email::envelope_pskel -{ -public: - envelope_pimpl (xml_schema::unsigned_int_pskel& uint_p, - xml_schema::string_pskel& string_p, - email::binary_pskel& binary_p) - : depth_ (0), cur_ (0), - uint_p_ (uint_p), string_p_ (string_p), binary_p_ (binary_p) - { - } - - virtual void - to (const string& addr) - { - cerr << "To: " << addr << endl; - } - - virtual void - from (const string& addr) - { - cerr << "From: " << addr << endl; - } - - virtual void - subject (const string& s) - { - cerr << "Subject: " << s << endl; - } - - // Wildcard handling. All wildcard events are routed to these - // four functions. It is our job to dispatch them to the right - // parsers. - // - virtual void - _start_any_element (const ro_string& ns, - const ro_string& name, - const ro_string* type) - { - if (depth_++ > 0) - { - // Nested wildcard element. - // - if (cur_) - cur_->_start_element (ns, name, type); - } - else - { - // Top-level element matched by the any wildcard. - // - if (ns == "http://www.codesynthesis.com/email") - { - if (name == "text") - { - cur_ = &string_p_; - string_p_.pre (); - string_p_._pre_impl (); - } - else if (name == "binary") - { - cur_ = &binary_p_; - binary_p_.pre (); - binary_p_._pre_impl (); - } - } - - if (cur_ == 0) - { - cerr << "Unknown wildcard content: " << ns << "#" << name << endl; - } - } - } - - virtual void - _end_any_element (const ro_string& ns, const ro_string& name) - { - if (--depth_ > 0) - { - if (cur_) - cur_->_end_element (ns, name); - } - else - { - if (ns == "http://www.codesynthesis.com/email") - { - if (name == "text") - { - string_p_._post_impl (); - string text (string_p_.post_string ()); - - cerr << text << endl - << endl; - } - else if (name == "binary") - { - binary_p_._post_impl (); - binary_p_.post_binary (); - } - } - - cur_ = 0; - } - } - - virtual void - _any_attribute (const ro_string& ns, - const ro_string& name, - const ro_string& value) - { - if (depth_ > 0) - { - // Nested wildcard attribute. - // - if (cur_) - cur_->_attribute (ns, name, value); - } - else - { - // Top-level attribute matched by the anyAttribute wildcard. - // - if (ns == "http://www.codesynthesis.com/email" && name == "thread-id") - { - uint_p_.pre (); - uint_p_._pre_impl (); - uint_p_._characters (value); - uint_p_._post_impl (); - unsigned int tid (uint_p_.post_unsigned_int ()); - - cerr << "Thread-id: " << tid << endl; - } - } - } - - virtual void - _any_characters (const ro_string& s) - { - if (depth_ > 0) - { - if (cur_) - cur_->_characters (s); - } - } - -private: - size_t depth_; - xml_schema::parser_base* cur_; - - // Parsers for the unsigned int, string and binary types. - // -private: - xml_schema::unsigned_int_pskel& uint_p_; - xml_schema::string_pskel& string_p_; - email::binary_pskel& binary_p_; -}; - - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " email.xml" << endl; - return 1; - } - - try - { - // Construct the parser. - // - xml_schema::unsigned_int_pimpl unsigned_int_p; - xml_schema::string_pimpl string_p; - binary_pimpl binary_p; - envelope_pimpl envelope_p (unsigned_int_p, string_p, binary_p); - - binary_p.parsers (string_p, // name - string_p); // mime - - envelope_p.parsers (string_p, // to - string_p, // from - string_p); // subject - - // Parse the XML instance document. - // - xml_schema::document doc_p (envelope_p, - "http://www.codesynthesis.com/email", - "message"); - envelope_p.pre (); - doc_p.parse (argv[1]); - envelope_p.post_envelope (); - } - 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/wildcard/email.xml b/examples/cxx/parser/wildcard/email.xml deleted file mode 100644 index f5d0359..0000000 --- a/examples/cxx/parser/wildcard/email.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - Jane Doe <jane@doe.com> - John Doe <john@doe.com> - Surfing pictures - - -Hi Jane, - -Here are cool pictures of me surfing. - -Cheers, -John - - - YmFzZTY0IGJpbmFyeQ== - YmFzZTY0IGJpbmFyeQ== - - diff --git a/examples/cxx/parser/wildcard/email.xsd b/examples/cxx/parser/wildcard/email.xsd deleted file mode 100644 index 087fc7e..0000000 --- a/examples/cxx/parser/wildcard/email.xsd +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/parser/wildcard/makefile b/examples/cxx/parser/wildcard/makefile deleted file mode 100644 index 5887375..0000000 --- a/examples/cxx/parser/wildcard/makefile +++ /dev/null @@ -1,101 +0,0 @@ -# file : examples/cxx/parser/wildcard/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := email.xsd -cxx := driver.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): $(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)/email.xsd,$(install_doc_dir)/xsd/$(path)/email.xsd) - $(call install-data,$(src_base)/email.xml,$(install_doc_dir)/xsd/$(path)/email.xml) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/email.xsd,$(dist_prefix)/$(path)/email.xsd) - $(call install-data,$(src_base)/email.xml,$(dist_prefix)/$(path)/email.xml) - -$(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/tree/README b/examples/cxx/tree/README deleted file mode 100644 index 83ffcab..0000000 --- a/examples/cxx/tree/README +++ /dev/null @@ -1,84 +0,0 @@ -This directory contains a number of examples that show how to use -the C++/Tree mapping. The following list gives an overview of -each example. See the README files in example directories for -more information on each example. - -hello - A simple "Hello, world!" example that shows how to parse XML - documents. - -library - Shows hot to handle more complex data structures, use the - ID/IDREF cross-referencing mechanism, use the xsd:enumeration - to C++ enum mapping, modify the object model, and serialize - the modified object model back to XML. - -polymorphism - Shows how to use XML Schema polymorphism features such as the - xsi:type attribute and substitution groups. - -order/ - A collection of examples that show how to use ordered types to - capture and maintain content order. - -xpath - Shows how to use the C++/Tree mapping together with XPath. - -wildcard - Shows how to use the optional wildcard mapping to parse, access, - modify, and serialize the XML data matched by XML Schema wildcards - (any and anyAttribute). - -mixed - Shows how to access the underlying DOM nodes to handle raw, "type- - less content" such as mixed content models, anyType/anySimpleType, - and any/anyAttribute. - -multiroot - Shows how to handle XML vocabularies with multiple root elements. - See also the messaging example. - -messaging - Shows how to handle XML vocabularies with multiple root elements - using the element type and element map features of the C++/Tree - mapping. - -caching - Shows how to parse several XML documents while reusing the - underlying XML parser and caching the schemas used for validation. - -embedded - Shows how to embed the binary representation of the schema grammar - into an application and then use it with the C++/Tree mapping to - parse and validate XML documents. - -secure - Shows how to perform more secure XML parsing by disabling the XML - External Entity (XXE) Processing. - -performance - Measures the performance of parsing and serialization. This example - also shows how to structure your code to achieve the maximum - performance for these two operations. - -custom/ - A collection of examples that show how to customize the C++/Tree - mapping by using custom C++ classes instead of or in addition to - the generated ones. See the accompanying README file for an - overview of each example in this directory. - -streaming - Shows how to perform stream-oriented, partially in-memory XML - processing using the C++/Tree mapping. With the partially in-memory - parsing and serialization only a part of the object model is in - memory at any given time. With this approach we can process parts - of the document as they become available as well as handle documents - that are too large to fit into memory. - -compression - Shows how to compress an XML document during serialization and decompress - it during parsing using the zlib library. - -binary/ - A collection of examples that show how to serialize the object model - into a number of predefined and custom binary formats. diff --git a/examples/cxx/tree/binary/README b/examples/cxx/tree/binary/README deleted file mode 100644 index 365551e..0000000 --- a/examples/cxx/tree/binary/README +++ /dev/null @@ -1,16 +0,0 @@ -This directory contains a number of examples that show how to serialize -the object model into a number of predefined and custom binary formats. -The following list gives an overview of each example: - -boost - Shows how to save/load the object model to/from a custom format - using the Boost serialization library as an example. - -cdr - Shows how to save/load the object model to/from CDR (Common Data - Representation) binary format using ACE CDR streams. - -xdr - Shows how to save/load the object model to/from XDR (eXternal Data - Representation) binary format using the XDR API provided as part of - Sun RPC. diff --git a/examples/cxx/tree/binary/boost/README b/examples/cxx/tree/binary/boost/README deleted file mode 100644 index 6cdd2dd..0000000 --- a/examples/cxx/tree/binary/boost/README +++ /dev/null @@ -1,49 +0,0 @@ -This example shows how to save/load the object model to/from a custom -format using the Boost serialization library as an example. You will -need the Boost serialization library[1] installed in order to build -and run this example. - -[1] http://www.boost.org - -The example consists of the following files: - -library.xsd - XML Schema which describes a library of books. - -library.xml - Sample XML instance document. - -boost-archive-extraction.hxx -boost-archive-insertion.hxx - Boost archive insertion and extraction operators for fundamental - types. You will need to provide a similar set of operators for - your own stream types. - -library-prologue.hxx - Contains a number of #include directives that are inserted into - the generated code by the XSD compiler. The included files are: - boost/archive/text_oarchive.hpp, boost/archive/text_oarchive.hpp, - boost-archive-insertion.hxx, and boost-archive-insertion.hxx. - -library.hxx -library.cxx - C++ types that represent the given vocabulary as well as Boost - archive insertion and extraction operations. These are generated - by the XSD compiler from library.xsd. The --hxx-prologue-file - option is used to insert the contents of the library-prologue.hxx - file into the generated header file. The --generate-insertion and - --generate-extraction options are used to generate the insertion - and extraction operations for text_oarchive and text_iarchive - types. - -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 text_oarchive and loads it back from - text_iarchive. Additionally, it prints the resulting text - representation as well as the content of the object model before - saving it to text_oarchive and after loading it from text_iarchive. - -To run the example on the sample XML instance document simply execute: - -$ ./driver library.xml diff --git a/examples/cxx/tree/binary/boost/boost-archive-extraction.hxx b/examples/cxx/tree/binary/boost/boost-archive-extraction.hxx deleted file mode 100644 index 8a1c1ef..0000000 --- a/examples/cxx/tree/binary/boost/boost-archive-extraction.hxx +++ /dev/null @@ -1,188 +0,0 @@ -// file : examples/cxx/tree/binary/boost/boost-archive-insertion.cxx -// copyright : not copyrighted - public domain - -#ifndef BOOST_ARCHIVE_EXTRACTION_HXX -#define BOOST_ARCHIVE_EXTRACTION_HXX - -#include // std::size_t -#include - -#include -#include - -#include - -namespace xsd -{ - namespace cxx - { - namespace tree - { - // as_size - // - template - inline istream& - operator>> (istream& s, istream_common::as_size& x) - { - std::size_t r; - s.impl () >> r; - x.x_ = static_cast (r); - return s; - } - - // 8-bit - // - template - inline istream& - operator>> (istream& s, istream_common::as_int8& x) - { - boost::int8_t r; - s.impl () >> r; - x.x_ = static_cast (r); - return s; - } - - template - inline istream& - operator>> (istream& s, istream_common::as_uint8& x) - { - boost::uint8_t r; - s.impl () >> r; - x.x_ = static_cast (r); - return s; - } - - - // 16-bit - // - template - inline istream& - operator>> (istream& s, istream_common::as_int16& x) - { - boost::int16_t r; - s.impl () >> r; - x.x_ = static_cast (r); - return s; - } - - template - inline istream& - operator>> (istream& s, istream_common::as_uint16& x) - { - boost::uint16_t r; - s.impl () >> r; - x.x_ = static_cast (r); - return s; - } - - - // 32-bit - // - template - inline istream& - operator>> (istream& s, istream_common::as_int32& x) - { - boost::int32_t r; - s.impl () >> r; - x.x_ = static_cast (r); - return s; - } - - template - inline istream& - operator>> (istream& s, istream_common::as_uint32& x) - { - boost::uint32_t r; - s.impl () >> r; - x.x_ = static_cast (r); - return s; - } - - - // 64-bit - // - template - inline istream& - operator>> (istream& s, istream_common::as_int64& x) - { - boost::int64_t r; - s.impl () >> r; - x.x_ = static_cast (r); - return s; - } - - template - inline istream& - operator>> (istream& s, istream_common::as_uint64& x) - { - boost::uint64_t r; - s.impl () >> r; - x.x_ = static_cast (r); - return s; - } - - - // Boolean - // - template - inline istream& - operator>> (istream& s, istream_common::as_bool& x) - { - bool r; - s.impl () >> r; - x.x_ = static_cast (r); - return s; - } - - - // Floating-point - // - template - inline istream& - operator>> (istream& s, istream_common::as_float32& x) - { - float r; - s.impl () >> r; - x.x_ = static_cast (r); - return s; - } - - template - inline istream& - operator>> (istream& s, istream_common::as_float64& x) - { - double r; - s.impl () >> r; - x.x_ = static_cast (r); - return s; - } - - // Extraction of std::basic_string. - // - - template - inline istream& - operator>> (istream& s, std::basic_string& x) - { - s.impl () >> x; - return s; - } - - - // Extraction of a binary buffer. - // - template - istream& - operator>> (istream& s, buffer& x) - { - std::size_t size; - s.impl () >> size; - x.size (size); - s.impl ().load_binary (x.data (), size); - return s; - } - } - } -} - -#endif // BOOST_ARCHIVE_EXTRACTION_HXX diff --git a/examples/cxx/tree/binary/boost/boost-archive-insertion.hxx b/examples/cxx/tree/binary/boost/boost-archive-insertion.hxx deleted file mode 100644 index 4c89104..0000000 --- a/examples/cxx/tree/binary/boost/boost-archive-insertion.hxx +++ /dev/null @@ -1,177 +0,0 @@ -// file : examples/cxx/tree/binary/boost/boost-archive-insertion.cxx -// copyright : not copyrighted - public domain - -#ifndef BOOST_ARCHIVE_INSERTION_HXX -#define BOOST_ARCHIVE_INSERTION_HXX - -#include // std::size_t -#include - -#include -#include - -#include - -namespace xsd -{ - namespace cxx - { - namespace tree - { - // as_size - // - template - inline ostream& - operator<< (ostream& s, ostream_common::as_size x) - { - std::size_t v (static_cast (x.x_)); - s.impl () << v; - return s; - } - - // 8-bit - // - template - inline ostream& - operator<< (ostream& s, ostream_common::as_int8 x) - { - boost::int8_t v (static_cast (x.x_)); - s.impl () << v; - return s; - } - - template - inline ostream& - operator<< (ostream& s, ostream_common::as_uint8 x) - { - boost::uint8_t v (static_cast (x.x_)); - s.impl () << v; - return s; - } - - - // 16-bit - // - template - inline ostream& - operator<< (ostream& s, ostream_common::as_int16 x) - { - boost::int16_t v (static_cast (x.x_)); - s.impl () << v; - return s; - } - - template - inline ostream& - operator<< (ostream& s, ostream_common::as_uint16 x) - { - boost::uint16_t v (static_cast (x.x_)); - s.impl () << v; - return s; - } - - - // 32-bit - // - template - inline ostream& - operator<< (ostream& s, ostream_common::as_int32 x) - { - boost::int32_t v (static_cast (x.x_)); - s.impl () << v; - return s; - } - - template - inline ostream& - operator<< (ostream& s, ostream_common::as_uint32 x) - { - boost::uint32_t v (static_cast (x.x_)); - s.impl () << v; - return s; - } - - - // 64-bit - // - template - inline ostream& - operator<< (ostream& s, ostream_common::as_int64 x) - { - boost::int64_t v (static_cast (x.x_)); - s.impl () << v; - return s; - } - - template - inline ostream& - operator<< (ostream& s, ostream_common::as_uint64 x) - { - boost::uint64_t v (static_cast (x.x_)); - s.impl () << v; - return s; - } - - - // Boolean - // - template - inline ostream& - operator<< (ostream& s, ostream_common::as_bool x) - { - bool v (static_cast (x.x_)); - s.impl () << v; - return s; - } - - - // Floating-point - // - template - inline ostream& - operator<< (ostream& s, ostream_common::as_float32 x) - { - float v (static_cast (x.x_)); - s.impl () << v; - return s; - } - - template - inline ostream& - operator<< (ostream& s, ostream_common::as_float64 x) - { - double v (static_cast (x.x_)); - s.impl () << v; - return s; - } - - - // Insertion of std::basic_string. - // - template - inline ostream& - operator<< (ostream& s, const std::basic_string& x) - { - s.impl () << x; - return s; - } - - - // Insertion of a binary buffer. - // - template - ostream& - operator<< (ostream& s, const buffer& x) - { - // Boost.Serialization needs an lvalue. - // - std::size_t size (x.size()); - s.impl () << size; - s.impl ().save_binary (x.data (), x.size ()); - return s; - } - } - } -} - -#endif // BOOST_ARCHIVE_INSERTION_HXX diff --git a/examples/cxx/tree/binary/boost/driver.cxx b/examples/cxx/tree/binary/boost/driver.cxx deleted file mode 100644 index df053b6..0000000 --- a/examples/cxx/tree/binary/boost/driver.cxx +++ /dev/null @@ -1,72 +0,0 @@ -// file : examples/cxx/tree/binary/boost/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include // std::memcpy -#include -#include - -// You can generate insertion/extraction code for other archive -// types (for example, binary, XML, etc). -// -#include -#include - -#include "library.hxx" - -using std::cerr; -using std::endl; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " library.xml" << endl; - return 1; - } - - try - { - using namespace library; - using boost::archive::text_oarchive; - using boost::archive::text_iarchive; - - // Read in the file. - // - std::auto_ptr c (catalog_ (argv[1])); - - cerr << *c << endl; - - // Save into a text archive. - // - std::ostringstream ostr; - text_oarchive oa (ostr); - xml_schema::ostream os (oa); - - os << *c; - - // Print the text representation. - // - std::string str (ostr.str ()); - - cerr << endl - << "text representation: " << endl - << str << endl; - - // Load from a text archive. - // - std::istringstream istr (str); - text_iarchive ia (istr); - xml_schema::istream is (ia); - - std::auto_ptr copy (new catalog (is)); - - cerr << *copy << endl; - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/examples/cxx/tree/binary/boost/library-prologue.hxx b/examples/cxx/tree/binary/boost/library-prologue.hxx deleted file mode 100644 index ba0d35f..0000000 --- a/examples/cxx/tree/binary/boost/library-prologue.hxx +++ /dev/null @@ -1,9 +0,0 @@ -// Include declarations for the archive types. -// -#include -#include - -// Include insertion/extraction operators for fundamental types. -// -#include "boost-archive-insertion.hxx" -#include "boost-archive-extraction.hxx" diff --git a/examples/cxx/tree/binary/boost/library.xml b/examples/cxx/tree/binary/boost/library.xml deleted file mode 100644 index ceb4443..0000000 --- a/examples/cxx/tree/binary/boost/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/boost/library.xsd b/examples/cxx/tree/binary/boost/library.xsd deleted file mode 100644 index 4bfdd1e..0000000 --- a/examples/cxx/tree/binary/boost/library.xsd +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/binary/boost/makefile b/examples/cxx/tree/binary/boost/makefile deleted file mode 100644 index 6e2f4d8..0000000 --- a/examples/cxx/tree/binary/boost/makefile +++ /dev/null @@ -1,131 +0,0 @@ -# file : examples/cxx/tree/binary/boost/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) - -ifeq ($(filter $(MAKECMDGOALS),dist dist-win install),) -$(call import,\ - $(scf_root)/import/libboost/serialization/stub.make,\ - l: boost_serialization.l,cpp-options: boost_serialization.l.cpp-options) -endif - - -# Build. -# -$(driver): $(obj) $(xerces_c.l) $(boost_serialization.l) - -$(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd -$(obj) $(dep): $(xerces_c.l.cpp-options) $(boost_serialization.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 \ ---hxx-prologue-file $(src_base)/library-prologue.hxx \ ---generate-insertion boost::archive::text_oarchive \ ---generate-extraction boost::archive::text_iarchive - -$(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) - $(call install-data,$(src_base)/library-prologue.hxx,$(install_doc_dir)/xsd/$(path)/library-prologue.hxx) - $(call install-data,$(src_base)/boost-archive-extraction.hxx,$(install_doc_dir)/xsd/$(path)/boost-archive-extraction.hxx) - $(call install-data,$(src_base)/boost-archive-insertion.hxx,$(install_doc_dir)/xsd/$(path)/boost-archive-insertion.hxx) - -$(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) - $(call install-data,$(src_base)/library-prologue.hxx,$(dist_prefix)/$(path)/library-prologue.hxx) - $(call install-data,$(src_base)/boost-archive-extraction.hxx,$(dist_prefix)/$(path)/boost-archive-extraction.hxx) - $(call install-data,$(src_base)/boost-archive-insertion.hxx,$(dist_prefix)/$(path)/boost-archive-insertion.hxx) - -$(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,boost-vc8.sln) - $(call meta-vc9sln,$(src_root)/dist/template-vc9.sln,boost-vc9.sln) - $(call meta-vc10sln,$(src_root)/dist/template-vc10.sln,boost-vc10.sln) - $(call meta-vc11sln,$(src_root)/dist/template-vc11.sln,boost-vc11.sln) - $(call meta-vc12sln,$(src_root)/dist/template-vc12.sln,boost-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) diff --git a/examples/cxx/tree/binary/cdr/README b/examples/cxx/tree/binary/cdr/README deleted file mode 100644 index 914d27c..0000000 --- a/examples/cxx/tree/binary/cdr/README +++ /dev/null @@ -1,36 +0,0 @@ -This example shows how to save/load the object model to/from CDR -(Common Data Representation) binary format using ACE CDR streams. -Support for other data representation streams can be easily added. You -will need the ACE library[1] installed in order to build and run this -example. - -[1] http://www.cs.wustl.edu/~schmidt/ACE.html - -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 ACE CDR - 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 ACE_OuputCDR and loads it back from - ACE_InputCDR. Additionally, it prints the resulting binary - representation as well as the content of the object model before - saving it to the CDR stream and after loading it from the CDR stream. - -To run the example on the sample XML instance document simply execute: - -$ ./driver library.xml diff --git a/examples/cxx/tree/binary/cdr/driver.cxx b/examples/cxx/tree/binary/cdr/driver.cxx deleted file mode 100644 index ec1ff32..0000000 --- a/examples/cxx/tree/binary/cdr/driver.cxx +++ /dev/null @@ -1,87 +0,0 @@ -// file : examples/cxx/tree/binary/cdr/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include // std::memcpy -#include - -#include // ACE_HEX_DUMP -#include - -// The following two headers define XSD-specific insertion/extraction -// operations for ACE CDR streams. You can use the content of these -// headers as a guide to implementing insertion/extraction to/from -// your own data representation streams: -// -// xsd/cxx/tree/ace-cdr-stream-insertion.hxx -// xsd/cxx/tree/ace-cdr-stream-extraction.hxx - -#include "library.hxx" - -using std::cerr; -using std::endl; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " library.xml" << endl; - return 1; - } - - try - { - using namespace library; - - // Read in the file. - // - std::auto_ptr c (catalog_ (argv[1])); - - cerr << *c << endl; - - // Save to a CDR stream. - // - ACE_OutputCDR ace_ocdr; - xml_schema::ostream ocdr (ace_ocdr); - - ocdr << *c; - - // Print the binary representation and at the same time save - // it into a continuous buffer. - // - cerr << endl - << "binary representation size: " << ace_ocdr.total_length () << endl; - - xml_schema::buffer buf (ace_ocdr.total_length ()); - char* data (buf.data ()); - - for (const ACE_Message_Block* mb = ace_ocdr.begin (); - mb != 0; - mb = mb->cont ()) - { - std::memcpy (data, mb->rd_ptr (), mb->length ()); - data += mb->length (); - - ACE_HEX_DUMP ((LM_DEBUG, mb->rd_ptr (), mb->length ())); - } - - // Load from a CDR stream. Note that ACE_InputCDR expects the - // buffer to be properly aligned. Since our buffer is dynamically - // allocated, its alignment should be good enough. - // - ACE_InputCDR ace_icdr (buf.data (), buf.size ()); - xml_schema::istream icdr (ace_icdr); - - std::auto_ptr copy (new catalog (icdr)); - - cerr << *copy << endl; - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - return 1; - } - - return 0; // ACE makes our main() an ordinary function. -} diff --git a/examples/cxx/tree/binary/cdr/library.xml b/examples/cxx/tree/binary/cdr/library.xml deleted file mode 100644 index 941c03f..0000000 --- a/examples/cxx/tree/binary/cdr/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/cdr/library.xsd b/examples/cxx/tree/binary/cdr/library.xsd deleted file mode 100644 index 5659e1b..0000000 --- a/examples/cxx/tree/binary/cdr/library.xsd +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/binary/cdr/makefile b/examples/cxx/tree/binary/cdr/makefile deleted file mode 100644 index 82bf7b7..0000000 --- a/examples/cxx/tree/binary/cdr/makefile +++ /dev/null @@ -1,119 +0,0 @@ -# file : examples/cxx/tree/binary/cdr/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) - -ifeq ($(filter $(MAKECMDGOALS),dist dist-win install),) -$(call import,\ - $(scf_root)/import/libace/stub.make,\ - l: ace.l,cpp-options: ace.l.cpp-options) -endif - - -# Build. -# -$(driver): $(obj) $(xerces_c.l) $(ace.l) - -$(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd -$(obj) $(dep): $(xerces_c.l.cpp-options) $(ace.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 ACE_OutputCDR --generate-extraction ACE_InputCDR -$(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,cdr-vc8.sln) - $(call meta-vc9sln,$(src_root)/dist/template-vc9.sln,cdr-vc9.sln) - $(call meta-vc10sln,$(src_root)/dist/template-vc10.sln,cdr-vc10.sln) - $(call meta-vc11sln,$(src_root)/dist/template-vc11.sln,cdr-vc11.sln) - $(call meta-vc12sln,$(src_root)/dist/template-vc12.sln,cdr-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) diff --git a/examples/cxx/tree/binary/makefile b/examples/cxx/tree/binary/makefile deleted file mode 100644 index 03b8919..0000000 --- a/examples/cxx/tree/binary/makefile +++ /dev/null @@ -1,55 +0,0 @@ -# file : examples/cxx/tree/binary/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -all_examples := boost cdr xdr -build_examples := - -ifeq ($(xsd_with_boost_serialization),y) -build_examples += boost -endif - -ifeq ($(xsd_with_ace),y) -build_examples += cdr -endif - -ifeq ($(xsd_with_xdr),y) -build_examples += xdr -endif - -default := $(out_base)/ -install := $(out_base)/.install -dist := $(out_base)/.dist -dist-win := $(out_base)/.dist-win -clean := $(out_base)/.clean - -# Build. -# -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(build_examples))) - -# Install & Dist. -# -$(install) $(dist) $(dist-win): path := $(subst $(src_root)/,,$(src_base)) - -$(install): $(addprefix $(out_base)/,$(addsuffix /.install,$(all_examples))) - $(call install-data,$(src_base)/README,$(install_doc_dir)/xsd/$(path)/README) - -$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(all_examples))) - $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README) - -$(dist-win): $(addprefix $(out_base)/,$(addsuffix /.dist-win,$(all_examples))) - $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README.txt) - $(call message,,todos $(dist_prefix)/$(path)/README.txt) - -# Clean. -# -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(build_examples))) - -$(call include,$(bld_root)/install.make) - -ifneq ($(filter $(MAKECMDGOALS),dist dist-win install),) -$(foreach e,$(all_examples),$(call import,$(src_base)/$e/makefile)) -else -$(foreach e,$(build_examples),$(call import,$(src_base)/$e/makefile)) -endif 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) diff --git a/examples/cxx/tree/caching/README b/examples/cxx/tree/caching/README deleted file mode 100644 index 64e5a1a..0000000 --- a/examples/cxx/tree/caching/README +++ /dev/null @@ -1,29 +0,0 @@ -This example shows how to use the C++/Tree mapping to parse several -XML documents while reusing the underlying XML parser and caching the -schemas used for validation. - -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 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 library.xsd. - -driver.cxx - Driver for the example. It first sets up the Xerces-C++ DOM parser - and caches the library.xsd schema for validation. It then performs - ten iterations that parse the input file to a DOM document using - the DOM parser and call one of the parsing functions that constructs - the object model from this DOM document. On each iteration the driver - prints a number of books in the object model to STDERR. - -To run the example on the sample XML instance document simply execute: - -$ ./driver library.xml diff --git a/examples/cxx/tree/caching/driver.cxx b/examples/cxx/tree/caching/driver.cxx deleted file mode 100644 index 2aa9396..0000000 --- a/examples/cxx/tree/caching/driver.cxx +++ /dev/null @@ -1,165 +0,0 @@ -// file : examples/cxx/tree/caching/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include -#include - -#include -#include // chLatin_* -#include -#include // xercesc::Grammar -#include - -#include -#include -#include - -#include - -#include "library.hxx" - -using namespace std; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " library.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 - { - using namespace xercesc; - namespace xml = xsd::cxx::xml; - namespace tree = xsd::cxx::tree; - - 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 validation. - // - conf->setParameter (XMLUni::fgDOMValidate, true); - conf->setParameter (XMLUni::fgXercesSchema, true); - 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 - - // Set error handler. - // - tree::error_handler eh; - xml::dom::bits::error_handler_proxy ehp (eh); - conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp); - - // Initialize the schema cache. - // - if (!parser->loadGrammar ("library.xsd", Grammar::SchemaGrammarType, true)) - { - // In Xerces-C++ grammar loading failure results in just a warning. - // Make it a fatal error. - // - eh.handle ("library.xsd", 0, 0, - tree::error_handler::severity::fatal, - "unable to load schema"); - } - - eh.throw_if_failed (); - - // Use the loaded grammar during parsing. - // - conf->setParameter (XMLUni::fgXercesUseCachedGrammarInParse, true); - - // Disable loading schemas via other means (e.g., schemaLocation). - // - conf->setParameter (XMLUni::fgXercesLoadSchema, false); - - // We will release the DOM document ourselves. - // - conf->setParameter (XMLUni::fgXercesUserAdoptsDOMDocument, true); - - // Parse XML documents. - // - for (unsigned long i (0); i < 10; ++i) - { - ifstream ifs; - ifs.exceptions (ifstream::badbit | ifstream::failbit); - ifs.open (argv[1]); - - // Wrap the standard input stream. - // - xml::sax::std_input_source isrc (ifs, argv[1]); - Wrapper4InputSource wrap (&isrc, false); - - // Parse XML to DOM. - // - xml_schema::dom::auto_ptr doc (parser->parse (&wrap)); - - eh.throw_if_failed (); - - // Parse DOM to the object model. - // - auto_ptr c (library::catalog_ (*doc)); - - cerr << "catalog with " << c->book ().size () << " books" << 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/caching/library.xml b/examples/cxx/tree/caching/library.xml deleted file mode 100644 index 6d4d6f1..0000000 --- a/examples/cxx/tree/caching/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/caching/library.xsd b/examples/cxx/tree/caching/library.xsd deleted file mode 100644 index a46c558..0000000 --- a/examples/cxx/tree/caching/library.xsd +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/caching/makefile b/examples/cxx/tree/caching/makefile deleted file mode 100644 index d205c0f..0000000 --- a/examples/cxx/tree/caching/makefile +++ /dev/null @@ -1,100 +0,0 @@ -# file : examples/cxx/tree/caching/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) - -$(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): $(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): $(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/compression/README b/examples/cxx/tree/compression/README deleted file mode 100644 index f163970..0000000 --- a/examples/cxx/tree/compression/README +++ /dev/null @@ -1,48 +0,0 @@ -This example shows how to compress an XML document during serialization -and decompress it during parsing. The example uses the compression -functionality provided by the zlib library[1] which needs to be installed -in order to build and run this example. It should also be fairly straight- -forward to modify the code in this example to use other compression -libraries. - -[1] http://www.zlib.net - -The example consists of the following files: - -library.xsd - XML Schema which describes a library of books. - -library.xml.gz - Sample XML instance document compressed using the gzip format. - -compressed-format-target.hxx -compressed-format-target.cxx - Implementation of the Xerces-C++ XMLFormatTarget interface with the on- - the-fly compression support. You can use it in your application to add - XML compression. - -compressed-input-source.hxx -compressed-input-source.cxx - Implementation of the Xerces-C++ InputSource interface with the on-the- - fly decompression support. You can use it in your application to add - XML decompression. - -library.hxx -library.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 library.xsd. - -driver.cxx - Driver for the example. It first creates the compressed_input_source - object and passes it to one of the parsing functions that constructs - the object model from the compressed input file. It then prints the - content of the object model to STDERR. Finally, the driver creates the - compressed_format_target object and passes it to one of the serialization - functions which converts the object model back to the compressed XML. - -To run the example on the sample XML document simply execute: - -$ ./driver library.xml.gz - -The serialization output is written to the out.xml.gz file. diff --git a/examples/cxx/tree/compression/compressed-format-target.cxx b/examples/cxx/tree/compression/compressed-format-target.cxx deleted file mode 100644 index 1f183e2..0000000 --- a/examples/cxx/tree/compression/compressed-format-target.cxx +++ /dev/null @@ -1,152 +0,0 @@ -// file : examples/cxx/tree/compression/compressed-format-target.cxx -// copyright : not copyrighted - public domain - -#include -#include // std::memcpy - -#include "compressed-format-target.hxx" - -using namespace std; - -// -// compression_failure -// - -const char* compression_failure:: -what () const throw () -{ - return "compression failure"; -} - -// -// compressed_format_target -// - -compressed_format_target:: -compressed_format_target (ostream& os, compression_type t) - : os_ (os), closed_ (false), n_ (0) - { - zs_.zalloc = Z_NULL; - zs_.zfree = Z_NULL; - zs_.opaque = Z_NULL; - - int window = 0; - - switch (t) - { - case raw: - { - window = -15; - break; - } - case zlib: - { - window = 15; - break; - } - case gzip: - { - window = 16 + 15; - break; - } - } - - int r (deflateInit2 (&zs_, - Z_DEFAULT_COMPRESSION, - Z_DEFLATED, - window, - 8, - Z_DEFAULT_STRATEGY)); - if (r != Z_OK) - throw compression_failure (r); - } - -compressed_format_target:: -~compressed_format_target () -{ - try - { - // Close the free the compression stream. - // - if (!closed_) - close (); - } - catch (...) - { - } - - deflateEnd (&zs_); -} - -void compressed_format_target:: -writeChars (const XMLByte* const buf, - const XMLSize_t size, - xercesc::XMLFormatter* const) -{ - // Flush the buffer if the block is too large or if we don't have - // any space left. - // - if ((size >= buf_size_ / 8 || n_ + size > buf_size_) && n_ != 0) - { - write (in_, n_); - n_ = 0; - } - - if (size < buf_size_ / 8) - { - memcpy (in_ + n_, reinterpret_cast (buf), size); - n_ += size; - } - else - write (reinterpret_cast (buf), size); -} - - -void compressed_format_target:: -flush () -{ - if (n_ != 0) - { - write (in_, n_); - n_ = 0; - } - - if (!os_.fail ()) - os_.flush (); -} - -void compressed_format_target:: -close () -{ - write (in_, n_, true); - n_ = 0; - - if (!os_.fail ()) - os_.flush (); - - closed_ = true; -} - -void compressed_format_target:: -write (const char* buf, size_t size, bool flush) -{ - zs_.next_in = reinterpret_cast (const_cast (buf)); - zs_.avail_in = static_cast (size); - - do - { - zs_.next_out = reinterpret_cast (out_); - zs_.avail_out = buf_size_; - - int r (deflate (&zs_, flush ? Z_FINISH : Z_NO_FLUSH)); - - if (r != Z_OK && r != Z_BUF_ERROR && r != Z_STREAM_END) - throw compression_failure (r); - - size_t n (buf_size_ - zs_.avail_out); - - if (!os_.fail () && n > 0) - os_.write (out_, static_cast (n)); - - } while (zs_.avail_out == 0); -} diff --git a/examples/cxx/tree/compression/compressed-format-target.hxx b/examples/cxx/tree/compression/compressed-format-target.hxx deleted file mode 100644 index 835b676..0000000 --- a/examples/cxx/tree/compression/compressed-format-target.hxx +++ /dev/null @@ -1,91 +0,0 @@ -// file : examples/cxx/tree/compression/compressed-format-target.hxx -// copyright : not copyrighted - public domain - -#ifndef COMPRESSED_FORMAT_TARGET_HXX -#define COMPRESSED_FORMAT_TARGET_HXX - -#include - -#include -#include // std::size_t -#include - -#include - -struct compression_failure: std::exception -{ - explicit - compression_failure (int code) - : code_ (code) - { - } - - int - code () const - { - return code_; - } - - const char* - message () const - { - return zError (code_); - } - - virtual const char* - what () const throw (); - -private: - int code_; -}; - -// Xerces-C++ XMLFormatTarget interface implementation with on-the-fly, -// zlib-based compression. -// -class compressed_format_target: public xercesc::XMLFormatTarget -{ -public: - enum compression_type - { - raw, - zlib, - gzip - }; - - compressed_format_target (std::ostream&, compression_type); - - virtual - ~compressed_format_target (); - - virtual void - writeChars (const XMLByte* const buf, - const XMLSize_t size, - xercesc::XMLFormatter* const); - - virtual void - flush (); - - // Close the compressed stream by writing out the zlib or gzip trailer. - // This function is automatically called from the destructor but you - // may want to call it explicitly to be able to catch any exceptions - // that it might throw. - // - void - close (); - -private: - void - write (const char* buf, std::size_t size, bool flush = false); - -private: - std::ostream& os_; - z_stream zs_; - bool closed_; - - static const std::size_t buf_size_ = 65536; - char in_[buf_size_]; - char out_[buf_size_]; - size_t n_; -}; - -#endif // COMPRESSED_FORMAT_TARGET_HXX diff --git a/examples/cxx/tree/compression/compressed-input-source.cxx b/examples/cxx/tree/compression/compressed-input-source.cxx deleted file mode 100644 index e25b169..0000000 --- a/examples/cxx/tree/compression/compressed-input-source.cxx +++ /dev/null @@ -1,195 +0,0 @@ -// file : examples/cxx/tree/compression/compressed-input-source.cxx -// copyright : not copyrighted - public domain - -#include - -#include - -#include "compressed-input-source.hxx" - -using namespace std; -using namespace xercesc; -namespace xml = xsd::cxx::xml; - -// -// decompression_failure -// - -const char* decompression_failure:: -what () const throw () -{ - return "decompression failure"; -} - -// -// compressed_input_source -// - -compressed_input_source:: -compressed_input_source (istream& is, compression_type t) - : is_ (&is), type_ (t) -{ -} - -compressed_input_source:: -compressed_input_source (istream& is, - compression_type t, - const string& sysid) - : InputSource (xml::string (sysid).c_str ()), is_ (&is), type_ (t) -{ -} - -compressed_input_source:: -compressed_input_source (istream& is, - compression_type t, - const string& sysid, - const string& pubid) - : xercesc::InputSource (xml::string (sysid).c_str (), - xml::string (pubid).c_str ()), - is_ (&is), - type_ (t) -{ -} - -BinInputStream* compressed_input_source:: -makeStream () const -{ - if (is_ == 0) - throw copy (); - - istream& is (*is_); - is_ = 0; - return new compressed_input_stream ( - is, static_cast (type_)); -} - -// -// compressed_input_stream -// - -compressed_input_stream:: -compressed_input_stream (istream& is, compression_type t) - : is_ (is), end_ (false), pos_ (0) -{ - zs_.zalloc = Z_NULL; - zs_.zfree = Z_NULL; - zs_.opaque = Z_NULL; - zs_.next_in = Z_NULL; - zs_.avail_in = 0; - - int window = 0; - - switch (t) - { - case raw: - { - window = -15; - break; - } - case zlib: - { - window = 15; - break; - } - case gzip: - { - window = 16 + 15; - break; - } - } - - int r (inflateInit2 (&zs_, window)); - - if (r != Z_OK) - throw decompression_failure (r); -} - -compressed_input_stream:: -~compressed_input_stream () -{ - inflateEnd (&zs_); -} - -XMLFilePos compressed_input_stream:: -curPos () const -{ - return static_cast (pos_); -} - -XMLSize_t compressed_input_stream:: -readBytes (XMLByte* const buf, const XMLSize_t size) -{ - if (end_) - return 0; - - // Keep calling inflate() until we fill up the buffer or reach the - // end of stream. If we run out of input data, call the underlying - // stream for more. - // - zs_.next_out = reinterpret_cast (buf); - zs_.avail_out = static_cast (size); - - int r; - - do - { - if (zs_.avail_in == 0) - { - zs_.avail_in = static_cast (read ()); - zs_.next_in = reinterpret_cast (const_cast (in_)); - - if (zs_.avail_in == 0) - throw decompression_failure (Z_DATA_ERROR); - } - - r = inflate (&zs_, Z_NO_FLUSH); - - if (r != Z_OK && r != Z_STREAM_END) - throw decompression_failure (r); - - } while (r != Z_STREAM_END && zs_.avail_out != 0); - - if (r == Z_STREAM_END) - end_ = true; - - size_t n (size - zs_.avail_out); - pos_ += n; - - return static_cast (n); -} - -const XMLCh* compressed_input_stream:: -getContentType () const -{ - return 0; -} - -size_t compressed_input_stream:: -read () -{ - // Some implementations don't clear gcount if you call read() on a - // stream that is in the eof state. - // - if (is_.eof ()) - return 0; - - // Unset the exception failbit while we are working with the stream. - // - ios_base::iostate old (is_.exceptions ()); - is_.exceptions (old & ~ios_base::failbit); - - is_.read (in_, static_cast (buf_size_)); - - // Clear the fail bit if it was caused by eof and restore the original - // exception state. If there are any pending errors then the exception - // will be thrown now. - // - if (is_.fail () && is_.eof ()) - is_.clear (is_.rdstate () & ~ios_base::failbit); - - is_.exceptions (old); - - // Make sure that if we failed, we won't be called again. - // - return !is_.fail () ? static_cast (is_.gcount ()) : 0; -} diff --git a/examples/cxx/tree/compression/compressed-input-source.hxx b/examples/cxx/tree/compression/compressed-input-source.hxx deleted file mode 100644 index 8065445..0000000 --- a/examples/cxx/tree/compression/compressed-input-source.hxx +++ /dev/null @@ -1,121 +0,0 @@ -// file : examples/cxx/tree/compression/compressed-input-source.hxx -// copyright : not copyrighted - public domain - -#ifndef COMPRESSED_INPUT_SOURCE_HXX -#define COMPRESSED_INPUT_SOURCE_HXX - -#include - -#include -#include -#include // std::size_t -#include - -#include -#include - -struct decompression_failure: std::exception -{ - explicit - decompression_failure (int code) - : code_ (code) - { - } - - int - code () const - { - return code_; - } - - const char* - message () const - { - return zError (code_); - } - - virtual const char* - what () const throw (); - -private: - int code_; -}; - -// Xerces-C++ InputSource interface implementation with on-the-fly, zlib- -// based decompression. -// -class compressed_input_source: public xercesc::InputSource -{ -public: - enum compression_type - { - raw, - zlib, - gzip - }; - - compressed_input_source (std::istream&, compression_type); - - compressed_input_source (std::istream&, - compression_type, - const std::string& system_id); - - compressed_input_source (std::istream&, - compression_type, - const std::string& system_id, - const std::string& public_id); - - struct copy {}; - - // Throws the copy exception if this function is called more than once. - // - virtual xercesc::BinInputStream* - makeStream () const; - -private: - mutable std::istream* is_; - compression_type type_; -}; - -// Xerces-C++ BinInputStream interface implementation with on-the-fly, zlib- -// based decompression. -// -class compressed_input_stream: public xercesc::BinInputStream -{ -public: - enum compression_type - { - raw, - zlib, - gzip - }; - - compressed_input_stream (std::istream&, compression_type); - - virtual - ~compressed_input_stream (); - - virtual XMLFilePos - curPos () const; - - virtual XMLSize_t - readBytes (XMLByte* const buf, const XMLSize_t size); - - virtual const XMLCh* - getContentType () const; - -private: - std::size_t - read (); - -private: - std::istream& is_; - z_stream zs_; - bool end_; - - static const std::size_t buf_size_ = 65536; - char in_[buf_size_]; - std::size_t pos_; // Current decompressed stream position. -}; - -#endif // COMPRESSED_INPUT_SOURCE_HXX diff --git a/examples/cxx/tree/compression/driver.cxx b/examples/cxx/tree/compression/driver.cxx deleted file mode 100644 index 34238b1..0000000 --- a/examples/cxx/tree/compression/driver.cxx +++ /dev/null @@ -1,124 +0,0 @@ -// file : examples/cxx/tree/compression/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include -#include - -#include - -#include "library.hxx" - -#include "compressed-input-source.hxx" -#include "compressed-format-target.hxx" - -using namespace std; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " library.xml.gz" << endl; - return 1; - } - - int r (0); - - // We need to initialize the Xerces-C++ runtime because we are - // using the Xerces-C++ input/output interfaces. - // - xercesc::XMLPlatformUtils::Initialize (); - - try - { - using namespace library; - - // Read in the XML file and obtain its object model. - // - ifstream ifs; - ifs.exceptions (ifstream::badbit | ifstream::failbit); - ifs.open (argv[1], ifstream::in | ifstream::binary); - - compressed_input_source cis (ifs, compressed_input_source::gzip, argv[1]); - - std::auto_ptr c ( - catalog_ (cis, xml_schema::flags::dont_initialize)); - - - // Let's print what we've got. - // - for (catalog::book_const_iterator bi (c->book ().begin ()); - bi != c->book ().end (); - ++bi) - { - cerr << endl - << "ID : " << bi->id () << endl - << "ISBN : " << bi->isbn () << endl - << "Title : " << bi->title () << endl - << "Genre : " << bi->genre () << endl; - - for (book::author_const_iterator ai (bi->author ().begin ()); - ai != bi->author ().end (); - ++ai) - { - cerr << "Author : " << ai->name () << endl; - cerr << " Born : " << ai->born () << endl; - - if (ai->died ()) - cerr << " Died : " << *ai->died () << endl; - - if (ai->recommends ()) - cerr << " Recommends : " << (*ai->recommends ())->title () << endl; - } - - cerr << "Available : " << std::boolalpha << bi->available () << endl; - } - - // Prepare namespace mapping and schema location information. - // - xml_schema::namespace_infomap map; - - map["lib"].name = "http://www.codesynthesis.com/library"; - map["lib"].schema = "library.xsd"; - - ofstream ofs; - ofs.exceptions (ofstream::badbit | ofstream::failbit | ofstream::eofbit); - ofs.open ("out.xml.gz", ofstream::out | ofstream::binary); - - compressed_format_target cft (ofs, compressed_format_target::gzip); - - // Write it out. - // - catalog_ (cft, *c, map, "UTF-8", xml_schema::flags::dont_initialize); - - // Write out the compression stream trailer. If we don't do this - // explicitly, it will be done automatically in the cft's destructor - // but then any exceptions that might be throws will be ignored. - // - cft.close(); - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - r = 1; - } - catch (const compression_failure& e) - { - cerr << "compression failure: " << e.message () << endl; - r = 1; - } - catch (const decompression_failure& e) - { - cerr << "decompression failure: " << e.message () << endl; - r = 1; - } - catch (const ios_base::failure&) - { - cerr << "file open or read/write failure" << endl; - r = 1; - } - - xercesc::XMLPlatformUtils::Terminate (); - return r; -} diff --git a/examples/cxx/tree/compression/library.xml.gz b/examples/cxx/tree/compression/library.xml.gz deleted file mode 100644 index dd71159..0000000 Binary files a/examples/cxx/tree/compression/library.xml.gz and /dev/null differ diff --git a/examples/cxx/tree/compression/library.xsd b/examples/cxx/tree/compression/library.xsd deleted file mode 100644 index 728acc7..0000000 --- a/examples/cxx/tree/compression/library.xsd +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/compression/makefile b/examples/cxx/tree/compression/makefile deleted file mode 100644 index f6af7ea..0000000 --- a/examples/cxx/tree/compression/makefile +++ /dev/null @@ -1,127 +0,0 @@ -# file : examples/cxx/tree/compression/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := library.xsd -cxx := driver.cxx compressed-input-source.cxx compressed-format-target.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) - -ifeq ($(filter $(MAKECMDGOALS),dist dist-win install),) -$(call import,\ - $(scf_root)/import/libz/stub.make,\ - l: z.l,cpp-options: z.l.cpp-options) -endif - -# Build. -# -$(driver): $(obj) $(xerces_c.l) $(z.l) - -$(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd -$(obj) $(dep): $(xerces_c.l.cpp-options) $(z.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-serialization -$(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)/compressed-format-target.hxx,$(install_doc_dir)/xsd/$(path)/compressed-format-target.hxx) - $(call install-data,$(src_base)/compressed-format-target.cxx,$(install_doc_dir)/xsd/$(path)/compressed-format-target.cxx) - $(call install-data,$(src_base)/compressed-input-source.hxx,$(install_doc_dir)/xsd/$(path)/compressed-input-source.hxx) - $(call install-data,$(src_base)/compressed-input-source.cxx,$(install_doc_dir)/xsd/$(path)/compressed-input-source.cxx) - $(call install-data,$(src_base)/library.xsd,$(install_doc_dir)/xsd/$(path)/library.xsd) - $(call install-data,$(src_base)/library.xml.gz,$(install_doc_dir)/xsd/$(path)/library.xml.gz) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/compressed-format-target.hxx,$(dist_prefix)/$(path)/compressed-format-target.hxx) - $(call install-data,$(src_base)/compressed-format-target.cxx,$(dist_prefix)/$(path)/compressed-format-target.cxx) - $(call install-data,$(src_base)/compressed-input-source.hxx,$(dist_prefix)/$(path)/compressed-input-source.hxx) - $(call install-data,$(src_base)/compressed-input-source.cxx,$(dist_prefix)/$(path)/compressed-input-source.cxx) - $(call install-data,$(src_base)/library.xsd,$(dist_prefix)/$(path)/library.xsd) - $(call install-data,$(src_base)/library.xml.gz,$(dist_prefix)/$(path)/library.xml.gz) - -$(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,compression-vc8.sln) - $(call meta-vc9sln,$(src_root)/dist/template-vc9.sln,compression-vc9.sln) - $(call meta-vc10sln,$(src_root)/dist/template-vc10.sln,compression-vc10.sln) - $(call meta-vc11sln,$(src_root)/dist/template-vc11.sln,compression-vc11.sln) - $(call meta-vc12sln,$(src_root)/dist/template-vc12.sln,compression-vc12.sln) - - -# 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)/out.xml.gz) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(gen): | $(out_base)/.gitignore -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver out.xml.gz $(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) diff --git a/examples/cxx/tree/custom/README b/examples/cxx/tree/custom/README deleted file mode 100644 index b2a65b5..0000000 --- a/examples/cxx/tree/custom/README +++ /dev/null @@ -1,40 +0,0 @@ -This directory contains a number of examples that show how to customize the -C++/Tree mapping. The following list gives an overview of each example: - -calendar - Shows how to customize XML Schema built-in types by mapping xsd:date - built-in type to the date class from the Boost date_time library. - -comments - 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. - -contacts - Shows how to map a user-defined XML Schema type to a custom C++ class. - This example presents the simple case where the customized type is not - used as a base in the same schema. - -double - Shows how to customize parsing and serialization code for the xsd:double - XML Schema built-in type. It can be used as a guide on how to customize - built-in XML Schema types that are mapped to fundamental C++ types. - -mixed - Shows how to use type customization to parse and serialize mixed content. - -taxonomy - Shows how to map user-defined XML Schema types to custom C++ classes. - This example presents the complex case where the customized types are - inherited from in the same schema. - -wildcard - Shows how to use type customization to parse and serialize a specific - attribute that is matched by a wildcard (anyAttribute). - -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 diff --git a/examples/cxx/tree/custom/calendar/README b/examples/cxx/tree/custom/calendar/README deleted file mode 100644 index f7f6989..0000000 --- a/examples/cxx/tree/custom/calendar/README +++ /dev/null @@ -1,47 +0,0 @@ -This example shows how to customize the XML Schema built-in types by mapping -xsd:date built-in type to the date class from the Boost date_time library. -You will need the Boost date_time library[1] installed in order to build -and run this example. For more information on the C++/Tree mapping -customization see the C++/Tree Mapping Customization Guide[2]. - -[1] http://www.boost.org -[2] http://wiki.codesynthesis.com/Tree/Customization_guide - -The example consists of the following files: - -calendar.xsd - XML Schema definition for a simple calendar format. - -calendar.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:date type. - -calendar.hxx -calendar.ixx -calendar.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 calendar.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::date 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:date - 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 calendar events to STDERR. - -To run the example on the sample XML instance document simply execute: - -$ ./driver calendar.xml diff --git a/examples/cxx/tree/custom/calendar/calendar.xml b/examples/cxx/tree/custom/calendar/calendar.xml deleted file mode 100644 index 5cc898a..0000000 --- a/examples/cxx/tree/custom/calendar/calendar.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - Don't forget to change the tire. - - - - Can be cancelled if it is too cold. - - - diff --git a/examples/cxx/tree/custom/calendar/calendar.xsd b/examples/cxx/tree/custom/calendar/calendar.xsd deleted file mode 100644 index 04b3af1..0000000 --- a/examples/cxx/tree/custom/calendar/calendar.xsd +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/custom/calendar/driver.cxx b/examples/cxx/tree/custom/calendar/driver.cxx deleted file mode 100644 index a5b223e..0000000 --- a/examples/cxx/tree/custom/calendar/driver.cxx +++ /dev/null @@ -1,39 +0,0 @@ -// file : examples/cxx/tree/custom/calendar/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include - -#include "calendar.hxx" - -using std::cerr; -using std::endl; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " calendar.xml" << endl; - return 1; - } - - try - { - using namespace calendar; - - std::auto_ptr e (events_ (argv[1])); - - for (events::event_const_iterator i (e->event ().begin ()); - i != e->event ().end (); ++i) - { - cerr << i->date () << " " << i->title () << endl - << *i << endl; - } - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/examples/cxx/tree/custom/calendar/makefile b/examples/cxx/tree/custom/calendar/makefile deleted file mode 100644 index 169f9e3..0000000 --- a/examples/cxx/tree/custom/calendar/makefile +++ /dev/null @@ -1,136 +0,0 @@ -# file : examples/cxx/tree/custom/calendar/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := calendar.xsd -cxx := driver.cxx xml-schema-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) - -ifeq ($(filter $(MAKECMDGOALS),dist dist-win install),) -$(call import,\ - $(scf_root)/import/libboost/date-time/stub.make,\ - l: boost_date_time.l,cpp-options: boost_date_time.l.cpp-options) -endif - -# Build. -# -$(driver): $(obj) $(xerces_c.l) $(boost_date_time.l) - -$(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd -$(obj) $(dep): $(xerces_c.l.cpp-options) $(boost_date_time.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 \ ---custom-type date \ ---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 \ ---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)/calendar.xsd,$(install_doc_dir)/xsd/$(path)/calendar.xsd) - $(call install-data,$(src_base)/calendar.xml,$(install_doc_dir)/xsd/$(path)/calendar.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) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/calendar.xsd,$(dist_prefix)/$(path)/calendar.xsd) - $(call install-data,$(src_base)/calendar.xml,$(dist_prefix)/$(path)/calendar.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) - -$(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,calendar-vc8.sln) - $(call meta-vc9sln,$(src_root)/dist/template-vc9.sln,calendar-vc9.sln) - $(call meta-vc10sln,$(src_root)/dist/template-vc10.sln,calendar-vc10.sln) - $(call meta-vc11sln,$(src_root)/dist/template-vc11.sln,calendar-vc11.sln) - $(call meta-vc12sln,$(src_root)/dist/template-vc12.sln,calendar-vc12.sln) - - -# 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,$(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) diff --git a/examples/cxx/tree/custom/calendar/xml-schema-custom.cxx b/examples/cxx/tree/custom/calendar/xml-schema-custom.cxx deleted file mode 100644 index 645880b..0000000 --- a/examples/cxx/tree/custom/calendar/xml-schema-custom.cxx +++ /dev/null @@ -1,56 +0,0 @@ -// file : examples/cxx/tree/custom/calendar/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 // xsd::cxx::xml::transcode -#include // xsd::cxx::tree::text_content - -using namespace boost; -using namespace boost::gregorian; - -namespace xml_schema -{ - date:: - date (const xercesc::DOMElement& e, flags f, container* c) - : simple_type (e, f, c), - gregorian::date ( - from_simple_string ( - xsd::cxx::tree::text_content (e))) - { - } - - date:: - date (const xercesc::DOMAttr& a, flags f, container* c) - : simple_type (a, f, c), - gregorian::date ( - from_simple_string ( - xsd::cxx::xml::transcode (a.getValue ()))) - { - } - - date:: - date (const std::string& s, - const xercesc::DOMElement* e, - flags f, - container* c) - : simple_type (s, e, f, c), - gregorian::date (from_simple_string (s)) - { - } - - date:: - date (const date& d, flags f, container* c) - : simple_type (d, f, c), - gregorian::date (d) - { - } - - date* date:: - _clone (flags f, container* c) const - { - return new date (*this, f, c); - } -} diff --git a/examples/cxx/tree/custom/calendar/xml-schema-custom.hxx b/examples/cxx/tree/custom/calendar/xml-schema-custom.hxx deleted file mode 100644 index 58f57e6..0000000 --- a/examples/cxx/tree/custom/calendar/xml-schema-custom.hxx +++ /dev/null @@ -1,33 +0,0 @@ -// file : examples/cxx/tree/custom/calendar/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 // boost::gregorian::date - -namespace xml_schema -{ - class date: public simple_type, - public boost::gregorian::date - { - public: - // Parsing c-tors: element, attribute, and list item. - // - date (const xercesc::DOMElement&, flags = 0, container* = 0); - date (const xercesc::DOMAttr&, flags = 0, container* = 0); - date (const std::string&, - const xercesc::DOMElement*, - flags = 0, - container* = 0); - - // Copy c-tor and _clone. - // - date (const date&, flags = 0, container* = 0); - - virtual date* - _clone (flags = 0, container* = 0) const; - }; -} 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&); -} 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 - -// 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 // 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 @@ - - - - - - - - Joe Dirt - joe@dirt.com - 555 DIRT - - - 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 @@ - - - - - - - - - - - - - - - - - - - - - - - - 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 // std::auto_ptr -#include - -#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 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) diff --git a/examples/cxx/tree/custom/double/README b/examples/cxx/tree/custom/double/README deleted file mode 100644 index 15348d2..0000000 --- a/examples/cxx/tree/custom/double/README +++ /dev/null @@ -1,62 +0,0 @@ -This example shows how to customize parsing and serialization code for the -xsd:double XML Schema built-in type using the type customization mechanism -provided by the C++/Tree Mapping. For more information on type customization -see the C++/Tree Mapping Customization Guide, particularly sections 1 and 4: - -http://wiki.codesynthesis.com/Tree/Customization_guide - -In this example our schema uses xsd:double to represent a price. There are -two potential problems with this choice of a price type. First, xsd:double -can be serialized in the scientific notation which would be an unusual way -of representing a price. Second, we would like to limit the number of -fraction digits in our prices to 2. Furthermore, we would like to always -have two fraction digits, even if one or both of them are zeros, for -example: 12.99, 12.90, 12.00. - -In case we can modify the schema, a better approach would be to define the -price type as a restriction of the xsd:decimal type (always fixed notation) -and specify the fractionDigits facet to limit the number of fraction digits -to 2. However, there is no way in XML Schema to specify that there should -always be exactly 2 fraction digits. Therefore, it may still be desirable -to customize this price type to get the required serialization behavior. - -Finally, it is worth noting that the behavior achieved in this example via -type customization can also be achieved by compiling your code with the -following macros defined: - -XSD_TREE_DOUBLE_FIXED -XSD_TREE_DOUBLE_PRECISION 2 - -However, the type customization approach while requiring more work is -cleaner since it does not rely on global macro definitions. - -This example consists of the following files: - -order.xsd - XML Schema definition for a simple order vocabulary. - -double-custom.hxx -double-custom.cxx - Custom parsing and serialization code for the xsd:double types. The - double-custom.hxx file is included at the end of the xml-schema.hxx - file described below. - -xml-schema.hxx - C++ types for XML Schema built-in types. This header file is generated - by the XSD compiler using the --generate-xml-schema option. The - --custom-type option is used to customize the xsd:double type. The - --hxx-epilogue option is used to include the double-custom.hxx file - at the end of this file. - -order.hxx -order.cxx - C++ types generated from order.xsd. The --extern-xml-schema option - is used to include xml-schema.hxx into order.hxx. - -driver.cxx - Test driver for the example. It creates a sample order and then - writes it to XML to test the custom xsd:double serialization code. - -To run the example simply execute: - -$ ./driver diff --git a/examples/cxx/tree/custom/double/double-custom.cxx b/examples/cxx/tree/custom/double/double-custom.cxx deleted file mode 100644 index 6aad908..0000000 --- a/examples/cxx/tree/custom/double/double-custom.cxx +++ /dev/null @@ -1,96 +0,0 @@ -// file : examples/cxx/tree/custom/double/double-custom.cxx -// copyright : not copyrighted - public domain - -// Include xml-schema.hxx instead of double-custom.hxx here. -// -#include "xml-schema.hxx" - -#include -#include -#include - -#include -#include - -using namespace std; - -// Parsing. -// -namespace xsd -{ - namespace cxx - { - namespace tree - { - double traits:: - create (const std::string& s, - const xercesc::DOMElement*, - flags, - type*) - { - // This type cannot have whitespaces in its values. As result we - // don't need to waste time collapsing whitespaces. All we need to - // do is trim the string representation which can be done without - // copying. - // - ro_string tmp (s); - trim (tmp); - - zc_istream is (tmp); - is.imbue (locale::classic ()); - - double t; - is >> t; - - return t; - } - } - } -} - -// Serialization. -// -namespace XERCES_CPP_NAMESPACE -{ - void - operator<< (xercesc::DOMElement& e, const xml_schema::as_double& d) - { - ostringstream os; - os.imbue (locale::classic ()); - - os.precision (2); - os << fixed << d.x; - - e << os.str (); - } - - void - operator<< (xercesc::DOMAttr& a, const xml_schema::as_double& d) - { - ostringstream os; - os.imbue (locale::classic ()); - - os.precision (2); - os << fixed << d.x; - - a << os.str (); - } -} - -namespace xsd -{ - namespace cxx - { - namespace tree - { - void - operator<< (xml_schema::list_stream& ls, - const xml_schema::as_double& d) - { - ls.os_.imbue (locale::classic ()); - ls.os_.precision (2); - ls.os_ << fixed << d.x; - } - } - } -} diff --git a/examples/cxx/tree/custom/double/double-custom.hxx b/examples/cxx/tree/custom/double/double-custom.hxx deleted file mode 100644 index 1516211..0000000 --- a/examples/cxx/tree/custom/double/double-custom.hxx +++ /dev/null @@ -1,67 +0,0 @@ -// file : examples/cxx/tree/custom/double/double-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 // xml::transcode -#include // text_content - -// Parsing. -// -namespace xsd -{ - namespace cxx - { - namespace tree - { - template<> - struct traits - { - static double - create (const xercesc::DOMElement& e, flags f, type* c) - { - return create (text_content (e), 0, f, c); - } - - static double - create (const xercesc::DOMAttr& a, flags f, type* c) - { - return create (xml::transcode (a.getValue ()), 0, f, c); - } - - static double - create (const std::string& s, - const xercesc::DOMElement*, - flags, - type*); - }; - } - } -} - -// Serialization. -// -namespace XERCES_CPP_NAMESPACE -{ - void - operator<< (xercesc::DOMElement& e, const xml_schema::as_double& d); - - void - operator<< (xercesc::DOMAttr& a, const xml_schema::as_double& d); -} - -namespace xsd -{ - namespace cxx - { - namespace tree - { - void - operator<< (xml_schema::list_stream& ls, - const xml_schema::as_double& d); - } - } -} diff --git a/examples/cxx/tree/custom/double/driver.cxx b/examples/cxx/tree/custom/double/driver.cxx deleted file mode 100644 index 8b102a5..0000000 --- a/examples/cxx/tree/custom/double/driver.cxx +++ /dev/null @@ -1,31 +0,0 @@ -// file : examples/cxx/tree/custom/double/driver.cxx -// copyright : not copyrighted - public domain - -#include - -#include "order.hxx" - -using std::cerr; -using std::endl; - -int -main () -{ - try - { - // Order one Airbus A380. - // - order o; - o.item ().push_back (item ("Airbus A380", 317000000.90)); - - - // Serialize. - // - order_ (std::cout, o); - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/examples/cxx/tree/custom/double/makefile b/examples/cxx/tree/custom/double/makefile deleted file mode 100644 index 7a5e22f..0000000 --- a/examples/cxx/tree/custom/double/makefile +++ /dev/null @@ -1,111 +0,0 @@ -# file : examples/cxx/tree/custom/double/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := order.xsd -cxx := driver.cxx double-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) - -$(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 double=double \ ---hxx-epilogue '#include "double-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-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)/order.xsd,$(install_doc_dir)/xsd/$(path)/order.xsd) - $(call install-data,$(src_base)/double-custom.hxx,$(install_doc_dir)/xsd/$(path)/double-custom.hxx) - $(call install-data,$(src_base)/double-custom.cxx,$(install_doc_dir)/xsd/$(path)/double-custom.cxx) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/order.xsd,$(dist_prefix)/$(path)/order.xsd) - $(call install-data,$(src_base)/double-custom.hxx,$(dist_prefix)/$(path)/double-custom.hxx) - $(call install-data,$(src_base)/double-custom.cxx,$(dist_prefix)/$(path)/double-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)) - $(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/double/order.xsd b/examples/cxx/tree/custom/double/order.xsd deleted file mode 100644 index 9cf1a1d..0000000 --- a/examples/cxx/tree/custom/double/order.xsd +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/custom/makefile b/examples/cxx/tree/custom/makefile deleted file mode 100644 index e2662a4..0000000 --- a/examples/cxx/tree/custom/makefile +++ /dev/null @@ -1,60 +0,0 @@ -# file : examples/cxx/tree/custom/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -all_examples := comments contacts double mixed taxonomy wildcard calendar -build_examples := comments contacts double mixed taxonomy wildcard - -ifeq ($(xsd_with_boost_date_time),y) -build_examples += calendar -endif - -default := $(out_base)/ -install := $(out_base)/.install -dist := $(out_base)/.dist -dist-win := $(out_base)/.dist-win -clean := $(out_base)/.clean - -# Build. -# -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(build_examples))) - -# Install & Dist. -# -$(install) $(dist) $(dist-win): path := $(subst $(src_root)/,,$(src_base)) - -$(install): $(addprefix $(out_base)/,$(addsuffix /.install,$(all_examples))) - $(call install-data,$(src_base)/README,$(install_doc_dir)/xsd/$(path)/README) - -$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(all_examples))) - $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README) - -$(dist-win): |$(out_root)/.dist-pre -$(dist-win): $(addprefix $(out_base)/,$(addsuffix /.dist-win,$(all_examples))) - $(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,custom-vc8.sln) - $(call meta-vc9sln,$(src_root)/dist/template-vc9.sln,custom-vc9.sln) - $(call meta-vc10sln,$(src_root)/dist/template-vc10.sln,custom-vc10.sln) - $(call meta-vc11sln,$(src_root)/dist/template-vc11.sln,custom-vc11.sln) - $(call meta-vc12sln,$(src_root)/dist/template-vc12.sln,custom-vc12.sln) - - -# Clean. -# -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(build_examples))) - -$(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) - -ifneq ($(filter $(MAKECMDGOALS),dist dist-win install),) -$(foreach e,$(all_examples),$(call import,$(src_base)/$e/makefile)) -else -$(foreach e,$(build_examples),$(call import,$(src_base)/$e/makefile)) -endif - diff --git a/examples/cxx/tree/custom/mixed/README b/examples/cxx/tree/custom/mixed/README deleted file mode 100644 index 7b56812..0000000 --- a/examples/cxx/tree/custom/mixed/README +++ /dev/null @@ -1,50 +0,0 @@ -This example shows how to use type customization to parse and serialize -mixed content. The example achieves this by customizing the type with -the mixed content model to include a DOM document that stores the data -as a raw XML representation. The customized type also provides its own -parsing constructor and serialization operator where the mixed content -is extracted from and inserted back to DOM, respectively. The use of -DOM for mixed content storage is one of the options. You may find other -data structures (e.g., a string) more suitable depending on your situation. - -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: - -people.xsd - XML Schema definition for a simple person record vocabulary. Each - record includes the bio element which represents arbitrary XHTML - fragments as mixed content. - -people.xml - Sample XML instance document. - -people.hxx -people.ixx -people.cxx - C++ types that represent the given 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 --custom-type option in order to customize the bio type. - -people-custom.hxx - Header file which defines our own bio class by inheriting from the - generated bio_base. It is included at the end of people.hxx using - the --hxx-epilogue option. - -people-custom.cxx - Source file which contains the implementation of our bio 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 data to STDERR, including the bio information converted to text. - Finally, the driver serializes the object model back to XML. - -To run the example on the sample XML instance document simply execute: - -$ ./driver people.xml diff --git a/examples/cxx/tree/custom/mixed/driver.cxx b/examples/cxx/tree/custom/mixed/driver.cxx deleted file mode 100644 index 0378f18..0000000 --- a/examples/cxx/tree/custom/mixed/driver.cxx +++ /dev/null @@ -1,123 +0,0 @@ -// file : examples/cxx/tree/custom/mixed/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include - -#include -#include - -#include "people.hxx" - -// The following transcode() utility function is handy when working with -// Xerces. Include it after the generated header in order to get only char -// or wchar_t version depending on how you compiled your schemas. -// -#include - -using std::cerr; -using std::endl; -using namespace xercesc; - - -void -xhtml2txt (const DOMElement*); - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " people.xml" << endl; - return 1; - } - - int r (0); - - // The Xerces-C++ DOM document that will be used to store the XHTML - // fragments "out-live" the call to the parsing function. Therefore - // we need to initialize the Xerces-C++ runtime ourselves. - // - XMLPlatformUtils::Initialize (); - - try - { - using namespace people; - - // Parse. - // - std::auto_ptr d ( - directory_ (argv[1], xml_schema::flags::dont_initialize)); - - // Print what we've got. - // - const directory::person_sequence& s (d->person ()); - - for (directory::person_const_iterator i (s.begin ()); i != s.end (); ++i) - { - cerr << "First : " << i->first_name () << endl - << "Last : " << i->last_name () << endl - << "Gender : " << i->gender () << endl - << "Age : " << i->age () << endl; - - const bio& b (i->bio ()); - const DOMElement* xhtml (b.xhtml ()); - - if (xhtml != 0) - { - cerr << "Bio : " << endl; - xhtml2txt (xhtml); - } - - cerr << endl; - } - - // Serialize. - // - xml_schema::namespace_infomap map; - - map["ppl"].name = "http://www.codesynthesis.com/people"; - map["ppl"].schema = "people.xsd"; - - directory_ ( - std::cout, *d, map, "UTF-8", xml_schema::flags::dont_initialize); - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - r = 1; - } - - XMLPlatformUtils::Terminate (); - return r; -} - -// Primitive XHTML to text converter that just prints all the text -// nodes and ignores everything else. -// -void -xhtml2txt (const DOMElement* e) -{ - namespace xml = xsd::cxx::xml; - - for (const DOMNode* n (e->getFirstChild ()); - n != 0; - n = n->getNextSibling ()) - { - switch (n->getNodeType ()) - { - case DOMNode::TEXT_NODE: - { - cerr << xml::transcode (n->getTextContent ()); - break; - } - case DOMNode::ELEMENT_NODE: - { - xhtml2txt (static_cast (n)); - break; - } - default: - break; // Ignore all other nodes (e.g., comments, etc). - } - } -} diff --git a/examples/cxx/tree/custom/mixed/makefile b/examples/cxx/tree/custom/mixed/makefile deleted file mode 100644 index c191271..0000000 --- a/examples/cxx/tree/custom/mixed/makefile +++ /dev/null @@ -1,114 +0,0 @@ -# file : examples/cxx/tree/custom/mixed/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := people.xsd -cxx := driver.cxx people-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 \ ---generate-serialization \ ---custom-type bio=/bio_base \ ---hxx-epilogue '\#include "people-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)/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)/people-custom.hxx,$(install_doc_dir)/xsd/$(path)/people-custom.hxx) - $(call install-data,$(src_base)/people-custom.cxx,$(install_doc_dir)/xsd/$(path)/people-custom.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)/people-custom.hxx,$(dist_prefix)/$(path)/people-custom.hxx) - $(call install-data,$(src_base)/people-custom.cxx,$(dist_prefix)/$(path)/people-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) diff --git a/examples/cxx/tree/custom/mixed/people-custom.cxx b/examples/cxx/tree/custom/mixed/people-custom.cxx deleted file mode 100644 index 7cd1947..0000000 --- a/examples/cxx/tree/custom/mixed/people-custom.cxx +++ /dev/null @@ -1,89 +0,0 @@ -// file : examples/cxx/tree/custom/mixed/people-custom.cxx -// copyright : not copyrighted - public domain - -#include - -// Include people.hxx instead of people-custom.hxx here. -// -#include "people.hxx" - -namespace people -{ - using namespace xercesc; - - const XMLCh ls[] = {chLatin_L, chLatin_S, chNull}; - - bio:: - bio () - : xhtml_ (0) - { - DOMImplementation* impl ( - DOMImplementationRegistry::getDOMImplementation (ls)); - - doc_.reset (impl->createDocument ()); - } - - bio:: - bio (const DOMElement& e, - xml_schema::flags f, - xml_schema::container* c) - : bio_base (e, f, c), xhtml_ (0) - { - DOMImplementation* impl ( - DOMImplementationRegistry::getDOMImplementation (ls)); - - doc_.reset (impl->createDocument ()); - - // Copy the xhtml element. Assume the first child element in - // e is always xhtml. - // - for (DOMNode* n (e.getFirstChild ()); n != 0; n = n->getNextSibling ()) - { - if (n->getNodeType () == DOMNode::ELEMENT_NODE) - { - xhtml_ = static_cast (doc_->importNode (n, true)); - break; - } - } - } - - bio:: - bio (const bio& d, - xml_schema::flags f, - xml_schema::container* c) - : bio_base (d, f, c), xhtml_ (0) - { - DOMImplementation* impl ( - DOMImplementationRegistry::getDOMImplementation (ls)); - - doc_.reset (impl->createDocument ()); - - xhtml_ = static_cast ( - doc_->importNode (const_cast (d.xhtml_), true)); - } - - bio* bio:: - _clone (xml_schema::flags f, xml_schema::container* c) const - { - return new bio (*this, f, c); - } - - void - operator<< (DOMElement& e, const bio& x) - { - // Allow our base to serialize first. - // - const bio_base& b (x); - e << b; - - // Copy the XHTML fragment if we have one. - // - const DOMElement* xhtml (x.xhtml ()); - - if (xhtml != 0) - { - DOMDocument* doc (e.getOwnerDocument ()); - e.appendChild (doc->importNode (const_cast (xhtml), true)); - } - } -} diff --git a/examples/cxx/tree/custom/mixed/people-custom.hxx b/examples/cxx/tree/custom/mixed/people-custom.hxx deleted file mode 100644 index 54dfb21..0000000 --- a/examples/cxx/tree/custom/mixed/people-custom.hxx +++ /dev/null @@ -1,83 +0,0 @@ -// file : examples/cxx/tree/custom/mixed/people-custom.hxx -// copyright : not copyrighted - public domain - -// Do not include this file directly, use people.hxx instead. This -// file is included into generated people.hxx so we do not need to -// guard against multiple inclusions. -// - -#include -#include - -namespace people -{ - class bio: public bio_base - { - // Standard constructors. - // - public: - bio (); - - bio (const xercesc::DOMElement&, - xml_schema::flags = 0, - xml_schema::container* = 0); - - bio (const bio&, - xml_schema::flags = 0, - xml_schema::container* = 0); - - virtual bio* - _clone (xml_schema::flags = 0, - xml_schema::container* = 0) const; - - // XHTML bio as a DOM document. - // - public: - const xercesc::DOMElement* - xhtml () const - { - return xhtml_; - } - - xercesc::DOMElement* - xhtml () - { - return xhtml_; - } - - // The element should belong to the DOMDocument returned by - // the dom_document() functions. - // - void - xhtml (xercesc::DOMElement* e) - { - assert (e->getOwnerDocument () == doc_.get ()); - - if (xhtml_ != 0) - xhtml_->release (); - - xhtml_ = e; - } - - const xercesc::DOMDocument& - dom_document () const - { - return *doc_; - } - - xercesc::DOMDocument& - dom_document () - { - return *doc_; - } - - private: - xercesc::DOMElement* xhtml_; - xml_schema::dom::auto_ptr doc_; - }; - - // Serialization operator. - // - void - operator<< (xercesc::DOMElement&, const bio&); -} diff --git a/examples/cxx/tree/custom/mixed/people.xml b/examples/cxx/tree/custom/mixed/people.xml deleted file mode 100644 index 47e68b9..0000000 --- a/examples/cxx/tree/custom/mixed/people.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - John - Doe - male - 32 - - -

Married to Jane Doe.

-
-
-
- - - Jane - Doe - female - 28 - - -

Married to John Doe.

-
-
-
- -
diff --git a/examples/cxx/tree/custom/mixed/people.xsd b/examples/cxx/tree/custom/mixed/people.xsd deleted file mode 100644 index 03e6c97..0000000 --- a/examples/cxx/tree/custom/mixed/people.xsd +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/custom/taxonomy/README b/examples/cxx/tree/custom/taxonomy/README deleted file mode 100644 index c2e425a..0000000 --- a/examples/cxx/tree/custom/taxonomy/README +++ /dev/null @@ -1,53 +0,0 @@ -This example shows how to map user-defined XML Schema types to custom C++ -classes. It presents the complex case where the customized types are -inherited from in the same schema. For the simple case see the contacts -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: - -people.xsd - XML Schema definition for a simple people database. - -people.xml - Sample XML instance document. - -people-fwd.hxx -people.hxx -people.ixx -people.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 people.xsd with the - --custom-type option in order to customize the person, superman, and - batman types. Generation of the people-fwd.hxx forward declaration - file is requested with the --generate-forward option. Note also that - we use the --generate-polymorphic command line option as well as - --polymorphic-type to mark the type hierarchy starting with the - person type as polymorphic. - -people-custom-fwd.hxx - Header file which forward-declares our own person, superman, and batman - as class templates. It is included at the beginning of people-fwd.hxx - using the --fwd-prologue option. - -people-custom.hxx - Header file which defines our own person, superman, and batman class - templates by inheriting from the generated person_base, superman_base, - and batman_base. It is included at the beginning of people.hxx using - the --hxx-prologue option. - -people-custom.cxx - Source file which contains the implementations and instantiations of - our person, superman, and batman class templates. - -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 database to STDERR. - -To run the example on the sample XML instance document simply execute: - -$ ./driver people.xml diff --git a/examples/cxx/tree/custom/taxonomy/driver.cxx b/examples/cxx/tree/custom/taxonomy/driver.cxx deleted file mode 100644 index ec562f6..0000000 --- a/examples/cxx/tree/custom/taxonomy/driver.cxx +++ /dev/null @@ -1,38 +0,0 @@ -// file : examples/cxx/tree/custom/taxonomy/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include - -#include "people.hxx" - -using std::cerr; -using std::endl; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " people.xml" << endl; - return 1; - } - - try - { - using namespace people; - - std::auto_ptr c (catalog_ (argv[1])); - - for (catalog::person_const_iterator i (c->person ().begin ()); - i != c->person ().end (); ++i) - { - i->print (cerr); - } - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/examples/cxx/tree/custom/taxonomy/makefile b/examples/cxx/tree/custom/taxonomy/makefile deleted file mode 100644 index bc041af..0000000 --- a/examples/cxx/tree/custom/taxonomy/makefile +++ /dev/null @@ -1,121 +0,0 @@ -# file : examples/cxx/tree/custom/taxonomy/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := people.xsd -cxx := driver.cxx people-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=-fwd.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 \ ---generate-forward \ ---generate-polymorphic \ ---polymorphic-type person \ ---custom-type "person=person_impl/person_base" \ ---custom-type "superman=superman_impl/superman_base" \ ---custom-type "batman=batman_impl/batman_base" \ ---fwd-prologue '\#include "people-custom-fwd.hxx"' \ ---hxx-prologue '\#include "people-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)/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)/people-custom.hxx,$(install_doc_dir)/xsd/$(path)/people-custom.hxx) - $(call install-data,$(src_base)/people-custom.cxx,$(install_doc_dir)/xsd/$(path)/people-custom.cxx) - $(call install-data,$(src_base)/people-custom-fwd.hxx,$(install_doc_dir)/xsd/$(path)/people-custom-fwd.hxx) - -$(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)/people-custom.hxx,$(dist_prefix)/$(path)/people-custom.hxx) - $(call install-data,$(src_base)/people-custom.cxx,$(dist_prefix)/$(path)/people-custom.cxx) - $(call install-data,$(src_base)/people-custom-fwd.hxx,$(dist_prefix)/$(path)/people-custom-fwd.hxx) - -$(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/custom/taxonomy/people-custom-fwd.hxx b/examples/cxx/tree/custom/taxonomy/people-custom-fwd.hxx deleted file mode 100644 index 2c26bf5..0000000 --- a/examples/cxx/tree/custom/taxonomy/people-custom-fwd.hxx +++ /dev/null @@ -1,19 +0,0 @@ -// file : examples/cxx/tree/custom/taxonomy/people-custom-fwd.hxx -// copyright : not copyrighted - public domain - -// Do not include this file directly, use people-fwd.hxx instead. This -// file is included into generated people-fwd.hxx so we do not need to -// guard against multiple inclusions. -// - -namespace people -{ - template - class person_impl; - - template - class superman_impl; - - template - class batman_impl; -} diff --git a/examples/cxx/tree/custom/taxonomy/people-custom.cxx b/examples/cxx/tree/custom/taxonomy/people-custom.cxx deleted file mode 100644 index a06a6ea..0000000 --- a/examples/cxx/tree/custom/taxonomy/people-custom.cxx +++ /dev/null @@ -1,156 +0,0 @@ -// file : examples/cxx/tree/custom/taxonomy/people-custom.cxx -// copyright : not copyrighted - public domain - -#include - -// Include people.hxx instead of people-custom.hxx here. -// -#include "people.hxx" - -namespace people -{ - // person_impl - // - template - person_impl:: - person_impl (const xml_schema::string& name) - : base (name) - { - } - - template - person_impl:: - person_impl (const xercesc::DOMElement& e, - xml_schema::flags f, - xml_schema::container* c) - : base (e, f, c) - { - } - - template - person_impl:: - person_impl (const person_impl& p, - xml_schema::flags f, - xml_schema::container* c) - : base (p, f, c) - { - } - - template - person_impl* person_impl:: - _clone (xml_schema::flags f, xml_schema::container* c) const - { - return new person_impl (*this, f, c); - } - - template - void person_impl:: - print (std::ostream& os) const - { - os << this->name () << std::endl; - } - - // Explicitly instantiate person_impl class template for person_base. - // - template class person_impl; - - - // superman_impl - // - template - superman_impl:: - superman_impl (const xml_schema::string& name, bool can_fly) - : base (name, can_fly) - { - } - - template - superman_impl:: - superman_impl (const xercesc::DOMElement& e, - xml_schema::flags f, - xml_schema::container* c) - : base (e, f, c) - { - } - - template - superman_impl:: - superman_impl (const superman_impl& s, - xml_schema::flags f, - xml_schema::container* c) - : base (s, f, c) - { - } - - template - superman_impl* superman_impl:: - _clone (xml_schema::flags f, xml_schema::container* c) const - { - return new superman_impl (*this, f, c); - } - - template - void superman_impl:: - print (std::ostream& os) const - { - if (this->can_fly ()) - os << "Flying superman "; - else - os << "Superman "; - - os << this->name () << std::endl; - } - - // Explicitly instantiate superman_impl class template for superman_base. - // - template class superman_impl; - - - // batman_impl - // - template - batman_impl:: - batman_impl (const xml_schema::string& name, - bool can_fly, - unsigned int wing_span) - : base (name, can_fly, wing_span) - { - } - - template - batman_impl:: - batman_impl (const xercesc::DOMElement& e, - xml_schema::flags f, - xml_schema::container* c) - : base (e, f, c) - { - } - - template - batman_impl:: - batman_impl (const batman_impl& s, - xml_schema::flags f, - xml_schema::container* c) - : base (s, f, c) - { - } - - template - batman_impl* batman_impl:: - _clone (xml_schema::flags f, xml_schema::container* c) const - { - return new batman_impl (*this, f, c); - } - - template - void batman_impl:: - print (std::ostream& os) const - { - os << "Batman " << this->name () << " with " << - this->wing_span () << "m wing span" << std::endl; - } - - // Explicitly instantiate batman_impl class template for batman_base. - // - template class batman_impl; -} diff --git a/examples/cxx/tree/custom/taxonomy/people-custom.hxx b/examples/cxx/tree/custom/taxonomy/people-custom.hxx deleted file mode 100644 index a60edc8..0000000 --- a/examples/cxx/tree/custom/taxonomy/people-custom.hxx +++ /dev/null @@ -1,96 +0,0 @@ -// file : examples/cxx/tree/custom/taxonomy/people-custom.hxx -// copyright : not copyrighted - public domain - -// Do not include this file directly, use people.hxx instead. This -// file is included into generated people.hxx so we do not need to -// guard against multiple inclusions. -// - -#include // std::ostream - -// Include people-fwd.hxx here so that we can refer to the generated -// types. -// -#include "people-fwd.hxx" - -namespace people -{ - // - // - template - class person_impl: public base - { - public: - person_impl (const xml_schema::string& name); - - person_impl (const xercesc::DOMElement&, - xml_schema::flags = 0, - xml_schema::container* = 0); - - person_impl (const person_impl&, - xml_schema::flags = 0, - xml_schema::container* = 0); - - virtual person_impl* - _clone (xml_schema::flags = 0, - xml_schema::container* = 0) const; - - public: - virtual void - print (std::ostream&) const; - }; - - - // - // - template - class superman_impl: public base - { - public: - superman_impl (const xml_schema::string& name, bool can_fly); - - superman_impl (const xercesc::DOMElement&, - xml_schema::flags = 0, - xml_schema::container* = 0); - - superman_impl (const superman_impl&, - xml_schema::flags = 0, - xml_schema::container* = 0); - - virtual superman_impl* - _clone (xml_schema::flags = 0, - xml_schema::container* = 0) const; - - public: - virtual void - print (std::ostream&) const; - }; - - - // - // - template - class batman_impl: public base - { - public: - batman_impl (const xml_schema::string& name, - bool can_fly, - unsigned int wing_span); - - batman_impl (const xercesc::DOMElement&, - xml_schema::flags = 0, - xml_schema::container* = 0); - - batman_impl (const batman_impl&, - xml_schema::flags = 0, - xml_schema::container* = 0); - - virtual batman_impl* - _clone (xml_schema::flags = 0, - xml_schema::container* = 0) const; - - public: - virtual void - print (std::ostream&) const; - }; -} diff --git a/examples/cxx/tree/custom/taxonomy/people.xml b/examples/cxx/tree/custom/taxonomy/people.xml deleted file mode 100644 index b53b576..0000000 --- a/examples/cxx/tree/custom/taxonomy/people.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - Joe Dirt - - - - James "007" Bond - - - - Bruce Wayne - - - diff --git a/examples/cxx/tree/custom/taxonomy/people.xsd b/examples/cxx/tree/custom/taxonomy/people.xsd deleted file mode 100644 index 1181270..0000000 --- a/examples/cxx/tree/custom/taxonomy/people.xsd +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/custom/wildcard/README b/examples/cxx/tree/custom/wildcard/README deleted file mode 100644 index 70eaea4..0000000 --- a/examples/cxx/tree/custom/wildcard/README +++ /dev/null @@ -1,45 +0,0 @@ -This example shows how to use type customization to parse and serialize -a specific attribute that is matched by a wildcard (anyAttribute). The -example achieves this by customizing the type to include the data -members and accessors/modifiers that represent the attribute as well as -the parsing constructor and serialization operator where the attribute -value is extracted from and inserted back to DOM, respectively. 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: - -wildcard.xsd - XML Schema definition for simple data type and element. - -wildcard.xml - Sample XML instance document. - -wildcard.hxx -wildcard.ixx -wildcard.cxx - C++ types that represent the given 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 wildcard.xsd - with the --custom-type option in order to customize the data type. - -wildcard-custom.hxx - Header file which defines our own data class by inheriting from the - generated data_base. It is included at the end of wildcard.hxx using - the --hxx-epilogue option. - -wildcard-custom.cxx - Source file which contains the implementation of our data 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 data to STDERR, including the extra attribute. Finally, the driver - serializes the object model back to XML. - -To run the example on the sample XML instance document simply execute: - -$ ./driver wildcard.xml diff --git a/examples/cxx/tree/custom/wildcard/driver.cxx b/examples/cxx/tree/custom/wildcard/driver.cxx deleted file mode 100644 index d29f125..0000000 --- a/examples/cxx/tree/custom/wildcard/driver.cxx +++ /dev/null @@ -1,47 +0,0 @@ -// file : examples/cxx/tree/custom/wildcard/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include - -#include "wildcard.hxx" - -using std::cerr; -using std::endl; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " wildcard.xml" << endl; - return 1; - } - - try - { - using namespace wildcard; - - // Parse. - // - std::auto_ptr d (data_ (argv[1])); - - // Print. - // - cerr << *d << endl; - - // Serialize. - // - xml_schema::namespace_infomap map; - - map["wc"].name = "http://www.codesynthesis.com/wildcard"; - map["wc"].schema = "wildcard.xsd"; - - data_ (std::cout, *d, map); - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/examples/cxx/tree/custom/wildcard/makefile b/examples/cxx/tree/custom/wildcard/makefile deleted file mode 100644 index ed8801c..0000000 --- a/examples/cxx/tree/custom/wildcard/makefile +++ /dev/null @@ -1,115 +0,0 @@ -# file : examples/cxx/tree/custom/wildcard/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := wildcard.xsd -cxx := driver.cxx wildcard-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 \ ---generate-ostream \ ---generate-serialization \ ---custom-type data=/data_base \ ---hxx-epilogue '\#include "wildcard-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)/wildcard.xsd,$(install_doc_dir)/xsd/$(path)/wildcard.xsd) - $(call install-data,$(src_base)/wildcard.xml,$(install_doc_dir)/xsd/$(path)/wildcard.xml) - $(call install-data,$(src_base)/wildcard-custom.hxx,$(install_doc_dir)/xsd/$(path)/wildcard-custom.hxx) - $(call install-data,$(src_base)/wildcard-custom.cxx,$(install_doc_dir)/xsd/$(path)/wildcard-custom.cxx) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/wildcard.xsd,$(dist_prefix)/$(path)/wildcard.xsd) - $(call install-data,$(src_base)/wildcard.xml,$(dist_prefix)/$(path)/wildcard.xml) - $(call install-data,$(src_base)/wildcard-custom.hxx,$(dist_prefix)/$(path)/wildcard-custom.hxx) - $(call install-data,$(src_base)/wildcard-custom.cxx,$(dist_prefix)/$(path)/wildcard-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) diff --git a/examples/cxx/tree/custom/wildcard/wildcard-custom.cxx b/examples/cxx/tree/custom/wildcard/wildcard-custom.cxx deleted file mode 100644 index 006f93a..0000000 --- a/examples/cxx/tree/custom/wildcard/wildcard-custom.cxx +++ /dev/null @@ -1,84 +0,0 @@ -// file : examples/cxx/tree/custom/wildcard/wildcard-custom.cxx -// copyright : not copyrighted - public domain - -#include - -// Include wildcard.hxx instead of wildcard-custom.hxx here. -// -#include "wildcard.hxx" - -namespace wildcard -{ - data:: - data (const xml_schema::string& d) - : data_base (d), scope_present_ (false) - { - } - - data:: - data (const xercesc::DOMElement& e, - xml_schema::flags f, - xml_schema::container* c) - : data_base (e, f, c), scope_present_ (false) - { - // Check if we've got the scope attribute. - // - namespace xml = xsd::cxx::xml; - xml::string name ("scope"); - - if (e.hasAttribute (name.c_str ())) - { - scope (xml::transcode (e.getAttribute (name.c_str ()))); - } - } - - data:: - data (const data& d, - xml_schema::flags f, - xml_schema::container* c) - : data_base (d, f, c), - scope_present_ (d.scope_present_), - scope_ (d.scope_) - { - } - - data* data:: - _clone (xml_schema::flags f, xml_schema::container* c) const - { - return new data (*this, f, c); - } - - void - operator<< (xercesc::DOMElement& e, const data& x) - { - // Use our base to serialize data and id. - // - const data_base& b (x); - e << b; - - // Add the scope attribute if present. - // - if (x.scope_present ()) - { - namespace xml = xsd::cxx::xml; - xml::string name ("scope"); - xml::string value (x.scope ()); - - e.setAttribute (name.c_str (), value.c_str ()); - } - } - - std::ostream& - operator<< (std::ostream& os, const data& x) - { - // Use our base to print date and id. - // - const data_base& b (x); - os << b; - - if (x.scope_present ()) - os << std::endl << "scope: " << x.scope (); - - return os; - } -} diff --git a/examples/cxx/tree/custom/wildcard/wildcard-custom.hxx b/examples/cxx/tree/custom/wildcard/wildcard-custom.hxx deleted file mode 100644 index 0546d38..0000000 --- a/examples/cxx/tree/custom/wildcard/wildcard-custom.hxx +++ /dev/null @@ -1,66 +0,0 @@ -// file : examples/cxx/tree/custom/wildcard/wildcard-custom.hxx -// copyright : not copyrighted - public domain - -// Do not include this file directly, use wildcard.hxx instead. This -// file is included into generated wildcard.hxx so we do not need to -// guard against multiple inclusions. -// - -namespace wildcard -{ - class data: public data_base - { - // Standard constructors. - // - public: - data (const xml_schema::string&); - - data (const xercesc::DOMElement&, - xml_schema::flags = 0, - xml_schema::container* = 0); - - data (const data&, - xml_schema::flags = 0, - xml_schema::container* = 0); - - virtual data* - _clone (xml_schema::flags = 0, - xml_schema::container* = 0) const; - - // Our customizations. - // - public: - bool - scope_present () const - { - return scope_present_; - } - - const xml_schema::string& - scope () const - { - return scope_; - } - - void - scope (const xml_schema::string& s) - { - scope_present_ = true; - scope_ = s; - } - - private: - bool scope_present_; - xml_schema::string scope_; - }; - - // Serialization operator. - // - void - operator<< (xercesc::DOMElement&, const data&); - - // std::ostream insertion operator. - // - std::ostream& - operator<< (std::ostream&, const data&); -} diff --git a/examples/cxx/tree/custom/wildcard/wildcard.xml b/examples/cxx/tree/custom/wildcard/wildcard.xml deleted file mode 100644 index 80f215a..0000000 --- a/examples/cxx/tree/custom/wildcard/wildcard.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - -abc123 diff --git a/examples/cxx/tree/custom/wildcard/wildcard.xsd b/examples/cxx/tree/custom/wildcard/wildcard.xsd deleted file mode 100644 index 1a32b1e..0000000 --- a/examples/cxx/tree/custom/wildcard/wildcard.xsd +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/embedded/README b/examples/cxx/tree/embedded/README deleted file mode 100644 index 266a8ff..0000000 --- a/examples/cxx/tree/embedded/README +++ /dev/null @@ -1,48 +0,0 @@ -This example shows how to embed the binary representation of the schema -grammar into an application and then use it with the C++/Tree mapping to -parse and validate XML documents. This example is similar to the 'caching' -example except that it loads the binary representation of the schemas -embedded into the application instead of pre-parsing external schema files. - -The example consists of the following files: - -xsdbin.cxx - Tool for converting one or more XML Schema files to the compressed binary - representation. The output is written as a pair of C++ source files - containing the array with the binary data. Use the --help option to see - the tool's usage information. - -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 and a set of parsing - functions that convert XML instance documents to a tree-like in-memory - object model. These are generated by the XSD compiler from library.xsd. - -library-schema.hxx -library-schema.cxx - Binary representation of the library.xsd schema. These files are generated - by the xsdbin tool. - -grammar-input-stream.hxx -grammar-input-stream.cxx - Input stream implementation with the special-purpose schema grammar - decompression algorithm. It is used to load the binary schema representation - produced by the xsdbin tool. - -driver.cxx - Driver for the example. It first sets up the Xerces-C++ DOM parser and - loads the embedded binary schema grammar for validation. It then performs - ten iterations that parse the input file to a DOM document using the DOM - parser and call one of the parsing functions that constructs the object - model from this DOM document. On each iteration the driver prints a number - of books in the object model to STDERR. - -To run the example on the sample XML instance document simply execute: - -$ ./driver library.xml diff --git a/examples/cxx/tree/embedded/driver.cxx b/examples/cxx/tree/embedded/driver.cxx deleted file mode 100644 index 5ceafa4..0000000 --- a/examples/cxx/tree/embedded/driver.cxx +++ /dev/null @@ -1,183 +0,0 @@ -// file : examples/cxx/tree/embedded/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include -#include - -#include -#include // chLatin_* -#include -#include // xercesc::Grammar -#include - -#include - -#include -#include -#include -#include - -#include - -#include "library.hxx" -#include "library-schema.hxx" -#include "grammar-input-stream.hxx" - -using namespace std; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " library.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 - { - using namespace xercesc; - namespace xml = xsd::cxx::xml; - namespace tree = xsd::cxx::tree; - - // Create and load the grammar pool. - // - MemoryManager* mm (XMLPlatformUtils::fgMemoryManager); - - auto_ptr gp (new XMLGrammarPoolImpl (mm)); - - try - { - grammar_input_stream is (library_schema, sizeof (library_schema)); - gp->deserializeGrammars(&is); - } - catch(const XSerializationException& e) - { - cerr << "unable to load schema: " << - xml::transcode (e.getMessage ()) << endl; - return 1; - } - - // Lock the grammar pool. This is necessary if we plan to use the - // same grammar pool in multiple threads (this way we can reuse the - // same grammar in multiple parsers). Locking the pool disallows any - // modifications to the pool, such as an attempt by one of the threads - // to cache additional schemas. - // - gp->lockPool (); - - // Get an implementation of the Load-Store (LS) interface. - // - const XMLCh ls_id [] = {chLatin_L, chLatin_S, chNull}; - - DOMImplementation* impl ( - DOMImplementationRegistry::getDOMImplementation (ls_id)); - - xml::dom::auto_ptr parser ( - impl->createLSParser ( - DOMImplementationLS::MODE_SYNCHRONOUS, 0, mm, gp.get ())); - - 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 validation. - // - conf->setParameter (XMLUni::fgDOMValidate, true); - conf->setParameter (XMLUni::fgXercesSchema, true); - 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 - - // Use the loaded grammar during parsing. - // - conf->setParameter (XMLUni::fgXercesUseCachedGrammarInParse, true); - - // Disable loading schemas via other means (e.g., schemaLocation). - // - conf->setParameter (XMLUni::fgXercesLoadSchema, false); - - // 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); - - // Parse XML documents. - // - for (unsigned long i (0); i < 10; ++i) - { - ifstream ifs; - ifs.exceptions (ifstream::badbit | ifstream::failbit); - ifs.open (argv[1]); - - // Wrap the standard input stream. - // - xml::sax::std_input_source isrc (ifs, argv[1]); - Wrapper4InputSource wrap (&isrc, false); - - // Parse XML to DOM. - // - xml_schema::dom::auto_ptr doc (parser->parse (&wrap)); - - eh.throw_if_failed (); - - // Parse DOM to the object model. - // - auto_ptr c (library::catalog_ (*doc)); - - cerr << "catalog with " << c->book ().size () << " books" << 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/embedded/grammar-input-stream.cxx b/examples/cxx/tree/embedded/grammar-input-stream.cxx deleted file mode 100644 index f3a6d52..0000000 --- a/examples/cxx/tree/embedded/grammar-input-stream.cxx +++ /dev/null @@ -1,95 +0,0 @@ -// file : examples/cxx/tree/embedded/grammar-input-stream.cxx -// copyright : not copyrighted - public domain - -#include -#include "grammar-input-stream.hxx" - -grammar_input_stream:: -grammar_input_stream (const XMLByte* data, std::size_t size) - : data_ (data), - size_ (size), - pos_ (0), - vpos_ (0), - cseq_ (0), - add_zero_ (false) -{ -} - -XMLFilePos grammar_input_stream:: -curPos () const -{ - return static_cast (vpos_); -} - -XMLSize_t grammar_input_stream:: -readBytes (XMLByte* const buf, const XMLSize_t size) -{ - std::size_t i (0); - - // Add a zero from the alternating sequence if it didn't - // fit on the previous read. - // - if (add_zero_) - { - buf[i++] = 0; - add_zero_ = false; - } - - // If have an unfinished sequential sequence, output it now. - // - if (cseq_ != 0 && !alt_) - { - for (; cseq_ != 0 && i < size; --cseq_) - buf[i++] = 0; - } - - for (; i < size && pos_ < size_;) - { - XMLByte b = buf[i++] = data_[pos_++]; - - // See if we are in a compression sequence. - // - if (cseq_ != 0) - { - if (i < size) - buf[i++] = 0; - else - add_zero_ = true; // Add it on the next read. - - cseq_--; - continue; - } - - // If we are not in a compression sequence and this byte is - // not zero then we are done. - // - if (b != 0) - continue; - - // We have a zero. - // - assert (pos_ < size_); // There has to be another byte. - unsigned char v (static_cast (data_[pos_++])); - alt_ = (v & 128) != 0; - cseq_ = v & 127; - - // If it is a sequential sequence, output as many zeros as - // we can. - // - if (!alt_) - { - for (; cseq_ != 0 && i < size; --cseq_) - buf[i++] = 0; - } - } - - vpos_ += i; - - return static_cast (i); -} - -const XMLCh* grammar_input_stream:: -getContentType () const -{ - return 0; -} diff --git a/examples/cxx/tree/embedded/grammar-input-stream.hxx b/examples/cxx/tree/embedded/grammar-input-stream.hxx deleted file mode 100644 index ed12b7c..0000000 --- a/examples/cxx/tree/embedded/grammar-input-stream.hxx +++ /dev/null @@ -1,40 +0,0 @@ -// file : examples/cxx/tree/embedded/grammar-input-stream.hxx -// copyright : not copyrighted - public domain - -#ifndef GRAMMAR_INPUT_STREAM_HXX -#define GRAMMAR_INPUT_STREAM_HXX - -#include -#include - -// Memory buffer input stream with the special-purpose schema -// grammar decompression. -// -class grammar_input_stream: public xercesc::BinInputStream -{ -public : - grammar_input_stream (const XMLByte* data, std::size_t size); - - virtual XMLFilePos - curPos () const; - - virtual XMLSize_t - readBytes (XMLByte* const buf, const XMLSize_t size); - - virtual const XMLCh* - getContentType () const; - -private : - const XMLByte* data_; - std::size_t size_; - std::size_t pos_; - std::size_t vpos_; - - // Compression data. - // - size_t cseq_; // Number of bytes left in a compression sequence. - bool alt_; // Alternating or sequential sequence. - bool add_zero_; // Add a zero on the next read. -}; - -#endif // GRAMMAR_INPUT_STREAM_HXX diff --git a/examples/cxx/tree/embedded/library.xml b/examples/cxx/tree/embedded/library.xml deleted file mode 100644 index f57c042..0000000 --- a/examples/cxx/tree/embedded/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/embedded/library.xsd b/examples/cxx/tree/embedded/library.xsd deleted file mode 100644 index 6a9ad01..0000000 --- a/examples/cxx/tree/embedded/library.xsd +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/embedded/makefile b/examples/cxx/tree/embedded/makefile deleted file mode 100644 index 1b68643..0000000 --- a/examples/cxx/tree/embedded/makefile +++ /dev/null @@ -1,122 +0,0 @@ -# file : examples/cxx/tree/embedded/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := library.xsd -cxx := driver.cxx grammar-input-stream.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o) \ -$(xsd:.xsd=-schema.o)) -obj2 := $(out_base)/xsdbin.o -dep := $(obj:.o=.o.d) $(obj2:.o=.o.d) - -driver := $(out_base)/driver -xsdbin := $(out_base)/xsdbin -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) -$(xsdbin): $(obj2) $(xerces_c.l) - -$(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd -$(obj) $(obj2) $(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): $(out_root)/xsd/xsd - -genf += $(xsd:.xsd=-schema.hxx) $(xsd:.xsd=-schema.cxx) - -.PRECIOUS: $(out_base)/%-schema.hxx $(out_base)/%-schema.cxx -$(out_base)/%: xsdbin := $(xsdbin) -$(out_base)/%-schema.hxx $(out_base)/%-schema.cxx: $(src_base)/%.xsd $(xsdbin) - $(call message,xsdbin $<,$(xsdbin) --output-dir $(out_base) $<) - -$(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)/xsdbin.cxx,$(install_doc_dir)/xsd/$(path)/xsdbin.cxx) - $(call install-data,$(src_base)/driver.cxx,$(install_doc_dir)/xsd/$(path)/driver.cxx) - $(call install-data,$(src_base)/grammar-input-stream.hxx,$(install_doc_dir)/xsd/$(path)/grammar-input-stream.hxx) - $(call install-data,$(src_base)/grammar-input-stream.cxx,$(install_doc_dir)/xsd/$(path)/grammar-input-stream.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)/xsdbin.cxx,$(dist_prefix)/$(path)/xsdbin.cxx) - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/grammar-input-stream.hxx,$(dist_prefix)/$(path)/grammar-input-stream.hxx) - $(call install-data,$(src_base)/grammar-input-stream.cxx,$(dist_prefix)/$(path)/grammar-input-stream.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) - # Note: solution files are not automatically generated. - -# Clean. -# -$(clean): files := $(out_base)/$(xsd:.xsd=-schema.?xx) -$(clean): $(driver).o.clean $(xsdbin).o.clean \ - $(addsuffix .cxx.clean,$(obj)) \ - $(addsuffix .cxx.clean,$(obj2)) \ - $(addsuffix .cxx.clean,$(dep)) \ - $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) - $(call message,rm '$(out_base)/*-schema.?xx',rm -f $(files)) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(gen): | $(out_base)/.gitignore -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver xsdbin $(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) - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/examples/cxx/tree/embedded/xsdbin.cxx b/examples/cxx/tree/embedded/xsdbin.cxx deleted file mode 100644 index c28590f..0000000 --- a/examples/cxx/tree/embedded/xsdbin.cxx +++ /dev/null @@ -1,494 +0,0 @@ -// file : examples/cxx/tree/embedded/xsdbin.cxx -// copyright : not copyrighted - public domain - -// This program loads the XML Schema file(s) and converts them to -// the Xerces-C++ binary schema format which can then be embedded -// into C++ programs and used to validate XML documents. The output -// is written as a C++ source file containing the array with the -// binary data. -// - -#include -#include // std::auto_ptr -#include // std::size_t -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include - -using namespace std; -using namespace xercesc; - -class error_handler: public ErrorHandler -{ -public: - error_handler () - : failed_ (false) - { - } - - bool - failed () const - { - return failed_; - } - - enum severity {s_warning, s_error, s_fatal}; - - virtual void - warning (const SAXParseException&); - - virtual void - error (const SAXParseException&); - - virtual void - fatalError (const SAXParseException&); - - virtual void - resetErrors () - { - failed_ = false; - } - - void - handle (const SAXParseException&, severity); - -private: - bool failed_; -}; - -void -cxx_escape (string&); - -int -main (int argc, char* argv[]) -{ - const char* hxx_suffix = "-schema.hxx"; - const char* cxx_suffix = "-schema.cxx"; - - string name; - string base; - string outdir; - - struct usage - { - usage (bool e = true): error (e) {} - bool error; - }; - - int argi (1); - bool multi_import (true); - bool verbose (false); - - try - { - for (; argi < argc; ++argi) - { - string a (argv[argi]); - - if (a == "--help") - throw usage (false); - else if (a == "--verbose") - { - verbose = true; - } - else if (a == "--hxx-suffix") - { - if (++argi >= argc) - throw usage (); - - hxx_suffix = argv[argi]; - } - else if (a == "--cxx-suffix") - { - if (++argi >= argc) - throw usage (); - - cxx_suffix = argv[argi]; - } - else if (a == "--output-dir") - { - if (++argi >= argc) - throw usage (); - - outdir = argv[argi]; - } - else if (a == "--array-name") - { - if (++argi >= argc) - throw usage (); - - name = argv[argi]; - } - else if (a == "--disable-multi-import") - { - multi_import = false; - } - else - break; - } - - if (argi >= argc) - { - cerr << "no input file specified" << endl; - throw usage (); - } - - base = argv[argi]; - } - catch (usage const& e) - { - ostream& o (e.error ? cerr : cout); - - o << "Usage: " << argv[0] << " [options] " << endl - << "Options:" << endl - << " --help Print usage information and exit." << endl - << " --verbose Print progress information." << endl - << " --output-dir Write generated files to ." << endl - << " --hxx-suffix Header file suffix instead of '-schema.hxx'." << endl - << " --cxx-suffix Source file suffix instead of '-schema.cxx'." << endl - << " --array-name Binary data array name." << endl - << " --disable-multi-import Disable multiple import support." << endl - << endl; - - return e.error ? 0 : 1; - } - - XMLPlatformUtils::Initialize (); - - { - MemoryManager* mm (XMLPlatformUtils::fgMemoryManager); - - auto_ptr gp (new XMLGrammarPoolImpl (mm)); - - // Load the schemas into grammar pool. - // - { - auto_ptr parser ( - XMLReaderFactory::createXMLReader (mm, gp.get ())); - - parser->setFeature (XMLUni::fgSAX2CoreNameSpaces, true); - parser->setFeature (XMLUni::fgSAX2CoreNameSpacePrefixes, true); - parser->setFeature (XMLUni::fgSAX2CoreValidation, true); - parser->setFeature (XMLUni::fgXercesSchema, true); - parser->setFeature (XMLUni::fgXercesSchemaFullChecking, true); - parser->setFeature (XMLUni::fgXercesValidationErrorAsFatal, true); - - // Xerces-C++ 3.1.0 is the first version with working multi import - // support. - // -#if _XERCES_VERSION >= 30100 - parser->setFeature (XMLUni::fgXercesHandleMultipleImports, multi_import); -#endif - - error_handler eh; - parser->setErrorHandler (&eh); - - for (; argi < argc; ++argi) - { - if (verbose) - cerr << "loading " << argv[argi] << endl; - - if (!parser->loadGrammar (argv[argi], Grammar::SchemaGrammarType, true)) - { - cerr << argv[argi] << ": error: unable to load" << endl; - return 1; - } - - if (eh.failed ()) - return 1; - } - } - - // Get the binary representation. - // - BinMemOutputStream data; - - try - { - gp->serializeGrammars (&data); - } - catch (const XSerializationException& e) - { - char* msg (XMLString::transcode (e.getMessage ())); - cerr << "error: " << msg << endl; - XMLString::release (&msg); - return 1; - } - - size_t n (static_cast (data.curPos ())); - const unsigned char* buf ( - static_cast (data.getRawBuffer ())); - - if (verbose) - cerr << "uncomressed data size " << n << " bytes" << endl; - - // Compress zeros. - // - size_t cn (0); - unsigned char* cbuf = new unsigned char[n]; - - size_t cseq (0); // Number of bytes left in a compression sequence. - bool alt (false); // Alternating or sequential sequence. - - for (size_t i (0); i < n;) - { - unsigned char v (buf[i++]); - - // See if we are in a compression sequence. - // - if (cseq != 0) - { - // See if this byte needs to be copied. - // - if (alt && cseq % 2 == 0) - cbuf[cn++] = v; - - cseq--; - continue; - } - - // If we are not in a compression sequence and this byte is - // not zero then simply copy it. - // - if (v != 0) - { - cbuf[cn++] = v; - continue; - } - - // We have a zero. - // - cbuf[cn++] = 0; - - // See if we can start a new compression sequence. - // - if (i < n) - { - if (buf[i] == 0) - { - // Sequential sequence. See how far it runs. - // - alt = false; - - for (cseq = 1; cseq < 127 && cseq + i < n; cseq++) - if (buf[cseq + i] != 0) - break; - } - else if (i + 1 < n && buf[i + 1] == 0) - { - // Alternating sequence. See how far it runs. - // - alt = true; - - for (cseq = 1; cseq < 127 && cseq * 2 + i + 1 < n; cseq++) - { - if (buf[cseq * 2 + i + 1] != 0) - break; - - // For longer sequences prefer sequential to alternating. - // - if (cseq > 2 && - buf[cseq * 2 + i] == 0 && - buf[(cseq - 1) * 2 + i] == 0 && - buf[(cseq - 2) * 2 + i] == 0) - { - cseq -= 2; - break; - } - } - - cseq *= 2; - } - } - - if (cseq != 0) - { - cbuf[cn++] = static_cast ( - alt ? (128 | cseq / 2) : cseq); - } - else - cbuf[cn++] = 0; - } - - if (verbose) - cerr << "comressed data size " << cn << " bytes" << endl; - - buf = cbuf; - n = cn; - - // Figure out the file names. - // - string::size_type p (base.rfind ('/')), p1 (base.rfind ('\\')); - - if (p1 != string::npos && (p == string::npos || p1 > p)) - p = p1; - - if (p != string::npos) - base = string (base, p + 1); - - p = base.rfind ('.'); - - if (p != string::npos) - base.resize (p); - - string hxx (base + hxx_suffix); - string cxx (base + cxx_suffix); - - if (!outdir.empty ()) - { -#if defined (WIN32) || defined (__WIN32__) - hxx = outdir + '\\' + hxx; - cxx = outdir + '\\' + cxx; -#else - hxx = outdir + '/' + hxx; - cxx = outdir + '/' + cxx; -#endif - } - - if (name.empty ()) - { - name = base + "_schema"; - cxx_escape (name); - } - - // Write header. - // - { - ofstream os (hxx.c_str ()); - - if (!os.is_open ()) - { - cerr << hxx << ": error: unable to open" << endl; - return 1; - } - - os << "// Automatically generated. Do not edit." << endl - << "//" << endl - << endl - << "#include " << endl - << endl - << "extern const XMLByte " << name << "[" << n << "UL];" << endl; - } - - { - ofstream os (cxx.c_str ()); - - if (!os.is_open ()) - { - cerr << cxx << ": error: unable to open" << endl; - return 1; - } - - os << "// Automatically generated. Do not edit." << endl - << "//" << endl - << endl - << "#include " << endl - << "#include " << endl - << endl - << "#if XERCES_GRAMMAR_SERIALIZATION_LEVEL != " << - XERCES_GRAMMAR_SERIALIZATION_LEVEL << endl - << "# error incompatible Xerces-C++ version detected" << endl - << "#endif" << endl - << endl - << "extern const XMLByte " << name << "[" << n << "UL] =" << endl - << "{"; - - for (size_t i (0); i < n; ++i) - { - if (i != 0) - os << ','; - - os << (i % 12 == 0 ? "\n " : " ") << "0x"; - os.width (2); - os.fill ('0'); - os << hex << static_cast (buf[i]); - } - - os << endl - << "};" << endl - << endl; - } - - delete[] cbuf; - } - - XMLPlatformUtils::Terminate (); -} - -void -cxx_escape (string& s) -{ - for (string::size_type i (0); i < s.size (); ++i) - { - char& c (s[i]); - - if (i == 0) - { - if (!((c >= 'a' && c <= 'z') || - (c >= 'A' && c <= 'Z') || - c == '_')) - c = '_'; - } - else - { - if (!((c >= 'a' && c <= 'z') || - (c >= 'A' && c <= 'Z') || - (c >= '0' && c <= '9') || - c == '_')) - c = '_'; - } - } -} - -void error_handler:: -warning (const SAXParseException& e) -{ - handle (e, s_warning); -} - -void error_handler:: -error (const SAXParseException& e) -{ - failed_ = true; - handle (e, s_error); -} - -void error_handler:: -fatalError (const SAXParseException& e) -{ - failed_ = true; - handle (e, s_fatal); -} - -void error_handler:: -handle (const SAXParseException& e, severity s) -{ - const XMLCh* xid (e.getPublicId ()); - - if (xid == 0) - xid = e.getSystemId (); - - char* id (XMLString::transcode (xid)); - char* msg (XMLString::transcode (e.getMessage ())); - - cerr << id << ":" - << e.getLineNumber () << ":" << e.getColumnNumber () << " " - << (s == s_warning ? "warning: " : "error: ") << msg << endl; - - XMLString::release (&id); - XMLString::release (&msg); -} diff --git a/examples/cxx/tree/hello/README b/examples/cxx/tree/hello/README deleted file mode 100644 index bb98584..0000000 --- a/examples/cxx/tree/hello/README +++ /dev/null @@ -1,26 +0,0 @@ -This is a "Hello, world!" example that shows how to use the C++/Tree -mapping to access XML instance documents described by XML Schema -definitions. - -The example consists of the following files: - -hello.xsd - XML Schema which describes "hello" instance documents. - -hello.xml - Sample XML instance document. - -hello.hxx -hello.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 hello.xsd. - -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 content of the object model to STDERR. - -To run the example on the sample XML instance document simply execute: - -$ ./driver hello.xml diff --git a/examples/cxx/tree/hello/driver.cxx b/examples/cxx/tree/hello/driver.cxx deleted file mode 100644 index b6629b3..0000000 --- a/examples/cxx/tree/hello/driver.cxx +++ /dev/null @@ -1,36 +0,0 @@ -// file : examples/cxx/tree/hello/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include - -#include "hello.hxx" - -using namespace std; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " hello.xml" << endl; - return 1; - } - - try - { - auto_ptr h (hello (argv[1])); - - for (hello_t::name_const_iterator i (h->name ().begin ()); - i != h->name ().end (); - ++i) - { - cout << h->greeting () << ", " << *i << "!" << endl; - } - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/examples/cxx/tree/hello/hello.xml b/examples/cxx/tree/hello/hello.xml deleted file mode 100644 index 8b25b5b..0000000 --- a/examples/cxx/tree/hello/hello.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - Hello - - sun - moon - world - - diff --git a/examples/cxx/tree/hello/hello.xsd b/examples/cxx/tree/hello/hello.xsd deleted file mode 100644 index 8326ff0..0000000 --- a/examples/cxx/tree/hello/hello.xsd +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - The hello_t type consists of a greeting phrase and a - collection of names to which this greeting applies. - - - - - - - - - The greeting element contains the greeting phrase - for this hello object. - - - - - - - - The name elements contains names to be greeted. - - - - - - - - - - - The hello element is a root of the Hello XML vocabulary. - Every conforming document should start with this element. - - - - - diff --git a/examples/cxx/tree/hello/makefile b/examples/cxx/tree/hello/makefile deleted file mode 100644 index 57d7f49..0000000 --- a/examples/cxx/tree/hello/makefile +++ /dev/null @@ -1,100 +0,0 @@ -# file : examples/cxx/tree/hello/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := hello.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) - -$(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): $(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)/hello.xsd,$(install_doc_dir)/xsd/$(path)/hello.xsd) - $(call install-data,$(src_base)/hello.xml,$(install_doc_dir)/xsd/$(path)/hello.xml) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/hello.xsd,$(dist_prefix)/$(path)/hello.xsd) - $(call install-data,$(src_base)/hello.xml,$(dist_prefix)/$(path)/hello.xml) - -$(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/library/README b/examples/cxx/tree/library/README deleted file mode 100644 index 0b8638c..0000000 --- a/examples/cxx/tree/library/README +++ /dev/null @@ -1,32 +0,0 @@ -This example shows how to use the C++/Tree mapping to parse XML documents -into a tree-like in-memory object model, modify this object model, and -finally serialize it back to XML. - -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.ixx -library.cxx - C++ types that represent the given vocabulary, a set of parsing - functions that convert XML 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 library.xsd. - -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 content of the object model to STDERR. Finally, the driver modifies - the object model and serializes it back to XML. - -To run the example on the sample XML instance document simply execute: - -$ ./driver library.xml - -This example also shows how to use the ID/IDREF cross-referencing -mechanism and the xsd:enumeration to C++ enum mapping. diff --git a/examples/cxx/tree/library/driver.cxx b/examples/cxx/tree/library/driver.cxx deleted file mode 100644 index 5913ddf..0000000 --- a/examples/cxx/tree/library/driver.cxx +++ /dev/null @@ -1,130 +0,0 @@ -// file : examples/cxx/tree/library/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include - -#include "library.hxx" - -using std::cerr; -using std::endl; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " library.xml" << endl; - return 1; - } - - try - { - using namespace library; - - // Read in the XML file and obtain its object model. - // - std::auto_ptr c (catalog_ (argv[1])); - - - // Let's print what we've got. - // - for (catalog::book_const_iterator bi (c->book ().begin ()); - bi != c->book ().end (); - ++bi) - { - cerr << endl - << "ID : " << bi->id () << endl - << "ISBN : " << bi->isbn () << endl - << "Title : " << bi->title () << endl - << "Genre : " << bi->genre () << endl; - - for (book::author_const_iterator ai (bi->author ().begin ()); - ai != bi->author ().end (); - ++ai) - { - cerr << "Author : " << ai->name () << endl; - cerr << " Born : " << ai->born () << endl; - - if (ai->died ()) - cerr << " Died : " << *ai->died () << endl; - - if (ai->recommends ()) - cerr << " Recommends : " << (*ai->recommends ())->title () << endl; - } - - cerr << "Available : " << std::boolalpha << bi->available () << endl; - } - - - // Now we are going to modify the object model and serialize it - // back to XML. - // - - catalog::book_sequence& books (c->book ()); - - - // Get rid of all unavailable books. - // - for (catalog::book_iterator bi (books.begin ()); bi != books.end ();) - { - if (!bi->available ()) - bi = books.erase (bi); - else - ++bi; - } - - - // Insert a new book. - // - book b (679776443, // ISBN - "Dead Souls", // Title - genre::philosophy, // Genre - "DS"); // ID - - b.author ().push_back (author ("Nikolai Gogol", - xml_schema::date (1809, 3, 31))); - - books.insert (books.begin (), b); - - - // Because we removed all unavailable books, some IDREFs might be - // broken. Let's fix this. - // - for (catalog::book_iterator bi (books.begin ()); bi != books.end (); ++bi) - { - for (book::author_iterator ai (bi->author ().begin ()); - ai != bi->author ().end (); - ++ai) - { - author::recommends_optional& c (ai->recommends ()); - - if (c.present ()) - { - author::recommends_type& ref (c.get ()); - - if (!ref) - c.reset (); - } - } - } - - - // Prepare namespace mapping and schema location information. - // - xml_schema::namespace_infomap map; - - map["lib"].name = "http://www.codesynthesis.com/library"; - map["lib"].schema = "library.xsd"; - - - // Write it out. - // - catalog_ (std::cout, *c, map); - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/examples/cxx/tree/library/library.xml b/examples/cxx/tree/library/library.xml deleted file mode 100644 index ca4ca9c..0000000 --- a/examples/cxx/tree/library/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/library/library.xsd b/examples/cxx/tree/library/library.xsd deleted file mode 100644 index b183efc..0000000 --- a/examples/cxx/tree/library/library.xsd +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/library/makefile b/examples/cxx/tree/library/makefile deleted file mode 100644 index ea9bfed..0000000 --- a/examples/cxx/tree/library/makefile +++ /dev/null @@ -1,101 +0,0 @@ -# file : examples/cxx/tree/library/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) - -$(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-inline --generate-ostream \ ---generate-serialization -$(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): $(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/makefile b/examples/cxx/tree/makefile deleted file mode 100644 index acfedcd..0000000 --- a/examples/cxx/tree/makefile +++ /dev/null @@ -1,69 +0,0 @@ -# file : examples/cxx/tree/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make - -all_examples := binary caching embedded custom hello library messaging \ -mixed multiroot order performance polymorphism secure streaming wildcard \ -compression xpath - -build_examples := binary caching embedded custom hello library messaging \ -mixed multiroot order performance polymorphism secure streaming wildcard - -ifeq ($(xsd_with_zlib),y) -build_examples += compression -endif - -ifeq ($(xsd_with_xqilla),y) -build_examples += xpath -endif - -default := $(out_base)/ -install := $(out_base)/.install -dist := $(out_base)/.dist -dist-win := $(out_base)/.dist-win -clean := $(out_base)/.clean - -# Build. -# -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(build_examples))) - -# Install & Dist. -# -$(install) $(dist) $(dist-win): path := $(subst $(src_root)/,,$(src_base)) - -$(install): $(addprefix $(out_base)/,$(addsuffix /.install,$(all_examples))) - $(call install-data,$(src_base)/README,$(install_doc_dir)/xsd/$(path)/README) - -$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(all_examples))) - $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README) - -$(dist-win): export dirs := $(shell find $(src_base) -type d -exec test -f {}/driver.cxx ';' -printf '%P ') -$(dist-win): |$(out_root)/.dist-pre -$(dist-win): $(addprefix $(out_base)/,$(addsuffix /.dist-win,$(all_examples))) - $(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,tree-vc8.sln) - $(call meta-vc9sln,$(src_root)/dist/template-vc9.sln,tree-vc9.sln) - $(call meta-vc10sln,$(src_root)/dist/template-vc10.sln,tree-vc10.sln) - $(call meta-vc11sln,$(src_root)/dist/template-vc11.sln,tree-vc11.sln) - $(call meta-vc12sln,$(src_root)/dist/template-vc12.sln,tree-vc12.sln) - $(call meta-vctest,tree-vc8.sln,$(src_root)/dist/examples/test.bat,test.bat) - -# Clean. -# -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(build_examples))) - -$(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) -$(call include,$(bld_root)/meta/vctest.make) - -ifneq ($(filter $(MAKECMDGOALS),dist dist-win install),) -$(foreach e,$(all_examples),$(call import,$(src_base)/$e/makefile)) -else -$(foreach e,$(build_examples),$(call import,$(src_base)/$e/makefile)) -endif diff --git a/examples/cxx/tree/messaging/README b/examples/cxx/tree/messaging/README deleted file mode 100644 index 435a4cf..0000000 --- a/examples/cxx/tree/messaging/README +++ /dev/null @@ -1,58 +0,0 @@ -This example shows how to handle XML vocabularies with multiple -root elements using the element type and element map features -of the C++/Tree mapping. The main purpose of element types is -to distinguish object models with the same root type but with -different root elements. The element map allows uniform parsing -and serialization of multiple root elements. - -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. Note that some request - and response elements are of the same type. - -balance.xml -withdraw.xml -deposit.xml - Sample XML instances for the protocol requests. - -protocol.hxx -protocol.cxx - C++ types that represent the given vocabulary. These are - generated by the XSD compiler from protocol.xsd. Generation of - element types instead of parsing and serialization functions is - requested with the --generate-element-type option. Generation of - the element map is requested with the --generate-element-map - option. - -dom-parse.hxx -dom-parse.cxx - Definition and implementation of the parse() function that - parses an XML document to a DOM document. - -dom-serialize.hxx -dom-serialize.cxx - Definition and implementation of the serialize() function that - serializes a DOM document to XML. - -driver.cxx - Driver for the example. It first calls the above-mentioned parse() - function to parse the input file to a DOM document. It then calls - the parse() function on the element map to parse the root document - element to the object model. The object model is returned as a - pointer to xml_schema::element_type which is a common base type for - all element types. The driver then determines which request it has - received either using RTTI or by comparing the root element names. - Once the request type is determined, information about it is printed - to STDERR and the corresponding response is created. Finally, the - driver serializes the opaque response object to a DOM document - using the element map and then serializes this DOM document to - STDOUT using the above-mentioned serialize() function. - -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/messaging/balance.xml b/examples/cxx/tree/messaging/balance.xml deleted file mode 100644 index 83b9692..0000000 --- a/examples/cxx/tree/messaging/balance.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - 123456789 - - diff --git a/examples/cxx/tree/messaging/deposit.xml b/examples/cxx/tree/messaging/deposit.xml deleted file mode 100644 index c59153d..0000000 --- a/examples/cxx/tree/messaging/deposit.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - 123456789 - 1000000 - - diff --git a/examples/cxx/tree/messaging/dom-parse.cxx b/examples/cxx/tree/messaging/dom-parse.cxx deleted file mode 100644 index 61f9f4a..0000000 --- a/examples/cxx/tree/messaging/dom-parse.cxx +++ /dev/null @@ -1,93 +0,0 @@ -// file : examples/cxx/tree/messaging/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/messaging/dom-parse.hxx b/examples/cxx/tree/messaging/dom-parse.hxx deleted file mode 100644 index 6eccacd..0000000 --- a/examples/cxx/tree/messaging/dom-parse.hxx +++ /dev/null @@ -1,22 +0,0 @@ -// file : examples/cxx/tree/messaging/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/messaging/dom-serialize.cxx b/examples/cxx/tree/messaging/dom-serialize.cxx deleted file mode 100644 index dbf3370..0000000 --- a/examples/cxx/tree/messaging/dom-serialize.cxx +++ /dev/null @@ -1,64 +0,0 @@ -// file : examples/cxx/tree/messaging/dom-serialize.cxx -// copyright : not copyrighted - public domain - -#include "dom-serialize.hxx" - -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include - -using namespace xercesc; -namespace xml = xsd::cxx::xml; -namespace tree = xsd::cxx::tree; - -void -serialize (std::ostream& os, - const xercesc::DOMDocument& doc, - const std::string& encoding) -{ - const XMLCh ls_id [] = {chLatin_L, chLatin_S, chNull}; - - // Get an implementation of the Load-Store (LS) interface. - // - DOMImplementation* impl ( - DOMImplementationRegistry::getDOMImplementation (ls_id)); - - tree::error_handler eh; - xml::dom::bits::error_handler_proxy ehp (eh); - - xml::dom::ostream_format_target oft (os); - - // Create a DOMSerializer. - // - xml::dom::auto_ptr writer ( - impl->createLSSerializer ()); - - DOMConfiguration* conf (writer->getDomConfig ()); - - // Set error handler. - // - conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp); - - // Set some generally nice features. - // - conf->setParameter (XMLUni::fgDOMWRTDiscardDefaultContent, true); - conf->setParameter (XMLUni::fgDOMWRTFormatPrettyPrint, true); - conf->setParameter (XMLUni::fgDOMWRTXercesPrettyPrint, false); - - xml::dom::auto_ptr out (impl->createLSOutput ()); - out->setEncoding (xml::string (encoding).c_str ()); - out->setByteStream (&oft); - - writer->write (&doc, out.get ()); - - eh.throw_if_failed > (); -} diff --git a/examples/cxx/tree/messaging/dom-serialize.hxx b/examples/cxx/tree/messaging/dom-serialize.hxx deleted file mode 100644 index f80e22b..0000000 --- a/examples/cxx/tree/messaging/dom-serialize.hxx +++ /dev/null @@ -1,20 +0,0 @@ -// file : examples/cxx/tree/messaging/dom-serialize.hxx -// copyright : not copyrighted - public domain - -#ifndef DOM_SERIALIZE -#define DOM_SERIALIZE - -#include -#include - -#include - -// Serialize a DOM document to XML which is written to the standard -// output stream. -// -void -serialize (std::ostream& os, - const xercesc::DOMDocument& doc, - const std::string& encoding = "UTF-8"); - -#endif // DOM_SERIALIZE diff --git a/examples/cxx/tree/messaging/driver.cxx b/examples/cxx/tree/messaging/driver.cxx deleted file mode 100644 index 095e2cd..0000000 --- a/examples/cxx/tree/messaging/driver.cxx +++ /dev/null @@ -1,144 +0,0 @@ -// file : examples/cxx/tree/messaging/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include -#include -#include -#include - -#include -#include - -#include - -#include "dom-parse.hxx" -#include "dom-serialize.hxx" - -#include "protocol.hxx" - -using namespace std; -using namespace protocol; -using namespace xercesc; - -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. - // - XMLPlatformUtils::Initialize (); - - try - { - ifstream ifs; - ifs.exceptions (ifstream::badbit | ifstream::failbit); - ifs.open (argv[1]); - - auto_ptr req, res; - - // Parse the XML request to a DOM document using the parse() - // function from dom-parse.hxx. - // - { - xml_schema::dom::auto_ptr doc (parse (ifs, argv[1], true)); - DOMElement& root (*doc->getDocumentElement ()); - - req = xml_schema::element_map::parse (root); - } - - // We can test which request we've got either using RTTI or by - // comparing the element names, as shown below. - // - if (balance* b = dynamic_cast (req.get ())) - { - account_t& a (b->value ()); - - cerr << "balance request for acc# " << a.account () << endl; - - res.reset (new success (balance_t (a.account (), 1000))); - } - else if (req->_name () == withdraw::name ()) - { - withdraw& w (static_cast (*req)); - change_t& c (w.value ()); - - wcerr << "withdrawal request for acc# " << c.account () << ", " - << "amount: " << c.amount () << endl; - - if (c.amount () > 1000) - res.reset (new insufficient_funds (balance_t (c.account (), 1000))); - else - res.reset (new success (balance_t (c.account (), 1000 - c.amount ()))); - - } - else if (req->_name () == deposit::name ()) - { - deposit& d (static_cast (*req)); - change_t& c (d.value ()); - - wcerr << "deposit request for acc# " << c.account () << ", " - << "amount: " << c.amount () << endl; - - res.reset (new success (balance_t (c.account (), 1000 + c.amount ()))); - } - - // Serialize the response to a DOM document. - // - namespace xml = xsd::cxx::xml; - - const XMLCh ls_id [] = {chLatin_L, chLatin_S, chNull}; - - DOMImplementation* impl ( - DOMImplementationRegistry::getDOMImplementation (ls_id)); - - const string& name (res->_name ()); - const string& ns (res->_namespace ()); - - xml_schema::dom::auto_ptr doc ( - impl->createDocument ( - xml::string (ns).c_str (), - xml::string ("p:" + name).c_str (), - 0)); - - xml_schema::element_map::serialize (*doc->getDocumentElement (), *res); - - // Serialize the DOM document to XML using the serialize() function - // from dom-serialize.hxx. - // - cout << "response:" << endl - << endl; - - serialize (cout, *doc); - } - catch (const xml_schema::no_element_info& e) - { - // This exception indicates that we tried to parse or serialize - // an unknown element. - // - cerr << "unknown request: " << e.element_namespace () << "#" << - e.element_name () << endl; - r = 1; - } - 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; - } - - XMLPlatformUtils::Terminate (); - return r; -} diff --git a/examples/cxx/tree/messaging/makefile b/examples/cxx/tree/messaging/makefile deleted file mode 100644 index 3b7deae..0000000 --- a/examples/cxx/tree/messaging/makefile +++ /dev/null @@ -1,116 +0,0 @@ -# file : examples/cxx/tree/messaging/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 dom-serialize.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 --generate-element-type \ ---generate-element-map --generate-serialization - -$(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) - $(call install-data,$(src_base)/dom-serialize.hxx,$(install_doc_dir)/xsd/$(path)/dom-serialize.hxx) - $(call install-data,$(src_base)/dom-serialize.cxx,$(install_doc_dir)/xsd/$(path)/dom-serialize.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) - $(call install-data,$(src_base)/dom-serialize.hxx,$(dist_prefix)/$(path)/dom-serialize.hxx) - $(call install-data,$(src_base)/dom-serialize.cxx,$(dist_prefix)/$(path)/dom-serialize.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/messaging/protocol.xsd b/examples/cxx/tree/messaging/protocol.xsd deleted file mode 100644 index b371ba7..0000000 --- a/examples/cxx/tree/messaging/protocol.xsd +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/messaging/withdraw.xml b/examples/cxx/tree/messaging/withdraw.xml deleted file mode 100644 index 1f309f3..0000000 --- a/examples/cxx/tree/messaging/withdraw.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - 123456789 - 1000000 - - diff --git a/examples/cxx/tree/mixed/README b/examples/cxx/tree/mixed/README deleted file mode 100644 index fc23faa..0000000 --- a/examples/cxx/tree/mixed/README +++ /dev/null @@ -1,45 +0,0 @@ -This example shows how to access the underlying DOM nodes in the -C++/Tree mapping in order to handle raw, "type-less content" such -as mixed content models, anyType/anySimpleType, and any/anyAttribute. - -For an alternative (and recommended) approach that employs ordered -types see the order/mixed example. - -For an alternative approach that employes type customization see -examples in the custom/ directory, in particular, custom/mixed and -custom/wildcard. - -In this example we use mixed content model to describe text with -embedded links, e.g., - - This paragraph talks about time. - -The example transforms such text into plain text with references, e.g., - - This paragraph talks about time[0]. - - [0] uri - -The example consists of the following files: - -text.xsd - XML Schema which describes "text with links" instance documents. - -text.xml - Sample XML instance document. - -text.hxx -text.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 text.xsd. - -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 uses - both the underlying DOM and statically-typed mapping to perform the - transformation. - -To run the example on the sample XML instance document simply execute: - -$ ./driver text.xml diff --git a/examples/cxx/tree/mixed/driver.cxx b/examples/cxx/tree/mixed/driver.cxx deleted file mode 100644 index 17c3b55..0000000 --- a/examples/cxx/tree/mixed/driver.cxx +++ /dev/null @@ -1,122 +0,0 @@ -// file : examples/cxx/tree/mixed/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include - -#include - -#include "text.hxx" - -// The following transcode() utility function is handy when working with -// Xerces. Include it after the generated header in order to get only char -// or wchar_t version depending on how you compiled your schemas. -// -#include - -using std::cout; -using std::cerr; -using std::endl; -using std::auto_ptr; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " text.xml" << endl; - return 1; - } - - using namespace xercesc; - - int r (0); - - // The Xerces-C++ DOM objects that will be associated with the - // document tree "out-live" the call to the parsing function. - // Therefore we need to initialize the Xerces-C++ runtime - // ourselves. - // - XMLPlatformUtils::Initialize (); - - try - { - auto_ptr t ( - text_ (argv[1], - xml_schema::flags::keep_dom | - xml_schema::flags::dont_initialize)); - - // The DOM association can be recreated in a copy (the underlying - // DOM document is cloned) if explicitly requested with the keep_dom - // flag and only if this copy is "complete", i.e., made from the root - // of the tree. - // - text copy (*t, xml_schema::flags::keep_dom); - - // Print text. - // - { - namespace xml = xsd::cxx::xml; - - unsigned long ref (0); - DOMNode* root (copy._node ()); - - for (DOMNode* n (root->getFirstChild ()); - n != 0; - n = n->getNextSibling ()) - { - switch (n->getNodeType ()) - { - case DOMNode::TEXT_NODE: - { - cout << xml::transcode (n->getTextContent ()); - break; - } - case DOMNode::ELEMENT_NODE: - { - // Let's get back to a tree node from this DOM node. - // - xml_schema::type& t ( - *reinterpret_cast ( - n->getUserData (xml_schema::dom::tree_node_key))); - - anchor& a (dynamic_cast (t)); - - cout << a << "[" << ref << "]"; - - // Or we could continue using DOM interface: - // - //cout << xml::transcode (n->getTextContent ()) - // << "[" << ref << "]"; - - ++ref; - break; - } - default: - break; // Ignore all other nodes (e.g., comments, etc). - } - } - } - - // Print references. - // - { - unsigned long r (0); - - for (text::a_const_iterator i (copy.a ().begin ()); - i != copy.a ().end (); - ++i, ++r) - { - cout << "[" << r << "] " << i->href () << endl; - } - } - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - r = 1; - } - - XMLPlatformUtils::Terminate (); - return r; -} diff --git a/examples/cxx/tree/mixed/makefile b/examples/cxx/tree/mixed/makefile deleted file mode 100644 index 831dd03..0000000 --- a/examples/cxx/tree/mixed/makefile +++ /dev/null @@ -1,101 +0,0 @@ -# file : examples/cxx/tree/mixed/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := text.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) - -$(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): $(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)/text.xsd,$(install_doc_dir)/xsd/$(path)/text.xsd) - $(call install-data,$(src_base)/text.xml,$(install_doc_dir)/xsd/$(path)/text.xml) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/text.xsd,$(dist_prefix)/$(path)/text.xsd) - $(call install-data,$(src_base)/text.xml,$(dist_prefix)/$(path)/text.xml) - -$(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/mixed/text.xml b/examples/cxx/tree/mixed/text.xml deleted file mode 100644 index 21e32af..0000000 --- a/examples/cxx/tree/mixed/text.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - -The first paragraph of this text talks about time. - -And this paragraph talks about space. - - diff --git a/examples/cxx/tree/mixed/text.xsd b/examples/cxx/tree/mixed/text.xsd deleted file mode 100644 index 9777f8a..0000000 --- a/examples/cxx/tree/mixed/text.xsd +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - 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 - - diff --git a/examples/cxx/tree/order/README b/examples/cxx/tree/order/README deleted file mode 100644 index 7125a2d..0000000 --- a/examples/cxx/tree/order/README +++ /dev/null @@ -1,11 +0,0 @@ -This directory contains a number of examples that show how to use ordered -types to capture and maintain content order. The following list gives an -overview of each example: - -element - Shows how to use ordered types to capture and maintain element order, - including element wildcards. - -mixed - Shows how to use ordered types to capture mixed content text and to - maintain order information between elements and text. diff --git a/examples/cxx/tree/order/element/README b/examples/cxx/tree/order/element/README deleted file mode 100644 index 19f2381..0000000 --- a/examples/cxx/tree/order/element/README +++ /dev/null @@ -1,35 +0,0 @@ -This example shows how to use ordered types to capture and maintain -element order, including element wildcards. - -The example consists of the following files: - -transactions.xsd - XML Schema which describes various bank transactions. A batch of - transactions can contain any number of different transactions in - any order but the order of transaction in the batch is significant. - -library.xml - Sample XML instance document. - -transactions.hxx -transactions.cxx - C++ types that represent the given vocabulary as well as a set of - parsing and serialization functions. These are generated by XSD - from transactions.xsd. Note that the --ordered-type option is - used to indicate to the XSD compiler that the batch type is - ordered. We also use the --generate-wildcard option to enable - wildcard support. An element wildcard is used in the batch to - allow transaction extensions. - -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 - iterates over transactions in the batch using the content order - sequence. The driver then performs various modifications of the - object model while showing how to maintain the content order. - Finally, it saves the modified transaction batch back to XML to - verify that the content order is preserved in the output document. - -To run the example on the sample XML instance document simply execute: - -$ ./driver transactions.xml diff --git a/examples/cxx/tree/order/element/driver.cxx b/examples/cxx/tree/order/element/driver.cxx deleted file mode 100644 index 0ea6d6f..0000000 --- a/examples/cxx/tree/order/element/driver.cxx +++ /dev/null @@ -1,147 +0,0 @@ -// file : examples/cxx/tree/order/element/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include "transactions.hxx" - -// The following string class keeps us sane when working with Xerces. -// Include it after the generated header in order to get only char or -// wchar_t version depending on how you compiled your schemas. -// -#include - -using std::cerr; -using std::endl; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " transactions.xml" << endl; - return 1; - } - - using namespace xercesc; - - int r (0); - - // The Xerces-C++ DOM objects that will be used to store the - // content matched by the wildcard "out-lives" the call to the - // parsing function. Therefore we need to initialize the - // Xerces-C++ runtime ourselves. - // - XMLPlatformUtils::Initialize (); - - try - { - using namespace transactions; - - // Parse the batch. - // - std::auto_ptr b ( - batch_ (argv[1], xml_schema::flags::dont_initialize)); - - // Print what we've got in content order. - // - for (batch::content_order_const_iterator i (b->content_order ().begin ()); - i != b->content_order ().end (); - ++i) - { - switch (i->id) - { - case batch::balance_id: - { - const balance& t (b->balance ()[i->index]); - cerr << t.account () << " balance" << endl; - break; - } - case batch::withdraw_id: - { - const withdraw& t (b->withdraw ()[i->index]); - cerr << t.account () << " withdraw " << t.amount () << endl; - break; - } - case batch::deposit_id: - { - const deposit& t (b->deposit ()[i->index]); - cerr << t.account () << " deposit " << t.amount () << endl; - break; - } - case batch::any_id: - { - namespace xml = xsd::cxx::xml; - - const DOMElement& e (b->any ()[i->index]); - cerr << xml::transcode (e.getLocalName ()) << endl; - break; - } - default: - { - assert (false); // Unknown content id. - } - } - } - - cerr << endl; - - // Modify the transaction batch. First remove the last transaction. - // Note that we have to update both the content itself and content - // order sequences. - // - batch::content_order_sequence& co (b->content_order ()); - - co.pop_back (); - b->withdraw ().pop_back (); - - // Now add a few more transactions. Again we have to add both the - // content and its ordering. The order information consists of the - // content id and, in case of a sequence, the index. - // - b->deposit ().push_back (deposit (123456789, 100000)); - co.push_back ( - batch::content_order_type ( - batch::deposit_id, b->deposit ().size () - 1)); - - // The next transaction we add at the beginning of the batch. - // - b->balance ().push_back (balance (123456789)); - co.insert (co.begin (), - batch::content_order_type ( - batch::balance_id, b->balance ().size () - 1)); - - // Note also that when we merely modify the content of one - // of the elements in place, we don't need to update its - // order. For example: - // - b->deposit ()[0].amount (2000000); - - // Serialize the modified transaction batch back to XML. - // - xml_schema::namespace_infomap map; - - map[""].name = "http://www.codesynthesis.com/transactions"; - map[""].schema = "transactions.xsd"; - map["te"].name = "http://www.codesynthesis.com/transactions-extras"; - - batch_ (std::cout, - *b, - map, - "UTF-8", - xml_schema::flags::dont_initialize); - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - r = 1; - } - - XMLPlatformUtils::Terminate (); - return r; -} diff --git a/examples/cxx/tree/order/element/makefile b/examples/cxx/tree/order/element/makefile deleted file mode 100644 index 8116787..0000000 --- a/examples/cxx/tree/order/element/makefile +++ /dev/null @@ -1,99 +0,0 @@ -# file : examples/cxx/tree/order/element/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := transactions.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-serialization --generate-wildcard \ ---ordered-type batch -$(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)/transactions.xsd,$(install_doc_dir)/xsd/$(path)/transactions.xsd) - $(call install-data,$(src_base)/transactions.xml,$(install_doc_dir)/xsd/$(path)/transactions.xml) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/transactions.xsd,$(dist_prefix)/$(path)/transactions.xsd) - $(call install-data,$(src_base)/transactions.xml,$(dist_prefix)/$(path)/transactions.xml) - -$(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/order/element/transactions.xml b/examples/cxx/tree/order/element/transactions.xml deleted file mode 100644 index 4c317c2..0000000 --- a/examples/cxx/tree/order/element/transactions.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - 123456789 - 1000000 - - - - 123456789 - - - - 123456789 - 500000 - - - - 123456789 - 500000 - - diff --git a/examples/cxx/tree/order/element/transactions.xsd b/examples/cxx/tree/order/element/transactions.xsd deleted file mode 100644 index 053aac4..0000000 --- a/examples/cxx/tree/order/element/transactions.xsd +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/order/makefile b/examples/cxx/tree/order/makefile deleted file mode 100644 index c807937..0000000 --- a/examples/cxx/tree/order/makefile +++ /dev/null @@ -1,43 +0,0 @@ -# file : examples/cxx/tree/order/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -all_examples := element mixed -build_examples := element mixed - -default := $(out_base)/ -install := $(out_base)/.install -dist := $(out_base)/.dist -dist-win := $(out_base)/.dist-win -clean := $(out_base)/.clean - -# Build. -# -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(build_examples))) - -# Install & Dist. -# -$(install) $(dist) $(dist-win): path := $(subst $(src_root)/,,$(src_base)) - -$(install): $(addprefix $(out_base)/,$(addsuffix /.install,$(all_examples))) - $(call install-data,$(src_base)/README,$(install_doc_dir)/xsd/$(path)/README) - -$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(all_examples))) - $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README) - -$(dist-win): $(addprefix $(out_base)/,$(addsuffix /.dist-win,$(all_examples))) - $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README.txt) - $(call message,,todos $(dist_prefix)/$(path)/README.txt) - -# Clean. -# -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(build_examples))) - -$(call include,$(bld_root)/install.make) - -ifneq ($(filter $(MAKECMDGOALS),dist dist-win install),) -$(foreach e,$(all_examples),$(call import,$(src_base)/$e/makefile)) -else -$(foreach e,$(build_examples),$(call import,$(src_base)/$e/makefile)) -endif diff --git a/examples/cxx/tree/order/mixed/README b/examples/cxx/tree/order/mixed/README deleted file mode 100644 index e66c1ad..0000000 --- a/examples/cxx/tree/order/mixed/README +++ /dev/null @@ -1,45 +0,0 @@ -This example shows how to use ordered types to capture mixed content -text and to maintain order information between elements and text. - -In this example we use mixed content model to describe text with -embedded links in the form: - - This paragraph talks about time. - -The example transforms such text into plain text with references in -the form: - - This paragraph talks about time[uri]. - -It also saves the modified text back to XML in order to verify the -element and text order. - -The example consists of the following files: - -text.xsd - XML Schema which describes "text with links" instance documents. - -text.xml - Sample XML instance document. - -text.hxx -text.cxx - C++ types that represent the given vocabulary as well as a set of - parsing and serialization functions. These are generated by XSD - from text.xsd. Note that the --ordered-type-mixed option is used - to indicate to the XSD compiler that all types with mixed content - should be automatically treated as ordered. - -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 - iterates over the text and elements in the content order to convert - the document to its plain text representation. The driver then adds - another paragraph of text and a link to the object model while showing - how to maintain the content order. Finally, it saves the modified - text back to XML to verify that the content order is preserved in - the output document. - -To run the example on the sample XML instance document simply execute: - -$ ./driver text.xml diff --git a/examples/cxx/tree/order/mixed/driver.cxx b/examples/cxx/tree/order/mixed/driver.cxx deleted file mode 100644 index 9606b67..0000000 --- a/examples/cxx/tree/order/mixed/driver.cxx +++ /dev/null @@ -1,89 +0,0 @@ -// file : examples/cxx/tree/order/mixed/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include -#include - -#include "text.hxx" - -using std::cerr; -using std::endl; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " text.xml" << endl; - return 1; - } - - try - { - std::auto_ptr t (text_ (argv[1])); - - // Print what we've got in content order. - // - for (text::content_order_const_iterator i (t->content_order ().begin ()); - i != t->content_order ().end (); - ++i) - { - switch (i->id) - { - case text::a_id: - { - const anchor& a (t->a ()[i->index]); - cerr << a << "[" << a.href () << "]"; - break; - } - case text::text_content_id: - { - const xml_schema::string& s (t->text_content ()[i->index]); - cerr << s; - break; - } - default: - { - assert (false); // Unknown content id. - } - } - } - - cerr << endl; - - // Modify the document. Note that we have to update both the content - // itself and content order sequences. - // - typedef text::content_order_type order_type; - - text::content_order_sequence& co (t->content_order ()); - text::text_content_sequence& tc (t->text_content ()); - - tc.push_back ("The last paragraph doesn't talk about "); - co.push_back (order_type (text::text_content_id, tc.size () - 1)); - - t->a ().push_back (anchor ("anything", "http://en.wikipedia.org")); - co.push_back (order_type (text::a_id, t->a ().size () - 1)); - - tc.push_back (" in particular.\n\n"); - co.push_back (order_type (text::text_content_id, tc.size () - 1)); - - // Serialize the modified document back to XML. - // - xml_schema::namespace_infomap map; - - map[""].schema = "text.xsd"; - - text_ (std::cout, - *t, - map, - "UTF-8", - xml_schema::flags::dont_pretty_print); - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/examples/cxx/tree/order/mixed/makefile b/examples/cxx/tree/order/mixed/makefile deleted file mode 100644 index 26e2783..0000000 --- a/examples/cxx/tree/order/mixed/makefile +++ /dev/null @@ -1,98 +0,0 @@ -# file : examples/cxx/tree/order/mixed/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := text.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-serialization --ordered-type-mixed -$(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)/text.xsd,$(install_doc_dir)/xsd/$(path)/text.xsd) - $(call install-data,$(src_base)/text.xml,$(install_doc_dir)/xsd/$(path)/text.xml) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/text.xsd,$(dist_prefix)/$(path)/text.xsd) - $(call install-data,$(src_base)/text.xml,$(dist_prefix)/$(path)/text.xml) - -$(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/order/mixed/text.xml b/examples/cxx/tree/order/mixed/text.xml deleted file mode 100644 index ac80159..0000000 --- a/examples/cxx/tree/order/mixed/text.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - -The first paragraph of this text talks about time. - -And this paragraph talks about space. - - diff --git a/examples/cxx/tree/order/mixed/text.xsd b/examples/cxx/tree/order/mixed/text.xsd deleted file mode 100644 index e45abcd..0000000 --- a/examples/cxx/tree/order/mixed/text.xsd +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/performance/README b/examples/cxx/tree/performance/README deleted file mode 100644 index cb79cc2..0000000 --- a/examples/cxx/tree/performance/README +++ /dev/null @@ -1,58 +0,0 @@ -This example measures the performance of parsing and serialization in -the C++/Tree mapping. It also shows how to structure your code to -achieve the maximum performance for these two operations. - -The example consists of the following files: - -test.xsd - XML Schema which describes the test vocabulary. - -test-50k.xml - Test XML document. - -gen.cxx - Program to generate a test document of desired size. - -time.hxx -time.cxx - Class definition that represents time. - -test.hxx -test.ixx -test.cxx - C++ types that represent the given vocabulary, a set of parsing - functions that convert XML 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 the XSD compiler from - test.xsd. - -parsing.cxx - Parsing performance test. It first reads the entire document into - a memory buffer. It then creates a DOM parser and pre-parses and - caches the schema if validation is enabled. Finally, it runs the - performance measurement loop which on each iteration parses the - XML document from the in-memory buffer into DOM and then DOM to - the object model. - -serialization.cxx - Serialization performance test. It first parses the XML document - into the object model. It then creates a memory buffer into which - the document is serialized and a DOM serializer. Finally, it runs - the performance measurement loop which on each iteration serializes - the object model to DOM and DOM to XML. - -driver.cxx - Driver for the example. It first parses the command line arguments. - It then initializes the Xerces-C++ runtime and calls the parsing - and serialization tests described above. - -To run the example on a test XML document simply execute: - -$ ./driver test-50k.xml - -The -v option can be used to turn on validation in the underlying XML -parser (off by default). The -i option can be used to specify the -number of parsing and serialization iterations (1000 by default). For -example: - -$ ./driver -v -i 100 test-50k.xml diff --git a/examples/cxx/tree/performance/driver.cxx b/examples/cxx/tree/performance/driver.cxx deleted file mode 100644 index b626e4d..0000000 --- a/examples/cxx/tree/performance/driver.cxx +++ /dev/null @@ -1,90 +0,0 @@ -// file : examples/cxx/tree/performance/driver.cxx -// copyright : not copyrighted - public domain - -#include -#include -#include - -#include - -using namespace std; - -// See parsing.cxx -// -bool -parsing (const char* file, unsigned long iter, bool validate); - -// See serialization.cxx -// -bool -serialization (const char* file, unsigned long iter); - -int -main (int argc, char* argv[]) -{ - if (argc < 2) - { - cerr << "usage: " << argv[0] << " [-v] [-i ] test.xml" << endl - << "\t -v turn on validation (default is off)" << endl - << "\t -i number of iterations to perform (default is 1000)" << endl; - return 1; - } - - bool validate (false); - unsigned long iter (1000); - const char* file (0); - - // Parse command line arguments. - // - for (int i (1); i < argc; ++i) - { - std::string arg (argv[i]); - - if (arg == "-v") - { - validate = true; - } - else if (arg == "-i") - { - if (++i == argc) - { - cerr << "argument expected for the -i option" << endl; - return 1; - } - - iter = 0; - istringstream is (argv[i]); - is >> iter; - - if (iter == 0) - { - cerr << "invalid argument for the -i option" << endl; - return 1; - } - } - else - { - file = argv[i]; - break; - } - } - - if (file == 0) - { - cerr << "no input file specified" << endl; - return 1; - } - - int r (0); - - xercesc::XMLPlatformUtils::Initialize (); - - // Call parsing and serialization tests. - // - if (!parsing (file, iter, validate) || !serialization (file, iter)) - r = 1; - - xercesc::XMLPlatformUtils::Terminate (); - - return r; -} diff --git a/examples/cxx/tree/performance/gen.cxx b/examples/cxx/tree/performance/gen.cxx deleted file mode 100644 index b6392c0..0000000 --- a/examples/cxx/tree/performance/gen.cxx +++ /dev/null @@ -1,76 +0,0 @@ -#include -#include -#include - -using namespace std; - -static const char* enums[] = -{ - "romance", - "fiction", - "horror", - "history", - "philosophy" -}; - -int -main (int argc, char* argv[]) -{ - if (argc != 3) - { - cerr << "usage: " << argv[0] << " " << endl; - return 1; - } - - unsigned long n (0); - istringstream is (argv[1]); - is >> n; - - if (n == 0) - { - cerr << "record count argument should be a positive number" << endl; - return 1; - } - - ofstream ofs (argv[2]); - - if (!ofs.is_open ()) - { - cerr << "unable to open '" << argv[2] << "' in write mode" << endl; - return 1; - } - - ofs << ""; - - unsigned short ch (1), en (0); - - for (unsigned long i (0); i < n; ++i) - { - ofs << "" - << "42" - << "42345.4232" - << "name123_45"; - - if (i % 2 == 1) - ofs << "one two three"; - - ofs << "" << ch << " choice" - << "" << enums[en] << "" - << ""; - - if (++ch > 4) - ch = 1; - - if (++en > 4) - en = 0; - } - - ofs << ""; -} diff --git a/examples/cxx/tree/performance/makefile b/examples/cxx/tree/performance/makefile deleted file mode 100644 index d5201e8..0000000 --- a/examples/cxx/tree/performance/makefile +++ /dev/null @@ -1,110 +0,0 @@ -# file : examples/cxx/tree/performance/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx parsing.cxx serialization.cxx time.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 += --generate-inline --generate-serialization -$(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)/parsing.cxx,$(install_doc_dir)/xsd/$(path)/parsing.cxx) - $(call install-data,$(src_base)/serialization.cxx,$(install_doc_dir)/xsd/$(path)/serialization.cxx) - $(call install-data,$(src_base)/test.xsd,$(install_doc_dir)/xsd/$(path)/test.xsd) - $(call install-data,$(src_base)/test-50k.xml,$(install_doc_dir)/xsd/$(path)/test-50k.xml) - $(call install-data,$(src_base)/time.hxx,$(install_doc_dir)/xsd/$(path)/time.hxx) - $(call install-data,$(src_base)/time.cxx,$(install_doc_dir)/xsd/$(path)/time.cxx) - $(call install-data,$(src_base)/gen.cxx,$(install_doc_dir)/xsd/$(path)/gen.cxx) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/parsing.cxx,$(dist_prefix)/$(path)/parsing.cxx) - $(call install-data,$(src_base)/serialization.cxx,$(dist_prefix)/$(path)/serialization.cxx) - $(call install-data,$(src_base)/test.xsd,$(dist_prefix)/$(path)/test.xsd) - $(call install-data,$(src_base)/test-50k.xml,$(dist_prefix)/$(path)/test-50k.xml) - $(call install-data,$(src_base)/time.hxx,$(dist_prefix)/$(path)/time.hxx) - $(call install-data,$(src_base)/time.cxx,$(dist_prefix)/$(path)/time.cxx) - $(call install-data,$(src_base)/gen.cxx,$(dist_prefix)/$(path)/gen.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/performance/parsing.cxx b/examples/cxx/tree/performance/parsing.cxx deleted file mode 100644 index bf7f667..0000000 --- a/examples/cxx/tree/performance/parsing.cxx +++ /dev/null @@ -1,172 +0,0 @@ -// file : examples/cxx/tree/performance/parsing.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include // std::size_t -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include - -#include - -#include -#include - -#include "time.hxx" -#include "test.hxx" - -using namespace std; - -bool -parsing (const char* file, unsigned long iter, bool validate) -{ - try - { - cerr << "parsing:" << endl; - - ifstream ifs; - ifs.exceptions (ios_base::failbit); - ifs.open (file, ios::in | ios::ate); - - size_t size (ifs.tellg ()); - ifs.seekg (0, ios::beg); - - char* buf = new char[size]; - ifs.read (buf, size); - ifs.close (); - - cerr << " document size: " << size << " bytes" << endl - << " iterations: " << iter << endl; - - // Create XML parser that we are going to use in all iterations. - // - using namespace xercesc; - - const XMLCh ls_id[] = - {xercesc::chLatin_L, xercesc::chLatin_S, xercesc::chNull}; - - DOMImplementation* impl ( - DOMImplementationRegistry::getDOMImplementation (ls_id)); - - // Use the error handler implementation provided by the XSD runtime. - // - xsd::cxx::tree::error_handler eh; - xsd::cxx::xml::dom::bits::error_handler_proxy ehp (eh); - - xml_schema::dom::auto_ptr parser ( - impl->createLSParser (DOMImplementationLS::MODE_SYNCHRONOUS, 0)); - - DOMConfiguration* conf (parser->getDomConfig ()); - - conf->setParameter (XMLUni::fgDOMComments, false); - conf->setParameter (XMLUni::fgDOMDatatypeNormalization, true); - conf->setParameter (XMLUni::fgDOMEntities, false); - conf->setParameter (XMLUni::fgDOMNamespaces, true); - conf->setParameter (XMLUni::fgDOMElementContentWhitespace, false); - - // Set error handler. - // - conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp); - - if (validate) - { - conf->setParameter (XMLUni::fgDOMValidate, true); - conf->setParameter (XMLUni::fgXercesSchema, true); - 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 - - // If we are validating, pre-load and cache the schema. - // - if (!parser->loadGrammar ("test.xsd", Grammar::SchemaGrammarType, true)) - { - // In Xerces-C++ grammar loading failure results in just a warning. - // Make it a fatal error. - // - eh.handle ("test.xsd", 0, 0, - xsd::cxx::tree::error_handler::severity::fatal, - "unable to load schema"); - } - - eh.throw_if_failed (); - conf->setParameter (XMLUni::fgXercesUseCachedGrammarInParse, true); - conf->setParameter (XMLUni::fgXercesLoadSchema, false); - } - else - { - conf->setParameter (XMLUni::fgDOMValidate, false); - conf->setParameter (XMLUni::fgXercesSchema, false); - conf->setParameter (XMLUni::fgXercesSchemaFullChecking, false); - } - - conf->setParameter (XMLUni::fgXercesUserAdoptsDOMDocument, true); - - // Create memory buffer input source. - // - MemBufInputSource is ( - reinterpret_cast (buf), size, file, false); - is.setCopyBufToStream (false); - Wrapper4InputSource wis (&is, false); - - // Parsing loop. - // - os::time start; - - for (unsigned long i (0); i < iter; ++i) - { - // First parse XML to DOM reusing the parser we created above. - // - xml_schema::dom::auto_ptr doc (parser->parse (&wis)); - eh.throw_if_failed (); - - // Then parse DOM to the object model. - // - auto_ptr r (test::root_ (*doc)); - } - - os::time end; - os::time time (end - start); - - delete[] buf; - - cerr << " time: " << time << " sec" << endl; - - double ms (time.sec () * 1000000ULL + time.nsec () / 1000ULL); - - // Calculate throughput in documents/sec. - // - double tpd ((iter / ms) * 1000000); - cerr << " throughput: " << tpd << " documents/sec" << endl; - - // Calculate throughput in MBytes/sec. - // - double tpb (((size * iter) / ms) * 1000000/(1024*1024)); - cerr << " throughput: " << tpb << " MBytes/sec" << endl; - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - return false; - } - catch (std::ios_base::failure const&) - { - cerr << "io failure" << endl; - return false; - } - - return true; -} diff --git a/examples/cxx/tree/performance/serialization.cxx b/examples/cxx/tree/performance/serialization.cxx deleted file mode 100644 index 08e5740..0000000 --- a/examples/cxx/tree/performance/serialization.cxx +++ /dev/null @@ -1,132 +0,0 @@ -// file : examples/cxx/tree/performance/serialization.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include // std::size_t -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include - -#include "time.hxx" -#include "test.hxx" - -using namespace std; - -bool -serialization (const char* file, unsigned long iter) -{ - try - { - using namespace xercesc; - - cerr << "serialization:" << endl; - - // Get the object model using the standard parsing function. - // - auto_ptr r ( - test::root_ (file, - xml_schema::flags::dont_initialize | - xml_schema::flags::dont_validate)); - - // Serialize it to the in-memory buffer. This makes sure the buffer - // pre-allocates enough memory. - // - xml_schema::namespace_infomap map; - map["t"].name = "test"; - map["t"].schema = "test.xsd"; - - MemBufFormatTarget ft (10240); - test::root_ (ft, *r, map, "UTF-8", - xml_schema::flags::dont_initialize | - xml_schema::flags::dont_pretty_print | - xml_schema::flags::no_xml_declaration); - - size_t size (ft.getLen ()); - cerr << " document size: " << size << " bytes" << endl - << " iterations: " << iter << endl; - - // Create XML serializer that we are going to use in all iterations. - // - const XMLCh ls_id[] = - {xercesc::chLatin_L, xercesc::chLatin_S, xercesc::chNull}; - - DOMImplementation* impl ( - DOMImplementationRegistry::getDOMImplementation (ls_id)); - - // Use the error handler implementation provided by the XSD runtime. - // - xsd::cxx::tree::error_handler eh; - xsd::cxx::xml::dom::bits::error_handler_proxy ehp (eh); - - xml_schema::dom::auto_ptr writer ( - impl->createLSSerializer ()); - - DOMConfiguration* conf (writer->getDomConfig ()); - - conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp); - conf->setParameter (XMLUni::fgDOMXMLDeclaration, false); - - xml_schema::dom::auto_ptr out (impl->createLSOutput ()); - - out->setByteStream (&ft); - - // Serialization loop. - // - os::time start; - - for (unsigned long i (0); i < iter; ++i) - { - // First serialize the object model to DOM. - // - xml_schema::dom::auto_ptr doc (test::root_ (*r, map)); - - ft.reset (); - - // Then serialize DOM to XML reusing the serializer we created above. - // - writer->write (doc.get (), out.get ()); - eh.throw_if_failed (); - } - - os::time end; - os::time time (end - start); - - cerr << " time: " << time << " sec" << endl; - - double ms (time.sec () * 1000000ULL + time.nsec () / 1000ULL); - - // Calculate throughput in documents/sec. - // - double tpd ((iter / ms) * 1000000); - cerr << " throughput: " << tpd << " documents/sec" << endl; - - // Calculate throughput in MBytes/sec. - // - double tpb (((size * iter) / ms) * 1000000/(1024*1024)); - cerr << " throughput: " << tpb << " MBytes/sec" << endl; - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - return false; - } - catch (std::ios_base::failure const&) - { - cerr << "io failure" << endl; - return false; - } - - return true; -} diff --git a/examples/cxx/tree/performance/test-50k.xml b/examples/cxx/tree/performance/test-50k.xml deleted file mode 100644 index 42e22f3..0000000 --- a/examples/cxx/tree/performance/test-50k.xml +++ /dev/null @@ -1 +0,0 @@ -4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction \ No newline at end of file diff --git a/examples/cxx/tree/performance/test.xsd b/examples/cxx/tree/performance/test.xsd deleted file mode 100644 index d9b5778..0000000 --- a/examples/cxx/tree/performance/test.xsd +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/performance/time.cxx b/examples/cxx/tree/performance/time.cxx deleted file mode 100644 index 6bec91b..0000000 --- a/examples/cxx/tree/performance/time.cxx +++ /dev/null @@ -1,46 +0,0 @@ -// file : examples/cxx/tree/performance/time.cxx -// copyright : not copyrighted - public domain - -#include "time.hxx" - -#if defined (WIN32) || defined (__WIN32__) -# define WIN32_LEAN_AND_MEAN -# include // GetSystemTimeAsFileTime -#else -# include // gettimeofday -# include // timeval -#endif - -#include // std::ostream -#include // std::setfill, std::setw - -namespace os -{ - time:: - time () - { -#if defined (WIN32) || defined (__WIN32__) - FILETIME ft; - GetSystemTimeAsFileTime (&ft); - unsigned long long v ( - ((unsigned long long) (ft.dwHighDateTime) << 32) + ft.dwLowDateTime); - - sec_ = static_cast (v / 10000000ULL); - nsec_ = static_cast ((v % 10000000ULL) * 100); -#else - timeval tv; - if (gettimeofday(&tv, 0) != 0) - throw failed (); - - sec_ = static_cast (tv.tv_sec); - nsec_ = static_cast (tv.tv_usec * 1000); -#endif - } - - std::ostream& - operator<< (std::ostream& o, time const& t) - { - return o << t.sec () << '.' - << std::setfill ('0') << std::setw (9) << t.nsec (); - } -} diff --git a/examples/cxx/tree/performance/time.hxx b/examples/cxx/tree/performance/time.hxx deleted file mode 100644 index ea71e83..0000000 --- a/examples/cxx/tree/performance/time.hxx +++ /dev/null @@ -1,110 +0,0 @@ -// file : examples/cxx/tree/performance/time.hxx -// copyright : not copyrighted - public domain - -#ifndef TIME_HXX -#define TIME_HXX - -#include // std::ostream& - -namespace os -{ - class time - { - public: - class failed {}; - - // Create a time object representing the current time. - // - time (); - - time (unsigned long long nsec) - { - sec_ = static_cast (nsec / 1000000000ULL); - nsec_ = static_cast (nsec % 1000000000ULL); - } - - time (unsigned long sec, unsigned long nsec) - { - sec_ = sec; - nsec_ = nsec; - } - - public: - unsigned long - sec () const - { - return sec_; - } - - unsigned long - nsec () const - { - return nsec_; - } - - public: - class overflow {}; - class underflow {}; - - time - operator+= (time const& b) - { - unsigned long long tmp = 0ULL + nsec_ + b.nsec_; - - sec_ += static_cast (b.sec_ + tmp / 1000000000ULL); - nsec_ = static_cast (tmp % 1000000000ULL); - - return *this; - } - - time - operator-= (time const& b) - { - if (*this < b) - throw underflow (); - - sec_ -= b.sec_; - - if (nsec_ < b.nsec_) - { - --sec_; - nsec_ += 1000000000ULL - b.nsec_; - } - else - nsec_ -= b.nsec_; - - return *this; - } - - friend time - operator+ (time const& a, time const& b) - { - time r (a); - r += b; - return r; - } - - friend time - operator- (time const& a, time const& b) - { - time r (a); - r -= b; - return r; - } - - friend bool - operator < (time const& a, time const& b) - { - return (a.sec_ < b.sec_) || (a.sec_ == b.sec_ && a.nsec_ < b.nsec_); - } - - private: - unsigned long sec_; - unsigned long nsec_; - }; - - std::ostream& - operator<< (std::ostream&, time const&); -} - -#endif // TIME_HXX diff --git a/examples/cxx/tree/polymorphism/README b/examples/cxx/tree/polymorphism/README deleted file mode 100644 index 6e54e49..0000000 --- a/examples/cxx/tree/polymorphism/README +++ /dev/null @@ -1,32 +0,0 @@ -This example shows how to use XML Schema polymorphism features such as -xsi:type attributes and substitution groups in the C++/Tree mapping. - -The example consists of the following files: - -supermen.xsd - XML Schema which describes the "supermen" instance documents. - -supermen.xml - Sample XML instance document. - -supermen.hxx -supermen.cxx - C++ types that represent the given 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 supermen.xsd. - Note also that we use the --generate-polymorphic command line option - and that we don't need to use --polymorphic-type to explicitly mark - types as polymorphic because this is automatically deduced by the - XSD compiler from the substitution groups used in the supermen.xsd - schema. - -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 content of the object model to STDERR. Finally, the driver serializes - the object model back to XML. - -To run the example on the sample XML instance document simply execute: - -$ ./driver instance.xml diff --git a/examples/cxx/tree/polymorphism/driver.cxx b/examples/cxx/tree/polymorphism/driver.cxx deleted file mode 100644 index 3f1598f..0000000 --- a/examples/cxx/tree/polymorphism/driver.cxx +++ /dev/null @@ -1,59 +0,0 @@ -// file : examples/cxx/tree/polymorphism/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include - -#include "supermen.hxx" - -using std::cerr; -using std::endl; -using std::auto_ptr; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " supermen.xml" << endl; - return 1; - } - - try - { - auto_ptr sm (supermen_ (argv[1])); - - supermen copy (*sm); // Dynamic types are preserved in copies. - - // Print what we've got. - // - for (supermen::person_const_iterator i (copy.person ().begin ()); - i != copy.person ().end (); - ++i) - { - cerr << i->name (); - - if (const superman* s = dynamic_cast (&*i)) - { - if (s->can_fly ()) - cerr << ", flying superman"; - else - cerr << ", superman"; - } - - cerr << endl; - } - - // Serialize back to XML. - // - xml_schema::namespace_infomap map; - map[""].schema = "supermen.xsd"; - - supermen_ (std::cout, copy, map); - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/examples/cxx/tree/polymorphism/makefile b/examples/cxx/tree/polymorphism/makefile deleted file mode 100644 index 24a1644..0000000 --- a/examples/cxx/tree/polymorphism/makefile +++ /dev/null @@ -1,103 +0,0 @@ -# file : examples/cxx/tree/polymorphism/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := supermen.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) - -$(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-polymorphic --generate-serialization \ ---root-element-last -$(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)/supermen.xsd,$(install_doc_dir)/xsd/$(path)/supermen.xsd) - $(call install-data,$(src_base)/supermen.xml,$(install_doc_dir)/xsd/$(path)/supermen.xml) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/supermen.xsd,$(dist_prefix)/$(path)/supermen.xsd) - $(call install-data,$(src_base)/supermen.xml,$(dist_prefix)/$(path)/supermen.xml) - -$(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/polymorphism/supermen.xml b/examples/cxx/tree/polymorphism/supermen.xml deleted file mode 100644 index 1b5b1df..0000000 --- a/examples/cxx/tree/polymorphism/supermen.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - John Doe - - - - James "007" Bond - - - - Bruce Wayne - - - diff --git a/examples/cxx/tree/polymorphism/supermen.xsd b/examples/cxx/tree/polymorphism/supermen.xsd deleted file mode 100644 index 0d37e3d..0000000 --- a/examples/cxx/tree/polymorphism/supermen.xsd +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/secure/README b/examples/cxx/tree/secure/README deleted file mode 100644 index 649f0a3..0000000 --- a/examples/cxx/tree/secure/README +++ /dev/null @@ -1,41 +0,0 @@ -This example shows how to perform more secure XML parsing by disabling -the XML External Entity (XXE) Processing. If XML Schema validation is -used, then it would also make sense to pre-load the known schemas and -to disable loading of any external schemas, for example, via the -schemaLocation attribute found in the XML documents. See the comment -in driver.cxx for more information on how to achieve this. - -The example consists of the following files: - -library.xsd - XML Schema which describes a library of books. - -library.xml - Sample XML instance document. It includes (commented out) DOCTYPE - declarations with internal and external subsets that the parser - will refuse to process. - -library.hxx -library.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 the XSD compiler from library.xsd. - -secure-dom-parser.hxx -secure-dom-parser.cxx - A secure Xerces-C++ DOM parser implementation that disables processing - of internal/external DTD subsets. - -driver.cxx - Driver for the example. It first sets up the secure DOM parser. It then - parses the input file to a DOM document using the secure DOM parser and - calls one of the parsing functions that constructs the object model from - this DOM document. Finally, the driver prints a number of books in the - object model to STDERR. - -To run the example on the sample XML instance document simply execute: - -$ ./driver library.xml - -To verify that DTD processing is disabled, uncomment a different DOCTYPE -version in the sample document. diff --git a/examples/cxx/tree/secure/driver.cxx b/examples/cxx/tree/secure/driver.cxx deleted file mode 100644 index 2dfb3bf..0000000 --- a/examples/cxx/tree/secure/driver.cxx +++ /dev/null @@ -1,141 +0,0 @@ -// file : examples/cxx/tree/secure/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include "library.hxx" -#include "secure-dom-parser.hxx" - -using namespace std; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " library.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 - { - using namespace xercesc; - namespace xml = xsd::cxx::xml; - namespace tree = xsd::cxx::tree; - - xml::dom::auto_ptr parser (new SecureDOMParser ()); - - 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 validation. - // - conf->setParameter (XMLUni::fgDOMValidate, true); - conf->setParameter (XMLUni::fgXercesSchema, true); - 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 - - // Disable loading schemas via other means (e.g., schemaLocation). - // - // Note: this might be a good idea though if you need validation, - // you will need to pre-load the schema via other means. See the - // 'caching' and 'embedded' examples for different approaches. - // Both of them can be used with SecureDOMParser. - // - // conf->setParameter (XMLUni::fgXercesLoadSchema, false); - - // 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); - - // Parse the XML document. - // - ifstream ifs; - ifs.exceptions (ifstream::badbit | ifstream::failbit); - ifs.open (argv[1]); - - // Wrap the standard input stream. - // - xml::sax::std_input_source isrc (ifs, argv[1]); - Wrapper4InputSource wrap (&isrc, false); - - // Parse XML to DOM. - // - xml_schema::dom::auto_ptr doc (parser->parse (&wrap)); - - eh.throw_if_failed (); - - // Parse DOM to the object model. - // - auto_ptr c (library::catalog_ (*doc)); - - cerr << "catalog with " << c->book ().size () << " books" << 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/secure/library.xml b/examples/cxx/tree/secure/library.xml deleted file mode 100644 index 33a2041..0000000 --- a/examples/cxx/tree/secure/library.xml +++ /dev/null @@ -1,59 +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/secure/library.xsd b/examples/cxx/tree/secure/library.xsd deleted file mode 100644 index afad24b..0000000 --- a/examples/cxx/tree/secure/library.xsd +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/secure/makefile b/examples/cxx/tree/secure/makefile deleted file mode 100644 index fe01e9a..0000000 --- a/examples/cxx/tree/secure/makefile +++ /dev/null @@ -1,103 +0,0 @@ -# file : examples/cxx/tree/secure/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := library.xsd -cxx := driver.cxx secure-dom-parser.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): $(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) - $(call install-data,$(src_base)/secure-dom-parser.hxx,$(install_doc_dir)/xsd/$(path)/secure-dom-parser.hxx) - $(call install-data,$(src_base)/secure-dom-parser.cxx,$(install_doc_dir)/xsd/$(path)/secure-dom-parser.cxx) - -$(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) - $(call install-data,$(src_base)/secure-dom-parser.hxx,$(dist_prefix)/$(path)/secure-dom-parser.hxx) - $(call install-data,$(src_base)/secure-dom-parser.cxx,$(dist_prefix)/$(path)/secure-dom-parser.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/secure/secure-dom-parser.cxx b/examples/cxx/tree/secure/secure-dom-parser.cxx deleted file mode 100644 index 9008e1e..0000000 --- a/examples/cxx/tree/secure/secure-dom-parser.cxx +++ /dev/null @@ -1,24 +0,0 @@ -// file : examples/cxx/tree/secure/secure-dom-parser.cxx -// copyright : not copyrighted - public domain - -#include "secure-dom-parser.hxx" - -#include -#include - -using namespace xercesc; - -void SecureDOMParser:: -doctypeDecl (const DTDElementDecl& e, - const XMLCh* const pub_id, - const XMLCh* const sys_id, - const bool hasi, - const bool hase) -{ - if (hasi || hase) - ThrowXMLwithMemMgr(RuntimeException, - XMLExcepts::Gen_NoDTDValidator, - fMemoryManager); - - DOMLSParserImpl::doctypeDecl (e, pub_id, sys_id, hasi, hase); -} diff --git a/examples/cxx/tree/secure/secure-dom-parser.hxx b/examples/cxx/tree/secure/secure-dom-parser.hxx deleted file mode 100644 index 20783b8..0000000 --- a/examples/cxx/tree/secure/secure-dom-parser.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : examples/cxx/tree/secure/secure-dom-parser.hxx -// copyright : not copyrighted - public domain - -#ifndef SECURE_DOM_PARSER_HXX -#define SECURE_DOM_PARSER_HXX - -#include - -class SecureDOMParser: public xercesc::DOMLSParserImpl -{ -public: - SecureDOMParser (xercesc::MemoryManager* mm = - xercesc::XMLPlatformUtils::fgMemoryManager, - xercesc::XMLGrammarPool* gp = 0) - : DOMLSParserImpl (0, mm, gp) {} - - virtual void - doctypeDecl (const xercesc::DTDElementDecl& root, - const XMLCh* const public_id, - const XMLCh* const system_id, - const bool has_internal, - const bool has_external); -}; - -#endif // SECURE_DOM_PARSER_HXX diff --git a/examples/cxx/tree/streaming/README b/examples/cxx/tree/streaming/README deleted file mode 100644 index 5a467e0..0000000 --- a/examples/cxx/tree/streaming/README +++ /dev/null @@ -1,51 +0,0 @@ -This example shows how to perform stream-oriented, partially in-memory -XML processing using the C++/Tree mapping. With the partially in-memory -parsing and serialization only a part of the object model is in memory at -any given time. With this approach we can process parts of the document -as they become available as well as handle documents that are too large -to fit into memory. - -The example consists of the following files: - -position.xsd - XML Schema which describes a simple object position vocabulary. The - position is represented as a potentially large series of latitude and - longitude measurements. - -position.xml - Sample object position document. - -position.hxx -position.cxx - C++ types that represent the position vocabulary as well as parsing - and serialization functions. These are generated by XSD from - position.xsd. - -parser.hxx -parser.cxx - Stream-oriented DOM parser implementation that is built on top of the - Xerces-C++ SAX2 parser in the progressive parsing mode. This parser - allows us to parse an XML document as a series of DOM fragments. - -serializer.hxx -serializer.cxx - Stream-oriented DOM serializer implementation that allows us to - serialize an XML Document as a series of object model fragments. - -grammar-input-stream.hxx -grammar-input-stream.cxx - Input stream implementation with the special-purpose schema grammar - decompression algorithm. It is used internally by the streaming parser. - -driver.cxx - Driver for the example. It parses the input file into a series of DOM - fragments which are then parsed into the object model fragments. The - driver prints the information from the document as it becomes available. - It also serializes the object model fragments into a new XML document - (out.xml). - -To run the example simply execute: - -$ ./driver position.xml - -The serialization results are written to the out.xml file. diff --git a/examples/cxx/tree/streaming/driver.cxx b/examples/cxx/tree/streaming/driver.cxx deleted file mode 100644 index eb7026a..0000000 --- a/examples/cxx/tree/streaming/driver.cxx +++ /dev/null @@ -1,139 +0,0 @@ -// file : examples/cxx/tree/streaming/driver.cxx -// copyright : not copyrighted - public domain - -#include -#include - -#include - -#include // xml::string - -#include "parser.hxx" -#include "serializer.hxx" -#include "position.hxx" - -using namespace std; -using namespace xercesc; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " position.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 - { - using namespace op; - namespace xml = xsd::cxx::xml; - - // Parse and serialize at the same time, in the streaming mode. - // - - ifstream ifs; - ifs.exceptions (ifstream::badbit | ifstream::failbit); - ifs.open (argv[1]); - - ofstream ofs; - ofs.exceptions (ios_base::badbit | ios_base::failbit); - ofs.open ("out.xml"); - - xml_schema::namespace_infomap ns_map; - ns_map["op"].name = "http://www.codesynthesis.com/op"; - ns_map["op"].schema = "position.xsd"; - - parser p; - serializer s; - - p.start (ifs, argv[1], true); - s.start (ofs); - - typedef xml_schema::dom::auto_ptr document_ptr; - - // Peek at the root element. This way we only get the "carcase" - // of the document, that is, the root element with its name, all - // the attributes, and namespace declarations but without any of - // the nested elements. - // - document_ptr docr (p.peek ()); - bool parsed (false); - - // Parse first-level elements. - // - for (document_ptr doc1 (p.peek ()); doc1.get () != 0; doc1 = p.peek ()) - { - // Check whether it is an element that we should stream (position) or - // just add to the root (header). - // - string n1 (xml::transcode ( - doc1->getDocumentElement ()->getLocalName ())); - - // If we see the first streaming element, then parse the root carcase. - // - if (!parsed && n1 == "position") - { - object o (*docr->getDocumentElement ()); - - cerr << "id: " << o.id () << endl - << "name: " << o.header ().name () << endl - << "type: " << o.header ().type () << endl; - - // Start serializing the document by writing out the root carcase. - // Note that we leave it open so that we can serialize more elements. - // - s.next_open (ns_map["op"].name, "op:object", ns_map, o); - parsed = true; - } - - // Handle elements that need streaming. - // - if (n1 == "position") - { - // Position has no nested elements that we need to stream so we - // finish parsing it in one go. - // - doc1 = p.next (doc1); - position pos (*doc1->getDocumentElement ()); - - cerr << "lat: " << pos.lat () << " lon: " << pos.lon () << endl; - - // Serialize it (append) to the root element. - // - s.next ("position", pos); - } - else - { - // Element that doesn't require streaming (header in our case). Add - // to the root element and finish parsing. - // - docr = p.next (doc1, docr); - } - } - - // Close the root element in serializer. - // - s.next_close ("op:object"); - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - r = 1; - } - catch (const ios_base::failure&) - { - cerr << "io failure" << endl; - r = 1; - } - - xercesc::XMLPlatformUtils::Terminate (); - return r; -} diff --git a/examples/cxx/tree/streaming/grammar-input-stream.cxx b/examples/cxx/tree/streaming/grammar-input-stream.cxx deleted file mode 100644 index ffdb5b4..0000000 --- a/examples/cxx/tree/streaming/grammar-input-stream.cxx +++ /dev/null @@ -1,96 +0,0 @@ -// file : examples/cxx/tree/streaming/grammar-input-stream.cxx -// author : Boris Kolpackov -// copyright : not copyrighted - public domain - -#include -#include "grammar-input-stream.hxx" - -grammar_input_stream:: -grammar_input_stream (const XMLByte* data, std::size_t size) - : data_ (data), - size_ (size), - pos_ (0), - vpos_ (0), - cseq_ (0), - add_zero_ (false) -{ -} - -XMLFilePos grammar_input_stream:: -curPos () const -{ - return static_cast (vpos_); -} - -XMLSize_t grammar_input_stream:: -readBytes (XMLByte* const buf, const XMLSize_t size) -{ - std::size_t i (0); - - // Add a zero from the alternating sequence if it didn't - // fit on the previous read. - // - if (add_zero_) - { - buf[i++] = 0; - add_zero_ = false; - } - - // If have an unfinished sequential sequence, output it now. - // - if (cseq_ != 0 && !alt_) - { - for (; cseq_ != 0 && i < size; --cseq_) - buf[i++] = 0; - } - - for (; i < size && pos_ < size_;) - { - XMLByte b = buf[i++] = data_[pos_++]; - - // See if we are in a compression sequence. - // - if (cseq_ != 0) - { - if (i < size) - buf[i++] = 0; - else - add_zero_ = true; // Add it on the next read. - - cseq_--; - continue; - } - - // If we are not in a compression sequence and this byte is - // not zero then we are done. - // - if (b != 0) - continue; - - // We have a zero. - // - assert (pos_ < size_); // There has to be another byte. - unsigned char v (static_cast (data_[pos_++])); - alt_ = (v & 128) != 0; - cseq_ = v & 127; - - // If it is a sequential sequence, output as many zeros as - // we can. - // - if (!alt_) - { - for (; cseq_ != 0 && i < size; --cseq_) - buf[i++] = 0; - } - } - - vpos_ += i; - - return static_cast (i); -} - -const XMLCh* grammar_input_stream:: -getContentType () const -{ - return 0; -} diff --git a/examples/cxx/tree/streaming/grammar-input-stream.hxx b/examples/cxx/tree/streaming/grammar-input-stream.hxx deleted file mode 100644 index 36ef74c..0000000 --- a/examples/cxx/tree/streaming/grammar-input-stream.hxx +++ /dev/null @@ -1,41 +0,0 @@ -// file : examples/cxx/tree/streaming/grammar-input-stream.hxx -// author : Boris Kolpackov -// copyright : not copyrighted - public domain - -#ifndef GRAMMAR_INPUT_STREAM_HXX -#define GRAMMAR_INPUT_STREAM_HXX - -#include -#include - -// Memory buffer input stream with the special-purpose schema -// grammar decompression. -// -class grammar_input_stream: public xercesc::BinInputStream -{ -public : - grammar_input_stream (const XMLByte* data, std::size_t size); - - virtual XMLFilePos - curPos () const; - - virtual XMLSize_t - readBytes (XMLByte* const buf, const XMLSize_t size); - - virtual const XMLCh* - getContentType () const; - -private : - const XMLByte* data_; - std::size_t size_; - std::size_t pos_; - std::size_t vpos_; - - // Compression data. - // - size_t cseq_; // Number of bytes left in a compression sequence. - bool alt_; // Alternating or sequential sequence. - bool add_zero_; // Add a zero on the next read. -}; - -#endif // GRAMMAR_INPUT_STREAM_HXX diff --git a/examples/cxx/tree/streaming/makefile b/examples/cxx/tree/streaming/makefile deleted file mode 100644 index e89e529..0000000 --- a/examples/cxx/tree/streaming/makefile +++ /dev/null @@ -1,114 +0,0 @@ -# file : examples/cxx/tree/streaming/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := position.xsd -cxx := driver.cxx parser.cxx serializer.cxx grammar-input-stream.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 += --generate-serialization -$(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)/parser.cxx,$(install_doc_dir)/xsd/$(path)/parser.cxx) - $(call install-data,$(src_base)/parser.hxx,$(install_doc_dir)/xsd/$(path)/parser.hxx) - $(call install-data,$(src_base)/serializer.cxx,$(install_doc_dir)/xsd/$(path)/serializer.cxx) - $(call install-data,$(src_base)/serializer.hxx,$(install_doc_dir)/xsd/$(path)/serializer.hxx) - $(call install-data,$(src_base)/grammar-input-stream.cxx,$(install_doc_dir)/xsd/$(path)/grammar-input-stream.cxx) - $(call install-data,$(src_base)/grammar-input-stream.hxx,$(install_doc_dir)/xsd/$(path)/grammar-input-stream.hxx) - $(call install-data,$(src_base)/position.xsd,$(install_doc_dir)/xsd/$(path)/position.xsd) - $(call install-data,$(src_base)/position.xml,$(install_doc_dir)/xsd/$(path)/position.xml) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/parser.cxx,$(dist_prefix)/$(path)/parser.cxx) - $(call install-data,$(src_base)/parser.hxx,$(dist_prefix)/$(path)/parser.hxx) - $(call install-data,$(src_base)/serializer.cxx,$(dist_prefix)/$(path)/serializer.cxx) - $(call install-data,$(src_base)/serializer.hxx,$(dist_prefix)/$(path)/serializer.hxx) - $(call install-data,$(src_base)/grammar-input-stream.cxx,$(dist_prefix)/$(path)/grammar-input-stream.cxx) - $(call install-data,$(src_base)/grammar-input-stream.hxx,$(dist_prefix)/$(path)/grammar-input-stream.hxx) - $(call install-data,$(src_base)/position.xsd,$(dist_prefix)/$(path)/position.xsd) - $(call install-data,$(src_base)/position.xml,$(dist_prefix)/$(path)/position.xml) - -$(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)/out.xml) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(gen): | $(out_base)/.gitignore -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver out.xml $(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/streaming/parser.cxx b/examples/cxx/tree/streaming/parser.cxx deleted file mode 100644 index 41ad7af..0000000 --- a/examples/cxx/tree/streaming/parser.cxx +++ /dev/null @@ -1,372 +0,0 @@ -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include // xercesc::Grammar -#include - -#include - -#include -#include - -#include -#include - -#include "parser.hxx" -#include "grammar-input-stream.hxx" - -using namespace std; -using namespace xercesc; - -namespace xml = xsd::cxx::xml; -namespace tree = xsd::cxx::tree; - -typedef parser::document_ptr document_ptr; - -class parser_impl: public DefaultHandler -{ -public: - parser_impl (const XMLByte* grammar, size_t grammar_size); - - void - start (istream& is, const string& id, bool validate); - - document_ptr - peek (); - - document_ptr - next (document_ptr doc = document_ptr (), - document_ptr outer_doc = document_ptr ()); - - // SAX event handlers. - // -private: - virtual void - startElement (const XMLCh* const uri, - const XMLCh* const lname, - const XMLCh* const qname, - const Attributes& attributes); - - virtual void - endElement (const XMLCh* const uri, - const XMLCh* const lname, - const XMLCh* const qname); - - virtual void - characters (const XMLCh* const s, - const XMLSize_t length); - -private: - // SAX parser. - // - bool clean_; - auto_ptr grammar_pool_; - auto_ptr parser_; - XMLPScanToken token_; - tree::error_handler error_handler_; - xml::sax::bits::error_handler_proxy error_proxy_; - auto_ptr isrc_; - - size_t depth_; - size_t whitespace_depth_; // Depth at which to ignore whitespaces. - - bool peek_; - size_t next_depth_; // Depth at which next() should work. - - // DOM document being built. - // - DOMImplementation& dom_impl_; - document_ptr doc_; - DOMElement* cur_; -}; - -const XMLCh ls[] = {chLatin_L, chLatin_S, chNull}; - -parser_impl:: -parser_impl (const XMLByte* grammar, size_t grammar_size) - : clean_ (true), - error_proxy_ (error_handler_), - dom_impl_ (*DOMImplementationRegistry::getDOMImplementation (ls)) -{ - MemoryManager* mm (XMLPlatformUtils::fgMemoryManager); - - if (grammar != 0) - { - assert (grammar_size != 0); - grammar_pool_.reset (new XMLGrammarPoolImpl (mm)); - - grammar_input_stream is (grammar, grammar_size); - grammar_pool_->deserializeGrammars(&is); - grammar_pool_->lockPool (); - } - - parser_.reset (XMLReaderFactory::createXMLReader (mm, grammar_pool_.get ())); - - parser_->setFeature (XMLUni::fgSAX2CoreNameSpaces, true); - parser_->setFeature (XMLUni::fgSAX2CoreNameSpacePrefixes, true); - parser_->setFeature (XMLUni::fgXercesValidationErrorAsFatal, true); - parser_->setFeature (XMLUni::fgXercesSchemaFullChecking, false); - - // Xerces-C++ 3.1.0 is the first version with working multi import - // support. It also allows us to disable buffering in the parser - // so that the data is parsed and returned as soon as it is - // available. - // -#if _XERCES_VERSION >= 30100 - parser_->setFeature (XMLUni::fgXercesHandleMultipleImports, true); - - XMLSize_t lwm = 0; - parser_->setProperty (XMLUni::fgXercesLowWaterMark, &lwm); -#endif - - parser_->setErrorHandler (&error_proxy_); - parser_->setContentHandler (this); -} - -void parser_impl:: -start (istream& is, const string& id, bool val) -{ - // Reset our state. - // - depth_ = 0; - peek_ = false; - doc_.reset (); - error_handler_.reset (); - - if (!clean_) - parser_->parseReset (token_); - else - clean_ = false; - - isrc_.reset (new xml::sax::std_input_source (is, id)); - - parser_->setFeature (XMLUni::fgSAX2CoreValidation, val); - parser_->setFeature (XMLUni::fgXercesSchema, val); - - if (val && grammar_pool_.get () != 0) - { - // Use the loaded grammar during parsing. - // - parser_->setFeature (XMLUni::fgXercesUseCachedGrammarInParse, true); - - // Disable loading schemas via other means (e.g., schemaLocation). - // - parser_->setFeature (XMLUni::fgXercesLoadSchema, false); - } - - parser_->parseFirst (*isrc_, token_); - error_handler_.throw_if_failed > (); -} - -document_ptr parser_impl:: -peek () -{ - bool r (true); - - size_t d (depth_); - whitespace_depth_ = d; - - peek_ = true; - - // Parse (skip whitespace content) until the depth increases or we get - // a document. The latter test covers cases where both start - // and end events will trigger and therefore leave the depth unchanged. - // - while (r && depth_ == d && doc_.get () == 0) - { - r = parser_->parseNext (token_); - error_handler_.throw_if_failed > (); - } - - if (!r) - return document_ptr (0); - - return doc_; -} - -document_ptr parser_impl:: -next (document_ptr doc, document_ptr outer_doc) -{ - assert (peek_ == (doc.get () != 0)); - - // Install doc/outer_doc as the document we are parsing. - // - if (doc.get () != 0) - { - if (outer_doc.get () != 0) - { - // Copy doc to outer_doc. - // - doc_ = outer_doc; - cur_ = static_cast ( - doc_->importNode (doc->getDocumentElement (), true)); - doc_->getDocumentElement ()->appendChild (cur_); - } - else - { - doc_ = doc; - cur_ = doc_->getDocumentElement (); - } - - // This handles the case where we get both start and - // end events in peek(). In this case the element is fully parsed - // and next() has nothing to do. - // - if (depth_ != next_depth_) - { - peek_ = false; - return doc_; - } - } - - bool r (true); - - // If we peeked, then we have already seen the start tag and our - // return depth is one above the current depth. - // - size_t d (peek_ ? depth_ - 1 : depth_); - whitespace_depth_ = d; - - peek_ = false; - - // Keep calling parseNext() until we either move to a greater depth or - // get a document. This way we skip the text (presumably whitespaces) - // that may be preceding this chunk. - // - while (r && depth_ == d && doc_.get () == 0) - { - parser_->parseNext (token_); - error_handler_.throw_if_failed > (); - } - - if (!r) - return document_ptr (0); - - // If we are not at our start depth, keep calling parseNext() until we - // get there again. - // - while (r && depth_ != d) - { - r = parser_->parseNext (token_); - error_handler_.throw_if_failed > (); - } - - if (!r) - return document_ptr (0); - - return doc_; -} - -// DOM builder. -// - -void parser_impl:: -startElement (const XMLCh* const uri, - const XMLCh* const /*lname*/, - const XMLCh* const qname, - const Attributes& attr) -{ - if (doc_.get () == 0) - { - doc_.reset (dom_impl_.createDocument (uri, qname, 0)); - cur_ = doc_->getDocumentElement (); - } - else - { - DOMElement* e = doc_->createElementNS (uri, qname); - cur_->appendChild (e); - cur_ = e; - } - - // Set attributes. - // - for (XMLSize_t i (0), end (attr.getLength()); i < end; ++i) - { - const XMLCh* qn (attr.getQName (i)); - const XMLCh* ns (attr.getURI (i)); - - // When SAX2 reports the xmlns attribute, it does not include - // the proper attribute namespace. So we have to detect and - // handle this case. - // - if (XMLString::equals (qn, XMLUni::fgXMLNSString)) - ns = XMLUni::fgXMLNSURIName; - - cur_->setAttributeNS (ns, qn, attr.getValue (i)); - } - - depth_++; - - if (peek_) - next_depth_ = depth_; -} - -void parser_impl:: -endElement (const XMLCh* const /*uri*/, - const XMLCh* const /*lname*/, - const XMLCh* const /*qname*/) -{ - // We have an element parent only on depth 2 or greater. - // - if (--depth_ > 1) - cur_ = static_cast (cur_->getParentNode ()); -} - -void parser_impl:: -characters (const XMLCh* const s, const XMLSize_t length) -{ - const XMLCh empty[] = {chNull}; - - // Ignore text content (presumably whitespaces) while looking for - // the next element. - // - if (depth_ > whitespace_depth_) - { - DOMText* t = doc_->createTextNode (empty); - static_cast (t)->appendData (s, length); - cur_->appendChild (t); - } -} - -// -// parser -// - -parser:: -~parser () -{ -} - -parser:: -parser (const XMLByte* grammar, size_t grammar_size) - : impl_ (new parser_impl (grammar, grammar_size)) -{ -} - -void parser:: -start (istream& is, const string& id, bool val) -{ - return impl_->start (is, id, val); -} - -document_ptr parser:: -peek () -{ - return impl_->peek (); -} - -document_ptr parser:: -next (document_ptr doc, document_ptr outer_doc) -{ - return impl_->next (doc, outer_doc); -} diff --git a/examples/cxx/tree/streaming/parser.hxx b/examples/cxx/tree/streaming/parser.hxx deleted file mode 100644 index cb34f92..0000000 --- a/examples/cxx/tree/streaming/parser.hxx +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef PARSER_HXX -#define PARSER_HXX - -#include -#include -#include // std::size_t -#include // std::auto_ptr - -#include - -#include - -class parser_impl; - -class parser -{ -public: - // We can specify embedded XML Schema grammar to be used by the parser - // that was created by the xsdbin utility from the 'embedded' example. - // - parser (const XMLByte* grammar = 0, std::size_t grammar_size = 0); - ~parser (); - - // The start function prepares everything for parsing a new document. - // - void - start (std::istream& is, const std::string& id, bool validate); - - typedef xsd::cxx::xml::dom::auto_ptr document_ptr; - - // The peek function parses just the next element (ignoring any - // preceding content assuming it is whitespace) without parsing - // any of its nested content (but it includes the element's - // attributes). It returns NULL if there are no more elements - // at this level (there could still be on outer levels in case - // of nested streaming). - // - document_ptr - peek (); - - // The next function parses (or finishes parsing after peek) the - // next element including its nested content. It returns NULL if - // there are no more elements at this level (there could still - // be on outer levels in case of nested streaming). - // - // If doc is not NULL, then it should be the document returned - // by peek(). That is, a document with only the root element. - // In this case next() finishes parsing this element. - // - // If outer_doc is not NULL, then next() will first add doc to - // outer_doc as a child of the document root. - // - document_ptr - next (document_ptr doc = document_ptr (), - document_ptr outer_doc = document_ptr ()); - -private: - parser (const parser&); - - parser& - operator= (const parser&); - -private: - std::auto_ptr impl_; -}; - -#endif // PARSER_HXX diff --git a/examples/cxx/tree/streaming/position.xml b/examples/cxx/tree/streaming/position.xml deleted file mode 100644 index a3428bf..0000000 --- a/examples/cxx/tree/streaming/position.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - -
- Lion's Head - rock -
- - - - - - - - - - -
diff --git a/examples/cxx/tree/streaming/position.xsd b/examples/cxx/tree/streaming/position.xsd deleted file mode 100644 index 18dda94..0000000 --- a/examples/cxx/tree/streaming/position.xsd +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/streaming/serializer.cxx b/examples/cxx/tree/streaming/serializer.cxx deleted file mode 100644 index e6513bc..0000000 --- a/examples/cxx/tree/streaming/serializer.cxx +++ /dev/null @@ -1,636 +0,0 @@ -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include "serializer.hxx" - -using namespace std; -using namespace xercesc; - -namespace xml = xsd::cxx::xml; -namespace tree = xsd::cxx::tree; - -static const XMLCh gEOLSeq[] = -{ - chLF, chNull -}; - -static const XMLCh gUTF8[] = -{ - chLatin_U, chLatin_T, chLatin_F, chDash, chDigit_8, chNull -}; - -static const XMLCh gEndElement[] = -{ - chOpenAngle, chForwardSlash, chNull -}; - -static const int DISCARD_DEFAULT_CONTENT_ID = 0x1; -static const int ENTITIES_ID = 0x2; -static const int FORMAT_PRETTY_PRINT_1ST_LEVEL_ID = 0xA; - -class StreamingDOMSerializer: public DOMLSSerializerImpl -{ -public: - StreamingDOMSerializer (MemoryManager* manager) - : DOMLSSerializerImpl (manager) - { - } - - bool - startOpen (const DOMElement* e, DOMLSOutput* const destination) - { - const DOMDocument* docu (e->getOwnerDocument ()); - assert (docu != 0); - - // Code adapted from DOMLSSerializerImpl::write(). - // - target_ = destination->getByteStream(); - - fEncodingUsed = gUTF8; - - const XMLCh* lsEncoding=destination->getEncoding(); - if (lsEncoding && *lsEncoding) - { - fEncodingUsed = lsEncoding; - } - else if (docu) - { - const XMLCh* tmpEncoding = docu->getInputEncoding(); - - if ( tmpEncoding && *tmpEncoding) - { - fEncodingUsed = tmpEncoding; - } - else - { - tmpEncoding = docu->getXmlEncoding(); - - if ( tmpEncoding && *tmpEncoding) - { - fEncodingUsed = tmpEncoding; - } - } - } - - fNewLineUsed = (fNewLine && *fNewLine)? fNewLine : gEOLSeq; - - fDocumentVersion = (docu->getXmlVersion() && *(docu->getXmlVersion())) - ? docu->getXmlVersion() - : XMLUni::fgVersion1_0; - - fErrorCount = 0; - - fLineFeedInTextNodePrinted = false; - fLastWhiteSpaceInTextNode = 0; - - level_ = 0; - namespace_map_.clear (); - - fFormatter = new (fMemoryManager) XMLFormatter( fEncodingUsed - ,fDocumentVersion - ,target_ - ,XMLFormatter::NoEscapes - ,XMLFormatter::UnRep_CharRef - ,fMemoryManager); - formatter_.reset (fFormatter); - - // Write out the XML declaration, etc. Here we assume that the document - // has no children (i.e., no root element). - // - processNode (docu, 0); - fLineFeedInTextNodePrinted = true; - - return writeOpen (e); - } - - bool - writeOpen (const DOMElement* e) - { - // Code adapted from the first part of ELEMENT_NODE case in - // DOMLSSerializerImpl::processNode(). - // - - if (!fLineFeedInTextNodePrinted) - { - if(level_ == 1 && getFeature(FORMAT_PRETTY_PRINT_1ST_LEVEL_ID)) - printNewLine(); - - printNewLine(); - } - else - { - fLineFeedInTextNodePrinted = false; - } - - printIndent(level_); - - RefHashTableOf* namespaceMap = NULL; - - *fFormatter << XMLFormatter::NoEscapes << chOpenAngle << - e->getNodeName (); - - setURCharRef(); - DOMNamedNodeMap *attributes = e->getAttributes(); - XMLSize_t attrCount = attributes->getLength(); - - const XMLCh* prefix = e->getPrefix(); - const XMLCh* uri = e->getNamespaceURI(); - if((uri && uri[0]) || - ((prefix==0 || prefix[0]==0) && isDefaultNamespacePrefixDeclared())) - { - if(prefix==0 || prefix[0]==0) - prefix=XMLUni::fgZeroLenString; - if(!isNamespaceBindingActive(prefix, uri)) - { - if(namespaceMap==NULL) - { - namespaceMap=new (fMemoryManager) RefHashTableOf(12, false, fMemoryManager); - fNamespaceStack->addElement(namespaceMap); - } - namespaceMap->put((void*)prefix,(XMLCh*)uri); - *fFormatter << XMLFormatter::NoEscapes - << chSpace << XMLUni::fgXMLNSString; - - if(!XMLString::equals(prefix,XMLUni::fgZeroLenString)) - *fFormatter << chColon << prefix; - - *fFormatter << chEqual << chDoubleQuote - << XMLFormatter::AttrEscapes - << uri - << XMLFormatter::NoEscapes - << chDoubleQuote; - } - } - - bool discard = getFeature(DISCARD_DEFAULT_CONTENT_ID); - for (XMLSize_t i = 0; i < attrCount; i++) - { - DOMAttr* attribute = (DOMAttr*)attributes->item(i); - - if (discard && !((DOMAttr*)attribute )->getSpecified()) - continue; - - // if this attribute is a namespace declaration, add it to the namespace map for the current level - const XMLCh* ns = attribute->getNamespaceURI(); - if (ns != 0 ) - { - if(XMLString::equals(ns, XMLUni::fgXMLNSURIName)) - { - if(namespaceMap==NULL) - { - namespaceMap=new (fMemoryManager) RefHashTableOf(12, false, fMemoryManager); - fNamespaceStack->addElement(namespaceMap); - } - const XMLCh* nsPrefix = attribute->getLocalName(); - if(XMLString::equals(attribute->getNodeName(),XMLUni::fgXMLNSString)) - nsPrefix = XMLUni::fgZeroLenString; - if(namespaceMap->containsKey((void*)nsPrefix)) - continue; - namespaceMap->put((void*)attribute->getLocalName(),(XMLCh*)attribute->getNodeValue()); - } - else if(!XMLString::equals(ns, XMLUni::fgXMLURIName)) - { - // check if the namespace for the current node is already defined - const XMLCh* prefix = attribute->getPrefix(); - if(prefix && prefix[0]) - { - const XMLCh* uri = attribute->getNamespaceURI(); - if(!isNamespaceBindingActive(prefix, uri)) - { - if(namespaceMap==NULL) - { - namespaceMap=new (fMemoryManager) RefHashTableOf(12, false, fMemoryManager); - fNamespaceStack->addElement(namespaceMap); - } - namespaceMap->put((void*)prefix,(XMLCh*)uri); - - *fFormatter << XMLFormatter::NoEscapes - << chSpace << XMLUni::fgXMLNSString << chColon << prefix - << chEqual << chDoubleQuote - << XMLFormatter::AttrEscapes - << uri - << XMLFormatter::NoEscapes - << chDoubleQuote; - } - } - } - } - - if (XMLString::equals(ns, XMLUni::fgXMLNSURIName) || checkFilter(attribute) == DOMNodeFilter::FILTER_ACCEPT) - { - *fFormatter << XMLFormatter::NoEscapes - << chSpace << attribute->getNodeName() - << chEqual << chDoubleQuote - << XMLFormatter::AttrEscapes; - - if (getFeature(ENTITIES_ID)) - { - DOMNode* child = attribute->getFirstChild(); - while( child != 0) - { - if(child->getNodeType()==DOMNode::TEXT_NODE) - *fFormatter << child->getNodeValue(); - else if(child->getNodeType()==DOMNode::ENTITY_REFERENCE_NODE) - *fFormatter << XMLFormatter::NoEscapes - << chAmpersand << child->getNodeName() << chSemiColon - << XMLFormatter::AttrEscapes; - child = child->getNextSibling(); - } - } - else - *fFormatter << attribute->getNodeValue(); - - *fFormatter << XMLFormatter::NoEscapes << chDoubleQuote; - } - } - - *fFormatter << XMLFormatter::NoEscapes << chCloseAngle; - - // Keep track of whether we have added a namespace map for this - // element. Used to pop it in writeClose(). - // - namespace_map_.push_back (namespaceMap != 0); - - level_++; - - DOMNode* child = e->getFirstChild(); - while (child != 0) - { - processNode (child, level_); - child = child->getNextSibling(); - } - - return fErrorCount == 0; - } - - bool - writeClose (const XMLCh* name) - { - // Code adapted from the second part of ELEMENT_NODE case in - // DOMLSSerializerImpl::processNode(). - // - level_--; - - // Assume we are not on the same line (nodeLine != fCurrentLine). - // - { - if (!fLineFeedInTextNodePrinted) - { - printNewLine(); - } - else - { - fLineFeedInTextNodePrinted = false; - } - - if(level_ == 0 && getFeature(FORMAT_PRETTY_PRINT_1ST_LEVEL_ID)) - printNewLine(); - - printIndent(level_); - } - - *fFormatter << XMLFormatter::NoEscapes << gEndElement << - name << chCloseAngle; - - if (namespace_map_.back ()) - fNamespaceStack->removeLastElement(); - - namespace_map_.pop_back (); - - if (level_ == 0) - { - printNewLine(); - target_->flush (); - } - - return fErrorCount == 0; - } - - bool - write (const DOMElement* e) - { - processNode (e, level_); - return fErrorCount == 0; - } - - using DOMLSSerializerImpl::write; // Whole document. - -public: - // Update the namespace stack to point to the strings from the - // new document's string pool. - // - void - update_namespace_stack (DOMDocument& d) - { - DOMDocumentImpl& di (dynamic_cast (d)); - - for (XMLSize_t i (0); i != fNamespaceStack->size (); ++i) - { - RefHashTableOf& t (*fNamespaceStack->elementAt (i)); - RefHashTableOfEnumerator e (&t, false, fMemoryManager); - while (e.hasMoreElements ()) - { - XMLCh* k ((XMLCh*) (e.nextElementKey ())); - XMLCh* v (t.get (k)); - t.put ((void*) (di.getPooledString (k)), - (XMLCh*) (di.getPooledString (v))); - } - } - } - -private: - XMLFormatTarget* target_; - std::auto_ptr formatter_; - int level_; - - std::vector namespace_map_; -}; - -class serializer_impl -{ -public: - typedef serializer::namespace_infomap namespace_infomap; - - serializer_impl (); - - void - start (ostream& os, const string& encoding); - - DOMElement* - create (const string& name, const namespace_infomap&); - - DOMElement* - create (const string& ns, const string& qname, const namespace_infomap&); - - void - serialize (xml::dom::auto_ptr); - - void - serialize_open (xml::dom::auto_ptr); - - void - serialize_close (const string&); - -private: - void - clear_document (); - -private: - bool start_; - - // Serializer. - // - xml::dom::auto_ptr out_; - xml::dom::auto_ptr serializer_; - - auto_ptr oft_; - - tree::error_handler error_handler_; - xml::dom::bits::error_handler_proxy error_proxy_; - - // DOM document that we use to create the elements. - // - DOMImplementation& dom_impl_; - xml::dom::auto_ptr doc_; - vector element_stack_; - - size_t element_count_; // Number of elements serialized using current doc. - static const size_t element_count_limit_ = 500; -}; - -const XMLCh ls[] = {chLatin_L, chLatin_S, chNull}; - -serializer_impl:: -serializer_impl () - : error_proxy_ (error_handler_), - dom_impl_ (*DOMImplementationRegistry::getDOMImplementation (ls)) -{ - serializer_.reset ( - new (XMLPlatformUtils::fgMemoryManager) - StreamingDOMSerializer (XMLPlatformUtils::fgMemoryManager)); - - DOMConfiguration* conf (serializer_->getDomConfig ()); - conf->setParameter (XMLUni::fgDOMErrorHandler, &error_proxy_); - conf->setParameter (XMLUni::fgDOMXMLDeclaration, true); - conf->setParameter (XMLUni::fgDOMWRTDiscardDefaultContent, true); - conf->setParameter (XMLUni::fgDOMWRTFormatPrettyPrint, true); - conf->setParameter (XMLUni::fgDOMWRTXercesPrettyPrint, false); -} - -void serializer_impl:: -start (ostream& os, const string& encoding) -{ - element_stack_.clear (); - doc_.reset (dom_impl_.createDocument ()); - element_count_ = 0; - - error_handler_.reset (); - oft_.reset (new xml::dom::ostream_format_target (os)); - - out_.reset (dom_impl_.createLSOutput ()); - out_->setEncoding (xml::string (encoding).c_str ()); - out_->setByteStream (oft_.get ()); - - start_ = true; -} - -DOMElement* serializer_impl:: -create (const string& name, const namespace_infomap& map) -{ - DOMElement* r (doc_->createElement (xml::string (name).c_str ())); - - if (!map.empty ()) - xml::dom::add_namespaces (*r, map); - - // Add the element as the child of the stack "tip" so that it - // "sees" all the namespace declarations active from this point. - // - if (!element_stack_.empty ()) - element_stack_.back ()->appendChild (r); - - return r; -} - -DOMElement* serializer_impl:: -create (const string& ns, const string& qname, const namespace_infomap& map) -{ - DOMElement* r ( - doc_->createElementNS ( - xml::string (ns).c_str (), xml::string (qname).c_str ())); - - if (!map.empty ()) - xml::dom::add_namespaces (*r, map); - - // Add the element as the child of the stack "tip" so that it - // "sees" all the namespace declarations active from this point. - // - if (!element_stack_.empty ()) - element_stack_.back ()->appendChild (r); - - return r; -} - -void serializer_impl:: -serialize (xml::dom::auto_ptr p) -{ - DOMElement* e (p.get ()); - - if (start_) - { - serializer_->write (e, out_.get ()); - start_ = false; - } - else - serializer_->write (e); - - error_handler_.throw_if_failed > (); - - // Remove this element from its parent before we release. - // - if (!element_stack_.empty ()) - element_stack_.back ()->removeChild (e); - - p.reset (); // Release it before we may clear the document below. - - if (element_count_++ > element_count_limit_) - clear_document (); -} - -void serializer_impl:: -serialize_open (xml::dom::auto_ptr p) -{ - DOMElement* e (p.get ()); - - if (start_) - { - serializer_->startOpen (e, out_.get ()); - start_ = false; - } - else - serializer_->writeOpen (e); - - error_handler_.throw_if_failed > (); - - // Add this element to the element stack. serialize_close() is - // responsible for its removal and releasing. - // - element_stack_.push_back (e); - p.release (); -} - -void serializer_impl:: -serialize_close (const string& name) -{ - serializer_->writeClose (xml::string (name).c_str ()); - error_handler_.throw_if_failed > (); - - // Release the element. - // - DOMElement* e (element_stack_.back ()); - element_stack_.pop_back (); - - if (!element_stack_.empty ()) - element_stack_.back ()->removeChild (e); - - e->release (); - - if (element_count_++ > element_count_limit_) - clear_document (); -} - -void serializer_impl:: -clear_document () -{ - // Re-create the document in order to force deallocation of its - // internal heap. While Xerces-C++ DOM tries to re-use memory, - // it still accumulates no longer used memory blocks. - // - xml::dom::auto_ptr doc (dom_impl_.createDocument ()); - - if (!element_stack_.empty ()) - { - DOMElement* e ( - static_cast ( - doc->importNode (element_stack_.front (), true))); - - for (vector::iterator i (element_stack_.begin ()); - i != element_stack_.end (); - ++i) - { - *i = e; - e = static_cast (e->getFirstChild ()); - } - } - - // Update the namespace stack to use the new document. - // - serializer_->update_namespace_stack (*doc); - - doc_ = doc; - element_count_ = 0; -} - -// -// serializer -// - -serializer:: -~serializer () -{ -} - -serializer:: -serializer () - : impl_ (new serializer_impl) -{ -} - -void serializer:: -start (ostream& os, const string& encoding) -{ - impl_->start (os, encoding); -} - -DOMElement* serializer:: -create (const string& name, const namespace_infomap& map) -{ - return impl_->create (name, map); -} - -DOMElement* serializer:: -create (const string& ns, const string& qname, const namespace_infomap& map) -{ - return impl_->create (ns, qname, map); -} - -void serializer:: -serialize (xml::dom::auto_ptr e) -{ - impl_->serialize (e); -} - -void serializer:: -serialize_open (xml::dom::auto_ptr e) -{ - impl_->serialize_open (e); -} - -void serializer:: -serialize_close (const string& name) -{ - impl_->serialize_close (name); -} diff --git a/examples/cxx/tree/streaming/serializer.hxx b/examples/cxx/tree/streaming/serializer.hxx deleted file mode 100644 index 43fab69..0000000 --- a/examples/cxx/tree/streaming/serializer.hxx +++ /dev/null @@ -1,205 +0,0 @@ -// file : examples/cxx/tree/streaming/serializer.hxx -// author : Boris Kolpackov -// copyright : not copyrighted - public domain - -#ifndef SERIALIZER_HXX -#define SERIALIZER_HXX - -#include -#include -#include // std::auto_ptr - -#include - -#include -#include // namespace_infomap - -class serializer_impl; - -class serializer -{ -public: - typedef xsd::cxx::xml::dom::namespace_infomap namespace_infomap; - - ~serializer (); - serializer (); - - // Start the serialization process. - // - void - start (std::ostream& is, const std::string& encoding = "UTF-8"); - - // Serialize next object model fragment into an element with the specified - // name. - // - template - void - next (const std::string& name, const T& x); - - // Serialize next object model fragment into an element with the specified - // name and namespace declarations. - // - template - void - next (const std::string& name, const namespace_infomap&, const T& x); - - // Serialize next object model fragment into an element with the specified - // namespace and qualified name. - // - template - void - next (const std::string& ns, const std::string& name, const T& x); - - // Serialize next object model fragment into an element with the specified - // namespace and qualified name as well as namespace declarations. - // - template - void - next (const std::string& ns, - const std::string& name, - const namespace_infomap&, - const T& x); - - // The next_open/close functions are like next() but split into two steps. - // next_open() serializes the object model fragment into an element leaving - // it open while next_close() closes the element. - // - template - void - next_open (const std::string& name, const T& x); - - template - void - next_open (const std::string& name, const namespace_infomap&, const T& x); - - template - void - next_open (const std::string& ns, const std::string& name, const T& x); - - template - void - next_open (const std::string& ns, - const std::string& name, - const namespace_infomap&, - const T& x); - - void - next_close (const std::string& name); - -private: - serializer (const serializer&); - - serializer& - operator= (const serializer&); - -private: - xercesc::DOMElement* - create (const std::string& name, const namespace_infomap&); - - xercesc::DOMElement* - create (const std::string& ns, - const std::string& name, - const namespace_infomap&); - - void - serialize (xsd::cxx::xml::dom::auto_ptr); - - void - serialize_open (xsd::cxx::xml::dom::auto_ptr); - - void - serialize_close (const std::string& name); - -private: - std::auto_ptr impl_; -}; - -template -inline void serializer:: -next (const std::string& name, const T& x) -{ - xsd::cxx::xml::dom::auto_ptr e ( - create (name, namespace_infomap ())); - *e << x; - serialize (e); -} - -template -inline void serializer:: -next (const std::string& name, const namespace_infomap& map, const T& x) -{ - xsd::cxx::xml::dom::auto_ptr e (create (name, map)); - *e << x; - serialize (e); -} - -template -inline void serializer:: -next (const std::string& ns, const std::string& name, const T& x) -{ - xsd::cxx::xml::dom::auto_ptr e ( - create (ns, name, namespace_infomap ())); - *e << x; - serialize (e); -} - -template -inline void serializer:: -next (const std::string& ns, - const std::string& name, - const namespace_infomap& map, - const T& x) -{ - xsd::cxx::xml::dom::auto_ptr e (create (ns, name, map)); - *e << x; - serialize (e); -} - -template -inline void serializer:: -next_open (const std::string& name, const T& x) -{ - xsd::cxx::xml::dom::auto_ptr e ( - create (name, namespace_infomap ())); - *e << x; - serialize_open (e); -} - -template -inline void serializer:: -next_open (const std::string& name, const namespace_infomap& map, const T& x) -{ - xsd::cxx::xml::dom::auto_ptr e (create (name, map)); - *e << x; - serialize_open (e); -} - -template -inline void serializer:: -next_open (const std::string& ns, const std::string& name, const T& x) -{ - xsd::cxx::xml::dom::auto_ptr e ( - create (ns, name, namespace_infomap ())); - *e << x; - serialize_open (e); -} - -template -inline void serializer:: -next_open (const std::string& ns, - const std::string& name, - const namespace_infomap& map, - const T& x) -{ - xsd::cxx::xml::dom::auto_ptr e (create (ns, name, map)); - *e << x; - serialize_open (e); -} - -inline void serializer:: -next_close (const std::string& name) -{ - serialize_close (name); -} - -#endif // SERIALIZER_HXX diff --git a/examples/cxx/tree/wildcard/README b/examples/cxx/tree/wildcard/README deleted file mode 100644 index d451509..0000000 --- a/examples/cxx/tree/wildcard/README +++ /dev/null @@ -1,34 +0,0 @@ -This example shows how to use the optional wildcard mapping provided -by C++/Tree to parse, access, modify, and serialize the XML data -matched by XML Schema wildcards (any and anyAttribute). For an -alternative approach that employes type customization see the -custom/wildcard example. - -The example consists of the following files: - -email.xsd - XML Schema which describes a simple email format with the - extensible envelope type. - -email.xml - Sample email message. - -email.hxx -email.ixx -email.cxx - C++ types that represent the given 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 email.xsd. - Note that the --generate-wildcard option is used to request the - wildcard mapping. - -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 content of the object model to STDERR. Next the driver creates a - reply email which is then serialized to XML. - -To run the example on the sample XML instance document simply execute: - -$ ./driver email.xml diff --git a/examples/cxx/tree/wildcard/driver.cxx b/examples/cxx/tree/wildcard/driver.cxx deleted file mode 100644 index 64acfce..0000000 --- a/examples/cxx/tree/wildcard/driver.cxx +++ /dev/null @@ -1,159 +0,0 @@ -// file : examples/cxx/tree/wildcard/driver.cxx -// copyright : not copyrighted - public domain - -#include -#include // std::auto_ptr -#include // std::memcpy -#include - -#include -#include - -#include "email.hxx" - -// The following string class keeps us sane when working with Xerces. -// Include it after the generated header in order to get only char or -// wchar_t version depending on how you compiled your schemas. -// -#include - -using std::cerr; -using std::endl; -using std::string; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " email.xml" << endl; - return 1; - } - - using namespace xercesc; - - int r (0); - - // The Xerces-C++ DOM objects that will be used to store the - // content matched by wildcards "out-live" the call to the - // parsing function. Therefore we need to initialize the - // Xerces-C++ runtime ourselves. - // - XMLPlatformUtils::Initialize (); - - try - { - using namespace email; - namespace xml = xsd::cxx::xml; - - // Read in the message. - // - std::auto_ptr msg ( - message (argv[1], xml_schema::flags::dont_initialize)); - - // Print what we've got. - // - cerr << "To: " << msg->to () << endl - << "From: " << msg->from () << endl - << "Subject: " << msg->subject () << endl; - - envelope::any_sequence& body (msg->any ()); - - for (envelope::any_iterator i (body.begin ()); i != body.end (); ++i) - { - DOMElement& e (*i); - string name (xml::transcode (e.getLocalName ())); - - if (name == "text") - { - // Create object representation for the text element. - // - xml_schema::string text (e); - - cerr << text << endl - << endl; - } - else if (name == "binary") - { - // Create object representation for the binary element. - // - binary bin (e); - - cerr << "binary: " << bin.name () << " type: " << bin.mime () << endl - << endl; - } - else - { - cerr << "unknown body type: " << name << endl; - } - } - - // Create a reply message. - // - envelope reply (msg->from (), msg->to (), "Re: " + msg->subject ()); - - // Copy the thread-id attribute from the original message if any. - // - envelope::any_attribute_set& as (msg->any_attribute ()); - envelope::any_attribute_iterator ti ( - as.find ("http://www.codesynthesis.com/email", "thread-id")); - - if (ti != as.end ()) - reply.any_attribute ().insert (*ti); - - // Add a text body. - // - DOMDocument& doc (reply.dom_document ()); - envelope::any_sequence& rbody (reply.any ()); - - xml_schema::string text ("Hi!\n\n" - "Indeed nice pictures. Check out mine.\n\n" - "Jane"); - - DOMElement* e ( - doc.createElementNS ( - xml::string ("http://www.codesynthesis.com/email").c_str (), - xml::string ("eml:text").c_str ())); - - *e << text; - rbody.push_back (e); - - // Add a (fake) image. - // - binary pic ("pic.jpg", "image/jpeg"); - pic.size (3); - std::memcpy (pic.data (), "123", 3); - - e = doc.createElementNS ( - xml::string ("http://www.codesynthesis.com/email").c_str (), - xml::string ("eml:binary").c_str ()); - - *e << pic; - rbody.push_back (e); - - - // Prepare namespace mapping and schema location information for - // serialization. - // - xml_schema::namespace_infomap map; - - map["eml"].name = "http://www.codesynthesis.com/email"; - map["eml"].schema = "email.xsd"; - - // Write it out. - // - message (std::cout, - reply, - map, - "UTF-8", - xml_schema::flags::dont_initialize); - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - r = 1; - } - - XMLPlatformUtils::Terminate (); - return r; -} diff --git a/examples/cxx/tree/wildcard/email.xml b/examples/cxx/tree/wildcard/email.xml deleted file mode 100644 index 9272d5c..0000000 --- a/examples/cxx/tree/wildcard/email.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - Jane Doe <jane@doe.com> - John Doe <john@doe.com> - Surfing pictures - - -Hi Jane, - -Here are cool pictures of me surfing. - -Cheers, -John - - - YmFzZTY0IGJpbmFyeQ== - YmFzZTY0IGJpbmFyeQ== - - diff --git a/examples/cxx/tree/wildcard/email.xsd b/examples/cxx/tree/wildcard/email.xsd deleted file mode 100644 index 239cb9d..0000000 --- a/examples/cxx/tree/wildcard/email.xsd +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/cxx/tree/wildcard/makefile b/examples/cxx/tree/wildcard/makefile deleted file mode 100644 index 84064c1..0000000 --- a/examples/cxx/tree/wildcard/makefile +++ /dev/null @@ -1,101 +0,0 @@ -# file : examples/cxx/tree/wildcard/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := email.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) - -$(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-inline --generate-wildcard \ ---generate-serialization --root-element message -$(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)/email.xsd,$(install_doc_dir)/xsd/$(path)/email.xsd) - $(call install-data,$(src_base)/email.xml,$(install_doc_dir)/xsd/$(path)/email.xml) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/email.xsd,$(dist_prefix)/$(path)/email.xsd) - $(call install-data,$(src_base)/email.xml,$(dist_prefix)/$(path)/email.xml) - -$(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/xpath/README b/examples/cxx/tree/xpath/README deleted file mode 100644 index 1187743..0000000 --- a/examples/cxx/tree/xpath/README +++ /dev/null @@ -1,43 +0,0 @@ -This example shows how to use the C++/Tree mapping together with XPath. -In particular, it shows how to execute an XPath query on the underlying -DOM document and then handle the result using the more convenient object -model representation. For more information on maintaining association -with the underlying DOM document, refer to Section 5.1, "DOM Association" -in the C++/Tree Mapping User Manual. - -You will need the XQilla library[1] which provides XQuery and XPath 2 -support on top of Xerces-C++ in order to build and run this example. - -[1] http://xqilla.sourceforge.net - -The example consists of the following files: - -people.xsd - XML Schema definition for a simple person record vocabulary. - -people.xml - Sample XML instance document. - -people.hxx -people.cxx - C++ types that represent the person record 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 people.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 using XQilla-provided DOM - Implementation with support for XPath 2. It then parses the DOM - document to the object model. Finally, it prepares and executes - an XPath query on the underlying DOM document and then handles - the result by getting back from the returned DOM nodes to object - model nodes. - -To run the example on the sample XML document simply execute: - -$ ./driver people.xml diff --git a/examples/cxx/tree/xpath/dom-parse.cxx b/examples/cxx/tree/xpath/dom-parse.cxx deleted file mode 100644 index 0282780..0000000 --- a/examples/cxx/tree/xpath/dom-parse.cxx +++ /dev/null @@ -1,88 +0,0 @@ -// file : examples/cxx/tree/xpath/dom-parse.cxx -// copyright : not copyrighted - public domain - -#include "dom-parse.hxx" - -#include - -#include -#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, - DOMImplementation* impl) -{ - 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/xpath/dom-parse.hxx b/examples/cxx/tree/xpath/dom-parse.hxx deleted file mode 100644 index 9fa0eb9..0000000 --- a/examples/cxx/tree/xpath/dom-parse.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : examples/cxx/tree/xpath/dom-parse.hxx -// copyright : not copyrighted - public domain - -#ifndef DOM_PARSE -#define DOM_PARSE - -#include -#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, - xercesc::DOMImplementation*); - -#endif // DOM_PARSE diff --git a/examples/cxx/tree/xpath/driver.cxx b/examples/cxx/tree/xpath/driver.cxx deleted file mode 100644 index f9bd040..0000000 --- a/examples/cxx/tree/xpath/driver.cxx +++ /dev/null @@ -1,136 +0,0 @@ -// file : examples/cxx/tree/xpath/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include -#include -#include - -#include - -#include - -#include // xml::string, xml::transcode - -#include "dom-parse.hxx" - -#include "people.hxx" - -using namespace std; -using namespace xercesc; -namespace xml = xsd::cxx::xml; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " people.xml" << endl; - return 1; - } - - int r (0); - - // Initialise Xerces-C++ and XQilla. - // - XQillaPlatformUtils::initialize(); - - // Get the XQilla DOMImplementation object with support for XPath. - // - DOMImplementation* impl ( - DOMImplementationRegistry::getDOMImplementation( - xml::string ("XPath2 3.0").c_str ())); - - try - { - using namespace people; - - ifstream ifs; - ifs.exceptions (ifstream::badbit | ifstream::failbit); - ifs.open (argv[1]); - - // Parse the XML file to DOM using the XQilla DOMImplementation. - // - xml_schema::dom::auto_ptr dom ( - parse (ifs, argv[1], true, impl)); - - // Parse the DOM document to the object model. We also request that - // the DOM document to be associated with the object model. - // - std::auto_ptr d ( - directory_ (dom, - xml_schema::flags::keep_dom | xml_schema::flags::own_dom)); - - // Obtain the root element and document corresponding to the - // directory object. - // - DOMElement* root (static_cast (d->_node ())); - DOMDocument* doc (root->getOwnerDocument ()); - - // Obtain namespace resolver. - // - xml_schema::dom::auto_ptr resolver ( - doc->createNSResolver (root)); - - // Set the namespace prefix for the people namespace that we can - // use reliably in XPath expressions regardless of what is used - // in XML documents. - // - resolver->addNamespaceBinding ( - xml::string ("p").c_str (), - xml::string ("http://www.codesynthesis.com/people").c_str ()); - - // Create XPath expression. - // - xml_schema::dom::auto_ptr expr ( - doc->createExpression ( - xml::string ("p:directory/person[age > 30]").c_str (), - resolver.get ())); - - // Execute the query. - // - xml_schema::dom::auto_ptr r ( - expr->evaluate (doc, DOMXPathResult::ITERATOR_RESULT_TYPE, 0)); - - // Iterate over the result. - // - cerr << "Records matching the query:" << endl; - - while (r->iterateNext ()) - { - DOMNode* n (r->getNodeValue ()); - - // Obtain the object model node corresponding to this DOM node. - // - person* p ( - static_cast ( - n->getUserData (xml_schema::dom::tree_node_key))); - - // Print the data using the object model. - // - cerr << endl - << "First : " << p->first_name () << endl - << "Last : " << p->last_name () << endl - << "Gender : " << p->gender () << endl - << "Age : " << p->age () << endl; - } - } - catch(const DOMException& e) - { - cerr << xml::transcode (e.getMessage ()) << std::endl; - r = 1; - } - 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; - } - - XQillaPlatformUtils::terminate(); - return r; -} diff --git a/examples/cxx/tree/xpath/makefile b/examples/cxx/tree/xpath/makefile deleted file mode 100644 index 3f5a3b0..0000000 --- a/examples/cxx/tree/xpath/makefile +++ /dev/null @@ -1,122 +0,0 @@ -# file : examples/cxx/tree/xpath/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := people.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) - -ifeq ($(filter $(MAKECMDGOALS),dist dist-win install),) -$(call import,\ - $(scf_root)/import/libxqilla/stub.make,\ - l: xqilla.l,cpp-options: xqilla.l.cpp-options) -endif - - -# Build. -# -$(driver): $(obj) $(xqilla.l) $(xerces_c.l) - -$(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd -$(obj) $(dep): $(xqilla.l.cpp-options) $(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): $(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)/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)/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): |$(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,xpath-vc8.sln) - $(call meta-vc9sln,$(src_root)/dist/template-vc9.sln,xpath-vc9.sln) - $(call meta-vc10sln,$(src_root)/dist/template-vc10.sln,xpath-vc10.sln) - $(call meta-vc11sln,$(src_root)/dist/template-vc11.sln,xpath-vc11.sln) - $(call meta-vc12sln,$(src_root)/dist/template-vc12.sln,xpath-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) diff --git a/examples/cxx/tree/xpath/people.xml b/examples/cxx/tree/xpath/people.xml deleted file mode 100644 index 9ad9ab6..0000000 --- a/examples/cxx/tree/xpath/people.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - John - Doe - male - 32 - - - - Jane - Doe - female - 28 - - - diff --git a/examples/cxx/tree/xpath/people.xsd b/examples/cxx/tree/xpath/people.xsd deleted file mode 100644 index 5be94de..0000000 --- a/examples/cxx/tree/xpath/people.xsd +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/makefile b/examples/makefile deleted file mode 100644 index 32f6336..0000000 --- a/examples/makefile +++ /dev/null @@ -1,19 +0,0 @@ -# file : examples/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make - -default := $(out_base)/ -install := $(out_base)/.install -dist := $(out_base)/.dist -dist-win := $(out_base)/.dist-win -clean := $(out_base)/.clean - -$(default): $(out_base)/cxx/parser/ $(out_base)/cxx/tree/ -$(install): $(out_base)/cxx/parser/.install $(out_base)/cxx/tree/.install -$(dist): $(out_base)/cxx/parser/.dist $(out_base)/cxx/tree/.dist -$(dist-win): $(out_base)/cxx/parser/.dist-win $(out_base)/cxx/tree/.dist-win -$(clean): $(out_base)/cxx/parser/.clean $(out_base)/cxx/tree/.clean - -$(call import,$(src_base)/cxx/parser/makefile) -$(call import,$(src_base)/cxx/tree/makefile) diff --git a/libxsd-tests/.gitignore b/libxsd-tests/.gitignore new file mode 100644 index 0000000..1b1f9fb --- /dev/null +++ b/libxsd-tests/.gitignore @@ -0,0 +1,28 @@ +# Compiler/linker output. +# +*.d +*.t +*.i +*.ii +*.o +*.obj +*.so +*.dll +*.a +*.lib +*.exp +*.pdb +*.ilk +*.exe +*.exe.dlls/ +*.exe.manifest +*.pc + +# Test executables. +# +driver + +# Testscript output directories (can be symlinks). +# +test +test-* diff --git a/libxsd-tests/FLOSSE b/libxsd-tests/FLOSSE new file mode 120000 index 0000000..be6df3d --- /dev/null +++ b/libxsd-tests/FLOSSE @@ -0,0 +1 @@ +../FLOSSE \ No newline at end of file diff --git a/libxsd-tests/GPLv2 b/libxsd-tests/GPLv2 new file mode 120000 index 0000000..08e5586 --- /dev/null +++ b/libxsd-tests/GPLv2 @@ -0,0 +1 @@ +../GPLv2 \ No newline at end of file diff --git a/libxsd-tests/LICENSE b/libxsd-tests/LICENSE new file mode 120000 index 0000000..ea5b606 --- /dev/null +++ b/libxsd-tests/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/libxsd-tests/README b/libxsd-tests/README new file mode 100644 index 0000000..1ab33da --- /dev/null +++ b/libxsd-tests/README @@ -0,0 +1,8 @@ +This package contains tests for the XSD to C++ data binding runtime library. + +See the LICENSE file for distribution conditions. + +The project page is at https://www.codesynthesis.com/projects/xsd/. + +Send bug reports or any other feedback to the xsd-users@codesynthesis.com +mailing list. diff --git a/libxsd-tests/build/.gitignore b/libxsd-tests/build/.gitignore new file mode 100644 index 0000000..4a730a3 --- /dev/null +++ b/libxsd-tests/build/.gitignore @@ -0,0 +1,3 @@ +config.build +root/ +bootstrap/ diff --git a/libxsd-tests/build/bootstrap.build b/libxsd-tests/build/bootstrap.build new file mode 100644 index 0000000..e10dbfc --- /dev/null +++ b/libxsd-tests/build/bootstrap.build @@ -0,0 +1,9 @@ +# file : build/bootstrap.build +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +project = libxsd-tests + +using version +using config +using dist +using test diff --git a/libxsd-tests/build/root.build b/libxsd-tests/build/root.build new file mode 100644 index 0000000..d511eb2 --- /dev/null +++ b/libxsd-tests/build/root.build @@ -0,0 +1,25 @@ +# file : build/root.build +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +cxx.std = latest + +using cxx + +hxx{*}: extension = hxx +ixx{*}: extension = ixx +txx{*}: extension = txx +cxx{*}: extension = cxx + +if ($cxx.target.system == 'win32-msvc') + cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + +if ($cxx.class == 'msvc') + cxx.coptions += /wd4251 /wd4275 /wd4800 + +# Every exe{} in this project is by default a test. +# +exe{*}: test = true + +# Specify the test target for cross-testing. +# +test.target = $cxx.target diff --git a/libxsd-tests/buildfile b/libxsd-tests/buildfile new file mode 100644 index 0000000..e783791 --- /dev/null +++ b/libxsd-tests/buildfile @@ -0,0 +1,4 @@ +# file : buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +./: {*/ -build/} doc{README} legal{GPLv2 LICENSE FLOSSE} manifest diff --git a/libxsd-tests/cxx/parser/expat/basic/buildfile b/libxsd-tests/cxx/parser/expat/basic/buildfile new file mode 100644 index 0000000..86279d4 --- /dev/null +++ b/libxsd-tests/cxx/parser/expat/basic/buildfile @@ -0,0 +1,7 @@ +# file : cxx/parser/expat/basic/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libexpat%lib{expat} + +exe{driver}: cxx{driver} $libs testscript diff --git a/libxsd-tests/cxx/parser/expat/basic/driver.cxx b/libxsd-tests/cxx/parser/expat/basic/driver.cxx new file mode 100644 index 0000000..f601e7a --- /dev/null +++ b/libxsd-tests/cxx/parser/expat/basic/driver.cxx @@ -0,0 +1,124 @@ +// file : cxx/parser/expat/basic/driver.cxx +// copyright : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include + +// Define XSD_CXX11 since we include libxsd headers directly. +// +#ifdef _MSC_VER +# if _MSC_VER >= 1600 // VC++10 and later have C++11 always enabled. +# define XSD_CXX11 +# endif +#else +# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L +# define XSD_CXX11 +# endif +#endif + +#include // XSD_UNUSED +#include + +#include + +#include +#include +#include + +using namespace std; +using namespace xsd::cxx; + +typedef parser::non_validating::string_pskel string_pskel; + +class hello_pimpl: public parser::non_validating::complex_content +{ +public: + hello_pimpl (string_pskel& greeting, string_pskel& name) + : greeting_parser_ (&greeting), + name_parser_ (&name) {} + +private: + virtual bool + _start_element_impl (const ro_string&, + const ro_string&, + const ro_string*); + + virtual bool + _end_element_impl (const ro_string&, const ro_string&); + + string_pskel* greeting_parser_; + string_pskel* name_parser_; +}; + +bool hello_pimpl:: +_start_element_impl (const ro_string& ns, + const ro_string& n, + const ro_string* t) +{ + XSD_UNUSED (t); + + if (complex_content::_start_element_impl (ns, n, t)) + return true; + + if (n == "greeting" && ns.empty ()) + { + context_.top ().parser_ = greeting_parser_; + + if (greeting_parser_) + greeting_parser_->pre (); + + return true; + } + + if (n == "name" && ns.empty ()) + { + context_.top ().parser_ = name_parser_; + + if (name_parser_) + name_parser_->pre (); + + return true; + } + + return false; +} + +bool hello_pimpl:: +_end_element_impl (const ro_string& ns, const ro_string& n) +{ + if (complex_content::_end_element_impl (ns, n)) + return true; + + if (n == "greeting" && ns.empty ()) + { + cout << n << ' ' << greeting_parser_->post_string () << endl; + return true; + } + + if (n == "name" && ns.empty ()) + { + cout << n << ' ' << name_parser_->post_string () << endl; + return true; + } + + return false; +} + + +// Usage: argv[0] +// +// Parse the specified XML file using the event-driven skeleton-based parser +// and print the element names and values to stdout. +// +int +main (int argc, char* argv[]) +{ + assert (argc == 2); + + parser::non_validating::string_pimpl string_p; + hello_pimpl hello_p (string_p, string_p); + + parser::expat::document doc_p (hello_p, "hello"); + + doc_p.parse (argv[1]); +} diff --git a/libxsd-tests/cxx/parser/expat/basic/testscript b/libxsd-tests/cxx/parser/expat/basic/testscript new file mode 100644 index 0000000..7e78e73 --- /dev/null +++ b/libxsd-tests/cxx/parser/expat/basic/testscript @@ -0,0 +1,41 @@ +# file : cxx/parser/expat/basic/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +: basic +: +{ + cat <=hello.xsd; + + + + + + + + + + + + + EOI + + cat <=hello.xml; + + + + Hello + + sun + moon + world + + EOI + + $* hello.xml >>EOO + greeting Hello + name sun + name moon + name world + EOO +} diff --git a/libxsd-tests/cxx/parser/xerces/basic/buildfile b/libxsd-tests/cxx/parser/xerces/basic/buildfile new file mode 100644 index 0000000..237629d --- /dev/null +++ b/libxsd-tests/cxx/parser/xerces/basic/buildfile @@ -0,0 +1,7 @@ +# file : cxx/parser/xerces/basic/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: cxx{driver} $libs testscript diff --git a/libxsd-tests/cxx/parser/xerces/basic/driver.cxx b/libxsd-tests/cxx/parser/xerces/basic/driver.cxx new file mode 100644 index 0000000..b7dfd1d --- /dev/null +++ b/libxsd-tests/cxx/parser/xerces/basic/driver.cxx @@ -0,0 +1,124 @@ +// file : cxx/parser/xerces/basic/driver.cxx +// copyright : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include + +// Define XSD_CXX11 since we include libxsd headers directly. +// +#ifdef _MSC_VER +# if _MSC_VER >= 1600 // VC++10 and later have C++11 always enabled. +# define XSD_CXX11 +# endif +#else +# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L +# define XSD_CXX11 +# endif +#endif + +#include // XSD_UNUSED +#include + +#include + +#include +#include +#include + +using namespace std; +using namespace xsd::cxx; + +typedef parser::non_validating::string_pskel string_pskel; + +class hello_pimpl: public parser::non_validating::complex_content +{ +public: + hello_pimpl (string_pskel& greeting, string_pskel& name) + : greeting_parser_ (&greeting), + name_parser_ (&name) {} + +private: + virtual bool + _start_element_impl (const ro_string&, + const ro_string&, + const ro_string*); + + virtual bool + _end_element_impl (const ro_string&, const ro_string&); + + string_pskel* greeting_parser_; + string_pskel* name_parser_; +}; + +bool hello_pimpl:: +_start_element_impl (const ro_string& ns, + const ro_string& n, + const ro_string* t) +{ + XSD_UNUSED (t); + + if (complex_content::_start_element_impl (ns, n, t)) + return true; + + if (n == "greeting" && ns.empty ()) + { + context_.top ().parser_ = greeting_parser_; + + if (greeting_parser_) + greeting_parser_->pre (); + + return true; + } + + if (n == "name" && ns.empty ()) + { + context_.top ().parser_ = name_parser_; + + if (name_parser_) + name_parser_->pre (); + + return true; + } + + return false; +} + +bool hello_pimpl:: +_end_element_impl (const ro_string& ns, const ro_string& n) +{ + if (complex_content::_end_element_impl (ns, n)) + return true; + + if (n == "greeting" && ns.empty ()) + { + cout << n << ' ' << greeting_parser_->post_string () << endl; + return true; + } + + if (n == "name" && ns.empty ()) + { + cout << n << ' ' << name_parser_->post_string () << endl; + return true; + } + + return false; +} + + +// Usage: argv[0] +// +// Parse the specified XML file using the event-driven skeleton-based parser +// and print the element names and values to stdout. +// +int +main (int argc, char* argv[]) +{ + assert (argc == 2); + + parser::non_validating::string_pimpl string_p; + hello_pimpl hello_p (string_p, string_p); + + parser::xerces::document doc_p (hello_p, "hello"); + + doc_p.parse (argv[1]); +} diff --git a/libxsd-tests/cxx/parser/xerces/basic/testscript b/libxsd-tests/cxx/parser/xerces/basic/testscript new file mode 100644 index 0000000..f11fb10 --- /dev/null +++ b/libxsd-tests/cxx/parser/xerces/basic/testscript @@ -0,0 +1,41 @@ +# file : cxx/parser/xerces/basic/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +: basic +: +{ + cat <=hello.xsd; + + + + + + + + + + + + + EOI + + cat <=hello.xml; + + + + Hello + + sun + moon + world + + EOI + + $* hello.xml >>EOO + greeting Hello + name sun + name moon + name world + EOO +} diff --git a/libxsd-tests/cxx/tree/basic/buildfile b/libxsd-tests/cxx/tree/basic/buildfile new file mode 100644 index 0000000..1bf94b0 --- /dev/null +++ b/libxsd-tests/cxx/tree/basic/buildfile @@ -0,0 +1,7 @@ +# file : cxx/tree/basic/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{*} $libs testscript diff --git a/libxsd-tests/cxx/tree/basic/driver.cxx b/libxsd-tests/cxx/tree/basic/driver.cxx new file mode 100644 index 0000000..d36d31e --- /dev/null +++ b/libxsd-tests/cxx/tree/basic/driver.cxx @@ -0,0 +1,65 @@ +// file : cxx/tree/basic/driver.cxx +// copyright : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include + +#include +#include +#include + +// Define XSD_CXX11 since we include libxsd headers directly. +// +#ifdef _MSC_VER +# if _MSC_VER >= 1600 // VC++10 and later have C++11 always enabled. +# define XSD_CXX11 +# endif +#else +# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L +# define XSD_CXX11 +# endif +#endif + +#include + +#include // XSD_DOM_AUTO_PTR +#include // name() +#include // parser, parse() + +#include // text_content() +#include +#include // auto_initializer, properties +#include // parsing +#include + +using namespace std; +using namespace xsd::cxx; + +// Usage: argv[0] +// +// Parse the specified XML file using the XML DOM parser and print the element +// names and values to stdout. +// +int +main (int argc, char* argv[]) +{ + assert (argc == 2); + + xml::auto_initializer ai; + + tree::error_handler h; + tree::properties ps; + + XSD_DOM_AUTO_PTR d ( + xml::dom::parse (argv[1], h, ps, 0 /* flags */)); + + h.throw_if_failed> (); // Abort on error. + + xml::dom::parser p (*d->getDocumentElement (), true, false, false); + for (; p.more_content (); p.next_content (false /* text */)) + { + const xercesc::DOMElement& i (p.cur_element ()); + const xml::qualified_name n (xml::dom::name (i)); + cout << n.name () << ' ' << tree::text_content (i) << endl; + } +} diff --git a/libxsd-tests/cxx/tree/basic/testscript b/libxsd-tests/cxx/tree/basic/testscript new file mode 100644 index 0000000..2606688 --- /dev/null +++ b/libxsd-tests/cxx/tree/basic/testscript @@ -0,0 +1,73 @@ +# file : cxx/tree/basic/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +: basic +: +{ + cat <=hello.xsd; + + + + + + + + The hello_t type consists of a greeting phrase and a + collection of names to which this greeting applies. + + + + + + + + + The greeting element contains the greeting phrase + for this hello object. + + + + + + + + The name elements contains names to be greeted. + + + + + + + + + + + The hello element is a root of the Hello XML vocabulary. + Every conforming document should start with this element. + + + + + EOI + + cat <=hello.xml; + + + + Hello + + sun + moon + world + + + EOI + + $* hello.xml >>EOO + greeting Hello + name sun + name moon + name world + EOO +} diff --git a/libxsd-tests/manifest b/libxsd-tests/manifest new file mode 100644 index 0000000..8de8b24 --- /dev/null +++ b/libxsd-tests/manifest @@ -0,0 +1,15 @@ +: 1 +name: libxsd-tests +version: 4.2.0-b.1.z +project: xsd +summary: XML Schema to C++ data binding compiler runtime library tests +license: other: GPL-2.0-only with Xerces-C++ linking exception and FLOSS exception +description-file: README +url: https://www.codesynthesis.com/projects/xsd/ +doc-url: https://www.codesynthesis.com/projects/xsd/ +src-url: https://git.codesynthesis.com/cgit/xsd/xsd/tree/libxsd-tests/ +email: xsd-users@codesynthesis.com ; Mailing list +depends: * build2 >= 0.13.0 +depends: * bpkg >= 0.13.0 +depends: libxerces-c ^3.0.0 +depends: libexpat ^2.1.0 diff --git a/libxsd/.gitignore b/libxsd/.gitignore new file mode 100644 index 0000000..cece09c --- /dev/null +++ b/libxsd/.gitignore @@ -0,0 +1,19 @@ +# Compiler/linker output. +# +*.d +*.t +*.i +*.ii +*.o +*.obj +*.so +*.dll +*.a +*.lib +*.exp +*.pdb +*.ilk +*.exe +*.exe.dlls/ +*.exe.manifest +*.pc diff --git a/libxsd/FLOSSE b/libxsd/FLOSSE deleted file mode 100644 index cbf8b2c..0000000 --- a/libxsd/FLOSSE +++ /dev/null @@ -1,89 +0,0 @@ -1. Intent - -We want specified Free/Libre and Open Source Software ("FLOSS") to be -able to use the specified GPL-licensed XSD runtime library (libxsd) and -XSD generated code (collectively called the "Program") despite the fact -that not all FLOSS licenses are compatible with version 2 of the GNU -General Public License (the "GPL"). - -It is our intent to allow distribution of the entire Derivative Work -(including the Program) under one or more of the FLOSS licenses listed -in section 3 (section 2.a). It is also our intent to disallow simple -relicensing of the Program for the sole purpose of using it in -proprietary applications (section 2.b and 2.c). As an example, consider -two hypothetical scenarios: - - a) You created a program that uses the XSD generated code and the XSD - runtime library to access information in XML instance documents. - Your program performs useful computations based on this information - (sections 2.b and 2.c are satisfied). You distribute your program, - including the XSD generated code and the XSD runtime library under - the BSD license and make it available at no charge to all third - parties (section 2.a is satisfied). Later you (or someone else) may - choose to base their proprietary application on your code since the - BSD license does not prohibit it. - - This scenario falls under this FLOSS Exception. - - - b) You created a library that uses the XSD generated code and the XSD - runtime library to access information in XML instance documents. You - did not add to the library any other useful code that uses the XSD - generated code or the XSD runtime library (neither section 2.b nor - 2.c is satisfied). You distribute your library, including the XSD - generated code and the XSD runtime library under the BSD license and - make it available at no charge to all third parties (section 2.a - is satisfied). Later you base your proprietary application on this - library since the BSD license does not prohibit it. - - This scenario does not fall under this FLOSS Exception (neither - section 2.b nor 2.c is satisfied). You created the library for the - sole purpose of making the XSD generated code and the XSD runtime - library available to your proprietary application. - - -2. Legal Terms and Conditions - -As a special exception to the terms and conditions of version 2 of -the GPL you are free to distribute a verbatim copy of the Program -as part of the Derivative Work that is formed from the Program or -any part thereof and one or more works (each, a "FLOSS Work") as -long as you also meet all of these conditions: - - a) You must cause the Derivative Work that in whole or in part - contains or is derived from the Program or any part thereof, - to be licensed as a whole at no charge to all third parties - under the terms of one or more of the licenses listed in - section 3. - - b) The Derivative Work should contain one or more FLOSS Work that - can be reasonably considered as derived from the Program or some - part thereof. - - c) The Derivative Work should not contain any part of the Program - that cannot be reasonably considered as a base of one or more - FLOSS Work. - - -3. FLOSS License List - - a) Any license listed in the "GPL-Compatible Free Software Licenses" - and the "GPL-Incompatible Free Software Licenses" sections of the - License List as published by the Free Software Foundation (FSF): - - http://www.gnu.org/licenses/license-list.html - - -4. Definitions - -Terms used, but not defined, herein shall have the meaning provided in -the GPL. - -Derivative Work means a derivative work under copyright law. - - -5. Applicability - -You may choose to redistribute a copy of the Program exclusively under -the terms of the GPL by removing the FLOSS Exception notice from that -copy of the Program. diff --git a/libxsd/FLOSSE b/libxsd/FLOSSE new file mode 120000 index 0000000..be6df3d --- /dev/null +++ b/libxsd/FLOSSE @@ -0,0 +1 @@ +../FLOSSE \ No newline at end of file diff --git a/libxsd/GPLv2 b/libxsd/GPLv2 deleted file mode 100644 index 3912109..0000000 --- a/libxsd/GPLv2 +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/libxsd/GPLv2 b/libxsd/GPLv2 new file mode 120000 index 0000000..08e5586 --- /dev/null +++ b/libxsd/GPLv2 @@ -0,0 +1 @@ +../GPLv2 \ No newline at end of file diff --git a/libxsd/INSTALL b/libxsd/INSTALL index c9b4625..181de1b 100644 --- a/libxsd/INSTALL +++ b/libxsd/INSTALL @@ -1,17 +1,6 @@ -Prerequisites +The easiest way to build this package is with the bpkg package manager: - run-time: - - - libxerces-c >= 3.0.0 http://xerces.apache.org/xerces-c/ - - -Building libxsd - - No building is necessary at the moment. - - -Installing libxsd - - Not supported in this version. You may want to copy libxsd/xsd - to $(prefix)/include so that you have $(prefix)/include/xsd/*. +$ bpkg build libxsd +But if you don't want to use the package manager, then you can also build it +manually using the standard build2 build system. diff --git a/libxsd/LICENSE b/libxsd/LICENSE deleted file mode 100644 index 7bd52e7..0000000 --- a/libxsd/LICENSE +++ /dev/null @@ -1,28 +0,0 @@ -Copyright (c) 2009-2020 Code Synthesis Tools CC. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License version 2 as -published by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -In addition, as a special exception, Code Synthesis Tools CC gives -permission to link this program with the Xerces-C++ library (or with -modified versions of Xerces-C++ that use the same license as Xerces-C++), -and distribute linked combinations including the two. You must obey -the GNU General Public License version 2 in all respects for all of -the code used other than Xerces-C++. If you modify this copy of the -program, you may extend this exception to your version of the program, -but you are not obligated to do so. If you do not wish to do so, delete -this exception statement from your version. - -In addition, Code Synthesis Tools CC makes a special exception for -the Free/Libre and Open Source Software (FLOSS) which is described -in the accompanying FLOSSE file. diff --git a/libxsd/LICENSE b/libxsd/LICENSE new file mode 120000 index 0000000..ea5b606 --- /dev/null +++ b/libxsd/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/libxsd/NEWS b/libxsd/NEWS new file mode 100644 index 0000000..c51e267 --- /dev/null +++ b/libxsd/NEWS @@ -0,0 +1 @@ +See the common NEWS file in the XSD compiler package. diff --git a/libxsd/README b/libxsd/README index 71f4f46..00f8e1d 100644 --- a/libxsd/README +++ b/libxsd/README @@ -1,12 +1,13 @@ -libxsd is a runtime library for language mappings generated by -CodeSynthesis XSD, a W3C XML Schema to C++ data binding compiler. +libxsd is a runtime library for language mappings generated by CodeSynthesis +XSD, a W3C XML Schema to C++ data binding compiler. See the LICENSE file for distribution conditions. See the INSTALL file for prerequisites and installation instructions. +See the doc/ directory for documentation. + The project page is at https://www.codesynthesis.com/projects/xsd/ Send bug reports or any other feedback to the xsd-users@codesynthesis.com mailing list. - diff --git a/libxsd/README-GIT b/libxsd/README-GIT new file mode 100644 index 0000000..bbc5b4c --- /dev/null +++ b/libxsd/README-GIT @@ -0,0 +1,4 @@ +The checked out xsd/cxx/version.hxx will be overwritten during the build +process but these changes should be ignored. To do this automatically, run: + +git update-index --assume-unchanged xsd/cxx/version.hxx diff --git a/libxsd/build/.gitignore b/libxsd/build/.gitignore new file mode 100644 index 0000000..4a730a3 --- /dev/null +++ b/libxsd/build/.gitignore @@ -0,0 +1,3 @@ +config.build +root/ +bootstrap/ diff --git a/libxsd/build/bootstrap.build b/libxsd/build/bootstrap.build new file mode 100644 index 0000000..d3dae6e --- /dev/null +++ b/libxsd/build/bootstrap.build @@ -0,0 +1,10 @@ +# file : build/bootstrap.build +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +project = libxsd + +using version +using config +using dist +using test +using install diff --git a/libxsd/build/export.build b/libxsd/build/export.build new file mode 100644 index 0000000..14a17c0 --- /dev/null +++ b/libxsd/build/export.build @@ -0,0 +1,9 @@ +# file : build/export.build +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +$out_root/ +{ + include xsd/ +} + +export $out_root/xsd/lib{xsd} diff --git a/libxsd/build/root.build b/libxsd/build/root.build new file mode 100644 index 0000000..82da455 --- /dev/null +++ b/libxsd/build/root.build @@ -0,0 +1,14 @@ +# file : build/root.build +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +using in + +cxx.std = latest + +using cxx + +# Note that this is a header-only library. +# +hxx{*}: extension = hxx +ixx{*}: extension = ixx +txx{*}: extension = txx diff --git a/libxsd/buildfile b/libxsd/buildfile new file mode 100644 index 0000000..abb2c7c --- /dev/null +++ b/libxsd/buildfile @@ -0,0 +1,8 @@ +# file : buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +./: {*/ -build/} doc{INSTALL NEWS README} legal{GPLv2 LICENSE FLOSSE} manifest + +# Don't the INSTALL file. +# +doc{INSTALL}@./: install = false diff --git a/libxsd/doc/buildfile b/libxsd/doc/buildfile new file mode 100644 index 0000000..c640a6c --- /dev/null +++ b/libxsd/doc/buildfile @@ -0,0 +1,83 @@ +# file : doc/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +define html: file +html{*}: extension = html + +define doxygen: file +doxygen{*}: extension = doxygen + +define doxytag: file +doxytag{*}: extension = doxytag + +# Import the doxygen program only if present on the system. This way a +# distribution that includes pre-generated files can be built without +# installing this programs. +# +import? doxygen = doxygen%exe{doxygen} + +# Note that we include the doxygen-generated files into the distribution and +# don't remove them when cleaning in src (so that clean results in a state +# identical to distributed). + +cxx/tree/reference/ +{ + # @@ Currently, there are the following issues that can only be addressed + # on the build2 level: + # + # - The update recipe is not re-executed after html/ directory content + # has changed or it is removed. + # + # - The clean operation doesn't remove the html/ directory. + # + # - The html/ directory is not installed nor distributed regardless of + # the doxygen presence. + # + if ($doxygen != [null]) + { + ../../../: doxytag{libxsd} + + headers = buffer types date-time elements element-map exceptions + + : doxygen{libxsd} \ + html{footer} \ + $src_root/xsd/cxx/tree/hxx{$headers} \ + $doxygen + { + dist = true + clean = ($src_root != $out_root) + } + {{ + diag doxygen $> : ($<[0]) # @@ TMP: revise + + rm -r -f $directory($>[1]) + + $doxygen $path($<[0]) + }} + + doxygen{libxsd}: in{libxsd} + { + in.symbol = '%' + + input = $regex.merge($headers, \ + '^(.*)$', \ + "$src_root/xsd/cxx/tree/\\1.hxx", \ + ' ') + } + + html{footer}: in{footer} + { + # Extract the copyright notice from the LICENSE file. + # + # Note that cat is a builtin which means this is both portable and fast. + # + copyright = $process.run_regex(cat $src_root/LICENSE, \ + 'Copyright \(c\) (.+)\.', \ + '\1') + } + } + else + ../../../: doxytag{+libxsd} +} + +doc{*}: install.subdirs = true diff --git a/libxsd/doc/cxx/tree/reference/.gitignore b/libxsd/doc/cxx/tree/reference/.gitignore new file mode 100644 index 0000000..e440fb6 --- /dev/null +++ b/libxsd/doc/cxx/tree/reference/.gitignore @@ -0,0 +1,4 @@ +html/ +libxsd.doxygen +libxsd.doxytag +footer.html diff --git a/libxsd/doc/cxx/tree/reference/footer.html.in b/libxsd/doc/cxx/tree/reference/footer.html.in new file mode 100644 index 0000000..7388387 --- /dev/null +++ b/libxsd/doc/cxx/tree/reference/footer.html.in @@ -0,0 +1,6 @@ +
+
+ Copyright © $copyright$. +
+ + diff --git a/libxsd/doc/cxx/tree/reference/libxsd.doxygen.in b/libxsd/doc/cxx/tree/reference/libxsd.doxygen.in new file mode 100644 index 0000000..c4625d8 --- /dev/null +++ b/libxsd/doc/cxx/tree/reference/libxsd.doxygen.in @@ -0,0 +1,1289 @@ +# Doxyfile 1.5.4 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file that +# follow. The default is UTF-8 which is also the encoding used for all text before +# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into +# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of +# possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = "C++/Tree Mapping Runtime Library" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, +# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, +# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, +# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = NO + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for Java. +# For instance, namespaces will be presented as packages, qualified scopes +# will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to +# include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = YES + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct (or union) is +# documented as struct with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code where the coding convention is that all structs are +# typedef'ed and only the typedef is referenced never the struct's name. + +TYPEDEF_HIDES_STRUCT = NO + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be extracted +# and appear in the documentation as a namespace called 'anonymous_namespace{file}', +# where file will be replaced with the base name of the file that contains the anonymous +# namespace. By default anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = YES + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = NO + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from the +# version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = YES + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = %input% + +# This tag can be used to specify the character encoding of the source files that +# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default +# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. +# See http://www.gnu.org/software/libiconv for the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the output. +# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, +# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. If you have enabled CALL_GRAPH or CALLER_GRAPH +# then you must also enable this option. If you don't then doxygen will produce +# a warning and turn it on anyway + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES (the default) +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES (the default) +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentstion. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = %out_base%/html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = %out_base%/footer.html + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be +# generated containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = YES + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = YES + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +# C++98 version. +# +PREDEFINED = XSD_AUTO_PTR=std::auto_ptr + +# C++11 version. +# +# PREDEFINED = XSD_AUTO_PTR=std::unique_ptr + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = %out_base%/libxsd.doxytag + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +# Note: deprecated as of 1.8. +# +#PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to +# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to +# specify the directory where the mscgen tool resides. If left empty the tool is assumed to +# be found in the default search path. + +# Note: deprecated as of 1.8. +# +#MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will +# generate a call dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable call graphs for selected +# functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will +# generate a caller dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable caller graphs for selected +# functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the number +# of direct children of the root node in a graph is already larger than +# MAX_DOT_GRAPH_NOTES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, which results in a white background. +# Warning: Depending on the platform used, enabling this option may lead to +# badly anti-aliased labels on the edges of a graph (i.e. they become hard to +# read). + +DOT_TRANSPARENT = YES + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO diff --git a/libxsd/makefile b/libxsd/makefile deleted file mode 100644 index 819a459..0000000 --- a/libxsd/makefile +++ /dev/null @@ -1,43 +0,0 @@ -# file : libxsd/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make - -install := $(out_base)/.install -dist := $(out_base)/.dist -dist-win := $(out_base)/.dist-win - - -# Install. -# -$(install): - $(call install-dir,$(src_base)/xsd,$(install_inc_dir)/xsd) - $(call install-data,$(src_base)/FLOSSE,$(install_doc_dir)/libxsd/FLOSSE) - $(call install-data,$(src_base)/GPLv2,$(install_doc_dir)/libxsd/GPLv2) - $(call install-data,$(src_base)/LICENSE,$(install_doc_dir)/libxsd/LICENSE) - $(call install-data,$(src_base)/README,$(install_doc_dir)/libxsd/README) - -# Dist. -# -dist-common := $(out_base)/.dist-common - -$(dist-common): - $(call install-dir,$(src_base)/xsd,$(dist_prefix)/libxsd/xsd) - -$(dist): $(dist-common) - $(call install-data,$(src_base)/GPLv2,$(dist_prefix)/libxsd/GPLv2) - $(call install-data,$(src_base)/FLOSSE,$(dist_prefix)/libxsd/FLOSSE) - $(call install-data,$(src_base)/LICENSE,$(dist_prefix)/libxsd/LICENSE) - $(call install-data,$(src_base)/README,$(dist_prefix)/libxsd/README) - -$(dist-win): $(dist-common) - $(call install-data,$(src_base)/GPLv2,$(dist_prefix)/libxsd/GPLv2.txt) - $(call message,,todos $(dist_prefix)/libxsd/GPLv2.txt) - $(call install-data,$(src_base)/FLOSSE,$(dist_prefix)/libxsd/FLOSSE.txt) - $(call message,,todos $(dist_prefix)/libxsd/FLOSSE.txt) - $(call install-data,$(src_base)/LICENSE,$(dist_prefix)/libxsd/LICENSE.txt) - $(call message,,todos $(dist_prefix)/libxsd/LICENSE.txt) - $(call install-data,$(src_base)/README,$(dist_prefix)/libxsd/README.txt) - $(call message,,todos $(dist_prefix)/libxsd/README.txt) - -$(call include,$(bld_root)/install.make) diff --git a/libxsd/manifest b/libxsd/manifest new file mode 100644 index 0000000..6715e28 --- /dev/null +++ b/libxsd/manifest @@ -0,0 +1,17 @@ +: 1 +name: libxsd +version: 4.2.0-b.1.z +project: xsd +summary: XML Schema to C++ data binding compiler runtime library +license: other: GPL-2.0-only with Xerces-C++ linking exception and FLOSS exception +topics: C++, XML, XML Schema, XML parser +description-file: README +changes-file: NEWS +url: https://www.codesynthesis.com/projects/xsd/ +doc-url: https://www.codesynthesis.com/projects/xsd/ +src-url: https://git.codesynthesis.com/cgit/xsd/xsd/tree/libxsd/ +email: xsd-users@codesynthesis.com ; Mailing list +build-warning-email: builds@codesynthesis.com +depends: * build2 >= 0.13.0 +depends: * bpkg >= 0.13.0 +tests: libxsd-tests == $ diff --git a/libxsd/xsd/buildfile b/libxsd/xsd/buildfile new file mode 100644 index 0000000..ef0d0c5 --- /dev/null +++ b/libxsd/xsd/buildfile @@ -0,0 +1,39 @@ +# file : xsd/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Note that libxsd includes headers of some third-party libraries (Xerces-C++, +# Expat, ACE) and APIs (XDR) into some of its headers. We consider +# functionality provided by these headers as optional and assume that libxsd +# dependents that require such functionality will handle the respective +# dependencies (in buildfiles, manifests, etc) themselves. An alternative would +# be to split libxsd into the hierarchy of libraries, but it doesn't feel very +# practical at the moment. +# +lib{xsd}: cxx/{hxx ixx txx}{** -version} cxx/hxx{version} + +# Include the generated version header into the distribution (so that we don't +# pick up an installed one) and don't remove it when cleaning in src (so that +# clean results in a state identical to distributed). +# +cxx/ +{ + hxx{version}: in{version} $src_root/manifest + hxx{version}: + { + dist = true + clean = ($src_root != $out_root) + } +} + +# Export options. +# +lib{xsd}: cxx.export.poptions = "-I$out_root" "-I$src_root" + +# Install into the xsd/ subdirectory of, say, /usr/include/ recreating +# subdirectories. +# +{hxx ixx txx}{*}: +{ + install = include/xsd/ + install.subdirs = true +} diff --git a/libxsd/xsd/cxx/tree/elements.hxx b/libxsd/xsd/cxx/tree/elements.hxx index 808b35e..be8fbeb 100644 --- a/libxsd/xsd/cxx/tree/elements.hxx +++ b/libxsd/xsd/cxx/tree/elements.hxx @@ -235,6 +235,8 @@ namespace xsd std::size_t index; }; + //@cond + bool operator== (const content_order&, const content_order&); @@ -244,8 +246,6 @@ namespace xsd bool operator< (const content_order&, const content_order&); - //@cond - // DOM user data keys. // template @@ -458,7 +458,9 @@ namespace xsd // anyType content API. // public: + //@cond typedef element_optional dom_content_optional; + //@endcond /** * @brief Return a read-only (constant) reference to the anyType @@ -1198,10 +1200,10 @@ namespace xsd dom_content_optional dom; }; - //@endcond - mutable XSD_AUTO_PTR content_; + //@endcond + private: container* container_; }; diff --git a/libxsd/xsd/cxx/tree/types.hxx b/libxsd/xsd/cxx/tree/types.hxx index 3355eb0..34eabd9 100644 --- a/libxsd/xsd/cxx/tree/types.hxx +++ b/libxsd/xsd/cxx/tree/types.hxx @@ -3123,7 +3123,9 @@ namespace xsd class base64_binary: public B, public buffer { public: + //@cond typedef typename buffer::size_t size_t; + //@endcond public: /** @@ -3342,7 +3344,9 @@ namespace xsd class hex_binary: public B, public buffer { public: + //@cond typedef typename buffer::size_t size_t; + //@endcond public: /** diff --git a/libxsd/xsd/cxx/version.hxx b/libxsd/xsd/cxx/version.hxx index c2948c3..e69de29 100644 --- a/libxsd/xsd/cxx/version.hxx +++ b/libxsd/xsd/cxx/version.hxx @@ -1,27 +0,0 @@ -// file : xsd/cxx/version.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef XSD_CXX_VERSION_HXX -#define XSD_CXX_VERSION_HXX - -// Version format is AABBCCDD where -// -// AA - major version number -// BB - minor version number -// CC - bugfix version number -// DD - alpha / beta (DD + 50) version number -// -// When DD is not 00, 1 is subtracted from AABBCC. For example: -// -// Version AABBCCDD -// 2.0.0 02000000 -// 2.1.0 02010000 -// 2.1.1 02010100 -// 2.2.0.a1 02019901 -// 3.0.0.b2 02999952 -// - -#define XSD_STR_VERSION "4.1.0.a11" -#define XSD_INT_VERSION 4009911L - -#endif // XSD_CXX_VERSION_HXX diff --git a/libxsd/xsd/cxx/version.hxx.in b/libxsd/xsd/cxx/version.hxx.in new file mode 100644 index 0000000..7f2e17a --- /dev/null +++ b/libxsd/xsd/cxx/version.hxx.in @@ -0,0 +1,43 @@ +// file : xsd/cxx/version.hxx.in +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_VERSION // Note: using the version macro itself. + +// The numeric version format is AAAAABBBBBCCCCCDDDE where: +// +// AAAAA - major version number +// BBBBB - minor version number +// CCCCC - bugfix version number +// DDD - alpha / beta (DDD + 500) version number +// E - final (0) / snapshot (1) +// +// When DDDE is not 0, 1 is subtracted from AAAAABBBBBCCCCC. For example: +// +// Version AAAAABBBBBCCCCCDDDE +// +// 0.1.0 0000000001000000000 +// 0.1.2 0000000001000020000 +// 1.2.3 0000100002000030000 +// 2.2.0-a.1 0000200001999990010 +// 3.0.0-b.2 0000299999999995020 +// 2.2.0-a.1.z 0000200001999990011 +// +#define LIBXSD_VERSION $libxsd.version.project_number$ULL +#define LIBXSD_VERSION_STR "$libxsd.version.project$" +#define LIBXSD_VERSION_ID "$libxsd.version.project_id$" +#define LIBXSD_VERSION_FULL "$libxsd.version$" + +#define LIBXSD_VERSION_MAJOR $libxsd.version.major$ +#define LIBXSD_VERSION_MINOR $libxsd.version.minor$ +#define LIBXSD_VERSION_PATCH $libxsd.version.patch$ + +#define LIBXSD_PRE_RELEASE $libxsd.version.pre_release$ + +#define LIBXSD_SNAPSHOT $libxsd.version.snapshot_sn$ULL +#define LIBXSD_SNAPSHOT_ID "$libxsd.version.snapshot_id$" + +// Note that Xerces and Expat compatibility is verified by the respective +// parsers (see parser/xerces/elements.hxx and parser/expat/elements.hxx for +// details). + +#endif // LIBXSD_VERSION diff --git a/libxsd/xsd/cxx/xml/char-utf8.txx b/libxsd/xsd/cxx/xml/char-utf8.txx index ba65397..a571ce9 100644 --- a/libxsd/xsd/cxx/xml/char-utf8.txx +++ b/libxsd/xsd/cxx/xml/char-utf8.txx @@ -115,20 +115,24 @@ namespace xsd rs[i + 3] = C ((u | 0x80UL) & 0xBFUL); u >>= 6; } + // Fall through. case 3: { rs[i + 2] = C ((u | 0x80UL) & 0xBFUL); u >>= 6; } + // Fall through. case 2: { rs[i + 1] = C ((u | 0x80UL) & 0xBFUL); u >>= 6; } + // Fall through. case 1: { rs[i] = C (u | first_byte_mask_[count]); } + // Fall through. } i += count; diff --git a/makefile b/makefile deleted file mode 100644 index acfe511..0000000 --- a/makefile +++ /dev/null @@ -1,102 +0,0 @@ -# file : makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make - -default := $(out_base)/ -test := $(out_base)/.test -install := $(out_base)/.install -dist := $(out_base)/.dist -dist-win := $(out_base)/.dist-win -dist-pre := $(out_base)/.dist-pre -clean := $(out_base)/.clean - -.PHONY: $(dist-pre) - -$(default): $(out_base)/xsd/ \ - $(out_base)/tests/ \ - $(out_base)/examples/ \ - $(out_base)/doc/ - -# Test. -# -$(test): $(out_base)/tests/.test - - -# Install. -# -$(install): $(out_base)/xsd/.install \ - $(out_base)/libxsd/.install \ - $(out_base)/examples/.install \ - $(out_base)/doc/.install - $(call install-dir,$(src_base)/dist/examples/build,$(install_doc_dir)/xsd/examples/build) - $(call install-dir,$(src_base)/dist/examples/cxx,$(install_doc_dir)/xsd/examples/cxx,-name makefile) - $(call install-data,$(src_base)/dist/examples/makefile,$(install_doc_dir)/xsd/examples/makefile) - $(call install-data,$(src_base)/FLOSSE,$(install_doc_dir)/xsd/FLOSSE) - $(call install-data,$(src_base)/GPLv2,$(install_doc_dir)/xsd/GPLv2) - $(call install-data,$(src_base)/LICENSE,$(install_doc_dir)/xsd/LICENSE) - $(call install-data,$(src_base)/NEWS,$(install_doc_dir)/xsd/NEWS) - $(call install-data,$(src_base)/dist/README-UNIX,$(install_doc_dir)/xsd/README) - - -# Dist. -# -$(dist): $(out_base)/xsd/.dist \ - $(out_base)/libxsd/.dist \ - $(out_base)/examples/.dist \ - $(out_base)/doc/.dist - $(call install-dir,$(src_base)/dist/examples/build,$(dist_prefix)/examples/build) - $(call install-dir,$(src_base)/dist/examples/cxx,$(dist_prefix)/examples/cxx,-name makefile) - $(call install-data,$(src_base)/dist/examples/makefile,$(dist_prefix)/examples/makefile) - $(call install-data,$(src_base)/dist/README-UNIX,$(dist_prefix)/README) - $(call install-data,$(src_base)/GPLv2,$(dist_prefix)/GPLv2) - $(call install-data,$(src_base)/FLOSSE,$(dist_prefix)/FLOSSE) - $(call install-data,$(src_base)/LICENSE,$(dist_prefix)/LICENSE) - $(call install-data,$(src_base)/NEWS,$(dist_prefix)/NEWS) - $(call install-data,$(src_base)/version,$(dist_prefix)/version) - -$(dist-win): $(dist-pre) \ - $(out_base)/xsd/.dist-win \ - $(out_base)/libxsd/.dist-win \ - $(out_base)/examples/.dist-win \ - $(out_base)/doc/.dist-win - $(call install-dir,$(src_base)/dist/etc,$(dist_prefix)/etc) - $(call install-dir,$(src_base)/dist/examples/build,$(dist_prefix)/examples/build) - $(call install-data,$(src_base)/dist/examples/tester.bat,$(dist_prefix)/examples/tester.bat) - $(call install-data,$(src_base)/dist/examples/makefile,$(dist_prefix)/examples/makefile) - $(call install-data,$(src_base)/dist/README-WINDOWS,$(dist_prefix)/README.txt) - $(call message,,todos $(dist_prefix)/README.txt) - $(call install-data,$(src_base)/dist/README-UNIX,$(dist_prefix)/README-CYGWIN.txt) - $(call message,,todos $(dist_prefix)/README-CYGWIN.txt) - $(call install-data,$(src_base)/GPLv2,$(dist_prefix)/GPLv2.txt) - $(call message,,todos $(dist_prefix)/GPLv2.txt) - $(call install-data,$(src_base)/FLOSSE,$(dist_prefix)/FLOSSE.txt) - $(call message,,todos $(dist_prefix)/FLOSSE.txt) - $(call install-data,$(src_base)/LICENSE,$(dist_prefix)/LICENSE.txt) - $(call message,,todos $(dist_prefix)/LICENSE.txt) - $(call install-data,$(src_base)/NEWS,$(dist_prefix)/NEWS.txt) - $(call message,,todos $(dist_prefix)/NEWS.txt) - $(call install-data,$(src_base)/version,$(dist_prefix)/version.txt) - $(call message,,todos $(dist_prefix)/version.txt) - -# We need the project files for the examples copied before we try to -# auto-generate the solution files. So each example target that generates -# solutions should depend in order-only on this target. -# -$(dist-pre): - $(call install-dir,$(src_base)/dist/examples/cxx,$(dist_prefix)/examples/cxx) - -# Clean. -# -$(clean): $(out_base)/xsd/.clean \ - $(out_base)/tests/.clean \ - $(out_base)/examples/.clean \ - $(out_base)/doc/.clean - -$(call include,$(bld_root)/install.make) - -$(call import,$(src_base)/xsd/makefile) -$(call import,$(src_base)/libxsd/makefile) -$(call import,$(src_base)/tests/makefile) -$(call import,$(src_base)/examples/makefile) -$(call import,$(src_base)/doc/makefile) diff --git a/packages.manifest b/packages.manifest new file mode 100644 index 0000000..4b6de4e --- /dev/null +++ b/packages.manifest @@ -0,0 +1,10 @@ +: 1 +location: libxsd/ +: +location: libxsd-tests/ +: +location: xsd/ +: +location: xsd-tests/ +: +location: xsd-examples/ diff --git a/repositories.manifest b/repositories.manifest new file mode 100644 index 0000000..71f161b --- /dev/null +++ b/repositories.manifest @@ -0,0 +1,22 @@ +: 1 +summary: XML Schema to C++ data binding compiler repository + +: +role: prerequisite +location: https://git.build2.org/packaging/zlib/zlib.git##HEAD + +: +role: prerequisite +location: https://git.build2.org/packaging/xerces-c/xerces-c.git##HEAD + +: +role: prerequisite +location: https://git.build2.org/packaging/expat/expat.git#2.1 + +: +role: prerequisite +location: https://git.codesynthesis.com/libcutl/libcutl.git##HEAD + +: +role: prerequisite +location: https://git.codesynthesis.com/libxsd-frontend/libxsd-frontend.git##HEAD diff --git a/tests/clash/clash.xsd b/tests/clash/clash.xsd deleted file mode 100644 index 8458908..0000000 --- a/tests/clash/clash.xsd +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/tests/clash/foo.xsd b/tests/clash/foo.xsd deleted file mode 100644 index 8a06ba8..0000000 --- a/tests/clash/foo.xsd +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - diff --git a/tests/code/name-conflict/test.xsd b/tests/code/name-conflict/test.xsd deleted file mode 100644 index a017cc8..0000000 --- a/tests/code/name-conflict/test.xsd +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/code/name-escaping/test.xsd b/tests/code/name-escaping/test.xsd deleted file mode 100644 index 08c7530..0000000 --- a/tests/code/name-escaping/test.xsd +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/makefile b/tests/cxx/makefile deleted file mode 100644 index 769a1d0..0000000 --- a/tests/cxx/makefile +++ /dev/null @@ -1,15 +0,0 @@ -# file : tests/cxx/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make - -default := $(out_base)/ -test := $(out_base)/.test -clean := $(out_base)/.clean - -$(default): $(out_base)/parser/ $(out_base)/tree/ -$(test): $(out_base)/parser/.test $(out_base)/tree/.test -$(clean): $(out_base)/parser/.clean $(out_base)/tree/.clean - -$(call import,$(src_base)/parser/makefile) -$(call import,$(src_base)/tree/makefile) diff --git a/tests/cxx/parser/built-in/driver.cxx b/tests/cxx/parser/built-in/driver.cxx deleted file mode 100644 index 6cfd8fc..0000000 --- a/tests/cxx/parser/built-in/driver.cxx +++ /dev/null @@ -1,529 +0,0 @@ -// file : tests/cxx/parser/built-in/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test built-in type parsing. -// - -#include -#include - -#include "test-pskel.hxx" - -using namespace std; -using namespace test; -using xml_schema::ro_string; - -struct any_type_pimpl: xml_schema::any_type_pimpl -{ - virtual void - pre () - { - cout << "{" << endl; - } - - virtual void - _start_any_element (ro_string const&, - ro_string const& n, - ro_string const*) - { - cout << " start any element '" << n << "'" << endl; - } - - virtual void - _end_any_element (ro_string const&, ro_string const& n) - { - cout << " end any element '" << n << "'" << endl; - } - - virtual void - _any_attribute (ro_string const&, - ro_string const& n, - ro_string const& v) - { - cout << " any attribute " << n << " = '" << v << "'" << endl; - } - - virtual void - _any_characters (ro_string const& s) - { - cout << " any text: '" << s << "'" << endl; - } - - virtual void - post_any_type () - { - cout << "}" << endl - << endl; - } -}; - -struct any_simple_type_pimpl: xml_schema::any_simple_type_pimpl -{ - virtual void - pre () - { - cout << "{" << endl; - } - - virtual void - _any_characters (ro_string const& s) - { - cout << " any text: '" << s << "'" << endl; - } - - virtual void - post_any_simple_type () - { - cout << "}" << endl - << endl; - } -}; - -struct type_pimpl: type_pskel -{ - virtual void - boolean (bool v) - { - cout << v << endl; - } - - virtual void - byte (signed char v) - { - cout << short (v) << endl; - } - - virtual void - unsigned_byte (unsigned char v) - { - cout << (unsigned short) (v) << endl; - } - - virtual void - short_ (short v) - { - cout << v << endl; - } - - virtual void - unsigned_short (unsigned short v) - { - cout << v << endl; - } - - virtual void - int_ (int v) - { - cout << v << endl; - } - - virtual void - unsigned_int (unsigned int v) - { - cout << v << endl; - } - - virtual void - long_ (long long v) - { - cout << v << endl; - } - - virtual void - unsigned_long (unsigned long long v) - { - cout << v << endl; - } - - virtual void - integer (long long v) - { - cout << v << endl; - } - - virtual void - negative_integer (long long v) - { - cout << v << endl; - } - - - virtual void - non_positive_integer (long long v) - { - cout << v << endl; - } - - - virtual void - positive_integer (unsigned long long v) - { - cout << v << endl; - } - - virtual void - non_negative_integer (unsigned long long v) - { - cout << v << endl; - } - - virtual void - float_ (float v) - { - cout << v << endl; - } - - virtual void - double_ (double v) - { - cout << v << endl; - } - - virtual void - decimal (double v) - { - cout << v << endl; - } - - virtual void - string (std::string const& v) - { - cout << "'" << v << "'" << endl; - } - - virtual void - normalized_string (std::string const& v) - { - cout << "'" << v << "'" << endl; - } - - virtual void - token (std::string const& v) - { - cout << "'" << v << "'" << endl; - } - - virtual void - name (std::string const& v) - { - cout << "'" << v << "'" << endl; - } - - virtual void - nmtoken (std::string const& v) - { - cout << "'" << v << "'" << endl; - } - - virtual void - nmtokens (xml_schema::string_sequence const& s) - { - cout << "'"; - - for (xml_schema::string_sequence::const_iterator i (s.begin ()); - i != s.end (); ++i) - cout << *i << " "; - - cout << "'" << endl; - } - - virtual void - ncname (std::string const& v) - { - cout << "'" << v << "'" << endl; - } - - virtual void - id (std::string const& v) - { - cout << "'" << v << "'" << endl; - } - - virtual void - idref (std::string const& v) - { - cout << "'" << v << "'" << endl; - } - - virtual void - idrefs (xml_schema::string_sequence const& s) - { - cout << "'"; - - for (xml_schema::string_sequence::const_iterator i (s.begin ()); - i != s.end (); ++i) - cout << *i << " "; - - cout << "'" << endl; - } - - virtual void - language (std::string const& v) - { - cout << "'" << v << "'" << endl; - } - - virtual void - uri (std::string const& v) - { - cout << "'" << v << "'" << endl; - } - - virtual void - qname (xml_schema::qname const& v) - { - cout << "'" << v.prefix () << ":" << v.name () << "'" << endl; - } - - virtual void - base64_binary (XSD_AUTO_PTR v) - { - std::string tmp (v->data (), v->size ()); - cout << "'" << tmp << "'" << endl; - } - - virtual void - hex_binary (XSD_AUTO_PTR v) - { - std::string tmp (v->data (), v->size ()); - cout << "'" << tmp << "'" << endl; - } - - virtual void - gday (xml_schema::gday const& v) - { - cout << v.day (); - - if (v.zone_present ()) - cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () - << ':' << v.zone_minutes (); - - cout << endl; - } - - virtual void - gmonth (xml_schema::gmonth const& v) - { - cout << v.month (); - - if (v.zone_present ()) - cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () - << ':' << v.zone_minutes (); - - cout << endl; - } - - virtual void - gyear (xml_schema::gyear const& v) - { - cout << v.year (); - - if (v.zone_present ()) - cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () - << ':' << v.zone_minutes (); - - cout << endl; - } - - virtual void - gmonth_day (xml_schema::gmonth_day const& v) - { - cout << v.month () << '-' << v.day (); - - if (v.zone_present ()) - cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () - << ':' << v.zone_minutes (); - - cout << endl; - } - - virtual void - gyear_month (xml_schema::gyear_month const& v) - { - cout << v.year () << '-' << v.month (); - - if (v.zone_present ()) - cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () - << ':' << v.zone_minutes (); - - cout << endl; - } - - virtual void - date (xml_schema::date const& v) - { - cout << v.year () << '-' << v.month () << '-' << v.day (); - - if (v.zone_present ()) - cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () - << ':' << v.zone_minutes (); - - cout << endl; - } - - virtual void - time (xml_schema::time const& v) - { - cout << v.hours () << ':' << v.minutes () << ':' << v.seconds (); - - if (v.zone_present ()) - cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () - << ':' << v.zone_minutes (); - - cout << endl; - } - - virtual void - date_time (xml_schema::date_time const& v) - { - cout << v.year () << '-' << v.month () << '-' << v.day () << 'T' - << v.hours () << ':' << v.minutes () << ':' << v.seconds (); - - if (v.zone_present ()) - cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () - << ':' << v.zone_minutes (); - - cout << endl; - } - - virtual void - duration (xml_schema::duration const& v) - { - cout << (v.negative () ? "-" : "") << 'P' - << v.years () << 'Y' - << v.months () << 'M' - << v.days () << 'D' - << 'T' - << v.hours () << 'H' - << v.minutes () << 'M' - << v.seconds () << 'S' - << endl; - } -}; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - any_type_pimpl any_type_p; - any_simple_type_pimpl any_simple_type_p; - - xml_schema::boolean_pimpl boolean_p; - - xml_schema::byte_pimpl byte_p; - xml_schema::unsigned_byte_pimpl unsigned_byte_p; - xml_schema::short_pimpl short_p; - xml_schema::unsigned_short_pimpl unsigned_short_p; - xml_schema::int_pimpl int_p; - xml_schema::unsigned_int_pimpl unsigned_int_p; - xml_schema::long_pimpl long_p; - xml_schema::unsigned_long_pimpl unsigned_long_p; - - xml_schema::integer_pimpl integer_p; - xml_schema::negative_integer_pimpl negative_integer_p; - xml_schema::non_positive_integer_pimpl non_positive_integer_p; - xml_schema::positive_integer_pimpl positive_integer_p; - xml_schema::non_negative_integer_pimpl non_negative_integer_p; - - xml_schema::float_pimpl float_p; - xml_schema::double_pimpl double_p; - xml_schema::decimal_pimpl decimal_p; - - xml_schema::string_pimpl string_p; - xml_schema::normalized_string_pimpl normalized_string_p; - xml_schema::token_pimpl token_p; - xml_schema::name_pimpl name_p; - xml_schema::nmtoken_pimpl nmtoken_p; - xml_schema::nmtokens_pimpl nmtokens_p; - xml_schema::ncname_pimpl ncname_p; - xml_schema::id_pimpl id_p; - xml_schema::idref_pimpl idref_p; - xml_schema::idrefs_pimpl idrefs_p; - - xml_schema::language_pimpl language_p; - xml_schema::uri_pimpl uri_p; - xml_schema::qname_pimpl qname_p; - - xml_schema::base64_binary_pimpl base64_binary_p; - xml_schema::hex_binary_pimpl hex_binary_p; - - xml_schema::gday_pimpl gday_p; - xml_schema::gmonth_pimpl gmonth_p; - xml_schema::gyear_pimpl gyear_p; - xml_schema::gmonth_day_pimpl gmonth_day_p; - xml_schema::gyear_month_pimpl gyear_month_p; - xml_schema::date_pimpl date_p; - xml_schema::time_pimpl time_p; - xml_schema::date_time_pimpl date_time_p; - xml_schema::duration_pimpl duration_p; - - type_pimpl type_p; - - type_p.parsers (any_type_p, - any_simple_type_p, - boolean_p, - byte_p, - unsigned_byte_p, - short_p, - unsigned_short_p, - int_p, - unsigned_int_p, - long_p, - unsigned_long_p, - integer_p, - negative_integer_p, - non_positive_integer_p, - positive_integer_p, - non_negative_integer_p, - float_p, - double_p, - decimal_p, - string_p, - normalized_string_p, - token_p, - name_p, - nmtoken_p, - nmtokens_p, - ncname_p, - id_p, - idref_p, - idrefs_p, - language_p, - uri_p, - qname_p, - base64_binary_p, - hex_binary_p, - gday_p, - gmonth_p, - gyear_p, - gmonth_day_p, - gyear_month_p, - date_p, - time_p, - date_time_p, - duration_p); - - xml_schema::document doc_p (type_p, "test", "root"); - - type_p.pre (); - doc_p.parse (argv[1]); - type_p.post_type (); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - catch (std::ios_base::failure const&) - { - cerr << "io failure" << endl; - return 1; - } -} diff --git a/tests/cxx/parser/built-in/makefile b/tests/cxx/parser/built-in/makefile deleted file mode 100644 index 5602b6a..0000000 --- a/tests/cxx/parser/built-in/makefile +++ /dev/null @@ -1,82 +0,0 @@ -# file : tests/cxx/parser/built-in/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/built-in/output b/tests/cxx/parser/built-in/output deleted file mode 100644 index 756abcd..0000000 --- a/tests/cxx/parser/built-in/output +++ /dev/null @@ -1,164 +0,0 @@ -{ - any attribute x = 'x' - any text: ' - ' - start any element 'a' - any text: 'a' - end any element 'a' - any text: ' - ' - start any element 'any-type' - any attribute x = 'xxx' - any text: 'aaa' - start any element 'a' - any text: 'bbb' - end any element 'a' - any text: 'ccc' - end any element 'any-type' - any text: ' - ' -} - -{ - any text: '123abc' -} - -1 -0 -1 -0 -0 -127 --128 -123 -0 -255 -123 -0 -32767 --32768 --12345 -0 -65535 -12345 -0 -2147483647 --2147483648 --1234567890 -0 -4294967295 -1234567890 -0 -9223372036854775807 --9223372036854775808 --1234567890123456789 -0 -18446744073709551615 -12345678901234567890 -0 -2147483647 --2147483648 --1234567890 --2147483648 --1234567890 -0 --2147483648 --1234567890 -4294967295 -1234567890 -0 -4294967295 -1234567890 -0 -0 --0 -inf --inf -nan -123.567 -123.567 --1.23567e+07 --4.5e-06 -0 -0 --0 -inf --inf -nan -123.567 -123.567 --1.23567e+07 --4.5e-06 -0 -0 --0 -123.567 -123.567 --123.567 -'string space -newline - ' -' string space newline ' -'string space newline' -'as123:345-.abs' -'1as123:345-.abs' -'abc 123 ' -'as123_345-.abs' -'as123_345-.abs' -'abc' -'a123' -'as123_345-.abs' -'abc a123 ' -'x' -'en' -'en-us' -'one-two-three-four44-seven77-eight888' -'' -'relative' -'#id' -'http://www.example.com/foo#bar' -':schemaLocation' -'xsi:schemaLocation' -'12345abcjk' -'a' -'ab' -'abc' -'' -'12345abcjk' -12+12:0 -1 -31 -15+0:0 -15-14:0 -10+12:0 -1 -12+0:0 -2007+12:0 -1 --20000+0:0 -10-28+12:0 -12-31 -1-1+0:0 -2007-12+12:0 --2007-10 -20007-10+0:0 --20007-1 -2007-12-26+12:0 --2007-10-15 -20007-12-31+0:0 --20007-1-1 -12:46:23.456+12:0 -12:13:14 -12:13:14+0:0 -2007-12-26T12:13:14.123+12:0 --2007-10-15T12:13:14 -20007-12-31T12:13:14+0:0 --20007-1-1T12:13:14 --P2007Y13M32DT25H61M61.123S -P1Y0M0DT0H0M0S -P0Y1M0DT0H0M0S -P0Y0M1DT0H0M0S -P0Y0M0DT1H0M0S -P0Y0M0DT0H1M0S -P0Y0M0DT0H0M1.1S -P1Y0M0DT0H0M1S diff --git a/tests/cxx/parser/built-in/test.xml b/tests/cxx/parser/built-in/test.xml deleted file mode 100644 index 8d9332a..0000000 --- a/tests/cxx/parser/built-in/test.xml +++ /dev/null @@ -1,199 +0,0 @@ - - - - a - aaabbbccc - - - 123abc - - 1 - 0 - true - false - - 0 - +127 - -128 - 123 - - 0 - 255 - 123 - - 0 - +32767 - -32768 - -12345 - - 0 - 65535 - 12345 - - 0 - +2147483647 - -2147483648 - -1234567890 - - 0 - 4294967295 - 1234567890 - - 0 - +9223372036854775807 - -9223372036854775808 - -1234567890123456789 - - 0 - 18446744073709551615 - 12345678901234567890 - - 0 - +2147483647 - -02147483648 - -1234567890 - - -02147483648 - -1234567890 - - 0 - -02147483648 - -1234567890 - - 4294967295 - +01234567890 - - 0 - 4294967295 - +01234567890 - - 0 - +0 - -0 - INF - -INF - NaN - 123.567 - +123.567 - -123.567e5 - -.45E-5 - - 0 - +0 - -0 - INF - -INF - NaN - 123.567 - +123.567 - -123.567e5 - -.45E-5 - - 0 - +0 - -0 - 123.567 - +123.567 - -123.567 - - string space -newline - - - string space -newline - - - - string space -newline - - - - as123:345-.abs - - 1as123:345-.abs - - abc 123 - - as123_345-.abs - - as123_345-.abs - abc - a123 - - as123_345-.abs - - abc a123 - - x - en - en-us - one-two-three-four44-seven77-eight888 - - - relative - #id - http://www.example.com/foo#bar - - schemaLocation - xsi:schemaLocation - - MTIzND - VhYmNqaw = = - YQ== - YWI= - YWJj - - - 31323334356162636a6b - - ---12+12:00 - ---01 - ---31 - ---15Z - ---15-14:00 - - --10+12:00 - --01 - --12Z - - 2007+12:00 - 0001 - -20000Z - - --10-28+12:00 - --12-31 - --01-01Z - - 2007-12+12:00 - -2007-10 - 20007-10Z - -20007-01 - - 2007-12-26+12:00 - -2007-10-15 - 20007-12-31Z - -20007-01-01 - - - - - - 2007-12-26T12:13:14.123+12:00 - -2007-10-15T12:13:14 - 20007-12-31T12:13:14Z - -20007-01-01T12:13:14 - - -P2007Y13M32DT25H61M61.123S - P1Y - P1M - P1D - PT1H - PT1M - PT1.1S - P1YT1S - - diff --git a/tests/cxx/parser/built-in/test.xsd b/tests/cxx/parser/built-in/test.xsd deleted file mode 100644 index 9c00eb4..0000000 --- a/tests/cxx/parser/built-in/test.xsd +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/parser/enumeration/driver.cxx b/tests/cxx/parser/enumeration/driver.cxx deleted file mode 100644 index e90f58b..0000000 --- a/tests/cxx/parser/enumeration/driver.cxx +++ /dev/null @@ -1,81 +0,0 @@ -// file : tests/cxx/parser/enumeration/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test xsd:enumeration parsing. -// - -#include -#include - -#include "test-pskel.hxx" - -using namespace std; -using namespace xml_schema; - -struct digit_pimpl: test::digit_pskel, int_pimpl -{ -}; - -struct gender_pimpl: test::gender_pskel, string_pimpl -{ - virtual ::gender - post_gender () - { - std::string str (post_string ()); - - if (str == "male") - return male; - else - return female; - } -}; - -struct type_pimpl: test::type_pskel -{ - virtual void - digit (int i) - { - cout << i << endl; - } - - virtual void - gender (::gender g) - { - cout << g << endl; - } -}; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - digit_pimpl digit_p; - gender_pimpl gender_p; - type_pimpl type_p; - - type_p.parsers (digit_p, gender_p); - - document doc_p (type_p, "test", "root"); - - type_p.pre (); - doc_p.parse (argv[1]); - type_p.post_type (); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - catch (std::ios_base::failure const&) - { - cerr << "io failure" << endl; - return 1; - } -} diff --git a/tests/cxx/parser/enumeration/gender.hxx b/tests/cxx/parser/enumeration/gender.hxx deleted file mode 100644 index a2e5cd8..0000000 --- a/tests/cxx/parser/enumeration/gender.hxx +++ /dev/null @@ -1,13 +0,0 @@ -// file : tests/cxx/parser/enumeration/gender.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef GENDER_HXX -#define GENDER_HXX - -enum gender -{ - male, - female -}; - -#endif // GENDER_HXX diff --git a/tests/cxx/parser/enumeration/makefile b/tests/cxx/parser/enumeration/makefile deleted file mode 100644 index f2ae834..0000000 --- a/tests/cxx/parser/enumeration/makefile +++ /dev/null @@ -1,83 +0,0 @@ -# file : tests/cxx/parser/enumeration/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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)/test.map -$(gen): $(out_root)/xsd/xsd $(src_base)/test.map - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/enumeration/output b/tests/cxx/parser/enumeration/output deleted file mode 100644 index 16db301..0000000 --- a/tests/cxx/parser/enumeration/output +++ /dev/null @@ -1,3 +0,0 @@ -1 -0 -1 diff --git a/tests/cxx/parser/enumeration/test.map b/tests/cxx/parser/enumeration/test.map deleted file mode 100644 index f8868d6..0000000 --- a/tests/cxx/parser/enumeration/test.map +++ /dev/null @@ -1,7 +0,0 @@ -namespace test -{ - include "gender.hxx"; - - digit int int; - gender ::gender ::gender; -} diff --git a/tests/cxx/parser/enumeration/test.xml b/tests/cxx/parser/enumeration/test.xml deleted file mode 100644 index a6fa893..0000000 --- a/tests/cxx/parser/enumeration/test.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - 1 - - male - female - - diff --git a/tests/cxx/parser/enumeration/test.xsd b/tests/cxx/parser/enumeration/test.xsd deleted file mode 100644 index ded3a18..0000000 --- a/tests/cxx/parser/enumeration/test.xsd +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/parser/generated-impl/makefile b/tests/cxx/parser/generated-impl/makefile deleted file mode 100644 index ba26c37..0000000 --- a/tests/cxx/parser/generated-impl/makefile +++ /dev/null @@ -1,93 +0,0 @@ -# file : tests/cxx/parser/generated-impl/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd - -obj := $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.o) $(xsd:.xsd=-pimpl.o) $(xsd:.xsd=-driver.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/$(xsd:.xsd=-driver) -test := $(out_base)/.test -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) \ - $(xsd:.xsd=-pimpl.hxx) \ - $(xsd:.xsd=-pimpl.cxx) \ - $(xsd:.xsd=-driver.cxx) - -gen := $(addprefix $(out_base)/,$(genf)) - - -$(gen): xsd := $(out_root)/xsd/xsd -$(gen): xsd_options += --generate-print-impl --generate-test-driver \ ---force-overwrite -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# Clean. -# -$(clean): $(driver).o.clean \ - $(addsuffix .cxx.clean,$(obj)) \ - $(addsuffix .cxx.clean,$(dep)) \ - $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.cxx.xsd.clean)) \ - $(addprefix $(out_base)/,$(xsd:.xsd=-pimpl.cxx.xsd.clean)) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(gen): | $(out_base)/.gitignore -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := $(xsd:.xsd=-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) - -xsd_parser_impl_suffix := -pimpl - -$(call include,$(bld_root)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/generated-impl/output b/tests/cxx/parser/generated-impl/output deleted file mode 100644 index 7c58647..0000000 --- a/tests/cxx/parser/generated-impl/output +++ /dev/null @@ -1,122 +0,0 @@ -gender: male -foo: foo -gender: male -int: 0 -int: 1 -int: 2 -int: 3 -foo: foo -int: 3 -int: 2 -int: 1 -int: 0 -union: 9 -foo: foo -union: string -x: x -a: aaa -x: x -y: y -a: aaa -b: bbb -boolean: 1 -boolean: 0 -boolean: 1 -boolean: 0 -byte: 0 -byte: 123 -byte: -123 -unsigned-byte: 0 -unsigned-byte: 123 -short: 0 -short: -1234 -short: 1234 -unsigned-short: 0 -unsigned-short: 1234 -int: 0 -int: -12345 -int: 12345 -unsigned-int: 0 -unsigned-int: 12345 -long: 0 -long: -123456 -long: 123456 -unsigned-long: 0 -unsigned-long: 123456 -integer: 0 -integer: -123456 -integer: 123456 -negative-integer: -123456 -non-positive-integer: 0 -non-positive-integer: -123456 -positive-integer: 123456 -non-negative-integer: 0 -non-negative-integer: 123456 -float: 0 -float: 1.123 -float: -1.123 -double: 0 -double: 1.1234 -double: -1.1234 -decimal: 0 -decimal: 1.1234 -decimal: -1.1234 -string: string space newline -normalized-string: string space newline -token: string space newline -name: as123:345-.abs -nmtoken: 1as123:345-.abs -nmtokens: abc 123 -ncname: as123_345-.abs -id: abc -id: a123 -idref: abc -idrefs: abc a123 -language: en -language: en-us -uri: http://www.example.com/foo#bar -qname: schemaLocation -qname: xsi:schemaLocation -base64_binary: 10 bytes -base64_binary: 1 bytes -base64_binary: 2 bytes -base64_binary: 3 bytes -hex_binary: 0 bytes -hex_binary: 10 bytes -gday: ---12+12:0 -gday: ---1 -gday: ---31 -gday: ---15+0:0 -gday: ---15-14:0 -gmonth: --10+12:0 -gmonth: --1 -gmonth: --12+0:0 -gyear: 2007+12:0 -gyear: 1 -gyear: -20000+0:0 -gmonth_day: --10-28+12:0 -gmonth_day: --12-31 -gmonth_day: --1-1+0:0 -gyear_month: 2007-12+12:0 -gyear_month: -2007-10 -gyear_month: 20007-10+0:0 -gyear_month: -20007-1 -date: 2007-12-26+12:0 -date: -2007-10-15 -date: 20007-12-31+0:0 -date: -20007-1-1 -time: 12:46:23.456+12:0 -time: 12:13:14 -time: 12:13:14+0:0 -date_time: 2007-12-26T12:13:14.123+12:0 -date_time: -2007-10-15T12:13:14 -date_time: 20007-12-31T12:13:14+0:0 -date_time: -20007-1-1T12:13:14 -duration: -P2007Y13M32DT25H61M61.123S -duration: P1Y0M0DT0H0M0S -duration: P0Y1M0DT0H0M0S -duration: P0Y0M1DT0H0M0S -duration: P0Y0M0DT1H0M0S -duration: P0Y0M0DT0H1M0S -duration: P0Y0M0DT0H0M1.1S -duration: P1Y0M0DT0H0M1S diff --git a/tests/cxx/parser/generated-impl/test.xml b/tests/cxx/parser/generated-impl/test.xml deleted file mode 100644 index 2f29a39..0000000 --- a/tests/cxx/parser/generated-impl/test.xml +++ /dev/null @@ -1,168 +0,0 @@ - - - male - male - - 0 1 2 3 - 3 2 1 0 - - 9 - string - - - aaa - - - - aaa - bbb - - - aaabbbccc - abc123 - - 1 - 0 - true - false - - 0 - 123 - -123 - - 0 - 123 - - 0 - -1234 - 1234 - - 0 - 1234 - - 0 - -12345 - 12345 - - 0 - 12345 - - 0 - -123456 - 123456 - - 0 - 123456 - - 0 - -123456 - 123456 - - -123456 - - 0 - -123456 - - 123456 - - 0 - 123456 - - 0 - 1.123 - -1.123 - - 0 - 1.1234 - -1.1234 - - 0 - 1.1234 - -1.1234 - - string space newline - - string space newline - - string space newline - - as123:345-.abs - - 1as123:345-.abs - - abc 123 - - as123_345-.abs - - abc - a123 - - abc - - abc a123 - - en - en-us - - http://www.example.com/foo#bar - - schemaLocation - xsi:schemaLocation - - MTIzNDVhYmNqaw== - YQ== - YWI= - YWJj - - - 31323334356162636a6b - - ---12+12:00 - ---01 - ---31 - ---15Z - ---15-14:00 - - --10+12:00 - --01 - --12Z - - 2007+12:00 - 0001 - -20000Z - - --10-28+12:00 - --12-31 - --01-01Z - - 2007-12+12:00 - -2007-10 - 20007-10Z - -20007-01 - - 2007-12-26+12:00 - -2007-10-15 - 20007-12-31Z - -20007-01-01 - - - - - - 2007-12-26T12:13:14.123+12:00 - -2007-10-15T12:13:14 - 20007-12-31T12:13:14Z - -20007-01-01T12:13:14 - - -P2007Y13M32DT25H61M61.123S - P1Y - P1M - P1D - PT1H - PT1M - PT1.1S - P1YT1S - - diff --git a/tests/cxx/parser/generated-impl/test.xsd b/tests/cxx/parser/generated-impl/test.xsd deleted file mode 100644 index 7bc8f23..0000000 --- a/tests/cxx/parser/generated-impl/test.xsd +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/parser/list/driver.cxx b/tests/cxx/parser/list/driver.cxx deleted file mode 100644 index dfc27bf..0000000 --- a/tests/cxx/parser/list/driver.cxx +++ /dev/null @@ -1,105 +0,0 @@ -// file : tests/cxx/parser/list/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test xsd:list parsing. -// - -#include -#include - -#include "test-pskel.hxx" - -using namespace std; -using namespace test; - -struct string_list_pimpl: string_list_pskel -{ - virtual void - pre () - { - cout << "{" << endl; - } - - virtual void - item (string const& v) - { - cout << " '" << v << "'" << endl; - } - - virtual void - post_string_list () - { - cout << "}" << endl - << endl; - } -}; - -struct string_list_lang_pimpl: string_list_lang_pskel -{ - virtual void - pre () - { - cout << "{" << endl; - } - - virtual void - item (string const& v) - { - cout << " '" << v << "'" << endl; - } - - virtual void - lang (string const& v) - { - cout << " lang: '" << v << "'" << endl; - } - - virtual void - post_string_list_lang () - { - cout << "}" << endl - << endl; - } -}; - -struct type_pimpl: type_pskel -{ -}; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - xml_schema::string_pimpl string_p; - string_list_pimpl string_list_p; - string_list_lang_pimpl string_list_lang_p; - type_pimpl type_p; - - string_list_p.parsers (string_p); - string_list_lang_p.parsers (string_p, string_p); - type_p.parsers (string_list_p, string_list_lang_p); - - xml_schema::document doc_p (type_p, "test", "root"); - - type_p.pre (); - doc_p.parse (argv[1]); - type_p.post_type (); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - catch (ios_base::failure const&) - { - cerr << "io failure" << endl; - return 1; - } -} diff --git a/tests/cxx/parser/list/makefile b/tests/cxx/parser/list/makefile deleted file mode 100644 index c3b5a87..0000000 --- a/tests/cxx/parser/list/makefile +++ /dev/null @@ -1,82 +0,0 @@ -# file : tests/cxx/parser/list/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/list/output b/tests/cxx/parser/list/output deleted file mode 100644 index 3642c4d..0000000 --- a/tests/cxx/parser/list/output +++ /dev/null @@ -1,26 +0,0 @@ -{ -} - -{ -} - -{ -} - -{ - 'one' -} - -{ - 'one' - 'two' - 'three' -} - -{ - lang: 'en' - 'one' - 'two' - 'three' -} - diff --git a/tests/cxx/parser/list/test.xml b/tests/cxx/parser/list/test.xml deleted file mode 100644 index 52229db..0000000 --- a/tests/cxx/parser/list/test.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - one - - - one two - three - - - - one two - three - - - diff --git a/tests/cxx/parser/list/test.xsd b/tests/cxx/parser/list/test.xsd deleted file mode 100644 index 79bd084..0000000 --- a/tests/cxx/parser/list/test.xsd +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/parser/makefile b/tests/cxx/parser/makefile deleted file mode 100644 index 53de7c7..0000000 --- a/tests/cxx/parser/makefile +++ /dev/null @@ -1,18 +0,0 @@ -# file : tests/cxx/parser/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make - -tests := built-in enumeration generated-impl list recursive \ -name-clash/inheritance polymorphism test-template validation \ -union - -default := $(out_base)/ -test := $(out_base)/.test -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) -$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) - -$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tests/cxx/parser/name-clash/inheritance/driver.cxx b/tests/cxx/parser/name-clash/inheritance/driver.cxx deleted file mode 100644 index dc5f871..0000000 --- a/tests/cxx/parser/name-clash/inheritance/driver.cxx +++ /dev/null @@ -1,62 +0,0 @@ -// file : tests/cxx/parser/name-clash/inheritance/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test for name clashes across inheritance hierarchy. -// - -#include -#include - -#include "test-pskel.hxx" - -using namespace std; -using namespace test; - -struct derived_pimpl: derived_pskel -{ - virtual void - e (string const& v) - { - cout << "e: " << v << endl; - } - - virtual void - e1 (string const& v) - { - cout << "e1: " << v << endl; - } -}; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - xml_schema::string_pimpl string_p; - derived_pimpl derived_p; - - derived_p.parsers (string_p, string_p); - - xml_schema::document doc_p (derived_p, "test", "root"); - - derived_p.pre (); - doc_p.parse (argv[1]); - derived_p.post_derived (); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - catch (std::ios_base::failure const&) - { - cerr << "io failure" << endl; - return 1; - } -} diff --git a/tests/cxx/parser/name-clash/inheritance/makefile b/tests/cxx/parser/name-clash/inheritance/makefile deleted file mode 100644 index c540ebe..0000000 --- a/tests/cxx/parser/name-clash/inheritance/makefile +++ /dev/null @@ -1,83 +0,0 @@ -# file : tests/cxx/parser/name-clash/inheritance/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-validation -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/name-clash/inheritance/output b/tests/cxx/parser/name-clash/inheritance/output deleted file mode 100644 index 4efd51b..0000000 --- a/tests/cxx/parser/name-clash/inheritance/output +++ /dev/null @@ -1,2 +0,0 @@ -e: e -e1: e1 diff --git a/tests/cxx/parser/name-clash/inheritance/test.xml b/tests/cxx/parser/name-clash/inheritance/test.xml deleted file mode 100644 index 8c17101..0000000 --- a/tests/cxx/parser/name-clash/inheritance/test.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - e - e1 - - diff --git a/tests/cxx/parser/name-clash/inheritance/test.xsd b/tests/cxx/parser/name-clash/inheritance/test.xsd deleted file mode 100644 index 62a782e..0000000 --- a/tests/cxx/parser/name-clash/inheritance/test.xsd +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/parser/polymorphism/makefile b/tests/cxx/parser/polymorphism/makefile deleted file mode 100644 index 252d857..0000000 --- a/tests/cxx/parser/polymorphism/makefile +++ /dev/null @@ -1,16 +0,0 @@ -# file : tests/cxx/parser/polymorphism/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -tests := same-type recursive - -default := $(out_base)/ -test := $(out_base)/.test -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) -$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) - -$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tests/cxx/parser/polymorphism/recursive/driver.cxx b/tests/cxx/parser/polymorphism/recursive/driver.cxx deleted file mode 100644 index 4a401bd..0000000 --- a/tests/cxx/parser/polymorphism/recursive/driver.cxx +++ /dev/null @@ -1,68 +0,0 @@ -// file : tests/cxx/parser/polymorphism/recursive/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test polymorphic recursive parsing. -// - -#include -#include - -#include "test-pskel.hxx" -#include "test-pimpl.hxx" - -using namespace std; -using namespace test; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - xml_schema::int_pimpl int_p; - - root_pimpl root_p; - expression_pimpl expression_p; - recursive_pimpl recursive_p; - value_a_pimpl value_a_p; - value_b_pimpl value_b_p; - - xml_schema::parser_map_impl expression_map; - - // Connect the parsers together. - // - root_p.parsers (expression_p); - expression_map.insert(value_a_p); - expression_map.insert(value_b_p); - expression_map.insert(recursive_p); - - root_p.expression_parser(expression_map); - - recursive_p.parsers(expression_p); - recursive_p.expression_parser(expression_map); - - value_a_p.parsers(int_p); - value_b_p.parsers(int_p); - - xml_schema::document doc_p (root_p, "test", "root", true); - - root_p.pre (); - doc_p.parse (argv[1]); - root_p.post_root (); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - catch (std::ios_base::failure const&) - { - cerr << "io failure" << endl; - return 1; - } -} diff --git a/tests/cxx/parser/polymorphism/recursive/makefile b/tests/cxx/parser/polymorphism/recursive/makefile deleted file mode 100644 index 855d471..0000000 --- a/tests/cxx/parser/polymorphism/recursive/makefile +++ /dev/null @@ -1,83 +0,0 @@ -# file : tests/cxx/parser/polymorphism/recursive/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx test-pimpl.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-polymorphic -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/polymorphism/recursive/output b/tests/cxx/parser/polymorphism/recursive/output deleted file mode 100644 index 28a835f..0000000 --- a/tests/cxx/parser/polymorphism/recursive/output +++ /dev/null @@ -1,22 +0,0 @@ -root start -recursive start -value_a begin -value->constant -value: post_expression override -value_a: post_value override -value_a end -recursive->expression event -recursive start -value_b begin -value->constant -value: post_expression override -value_b: post_value override -value_b end -recursive->expression event -recursive: post_expression override -recursive end -recursive->expression event -recursive: post_expression override -recursive end -root->expression -root end diff --git a/tests/cxx/parser/polymorphism/recursive/test-pimpl.cxx b/tests/cxx/parser/polymorphism/recursive/test-pimpl.cxx deleted file mode 100644 index 8c355ea..0000000 --- a/tests/cxx/parser/polymorphism/recursive/test-pimpl.cxx +++ /dev/null @@ -1,147 +0,0 @@ -// file : tests/cxx/parser/polymorphism/recursive/test-pimpl.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include "test-pimpl.hxx" - -using namespace std; - -namespace test -{ - // root_pimpl - // - - void root_pimpl:: - pre () - { - cout << "root start" << endl; - } - - void root_pimpl:: - expression () - { - cout << "root->expression" << endl; - } - - void root_pimpl:: - post_root () - { - cout << "root end" << endl; - } - - // expression_pimpl - // - - void expression_pimpl:: - pre () - { - cout << "expression begin" << endl; - } - - void expression_pimpl:: - post_expression () - { - cout << "expression end" << endl; - } - - // recursive_pimpl - // - - void recursive_pimpl:: - pre () - { - cout << "recursive start" << endl; - } - - void recursive_pimpl:: - expression () - { - cout << "recursive->expression event" << endl; - } - - void recursive_pimpl:: - post_expression () - { - cout << "recursive: post_expression override" << endl; - post_recursive (); - } - - void recursive_pimpl:: - post_recursive () - { - cout << "recursive end" << endl; - } - - // value_pimpl - // - - void value_pimpl:: - pre () - { - cout << "value begin" << endl; - } - - void value_pimpl:: - constant (int) - { - cout << "value->constant" << endl; - } - - void value_pimpl:: - post_expression () - { - cout << "value: post_expression override" << endl; - post_value (); - } - - void value_pimpl:: - post_value () - { - cout << "value end" << endl; - } - - // value_a_pimpl - // - - void value_a_pimpl:: - pre () - { - cout << "value_a begin" << endl; - } - - void value_a_pimpl:: - post_value () - { - cout << "value_a: post_value override" << endl; - post_value_a (); - } - - void value_a_pimpl:: - post_value_a () - { - cout << "value_a end" << endl; - } - - // value_b_pimpl - // - - void value_b_pimpl:: - pre () - { - cout << "value_b begin" << endl; - } - - void value_b_pimpl:: - post_value () - { - cout << "value_b: post_value override" << endl; - post_value_b (); - } - - void value_b_pimpl:: - post_value_b () - { - cout << "value_b end" << endl; - } -} diff --git a/tests/cxx/parser/polymorphism/recursive/test-pimpl.hxx b/tests/cxx/parser/polymorphism/recursive/test-pimpl.hxx deleted file mode 100644 index 932be9e..0000000 --- a/tests/cxx/parser/polymorphism/recursive/test-pimpl.hxx +++ /dev/null @@ -1,94 +0,0 @@ -// file : tests/cxx/parser/polymorphism/recursive/test-pimpl.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef TEST_PIMPL_HXX -#define TEST_PIMPL_HXX - -#include "test-pskel.hxx" - -namespace test -{ - class root_pimpl: public virtual root_pskel - { - public: - virtual void - pre (); - - virtual void - expression (); - - virtual void - post_root (); - }; - - class expression_pimpl: public virtual expression_pskel - { - public: - virtual void - pre (); - - virtual void - post_expression (); - }; - - class recursive_pimpl: public virtual recursive_pskel, - public expression_pimpl - { - public: - virtual void - pre (); - - virtual void - expression (); - - virtual void - post_expression (); - - virtual void - post_recursive (); - }; - - class value_pimpl: public virtual value_pskel, public expression_pimpl - { - public: - virtual void - pre (); - - virtual void - constant (int); - - virtual void - post_expression (); - - virtual void - post_value (); - }; - - class value_a_pimpl: public virtual value_a_pskel, public value_pimpl - { - public: - virtual void - pre (); - - virtual void - post_value (); - - virtual void - post_value_a (); - }; - - class value_b_pimpl: public virtual value_b_pskel, public value_pimpl - { - public: - virtual void - pre (); - - virtual void - post_value (); - - virtual void - post_value_b (); - }; -} - -#endif // TEST_PIMPL_HXX diff --git a/tests/cxx/parser/polymorphism/recursive/test.xml b/tests/cxx/parser/polymorphism/recursive/test.xml deleted file mode 100644 index 42035ba..0000000 --- a/tests/cxx/parser/polymorphism/recursive/test.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - 1 - - - - 2 - - - - diff --git a/tests/cxx/parser/polymorphism/recursive/test.xsd b/tests/cxx/parser/polymorphism/recursive/test.xsd deleted file mode 100644 index affcc8a..0000000 --- a/tests/cxx/parser/polymorphism/recursive/test.xsd +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/parser/polymorphism/same-type/driver.cxx b/tests/cxx/parser/polymorphism/same-type/driver.cxx deleted file mode 100644 index 4ccaec5..0000000 --- a/tests/cxx/parser/polymorphism/same-type/driver.cxx +++ /dev/null @@ -1,62 +0,0 @@ -// file : tests/cxx/parser/polymorphism/same-type/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test substitution group and xsi:type that don't change the type. -// - -#include -#include - -#include "test-pskel.hxx" - -using namespace std; -using namespace test; - -struct base_pimpl: base_pskel -{ - virtual void - a (string const& v) - { - cout << v << endl; - } -}; - -struct type_pimpl: type_pskel -{ -}; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - xml_schema::string_pimpl string_p; - base_pimpl base_p; - type_pimpl type_p; - - base_p.parsers (string_p); - type_p.parsers (base_p); - - xml_schema::document doc_p (type_p, "test", "root", true); - - type_p.pre (); - doc_p.parse (argv[1]); - type_p.post_type (); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - catch (std::ios_base::failure const&) - { - cerr << "io failure" << endl; - return 1; - } -} diff --git a/tests/cxx/parser/polymorphism/same-type/makefile b/tests/cxx/parser/polymorphism/same-type/makefile deleted file mode 100644 index 588d8b6..0000000 --- a/tests/cxx/parser/polymorphism/same-type/makefile +++ /dev/null @@ -1,83 +0,0 @@ -# file : tests/cxx/parser/polymorphism/same-type/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-polymorphic -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/polymorphism/same-type/output b/tests/cxx/parser/polymorphism/same-type/output deleted file mode 100644 index d418277..0000000 --- a/tests/cxx/parser/polymorphism/same-type/output +++ /dev/null @@ -1,4 +0,0 @@ -a1 -a2 -a3 -a4 diff --git a/tests/cxx/parser/polymorphism/same-type/test.xml b/tests/cxx/parser/polymorphism/same-type/test.xml deleted file mode 100644 index f8b6d1e..0000000 --- a/tests/cxx/parser/polymorphism/same-type/test.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - a1 - a2 - a3 - a4 - - diff --git a/tests/cxx/parser/polymorphism/same-type/test.xsd b/tests/cxx/parser/polymorphism/same-type/test.xsd deleted file mode 100644 index a4157d3..0000000 --- a/tests/cxx/parser/polymorphism/same-type/test.xsd +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/parser/recursive/driver.cxx b/tests/cxx/parser/recursive/driver.cxx deleted file mode 100644 index 39c6621..0000000 --- a/tests/cxx/parser/recursive/driver.cxx +++ /dev/null @@ -1,139 +0,0 @@ -// file : tests/cxx/parser/recursive/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test recursive parser invocation. -// - -#include -#include - -#include "test-pskel.hxx" - -using namespace std; - -struct sub_pimpl: sub_type_pskel -{ - virtual void - pre () - { - cout << "sub::pre" << endl; - } - - virtual void - sub () - { - cout << "sub::sub" << endl; - } - - virtual void - sub2 () - { - cout << "sub::sub2" << endl; - } - - virtual void - name (string const& n) - { - cout << "sub::name: " << n << endl; - } - - virtual void - post_sub_type () - { - cout << "sub::post" << endl; - } -}; - -struct indir_pimpl: indir_type_pskel -{ - virtual void - pre () - { - cout << "indir::pre" << endl; - } - - virtual void - sub () - { - cout << "indir::sub" << endl; - } - - virtual void - name (string const& n) - { - cout << "indir::name: " << n << endl; - } - - virtual void - post_indir_type () - { - cout << "indir::post" << endl; - } -}; - -struct test_pimpl: test_type_pskel -{ - virtual void - pre () - { - cout << "test::pre" << endl; - } - - virtual void - sub () - { - cout << "test::sub" << endl; - } - - virtual void - name (string const& n) - { - cout << "test::name: " << n << endl; - } - - virtual void - post_test_type () - { - cout << "test::post" << endl; - } -}; - - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - xml_schema::string_pimpl string_p; - - sub_pimpl sub_p; - indir_pimpl indir_p; - test_pimpl test_p; - - sub_p.parsers (sub_p, indir_p, sub_p, string_p); - indir_p.parsers (sub_p, string_p); - test_p.parsers (sub_p, string_p); - - xml_schema::document doc_p (test_p, "test"); - - test_p.pre (); - doc_p.parse (argv[1]); - test_p.post_test_type (); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - catch (ios_base::failure const&) - { - cerr << "io failure" << endl; - return 1; - } -} diff --git a/tests/cxx/parser/recursive/makefile b/tests/cxx/parser/recursive/makefile deleted file mode 100644 index a1bc9ab..0000000 --- a/tests/cxx/parser/recursive/makefile +++ /dev/null @@ -1,83 +0,0 @@ -# file : tests/cxx/parser/recursive/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-validation -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/recursive/output b/tests/cxx/parser/recursive/output deleted file mode 100644 index f26fb72..0000000 --- a/tests/cxx/parser/recursive/output +++ /dev/null @@ -1,22 +0,0 @@ -test::pre -test::name: testName -sub::pre -sub::name: subName -sub::pre -sub::name: sub-subName -sub::post -sub::sub -indir::pre -indir::name: sub-indirName -sub::pre -sub::name: sub-indir-subName -sub::post -indir::sub -indir::post -sub::pre -sub::name: sub-sub2Name -sub::post -sub::sub2 -sub::post -test::sub -test::post diff --git a/tests/cxx/parser/recursive/test.xml b/tests/cxx/parser/recursive/test.xml deleted file mode 100644 index f6c219d..0000000 --- a/tests/cxx/parser/recursive/test.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - diff --git a/tests/cxx/parser/recursive/test.xsd b/tests/cxx/parser/recursive/test.xsd deleted file mode 100644 index 33e1d2d..0000000 --- a/tests/cxx/parser/recursive/test.xsd +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/parser/test-template/driver.cxx b/tests/cxx/parser/test-template/driver.cxx deleted file mode 100644 index 9f56496..0000000 --- a/tests/cxx/parser/test-template/driver.cxx +++ /dev/null @@ -1,66 +0,0 @@ -// file : tests/cxx/parser/test-template/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Insert test description here. -// - -#include -#include - -#include "test-pskel.hxx" - -using namespace std; -using namespace test; - -struct type_pimpl: type_pskel -{ - virtual void - pre () - { - } - - virtual void - a (string const& v) - { - cout << v << endl; - } - - virtual void - post_type () - { - } -}; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - xml_schema::string_pimpl string_p; - type_pimpl type_p; - - type_p.parsers (string_p); - - xml_schema::document doc_p (type_p, "test", "root"); - - type_p.pre (); - doc_p.parse (argv[1]); - type_p.post_type (); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - catch (std::ios_base::failure const&) - { - cerr << "io failure" << endl; - return 1; - } -} diff --git a/tests/cxx/parser/test-template/makefile b/tests/cxx/parser/test-template/makefile deleted file mode 100644 index b680466..0000000 --- a/tests/cxx/parser/test-template/makefile +++ /dev/null @@ -1,82 +0,0 @@ -# file : tests/cxx/parser/test-template/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/test-template/output b/tests/cxx/parser/test-template/output deleted file mode 100644 index 7898192..0000000 --- a/tests/cxx/parser/test-template/output +++ /dev/null @@ -1 +0,0 @@ -a diff --git a/tests/cxx/parser/test-template/test.xml b/tests/cxx/parser/test-template/test.xml deleted file mode 100644 index 624a80c..0000000 --- a/tests/cxx/parser/test-template/test.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - a - - diff --git a/tests/cxx/parser/test-template/test.xsd b/tests/cxx/parser/test-template/test.xsd deleted file mode 100644 index 07bebc7..0000000 --- a/tests/cxx/parser/test-template/test.xsd +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/tests/cxx/parser/union/driver.cxx b/tests/cxx/parser/union/driver.cxx deleted file mode 100644 index 5577f78..0000000 --- a/tests/cxx/parser/union/driver.cxx +++ /dev/null @@ -1,60 +0,0 @@ -// file : tests/cxx/parser/union/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test xsd:union parsing. -// - -#include -#include - -#include "test-pskel.hxx" - -using namespace std; -using namespace test; - -struct int_string_union_pimpl: int_string_union_pskel -{ - virtual void - _characters (const xml_schema::ro_string& s) - { - cout << "'" << s << "'" << endl; - } -}; - -struct type_pimpl: type_pskel -{ -}; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - int_string_union_pimpl int_string_union_p; - type_pimpl type_p; - - type_p.parsers (int_string_union_p); - - xml_schema::document doc_p (type_p, "test", "root"); - - type_p.pre (); - doc_p.parse (argv[1]); - type_p.post_type (); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - catch (std::ios_base::failure const&) - { - cerr << "io failure" << endl; - return 1; - } -} diff --git a/tests/cxx/parser/union/makefile b/tests/cxx/parser/union/makefile deleted file mode 100644 index a8e70f6..0000000 --- a/tests/cxx/parser/union/makefile +++ /dev/null @@ -1,82 +0,0 @@ -# file : tests/cxx/parser/union/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/union/output b/tests/cxx/parser/union/output deleted file mode 100644 index a92ffc3..0000000 --- a/tests/cxx/parser/union/output +++ /dev/null @@ -1,2 +0,0 @@ -'one' -'1' diff --git a/tests/cxx/parser/union/test.xml b/tests/cxx/parser/union/test.xml deleted file mode 100644 index 5b3e799..0000000 --- a/tests/cxx/parser/union/test.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - one - 1 - - diff --git a/tests/cxx/parser/union/test.xsd b/tests/cxx/parser/union/test.xsd deleted file mode 100644 index 5bf3d47..0000000 --- a/tests/cxx/parser/union/test.xsd +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/tests/cxx/parser/validation/all/driver.cxx b/tests/cxx/parser/validation/all/driver.cxx deleted file mode 100644 index 093d480..0000000 --- a/tests/cxx/parser/validation/all/driver.cxx +++ /dev/null @@ -1,98 +0,0 @@ -// file : tests/cxx/parser/validation/all/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the all compositor validation. -// - -#include -#include -#include - -#include "test-pskel.hxx" - -using namespace std; -using namespace test; - -struct all_pimpl: all_pskel -{ - virtual void - pre () - { - cout << "{" << endl; - } - - virtual void - a (string const& v) - { - cout << " a = " << v << endl; - } - - virtual void - b (string const& v) - { - cout << " b = " << v << endl; - } - - virtual void - c (string const& v) - { - cout << " c = " << v << endl; - } - - virtual void - post_all () - { - cout << "}" << endl - << endl; - } -}; - -struct type_pimpl: type_pskel -{ -}; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - xml_schema::string_pimpl string_p; - all_pimpl all_p; - type_pimpl type_p; - - all_p.parsers (string_p, string_p, string_p); - type_p.parsers (all_p); - - xml_schema::document doc_p (type_p, "test", "root"); - - try - { - ifstream ifs (argv[1]); - type_p.pre (); - doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); - type_p.post_type (); - } - catch (xml_schema::exception const& e) - { - cout << " " << e << endl - << "}" << endl - << endl; - } - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - catch (ios_base::failure const&) - { - cerr << "io failure" << endl; - return 1; - } -} diff --git a/tests/cxx/parser/validation/all/makefile b/tests/cxx/parser/validation/all/makefile deleted file mode 100644 index b50e067..0000000 --- a/tests/cxx/parser/validation/all/makefile +++ /dev/null @@ -1,92 +0,0 @@ -# file : tests/cxx/parser/validation/all/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -tests := 000 001 002 003 - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-validation -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -test_targets := $(addprefix $(out_base)/.test-,$(tests)) - -$(test): $(test_targets) -$(test_targets): driver := $(driver) - -.PHONY: $(out_base)/.test-% -$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std - $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -) - - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/validation/all/test-000.std b/tests/cxx/parser/validation/all/test-000.std deleted file mode 100644 index b4445f2..0000000 --- a/tests/cxx/parser/validation/all/test-000.std +++ /dev/null @@ -1,46 +0,0 @@ -{ - a = a - b = b - c = c -} - -{ - a = a - c = c - b = b -} - -{ - b = b - a = a - c = c -} - -{ - b = b - c = c - a = a -} - -{ - c = c - a = a - b = b -} - -{ - c = c - b = b - a = a -} - -{ - a = a - b = b -} - -{ - a = a - b = b -} - diff --git a/tests/cxx/parser/validation/all/test-000.xml b/tests/cxx/parser/validation/all/test-000.xml deleted file mode 100644 index 6e46fae..0000000 --- a/tests/cxx/parser/validation/all/test-000.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - a - b - c - - - - a - c - b - - - - b - a - c - - - - b - c - a - - - - c - a - b - - - - c - b - a - - - - - a - b - - - - a - b - - - diff --git a/tests/cxx/parser/validation/all/test-001.std b/tests/cxx/parser/validation/all/test-001.std deleted file mode 100644 index 0472ad9..0000000 --- a/tests/cxx/parser/validation/all/test-001.std +++ /dev/null @@ -1,6 +0,0 @@ -{ - a = a - c = c - :9:9 error: expected element 'b' -} - diff --git a/tests/cxx/parser/validation/all/test-001.xml b/tests/cxx/parser/validation/all/test-001.xml deleted file mode 100644 index 3df5600..0000000 --- a/tests/cxx/parser/validation/all/test-001.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - a - c - - - diff --git a/tests/cxx/parser/validation/all/test-002.std b/tests/cxx/parser/validation/all/test-002.std deleted file mode 100644 index c014230..0000000 --- a/tests/cxx/parser/validation/all/test-002.std +++ /dev/null @@ -1,4 +0,0 @@ -{ - :7:9 error: expected element 'a' -} - diff --git a/tests/cxx/parser/validation/all/test-002.xml b/tests/cxx/parser/validation/all/test-002.xml deleted file mode 100644 index aed0c0c..0000000 --- a/tests/cxx/parser/validation/all/test-002.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - diff --git a/tests/cxx/parser/validation/all/test-003.std b/tests/cxx/parser/validation/all/test-003.std deleted file mode 100644 index dd8c0d3..0000000 --- a/tests/cxx/parser/validation/all/test-003.std +++ /dev/null @@ -1,6 +0,0 @@ -{ - a = a - b = b - :9:7 error: unexpected element 'a' -} - diff --git a/tests/cxx/parser/validation/all/test-003.xml b/tests/cxx/parser/validation/all/test-003.xml deleted file mode 100644 index b147cba..0000000 --- a/tests/cxx/parser/validation/all/test-003.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - a - b - a - - - diff --git a/tests/cxx/parser/validation/all/test.xsd b/tests/cxx/parser/validation/all/test.xsd deleted file mode 100644 index 1f670e3..0000000 --- a/tests/cxx/parser/validation/all/test.xsd +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/parser/validation/any/driver.cxx b/tests/cxx/parser/validation/any/driver.cxx deleted file mode 100644 index 3896598..0000000 --- a/tests/cxx/parser/validation/any/driver.cxx +++ /dev/null @@ -1,121 +0,0 @@ -// file : tests/cxx/parser/validation/any/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the any particle validation. -// - -#include -#include -#include - -#include "test-pskel.hxx" - -using namespace std; -using namespace test; -using xml_schema::ro_string; - -struct any_a_pimpl: any_a_pskel -{ - virtual void - pre () - { - cout << "{" << endl; - } - - virtual void - a (string const& v) - { - cout << " a = " << v << endl; - } - - virtual void - x (string const& v) - { - cout << " x = " << v << endl; - } - - virtual void - _start_any_element (ro_string const&, - ro_string const& n, - ro_string const*) - { - cout << " start any element '" << n << "'" << endl; - } - - virtual void - _end_any_element (ro_string const&, ro_string const& n) - { - cout << " end any element '" << n << "'" << endl; - } - - virtual void - _any_attribute (ro_string const&, - ro_string const& n, - ro_string const& v) - { - cout << " any attribute " << n << " = '" << v << "'" << endl; - } - - virtual void - _any_characters (ro_string const& s) - { - cout << " any text: '" << s << "'" << endl; - } - - virtual void - post_any_a () - { - cout << "}" << endl - << endl; - } -}; - -struct type_pimpl: type_pskel -{ -}; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - xml_schema::string_pimpl string_p; - any_a_pimpl any_a_p; - type_pimpl type_p; - - any_a_p.parsers (string_p, string_p); - type_p.parsers (any_a_p); - - xml_schema::document doc_p (type_p, "test", "root"); - - try - { - ifstream ifs (argv[1]); - type_p.pre (); - doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); - type_p.post_type (); - } - catch (xml_schema::exception const& e) - { - cout << " " << e << endl - << "}" << endl - << endl; - } - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - catch (ios_base::failure const&) - { - cerr << "io failure" << endl; - return 1; - } -} diff --git a/tests/cxx/parser/validation/any/makefile b/tests/cxx/parser/validation/any/makefile deleted file mode 100644 index fe3cdab..0000000 --- a/tests/cxx/parser/validation/any/makefile +++ /dev/null @@ -1,92 +0,0 @@ -# file : tests/cxx/parser/validation/any/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -tests := 000 - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-validation -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -test_targets := $(addprefix $(out_base)/.test-,$(tests)) - -$(test): $(test_targets) -$(test_targets): driver := $(driver) - -.PHONY: $(out_base)/.test-% -$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std - $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -) - - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/validation/any/test-000.std b/tests/cxx/parser/validation/any/test-000.std deleted file mode 100644 index a1cc6e3..0000000 --- a/tests/cxx/parser/validation/any/test-000.std +++ /dev/null @@ -1,29 +0,0 @@ -{ - start any element 'any' - end any element 'any' -} - -{ - start any element 'any' - any attribute x = 'xxx' - any text: 'aaa' - start any element 'a' - any text: 'bbb' - end any element 'a' - any text: 'ccc' - end any element 'any' -} - -{ - x = x - a = a - start any element 'any' - any attribute x = 'xxx' - any text: 'aaa' - start any element 'a' - any text: 'bbb' - end any element 'a' - any text: 'ccc' - end any element 'any' -} - diff --git a/tests/cxx/parser/validation/any/test-000.xml b/tests/cxx/parser/validation/any/test-000.xml deleted file mode 100644 index f1a0c83..0000000 --- a/tests/cxx/parser/validation/any/test-000.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - aaabbbccc - - - - a - aaabbbccc - - - diff --git a/tests/cxx/parser/validation/any/test.xsd b/tests/cxx/parser/validation/any/test.xsd deleted file mode 100644 index c05aeb5..0000000 --- a/tests/cxx/parser/validation/any/test.xsd +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/parser/validation/attribute/driver.cxx b/tests/cxx/parser/validation/attribute/driver.cxx deleted file mode 100644 index 8eda713..0000000 --- a/tests/cxx/parser/validation/attribute/driver.cxx +++ /dev/null @@ -1,197 +0,0 @@ -// file : tests/cxx/parser/validation/attribute/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test attribute and attribute wildcard (anyAttribute) validation. -// - -#include -#include -#include - -#include "test-pskel.hxx" - -using namespace std; -using namespace test; -using xml_schema::ro_string; - -struct pass_a_pimpl: pass_a_pskel -{ - virtual void - pre () - { - cout << "pass-a" << endl - << "{" << endl; - } - - virtual void - a (string const& v) - { - cout << " a = " << v << endl; - } - - virtual void - b (string const& v) - { - cout << " b = " << v << endl; - } - - virtual void - _any_attribute (ro_string const& ns, - ro_string const& name, - ro_string const& value) - { - cout << " any: " << ns << "#" << name << " = " << value << endl; - } - - virtual void - post_pass_a () - { - cout << "}" << endl - << endl; - } -}; - -struct pass_b_pimpl: pass_b_pskel -{ - virtual void - pre () - { - cout << "pass-b" << endl - << "{" << endl; - } - - virtual void - a (string const& v) - { - cout << " a = " << v << endl; - } - - virtual void - b (string const& v) - { - cout << " b = " << v << endl; - } - - virtual void - _any_attribute (ro_string const& ns, - ro_string const& name, - ro_string const& value) - { - cout << " any: " << ns << "#" << name << " = " << value << endl; - } - - virtual void - post_pass_b () - { - cout << "}" << endl - << endl; - } -}; - -struct pass_c_pimpl: pass_c_pskel -{ - virtual void - pre () - { - cout << "pass-c" << endl - << "{" << endl; - } - - virtual void - a (string const& v) - { - cout << " a = " << v << endl; - } - - virtual void - b (string const& v) - { - cout << " b = " << v << endl; - } - - virtual void - post_pass_c () - { - cout << "}" << endl - << endl; - } -}; - -struct fail_pimpl: fail_pskel -{ - virtual void - pre () - { - cout << "fail" << endl - << "{" << endl; - } - - virtual void - a (string const& v) - { - cout << " a = " << v << endl; - } - - virtual void - post_fail () - { - cout << "}" << endl - << endl; - } -}; - -struct type_pimpl: type_pskel -{ -}; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - xml_schema::string_pimpl string_p; - pass_a_pimpl pass_a_p; - pass_b_pimpl pass_b_p; - pass_c_pimpl pass_c_p; - fail_pimpl fail_p; - type_pimpl type_p; - - pass_a_p.parsers (string_p, string_p); - pass_b_p.parsers (string_p, string_p); - pass_c_p.parsers (string_p, string_p); - fail_p.parsers (string_p); - type_p.parsers (pass_a_p, pass_b_p, pass_c_p, fail_p); - - xml_schema::document doc_p (type_p, "test", "root"); - - try - { - ifstream ifs (argv[1]); - type_p.pre (); - doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); - type_p.post_type (); - } - catch (xml_schema::exception const& e) - { - cout << " " << e << endl - << "}" << endl - << endl; - } - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - catch (ios_base::failure const&) - { - cerr << "io failure" << endl; - return 1; - } -} diff --git a/tests/cxx/parser/validation/attribute/makefile b/tests/cxx/parser/validation/attribute/makefile deleted file mode 100644 index d92bf1d..0000000 --- a/tests/cxx/parser/validation/attribute/makefile +++ /dev/null @@ -1,92 +0,0 @@ -# file : tests/cxx/parser/validation/attribute/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -tests := 000 - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-validation -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -test_targets := $(addprefix $(out_base)/.test-,$(tests)) - -$(test): $(test_targets) -$(test_targets): driver := $(driver) - -.PHONY: $(out_base)/.test-% -$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std - $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -) - - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/validation/attribute/test-000.std b/tests/cxx/parser/validation/attribute/test-000.std deleted file mode 100644 index 847b054..0000000 --- a/tests/cxx/parser/validation/attribute/test-000.std +++ /dev/null @@ -1,24 +0,0 @@ -pass-a -{ - b = b - any: test#foo = foo - any: test#bar = bar -} - -pass-b -{ - a = a - b = b -} - -pass-c -{ - a = a - b = b -} - -fail -{ - :8:10 error: expected attribute 'a' -} - diff --git a/tests/cxx/parser/validation/attribute/test-000.xml b/tests/cxx/parser/validation/attribute/test-000.xml deleted file mode 100644 index b994d1a..0000000 --- a/tests/cxx/parser/validation/attribute/test-000.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - diff --git a/tests/cxx/parser/validation/attribute/test.xsd b/tests/cxx/parser/validation/attribute/test.xsd deleted file mode 100644 index 833eb8e..0000000 --- a/tests/cxx/parser/validation/attribute/test.xsd +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/parser/validation/built-in/any-type/driver.cxx b/tests/cxx/parser/validation/built-in/any-type/driver.cxx deleted file mode 100644 index fd91247..0000000 --- a/tests/cxx/parser/validation/built-in/any-type/driver.cxx +++ /dev/null @@ -1,154 +0,0 @@ -// file : tests/cxx/parser/validation/built-in/any-type/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the anyType and anySimpleType validation. -// - -#include -#include -#include - -#include "test-pskel.hxx" - -using namespace std; -using namespace test; -using xml_schema::ro_string; - -struct any_type_pimpl: xml_schema::any_type_pimpl -{ - virtual void - pre () - { - cout << "{" << endl; - } - - virtual void - _start_any_element (ro_string const&, - ro_string const& n, - ro_string const*) - { - cout << " start any element '" << n << "'" << endl; - } - - virtual void - _end_any_element (ro_string const&, ro_string const& n) - { - cout << " end any element '" << n << "'" << endl; - } - - virtual void - _any_attribute (ro_string const&, - ro_string const& n, - ro_string const& v) - { - cout << " any attribute " << n << " = '" << v << "'" << endl; - } - - virtual void - _any_characters (ro_string const& s) - { - cout << " any text: '" << s << "'" << endl; - } - - virtual void - post_any_type () - { - cout << "}" << endl - << endl; - } -}; - -struct any_simple_type_pimpl: xml_schema::any_simple_type_pimpl -{ - virtual void - pre () - { - cout << "{" << endl; - } - - virtual void - _any_characters (ro_string const& s) - { - cout << " any text: '" << s << "'" << endl; - } - - virtual void - post_any_simple_type () - { - cout << "}" << endl - << endl; - } -}; - -struct any_extension_pimpl: virtual any_extension_pskel, - any_type_pimpl - -{ - virtual void - x (const string& v) - { - cout << " x = " << v << endl; - } -}; - -struct any_simple_extension_pimpl: virtual any_simple_extension_pskel, - any_simple_type_pimpl -{ - virtual void - x (const string& v) - { - cout << " x = " << v << endl; - } -}; - -struct type_pimpl: type_pskel -{ -}; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - xml_schema::string_pimpl string_p; - - any_type_pimpl any_type_p; - any_simple_type_pimpl any_simple_type_p; - - any_extension_pimpl any_extension_p; - any_simple_extension_pimpl any_simple_extension_p; - - type_pimpl type_p; - - any_extension_p.parsers (string_p); - any_simple_extension_p.parsers (string_p); - - type_p.parsers (any_type_p, - any_extension_p, - any_simple_extension_p, - any_simple_type_p); - - xml_schema::document doc_p (type_p, "test", "root"); - - ifstream ifs (argv[1]); - type_p.pre (); - doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); - type_p.post_type (); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - catch (ios_base::failure const&) - { - cerr << "io failure" << endl; - return 1; - } -} diff --git a/tests/cxx/parser/validation/built-in/any-type/makefile b/tests/cxx/parser/validation/built-in/any-type/makefile deleted file mode 100644 index dfbb183..0000000 --- a/tests/cxx/parser/validation/built-in/any-type/makefile +++ /dev/null @@ -1,92 +0,0 @@ -# file : tests/cxx/parser/validation/built-in/any-type/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -tests := 000 - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-validation -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -test_targets := $(addprefix $(out_base)/.test-,$(tests)) - -$(test): $(test_targets) -$(test_targets): driver := $(driver) - -.PHONY: $(out_base)/.test-% -$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std - $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -) - - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/validation/built-in/any-type/test-000.std b/tests/cxx/parser/validation/built-in/any-type/test-000.std deleted file mode 100644 index 84d7b3a..0000000 --- a/tests/cxx/parser/validation/built-in/any-type/test-000.std +++ /dev/null @@ -1,99 +0,0 @@ -{ - any text: '123abc' -} - -{ - any text: ' - ' - start any element 'any' - end any element 'any' - any text: ' - ' -} - -{ - any text: ' - ' - start any element 'any' - any attribute x = 'xxx' - any text: 'aaa' - start any element 'a' - any text: 'bbb' - end any element 'a' - any text: 'ccc' - end any element 'any' - any text: ' - ' -} - -{ - any attribute x = 'x' - any text: ' - ' - start any element 'a' - any text: 'a' - end any element 'a' - any text: ' - ' - start any element 'any' - any attribute x = 'xxx' - any text: 'aaa' - start any element 'a' - any text: 'bbb' - end any element 'a' - any text: 'ccc' - end any element 'any' - any text: ' - ' -} - -{ - any text: ' - ' - start any element 'any' - end any element 'any' - any text: ' - ' -} - -{ - any text: ' - ' - start any element 'any' - any attribute x = 'xxx' - any text: 'aaa' - start any element 'a' - any text: 'bbb' - end any element 'a' - any text: 'ccc' - end any element 'any' - any text: ' - ' -} - -{ - x = x - any text: ' - ' - start any element 'a' - any text: 'a' - end any element 'a' - any text: ' - ' - start any element 'any' - any attribute x = 'xxx' - any text: 'aaa' - start any element 'a' - any text: 'bbb' - end any element 'a' - any text: 'ccc' - end any element 'any' - any text: ' - ' -} - -{ - x = x - any text: 'abc123' -} - diff --git a/tests/cxx/parser/validation/built-in/any-type/test-000.xml b/tests/cxx/parser/validation/built-in/any-type/test-000.xml deleted file mode 100644 index 7875b7e..0000000 --- a/tests/cxx/parser/validation/built-in/any-type/test-000.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - aaabbbccc - - - - a - aaabbbccc - - - - - - - - - - aaabbbccc - - - - a - aaabbbccc - - - - - abc123 - - diff --git a/tests/cxx/parser/validation/built-in/any-type/test.xsd b/tests/cxx/parser/validation/built-in/any-type/test.xsd deleted file mode 100644 index 86a4e13..0000000 --- a/tests/cxx/parser/validation/built-in/any-type/test.xsd +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/parser/validation/built-in/binary/driver.cxx b/tests/cxx/parser/validation/built-in/binary/driver.cxx deleted file mode 100644 index 86575f4..0000000 --- a/tests/cxx/parser/validation/built-in/binary/driver.cxx +++ /dev/null @@ -1,153 +0,0 @@ -// file : tests/cxx/parser/validation/built-in/binary/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the built-in base64Binary and hexBinary types validation. -// -#include - -#include -#include - -using namespace xsd::cxx::parser::validating; - -template -bool -test_post_fail (T& p) -{ - try - { - p._post (); - } - catch (invalid_value const&) - { - return true; - } - - return false; -} - -int -main () -{ - typedef xsd::cxx::parser::buffer buffer; - - // Good. - // - - // hexBinary - // - { - hex_binary_pimpl p; - p.pre (); - p._pre (); - p._characters (" \t\n "); - p._characters (" "); - p._post (); - assert (*p.post_hex_binary () == buffer ()); - } - - { - hex_binary_pimpl p; - p.pre (); - p._pre (); - p._characters (" \t\n313"); - p._characters ("23334356162636a6b "); - p._post (); - assert (*p.post_hex_binary () == buffer ("12345abcjk", 10)); - } - - // base64Binary - // - { - base64_binary_pimpl p; - p.pre (); - p._pre (); - p._characters (" \t\n "); - p._characters ("MTIzND "); - p._characters ("VhYmNqaw = = "); - p._post (); - assert (*p.post_base64_binary () == buffer ("12345abcjk", 10)); - } - - { - base64_binary_pimpl p; - p.pre (); - p._pre (); - p._characters ("YQ=="); - p._post (); - assert (*p.post_base64_binary () == buffer ("a", 1)); - } - - { - base64_binary_pimpl p; - p.pre (); - p._pre (); - p._characters ("YWI="); - p._post (); - assert (*p.post_base64_binary () == buffer ("ab", 2)); - } - - { - base64_binary_pimpl p; - p.pre (); - p._pre (); - p._characters ("YWJj"); - p._post (); - assert (*p.post_base64_binary () == buffer ("abc", 3)); - } - - // Bad - // - - // hexBinary - // - { - hex_binary_pimpl p; - p.pre (); - p._pre (); - p._characters ("313"); - assert (test_post_fail (p)); - } - - { - hex_binary_pimpl p; - p.pre (); - p._pre (); - p._characters ("313233343X6162636a6b"); - assert (test_post_fail (p)); - } - - // base64Binary - // - { - base64_binary_pimpl p; - p.pre (); - p._pre (); - // p._characters (""); - assert (test_post_fail (p)); - } - - { - base64_binary_pimpl p; - p.pre (); - p._pre (); - p._characters ("YQ"); - assert (test_post_fail (p)); - } - - { - base64_binary_pimpl p; - p.pre (); - p._pre (); - p._characters ("=="); - assert (test_post_fail (p)); - } - - { - base64_binary_pimpl p; - p.pre (); - p._pre (); - p._characters ("MTIzNDVhYmNqaw=A"); - assert (test_post_fail (p)); - } -} diff --git a/tests/cxx/parser/validation/built-in/binary/makefile b/tests/cxx/parser/validation/built-in/binary/makefile deleted file mode 100644 index f0c5ae6..0000000 --- a/tests/cxx/parser/validation/built-in/binary/makefile +++ /dev/null @@ -1,70 +0,0 @@ -# file : tests/cxx/parser/validation/built-in/binary/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make - -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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) - -# Define XSD_CXX11 since we include libxsd headers directly. -# -$(call include,$(bld_root)/cxx/standard.make) # cxx_standard -ifeq ($(cxx_standard),c++11) -$(obj) $(dep): cpp_options += -DXSD_CXX11 -endif - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# Clean. -# -$(clean): $(driver).o.clean \ - $(addsuffix .cxx.clean,$(obj)) \ - $(addsuffix .cxx.clean,$(dep)) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver -$(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) diff --git a/tests/cxx/parser/validation/built-in/boolean/driver.cxx b/tests/cxx/parser/validation/built-in/boolean/driver.cxx deleted file mode 100644 index 6a21cb7..0000000 --- a/tests/cxx/parser/validation/built-in/boolean/driver.cxx +++ /dev/null @@ -1,145 +0,0 @@ -// file : tests/cxx/parser/validation/built-in/boolean/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the built-in boolean type validation. -// -#include - -#include -#include - -using namespace xsd::cxx::parser::validating; - -bool -test_post_fail (boolean_pimpl& p) -{ - try - { - p._post (); - } - catch (invalid_value const&) - { - return true; - } - - return false; -} - -int -main () -{ - // Good. - // - { - boolean_pimpl p; - p.pre (); - p._pre (); - p._characters ("true"); - p._post (); - assert (p.post_boolean ()); - } - - { - boolean_pimpl p; - p.pre (); - p._pre (); - p._characters ("1"); - p._post (); - assert (p.post_boolean ()); - } - - { - boolean_pimpl p; - p.pre (); - p._pre (); - p._characters ("false"); - p._post (); - assert (!p.post_boolean ()); - } - - { - boolean_pimpl p; - p.pre (); - p._pre (); - p._characters ("0"); - p._post (); - assert (!p.post_boolean ()); - } - - - { - boolean_pimpl p; - p.pre (); - p._pre (); - p._characters (" true "); - p._post (); - assert (p.post_boolean ()); - } - - { - boolean_pimpl p; - p.pre (); - p._pre (); - p._characters (" "); - p._characters (" \n "); - p._characters (" fa"); - p._characters ("l"); - p._characters ("se "); - p._characters (" \n "); - p._characters (" "); - p._post (); - assert (!p.post_boolean ()); - } - - // Bad - // - { - boolean_pimpl p; - p.pre (); - p._pre (); - //p._characters (""); - assert (test_post_fail (p)); - } - - { - boolean_pimpl p; - p.pre (); - p._pre (); - p._characters (""); - assert (test_post_fail (p)); - } - - { - boolean_pimpl p; - p.pre (); - p._pre (); - p._characters (" "); - assert (test_post_fail (p)); - } - - { - boolean_pimpl p; - p.pre (); - p._pre (); - p._characters (" "); - assert (test_post_fail (p)); - } - - { - boolean_pimpl p; - p.pre (); - p._pre (); - p._characters ("fal"); - p._characters ("s "); - p._characters ("e"); - assert (test_post_fail (p)); - } - - { - boolean_pimpl p; - p.pre (); - p._pre (); - p._characters ("01"); - assert (test_post_fail (p)); - } -} diff --git a/tests/cxx/parser/validation/built-in/boolean/makefile b/tests/cxx/parser/validation/built-in/boolean/makefile deleted file mode 100644 index 52f4e88..0000000 --- a/tests/cxx/parser/validation/built-in/boolean/makefile +++ /dev/null @@ -1,70 +0,0 @@ -# file : tests/cxx/parser/validation/built-in/boolean/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make - -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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) - -# Define XSD_CXX11 since we include libxsd headers directly. -# -$(call include,$(bld_root)/cxx/standard.make) # cxx_standard -ifeq ($(cxx_standard),c++11) -$(obj) $(dep): cpp_options += -DXSD_CXX11 -endif - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# Clean. -# -$(clean): $(driver).o.clean \ - $(addsuffix .cxx.clean,$(obj)) \ - $(addsuffix .cxx.clean,$(dep)) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver -$(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) diff --git a/tests/cxx/parser/validation/built-in/byte/driver.cxx b/tests/cxx/parser/validation/built-in/byte/driver.cxx deleted file mode 100644 index c0e2b99..0000000 --- a/tests/cxx/parser/validation/built-in/byte/driver.cxx +++ /dev/null @@ -1,256 +0,0 @@ -// file : tests/cxx/parser/validation/built-in/byte/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the built-in byte and unsigned byte types validation. -// -#include - -#include -#include - -using namespace xsd::cxx::parser::validating; - -template -bool -test_post_fail (T& p) -{ - try - { - p._post (); - } - catch (invalid_value const&) - { - return true; - } - - return false; -} - -int -main () -{ - // Good. - // - { - byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("123"); - p._post (); - assert (p.post_byte () == 123); - } - - { - byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("\t +123 \n "); - p._post (); - assert (p.post_byte () == 123); - } - - { - byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("-123"); - p._post (); - assert (p.post_byte () == -123); - } - - { - byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("+123"); - p._post (); - assert (p.post_byte () == 123); - } - - { - byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("0000000000000000123"); - p._post (); - assert (p.post_byte () == 123); - } - - { - byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("+0000000000000000123"); - p._post (); - assert (p.post_byte () == 123); - } - - { - byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("-0000000000000000123"); - p._post (); - assert (p.post_byte () == -123); - } - - { - byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("\t \n"); - p._characters (" -"); - p._characters ("00000"); - p._characters ("001"); - p._characters ("23 \n\t"); - p._post (); - assert (p.post_byte () == -123); - } - - { - byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("-128"); - p._post (); - assert (p.post_byte () == -128); - } - - { - byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("127"); - p._post (); - assert (p.post_byte () == 127); - } - - { - unsigned_byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("+123"); - p._post (); - assert (p.post_unsigned_byte () == 123); - } - - { - unsigned_byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("0"); - p._post (); - assert (p.post_unsigned_byte () == 0); - } - - { - unsigned_byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("255"); - p._post (); - assert (p.post_unsigned_byte () == 255); - } - - // Bad - // - { - byte_pimpl p; - p.pre (); - p._pre (); - // p._characters (""); - assert (test_post_fail (p)); - } - - { - byte_pimpl p; - p.pre (); - p._pre (); - p._characters (""); - assert (test_post_fail (p)); - } - - { - byte_pimpl p; - p.pre (); - p._pre (); - p._characters (" \n \t "); - assert (test_post_fail (p)); - } - - { - byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("+"); - assert (test_post_fail (p)); - } - - { - byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("-"); - assert (test_post_fail (p)); - } - - { - byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("++01"); - assert (test_post_fail (p)); - } - - { - byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("--01"); - assert (test_post_fail (p)); - } - - { - byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("-01"); - p._characters (" "); - p._characters ("23 "); - assert (test_post_fail (p)); - } - - { - unsigned_byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("-123"); - assert (test_post_fail (p)); - } - - // Ranges - // - { - byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("-129"); - assert (test_post_fail (p)); - } - - { - byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("128"); - assert (test_post_fail (p)); - } - - { - unsigned_byte_pimpl p; - p.pre (); - p._pre (); - p._characters ("256"); - assert (test_post_fail (p)); - } -} diff --git a/tests/cxx/parser/validation/built-in/byte/makefile b/tests/cxx/parser/validation/built-in/byte/makefile deleted file mode 100644 index afc8174..0000000 --- a/tests/cxx/parser/validation/built-in/byte/makefile +++ /dev/null @@ -1,70 +0,0 @@ -# file : tests/cxx/parser/validation/built-in/byte/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make - -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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) - -# Define XSD_CXX11 since we include libxsd headers directly. -# -$(call include,$(bld_root)/cxx/standard.make) # cxx_standard -ifeq ($(cxx_standard),c++11) -$(obj) $(dep): cpp_options += -DXSD_CXX11 -endif - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# Clean. -# -$(clean): $(driver).o.clean \ - $(addsuffix .cxx.clean,$(obj)) \ - $(addsuffix .cxx.clean,$(dep)) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver -$(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) diff --git a/tests/cxx/parser/validation/built-in/date-time/driver.cxx b/tests/cxx/parser/validation/built-in/date-time/driver.cxx deleted file mode 100644 index 8aa3943..0000000 --- a/tests/cxx/parser/validation/built-in/date-time/driver.cxx +++ /dev/null @@ -1,1533 +0,0 @@ -// file : tests/cxx/parser/validation/built-in/date-time/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the built-in date and time types validation. -// -#include - -#include -#include - -using namespace xsd::cxx::parser::validating; - -template -bool -test_post_fail (T& p) -{ - try - { - p._post (); - } - catch (invalid_value const&) - { - return true; - } - - return false; -} - -int -main () -{ - typedef xsd::cxx::parser::gday gday; - typedef xsd::cxx::parser::gmonth gmonth; - typedef xsd::cxx::parser::gyear gyear; - typedef xsd::cxx::parser::gmonth_day gmonth_day; - typedef xsd::cxx::parser::gyear_month gyear_month; - typedef xsd::cxx::parser::date date; - typedef xsd::cxx::parser::time time; - typedef xsd::cxx::parser::date_time date_time; - typedef xsd::cxx::parser::duration duration; - - // Good. - // - - // gday & time zone parsing - // - { - gday_pimpl p; - p.pre (); - p._pre (); - p._characters (" \t\n "); - p._characters ("---1"); - p._characters ("2+12:00"); - p._post (); - assert (p.post_gday () == gday (12, 12, 00)); - } - - { - gday_pimpl p; - p.pre (); - p._pre (); - p._characters ("---01"); - p._post (); - assert (p.post_gday () == gday (1)); - } - - { - gday_pimpl p; - p.pre (); - p._pre (); - p._characters ("---31"); - p._post (); - assert (p.post_gday () == gday (31)); - } - - { - gday_pimpl p; - p.pre (); - p._pre (); - p._characters ("---15Z"); - p._post (); - assert (p.post_gday () == gday (15, 0, 0)); - } - - { - gday_pimpl p; - p.pre (); - p._pre (); - p._characters ("---15-14:00"); - p._post (); - assert (p.post_gday () == gday (15, -14, 0)); - } - - // gmonth - // - { - gmonth_pimpl p; - p.pre (); - p._pre (); - p._characters (" \t\n "); - p._characters ("--1"); - p._characters ("0+12:00"); - p._post (); - assert (p.post_gmonth () == gmonth (10, 12, 0)); - } - - { - gmonth_pimpl p; - p.pre (); - p._pre (); - p._characters ("--01"); - p._post (); - assert (p.post_gmonth () == gmonth (1)); - } - - { - gmonth_pimpl p; - p.pre (); - p._pre (); - p._characters ("--12Z"); - p._post (); - assert (p.post_gmonth () == gmonth (12, 0, 0)); - } - - // gyear - // - { - gyear_pimpl p; - p.pre (); - p._pre (); - p._characters (" \t\n "); - p._characters ("20"); - p._characters ("07+12:00"); - p._post (); - assert (p.post_gyear () == gyear (2007, 12, 00)); - } - - { - gyear_pimpl p; - p.pre (); - p._pre (); - p._characters ("0001"); - p._post (); - assert (p.post_gyear () == gyear (1)); - } - - { - gyear_pimpl p; - p.pre (); - p._pre (); - p._characters ("-20000Z"); - p._post (); - assert (p.post_gyear () == gyear (-20000, 0, 0)); - } - - // gmonth_day - // - { - gmonth_day_pimpl p; - p.pre (); - p._pre (); - p._characters (" \t\n "); - p._characters ("--1"); - p._characters ("0-28+12:00 "); - p._post (); - assert (p.post_gmonth_day () == gmonth_day (10, 28, 12, 00)); - } - - { - gmonth_day_pimpl p; - p.pre (); - p._pre (); - p._characters ("--12-31"); - p._post (); - assert (p.post_gmonth_day () == gmonth_day (12, 31)); - } - - { - gmonth_day_pimpl p; - p.pre (); - p._pre (); - p._characters ("--01-01Z"); - p._post (); - assert (p.post_gmonth_day () == gmonth_day (1, 1, 0, 0)); - } - - // gyear_month - // - { - gyear_month_pimpl p; - p.pre (); - p._pre (); - p._characters (" \t\n "); - p._characters ("200"); - p._characters ("7-12+12:00 "); - p._post (); - assert (p.post_gyear_month () == gyear_month (2007, 12, 12, 00)); - } - - { - gyear_month_pimpl p; - p.pre (); - p._pre (); - p._characters ("-2007-10"); - p._post (); - assert (p.post_gyear_month () == gyear_month (-2007, 10)); - } - - { - gyear_month_pimpl p; - p.pre (); - p._pre (); - p._characters ("20007-10Z"); - p._post (); - assert (p.post_gyear_month () == gyear_month (20007, 10, 0, 0)); - } - - { - gyear_month_pimpl p; - p.pre (); - p._pre (); - p._characters ("-20007-01"); - p._post (); - assert (p.post_gyear_month () == gyear_month (-20007, 1)); - } - - // date - // - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters (" \t\n "); - p._characters ("200"); - p._characters ("7-12-26+12:00 "); - p._post (); - assert (p.post_date () == date (2007, 12, 26, 12, 0)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("-2007-10-15"); - p._post (); - assert (p.post_date () == date (-2007, 10, 15)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("20007-12-31Z"); - p._post (); - assert (p.post_date () == date (20007, 12, 31, 0, 0)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("-20007-01-01"); - p._post (); - assert (p.post_date () == date (-20007, 1, 1)); - } - - // time - // - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters (" \t\n "); - p._characters ("12:"); - p._characters ("46:23.456+12:00 "); - p._post (); - assert (p.post_time () == time (12, 46, 23.456, 12, 0)); - } - - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters ("12:13:14"); - p._post (); - assert (p.post_time () == time (12, 13, 14.0)); - } - - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters ("12:13:14Z"); - p._post (); - assert (p.post_time () == time (12, 13, 14.0, 0, 0)); - } - - // date_time - // - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters (" \t\n "); - p._characters ("200"); - p._characters ("7-12-26T12:13:14.123+12:00 "); - p._post (); - assert (p.post_date_time () == - date_time (2007, 12, 26, 12, 13, 14.123, 12, 0)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("-2007-10-15T12:13:14"); - p._post (); - assert (p.post_date_time () == date_time (-2007, 10, 15, 12, 13, 14.0)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("20007-12-31T12:13:14Z"); - p._post (); - assert (p.post_date_time () == - date_time (20007, 12, 31, 12, 13, 14.0, 0, 0)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("-20007-01-01T12:13:14"); - p._post (); - assert (p.post_date_time () == date_time (-20007, 1, 1, 12, 13, 14.0)); - } - - // duration - // - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters (" \t\n "); - p._characters ("-P200"); - p._characters ("7Y13M32DT25H61M61.123S "); - p._post (); - assert (p.post_duration () == - duration (true, 2007, 13, 32, 25, 61, 61.123)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("P1Y"); - p._post (); - assert (p.post_duration () == duration (false, 1, 0, 0, 0, 0, 0.0)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("P1M"); - p._post (); - assert (p.post_duration () == duration (false, 0, 1, 0, 0, 0, 0.0)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("P1D"); - p._post (); - assert (p.post_duration () == duration (false, 0, 0, 1, 0, 0, 0.0)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("PT1H"); - p._post (); - assert (p.post_duration () == duration (false, 0, 0, 0, 1, 0, 0.0)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("PT1M"); - p._post (); - assert (p.post_duration () == duration (false, 0, 0, 0, 0, 1, 0.0)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("PT1.1S"); - p._post (); - assert (p.post_duration () == duration (false, 0, 0, 0, 0, 0, 1.1)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("P1YT1S"); - p._post (); - assert (p.post_duration () == duration (false, 1, 0, 0, 0, 0, 1.0)); - } - - // Bad - // - - // gday & time zone parsing - // - { - gday_pimpl p; - p.pre (); - p._pre (); - // p._characters (""); - assert (test_post_fail (p)); - } - - { - gday_pimpl p; - p.pre (); - p._pre (); - p._characters ("--12"); - assert (test_post_fail (p)); - } - - { - gday_pimpl p; - p.pre (); - p._pre (); - p._characters ("---1"); - assert (test_post_fail (p)); - } - - { - gday_pimpl p; - p.pre (); - p._pre (); - p._characters ("---00"); - assert (test_post_fail (p)); - } - - { - gday_pimpl p; - p.pre (); - p._pre (); - p._characters ("---32"); - assert (test_post_fail (p)); - } - - { - gday_pimpl p; - p.pre (); - p._pre (); - p._characters ("---2X"); - assert (test_post_fail (p)); - } - - { - gday_pimpl p; - p.pre (); - p._pre (); - p._characters ("---12asd"); - assert (test_post_fail (p)); - } - - { - gday_pimpl p; - p.pre (); - p._pre (); - p._characters ("---12X"); - assert (test_post_fail (p)); - } - - { - gday_pimpl p; - p.pre (); - p._pre (); - p._characters ("---1212:00"); - assert (test_post_fail (p)); - } - - { - gday_pimpl p; - p.pre (); - p._pre (); - p._characters ("---12+2:00"); - assert (test_post_fail (p)); - } - - { - gday_pimpl p; - p.pre (); - p._pre (); - p._characters ("---12+1200"); - assert (test_post_fail (p)); - } - - { - gday_pimpl p; - p.pre (); - p._pre (); - p._characters ("---12+15:00"); - assert (test_post_fail (p)); - } - - { - gday_pimpl p; - p.pre (); - p._pre (); - p._characters ("---12+12:60"); - assert (test_post_fail (p)); - } - - { - gday_pimpl p; - p.pre (); - p._pre (); - p._characters ("---12+14:01"); - assert (test_post_fail (p)); - } - - // gmonth - // - { - gmonth_pimpl p; - p.pre (); - p._pre (); - // p._characters (""); - assert (test_post_fail (p)); - } - - { - gmonth_pimpl p; - p.pre (); - p._pre (); - p._characters ("-12"); - assert (test_post_fail (p)); - } - - { - gmonth_pimpl p; - p.pre (); - p._pre (); - p._characters ("--00"); - assert (test_post_fail (p)); - } - - { - gmonth_pimpl p; - p.pre (); - p._pre (); - p._characters ("--13"); - assert (test_post_fail (p)); - } - - { - gmonth_pimpl p; - p.pre (); - p._pre (); - p._characters ("--1X"); - assert (test_post_fail (p)); - } - - { - gmonth_pimpl p; - p.pre (); - p._pre (); - p._characters ("--11+12:3o"); - assert (test_post_fail (p)); - } - - // gyear - // - { - gyear_pimpl p; - p.pre (); - p._pre (); - // p._characters (""); - assert (test_post_fail (p)); - } - - { - gyear_pimpl p; - p.pre (); - p._pre (); - p._characters ("207"); - assert (test_post_fail (p)); - } - - { - gyear_pimpl p; - p.pre (); - p._pre (); - p._characters ("-207"); - assert (test_post_fail (p)); - } - - { - gyear_pimpl p; - p.pre (); - p._pre (); - p._characters ("-0000"); - assert (test_post_fail (p)); - } - - { - gyear_pimpl p; - p.pre (); - p._pre (); - p._characters ("20X7"); - assert (test_post_fail (p)); - } - - { - gyear_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007+12:3o"); - assert (test_post_fail (p)); - } - - // gmonth_day - // - { - gmonth_day_pimpl p; - p.pre (); - p._pre (); - // p._characters (""); - assert (test_post_fail (p)); - } - - { - gmonth_day_pimpl p; - p.pre (); - p._pre (); - p._characters ("-12-12"); - assert (test_post_fail (p)); - } - - { - gmonth_day_pimpl p; - p.pre (); - p._pre (); - p._characters ("--1212"); - assert (test_post_fail (p)); - } - - { - gmonth_day_pimpl p; - p.pre (); - p._pre (); - p._characters ("--12?12"); - assert (test_post_fail (p)); - } - - { - gmonth_day_pimpl p; - p.pre (); - p._pre (); - p._characters ("--00-12"); - assert (test_post_fail (p)); - } - - { - gmonth_day_pimpl p; - p.pre (); - p._pre (); - p._characters ("--12-00"); - assert (test_post_fail (p)); - } - - { - gmonth_day_pimpl p; - p.pre (); - p._pre (); - p._characters ("--13-23"); - assert (test_post_fail (p)); - } - - { - gmonth_day_pimpl p; - p.pre (); - p._pre (); - p._characters ("--12-32"); - assert (test_post_fail (p)); - } - - { - gmonth_day_pimpl p; - p.pre (); - p._pre (); - p._characters ("--1X-12"); - assert (test_post_fail (p)); - } - - { - gmonth_day_pimpl p; - p.pre (); - p._pre (); - p._characters ("--12-2X"); - assert (test_post_fail (p)); - } - - { - gmonth_day_pimpl p; - p.pre (); - p._pre (); - p._characters ("--11-11+12:3o"); - assert (test_post_fail (p)); - } - - // gyear_month - // - { - gyear_month_pimpl p; - p.pre (); - p._pre (); - // p._characters (""); - assert (test_post_fail (p)); - } - - { - gyear_month_pimpl p; - p.pre (); - p._pre (); - p._characters ("207-01"); - assert (test_post_fail (p)); - } - - { - gyear_month_pimpl p; - p.pre (); - p._pre (); - p._characters ("-207-01"); - assert (test_post_fail (p)); - } - - { - gyear_month_pimpl p; - p.pre (); - p._pre (); - p._characters ("0000-01"); - assert (test_post_fail (p)); - } - - { - gyear_month_pimpl p; - p.pre (); - p._pre (); - p._characters ("20X7-01"); - assert (test_post_fail (p)); - } - - { - gyear_month_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007"); - assert (test_post_fail (p)); - } - - { - gyear_month_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007?12"); - assert (test_post_fail (p)); - } - - { - gyear_month_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-0"); - assert (test_post_fail (p)); - } - - { - gyear_month_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-00"); - assert (test_post_fail (p)); - } - - { - gyear_month_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-13"); - assert (test_post_fail (p)); - } - - { - gyear_month_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-1X"); - assert (test_post_fail (p)); - } - - { - gyear_month_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-01+12:3o"); - assert (test_post_fail (p)); - } - - // date - // - { - date_pimpl p; - p.pre (); - p._pre (); - // p._characters (""); - assert (test_post_fail (p)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("207-01-01"); - assert (test_post_fail (p)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("-207-01-01"); - assert (test_post_fail (p)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("0000-01-01"); - assert (test_post_fail (p)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("20X7-01-01"); - assert (test_post_fail (p)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007"); - assert (test_post_fail (p)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007?01-01"); - assert (test_post_fail (p)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-0-01"); - assert (test_post_fail (p)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-00-01"); - assert (test_post_fail (p)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-13-01"); - assert (test_post_fail (p)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-1X-01"); - assert (test_post_fail (p)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-10"); - assert (test_post_fail (p)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-10?12"); - assert (test_post_fail (p)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-10-"); - assert (test_post_fail (p)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-10-0"); - assert (test_post_fail (p)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-10-00"); - assert (test_post_fail (p)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-10-32"); - assert (test_post_fail (p)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-10-2X"); - assert (test_post_fail (p)); - } - - { - date_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-01-01+12:3o"); - assert (test_post_fail (p)); - } - - // time - // - { - time_pimpl p; - p.pre (); - p._pre (); - // p._characters (""); - assert (test_post_fail (p)); - } - - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters ("1:01:01"); - assert (test_post_fail (p)); - } - - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2X:01:01"); - assert (test_post_fail (p)); - } - - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters ("23"); - assert (test_post_fail (p)); - } - - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters ("23?01:01"); - assert (test_post_fail (p)); - } - - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters ("23:0:01"); - assert (test_post_fail (p)); - } - - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters ("23:60:01"); - assert (test_post_fail (p)); - } - - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters ("23:4X:01"); - assert (test_post_fail (p)); - } - - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters ("23:10"); - assert (test_post_fail (p)); - } - - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters ("23:10?12"); - assert (test_post_fail (p)); - } - - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters ("23:10:"); - assert (test_post_fail (p)); - } - - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters ("23:10:0"); - assert (test_post_fail (p)); - } - - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters ("23:10:01."); - assert (test_post_fail (p)); - } - - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters ("23:10:60"); - assert (test_post_fail (p)); - } - - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters ("23:10:2X"); - assert (test_post_fail (p)); - } - - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters ("24:01:00"); - assert (test_post_fail (p)); - } - - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters ("24:00:01"); - assert (test_post_fail (p)); - } - - { - time_pimpl p; - p.pre (); - p._pre (); - p._characters ("23:01:01+12:3o"); - assert (test_post_fail (p)); - } - - // date_time - // - { - date_time_pimpl p; - p.pre (); - p._pre (); - // p._characters (""); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("207-01-01T12:13:14"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("-207-01-01T12:13:14"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("0000-01-01T12:13:14"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("20X7-01-01T12:13:14"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007?01-01T12:13:14"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-0-01T12:13:14"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-00-01T12:13:14"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-13-01T12:13:14"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-1X-01T12:13:14"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-10"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-10?12T12:13:14"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-10-T12:13:14"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-10-0T12:13:14"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-10-00T12:13:14"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-10-32T12:13:14"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-10-2XT12:13:14"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-01-01T1:01:01"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-01-01T2X:01:01"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-01-01T23"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-01-01T23?01:01"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-01-01T23:0:01"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-01-01T23:60:01"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-01-01T23:4X:01"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-01-01T23:10"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-01-01T23:10?12"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-01-01T23:10:"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-01-01T23:10:0"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-01-01T23:10:01."); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-01-01T23:10:60"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-01-01T23:10:2X"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-01-01T24:01:00"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-01-01T24:00:01"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("23:01:01+12:3o"); - assert (test_post_fail (p)); - } - - { - date_time_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007-01-01T12:13:14+12:3o"); - assert (test_post_fail (p)); - } - - // duration - // - { - duration_pimpl p; - p.pre (); - p._pre (); - // p._characters (""); - assert (test_post_fail (p)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("2007Y"); - assert (test_post_fail (p)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("-2007Y"); - assert (test_post_fail (p)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("P-2007Y"); - assert (test_post_fail (p)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("P-1M"); - assert (test_post_fail (p)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("P-1D"); - assert (test_post_fail (p)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("PT-1H"); - assert (test_post_fail (p)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("PT-1M"); - assert (test_post_fail (p)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("PT-1.1S"); - assert (test_post_fail (p)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("P1H1M1S"); - assert (test_post_fail (p)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("P1M1Y"); - assert (test_post_fail (p)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("PT1S1H"); - assert (test_post_fail (p)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("PT1H1Y"); - assert (test_post_fail (p)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("P1Ygarbage"); - assert (test_post_fail (p)); - } - - { - duration_pimpl p; - p.pre (); - p._pre (); - p._characters ("P1YT"); - assert (test_post_fail (p)); - } -} diff --git a/tests/cxx/parser/validation/built-in/date-time/makefile b/tests/cxx/parser/validation/built-in/date-time/makefile deleted file mode 100644 index 42d60e8..0000000 --- a/tests/cxx/parser/validation/built-in/date-time/makefile +++ /dev/null @@ -1,70 +0,0 @@ -# file : tests/cxx/parser/validation/built-in/date-time/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make - -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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) - -# Define XSD_CXX11 since we include libxsd headers directly. -# -$(call include,$(bld_root)/cxx/standard.make) # cxx_standard -ifeq ($(cxx_standard),c++11) -$(obj) $(dep): cpp_options += -DXSD_CXX11 -endif - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# Clean. -# -$(clean): $(driver).o.clean \ - $(addsuffix .cxx.clean,$(obj)) \ - $(addsuffix .cxx.clean,$(dep)) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver -$(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) diff --git a/tests/cxx/parser/validation/built-in/float/driver.cxx b/tests/cxx/parser/validation/built-in/float/driver.cxx deleted file mode 100644 index 7563aa7..0000000 --- a/tests/cxx/parser/validation/built-in/float/driver.cxx +++ /dev/null @@ -1,285 +0,0 @@ -// file : tests/cxx/parser/validation/built-in/float/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the built-in float, double, and decimal types validation. -// -#include -#include - -#include -#include - -using namespace xsd::cxx::parser::validating; - -template -bool -test_post_fail (T& p) -{ - try - { - p._post (); - } - catch (invalid_value const&) - { - return true; - } - - return false; -} - -int -main () -{ - // Good. - // - - // float - // - { - float_pimpl p; - p.pre (); - p._pre (); - p._characters (" 0000123.456 "); - p._post (); - assert (p.post_float () == 123.456F); - } - - { - float_pimpl p; - p.pre (); - p._pre (); - p._characters ("-12.345E2"); - p._post (); - assert (p.post_float () == -12.345E2F); - } - - { - float_pimpl p; - p.pre (); - p._pre (); - p._characters ("0"); - p._post (); - assert (p.post_float () == 0.0F); - } - - { - float_pimpl p; - p.pre (); - p._pre (); - p._characters ("-0"); - p._post (); - assert (p.post_float () == -0.0F); - } - - { - float_pimpl p; - p.pre (); - p._pre (); - p._characters ("INF"); - p._post (); - assert (isinf (p.post_float ())); - } - - { - float_pimpl p; - p.pre (); - p._pre (); - p._characters ("-INF"); - p._post (); - assert (isinf (p.post_float ())); - } - - { - float_pimpl p; - p.pre (); - p._pre (); - p._characters ("NaN"); - p._post (); - assert (isnan (p.post_float ())); - } - - // double - // - { - double_pimpl p; - p.pre (); - p._pre (); - p._characters (" 0000123.456789 "); - p._post (); - assert (p.post_double () == 123.456789); - } - - { - double_pimpl p; - p.pre (); - p._pre (); - p._characters ("-12.3456789E2"); - p._post (); - assert (p.post_double () == -12.3456789E2); - } - - { - double_pimpl p; - p.pre (); - p._pre (); - p._characters ("0"); - p._post (); - assert (p.post_double () == 0.0); - } - - { - double_pimpl p; - p.pre (); - p._pre (); - p._characters ("-0"); - p._post (); - assert (p.post_double () == -0.0); - } - - { - double_pimpl p; - p.pre (); - p._pre (); - p._characters ("INF"); - p._post (); - assert (isinf (p.post_double ())); - } - - { - double_pimpl p; - p.pre (); - p._pre (); - p._characters ("-INF"); - p._post (); - assert (isinf (p.post_double ())); - } - - { - double_pimpl p; - p.pre (); - p._pre (); - p._characters ("NaN"); - p._post (); - assert (isnan (p.post_double ())); - } - - // decimal - // - { - decimal_pimpl p; - p.pre (); - p._pre (); - p._characters (" 0000123.456789 "); - p._post (); - assert (p.post_decimal () == 123.456789); - } - - { - decimal_pimpl p; - p.pre (); - p._pre (); - p._characters ("-123.45678912345"); - p._post (); - assert (p.post_decimal () == -123.45678912345); - } - - { - decimal_pimpl p; - p.pre (); - p._pre (); - p._characters ("0"); - p._post (); - assert (p.post_decimal () == 0.0); - } - - { - decimal_pimpl p; - p.pre (); - p._pre (); - p._characters ("-0"); - p._post (); - assert (p.post_decimal () == -0.0); - } - - - // Bad - // - - // float - // - { - float_pimpl p; - p.pre (); - p._pre (); - p._characters ("+INF"); - assert (test_post_fail (p)); - } - - { - float_pimpl p; - p.pre (); - p._pre (); - p._characters ("1.45 E2"); - assert (test_post_fail (p)); - } - - // double - // - { - double_pimpl p; - p.pre (); - p._pre (); - p._characters ("+INF"); - assert (test_post_fail (p)); - } - - { - double_pimpl p; - p.pre (); - p._pre (); - p._characters ("1.45 E2"); - assert (test_post_fail (p)); - } - - // decimal - // - { - decimal_pimpl p; - p.pre (); - p._pre (); - p._characters ("INF"); - assert (test_post_fail (p)); - } - - { - decimal_pimpl p; - p.pre (); - p._pre (); - p._characters ("+INF"); - assert (test_post_fail (p)); - } - - { - decimal_pimpl p; - p.pre (); - p._pre (); - p._characters ("-INF"); - assert (test_post_fail (p)); - } - - { - decimal_pimpl p; - p.pre (); - p._pre (); - p._characters ("NaN"); - assert (test_post_fail (p)); - } - - { - decimal_pimpl p; - p.pre (); - p._pre (); - p._characters ("1.45 2"); - assert (test_post_fail (p)); - } -} diff --git a/tests/cxx/parser/validation/built-in/float/makefile b/tests/cxx/parser/validation/built-in/float/makefile deleted file mode 100644 index 68fac22..0000000 --- a/tests/cxx/parser/validation/built-in/float/makefile +++ /dev/null @@ -1,70 +0,0 @@ -# file : tests/cxx/parser/validation/built-in/float/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make - -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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) - -# Define XSD_CXX11 since we include libxsd headers directly. -# -$(call include,$(bld_root)/cxx/standard.make) # cxx_standard -ifeq ($(cxx_standard),c++11) -$(obj) $(dep): cpp_options += -DXSD_CXX11 -endif - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# Clean. -# -$(clean): $(driver).o.clean \ - $(addsuffix .cxx.clean,$(obj)) \ - $(addsuffix .cxx.clean,$(dep)) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver -$(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) diff --git a/tests/cxx/parser/validation/built-in/int/driver.cxx b/tests/cxx/parser/validation/built-in/int/driver.cxx deleted file mode 100644 index 18e83ca..0000000 --- a/tests/cxx/parser/validation/built-in/int/driver.cxx +++ /dev/null @@ -1,116 +0,0 @@ -// file : tests/cxx/parser/validation/built-in/int/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the built-in int and unsigned int types validation. -// -#include - -#include -#include - -using namespace xsd::cxx::parser::validating; - -template -bool -test_post_fail (T& p) -{ - try - { - p._post (); - } - catch (invalid_value const&) - { - return true; - } - - return false; -} - -int -main () -{ - // Good. - // - { - int_pimpl p; - p.pre (); - p._pre (); - p._characters ("-2147483648"); - p._post (); - assert (p.post_int () == -2147483648); - } - - { - int_pimpl p; - p.pre (); - p._pre (); - p._characters ("0"); - p._post (); - assert (p.post_int () == 0); - } - - { - int_pimpl p; - p.pre (); - p._pre (); - p._characters ("2147483647"); - p._post (); - assert (p.post_int () == 2147483647); - } - - { - unsigned_int_pimpl p; - p.pre (); - p._pre (); - p._characters ("0"); - p._post (); - assert (p.post_unsigned_int () == 0); - } - - { - unsigned_int_pimpl p; - p.pre (); - p._pre (); - p._characters ("4294967295"); - p._post (); - assert (p.post_unsigned_int () == 4294967295); - } - - // Bad - // - - { - unsigned_int_pimpl p; - p.pre (); - p._pre (); - p._characters ("-123"); - assert (test_post_fail (p)); - } - - - // Ranges - // - { - int_pimpl p; - p.pre (); - p._pre (); - p._characters ("-2147483649"); - assert (test_post_fail (p)); - } - - { - int_pimpl p; - p.pre (); - p._pre (); - p._characters ("2147483648"); - assert (test_post_fail (p)); - } - - { - unsigned_int_pimpl p; - p.pre (); - p._pre (); - p._characters ("4294967296"); - assert (test_post_fail (p)); - } -} diff --git a/tests/cxx/parser/validation/built-in/int/makefile b/tests/cxx/parser/validation/built-in/int/makefile deleted file mode 100644 index 7a13105..0000000 --- a/tests/cxx/parser/validation/built-in/int/makefile +++ /dev/null @@ -1,70 +0,0 @@ -# file : tests/cxx/parser/validation/built-in/int/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make - -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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) - -# Define XSD_CXX11 since we include libxsd headers directly. -# -$(call include,$(bld_root)/cxx/standard.make) # cxx_standard -ifeq ($(cxx_standard),c++11) -$(obj) $(dep): cpp_options += -DXSD_CXX11 -endif - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# Clean. -# -$(clean): $(driver).o.clean \ - $(addsuffix .cxx.clean,$(obj)) \ - $(addsuffix .cxx.clean,$(dep)) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver -$(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) diff --git a/tests/cxx/parser/validation/built-in/integer/driver.cxx b/tests/cxx/parser/validation/built-in/integer/driver.cxx deleted file mode 100644 index 7eeb708..0000000 --- a/tests/cxx/parser/validation/built-in/integer/driver.cxx +++ /dev/null @@ -1,303 +0,0 @@ -// file : tests/cxx/parser/validation/built-in/int/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the built-in integer & friends types validation. -// -#include - -#include -#include -#include - -#include -#include - -using namespace std; -using namespace xsd::cxx::parser::validating; - -template -bool -test_post_fail (T& p) -{ - try - { - p._post (); - } - catch (invalid_value const&) - { - return true; - } - - return false; -} - -int -main () -{ - // Good. - // - - std::string min; - std::string max; - std::string umax; - - { - ostringstream ostr; - ostr << LLONG_MIN; - min = ostr.str (); - } - - { - ostringstream ostr; - ostr << LLONG_MAX; - max = ostr.str (); - } - - { - ostringstream ostr; - ostr << ULLONG_MAX; - umax = ostr.str (); - } - - // integer - // - { - integer_pimpl p; - p.pre (); - p._pre (); - p._characters (min.c_str ()); - p._post (); - assert (p.post_integer () == LLONG_MIN); - } - - { - integer_pimpl p; - p.pre (); - p._pre (); - p._characters ("0"); - p._post (); - assert (p.post_integer () == 0); - } - - { - integer_pimpl p; - p.pre (); - p._pre (); - p._characters (max.c_str ()); - p._post (); - assert (p.post_integer () == LLONG_MAX); - } - - // negative_integer - // - { - negative_integer_pimpl p; - p.pre (); - p._pre (); - p._characters (min.c_str ()); - p._post (); - assert (p.post_negative_integer () == LLONG_MIN); - } - - { - negative_integer_pimpl p; - p.pre (); - p._pre (); - p._characters ("-1"); - p._post (); - assert (p.post_negative_integer () == -1); - } - - // non_positive_integer - // - { - non_positive_integer_pimpl p; - p.pre (); - p._pre (); - p._characters (min.c_str ()); - p._post (); - assert (p.post_non_positive_integer () == LLONG_MIN); - } - - { - non_positive_integer_pimpl p; - p.pre (); - p._pre (); - p._characters ("+0"); - p._post (); - assert (p.post_non_positive_integer () == 0); - } - - // positive_integer - // - { - positive_integer_pimpl p; - p.pre (); - p._pre (); - p._characters ("1"); - p._post (); - assert (p.post_positive_integer () == 1); - } - - { - positive_integer_pimpl p; - p.pre (); - p._pre (); - p._characters (umax.c_str ()); - p._post (); - assert (p.post_positive_integer () == ULLONG_MAX); - } - - // non_negative_integer - // - /* - { - non_negative_integer_pimpl p; - p.pre (); - p._pre (); - p._characters ("-0"); - p._post (); - assert (p.post_non_negative_integer () == 0); - } - */ - - { - non_negative_integer_pimpl p; - p.pre (); - p._pre (); - p._characters ("0"); - p._post (); - assert (p.post_non_negative_integer () == 0); - } - - { - non_negative_integer_pimpl p; - p.pre (); - p._pre (); - p._characters (umax.c_str ()); - p._post (); - assert (p.post_non_negative_integer () == ULLONG_MAX); - } - - - // Bad - // - - std::string past_min (min); - std::string past_max (max); - std::string past_umax (umax); - - assert (*past_min.rbegin () != '9'); - assert (*past_max.rbegin () != '9'); - assert (*past_umax.rbegin () != '9'); - - (*past_min.rbegin ())++; - (*past_max.rbegin ())++; - (*past_umax.rbegin ())++; - - // integer - // - { - integer_pimpl p; - p.pre (); - p._pre (); - p._characters (past_min.c_str ()); - assert (test_post_fail (p)); - } - - { - integer_pimpl p; - p.pre (); - p._pre (); - p._characters (past_max.c_str ()); - assert (test_post_fail (p)); - } - - // negative_integer - // - { - negative_integer_pimpl p; - p.pre (); - p._pre (); - p._characters (past_min.c_str ()); - assert (test_post_fail (p)); - } - - { - negative_integer_pimpl p; - p.pre (); - p._pre (); - p._characters ("-0"); - assert (test_post_fail (p)); - } - - { - negative_integer_pimpl p; - p.pre (); - p._pre (); - p._characters ("1"); - assert (test_post_fail (p)); - } - - // non_positive_integer - // - { - non_positive_integer_pimpl p; - p.pre (); - p._pre (); - p._characters (past_min.c_str ()); - assert (test_post_fail (p)); - } - - { - non_positive_integer_pimpl p; - p.pre (); - p._pre (); - p._characters ("1"); - assert (test_post_fail (p)); - } - - // positive_integer - // - { - positive_integer_pimpl p; - p.pre (); - p._pre (); - p._characters ("-1"); - assert (test_post_fail (p)); - } - - { - positive_integer_pimpl p; - p.pre (); - p._pre (); - p._characters ("+0"); - assert (test_post_fail (p)); - } - - { - positive_integer_pimpl p; - p.pre (); - p._pre (); - p._characters (past_umax.c_str ()); - assert (test_post_fail (p)); - } - - // non_negative_integer - // - { - non_negative_integer_pimpl p; - p.pre (); - p._pre (); - p._characters ("-1"); - assert (test_post_fail (p)); - } - - { - non_negative_integer_pimpl p; - p.pre (); - p._pre (); - p._characters (past_umax.c_str ()); - assert (test_post_fail (p)); - } -} diff --git a/tests/cxx/parser/validation/built-in/integer/makefile b/tests/cxx/parser/validation/built-in/integer/makefile deleted file mode 100644 index 66a7dd6..0000000 --- a/tests/cxx/parser/validation/built-in/integer/makefile +++ /dev/null @@ -1,70 +0,0 @@ -# file : tests/cxx/parser/validation/built-in/integer/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make - -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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) - -# Define XSD_CXX11 since we include libxsd headers directly. -# -$(call include,$(bld_root)/cxx/standard.make) # cxx_standard -ifeq ($(cxx_standard),c++11) -$(obj) $(dep): cpp_options += -DXSD_CXX11 -endif - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# Clean. -# -$(clean): $(driver).o.clean \ - $(addsuffix .cxx.clean,$(obj)) \ - $(addsuffix .cxx.clean,$(dep)) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver -$(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) diff --git a/tests/cxx/parser/validation/built-in/long/driver.cxx b/tests/cxx/parser/validation/built-in/long/driver.cxx deleted file mode 100644 index a44ae70..0000000 --- a/tests/cxx/parser/validation/built-in/long/driver.cxx +++ /dev/null @@ -1,116 +0,0 @@ -// file : tests/cxx/parser/validation/built-in/long/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the built-in long and unsigned long types validation. -// -#include - -#include -#include - -using namespace xsd::cxx::parser::validating; - -template -bool -test_post_fail (T& p) -{ - try - { - p._post (); - } - catch (invalid_value const&) - { - return true; - } - - return false; -} - -int -main () -{ - // Good. - // - { - long_pimpl p; - p.pre (); - p._pre (); - p._characters ("-9223372036854775808"); - p._post (); - assert (p.post_long () == (-9223372036854775807LL - 1)); - } - - { - long_pimpl p; - p.pre (); - p._pre (); - p._characters ("0"); - p._post (); - assert (p.post_long () == 0); - } - - { - long_pimpl p; - p.pre (); - p._pre (); - p._characters ("9223372036854775807"); - p._post (); - assert (p.post_long () == 9223372036854775807LL); - } - - { - unsigned_long_pimpl p; - p.pre (); - p._pre (); - p._characters ("0"); - p._post (); - assert (p.post_unsigned_long () == 0); - } - - { - unsigned_long_pimpl p; - p.pre (); - p._pre (); - p._characters ("18446744073709551615"); - p._post (); - assert (p.post_unsigned_long () == 18446744073709551615ULL); - } - - // Bad - // - - { - unsigned_long_pimpl p; - p.pre (); - p._pre (); - p._characters ("-123"); - assert (test_post_fail (p)); - } - - - // Ranges - // - { - long_pimpl p; - p.pre (); - p._pre (); - p._characters ("-9223372036854775809"); - assert (test_post_fail (p)); - } - - { - long_pimpl p; - p.pre (); - p._pre (); - p._characters ("9223372036854775808"); - assert (test_post_fail (p)); - } - - { - unsigned_long_pimpl p; - p.pre (); - p._pre (); - p._characters ("18446744073709551616"); - assert (test_post_fail (p)); - } -} diff --git a/tests/cxx/parser/validation/built-in/long/makefile b/tests/cxx/parser/validation/built-in/long/makefile deleted file mode 100644 index 5854363..0000000 --- a/tests/cxx/parser/validation/built-in/long/makefile +++ /dev/null @@ -1,70 +0,0 @@ -# file : tests/cxx/parser/validation/built-in/long/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make - -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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) - -# Define XSD_CXX11 since we include libxsd headers directly. -# -$(call include,$(bld_root)/cxx/standard.make) # cxx_standard -ifeq ($(cxx_standard),c++11) -$(obj) $(dep): cpp_options += -DXSD_CXX11 -endif - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# Clean. -# -$(clean): $(driver).o.clean \ - $(addsuffix .cxx.clean,$(obj)) \ - $(addsuffix .cxx.clean,$(dep)) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver -$(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) diff --git a/tests/cxx/parser/validation/built-in/makefile b/tests/cxx/parser/validation/built-in/makefile deleted file mode 100644 index 79eab4f..0000000 --- a/tests/cxx/parser/validation/built-in/makefile +++ /dev/null @@ -1,17 +0,0 @@ -# file : tests/cxx/parser/validation/built-in/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -tests := any-type binary boolean byte date-time float int integer long \ -qname short string uri - -default := $(out_base)/ -test := $(out_base)/.test -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) -$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) - -$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tests/cxx/parser/validation/built-in/qname/driver.cxx b/tests/cxx/parser/validation/built-in/qname/driver.cxx deleted file mode 100644 index 6da6f2f..0000000 --- a/tests/cxx/parser/validation/built-in/qname/driver.cxx +++ /dev/null @@ -1,105 +0,0 @@ -// file : tests/cxx/parser/validation/built-in/qname/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the built-in QName type validation. -// -#include - -#include -#include - -using namespace xsd::cxx::parser::validating; - -bool -test_post_fail (qname_pimpl& p) -{ - try - { - p._post (); - } - catch (invalid_value const&) - { - return true; - } - - return false; -} - -int -main () -{ - typedef xsd::cxx::parser::qname qname; - - // Good. - // - { - qname_pimpl p; - p.pre (); - p._pre (); - p._characters (" xsi"); - p._characters (":"); - p._characters ("schemaLocation"); - p._post (); - assert (p.post_qname () == qname ("xsi", "schemaLocation")); - } - - { - qname_pimpl p; - p.pre (); - p._pre (); - p._characters ("schemaLocation"); - p._post (); - assert (p.post_qname () == qname ("schemaLocation")); - } - - - // Bad - // - { - qname_pimpl p; - p.pre (); - p._pre (); - //p._characters (""); - assert (test_post_fail (p)); - } - - { - qname_pimpl p; - p.pre (); - p._pre (); - p._characters (":"); - assert (test_post_fail (p)); - } - - { - qname_pimpl p; - p.pre (); - p._pre (); - p._characters ("xsi:"); - assert (test_post_fail (p)); - } - - { - qname_pimpl p; - p.pre (); - p._pre (); - p._characters (":schemaLocation"); - assert (test_post_fail (p)); - } - - { - qname_pimpl p; - p.pre (); - p._pre (); - p._characters ("x?i:schemaLocation"); - assert (test_post_fail (p)); - } - - { - qname_pimpl p; - p.pre (); - p._pre (); - p._characters ("xsi:schema Location"); - assert (test_post_fail (p)); - } -} diff --git a/tests/cxx/parser/validation/built-in/qname/makefile b/tests/cxx/parser/validation/built-in/qname/makefile deleted file mode 100644 index c442812..0000000 --- a/tests/cxx/parser/validation/built-in/qname/makefile +++ /dev/null @@ -1,70 +0,0 @@ -# file : tests/cxx/parser/validation/built-in/qname/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make - -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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) - -# Define XSD_CXX11 since we include libxsd headers directly. -# -$(call include,$(bld_root)/cxx/standard.make) # cxx_standard -ifeq ($(cxx_standard),c++11) -$(obj) $(dep): cpp_options += -DXSD_CXX11 -endif - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# Clean. -# -$(clean): $(driver).o.clean \ - $(addsuffix .cxx.clean,$(obj)) \ - $(addsuffix .cxx.clean,$(dep)) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver -$(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) diff --git a/tests/cxx/parser/validation/built-in/short/driver.cxx b/tests/cxx/parser/validation/built-in/short/driver.cxx deleted file mode 100644 index 42009a1..0000000 --- a/tests/cxx/parser/validation/built-in/short/driver.cxx +++ /dev/null @@ -1,116 +0,0 @@ -// file : tests/cxx/parser/validation/built-in/short/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the built-in short and unsigned short types validation. -// -#include - -#include -#include - -using namespace xsd::cxx::parser::validating; - -template -bool -test_post_fail (T& p) -{ - try - { - p._post (); - } - catch (invalid_value const&) - { - return true; - } - - return false; -} - -int -main () -{ - // Good. - // - { - short_pimpl p; - p.pre (); - p._pre (); - p._characters ("-32768"); - p._post (); - assert (p.post_short () == -32768); - } - - { - short_pimpl p; - p.pre (); - p._pre (); - p._characters ("0"); - p._post (); - assert (p.post_short () == 0); - } - - { - short_pimpl p; - p.pre (); - p._pre (); - p._characters ("32767"); - p._post (); - assert (p.post_short () == 32767); - } - - { - unsigned_short_pimpl p; - p.pre (); - p._pre (); - p._characters ("0"); - p._post (); - assert (p.post_unsigned_short () == 0); - } - - { - unsigned_short_pimpl p; - p.pre (); - p._pre (); - p._characters ("65535"); - p._post (); - assert (p.post_unsigned_short () == 65535); - } - - // Bad - // - - { - unsigned_short_pimpl p; - p.pre (); - p._pre (); - p._characters ("-1234"); - assert (test_post_fail (p)); - } - - - // Ranges - // - { - short_pimpl p; - p.pre (); - p._pre (); - p._characters ("-32769"); - assert (test_post_fail (p)); - } - - { - short_pimpl p; - p.pre (); - p._pre (); - p._characters ("32768"); - assert (test_post_fail (p)); - } - - { - unsigned_short_pimpl p; - p.pre (); - p._pre (); - p._characters ("65536"); - assert (test_post_fail (p)); - } -} diff --git a/tests/cxx/parser/validation/built-in/short/makefile b/tests/cxx/parser/validation/built-in/short/makefile deleted file mode 100644 index 05f8e2c..0000000 --- a/tests/cxx/parser/validation/built-in/short/makefile +++ /dev/null @@ -1,70 +0,0 @@ -# file : tests/cxx/parser/validation/built-in/short/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make - -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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) - -# Define XSD_CXX11 since we include libxsd headers directly. -# -$(call include,$(bld_root)/cxx/standard.make) # cxx_standard -ifeq ($(cxx_standard),c++11) -$(obj) $(dep): cpp_options += -DXSD_CXX11 -endif - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# Clean. -# -$(clean): $(driver).o.clean \ - $(addsuffix .cxx.clean,$(obj)) \ - $(addsuffix .cxx.clean,$(dep)) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver -$(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) diff --git a/tests/cxx/parser/validation/built-in/string/driver.cxx b/tests/cxx/parser/validation/built-in/string/driver.cxx deleted file mode 100644 index b5da70d..0000000 --- a/tests/cxx/parser/validation/built-in/string/driver.cxx +++ /dev/null @@ -1,512 +0,0 @@ -// file : tests/cxx/parser/validation/built-in/string/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the built-in string & friends types validation. -// -#include -#include - -#include -#include - -using namespace xsd::cxx::parser::validating; - -template -bool -test_post_fail (T& p) -{ - try - { - p._post_impl (); // List implementation needs this to be post_impl. - } - catch (invalid_value const&) - { - return true; - } - - return false; -} - -int -main () -{ - typedef xsd::cxx::parser::string_sequence strings; - - // Good. - // - - // string - // - { - string_pimpl p; - p.pre (); - p._pre (); - p._characters (" \n\t"); - p._characters (" aaa "); - p._characters ("bbb"); - p._characters (" "); - p._post (); - assert (p.post_string () == " \n\t aaa bbb "); - } - - // normalized_string - // - { - normalized_string_pimpl p; - p.pre (); - p._pre (); - p._characters (" \n\t"); - p._characters (" aaa \n\t "); - p._characters (" bbb"); - p._characters (" "); - p._post (); - assert (p.post_normalized_string () == " aaa bbb "); - } - - // token - // - { - token_pimpl p; - p.pre (); - p._pre (); - p._characters (" \n\t"); - p._characters (" aaa \n\t "); - p._characters (" bbb \n\t"); - p._characters (" "); - p._post (); - assert (p.post_token () == "aaa bbb"); - } - - // name - // - { - name_pimpl p; - p.pre (); - p._pre (); - p._characters (" \n\t"); - p._characters (" a:b-c_d123 "); - p._characters (" "); - p._post (); - assert (p.post_name () == "a:b-c_d123"); - } - - { - name_pimpl p; - p.pre (); - p._pre (); - p._characters (" \n\t"); - p._characters (" _12 "); - p._characters (" "); - p._post (); - assert (p.post_name () == "_12"); - } - - { - name_pimpl p; - p.pre (); - p._pre (); - p._characters (" \n\t"); - p._characters (" :12 "); - p._characters (" "); - p._post (); - assert (p.post_name () == ":12"); - } - - // nmtoken - // - { - nmtoken_pimpl p; - p.pre (); - p._pre (); - p._characters (" \n\t"); - p._characters (" 123a:b-c_d123 "); - p._characters (" \n\t"); - p._characters (" "); - p._post (); - assert (p.post_nmtoken () == "123a:b-c_d123"); - } - - // nmtokens - // - { - strings s; - s.push_back ("123"); - s.push_back ("abc"); - - nmtokens_pimpl p; - p.pre (); - p._pre (); - p._characters (" \n\t"); - p._characters (" 123 "); - p._characters (" \n\t abc "); - p._characters (" "); - p._post (); - assert (p.post_nmtokens () == s); - } - - // ncname - // - { - ncname_pimpl p; - p.pre (); - p._pre (); - p._characters (" \n\t"); - p._characters (" a.b-c_d123 "); - p._characters (" "); - p._post (); - assert (p.post_ncname () == "a.b-c_d123"); - } - - // id - // - { - id_pimpl p; - p.pre (); - p._pre (); - p._characters (" \n\t"); - p._characters (" a.b-c_d123 "); - p._characters (" "); - p._post (); - assert (p.post_id () == "a.b-c_d123"); - } - - // idref - // - { - idref_pimpl p; - p.pre (); - p._pre (); - p._characters (" \n\t"); - p._characters (" a.b-c_d123 "); - p._characters (" "); - p._post (); - assert (p.post_idref () == "a.b-c_d123"); - } - - // idrefs - // - { - strings s; - s.push_back ("a123"); - s.push_back ("abc"); - - idrefs_pimpl p; - p.pre (); - p._pre (); - p._characters (" \n\t"); - p._characters (" a123 "); - p._characters (" \n\t abc "); - p._characters (" "); - p._post (); - assert (p.post_idrefs () == s); - } - - // language - // - { - language_pimpl p; - p.pre (); - p._pre (); - p._characters (" x "); - p._post (); - assert (p.post_language () == "x"); - } - - { - language_pimpl p; - p.pre (); - p._pre (); - p._characters (" en "); - p._post (); - assert (p.post_language () == "en"); - } - - { - language_pimpl p; - p.pre (); - p._pre (); - p._characters (" en"); - p._characters ("-us "); - p._post (); - assert (p.post_language () == "en-us"); - } - - { - language_pimpl p; - p.pre (); - p._pre (); - p._characters ("one-two-three-four44-seven77-eight888"); - p._post (); - assert (p.post_language () == "one-two-three-four44-seven77-eight888"); - } - - - // Bad - // - - // name - // - { - name_pimpl p; - p.pre (); - p._pre (); - p._characters (""); - assert (test_post_fail (p)); - } - - { - name_pimpl p; - p.pre (); - p._pre (); - p._characters (".a"); - assert (test_post_fail (p)); - } - - { - name_pimpl p; - p.pre (); - p._pre (); - p._characters ("-a"); - assert (test_post_fail (p)); - } - - { - name_pimpl p; - p.pre (); - p._pre (); - p._characters ("1a"); - assert (test_post_fail (p)); - } - - { - name_pimpl p; - p.pre (); - p._pre (); - p._characters ("a,b"); - assert (test_post_fail (p)); - } - - { - name_pimpl p; - p.pre (); - p._pre (); - p._characters ("a b"); - assert (test_post_fail (p)); - } - - { - name_pimpl p; - p.pre (); - p._pre (); - p._characters ("a p; - p.pre (); - p._pre (); - p._characters (""); - assert (test_post_fail (p)); - } - - { - nmtoken_pimpl p; - p.pre (); - p._pre (); - p._characters ("a,b"); - assert (test_post_fail (p)); - } - - { - nmtoken_pimpl p; - p.pre (); - p._pre (); - p._characters ("a b"); - assert (test_post_fail (p)); - } - - { - nmtoken_pimpl p; - p.pre (); - p._pre (); - p._characters ("a p; - p.pre (); - p._pre (); - p._characters (" "); - p._characters (" \t\n "); - assert (test_post_fail (p)); - } - - { - nmtokens_pimpl p; - p.pre (); - p._pre (); - p._characters ("ab a,b"); - assert (test_post_fail (p)); - } - - // ncname - // - { - ncname_pimpl p; - p.pre (); - p._pre (); - p._characters (""); - assert (test_post_fail (p)); - } - - { - ncname_pimpl p; - p.pre (); - p._pre (); - p._characters (".a"); - assert (test_post_fail (p)); - } - - { - ncname_pimpl p; - p.pre (); - p._pre (); - p._characters ("-a"); - assert (test_post_fail (p)); - } - - { - ncname_pimpl p; - p.pre (); - p._pre (); - p._characters (":a"); - assert (test_post_fail (p)); - } - - { - ncname_pimpl p; - p.pre (); - p._pre (); - p._characters ("1a"); - assert (test_post_fail (p)); - } - - { - ncname_pimpl p; - p.pre (); - p._pre (); - p._characters ("1:a"); - assert (test_post_fail (p)); - } - - { - ncname_pimpl p; - p.pre (); - p._pre (); - p._characters ("a,b"); - assert (test_post_fail (p)); - } - - { - ncname_pimpl p; - p.pre (); - p._pre (); - p._characters ("a b"); - assert (test_post_fail (p)); - } - - { - ncname_pimpl p; - p.pre (); - p._pre (); - p._characters ("a p; - p.pre (); - p._pre (); - p._characters ("a b"); - assert (test_post_fail (p)); - } - - // idref - // - { - idref_pimpl p; - p.pre (); - p._pre (); - p._characters ("a b"); - assert (test_post_fail (p)); - } - - // idrefs - // - { - idrefs_pimpl p; - p.pre (); - p._pre (); - p._characters (" "); - p._characters (" \t\n "); - assert (test_post_fail (p)); - } - - { - idrefs_pimpl p; - p.pre (); - p._pre (); - p._characters ("ab a p; - p.pre (); - p._pre (); - p._characters (" "); - assert (test_post_fail (p)); - } - - { - language_pimpl p; - p.pre (); - p._pre (); - p._characters ("en-"); - assert (test_post_fail (p)); - } - - { - language_pimpl p; - p.pre (); - p._pre (); - p._characters ("a1"); - assert (test_post_fail (p)); - } - - { - language_pimpl p; - p.pre (); - p._pre (); - p._characters ("en+us"); - assert (test_post_fail (p)); - } - - { - language_pimpl p; - p.pre (); - p._pre (); - p._characters ("en-nine99999"); - assert (test_post_fail (p)); - } -} diff --git a/tests/cxx/parser/validation/built-in/string/makefile b/tests/cxx/parser/validation/built-in/string/makefile deleted file mode 100644 index bcdae7e..0000000 --- a/tests/cxx/parser/validation/built-in/string/makefile +++ /dev/null @@ -1,70 +0,0 @@ -# file : tests/cxx/parser/validation/built-in/string/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make - -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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) - -# Define XSD_CXX11 since we include libxsd headers directly. -# -$(call include,$(bld_root)/cxx/standard.make) # cxx_standard -ifeq ($(cxx_standard),c++11) -$(obj) $(dep): cpp_options += -DXSD_CXX11 -endif - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# Clean. -# -$(clean): $(driver).o.clean \ - $(addsuffix .cxx.clean,$(obj)) \ - $(addsuffix .cxx.clean,$(dep)) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver -$(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) diff --git a/tests/cxx/parser/validation/built-in/uri/driver.cxx b/tests/cxx/parser/validation/built-in/uri/driver.cxx deleted file mode 100644 index 9e487e6..0000000 --- a/tests/cxx/parser/validation/built-in/uri/driver.cxx +++ /dev/null @@ -1,53 +0,0 @@ -// file : tests/cxx/parser/validation/built-in/uri/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the built-in anyURI type validation. -// -#include - -#include -#include - -using namespace xsd::cxx::parser::validating; - -int -main () -{ - // Good. - // - { - uri_pimpl p; - p.pre (); - p._pre (); - p._characters (" "); - p._post (); - assert (p.post_uri () == ""); - } - - { - uri_pimpl p; - p.pre (); - p._pre (); - p._characters ("relative"); - p._post (); - assert (p.post_uri () == "relative"); - } - - { - uri_pimpl p; - p.pre (); - p._pre (); - p._characters ("#id"); - p._post (); - assert (p.post_uri () == "#id"); - } - - { - uri_pimpl p; - p.pre (); - p._pre (); - p._characters ("http://www.example.com/foo#bar"); - p._post (); - assert (p.post_uri () == "http://www.example.com/foo#bar"); - } -} diff --git a/tests/cxx/parser/validation/built-in/uri/makefile b/tests/cxx/parser/validation/built-in/uri/makefile deleted file mode 100644 index ae7e8bd..0000000 --- a/tests/cxx/parser/validation/built-in/uri/makefile +++ /dev/null @@ -1,70 +0,0 @@ -# file : tests/cxx/parser/validation/built-in/uri/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make - -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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) - -# Define XSD_CXX11 since we include libxsd headers directly. -# -$(call include,$(bld_root)/cxx/standard.make) # cxx_standard -ifeq ($(cxx_standard),c++11) -$(obj) $(dep): cpp_options += -DXSD_CXX11 -endif - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# Clean. -# -$(clean): $(driver).o.clean \ - $(addsuffix .cxx.clean,$(obj)) \ - $(addsuffix .cxx.clean,$(dep)) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver -$(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) diff --git a/tests/cxx/parser/validation/choice/driver.cxx b/tests/cxx/parser/validation/choice/driver.cxx deleted file mode 100644 index af30727..0000000 --- a/tests/cxx/parser/validation/choice/driver.cxx +++ /dev/null @@ -1,126 +0,0 @@ -// file : tests/cxx/parser/validation/choice/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the choice compositor validation. -// - -#include -#include -#include - -#include "test-pskel.hxx" - -using namespace std; -using namespace test; -using xml_schema::ro_string; - -struct choice_pimpl: choice_pskel -{ - virtual void - pre () - { - cout << "{" << endl; - } - - virtual void - a (string const& v) - { - cout << " a = " << v << endl; - } - - virtual void - b (string const& v) - { - cout << " b = " << v << endl; - } - - virtual void - c (string const& v) - { - cout << " c = " << v << endl; - } - - virtual void - d (string const& v) - { - cout << " d = " << v << endl; - } - - virtual void - _start_any_element (ro_string const& ns, - ro_string const& name, - ro_string const*) - { - cout << " any: " << ns << "#" << name << endl - << " {" << endl; - } - - virtual void - _any_characters (ro_string const& v) - { - cout << " chars = " << v << endl; - } - - virtual void - _end_any_element (ro_string const&, ro_string const&) - { - cout << " }" << endl; - } - - virtual void - post_choice () - { - cout << "}" << endl - << endl; - } -}; - -struct type_pimpl: type_pskel -{ -}; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - xml_schema::string_pimpl string_p; - choice_pimpl choice_p; - type_pimpl type_p; - - choice_p.parsers (string_p, string_p, string_p, string_p); - type_p.parsers (choice_p); - - xml_schema::document doc_p (type_p, "test", "root"); - - try - { - ifstream ifs (argv[1]); - type_p.pre (); - doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); - type_p.post_type (); - } - catch (xml_schema::exception const& e) - { - cout << " " << e << endl - << "}" << endl - << endl; - } - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - catch (ios_base::failure const&) - { - cerr << "io failure" << endl; - return 1; - } -} diff --git a/tests/cxx/parser/validation/choice/makefile b/tests/cxx/parser/validation/choice/makefile deleted file mode 100644 index 93b05c5..0000000 --- a/tests/cxx/parser/validation/choice/makefile +++ /dev/null @@ -1,92 +0,0 @@ -# file : tests/cxx/parser/validation/choice/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -tests := 000 001 002 003 004 - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-validation -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -test_targets := $(addprefix $(out_base)/.test-,$(tests)) - -$(test): $(test_targets) -$(test_targets): driver := $(driver) - -.PHONY: $(out_base)/.test-% -$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std - $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -) - - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/validation/choice/test-000.std b/tests/cxx/parser/validation/choice/test-000.std deleted file mode 100644 index 856b7f5..0000000 --- a/tests/cxx/parser/validation/choice/test-000.std +++ /dev/null @@ -1,22 +0,0 @@ -{ - a = a - b = b -} - -{ - c = c - d = d - any: other#any - { - chars = any - } - a = a -} - -{ - c = c - d = d - d = d - a = a -} - diff --git a/tests/cxx/parser/validation/choice/test-000.xml b/tests/cxx/parser/validation/choice/test-000.xml deleted file mode 100644 index 39b9614..0000000 --- a/tests/cxx/parser/validation/choice/test-000.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - a - - b - - - - c - d - - any - - a - - - - c - d - - d - - a - - - diff --git a/tests/cxx/parser/validation/choice/test-001.std b/tests/cxx/parser/validation/choice/test-001.std deleted file mode 100644 index 8a78666..0000000 --- a/tests/cxx/parser/validation/choice/test-001.std +++ /dev/null @@ -1,4 +0,0 @@ -{ - :8:12 error: expected element 'a' -} - diff --git a/tests/cxx/parser/validation/choice/test-001.xml b/tests/cxx/parser/validation/choice/test-001.xml deleted file mode 100644 index c509e0d..0000000 --- a/tests/cxx/parser/validation/choice/test-001.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - diff --git a/tests/cxx/parser/validation/choice/test-002.std b/tests/cxx/parser/validation/choice/test-002.std deleted file mode 100644 index 1dc1a3a..0000000 --- a/tests/cxx/parser/validation/choice/test-002.std +++ /dev/null @@ -1,11 +0,0 @@ -{ - c = c - d = d - any: other#any - { - chars = any - } - a = a - :14:8 error: unexpected element 'b' -} - diff --git a/tests/cxx/parser/validation/choice/test-002.xml b/tests/cxx/parser/validation/choice/test-002.xml deleted file mode 100644 index 3b7e663..0000000 --- a/tests/cxx/parser/validation/choice/test-002.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - c - d - - any - - a - b - - - diff --git a/tests/cxx/parser/validation/choice/test-003.std b/tests/cxx/parser/validation/choice/test-003.std deleted file mode 100644 index 29d5e44..0000000 --- a/tests/cxx/parser/validation/choice/test-003.std +++ /dev/null @@ -1,5 +0,0 @@ -{ - c = c - :9:12 error: expected element 'd' -} - diff --git a/tests/cxx/parser/validation/choice/test-003.xml b/tests/cxx/parser/validation/choice/test-003.xml deleted file mode 100644 index ba15c7e..0000000 --- a/tests/cxx/parser/validation/choice/test-003.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - c - - - diff --git a/tests/cxx/parser/validation/choice/test-004.std b/tests/cxx/parser/validation/choice/test-004.std deleted file mode 100644 index 4a7530b..0000000 --- a/tests/cxx/parser/validation/choice/test-004.std +++ /dev/null @@ -1,4 +0,0 @@ -{ - :8:8 error: expected element 'a' instead of 'x' -} - diff --git a/tests/cxx/parser/validation/choice/test-004.xml b/tests/cxx/parser/validation/choice/test-004.xml deleted file mode 100644 index f6960dd..0000000 --- a/tests/cxx/parser/validation/choice/test-004.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - x - - - diff --git a/tests/cxx/parser/validation/choice/test.xsd b/tests/cxx/parser/validation/choice/test.xsd deleted file mode 100644 index 8132bbb..0000000 --- a/tests/cxx/parser/validation/choice/test.xsd +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/parser/validation/makefile b/tests/cxx/parser/validation/makefile deleted file mode 100644 index 600d9dd..0000000 --- a/tests/cxx/parser/validation/makefile +++ /dev/null @@ -1,16 +0,0 @@ -# file : tests/cxx/parser/validation/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -tests := all any attribute built-in choice restriction sequence - -default := $(out_base)/ -test := $(out_base)/.test -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) -$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) - -$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tests/cxx/parser/validation/restriction/driver.cxx b/tests/cxx/parser/validation/restriction/driver.cxx deleted file mode 100644 index 6f9a871..0000000 --- a/tests/cxx/parser/validation/restriction/driver.cxx +++ /dev/null @@ -1,107 +0,0 @@ -// file : tests/cxx/parser/validation/restriction/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the restriction compositor validation. -// - -#include -#include -#include - -#include "test-pskel.hxx" - -using namespace std; -using namespace test; - -struct base_a_pimpl: base_a_pskel -{ -}; - -struct restriction_a_pimpl: restriction_a_pskel -{ -}; - -struct extension_b_pimpl: extension_b_pskel -{ -}; - -struct restriction_b_pimpl: restriction_b_pskel -{ -}; - -struct type_b_pimpl: type_b_pskel -{ -}; - -struct type_r_pimpl: type_r_pskel -{ -}; - - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - xml_schema::string_pimpl string_p; - base_a_pimpl base_a_p; - restriction_a_pimpl restriction_a_p; - extension_b_pimpl extension_b_p; - restriction_b_pimpl restriction_b_p; - type_b_pimpl type_b_p; - type_r_pimpl type_r_p; - - base_a_p.parsers (string_p, string_p, string_p, - string_p, string_p, string_p); - - restriction_a_p.parsers (string_p, string_p, string_p, - string_p, string_p, string_p); - - extension_b_p.parsers (string_p, string_p, string_p, - string_p, string_p); - - restriction_b_p.parsers (string_p, string_p, string_p, - string_p, string_p); - - type_b_p.parsers (base_a_p, extension_b_p); - type_r_p.parsers (restriction_a_p, restriction_b_p); - - xml_schema::document doc_b_p (type_b_p, "test", "root"); - xml_schema::document doc_r_p (type_r_p, "test", "root"); - - { - ifstream ifs (argv[1]); - type_b_p.pre (); - doc_b_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); - type_b_p.post_type_b (); - } - - try - { - ifstream ifs (argv[1]); - type_r_p.pre (); - doc_r_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); - type_r_p.post_type_r (); - } - catch (xml_schema::exception const& e) - { - cout << e << endl; - } - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - catch (ios_base::failure const&) - { - cerr << "io failure" << endl; - return 1; - } -} diff --git a/tests/cxx/parser/validation/restriction/makefile b/tests/cxx/parser/validation/restriction/makefile deleted file mode 100644 index 61af2bf..0000000 --- a/tests/cxx/parser/validation/restriction/makefile +++ /dev/null @@ -1,92 +0,0 @@ -# file : tests/cxx/parser/validation/restriction/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -tests := 000 001 002 003 004 005 - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-validation -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -test_targets := $(addprefix $(out_base)/.test-,$(tests)) - -$(test): $(test_targets) -$(test_targets): driver := $(driver) - -.PHONY: $(out_base)/.test-% -$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std - $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -) - - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/validation/restriction/test-000.std b/tests/cxx/parser/validation/restriction/test-000.std deleted file mode 100644 index e69de29..0000000 diff --git a/tests/cxx/parser/validation/restriction/test-000.xml b/tests/cxx/parser/validation/restriction/test-000.xml deleted file mode 100644 index 21402b4..0000000 --- a/tests/cxx/parser/validation/restriction/test-000.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - a - b - c - - - - a - b - c - - - - a - b - - - - a - c - - - - a - - - diff --git a/tests/cxx/parser/validation/restriction/test-001.std b/tests/cxx/parser/validation/restriction/test-001.std deleted file mode 100644 index 5077837..0000000 --- a/tests/cxx/parser/validation/restriction/test-001.std +++ /dev/null @@ -1 +0,0 @@ -:7:8 error: expected element 'a' instead of 'b' diff --git a/tests/cxx/parser/validation/restriction/test-001.xml b/tests/cxx/parser/validation/restriction/test-001.xml deleted file mode 100644 index 4015302..0000000 --- a/tests/cxx/parser/validation/restriction/test-001.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - b - c - - - diff --git a/tests/cxx/parser/validation/restriction/test-002.std b/tests/cxx/parser/validation/restriction/test-002.std deleted file mode 100644 index f12c342..0000000 --- a/tests/cxx/parser/validation/restriction/test-002.std +++ /dev/null @@ -1 +0,0 @@ -:10:19 error: expected attribute 'z' diff --git a/tests/cxx/parser/validation/restriction/test-002.xml b/tests/cxx/parser/validation/restriction/test-002.xml deleted file mode 100644 index eb7684c..0000000 --- a/tests/cxx/parser/validation/restriction/test-002.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - a - b - c - - - diff --git a/tests/cxx/parser/validation/restriction/test-003.std b/tests/cxx/parser/validation/restriction/test-003.std deleted file mode 100644 index 0c65175..0000000 --- a/tests/cxx/parser/validation/restriction/test-003.std +++ /dev/null @@ -1 +0,0 @@ -:11:8 error: unexpected element 'a' diff --git a/tests/cxx/parser/validation/restriction/test-003.xml b/tests/cxx/parser/validation/restriction/test-003.xml deleted file mode 100644 index 49f18c7..0000000 --- a/tests/cxx/parser/validation/restriction/test-003.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - a - b - c - - a - b - c - - - diff --git a/tests/cxx/parser/validation/restriction/test-004.std b/tests/cxx/parser/validation/restriction/test-004.std deleted file mode 100644 index 5077837..0000000 --- a/tests/cxx/parser/validation/restriction/test-004.std +++ /dev/null @@ -1 +0,0 @@ -:7:8 error: expected element 'a' instead of 'b' diff --git a/tests/cxx/parser/validation/restriction/test-004.xml b/tests/cxx/parser/validation/restriction/test-004.xml deleted file mode 100644 index 115cd38..0000000 --- a/tests/cxx/parser/validation/restriction/test-004.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - b - - - diff --git a/tests/cxx/parser/validation/restriction/test-005.std b/tests/cxx/parser/validation/restriction/test-005.std deleted file mode 100644 index e92de14..0000000 --- a/tests/cxx/parser/validation/restriction/test-005.std +++ /dev/null @@ -1 +0,0 @@ -:9:19 error: expected attribute 'y' diff --git a/tests/cxx/parser/validation/restriction/test-005.xml b/tests/cxx/parser/validation/restriction/test-005.xml deleted file mode 100644 index e9ab7d9..0000000 --- a/tests/cxx/parser/validation/restriction/test-005.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - a - b - - - diff --git a/tests/cxx/parser/validation/restriction/test.xsd b/tests/cxx/parser/validation/restriction/test.xsd deleted file mode 100644 index 158ded5..0000000 --- a/tests/cxx/parser/validation/restriction/test.xsd +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/parser/validation/sequence/driver.cxx b/tests/cxx/parser/validation/sequence/driver.cxx deleted file mode 100644 index 61652b3..0000000 --- a/tests/cxx/parser/validation/sequence/driver.cxx +++ /dev/null @@ -1,139 +0,0 @@ -// file : tests/cxx/parser/validation/sequence/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the sequence compositor validation. -// - -#include -#include -#include - -#include "test-pskel.hxx" - -using namespace std; -using namespace test; -using xml_schema::ro_string; - -struct sequence_pimpl: sequence_pskel -{ - virtual void - pre () - { - cout << "{" << endl; - } - - virtual void - a (string const& v) - { - cout << " a = " << v << endl; - } - - virtual void - b (string const& v) - { - cout << " b = " << v << endl; - } - - virtual void - c (string const& v) - { - cout << " c = " << v << endl; - } - - virtual void - d (string const& v) - { - cout << " d = " << v << endl; - } - - virtual void - e (string const& v) - { - cout << " e = " << v << endl; - } - - virtual void - f (string const& v) - { - cout << " f = " << v << endl; - } - - virtual void - _start_any_element (ro_string const& ns, - ro_string const& name, - ro_string const*) - { - cout << " any: " << ns << "#" << name << endl - << " {" << endl; - } - - virtual void - _any_characters (ro_string const& v) - { - cout << " chars = " << v << endl; - } - - virtual void - _end_any_element (ro_string const&, ro_string const&) - { - cout << " }" << endl; - } - - virtual void - post_sequence () - { - cout << "}" << endl - << endl; - } -}; - -struct type_pimpl: type_pskel -{ -}; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - xml_schema::string_pimpl string_p; - sequence_pimpl sequence_p; - type_pimpl type_p; - - sequence_p.parsers (string_p, string_p, string_p, - string_p, string_p, string_p); - type_p.parsers (sequence_p); - - xml_schema::document doc_p (type_p, "test", "root"); - - try - { - ifstream ifs (argv[1]); - type_p.pre (); - doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); - type_p.post_type (); - } - catch (xml_schema::exception const& e) - { - cout << " " << e << endl - << "}" << endl - << endl; - } - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - catch (ios_base::failure const&) - { - cerr << "io failure" << endl; - return 1; - } -} diff --git a/tests/cxx/parser/validation/sequence/makefile b/tests/cxx/parser/validation/sequence/makefile deleted file mode 100644 index f0a7b14..0000000 --- a/tests/cxx/parser/validation/sequence/makefile +++ /dev/null @@ -1,92 +0,0 @@ -# file : tests/cxx/parser/validation/sequence/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -tests := 000 001 002 003 004 005 006 - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-validation -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -test_targets := $(addprefix $(out_base)/.test-,$(tests)) - -$(test): $(test_targets) -$(test_targets): driver := $(driver) - -.PHONY: $(out_base)/.test-% -$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std - $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -) - - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/validation/sequence/test-000.std b/tests/cxx/parser/validation/sequence/test-000.std deleted file mode 100644 index 8a44762..0000000 --- a/tests/cxx/parser/validation/sequence/test-000.std +++ /dev/null @@ -1,56 +0,0 @@ -{ - c = c - d = d - any: test#any - { - chars = aaa - any: #a - { - chars = bbb - } - chars = ccc - } - f = f - e = e -} - -{ - a = a - b = b - c = c - d = d - d = d - d = d - any: other#any - { - chars = any - } - f = f - e = e - e = e -} - -{ - a = a - b = b - c = c - d = d - d = d - d = d - any: other#any - { - chars = any - } - f = f - e = e - e = e - c = c - d = d - any: test#any - { - chars = any - } - f = f - e = e -} - diff --git a/tests/cxx/parser/validation/sequence/test-000.xml b/tests/cxx/parser/validation/sequence/test-000.xml deleted file mode 100644 index 9bcbd7e..0000000 --- a/tests/cxx/parser/validation/sequence/test-000.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - c - d - aaabbbccc - f - e - - - - a - b - c - d - d - d - any - f - e - e - - - - a - b - c - d - d - d - any - f - e - e - - c - d - any - f - e - - - diff --git a/tests/cxx/parser/validation/sequence/test-001.std b/tests/cxx/parser/validation/sequence/test-001.std deleted file mode 100644 index 20dea34..0000000 --- a/tests/cxx/parser/validation/sequence/test-001.std +++ /dev/null @@ -1,4 +0,0 @@ -{ - :8:14 error: expected element 'a' -} - diff --git a/tests/cxx/parser/validation/sequence/test-001.xml b/tests/cxx/parser/validation/sequence/test-001.xml deleted file mode 100644 index 67d33ce..0000000 --- a/tests/cxx/parser/validation/sequence/test-001.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - diff --git a/tests/cxx/parser/validation/sequence/test-002.std b/tests/cxx/parser/validation/sequence/test-002.std deleted file mode 100644 index 61343e7..0000000 --- a/tests/cxx/parser/validation/sequence/test-002.std +++ /dev/null @@ -1,20 +0,0 @@ -{ - c = c - d = d - any: test#any - { - chars = any - } - f = f - e = e - c = c - d = d - any: test#any - { - chars = any - } - f = f - e = e - :20:8 error: unexpected element 'c' -} - diff --git a/tests/cxx/parser/validation/sequence/test-002.xml b/tests/cxx/parser/validation/sequence/test-002.xml deleted file mode 100644 index be25fcf..0000000 --- a/tests/cxx/parser/validation/sequence/test-002.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - c - d - any - f - e - - c - d - any - f - e - - c - d - any - f - e - - - diff --git a/tests/cxx/parser/validation/sequence/test-003.std b/tests/cxx/parser/validation/sequence/test-003.std deleted file mode 100644 index c4e1e46..0000000 --- a/tests/cxx/parser/validation/sequence/test-003.std +++ /dev/null @@ -1,5 +0,0 @@ -{ - a = a - :9:8 error: expected element 'b' instead of 'a' -} - diff --git a/tests/cxx/parser/validation/sequence/test-003.xml b/tests/cxx/parser/validation/sequence/test-003.xml deleted file mode 100644 index af7d21d..0000000 --- a/tests/cxx/parser/validation/sequence/test-003.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - a - a - c - d - any - f - e - - - diff --git a/tests/cxx/parser/validation/sequence/test-004.std b/tests/cxx/parser/validation/sequence/test-004.std deleted file mode 100644 index f4c1d4d..0000000 --- a/tests/cxx/parser/validation/sequence/test-004.std +++ /dev/null @@ -1,4 +0,0 @@ -{ - :8:8 error: expected element 'a' instead of 'd' -} - diff --git a/tests/cxx/parser/validation/sequence/test-004.xml b/tests/cxx/parser/validation/sequence/test-004.xml deleted file mode 100644 index a58b6d4..0000000 --- a/tests/cxx/parser/validation/sequence/test-004.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - d - any - f - e - - - diff --git a/tests/cxx/parser/validation/sequence/test-005.std b/tests/cxx/parser/validation/sequence/test-005.std deleted file mode 100644 index 9fa7904..0000000 --- a/tests/cxx/parser/validation/sequence/test-005.std +++ /dev/null @@ -1,6 +0,0 @@ -{ - c = c - d = d - :10:13 error: expected element '##targetNamespace#*' instead of 'other1#any' -} - diff --git a/tests/cxx/parser/validation/sequence/test-005.xml b/tests/cxx/parser/validation/sequence/test-005.xml deleted file mode 100644 index e3dd03d..0000000 --- a/tests/cxx/parser/validation/sequence/test-005.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - c - d - any - f - e - - - diff --git a/tests/cxx/parser/validation/sequence/test-006.std b/tests/cxx/parser/validation/sequence/test-006.std deleted file mode 100644 index eb79f47..0000000 --- a/tests/cxx/parser/validation/sequence/test-006.std +++ /dev/null @@ -1,13 +0,0 @@ -{ - c = c - d = d - any: test#any - { - chars = any - } - f = f - e = e - e = e - :14:8 error: unexpected element 'e' -} - diff --git a/tests/cxx/parser/validation/sequence/test-006.xml b/tests/cxx/parser/validation/sequence/test-006.xml deleted file mode 100644 index e1ecd69..0000000 --- a/tests/cxx/parser/validation/sequence/test-006.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - c - d - any - f - e - e - e - - - diff --git a/tests/cxx/parser/validation/sequence/test.xsd b/tests/cxx/parser/validation/sequence/test.xsd deleted file mode 100644 index 8753f54..0000000 --- a/tests/cxx/parser/validation/sequence/test.xsd +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/any-type/driver.cxx b/tests/cxx/tree/any-type/driver.cxx deleted file mode 100644 index ae81081..0000000 --- a/tests/cxx/tree/any-type/driver.cxx +++ /dev/null @@ -1,144 +0,0 @@ -// file : tests/cxx/tree/any-type/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test anyType and anySimpleType content extraction. -// - -#include // std::auto_ptr/unique_ptr -#include // std::move -#include -#include - -#include -#include - -#include "test.hxx" // Get XSD_CXX11 defined. - -#include - -using namespace std; -using namespace test; -using namespace xercesc; - -namespace xml = xsd::cxx::xml; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - XMLPlatformUtils::Initialize (); - - try - { - // Test parsing - // - XSD_AUTO_PTR r (root (argv[1])); - - // Test API. - // - { - assert (type::a_default_value ().text_content () == "default value"); - } - - { - xml_schema::simple_type x ("fox"); - assert (x.text_content () == "fox"); - x.text_content ("foo"); - assert (x.text_content () == "foo"); - x.text_content ().clear (); - assert (x.text_content () == ""); - x.text_content () = "baz"; - r->s ().push_back (x); - } - - { - xml_schema::type x; - - DOMDocument& doc (x.dom_content_document ()); - - // Copy. - // - DOMElement* e (doc.createElement (xml::string ("dummy").c_str ())); - e->setAttribute (xml::string ("x").c_str (), - xml::string ("foo").c_str ()); - e->setTextContent (xml::string ("data").c_str ()); - x.dom_content ().set (*e); - e->release (); - - r->t ().push_back (x); - } - - { - XSD_AUTO_PTR x (new xml_schema::type); - - DOMDocument& doc (x->dom_content_document ()); - - // Assume ownership. - // - DOMElement* e (doc.createElement (xml::string ("dummy").c_str ())); - e->setAttribute (xml::string ("x").c_str (), - xml::string ("foo").c_str ()); - e->setTextContent (xml::string ("data").c_str ()); - x->dom_content ().set (e); - -#ifdef XSD_CXX11 - r->t ().push_back (std::move (x)); -#else - r->t ().push_back (x); -#endif - } - - // Test printing. - // - cout << *r << endl - << endl; - - // Test serialization. - // - xml_schema::namespace_infomap map; - - map["t"].name = "test"; - map["t"].schema = "test.xsd"; - map["o"].name = "other"; - - stringstream iostr; - root (iostr, *r, map); - - cout << iostr.str () << endl - << endl; - - { - XSD_AUTO_PTR r1 (root (iostr, argv[1])); - - // Xerces-C++ mis-indentation of mixed content messes this up. - // assert (*r == *r); - - stringstream iostr; - root (iostr, *r1, map); - - cout << iostr.str () << endl - << endl; - } - - // Test comparison. - // - assert (*r == *r); - - // Test copy c-tor. - // - type copy (*r); - assert (copy == *r); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - - XMLPlatformUtils::Terminate (); -} diff --git a/tests/cxx/tree/any-type/makefile b/tests/cxx/tree/any-type/makefile deleted file mode 100644 index 1267cd4..0000000 --- a/tests/cxx/tree/any-type/makefile +++ /dev/null @@ -1,86 +0,0 @@ -# file : tests/cxx/tree/any-type/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-any-type --generate-serialization \ ---generate-ostream --generate-comparison -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/any-type/output b/tests/cxx/tree/any-type/output deleted file mode 100644 index 580e7db..0000000 --- a/tests/cxx/tree/any-type/output +++ /dev/null @@ -1,73 +0,0 @@ - -t: -t: -t: -t: -t: -t: -t: -t: -s: -s: simple -s: baz -l: one two three -a: any simple content - - - - - - any - any - - - nested 1 - nested 2 - - more - - mi - nested 1x - nested 2ed - content - - data - data - - simple - baz - one two three - - - - - - - - any - any - - - nested 1 - nested 2 - - more - - mi - - nested 1x - - nested 2ed - - content - - - data - data - - simple - baz - one two three - - - diff --git a/tests/cxx/tree/any-type/test.xml b/tests/cxx/tree/any-type/test.xml deleted file mode 100644 index 7c9035a..0000000 --- a/tests/cxx/tree/any-type/test.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - any - any - - - nested 1 - nested 2 - - more - - minested 1xnested 2edcontent - - - simple - - one two three - - diff --git a/tests/cxx/tree/any-type/test.xsd b/tests/cxx/tree/any-type/test.xsd deleted file mode 100644 index 37dcc8d..0000000 --- a/tests/cxx/tree/any-type/test.xsd +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/binary/cdr/driver.cxx b/tests/cxx/tree/binary/cdr/driver.cxx deleted file mode 100644 index fe74bb5..0000000 --- a/tests/cxx/tree/binary/cdr/driver.cxx +++ /dev/null @@ -1,143 +0,0 @@ -// file : tests/cxx/tree/binary/cdr/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test non-polymorphic binary serialization to ACE CDR. -// - -#include // std::auto_ptr/unique_ptr -#include -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - XSD_AUTO_PTR r (root (argv[1])); - - // Save to a CDR stream. - // - ACE_OutputCDR ace_ocdr; - xml_schema::ostream ocdr (ace_ocdr); - ocdr << *r; - - // Load from a CDR stream. - // - ACE_InputCDR ace_icdr (ace_ocdr); - xml_schema::istream icdr (ace_icdr); - XSD_AUTO_PTR c (new type (icdr)); - - // Compare the two. - // - assert (r->list () == c->list ()); - assert (r->union_ () == c->union_ ()); - assert (r->enumeration () == c->enumeration ()); - - type::complex_sequence rs (r->complex ()), cs (c->complex ()); - - for (type::complex_iterator ri (rs.begin ()), ci (cs.begin ()); - ri != rs.end () && ci != rs.end (); ++ri, ++ci) - { - assert (ri->a () == ci->a ()); - if (ri->b ()) - assert (ri->b () == ci->b ()); - assert (ri->c () == ci->c ()); - - assert (ri->x () == ci->x ()); - if (ri->y ()) - assert (ri->y () == ci->y ()); - } - - // integers - // - assert (r->byte () == c->byte ()); - assert (r->unsigned_byte () == c->unsigned_byte ()); - assert (r->short_ () == c->short_ ()); - assert (r->unsigned_short () == c->unsigned_short ()); - assert (r->int_ () == c->int_ ()); - assert (r->unsigned_int () == c->unsigned_int ()); - assert (r->long_ () == c->long_ ()); - assert (r->unsigned_long () == c->unsigned_long ()); - assert (r->integer () == c->integer ()); - assert (r->non_positive_integer () == c->non_positive_integer ()); - assert (r->non_negative_integer () == c->non_negative_integer ()); - assert (r->positive_integer () == c->positive_integer ()); - assert (r->negative_integer () == c->negative_integer ()); - - // boolean - // - assert (r->boolean () == c->boolean ()); - - // floats - // - assert (r->float_ () == c->float_ ()); - assert (r->double_ () == c->double_ ()); - assert (r->decimal () == c->decimal ()); - - // strings - // - assert (r->string () == c->string ()); - assert (r->normalized_string () == c->normalized_string ()); - assert (r->token () == c->token ()); - assert (r->name () == c->name ()); - assert (r->name_token () == c->name_token ()); - assert (r->name_tokens () == c->name_tokens ()); - assert (r->ncname () == c->ncname ()); - assert (r->language () == c->language ()); - - // qualified name - // - assert (r->qname () == c->qname ()); - - // ID/IDREF - // - assert (r->id () == c->id ()); - assert (r->id_ref () == c->id_ref ()); - assert (r->id_refs () == c->id_refs ()); - - // URI - // - assert (r->any_uri () == c->any_uri ()); - - // binary - // - assert (r->base64_binary () == c->base64_binary ()); - assert (r->hex_binary () == c->hex_binary ()); - - // date/time - // - assert (r->day () == c->day ()); - assert (r->month () == c->month ()); - assert (r->year () == c->year ()); - assert (r->month_day () == c->month_day ()); - assert (r->year_month () == c->year_month ()); - assert (r->date () == c->date ()); - assert (r->time () == c->time ()); - assert (r->date_time () == c->date_time ()); - assert (r->duration () == c->duration ()); - - // anySimpleType - // - assert (!r->any_simple_type_attr ().text_content ().empty ()); - assert (r->any_simple_type_attr () == c->any_simple_type_attr ()); - - assert (!r->any_simple_type ().text_content ().empty ()); - assert (r->any_simple_type () == c->any_simple_type ()); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/tests/cxx/tree/binary/cdr/makefile b/tests/cxx/tree/binary/cdr/makefile deleted file mode 100644 index 2d452ee..0000000 --- a/tests/cxx/tree/binary/cdr/makefile +++ /dev/null @@ -1,89 +0,0 @@ -# file : tests/cxx/tree/binary/cdr/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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) - -$(call import,\ - $(scf_root)/import/libace/stub.make,\ - l: ace.l,cpp-options: ace.l.cpp-options) - -# Build. -# -$(driver): $(obj) $(xerces_c.l) $(ace.l) - -$(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd -$(obj) $(dep): $(xerces_c.l.cpp-options) $(ace.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-insertion ACE_OutputCDR \ ---generate-extraction ACE_InputCDR --generate-comparison -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml - $(call message,test $$1,$$1 $(src_base)/test.xml,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/binary/cdr/test.xml b/tests/cxx/tree/binary/cdr/test.xml deleted file mode 100644 index 5cedd98..0000000 --- a/tests/cxx/tree/binary/cdr/test.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - 1 2 3 - - abc - - left - - - aaa - - - aaa - bbb - c - cc - ccc - - - - - 65 - 66 - -222 - 57005 - -57005 - 3735928559 - -3735928559 - 16045690984833335023 - -3735928559 - -3735928559 - 3735928559 - 3735928559 - -3735928559 - - - - true - - - - 1234.1234 - 12345678.12345678 - 1234567812345678.1234567812345678 - - - - string - normalized string - one two three - name - name-token - name tokens - ncname - en-us - - - xsi:schemaLocation - - - - elements1 - elements2 - elements1 - elements1 elements2 - - - - http://www.codesynthesis.com - - - - YmFzZTY0IGJpbmFyeQ== - 6865782052696E617279 - - - - 2001-10-26+02:00 - 2001-10-26T21:32:52+02:00 - P1Y2M3DT5H20M30S - ---01+02:00 - --11+02:00 - --11-02+02:00 - 2001+02:00 - 2001-11+02:00 - - - any simple content in element - - diff --git a/tests/cxx/tree/binary/cdr/test.xsd b/tests/cxx/tree/binary/cdr/test.xsd deleted file mode 100644 index 0629e94..0000000 --- a/tests/cxx/tree/binary/cdr/test.xsd +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/binary/makefile b/tests/cxx/tree/binary/makefile deleted file mode 100644 index 9ccc93f..0000000 --- a/tests/cxx/tree/binary/makefile +++ /dev/null @@ -1,16 +0,0 @@ -# file : tests/cxx/tree/binary/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -tests := cdr polymorphic xdr xdr-ordered - -default := $(out_base)/ -test := $(out_base)/.test -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) -$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) - -$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tests/cxx/tree/binary/polymorphic/driver.cxx b/tests/cxx/tree/binary/polymorphic/driver.cxx deleted file mode 100644 index 15ebf17..0000000 --- a/tests/cxx/tree/binary/polymorphic/driver.cxx +++ /dev/null @@ -1,164 +0,0 @@ -// file : tests/cxx/tree/binary/polymorphic/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test polymorphic binary serialization. -// - -#include // std::auto_ptr/unique_ptr -#include -#include -#include - -#include // ACE_HEX_DUMP - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - XSD_AUTO_PTR r (root (argv[1])); - - // Save to a CDR stream. - // - ACE_OutputCDR ace_ocdr; - xml_schema::ostream ocdr (ace_ocdr); - ocdr << *r; - - /* - // Print the binary representation. - // - cerr << "binary representation size: " << ace_ocdr.total_length () << endl; - - for (const ACE_Message_Block* mb = ace_ocdr.begin (); - mb != 0; - mb = mb->cont ()) - { - ACE_HEX_DUMP ((LM_DEBUG, mb->rd_ptr (), mb->length ())); - } - */ - - // Load from a CDR stream. - // - ACE_InputCDR ace_icdr (ace_ocdr); - xml_schema::istream icdr (ace_icdr); - XSD_AUTO_PTR c (new type (icdr)); - - // Compare the two. - // - assert (r->list () == c->list ()); - assert (r->union_ () == c->union_ ()); - assert (r->enumeration () == c->enumeration ()); - - { - complex& rc (dynamic_cast (r->base ())); - complex& cc (dynamic_cast (c->base ())); - - assert (rc.a () == cc.a ()); - if (rc.b ()) - assert (rc.b () == cc.b ()); - assert (rc.c () == cc.c ()); - - assert (rc.x () == cc.x ()); - if (rc.y ()) - assert (rc.y () == cc.y ()); - } - - { - complex& rc (dynamic_cast (r->sbase ())); - complex& cc (dynamic_cast (c->sbase ())); - - assert (rc.a () == cc.a ()); - if (rc.b ()) - assert (rc.b () == cc.b ()); - assert (rc.c () == cc.c ()); - - assert (rc.x () == cc.x ()); - if (rc.y ()) - assert (rc.y () == cc.y ()); - } - - // integers - // - assert (r->byte () == c->byte ()); - assert (r->unsigned_byte () == c->unsigned_byte ()); - assert (r->short_ () == c->short_ ()); - assert (r->unsigned_short () == c->unsigned_short ()); - assert (r->int_ () == c->int_ ()); - assert (r->unsigned_int () == c->unsigned_int ()); - assert (r->long_ () == c->long_ ()); - assert (r->unsigned_long () == c->unsigned_long ()); - assert (r->integer () == c->integer ()); - assert (r->non_positive_integer () == c->non_positive_integer ()); - assert (r->non_negative_integer () == c->non_negative_integer ()); - assert (r->positive_integer () == c->positive_integer ()); - assert (r->negative_integer () == c->negative_integer ()); - - // boolean - // - assert (r->boolean () == c->boolean ()); - - // floats - // - assert (r->float_ () == c->float_ ()); - assert (r->double_ () == c->double_ ()); - assert (r->decimal () == c->decimal ()); - - // strings - // - assert (r->string () == c->string ()); - assert (r->normalized_string () == c->normalized_string ()); - assert (r->token () == c->token ()); - assert (r->name () == c->name ()); - assert (r->name_token () == c->name_token ()); - assert (r->name_tokens () == c->name_tokens ()); - assert (r->ncname () == c->ncname ()); - assert (r->language () == c->language ()); - - // qualified name - // - assert (r->qname () == c->qname ()); - - // ID/IDREF - // - assert (r->id () == c->id ()); - assert (r->id_ref () == c->id_ref ()); - assert (r->id_refs () == c->id_refs ()); - - // URI - // - assert (r->any_uri () == c->any_uri ()); - - // binary - // - assert (r->base64_binary () == c->base64_binary ()); - assert (r->hex_binary () == c->hex_binary ()); - - // date/time - // - assert (r->date () == c->date ()); - assert (r->date_time () == c->date_time ()); - assert (r->duration () == c->duration ()); - assert (r->day () == c->day ()); - assert (r->month () == c->month ()); - assert (r->month_day () == c->month_day ()); - assert (r->year () == c->year ()); - assert (r->year_month () == c->year_month ()); - assert (r->time () == c->time ()); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/tests/cxx/tree/binary/polymorphic/makefile b/tests/cxx/tree/binary/polymorphic/makefile deleted file mode 100644 index c88b79c..0000000 --- a/tests/cxx/tree/binary/polymorphic/makefile +++ /dev/null @@ -1,90 +0,0 @@ -# file : tests/cxx/tree/binary/polymorphic/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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) - -$(call import,\ - $(scf_root)/import/libace/stub.make,\ - l: ace.l,cpp-options: ace.l.cpp-options) - -# Build. -# -$(driver): $(obj) $(xerces_c.l) $(ace.l) - -$(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd -$(obj) $(dep): $(xerces_c.l.cpp-options) $(ace.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-polymorphic --root-element-last \ ---generate-insertion ACE_OutputCDR --generate-extraction ACE_InputCDR \ - --generate-comparison -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml - $(call message,test $$1,$$1 $(src_base)/test.xml,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/binary/polymorphic/test.xml b/tests/cxx/tree/binary/polymorphic/test.xml deleted file mode 100644 index ad3a403..0000000 --- a/tests/cxx/tree/binary/polymorphic/test.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - 1 2 3 - - abc - - left - - - aaa - - - - aaa - bbb - c - cc - ccc - - - - - 65 - 66 - -222 - 57005 - -57005 - 3735928559 - -3735928559 - 16045690984833335023 - -3735928559 - -3735928559 - 3735928559 - 3735928559 - -3735928559 - - - - true - - - - 1234.1234 - 12345678.12345678 - 1234567812345678.1234567812345678 - - - - string - normalized string - one two three - name - name-token - name tokens - ncname - en-us - - - xsi:schemaLocation - - - - elements1 - elements2 - elements1 - elements1 elements2 - - - - http://www.codesynthesis.com - - - - YmFzZTY0IGJpbmFyeQ== - 6865782052696E617279 - - - - 2001-10-26+02:00 - 2001-10-26T21:32:52+02:00 - P1Y2M3DT5H20M30S - ---01+02:00 - --11+02:00 - --11-02+02:00 - 2001+02:00 - 2001-11+02:00 - - - - diff --git a/tests/cxx/tree/binary/polymorphic/test.xsd b/tests/cxx/tree/binary/polymorphic/test.xsd deleted file mode 100644 index 8c214e5..0000000 --- a/tests/cxx/tree/binary/polymorphic/test.xsd +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/binary/xdr-ordered/driver.cxx b/tests/cxx/tree/binary/xdr-ordered/driver.cxx deleted file mode 100644 index 8e2d845..0000000 --- a/tests/cxx/tree/binary/xdr-ordered/driver.cxx +++ /dev/null @@ -1,189 +0,0 @@ -// file : tests/cxx/tree/binary/xdr-ordered/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test non-polymorphic ordered binary serialization to XDR. -// -// Note: just a copy of xdr test with --ordered-type-all option. -// - -#include // std::auto_ptr/unique_ptr -#include // std::memcpy -#include -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -extern "C" int -overflow (char* p, char* buf, int in) -{ - xml_schema::buffer* dst (reinterpret_cast (p)); - - size_t n (static_cast (in)), size (dst->size ()); - dst->size (size + n); - memcpy (dst->data () + size, buf, n); - - return static_cast (n); -} - -struct underflow_info -{ - xml_schema::buffer* buf; - std::size_t pos; -}; - -extern "C" int -underflow (char* p, char* buf, int in) -{ - underflow_info* ui (reinterpret_cast (p)); - - size_t n (static_cast (in)), size (ui->buf->size () - ui->pos); - n = size > n ? n : size; - - memcpy (buf, ui->buf->data () + ui->pos, n); - ui->pos += n; - - return static_cast (n); -} - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - XSD_AUTO_PTR r (root (argv[1])); - - // 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; - xsd::cxx::tree::ostream oxdr (xdr); - oxdr << *r; - xdrrec_endofrecord (&xdr, true); // flush the data - xdr_destroy (&xdr); - - // 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); - xsd::cxx::tree::istream ixdr (xdr); - XSD_AUTO_PTR c (new type (ixdr)); - xdr_destroy (&xdr); - - // Compare the two. - // - assert (r->list () == c->list ()); - assert (r->union_ () == c->union_ ()); - assert (r->enumeration () == c->enumeration ()); - - type::complex_sequence rs (r->complex ()), cs (c->complex ()); - - for (type::complex_iterator ri (rs.begin ()), ci (cs.begin ()); - ri != rs.end () && ci != rs.end (); ++ri, ++ci) - { - assert (ri->a () == ci->a ()); - if (ri->b ()) - assert (ri->b () == ci->b ()); - assert (ri->c () == ci->c ()); - - assert (ri->x () == ci->x ()); - if (ri->y ()) - assert (ri->y () == ci->y ()); - } - - // integers - // - assert (r->byte () == c->byte ()); - assert (r->unsigned_byte () == c->unsigned_byte ()); - assert (r->short_ () == c->short_ ()); - assert (r->unsigned_short () == c->unsigned_short ()); - assert (r->int_ () == c->int_ ()); - assert (r->unsigned_int () == c->unsigned_int ()); - assert (r->long_ () == c->long_ ()); - assert (r->unsigned_long () == c->unsigned_long ()); - assert (r->integer () == c->integer ()); - assert (r->non_positive_integer () == c->non_positive_integer ()); - assert (r->non_negative_integer () == c->non_negative_integer ()); - assert (r->positive_integer () == c->positive_integer ()); - assert (r->negative_integer () == c->negative_integer ()); - - // boolean - // - assert (r->boolean () == c->boolean ()); - - // floats - // - assert (r->float_ () == c->float_ ()); - assert (r->double_ () == c->double_ ()); - assert (r->decimal () == c->decimal ()); - - // strings - // - assert (r->string () == c->string ()); - assert (r->normalized_string () == c->normalized_string ()); - assert (r->token () == c->token ()); - assert (r->name () == c->name ()); - assert (r->name_token () == c->name_token ()); - assert (r->name_tokens () == c->name_tokens ()); - assert (r->ncname () == c->ncname ()); - assert (r->language () == c->language ()); - - // qualified name - // - assert (r->qname () == c->qname ()); - - // ID/IDREF - // - assert (r->id () == c->id ()); - assert (r->id_ref () == c->id_ref ()); - assert (r->id_refs () == c->id_refs ()); - - // URI - // - assert (r->any_uri () == c->any_uri ()); - - // binary - // - assert (r->base64_binary () == c->base64_binary ()); - assert (r->hex_binary () == c->hex_binary ()); - - // date/time - // - assert (r->date () == c->date ()); - assert (r->date_time () == c->date_time ()); - assert (r->duration () == c->duration ()); - assert (r->day () == c->day ()); - assert (r->month () == c->month ()); - assert (r->month_day () == c->month_day ()); - assert (r->year () == c->year ()); - assert (r->year_month () == c->year_month ()); - assert (r->time () == c->time ()); - - // anySimpleType - // - assert (!r->any_simple_type_attr ().text_content ().empty ()); - assert (r->any_simple_type_attr () == c->any_simple_type_attr ()); - - assert (!r->any_simple_type ().text_content ().empty ()); - assert (r->any_simple_type () == c->any_simple_type ()); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/tests/cxx/tree/binary/xdr-ordered/makefile b/tests/cxx/tree/binary/xdr-ordered/makefile deleted file mode 100644 index df3a945..0000000 --- a/tests/cxx/tree/binary/xdr-ordered/makefile +++ /dev/null @@ -1,85 +0,0 @@ -# file : tests/cxx/tree/binary/xdr-ordered/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-insertion XDR --generate-extraction XDR \ ---generate-comparison --ordered-type-all -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml - $(call message,test $$1,$$1 $(src_base)/test.xml,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/binary/xdr-ordered/test.xml b/tests/cxx/tree/binary/xdr-ordered/test.xml deleted file mode 100644 index 5cedd98..0000000 --- a/tests/cxx/tree/binary/xdr-ordered/test.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - 1 2 3 - - abc - - left - - - aaa - - - aaa - bbb - c - cc - ccc - - - - - 65 - 66 - -222 - 57005 - -57005 - 3735928559 - -3735928559 - 16045690984833335023 - -3735928559 - -3735928559 - 3735928559 - 3735928559 - -3735928559 - - - - true - - - - 1234.1234 - 12345678.12345678 - 1234567812345678.1234567812345678 - - - - string - normalized string - one two three - name - name-token - name tokens - ncname - en-us - - - xsi:schemaLocation - - - - elements1 - elements2 - elements1 - elements1 elements2 - - - - http://www.codesynthesis.com - - - - YmFzZTY0IGJpbmFyeQ== - 6865782052696E617279 - - - - 2001-10-26+02:00 - 2001-10-26T21:32:52+02:00 - P1Y2M3DT5H20M30S - ---01+02:00 - --11+02:00 - --11-02+02:00 - 2001+02:00 - 2001-11+02:00 - - - any simple content in element - - diff --git a/tests/cxx/tree/binary/xdr-ordered/test.xsd b/tests/cxx/tree/binary/xdr-ordered/test.xsd deleted file mode 100644 index 0629e94..0000000 --- a/tests/cxx/tree/binary/xdr-ordered/test.xsd +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/binary/xdr/driver.cxx b/tests/cxx/tree/binary/xdr/driver.cxx deleted file mode 100644 index f5912c5..0000000 --- a/tests/cxx/tree/binary/xdr/driver.cxx +++ /dev/null @@ -1,187 +0,0 @@ -// file : tests/cxx/tree/binary/xdr/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test non-polymorphic binary serialization to XDR. -// - -#include // std::auto_ptr/unique_ptr -#include // std::memcpy -#include -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -extern "C" int -overflow (char* p, char* buf, int in) -{ - xml_schema::buffer* dst (reinterpret_cast (p)); - - size_t n (static_cast (in)), size (dst->size ()); - dst->size (size + n); - memcpy (dst->data () + size, buf, n); - - return static_cast (n); -} - -struct underflow_info -{ - xml_schema::buffer* buf; - std::size_t pos; -}; - -extern "C" int -underflow (char* p, char* buf, int in) -{ - underflow_info* ui (reinterpret_cast (p)); - - size_t n (static_cast (in)), size (ui->buf->size () - ui->pos); - n = size > n ? n : size; - - memcpy (buf, ui->buf->data () + ui->pos, n); - ui->pos += n; - - return static_cast (n); -} - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - XSD_AUTO_PTR r (root (argv[1])); - - // 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; - xsd::cxx::tree::ostream oxdr (xdr); - oxdr << *r; - xdrrec_endofrecord (&xdr, true); // flush the data - xdr_destroy (&xdr); - - // 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); - xsd::cxx::tree::istream ixdr (xdr); - XSD_AUTO_PTR c (new type (ixdr)); - xdr_destroy (&xdr); - - // Compare the two. - // - assert (r->list () == c->list ()); - assert (r->union_ () == c->union_ ()); - assert (r->enumeration () == c->enumeration ()); - - type::complex_sequence rs (r->complex ()), cs (c->complex ()); - - for (type::complex_iterator ri (rs.begin ()), ci (cs.begin ()); - ri != rs.end () && ci != rs.end (); ++ri, ++ci) - { - assert (ri->a () == ci->a ()); - if (ri->b ()) - assert (ri->b () == ci->b ()); - assert (ri->c () == ci->c ()); - - assert (ri->x () == ci->x ()); - if (ri->y ()) - assert (ri->y () == ci->y ()); - } - - // integers - // - assert (r->byte () == c->byte ()); - assert (r->unsigned_byte () == c->unsigned_byte ()); - assert (r->short_ () == c->short_ ()); - assert (r->unsigned_short () == c->unsigned_short ()); - assert (r->int_ () == c->int_ ()); - assert (r->unsigned_int () == c->unsigned_int ()); - assert (r->long_ () == c->long_ ()); - assert (r->unsigned_long () == c->unsigned_long ()); - assert (r->integer () == c->integer ()); - assert (r->non_positive_integer () == c->non_positive_integer ()); - assert (r->non_negative_integer () == c->non_negative_integer ()); - assert (r->positive_integer () == c->positive_integer ()); - assert (r->negative_integer () == c->negative_integer ()); - - // boolean - // - assert (r->boolean () == c->boolean ()); - - // floats - // - assert (r->float_ () == c->float_ ()); - assert (r->double_ () == c->double_ ()); - assert (r->decimal () == c->decimal ()); - - // strings - // - assert (r->string () == c->string ()); - assert (r->normalized_string () == c->normalized_string ()); - assert (r->token () == c->token ()); - assert (r->name () == c->name ()); - assert (r->name_token () == c->name_token ()); - assert (r->name_tokens () == c->name_tokens ()); - assert (r->ncname () == c->ncname ()); - assert (r->language () == c->language ()); - - // qualified name - // - assert (r->qname () == c->qname ()); - - // ID/IDREF - // - assert (r->id () == c->id ()); - assert (r->id_ref () == c->id_ref ()); - assert (r->id_refs () == c->id_refs ()); - - // URI - // - assert (r->any_uri () == c->any_uri ()); - - // binary - // - assert (r->base64_binary () == c->base64_binary ()); - assert (r->hex_binary () == c->hex_binary ()); - - // date/time - // - assert (r->date () == c->date ()); - assert (r->date_time () == c->date_time ()); - assert (r->duration () == c->duration ()); - assert (r->day () == c->day ()); - assert (r->month () == c->month ()); - assert (r->month_day () == c->month_day ()); - assert (r->year () == c->year ()); - assert (r->year_month () == c->year_month ()); - assert (r->time () == c->time ()); - - // anySimpleType - // - assert (!r->any_simple_type_attr ().text_content ().empty ()); - assert (r->any_simple_type_attr () == c->any_simple_type_attr ()); - - assert (!r->any_simple_type ().text_content ().empty ()); - assert (r->any_simple_type () == c->any_simple_type ()); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/tests/cxx/tree/binary/xdr/makefile b/tests/cxx/tree/binary/xdr/makefile deleted file mode 100644 index dca3230..0000000 --- a/tests/cxx/tree/binary/xdr/makefile +++ /dev/null @@ -1,85 +0,0 @@ -# file : tests/cxx/tree/binary/xdr/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-insertion XDR --generate-extraction XDR \ ---generate-comparison -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml - $(call message,test $$1,$$1 $(src_base)/test.xml,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/binary/xdr/test.xml b/tests/cxx/tree/binary/xdr/test.xml deleted file mode 100644 index 5cedd98..0000000 --- a/tests/cxx/tree/binary/xdr/test.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - 1 2 3 - - abc - - left - - - aaa - - - aaa - bbb - c - cc - ccc - - - - - 65 - 66 - -222 - 57005 - -57005 - 3735928559 - -3735928559 - 16045690984833335023 - -3735928559 - -3735928559 - 3735928559 - 3735928559 - -3735928559 - - - - true - - - - 1234.1234 - 12345678.12345678 - 1234567812345678.1234567812345678 - - - - string - normalized string - one two three - name - name-token - name tokens - ncname - en-us - - - xsi:schemaLocation - - - - elements1 - elements2 - elements1 - elements1 elements2 - - - - http://www.codesynthesis.com - - - - YmFzZTY0IGJpbmFyeQ== - 6865782052696E617279 - - - - 2001-10-26+02:00 - 2001-10-26T21:32:52+02:00 - P1Y2M3DT5H20M30S - ---01+02:00 - --11+02:00 - --11-02+02:00 - 2001+02:00 - 2001-11+02:00 - - - any simple content in element - - diff --git a/tests/cxx/tree/binary/xdr/test.xsd b/tests/cxx/tree/binary/xdr/test.xsd deleted file mode 100644 index 0629e94..0000000 --- a/tests/cxx/tree/binary/xdr/test.xsd +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/built-in/attributes.xml b/tests/cxx/tree/built-in/attributes.xml deleted file mode 100644 index 609a757..0000000 --- a/tests/cxx/tree/built-in/attributes.xml +++ /dev/null @@ -1,73 +0,0 @@ - - diff --git a/tests/cxx/tree/built-in/driver.cxx b/tests/cxx/tree/built-in/driver.cxx deleted file mode 100644 index f000f5a..0000000 --- a/tests/cxx/tree/built-in/driver.cxx +++ /dev/null @@ -1,93 +0,0 @@ -// file : tests/cxx/tree/built-in/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test built-in type mapping. -// - -#include // std::auto_ptr/unique_ptr -#include -#include - - -#include "types.hxx" - -using std::cerr; -using std::endl; - -int -main (int argc, char* argv[]) -{ - if (argc != 4) - { - cerr << "usage: " << argv[0] << " elements.xml attributes.xml inherited.xml" << endl; - return 1; - } - - XSD_AUTO_PTR elements ( - xmlns::test::elements (argv[1])); - - XSD_AUTO_PTR attributes ( - xmlns::test::attributes (argv[2])); - - XSD_AUTO_PTR inherited ( - xmlns::test::inherited (argv[3])); - - cerr << "elements: " << *elements << endl - << endl - << "attributes: " << *attributes << endl - << endl - << "inherited: " << *inherited << endl; - - // Test parsing/serialization. - // - - xml_schema::namespace_infomap map; - - map["test"].name = "http://www.codesynthesis.com/xmlns/test"; - map["test"].schema = "types.xsd"; - - { - std::ostringstream ostr; - xmlns::test::elements (ostr, *elements, map); - - std::istringstream istr (ostr.str ()); - XSD_AUTO_PTR elements1 ( - xmlns::test::elements (istr)); - - std::ostringstream ostr1; - xmlns::test::elements (ostr1, *elements1, map); - - if (ostr.str () != ostr1.str ()) - return 1; - } - - { - std::ostringstream ostr; - xmlns::test::attributes (ostr, *attributes, map); - - std::istringstream istr (ostr.str ()); - XSD_AUTO_PTR attributes1 ( - xmlns::test::attributes (istr)); - - std::ostringstream ostr1; - xmlns::test::attributes (ostr1, *attributes1, map); - - if (ostr.str () != ostr1.str ()) - return 1; - } - - { - std::ostringstream ostr; - xmlns::test::inherited (ostr, *inherited, map); - - std::istringstream istr (ostr.str ()); - XSD_AUTO_PTR inherited1 ( - xmlns::test::inherited (istr)); - - std::ostringstream ostr1; - xmlns::test::inherited (ostr1, *inherited1, map); - - if (ostr.str () != ostr1.str ()) - return 1; - } -} diff --git a/tests/cxx/tree/built-in/elements.xml b/tests/cxx/tree/built-in/elements.xml deleted file mode 100644 index f76f019..0000000 --- a/tests/cxx/tree/built-in/elements.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - - 65 - 66 - -222 - 57005 - -57005 - 3735928559 - -3735928559 - 16045690984833335023 - -3735928559 - -3735928559 - 3735928559 - 3735928559 - -3735928559 - - - - true - - - - 1234.1234 - 12345678.12345678 - 12345678.12345678 - - - - string - normalized -string - - one - two three - name - name-token - name tokens - ncname - en-us - - - xsi:schemaLocation - - - - elements1 - elements2 - elements1 - elements1 elements2 - - - - http://www.codesynthesis.com - - - - YmFzZTY0IGJpbmFyeQ== - 6865782052696E617279 - - - - 2001-10-26+02:00 - 2001-10-26T21:32:52+02:00 - P1Y2M3DT5H20M30S - ---01+02:00 - --11+02:00 - --11-02+02:00 - 2001+02:00 - 2001-11+02:00 - - - - - - - diff --git a/tests/cxx/tree/built-in/inherited.xml b/tests/cxx/tree/built-in/inherited.xml deleted file mode 100644 index 1781a69..0000000 --- a/tests/cxx/tree/built-in/inherited.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - - 65 - 66 - -222 - 57005 - -57005 - 3735928559 - -3735928559 - 16045690984833335023 - -3735928559 - -3735928559 - 3735928559 - 3735928559 - -3735928559 - - - - true - - - - 1234.1234 - 12345678.12345678 - 12345678.12345678 - - - - string - normalized -string - - one - two three - name - name-token - name tokens - ncname - en-us - - - xsi:schemaLocation - - - - elements1 - elements2 - elements1 - elements1 elements2 - - - - http://www.codesynthesis.com - - - - YmFzZTY0IGJpbmFyeQ== - 6865782052696E617279 - - - - 2001-10-26+02:00 - 2001-10-26T21:32:52+02:00 - P1Y2M3DT5H20M30S - ---01+02:00 - --11+02:00 - --11-02+02:00 - 2001+02:00 - 2001-11+02:00 - - - - - - - diff --git a/tests/cxx/tree/built-in/makefile b/tests/cxx/tree/built-in/makefile deleted file mode 100644 index b989fd1..0000000 --- a/tests/cxx/tree/built-in/makefile +++ /dev/null @@ -1,99 +0,0 @@ -# file : tests/cxx/tree/built-in/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := types.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += \ ---char-type char \ ---generate-inline \ ---generate-ostream \ ---generate-serialization \ ---generate-default-ctor \ ---generate-from-base-ctor \ ---root-element-all - -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -# We need to cd to src_base in order to have the schema in the working -# directory. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/elements.xml $(src_base)/attributes.xml \ -$(src_base)/inherited.xml - cd $(src_base) && $(driver) $(src_base)/elements.xml \ -$(src_base)/attributes.xml $(src_base)/inherited.xml - - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/built-in/types.xsd b/tests/cxx/tree/built-in/types.xsd deleted file mode 100644 index 22582cb..0000000 --- a/tests/cxx/tree/built-in/types.xsd +++ /dev/null @@ -1,460 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/chameleon/driver.cxx b/tests/cxx/tree/chameleon/driver.cxx deleted file mode 100644 index f196128..0000000 --- a/tests/cxx/tree/chameleon/driver.cxx +++ /dev/null @@ -1,35 +0,0 @@ -// file : tests/cxx/tree/chameleon/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test chameleon inclusion. -// - -#include // std::auto_ptr/unique_ptr -#include - -#include "includer.hxx" - -using namespace std; -using namespace test; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - XSD_AUTO_PTR r (root (argv[1])); - - cout << *r << endl; - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/tests/cxx/tree/chameleon/includee.xsd b/tests/cxx/tree/chameleon/includee.xsd deleted file mode 100644 index 531a7d0..0000000 --- a/tests/cxx/tree/chameleon/includee.xsd +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/tests/cxx/tree/chameleon/includer.xsd b/tests/cxx/tree/chameleon/includer.xsd deleted file mode 100644 index a1c850a..0000000 --- a/tests/cxx/tree/chameleon/includer.xsd +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - diff --git a/tests/cxx/tree/chameleon/makefile b/tests/cxx/tree/chameleon/makefile deleted file mode 100644 index b647ae3..0000000 --- a/tests/cxx/tree/chameleon/makefile +++ /dev/null @@ -1,85 +0,0 @@ -# file : tests/cxx/tree/chameleon/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := includer.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 root --generate-ostream -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/chameleon/output b/tests/cxx/tree/chameleon/output deleted file mode 100644 index c40f715..0000000 --- a/tests/cxx/tree/chameleon/output +++ /dev/null @@ -1,3 +0,0 @@ - -a: a -b: b diff --git a/tests/cxx/tree/chameleon/test.xml b/tests/cxx/tree/chameleon/test.xml deleted file mode 100644 index 12ff279..0000000 --- a/tests/cxx/tree/chameleon/test.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - a - b - - diff --git a/tests/cxx/tree/comparison/driver.cxx b/tests/cxx/tree/comparison/driver.cxx deleted file mode 100644 index c44598c..0000000 --- a/tests/cxx/tree/comparison/driver.cxx +++ /dev/null @@ -1,38 +0,0 @@ -// file : tests/cxx/tree/comparison/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test generated comparison operators. -// - -#include // std::auto_ptr/unique_ptr -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - XSD_AUTO_PTR r (root (argv[1])); - - type::complex_sequence s (r->complex ()); - - assert (s[0] == s[0]); - assert (s[0] != s[1]); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/tests/cxx/tree/comparison/makefile b/tests/cxx/tree/comparison/makefile deleted file mode 100644 index 373391b..0000000 --- a/tests/cxx/tree/comparison/makefile +++ /dev/null @@ -1,85 +0,0 @@ -# file : tests/cxx/tree/comparison/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-comparison -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml - $(call message,test $$1,$$1 $(src_base)/test.xml,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/comparison/test.xml b/tests/cxx/tree/comparison/test.xml deleted file mode 100644 index b5d8158..0000000 --- a/tests/cxx/tree/comparison/test.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - 123 - abc - abc - def - - - - 123 - abc - abc - xyz - - - diff --git a/tests/cxx/tree/comparison/test.xsd b/tests/cxx/tree/comparison/test.xsd deleted file mode 100644 index c234add..0000000 --- a/tests/cxx/tree/comparison/test.xsd +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/compilation/driver.cxx b/tests/cxx/tree/compilation/driver.cxx deleted file mode 100644 index 4318d97..0000000 --- a/tests/cxx/tree/compilation/driver.cxx +++ /dev/null @@ -1,116 +0,0 @@ -// file : tests/cxx/tree/compilation/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Make sure the runtime library compiles by explicitly instantiating -// all the types. -// - -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -template class xsd::cxx::tree::simple_type; - -// String types. -// -template class xsd::cxx::tree::string< char, xml_schema::simple_type >; -template class xsd::cxx::tree::normalized_string< char, xml_schema::string >; -template class xsd::cxx::tree::token< char, xml_schema::normalized_string >; -template class xsd::cxx::tree::name< char, xml_schema::token >; -template class xsd::cxx::tree::nmtoken< char, xml_schema::token >; -template class xsd::cxx::tree::nmtokens< char, xml_schema::simple_type, xml_schema::nmtoken >; -template class xsd::cxx::tree::ncname< char, xml_schema::name >; -template class xsd::cxx::tree::language< char, xml_schema::token >; - -// ID/IDREF. -// -template class xsd::cxx::tree::id< char, xml_schema::ncname >; -template class xsd::cxx::tree::idref< char, xml_schema::ncname, xml_schema::type >; -template class xsd::cxx::tree::idrefs< char, xml_schema::simple_type, xml_schema::idref >; - -// URI. -// -template class xsd::cxx::tree::uri< char, xml_schema::simple_type >; - -// Qualified name. -// -template class xsd::cxx::tree::qname< char, xml_schema::simple_type, xml_schema::uri, xml_schema::ncname >; - -// Binary. -// -template class xsd::cxx::tree::buffer< char >; -template class xsd::cxx::tree::base64_binary< char, xml_schema::simple_type >; -template class xsd::cxx::tree::hex_binary< char, xml_schema::simple_type >; - -// Date/time. -// -template class xsd::cxx::tree::date< char, xml_schema::simple_type >; -template class xsd::cxx::tree::date_time< char, xml_schema::simple_type >; -template class xsd::cxx::tree::duration< char, xml_schema::simple_type >; -template class xsd::cxx::tree::gday< char, xml_schema::simple_type >; -template class xsd::cxx::tree::gmonth< char, xml_schema::simple_type >; -template class xsd::cxx::tree::gmonth_day< char, xml_schema::simple_type >; -template class xsd::cxx::tree::gyear< char, xml_schema::simple_type >; -template class xsd::cxx::tree::gyear_month< char, xml_schema::simple_type >; -template class xsd::cxx::tree::time< char, xml_schema::simple_type >; - -// Entity. -// -template class xsd::cxx::tree::entity< char, xml_schema::ncname >; -template class xsd::cxx::tree::entities< char, xml_schema::simple_type, xml_schema::entity >; - -// Namespace information and list stream. Used in -// serialization functions. -// -template class xsd::cxx::xml::dom::namespace_info < char >; -template class xsd::cxx::xml::dom::namespace_infomap < char >; -template class xsd::cxx::tree::list_stream < char >; - -// Flags and properties. -// -template class xsd::cxx::tree::properties< char >; - -// Exceptions. -// -template class xsd::cxx::tree::exception< char >; -template class xsd::cxx::tree::parsing< char >; -template class xsd::cxx::tree::expected_element< char >; -template class xsd::cxx::tree::unexpected_element< char >; -template class xsd::cxx::tree::expected_attribute< char >; -template class xsd::cxx::tree::unexpected_enumerator< char >; -template class xsd::cxx::tree::expected_text_content< char >; -template class xsd::cxx::tree::no_type_info< char >; -template class xsd::cxx::tree::not_derived< char >; -template class xsd::cxx::tree::duplicate_id< char >; -template class xsd::cxx::tree::serialization< char >; -template class xsd::cxx::tree::no_prefix_mapping< char >; -template class xsd::cxx::tree::bounds< char >; - -// Parsing/serialization diagnostics. -// -template class xsd::cxx::tree::error< char >; -template class xsd::cxx::tree::diagnostics< char >; - -// Error handler interface. -// -template class xsd::cxx::xml::error_handler< char >; - - -// -// -template class xsd::cxx::tree::fundamental_base; -template class xsd::cxx::tree::one; -template class xsd::cxx::tree::one; -template class xsd::cxx::tree::optional; -template class xsd::cxx::tree::optional; -template class xsd::cxx::tree::sequence; -template class xsd::cxx::tree::sequence; - - -int -main () -{ -} diff --git a/tests/cxx/tree/compilation/makefile b/tests/cxx/tree/compilation/makefile deleted file mode 100644 index 3856416..0000000 --- a/tests/cxx/tree/compilation/makefile +++ /dev/null @@ -1,85 +0,0 @@ -# file : tests/cxx/tree/compilation/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-serialization -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/compilation/test.xsd b/tests/cxx/tree/compilation/test.xsd deleted file mode 100644 index 07bebc7..0000000 --- a/tests/cxx/tree/compilation/test.xsd +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/tests/cxx/tree/complex/ctor/driver.cxx b/tests/cxx/tree/complex/ctor/driver.cxx deleted file mode 100644 index 0d691ac..0000000 --- a/tests/cxx/tree/complex/ctor/driver.cxx +++ /dev/null @@ -1,122 +0,0 @@ -// file : tests/cxx/tree/complex/ctor/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test generation of varous complex type constructors. -// - -#include -#include - -#include "test.hxx" - -#ifdef XSD_CXX11 -# include // std::move -# define XSD_MOVE(x) std::move(x) -#else -# define XSD_MOVE(x) x -#endif - -using namespace std; -using namespace test; - -int -main () -{ - // Test case A. - // - { - a_base b1; - a_base b2 ("abc"); // empty ultimate base + required - a_base b3 ("abc", "foo"); // ultimate base + required - - a_derived a1; - a_derived a2 ("foo", "bar"); // empty ultimate base + required - a_derived a3 (b3, "bar"); // base + required - a_derived a4 ("abc", "foo", "bar"); // ultimate base + required - } - - // Test case B. - // - { - b_simple s ("base"); - b_base b ("base", "foo"); - b_derived d ("base", "foo", "bar"); - b_type t ("base"); - } - - // Test case C. - // - { - c_simple s (c_enum::a); - c_base b (c_enum::a, "foo"); - c_derived d (c_enum::a, "foo", "bar"); - c_type t (c_enum::a); - } - - // Test case D. - // - { - d_simple s (1); - d_base b (1, "foo"); - d_derived d (1, "foo", "bar"); - d_type t (1); - } - - // Test case E. - // - { - // e_base - // - e_base b1 (1, "foo", e_complex_type ("bar")); - - XSD_AUTO_PTR c2 (new e_complex_type ("bar")); - e_base b2 (1, "foo", XSD_MOVE (c2)); - - XSD_AUTO_PTR s3 (new e_simple_type ("foo")); - XSD_AUTO_PTR c3 (new e_complex_type ("bar")); - e_base b3 (1, XSD_MOVE (s3), XSD_MOVE (c3)); - - assert (b1 == b2); - assert (b1 == b3); - - // e_derived - // - e_derived d1 (1, "foo", e_complex_type ("bar"), - true, "baz", e_complex_type ("biz")); - - XSD_AUTO_PTR c2a (new e_complex_type ("bar")); - XSD_AUTO_PTR c2b (new e_complex_type ("biz")); - e_derived d2 (1, "foo", XSD_MOVE (c2a), true, "baz", XSD_MOVE (c2b)); - - XSD_AUTO_PTR s3a (new e_simple_type ("foo")); - XSD_AUTO_PTR s3b (new xml_schema::string ("baz")); - XSD_AUTO_PTR c3a (new e_complex_type ("bar")); - XSD_AUTO_PTR c3b (new e_complex_type ("biz")); - e_derived d3 (1, - XSD_MOVE (s3a), - XSD_MOVE (c3a), - true, - XSD_MOVE (s3b), - XSD_MOVE (c3b)); - - assert (d1 == d2); - assert (d1 == d3); - - } - - // Test case F. - // - { - f_type f1 (xml_schema::type (), 1, "foo", f_complex_type ("bar")); - - XSD_AUTO_PTR c2 (new f_complex_type ("bar")); - f_type f2 (1, "foo", XSD_MOVE (c2)); - - XSD_AUTO_PTR s3 (new f_simple_type ("foo")); - XSD_AUTO_PTR c3 (new f_complex_type ("bar")); - f_type f3 (1, XSD_MOVE (s3), XSD_MOVE (c3)); - - assert (f1 == f2); - assert (f1 == f3); - } -} diff --git a/tests/cxx/tree/complex/ctor/makefile b/tests/cxx/tree/complex/ctor/makefile deleted file mode 100644 index db592ff..0000000 --- a/tests/cxx/tree/complex/ctor/makefile +++ /dev/null @@ -1,86 +0,0 @@ -# file : tests/cxx/tree/complex/ctor/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-default-ctor --generate-from-base-ctor \ ---generate-doxygen --generate-polymorphic --polymorphic-type-all \ ---generate-comparison -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/complex/ctor/test.xsd b/tests/cxx/tree/complex/ctor/test.xsd deleted file mode 100644 index b8dd95e..0000000 --- a/tests/cxx/tree/complex/ctor/test.xsd +++ /dev/null @@ -1,182 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/complex/makefile b/tests/cxx/tree/complex/makefile deleted file mode 100644 index 95ff3f6..0000000 --- a/tests/cxx/tree/complex/makefile +++ /dev/null @@ -1,16 +0,0 @@ -# file : tests/cxx/tree/complex/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -tests := ctor - -default := $(out_base)/ -test := $(out_base)/.test -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) -$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) - -$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tests/cxx/tree/containment/driver.cxx b/tests/cxx/tree/containment/driver.cxx deleted file mode 100644 index 954b76b..0000000 --- a/tests/cxx/tree/containment/driver.cxx +++ /dev/null @@ -1,118 +0,0 @@ -// file : tests/cxx/tree/containment/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test tree node containment. -// - -#include // std::auto_ptr/unique_ptr -#include - -#include "test.hxx" - -#ifdef XSD_CXX11 -# include // std::move -# define XSD_MOVE(x) std::move(x) -#else -# define XSD_MOVE(x) x -#endif - -using namespace std; -using namespace test; - -int -main () -{ - // Change of a container in a sub-tree without ID. - // - { - XSD_AUTO_PTR i (new inner ()); - i->ref ("foo"); - - outer o; - o.i (XSD_MOVE (i)); - o.ref ("foo"); - - assert (o.i ()->ref ()->get () == 0); - assert (o.ref ()->get () == 0); - } - - // Change of container in a sub-tree with ID inside. - // - { - XSD_AUTO_PTR i (new inner ()); - inner* p (i.get ()); - i->id ("foo"); - i->ref ("foo"); - assert (i->ref ()->get () == p); - - outer o; - o.i (XSD_MOVE (i)); - o.ref ("foo"); - - assert (o.i ()->ref ()->get () == p); - assert (o.ref ()->get () == p); - } - - // Change of a container in ID. - // - { - XSD_AUTO_PTR id (new xml_schema::id ("foo")); - - inner i; - i.id (XSD_MOVE (id)); - i.ref ("foo"); - assert (i.ref ()->get () == &i); - } - - // Change of a container in a type derived from ID with ID inside. - // - { - XSD_AUTO_PTR id (new id_ex ("foo")); - id_ex* p (id.get ()); - id->id ("bar"); - - inner i; - i.id_ex (XSD_MOVE (id)); - - i.ref ("foo"); - assert (i.ref ()->get () == &i); - - i.ref ("bar"); - assert (i.ref ()->get () == p); - } - - // IDREF lists - // - { - id i1 ("a"), i2 ("b"); - - XSD_AUTO_PTR ic (new ids); - ic->id ().push_back (i1); - ic->id ().push_back (i2); - - XSD_AUTO_PTR r1 (new xml_schema::idrefs); - r1->push_back (xml_schema::idref ("a")); - r1->push_back (xml_schema::idref ("b")); - - XSD_AUTO_PTR r2 (new idref_list); - r2->push_back (xml_schema::idref ("a")); - r2->push_back (xml_schema::idref ("b")); - - XSD_AUTO_PTR rc1 (new idrefs1); - XSD_AUTO_PTR rc2 (new idrefs2); - - rc1->idrefs (XSD_MOVE (r1)); - rc2->idrefs (XSD_MOVE (r2)); - - model m; - m.ids (XSD_MOVE (ic)); - m.idrefs1 (XSD_MOVE (rc1)); - m.idrefs2 (XSD_MOVE (rc2)); - - assert (m.idrefs1 ().idrefs ()[0].get () != 0); - assert (m.idrefs1 ().idrefs ()[1].get () != 0); - - assert (m.idrefs2 ().idrefs ()[0].get () != 0); - assert (m.idrefs2 ().idrefs ()[1].get () != 0); - } -} diff --git a/tests/cxx/tree/containment/makefile b/tests/cxx/tree/containment/makefile deleted file mode 100644 index dc7ca7b..0000000 --- a/tests/cxx/tree/containment/makefile +++ /dev/null @@ -1,85 +0,0 @@ -# file : tests/cxx/tree/containment/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-default-ctor -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/containment/test.xsd b/tests/cxx/tree/containment/test.xsd deleted file mode 100644 index 72c9379..0000000 --- a/tests/cxx/tree/containment/test.xsd +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/default/general/driver.cxx b/tests/cxx/tree/default/general/driver.cxx deleted file mode 100644 index 97d0a7d..0000000 --- a/tests/cxx/tree/default/general/driver.cxx +++ /dev/null @@ -1,37 +0,0 @@ -// file : tests/cxx/tree/default/general/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test default attribute/element values. -// - -#include // std::auto_ptr/unique_ptr -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - XSD_AUTO_PTR r (root (argv[1], xml_schema::flags::dont_validate)); - - xml_schema::namespace_infomap map; - map["t"].name = "test"; - root (cout, *r, map); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/tests/cxx/tree/default/general/makefile b/tests/cxx/tree/default/general/makefile deleted file mode 100644 index fc1bca1..0000000 --- a/tests/cxx/tree/default/general/makefile +++ /dev/null @@ -1,86 +0,0 @@ -# file : tests/cxx/tree/default/general/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-ostream --generate-serialization \ ---generate-default-ctor --generate-from-base-ctor -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/default/general/output b/tests/cxx/tree/default/general/output deleted file mode 100644 index 396a698..0000000 --- a/tests/cxx/tree/default/general/output +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - diff --git a/tests/cxx/tree/default/general/test.xml b/tests/cxx/tree/default/general/test.xml deleted file mode 100644 index 11bd0a7..0000000 --- a/tests/cxx/tree/default/general/test.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - diff --git a/tests/cxx/tree/default/general/test.xsd b/tests/cxx/tree/default/general/test.xsd deleted file mode 100644 index 9d9cd38..0000000 --- a/tests/cxx/tree/default/general/test.xsd +++ /dev/null @@ -1,241 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/default/makefile b/tests/cxx/tree/default/makefile deleted file mode 100644 index 304640e..0000000 --- a/tests/cxx/tree/default/makefile +++ /dev/null @@ -1,16 +0,0 @@ -# file : tests/cxx/tree/default/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -tests := general omit - -default := $(out_base)/ -test := $(out_base)/.test -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) -$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) - -$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tests/cxx/tree/default/omit/driver.cxx b/tests/cxx/tree/default/omit/driver.cxx deleted file mode 100644 index e588a34..0000000 --- a/tests/cxx/tree/default/omit/driver.cxx +++ /dev/null @@ -1,46 +0,0 @@ -// file : tests/cxx/tree/default/omit/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test default attribute omission from the output. -// - -#include // std::auto_ptr/unique_ptr -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - XSD_AUTO_PTR r (root (argv[1], xml_schema::flags::dont_validate)); - - cout << *r << endl - << "default x: " << derived::x_default_value () << endl - << "default y: " << derived::y_default_value () << endl - << "fixed p: " << derived::p_default_value () << endl - << "fixed q1: " << derived::q1_default_value () << endl - << "fixed q2: " << derived::q2_default_value () << endl; - - // Serialize. - // - xml_schema::namespace_infomap map; - map["t"].name = "test"; - root (cout, *r, map); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/tests/cxx/tree/default/omit/makefile b/tests/cxx/tree/default/omit/makefile deleted file mode 100644 index 93a9cd2..0000000 --- a/tests/cxx/tree/default/omit/makefile +++ /dev/null @@ -1,86 +0,0 @@ -# file : tests/cxx/tree/default/omit/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-ostream --generate-serialization \ ---generate-default-ctor --generate-from-base-ctor --omit-default-attributes -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/default/omit/output b/tests/cxx/tree/default/omit/output deleted file mode 100644 index 150ad58..0000000 --- a/tests/cxx/tree/default/omit/output +++ /dev/null @@ -1,19 +0,0 @@ - -derived: -a: a -x: foo -q1: 1 -y: -20 -p: bar -q2: 2 -default x: foo -default y: -20 -fixed p: bar -fixed q1: 1 -fixed q2: 2 - - - - a - - diff --git a/tests/cxx/tree/default/omit/test.xml b/tests/cxx/tree/default/omit/test.xml deleted file mode 100644 index dec39b4..0000000 --- a/tests/cxx/tree/default/omit/test.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - a - - - diff --git a/tests/cxx/tree/default/omit/test.xsd b/tests/cxx/tree/default/omit/test.xsd deleted file mode 100644 index bfc68d4..0000000 --- a/tests/cxx/tree/default/omit/test.xsd +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/detach/driver.cxx b/tests/cxx/tree/detach/driver.cxx deleted file mode 100644 index d1a8f6f..0000000 --- a/tests/cxx/tree/detach/driver.cxx +++ /dev/null @@ -1,108 +0,0 @@ -// file : tests/cxx/tree/detach/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the detach functionality. -// - -#include // std::auto_ptr/unique_ptr -#include - -#include "test.hxx" - -#ifdef XSD_CXX11 -# include // std::move -# define XSD_MOVE(x) std::move(x) -#else -# define XSD_MOVE(x) x -#endif - -using namespace std; -using namespace test; - -int -main () -{ - using test::ref; - - // Construct the model. - // - object o1 ("o1"); - o1.data ().push_back ("1-1"); - o1.data ().push_back ("1-2"); - o1.data ().push_back ("1-3"); - - object o2 ("o2"); - o1.data ().push_back ("2-1"); - o1.data ().push_back ("2-2"); - o1.data ().push_back ("2-3"); - - object o3 ("o3"); - o1.data ().push_back ("3-1"); - o1.data ().push_back ("3-2"); - o1.data ().push_back ("3-3"); - - object o4 ("o4"); - o1.data ().push_back ("4-1"); - o1.data ().push_back ("4-2"); - o1.data ().push_back ("4-3"); - - subtree s1; - s1.o ().push_back (o1); - s1.o ().push_back (o2); - s1.r ().push_back (ref ("o2")); - s1.r ().push_back (ref ("o3")); - - subtree s2; - s2.o ().push_back (o3); - s2.o ().push_back (o4); - s2.r ().push_back (ref ("o4")); - s2.r ().push_back (ref ("o1")); - - model m; - m.one (s1); - m.opt (s2); - - // Detach one. - // - XSD_AUTO_PTR p (m.detach_one ()); - assert (p->_container () == 0); - assert (p->r ()[0].get () == &p->o ()[1]); - assert (m.opt ()->r ()[1].get () == 0); - - m.one (XSD_MOVE (p)); - assert (m.opt ()->r ()[1].get () == &m.one ().o ()[0]); - p = m.detach_one (); - - model m1; - m1.one (XSD_MOVE (p)); - m1.opt (s2); - assert (m1.opt ()->r ()[1].get () == &m1.one ().o ()[0]); - - p = m1.detach_one (); - m.seq ().push_back (XSD_MOVE (p)); - - // Detach opt. - // - p = m.opt ().detach (); - assert (!m.opt ()); - assert (p->_container () == 0); - assert (p->r ()[0].get () == &p->o ()[1]); - assert (m.seq ()[0].r ()[1].get () == 0); - - m.seq ().push_back (XSD_MOVE (p)); - - // Detach seq. - // - p = m.seq ().detach_back (); - assert (p->_container () == 0); - assert (p->r ()[0].get () == &p->o ()[1]); - assert (m.seq ()[0].r ()[1].get () == 0); - - m.seq ().push_back (XSD_MOVE (p)); - assert (m.seq ()[0].r ()[1].get () == &m.seq ()[1].o ()[0]); - - m.seq ().detach (m.seq ().begin (), p); - assert (p->_container () == 0); - assert (p->r ()[0].get () == &p->o ()[1]); - assert (m.seq ()[0].r ()[1].get () == 0); -} diff --git a/tests/cxx/tree/detach/makefile b/tests/cxx/tree/detach/makefile deleted file mode 100644 index 56c59fa..0000000 --- a/tests/cxx/tree/detach/makefile +++ /dev/null @@ -1,85 +0,0 @@ -# file : tests/cxx/tree/detach/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-detach --generate-default-ctor -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/detach/test.xsd b/tests/cxx/tree/detach/test.xsd deleted file mode 100644 index b9f5166..0000000 --- a/tests/cxx/tree/detach/test.xsd +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/dom-association/dom-parse.cxx b/tests/cxx/tree/dom-association/dom-parse.cxx deleted file mode 100644 index 0d26d02..0000000 --- a/tests/cxx/tree/dom-association/dom-parse.cxx +++ /dev/null @@ -1,95 +0,0 @@ -// file : tests/cxx/tree/dom-association/dom-parse.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#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; - -XSD_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)); - - XSD_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); - - XSD_DOM_AUTO_PTR doc (parser->parse (&wrap)); - - eh.throw_if_failed > (); - - return doc; -} diff --git a/tests/cxx/tree/dom-association/dom-parse.hxx b/tests/cxx/tree/dom-association/dom-parse.hxx deleted file mode 100644 index c1c9326..0000000 --- a/tests/cxx/tree/dom-association/dom-parse.hxx +++ /dev/null @@ -1,23 +0,0 @@ -// file : tests/cxx/tree/dom-association/dom-parse.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#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_DOM_AUTO_PTR -parse (std::istream& is, - const std::string& id, - bool validate); - -#endif // DOM_PARSE diff --git a/tests/cxx/tree/dom-association/driver.cxx b/tests/cxx/tree/dom-association/driver.cxx deleted file mode 100644 index 44343a3..0000000 --- a/tests/cxx/tree/dom-association/driver.cxx +++ /dev/null @@ -1,71 +0,0 @@ -// file : tests/cxx/tree/dom-association/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test DOM association/ownership. -// - -#include // std::auto_ptr/unique_ptr -#include -#include - -#include - -#include "dom-parse.hxx" -#include "test.hxx" - -using namespace std; -using namespace test; -using namespace xercesc; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - int r (0); - - XMLPlatformUtils::Initialize (); - - try - { - ifstream ifs; - ifs.exceptions (ifstream::badbit | ifstream::failbit); - ifs.open (argv[1]); - - DOMDocument* ptr; - -#ifdef XSD_CXX11 - xml_schema::dom::unique_ptr doc (parse (ifs, argv[1], true)); - ptr = doc.get (); - unique_ptr r ( - root (std::move (doc), - xml_schema::flags::keep_dom | xml_schema::flags::own_dom)); -#else - xml_schema::dom::auto_ptr doc (parse (ifs, argv[1], true)); - ptr = doc.get (); - auto_ptr r ( - root (doc, - xml_schema::flags::keep_dom | xml_schema::flags::own_dom)); -#endif - - assert (doc.get () == 0); - assert (r->_node ()->getOwnerDocument () == ptr); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - r = 1; - } - catch (const std::ios_base::failure&) - { - cerr << argv[1] << ": unable to open or read failure" << endl; - r = 1; - } - - XMLPlatformUtils::Terminate (); - return r; -} diff --git a/tests/cxx/tree/dom-association/makefile b/tests/cxx/tree/dom-association/makefile deleted file mode 100644 index 6c1f44c..0000000 --- a/tests/cxx/tree/dom-association/makefile +++ /dev/null @@ -1,91 +0,0 @@ -# file : tests/cxx/tree/dom-association/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.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 -test := $(out_base)/.test -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) - -# Define XSD_CXX11 since we include libxsd headers directly. -# -$(call include,$(bld_root)/cxx/standard.make) # cxx_standard -ifeq ($(cxx_standard),c++11) -$(obj) $(dep): cpp_options += -DXSD_CXX11 -endif - -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 -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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) - -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/dom-association/output b/tests/cxx/tree/dom-association/output deleted file mode 100644 index e69de29..0000000 diff --git a/tests/cxx/tree/dom-association/test.xml b/tests/cxx/tree/dom-association/test.xml deleted file mode 100644 index 624a80c..0000000 --- a/tests/cxx/tree/dom-association/test.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - a - - diff --git a/tests/cxx/tree/dom-association/test.xsd b/tests/cxx/tree/dom-association/test.xsd deleted file mode 100644 index 07bebc7..0000000 --- a/tests/cxx/tree/dom-association/test.xsd +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/tests/cxx/tree/encoding/char/iso-8859-1/driver.cxx b/tests/cxx/tree/encoding/char/iso-8859-1/driver.cxx deleted file mode 100644 index 2840e0a..0000000 --- a/tests/cxx/tree/encoding/char/iso-8859-1/driver.cxx +++ /dev/null @@ -1,74 +0,0 @@ -// file : tests/cxx/tree/encoding/char/iso-8859-1/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test ISO-8859-1 encoding. -// - -#include // std::auto_ptr/unique_ptr -#include -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - try - { - root (argv[1]); - return 1; - } - catch (xsd::cxx::xml::iso8859_1_unrepresentable const&) - { - } - - xsd::cxx::xml::char_transcoder::unrep_char ('?'); - XSD_AUTO_PTR r (root (argv[1])); - - { - type::a_sequence const& s (r->a ()); - - if (s[0] != "abc" || - s[1] != "\xE6" || - s[2] != "\xA2\xA3\xA4\xA5" || - s[3] != "??") - { - cerr << "invalid encoding" << endl; - return 1; - } - } - - { - type::b_sequence const& s (r->b ()); - - if (s[0] != strenum::abc || - s[1] != strenum::a_c || - s[2] != strenum::cxx__bc) - { - cerr << "invalid encoding" << endl; - return 1; - } - } - - xml_schema::namespace_infomap map; - map["t"].name = "test"; - - root (std::cout, *r, map, "ISO-8859-1"); - } - catch (xml_schema::exception const& e) - { - cerr << "xml_schema::exception: " << e.what () << endl; - return 1; - } -} diff --git a/tests/cxx/tree/encoding/char/iso-8859-1/makefile b/tests/cxx/tree/encoding/char/iso-8859-1/makefile deleted file mode 100644 index 8b28e4e..0000000 --- a/tests/cxx/tree/encoding/char/iso-8859-1/makefile +++ /dev/null @@ -1,86 +0,0 @@ -# file : tests/cxx/tree/encoding/char/iso-8859-1/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --char-encoding iso8859-1 --generate-serialization \ ---generate-doxygen -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/test.std - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/test.std -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/encoding/char/iso-8859-1/test.std b/tests/cxx/tree/encoding/char/iso-8859-1/test.std deleted file mode 100644 index cb73faa..0000000 --- a/tests/cxx/tree/encoding/char/iso-8859-1/test.std +++ /dev/null @@ -1,10 +0,0 @@ - - - abc - æ - ¢£¤¥ - ?? - abc - aâc - âòbc - diff --git a/tests/cxx/tree/encoding/char/iso-8859-1/test.xml b/tests/cxx/tree/encoding/char/iso-8859-1/test.xml deleted file mode 100644 index cc05f8d..0000000 --- a/tests/cxx/tree/encoding/char/iso-8859-1/test.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - abc - æ - ¢£¤¥ - Āꪪ - - abc - aâc - âòbc - - diff --git a/tests/cxx/tree/encoding/char/iso-8859-1/test.xsd b/tests/cxx/tree/encoding/char/iso-8859-1/test.xsd deleted file mode 100644 index 31b8901..0000000 --- a/tests/cxx/tree/encoding/char/iso-8859-1/test.xsd +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - Test enum. Valid values are: - abc - aâc - òbc - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/encoding/char/lcp/driver.cxx b/tests/cxx/tree/encoding/char/lcp/driver.cxx deleted file mode 100644 index 4e2933d..0000000 --- a/tests/cxx/tree/encoding/char/lcp/driver.cxx +++ /dev/null @@ -1,40 +0,0 @@ -// file : tests/cxx/tree/encoding/char/lcp/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test local code page encoding (--char-encoding lcp). -// The test just makes sure it still compiles and works. -// - -#include // std::auto_ptr/unique_ptr -#include -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - XSD_AUTO_PTR r (root (argv[1])); - - xml_schema::namespace_infomap map; - map["t"].name = "test"; - - root (std::cout, *r, map); - } - catch (xml_schema::exception const& e) - { - cerr << "xml_schema::exception: " << e.what () << endl; - return 1; - } -} diff --git a/tests/cxx/tree/encoding/char/lcp/makefile b/tests/cxx/tree/encoding/char/lcp/makefile deleted file mode 100644 index bb99e33..0000000 --- a/tests/cxx/tree/encoding/char/lcp/makefile +++ /dev/null @@ -1,85 +0,0 @@ -# file : tests/cxx/tree/encoding/char/lcp/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-serialization --char-encoding lcp -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/test.std - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/test.std -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/encoding/char/lcp/test.std b/tests/cxx/tree/encoding/char/lcp/test.std deleted file mode 100644 index 368826d..0000000 --- a/tests/cxx/tree/encoding/char/lcp/test.std +++ /dev/null @@ -1,4 +0,0 @@ - - - abcd - diff --git a/tests/cxx/tree/encoding/char/lcp/test.xml b/tests/cxx/tree/encoding/char/lcp/test.xml deleted file mode 100644 index 772512e..0000000 --- a/tests/cxx/tree/encoding/char/lcp/test.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - abcd - - diff --git a/tests/cxx/tree/encoding/char/lcp/test.xsd b/tests/cxx/tree/encoding/char/lcp/test.xsd deleted file mode 100644 index 1e264e3..0000000 --- a/tests/cxx/tree/encoding/char/lcp/test.xsd +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/tests/cxx/tree/encoding/char/makefile b/tests/cxx/tree/encoding/char/makefile deleted file mode 100644 index cd7a325..0000000 --- a/tests/cxx/tree/encoding/char/makefile +++ /dev/null @@ -1,16 +0,0 @@ -# file : tests/cxx/tree/encoding/char/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -tests := lcp utf-8 iso-8859-1 - -default := $(out_base)/ -test := $(out_base)/.test -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) -$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) - -$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tests/cxx/tree/encoding/char/utf-8/driver.cxx b/tests/cxx/tree/encoding/char/utf-8/driver.cxx deleted file mode 100644 index 38fae4d..0000000 --- a/tests/cxx/tree/encoding/char/utf-8/driver.cxx +++ /dev/null @@ -1,63 +0,0 @@ -// file : tests/cxx/tree/encoding/char/utf-8/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test UTF-8 encoding. -// - -#include // std::auto_ptr/unique_ptr -#include -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - XSD_AUTO_PTR r (root (argv[1])); - - { - type::a_sequence const& s (r->a ()); - - if (s[0] != "abc" || - s[1] != "\xD5\x95" || - s[2] != "\xEA\xAA\xAA") - { - cerr << "invalid encoding" << endl; - return 1; - } - } - - { - type::b_sequence const& s (r->b ()); - - if (s[0] != strenum::abc || - s[1] != strenum::a_c || - s[2] != strenum::cxx_bc) - { - cerr << "invalid encoding" << endl; - return 1; - } - } - - xml_schema::namespace_infomap map; - map["t"].name = "test"; - - root (std::cout, *r, map, "ASCII"); - } - catch (xml_schema::exception const& e) - { - cerr << "xml_schema::exception: " << e.what () << endl; - return 1; - } -} diff --git a/tests/cxx/tree/encoding/char/utf-8/makefile b/tests/cxx/tree/encoding/char/utf-8/makefile deleted file mode 100644 index fd465f3..0000000 --- a/tests/cxx/tree/encoding/char/utf-8/makefile +++ /dev/null @@ -1,85 +0,0 @@ -# file : tests/cxx/tree/encoding/char/utf-8/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-serialization --generate-doxygen -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/test.std - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/test.std -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/encoding/char/utf-8/test.std b/tests/cxx/tree/encoding/char/utf-8/test.std deleted file mode 100644 index fdfef4c..0000000 --- a/tests/cxx/tree/encoding/char/utf-8/test.std +++ /dev/null @@ -1,9 +0,0 @@ - - - abc - Օ - - abc - aՕc - ꪪbc - diff --git a/tests/cxx/tree/encoding/char/utf-8/test.xml b/tests/cxx/tree/encoding/char/utf-8/test.xml deleted file mode 100644 index 0d3e27a..0000000 --- a/tests/cxx/tree/encoding/char/utf-8/test.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - abc - Օ - - - abc - aՕc - ꪪbc - - diff --git a/tests/cxx/tree/encoding/char/utf-8/test.xsd b/tests/cxx/tree/encoding/char/utf-8/test.xsd deleted file mode 100644 index d5ee868..0000000 --- a/tests/cxx/tree/encoding/char/utf-8/test.xsd +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - Test enum. Valid values are: - abc - aՕc - ꪪbc - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/encoding/makefile b/tests/cxx/tree/encoding/makefile deleted file mode 100644 index b6f2ea6..0000000 --- a/tests/cxx/tree/encoding/makefile +++ /dev/null @@ -1,16 +0,0 @@ -# file : tests/cxx/tree/encoding/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -tests := char wchar - -default := $(out_base)/ -test := $(out_base)/.test -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) -$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) - -$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tests/cxx/tree/encoding/wchar/driver.cxx b/tests/cxx/tree/encoding/wchar/driver.cxx deleted file mode 100644 index 0756d4e..0000000 --- a/tests/cxx/tree/encoding/wchar/driver.cxx +++ /dev/null @@ -1,55 +0,0 @@ -// file : tests/cxx/tree/encoding/wchar/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test the wide character mapping. -// - -#include // std::auto_ptr/unique_ptr -#include -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - // Use dont_validate because we do not have instance's system id (path). - // - std::ifstream ifs (argv[1]); - XSD_AUTO_PTR r (root (ifs, xml_schema::flags::dont_validate)); - - { - type::b_sequence const& s (r->b ()); - - if (s[0] != strenum::abc || - s[1] != strenum::a__c || - s[2] != strenum::cxx__bc || - s[3] != strenum::ab__) - { - cerr << "invalid encoding" << endl; - return 1; - } - } - - xml_schema::namespace_infomap map; - map[L"t"].name = L"test"; - - root (std::cout, *r, map, L"ASCII"); - } - catch (xml_schema::exception const& e) - { - cerr << "xml_schema::exception: " << e.what () << endl; - return 1; - } -} diff --git a/tests/cxx/tree/encoding/wchar/makefile b/tests/cxx/tree/encoding/wchar/makefile deleted file mode 100644 index 1e351fa..0000000 --- a/tests/cxx/tree/encoding/wchar/makefile +++ /dev/null @@ -1,86 +0,0 @@ -# file : tests/cxx/tree/encoding/wchar/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-serialization --generate-doxygen \ ---char-type wchar_t -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/test.std - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/test.std -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/encoding/wchar/test.std b/tests/cxx/tree/encoding/wchar/test.std deleted file mode 100644 index e0eaef0..0000000 --- a/tests/cxx/tree/encoding/wchar/test.std +++ /dev/null @@ -1,10 +0,0 @@ - - - abc - ῿퟿ - ကჿ - abc - a῿퟿c - ကჿbc - abကჿ - diff --git a/tests/cxx/tree/encoding/wchar/test.xml b/tests/cxx/tree/encoding/wchar/test.xml deleted file mode 100644 index 9abb1b6..0000000 --- a/tests/cxx/tree/encoding/wchar/test.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - abc - ῿퟿ - ကჿ - - abc - a῿퟿c - ကჿbc - abကჿ - - diff --git a/tests/cxx/tree/encoding/wchar/test.xsd b/tests/cxx/tree/encoding/wchar/test.xsd deleted file mode 100644 index 0151d2f..0000000 --- a/tests/cxx/tree/encoding/wchar/test.xsd +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - Test enum. Valid values are: - abc - a῿퟿c - ကჿbc - abကჿ - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/enumeration/ctor/driver.cxx b/tests/cxx/tree/enumeration/ctor/driver.cxx deleted file mode 100644 index beda424..0000000 --- a/tests/cxx/tree/enumeration/ctor/driver.cxx +++ /dev/null @@ -1,30 +0,0 @@ -// file : tests/cxx/tree/enumeration/ctor/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test enumeration constructors. -// -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main () -{ - // Test ctor(const char*). - // - { - string_enum se ("a"); - type t ("a", 1); - } - - // Test ctor(const std::string&) - // - { - string const s ("c"); - string_enum se (s); - type t (s, 3); - } -} diff --git a/tests/cxx/tree/enumeration/ctor/makefile b/tests/cxx/tree/enumeration/ctor/makefile deleted file mode 100644 index 463997b..0000000 --- a/tests/cxx/tree/enumeration/ctor/makefile +++ /dev/null @@ -1,86 +0,0 @@ -# file : tests/cxx/tree/enumeration/ctor/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-default-ctor --generate-from-base-ctor \ ---generate-doxygen -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/enumeration/ctor/test.xsd b/tests/cxx/tree/enumeration/ctor/test.xsd deleted file mode 100644 index c5d625a..0000000 --- a/tests/cxx/tree/enumeration/ctor/test.xsd +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/enumeration/inheritance/driver.cxx b/tests/cxx/tree/enumeration/inheritance/driver.cxx deleted file mode 100644 index 4592099..0000000 --- a/tests/cxx/tree/enumeration/inheritance/driver.cxx +++ /dev/null @@ -1,53 +0,0 @@ -// file : tests/cxx/tree/enumeration/inheritance/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Insert test description here. -// - -#include // std::auto_ptr/unique_ptr -#include -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - XSD_AUTO_PTR r (root (argv[1])); - - switch (*r) - { - case top_bottom::top: - { - cout << "top" << endl; - break; - } - case top_bottom::bottom: - { - cout << "bottom" << endl; - break; - } - default: // Suppress warning. - { - assert (false); - break; - } - } - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/tests/cxx/tree/enumeration/inheritance/makefile b/tests/cxx/tree/enumeration/inheritance/makefile deleted file mode 100644 index 716df9b..0000000 --- a/tests/cxx/tree/enumeration/inheritance/makefile +++ /dev/null @@ -1,85 +0,0 @@ -# file : tests/cxx/tree/enumeration/inheritance/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-ostream -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/enumeration/inheritance/output b/tests/cxx/tree/enumeration/inheritance/output deleted file mode 100644 index fef12e2..0000000 --- a/tests/cxx/tree/enumeration/inheritance/output +++ /dev/null @@ -1 +0,0 @@ -bottom diff --git a/tests/cxx/tree/enumeration/inheritance/test.xml b/tests/cxx/tree/enumeration/inheritance/test.xml deleted file mode 100644 index 1de9043..0000000 --- a/tests/cxx/tree/enumeration/inheritance/test.xml +++ /dev/null @@ -1,3 +0,0 @@ -bottom diff --git a/tests/cxx/tree/enumeration/inheritance/test.xsd b/tests/cxx/tree/enumeration/inheritance/test.xsd deleted file mode 100644 index cf2eeb1..0000000 --- a/tests/cxx/tree/enumeration/inheritance/test.xsd +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/enumeration/makefile b/tests/cxx/tree/enumeration/makefile deleted file mode 100644 index 03f31f4..0000000 --- a/tests/cxx/tree/enumeration/makefile +++ /dev/null @@ -1,16 +0,0 @@ -# file : tests/cxx/tree/enumeration/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -tests := ctor inheritance - -default := $(out_base)/ -test := $(out_base)/.test -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) -$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) - -$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tests/cxx/tree/float/driver.cxx b/tests/cxx/tree/float/driver.cxx deleted file mode 100644 index fbbad95..0000000 --- a/tests/cxx/tree/float/driver.cxx +++ /dev/null @@ -1,53 +0,0 @@ -// file : tests/cxx/tree/float/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test floating point (xsd:{float, double, decimal}) type parsing -// and serialization. -// - -#include // std::auto_ptr/unique_ptr -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - XSD_AUTO_PTR r (root (argv[1])); - - r->simple ().push_back (12.129456); - r->simple ().push_back (123.129456); - r->simple ().push_back (1234.129456); - - r->s (12.129456); - - r->complex ().push_back (12.129456); - r->complex ().push_back (123.129456); - r->complex ().push_back (1234.129456); - r->complex ().push_back (-12.12); - r->complex ().push_back (-123.12); - - r->s (12.129456); - - xml_schema::namespace_infomap map; - - map["t"].name = "test"; - root (cout, *r, map); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/tests/cxx/tree/float/makefile b/tests/cxx/tree/float/makefile deleted file mode 100644 index 1bd8069..0000000 --- a/tests/cxx/tree/float/makefile +++ /dev/null @@ -1,85 +0,0 @@ -# file : tests/cxx/tree/float/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-serialization --root-element-all -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/test.std - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/test.std -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/float/test.std b/tests/cxx/tree/float/test.std deleted file mode 100644 index 399e28c..0000000 --- a/tests/cxx/tree/float/test.std +++ /dev/null @@ -1,35 +0,0 @@ - - - 0 - 1 - 1e+06 - 1e-07 - 0 1 1e+06 1e-07 - 0 - 1 - 100000000000000 - 1e-15 - 0 1 100000000000000 1e-15 - 0 - 1 - 10000 - 100000000000000 - 0.000000000000001 - 0 1 100000000000000 0.000000000000001 - 0 - 1 - 12.34 - 0.12 - 12.13 - 123.1 - 1234 - 0 - 1 - 12.34 - 0.12 - 12.13 - 123.1 - 1234 - -12.12 - -123.1 - diff --git a/tests/cxx/tree/float/test.xml b/tests/cxx/tree/float/test.xml deleted file mode 100644 index e5124a4..0000000 --- a/tests/cxx/tree/float/test.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - 0.0 - 1.0 - 1000000.0 - 0.0000001 - 0.0 1.0 1000000.0 0.0000001 - - 0.0 - 1.0 - 100000000000000.0 - 0.000000000000001 - 0.0 1.0 100000000000000.0 0.000000000000001 - - 0.0 - 1.0 - 10000 - 100000000000000.0 - 0.000000000000001 - 0.0 1.0 100000000000000.0 0.000000000000001 - - 0.0 - 1.0 - 12.34 - 0.12 - - 0.0 - 1.0 - 12.34 - 0.12 - - diff --git a/tests/cxx/tree/float/test.xsd b/tests/cxx/tree/float/test.xsd deleted file mode 100644 index c02678d..0000000 --- a/tests/cxx/tree/float/test.xsd +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/list/ctor/driver.cxx b/tests/cxx/tree/list/ctor/driver.cxx deleted file mode 100644 index 7dfe301..0000000 --- a/tests/cxx/tree/list/ctor/driver.cxx +++ /dev/null @@ -1,50 +0,0 @@ -// file : tests/cxx/tree/list/ctor/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test list constructors. -// -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main () -{ - // Test ctor() - // - { - string_list sl; - - xml_schema::nmtokens nt; - xml_schema::idrefs id; - } - - // Test ctor(size_type, const X&) - // - { - string_list sl (10, "abc"); - size_type st (10, 123); - - xml_schema::nmtokens nt (10, "abc"); - xml_schema::idrefs id (10, "abc"); - } - - // Test ctor(const I& begin, const I& end) - // - { - string_list sl1 (10, "abc"); - string_list sl2 (sl1.begin (), sl1.end ()); - - I i1 (10, 123); - I i2 (i1.begin (), i1.end ()); - - xml_schema::nmtokens nt1 (10, "abc"); - xml_schema::nmtokens nt2 (nt1.begin (), nt1.end ()); - - xml_schema::idrefs id1 (10, "abc"); - xml_schema::idrefs id2 (id1.begin (), id1.end ()); - } -} diff --git a/tests/cxx/tree/list/ctor/makefile b/tests/cxx/tree/list/ctor/makefile deleted file mode 100644 index c379934..0000000 --- a/tests/cxx/tree/list/ctor/makefile +++ /dev/null @@ -1,86 +0,0 @@ -# file : tests/cxx/tree/list/ctor/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-default-ctor --generate-from-base-ctor \ ---generate-doxygen -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/list/ctor/test.xsd b/tests/cxx/tree/list/ctor/test.xsd deleted file mode 100644 index f090bb8..0000000 --- a/tests/cxx/tree/list/ctor/test.xsd +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/list/makefile b/tests/cxx/tree/list/makefile deleted file mode 100644 index 55bc85a..0000000 --- a/tests/cxx/tree/list/makefile +++ /dev/null @@ -1,16 +0,0 @@ -# file : tests/cxx/tree/list/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -tests := ctor - -default := $(out_base)/ -test := $(out_base)/.test -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) -$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) - -$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tests/cxx/tree/makefile b/tests/cxx/tree/makefile deleted file mode 100644 index 21c79f3..0000000 --- a/tests/cxx/tree/makefile +++ /dev/null @@ -1,43 +0,0 @@ -# file : tests/cxx/tree/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make - -tests := \ -any-type \ -built-in \ -chameleon \ -comparison \ -compilation \ -complex \ -containment \ -default \ -detach \ -dom-association \ -encoding \ -enumeration \ -float \ -list \ -name-clash \ -naming \ -order \ -polymorphism \ -prefix \ -test-template \ -types-only \ -union \ -wildcard - -ifeq ($(xsd_with_ace),y) -tests += binary -endif - -default := $(out_base)/ -test := $(out_base)/.test -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) -$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) - -$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tests/cxx/tree/name-clash/inheritance/driver.cxx b/tests/cxx/tree/name-clash/inheritance/driver.cxx deleted file mode 100644 index b27d18c..0000000 --- a/tests/cxx/tree/name-clash/inheritance/driver.cxx +++ /dev/null @@ -1,35 +0,0 @@ -// file : tests/cxx/tree/name-clash/inheritance/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test for name clashes across inheritance hierarchy. -// - -#include // std::auto_ptr/unique_ptr -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - XSD_AUTO_PTR r (root (argv[1])); - - cout << *r << endl; - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/tests/cxx/tree/name-clash/inheritance/makefile b/tests/cxx/tree/name-clash/inheritance/makefile deleted file mode 100644 index 23e3cf7..0000000 --- a/tests/cxx/tree/name-clash/inheritance/makefile +++ /dev/null @@ -1,85 +0,0 @@ -# file : tests/cxx/tree/name-clash/inheritance/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-ostream -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/name-clash/inheritance/output b/tests/cxx/tree/name-clash/inheritance/output deleted file mode 100644 index 54565bb..0000000 --- a/tests/cxx/tree/name-clash/inheritance/output +++ /dev/null @@ -1,3 +0,0 @@ - -e: e -e: e1 diff --git a/tests/cxx/tree/name-clash/inheritance/test.xml b/tests/cxx/tree/name-clash/inheritance/test.xml deleted file mode 100644 index 8c17101..0000000 --- a/tests/cxx/tree/name-clash/inheritance/test.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - e - e1 - - diff --git a/tests/cxx/tree/name-clash/inheritance/test.xsd b/tests/cxx/tree/name-clash/inheritance/test.xsd deleted file mode 100644 index b83d7df..0000000 --- a/tests/cxx/tree/name-clash/inheritance/test.xsd +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/name-clash/makefile b/tests/cxx/tree/name-clash/makefile deleted file mode 100644 index 5d2b24c..0000000 --- a/tests/cxx/tree/name-clash/makefile +++ /dev/null @@ -1,16 +0,0 @@ -# file : tests/cxx/tree/name-clash/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -tests := inheritance - -default := $(out_base)/ -test := $(out_base)/.test -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) -$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) - -$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tests/cxx/tree/naming/camel/driver.cxx b/tests/cxx/tree/naming/camel/driver.cxx deleted file mode 100644 index e9d7180..0000000 --- a/tests/cxx/tree/naming/camel/driver.cxx +++ /dev/null @@ -1,154 +0,0 @@ -// file : tests/cxx/tree/naming/camel/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test camel case (upper for types, lower for functions) naming style. -// - -#include -#include - -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main () -{ - xercesc::XMLPlatformUtils::Initialize (); - - try - { - // Enum 'value' type. - // - { - Gender::Value v; - v = Gender::female; - XSD_UNUSED (v); - } - - // Anonymous type. - // - { - Foo f ("a", "b"); - - if (f.a () != "a" || f.b () != "b") - return 1; - } - - // Type name and accessors/modifiers. - // - { - Type t ("bar"); - - // foo - // - { - Type::FooType* p = 0; - XSD_UNUSED (p); - - Type::FooOptional o; - - if (t.foo ().present ()) - return 1; - - t.foo (o); - } - - // bar - // - { - Type::BarType* p = 0; - XSD_UNUSED (p); - - if (t.bar () != "bar") - return 1; - - t.bar ("barbar"); - } - - // baz - // - { - Type::BazType* p = 0; - XSD_UNUSED (p); - - Type::BazSequence s; - Type::BazIterator i (s.begin ()); - Type::BazConstIterator ci (s.begin ()); - XSD_UNUSED (i); - XSD_UNUSED (ci); - - if (t.baz () != s) - return 1; - - t.baz (s); - } - - // any - // - { - Type::AnySequence s (t.domDocument ()); - Type::AnyIterator i (s.begin ()); - Type::AnyConstIterator ci (s.begin ()); - XSD_UNUSED (i); - XSD_UNUSED (ci); - - if (t.any () != s) - return 1; - - t.any (s); - } - - // foo - // - { - Type::FoxType x = Type::foxDefaultValue (); - - if (t.fox () != x) - return 1; - - t.fox ("fox"); - } - - // any_attribute - // - { - Type::AnyAttributeSet s (t.domDocument ()); - Type::AnyAttributeIterator i (s.begin ()); - Type::AnyAttributeConstIterator ci (s.begin ()); - XSD_UNUSED (i); - XSD_UNUSED (ci); - - if (t.anyAttribute () != s) - return 1; - - t.anyAttribute (s); - } - } - - // Parsing/serialization functions. - // - { - istringstream is ("foo"); - root (is, xml_schema::Flags::dont_validate); - } - - { - ostringstream os; - xml_schema::NamespaceInfomap m; - m["t"].name = "test"; - - root (os, "foo", m); - } - } - catch (xml_schema::Exception const& e) - { - cerr << e << endl; - return 1; - } - - xercesc::XMLPlatformUtils::Terminate (); -} diff --git a/tests/cxx/tree/naming/camel/makefile b/tests/cxx/tree/naming/camel/makefile deleted file mode 100644 index 3fc0dcc..0000000 --- a/tests/cxx/tree/naming/camel/makefile +++ /dev/null @@ -1,93 +0,0 @@ -# file : tests/cxx/tree/naming/camel/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += \ ---type-naming ucc \ ---function-naming lcc \ ---generate-ostream \ ---generate-serialization \ ---generate-comparison \ ---generate-wildcard - -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/naming/camel/test.xsd b/tests/cxx/tree/naming/camel/test.xsd deleted file mode 100644 index 7d0a745..0000000 --- a/tests/cxx/tree/naming/camel/test.xsd +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/naming/java/driver.cxx b/tests/cxx/tree/naming/java/driver.cxx deleted file mode 100644 index b96917b..0000000 --- a/tests/cxx/tree/naming/java/driver.cxx +++ /dev/null @@ -1,153 +0,0 @@ -// file : tests/cxx/tree/naming/java/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test Java naming style. -// - -#include -#include - -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main () -{ - xercesc::XMLPlatformUtils::Initialize (); - - try - { - // Enum 'value' type. - // - { - Gender::Value v; - v = Gender::female; - XSD_UNUSED (v); - } - - // Anonymous type. - // - { - Foo f ("a", "b"); - - if (f.getA () != "a" || f.getB () != "b") - return 1; - } - - // Type name and accessors/modifiers. - // - { - Type t ("bar"); - - // foo - // - { - Type::FooType* p = 0; - XSD_UNUSED (p); - Type::FooOptional o; - - if (t.getFoo ().present ()) - return 1; - - t.setFoo (o); - } - - // bar - // - { - Type::BarType* p = 0; - XSD_UNUSED (p); - - if (t.getBar () != "bar") - return 1; - - t.setBar ("barbar"); - } - - // baz - // - { - Type::BazType* p = 0; - XSD_UNUSED (p); - - Type::BazSequence s; - Type::BazIterator i (s.begin ()); - Type::BazConstIterator ci (s.begin ()); - XSD_UNUSED (i); - XSD_UNUSED (ci); - - if (t.getBaz () != s) - return 1; - - t.setBaz (s); - } - - // any - // - { - Type::AnySequence s (t.getDomDocument ()); - Type::AnyIterator i (s.begin ()); - Type::AnyConstIterator ci (s.begin ()); - XSD_UNUSED (i); - XSD_UNUSED (ci); - - if (t.getAny () != s) - return 1; - - t.setAny (s); - } - - // foo - // - { - Type::FoxType x = Type::getFoxDefaultValue (); - - if (t.getFox () != x) - return 1; - - t.setFox ("fox"); - } - - // any_attribute - // - { - Type::AnyAttributeSet s (t.getDomDocument ()); - Type::AnyAttributeIterator i (s.begin ()); - Type::AnyAttributeConstIterator ci (s.begin ()); - XSD_UNUSED (i); - XSD_UNUSED (ci); - - if (t.getAnyAttribute () != s) - return 1; - - t.setAnyAttribute (s); - } - } - - // Parsing/serialization functions. - // - { - istringstream is ("foo"); - parseRoot (is, xml_schema::Flags::dont_validate); - } - - { - ostringstream os; - xml_schema::NamespaceInfomap m; - m["t"].name = "test"; - - serializeRoot (os, "foo", m); - } - } - catch (xml_schema::Exception const& e) - { - cerr << e << endl; - return 1; - } - - xercesc::XMLPlatformUtils::Terminate (); -} diff --git a/tests/cxx/tree/naming/java/makefile b/tests/cxx/tree/naming/java/makefile deleted file mode 100644 index 713126d..0000000 --- a/tests/cxx/tree/naming/java/makefile +++ /dev/null @@ -1,93 +0,0 @@ -# file : tests/cxx/tree/naming/java/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += \ ---type-naming java \ ---function-naming java \ ---generate-ostream \ ---generate-serialization \ ---generate-comparison \ ---generate-wildcard - -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/naming/java/test.xsd b/tests/cxx/tree/naming/java/test.xsd deleted file mode 100644 index f525534..0000000 --- a/tests/cxx/tree/naming/java/test.xsd +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/naming/knr/driver.cxx b/tests/cxx/tree/naming/knr/driver.cxx deleted file mode 100644 index 28e6562..0000000 --- a/tests/cxx/tree/naming/knr/driver.cxx +++ /dev/null @@ -1,154 +0,0 @@ -// file : tests/cxx/tree/naming/knr/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test K&R naming style. -// - -#include -#include - -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main () -{ - xercesc::XMLPlatformUtils::Initialize (); - - try - { - // Enum 'value' type. - // - { - gender::value v; - v = gender::female; - XSD_UNUSED (v); - } - - // Anonymous type. - // - { - foo f ("a", "b"); - - if (f.a () != "a" || f.b () != "b") - return 1; - } - - // Type name and accessors/modifiers. - // - { - type t ("bar"); - - // foo - // - { - type::foo_type* p = 0; - XSD_UNUSED (p); - - type::foo_optional o; - - if (t.foo ().present ()) - return 1; - - t.foo (o); - } - - // bar - // - { - type::bar_type* p = 0; - XSD_UNUSED (p); - - if (t.bar () != "bar") - return 1; - - t.bar ("barbar"); - } - - // baz - // - { - type::baz_type* p = 0; - XSD_UNUSED (p); - - type::baz_sequence s; - type::baz_iterator i (s.begin ()); - type::baz_const_iterator ci (s.begin ()); - XSD_UNUSED (i); - XSD_UNUSED (ci); - - if (t.baz () != s) - return 1; - - t.baz (s); - } - - // any - // - { - type::any_sequence s (t.dom_document ()); - type::any_iterator i (s.begin ()); - type::any_const_iterator ci (s.begin ()); - XSD_UNUSED (i); - XSD_UNUSED (ci); - - if (t.any () != s) - return 1; - - t.any (s); - } - - // foo - // - { - type::fox_type x = type::fox_default_value (); - - if (t.fox () != x) - return 1; - - t.fox ("fox"); - } - - // any_attribute - // - { - type::any_attribute_set s (t.dom_document ()); - type::any_attribute_iterator i (s.begin ()); - type::any_attribute_const_iterator ci (s.begin ()); - XSD_UNUSED (i); - XSD_UNUSED (ci); - - if (t.any_attribute () != s) - return 1; - - t.any_attribute (s); - } - } - - // Parsing/serialization functions. - // - { - istringstream is ("foo"); - root (is, xml_schema::flags::dont_validate); - } - - { - ostringstream os; - xml_schema::namespace_infomap m; - m["t"].name = "test"; - - root (os, "foo", m); - } - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - - xercesc::XMLPlatformUtils::Terminate (); -} diff --git a/tests/cxx/tree/naming/knr/makefile b/tests/cxx/tree/naming/knr/makefile deleted file mode 100644 index 364a491..0000000 --- a/tests/cxx/tree/naming/knr/makefile +++ /dev/null @@ -1,93 +0,0 @@ -# file : tests/cxx/tree/naming/knr/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += \ ---type-naming knr \ ---function-naming knr \ ---generate-ostream \ ---generate-serialization \ ---generate-comparison \ ---generate-wildcard - -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/naming/knr/test.xsd b/tests/cxx/tree/naming/knr/test.xsd deleted file mode 100644 index 4361544..0000000 --- a/tests/cxx/tree/naming/knr/test.xsd +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/naming/makefile b/tests/cxx/tree/naming/makefile deleted file mode 100644 index 3c974ef..0000000 --- a/tests/cxx/tree/naming/makefile +++ /dev/null @@ -1,16 +0,0 @@ -# file : tests/cxx/tree/naming/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -tests := camel java knr - -default := $(out_base)/ -test := $(out_base)/.test -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) -$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) - -$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tests/cxx/tree/order/driver.cxx b/tests/cxx/tree/order/driver.cxx deleted file mode 100644 index 839191a..0000000 --- a/tests/cxx/tree/order/driver.cxx +++ /dev/null @@ -1,64 +0,0 @@ -// file : tests/cxx/tree/order/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test ordered type support. -// - -#include // std::auto_ptr/unique_ptr -#include -#include - -#include -#include - -#include "test.hxx" - -using namespace std; -using namespace test; -using namespace xercesc; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - XMLPlatformUtils::Initialize (); - - try - { - XSD_AUTO_PTR r (root_ (argv[1], xml_schema::flags::dont_initialize)); - - root c (*r); - assert (c == *r); - - for (root::t1_const_iterator j (r->t1 ().begin ()); - j != r->t1 ().end (); ++j) - { - const t1_derived& d (*j); - - for (t1_derived::content_order_const_iterator i ( - d.content_order ().begin ()); i != d.content_order ().end (); ++i) - { - cout << i->id << ' ' << i->index << endl; - } - } - - xml_schema::namespace_infomap map; - - map["t"].name = "test"; - map["t1"].name = "test1"; - - root_ (cout, *r, map, "UTF-8", xml_schema::flags::dont_initialize); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - - XMLPlatformUtils::Terminate (); -} diff --git a/tests/cxx/tree/order/makefile b/tests/cxx/tree/order/makefile deleted file mode 100644 index 251b1f3..0000000 --- a/tests/cxx/tree/order/makefile +++ /dev/null @@ -1,93 +0,0 @@ -# file : tests/cxx/tree/order/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-serialization --generate-wildcard \ ---generate-comparison \ ---ordered-type t1_base --ordered-type t1_derived \ ---ordered-type t2_base --ordered-type t2_derived \ ---ordered-type t3_type \ ---ordered-type t4_base --ordered-type t4_derived \ ---ordered-type t5_base --ordered-type t5_derived \ ---ordered-type t6_base --ordered-type t6_derived \ ---ordered-type t7_type -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/order/output b/tests/cxx/tree/order/output deleted file mode 100644 index 73442fe..0000000 --- a/tests/cxx/tree/order/output +++ /dev/null @@ -1,92 +0,0 @@ -2 0 -1 0 -1 1 -2 1 -3 0 -4 0 -3 1 -4 1 - - - - b1 - a1 - a2 - b2 - c1 - d1 - e1 - d2 - f1 - - - b1 - a1 - b2 - a2 - - - a1 - b1 - c1 - c2 - - - a1 - c1 - - - t1 - - b1 - t2 - - a1 - t3 - - b2 - t4 - - a2 - t5 - - d1 - t6 - - c1 - t7 - - - - t5a - - - t1 - - b1 - t2 - - a1 - t3 - - a2 - t4 - - b2 - t5 - - - - t6 - - - t1 - - a1 - t2 - - b1 - t3 - - - diff --git a/tests/cxx/tree/order/test.xml b/tests/cxx/tree/order/test.xml deleted file mode 100644 index cd82936..0000000 --- a/tests/cxx/tree/order/test.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - b1 - a1 - a2 - b2 - c1 - d1 - e1 - d2 - f1 - - - b1 - a1 - b2 - a2 - - - a1 - b1 - c1 - c2 - - - a1 - c1 - - - t1 - b1 - t2 - a1 - t3 - b2 - t4 - a2 - t5 - d1 - t6 - c1 - t7 - - - t5a - - - t1 - b1 - t2 - a1 - t3 - a2 - t4 - b2 - t5 - - - t6 - - - t1 - a1 - t2 - b1 - t3 - - diff --git a/tests/cxx/tree/order/test.xsd b/tests/cxx/tree/order/test.xsd deleted file mode 100644 index c30c027..0000000 --- a/tests/cxx/tree/order/test.xsd +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/polymorphism/comparison/driver.cxx b/tests/cxx/tree/polymorphism/comparison/driver.cxx deleted file mode 100644 index 8685a2e..0000000 --- a/tests/cxx/tree/polymorphism/comparison/driver.cxx +++ /dev/null @@ -1,85 +0,0 @@ -// file : tests/cxx/tree/polymorphism/comparison/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test comparison of polymorphic object models. -// - -#include // std::auto_ptr/unique_ptr -#include -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - XSD_AUTO_PTR r (root (argv[1])); - - // Equals. - // - { - derived1 d ("a", 1); - d.b ("b"); - type r1 (d); - - assert (*r == r1); - } - - // Values are not equal. - // - { - derived1 d ("a", 1); - d.b ("c"); - type r1 (d); - - assert (*r != r1); - } - - // Values are not equal. - // - { - derived1 d ("a", 2); - d.b ("b"); - type r1 (d); - - assert (*r != r1); - } - - // Different types. - // - { - derived2 d ("a", 1); - d.c ().push_back ("c"); - type r1 (d); - - assert (*r != r1); - } - - xml_schema::namespace_infomap map; - - map["t"].name = "test"; - - stringstream s; - root (s, *r, map); - - XSD_AUTO_PTR c (root (s, xml_schema::flags::dont_validate)); - - assert (*r == *c); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/tests/cxx/tree/polymorphism/comparison/makefile b/tests/cxx/tree/polymorphism/comparison/makefile deleted file mode 100644 index 15e6d02..0000000 --- a/tests/cxx/tree/polymorphism/comparison/makefile +++ /dev/null @@ -1,86 +0,0 @@ -# file : tests/cxx/tree/polymorphism/comparison/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-polymorphic --polymorphic-type base \ ---generate-comparison --generate-serialization -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml - $(call message,test $$1,$$1 $(src_base)/test.xml,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/polymorphism/comparison/test.xml b/tests/cxx/tree/polymorphism/comparison/test.xml deleted file mode 100644 index 0b8c125..0000000 --- a/tests/cxx/tree/polymorphism/comparison/test.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - a1b - - diff --git a/tests/cxx/tree/polymorphism/comparison/test.xsd b/tests/cxx/tree/polymorphism/comparison/test.xsd deleted file mode 100644 index 364d1b3..0000000 --- a/tests/cxx/tree/polymorphism/comparison/test.xsd +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/polymorphism/makefile b/tests/cxx/tree/polymorphism/makefile deleted file mode 100644 index 93a3ad2..0000000 --- a/tests/cxx/tree/polymorphism/makefile +++ /dev/null @@ -1,16 +0,0 @@ -# file : tests/cxx/tree/polymorphism/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -tests := comparison ostream same-type - -default := $(out_base)/ -test := $(out_base)/.test -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) -$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) - -$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tests/cxx/tree/polymorphism/ostream/driver.cxx b/tests/cxx/tree/polymorphism/ostream/driver.cxx deleted file mode 100644 index 7da2030..0000000 --- a/tests/cxx/tree/polymorphism/ostream/driver.cxx +++ /dev/null @@ -1,34 +0,0 @@ -// file : tests/cxx/tree/polymorphism/ostream/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test printing of polymorphic object models. -// - -#include // std::auto_ptr/unique_ptr -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - XSD_AUTO_PTR r (root (argv[1])); - cout << *r << endl; - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/tests/cxx/tree/polymorphism/ostream/makefile b/tests/cxx/tree/polymorphism/ostream/makefile deleted file mode 100644 index 65c37b1..0000000 --- a/tests/cxx/tree/polymorphism/ostream/makefile +++ /dev/null @@ -1,87 +0,0 @@ -# file : tests/cxx/tree/polymorphism/ostream/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-polymorphic --polymorphic-type-all \ ---root-element root --generate-ostream -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/polymorphism/ostream/output b/tests/cxx/tree/polymorphism/ostream/output deleted file mode 100644 index e7fbd68..0000000 --- a/tests/cxx/tree/polymorphism/ostream/output +++ /dev/null @@ -1,18 +0,0 @@ - -base: -a: a -fund: 1 -base: -a: a -fund: 1 -b: b -base: -a: a -fund: 1 -c: c1 -c: c2 -base: -a: a -fund: 1 -d: d1 -d: d2 diff --git a/tests/cxx/tree/polymorphism/ostream/test.xml b/tests/cxx/tree/polymorphism/ostream/test.xml deleted file mode 100644 index 5409d2a..0000000 --- a/tests/cxx/tree/polymorphism/ostream/test.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - a1 - a1b - a1c1c2 - a1d1d2 - - diff --git a/tests/cxx/tree/polymorphism/ostream/test.xsd b/tests/cxx/tree/polymorphism/ostream/test.xsd deleted file mode 100644 index 688cd5a..0000000 --- a/tests/cxx/tree/polymorphism/ostream/test.xsd +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/polymorphism/same-type/driver.cxx b/tests/cxx/tree/polymorphism/same-type/driver.cxx deleted file mode 100644 index 883ba64..0000000 --- a/tests/cxx/tree/polymorphism/same-type/driver.cxx +++ /dev/null @@ -1,35 +0,0 @@ -// file : tests/cxx/tree/polymorphism/same-type/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test substitution group and xsi:type that don't change the type. -// - -#include // std::auto_ptr/unique_ptr -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - XSD_AUTO_PTR r (root (argv[1])); - - cout << *r << endl; - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/tests/cxx/tree/polymorphism/same-type/makefile b/tests/cxx/tree/polymorphism/same-type/makefile deleted file mode 100644 index 3185804..0000000 --- a/tests/cxx/tree/polymorphism/same-type/makefile +++ /dev/null @@ -1,86 +0,0 @@ -# file : tests/cxx/tree/polymorphism/same-type/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-ostream --generate-polymorphic \ ---root-element root -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/polymorphism/same-type/output b/tests/cxx/tree/polymorphism/same-type/output deleted file mode 100644 index 04b5cbf..0000000 --- a/tests/cxx/tree/polymorphism/same-type/output +++ /dev/null @@ -1,9 +0,0 @@ - -base: -a: a1 -base: -a: a2 -base: -a: a3 -base: -a: a4 diff --git a/tests/cxx/tree/polymorphism/same-type/test.xml b/tests/cxx/tree/polymorphism/same-type/test.xml deleted file mode 100644 index f8b6d1e..0000000 --- a/tests/cxx/tree/polymorphism/same-type/test.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - a1 - a2 - a3 - a4 - - diff --git a/tests/cxx/tree/polymorphism/same-type/test.xsd b/tests/cxx/tree/polymorphism/same-type/test.xsd deleted file mode 100644 index a4157d3..0000000 --- a/tests/cxx/tree/polymorphism/same-type/test.xsd +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/prefix/bar.xsd b/tests/cxx/tree/prefix/bar.xsd deleted file mode 100644 index 4e20902..0000000 --- a/tests/cxx/tree/prefix/bar.xsd +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/prefix/driver.cxx b/tests/cxx/tree/prefix/driver.cxx deleted file mode 100644 index 4c99fd9..0000000 --- a/tests/cxx/tree/prefix/driver.cxx +++ /dev/null @@ -1,34 +0,0 @@ -// file : tests/cxx/tree/prefix/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test automatic prefix assignment. -// - -#include // std::auto_ptr/unique_ptr -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - XSD_AUTO_PTR r (root (argv[1])); - root (std::cout, *r); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/tests/cxx/tree/prefix/foo.xsd b/tests/cxx/tree/prefix/foo.xsd deleted file mode 100644 index 97a35cf..0000000 --- a/tests/cxx/tree/prefix/foo.xsd +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/prefix/makefile b/tests/cxx/tree/prefix/makefile deleted file mode 100644 index 0e5e3f3..0000000 --- a/tests/cxx/tree/prefix/makefile +++ /dev/null @@ -1,86 +0,0 @@ -# file : tests/cxx/tree/prefix/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd foo.xsd bar.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-serialization --generate-polymorphic \ ---polymorphic-type foo\#base --root-element root -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/prefix/output b/tests/cxx/tree/prefix/output deleted file mode 100644 index 9801a23..0000000 --- a/tests/cxx/tree/prefix/output +++ /dev/null @@ -1,18 +0,0 @@ - - - - 123 - - - - 1 - 2 - - - - - 1 - 2 - - - diff --git a/tests/cxx/tree/prefix/test.xml b/tests/cxx/tree/prefix/test.xml deleted file mode 100644 index b6d0dd6..0000000 --- a/tests/cxx/tree/prefix/test.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - 123 - - - - 12 - - - - 12 - - - diff --git a/tests/cxx/tree/prefix/test.xsd b/tests/cxx/tree/prefix/test.xsd deleted file mode 100644 index 421fdc0..0000000 --- a/tests/cxx/tree/prefix/test.xsd +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/test-template/driver.cxx b/tests/cxx/tree/test-template/driver.cxx deleted file mode 100644 index be345f6..0000000 --- a/tests/cxx/tree/test-template/driver.cxx +++ /dev/null @@ -1,35 +0,0 @@ -// file : tests/cxx/tree/test-template/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Insert test description here. -// - -#include // std::auto_ptr/unique_ptr -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - try - { - XSD_AUTO_PTR r (root (argv[1])); - - cout << *r << endl; - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } -} diff --git a/tests/cxx/tree/test-template/makefile b/tests/cxx/tree/test-template/makefile deleted file mode 100644 index 1b1e531..0000000 --- a/tests/cxx/tree/test-template/makefile +++ /dev/null @@ -1,85 +0,0 @@ -# file : tests/cxx/tree/test-template/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-ostream -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/test-template/output b/tests/cxx/tree/test-template/output deleted file mode 100644 index 2a50681..0000000 --- a/tests/cxx/tree/test-template/output +++ /dev/null @@ -1,2 +0,0 @@ - -a: a diff --git a/tests/cxx/tree/test-template/test.xml b/tests/cxx/tree/test-template/test.xml deleted file mode 100644 index 624a80c..0000000 --- a/tests/cxx/tree/test-template/test.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - a - - diff --git a/tests/cxx/tree/test-template/test.xsd b/tests/cxx/tree/test-template/test.xsd deleted file mode 100644 index 07bebc7..0000000 --- a/tests/cxx/tree/test-template/test.xsd +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/tests/cxx/tree/types-only/driver.cxx b/tests/cxx/tree/types-only/driver.cxx deleted file mode 100644 index fd1b8f6..0000000 --- a/tests/cxx/tree/types-only/driver.cxx +++ /dev/null @@ -1,30 +0,0 @@ -// file : tests/cxx/tree/types-only/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test that code generated without parsing and serialization functions -// still compiles. -// - -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main () -{ - color_enum red (color_enum::red); - red_blue_enum blue (red_blue_enum::blue); - - long_string_union num ("123"); - - string_list list; - list.push_back ("Hello"); - list.push_back ("World"); - - complex_type t ("Hello, World!", "foo", color_enum::red); - - anon a ("Hello, World!"); -} diff --git a/tests/cxx/tree/types-only/makefile b/tests/cxx/tree/types-only/makefile deleted file mode 100644 index 3c156ac..0000000 --- a/tests/cxx/tree/types-only/makefile +++ /dev/null @@ -1,85 +0,0 @@ -# file : tests/cxx/tree/types-only/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --suppress-parsing -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/types-only/test.xsd b/tests/cxx/tree/types-only/test.xsd deleted file mode 100644 index 9f02240..0000000 --- a/tests/cxx/tree/types-only/test.xsd +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/union/ctor/driver.cxx b/tests/cxx/tree/union/ctor/driver.cxx deleted file mode 100644 index df60a93..0000000 --- a/tests/cxx/tree/union/ctor/driver.cxx +++ /dev/null @@ -1,30 +0,0 @@ -// file : tests/cxx/tree/union/ctor/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test union constructors. -// -#include - -#include "test.hxx" - -using namespace std; -using namespace test; - -int -main () -{ - // Test ctor(const std::string&) - // - { - string const s ("123"); - int_string_union u (s); - type t (s); - } - - // Test ctor(const char*). - // - { - int_string_union u ("123"); - type t ("123"); - } -} diff --git a/tests/cxx/tree/union/ctor/makefile b/tests/cxx/tree/union/ctor/makefile deleted file mode 100644 index 45dc1c5..0000000 --- a/tests/cxx/tree/union/ctor/makefile +++ /dev/null @@ -1,86 +0,0 @@ -# file : tests/cxx/tree/union/ctor/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-default-ctor --generate-from-base-ctor \ ---generate-doxygen -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) - $(call message,test $$1,$$1,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/union/ctor/test.xsd b/tests/cxx/tree/union/ctor/test.xsd deleted file mode 100644 index 9601093..0000000 --- a/tests/cxx/tree/union/ctor/test.xsd +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/tests/cxx/tree/union/makefile b/tests/cxx/tree/union/makefile deleted file mode 100644 index 59fa39c..0000000 --- a/tests/cxx/tree/union/makefile +++ /dev/null @@ -1,16 +0,0 @@ -# file : tests/cxx/tree/union/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -tests := ctor - -default := $(out_base)/ -test := $(out_base)/.test -clean := $(out_base)/.clean - -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) -$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) - -$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tests/cxx/tree/wildcard/driver.cxx b/tests/cxx/tree/wildcard/driver.cxx deleted file mode 100644 index 51a17a3..0000000 --- a/tests/cxx/tree/wildcard/driver.cxx +++ /dev/null @@ -1,203 +0,0 @@ -// file : tests/cxx/tree/wildcard/driver.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -// Test wildcard (any & anyAttribute) mapping. -// - -#include // std::auto_ptr/unique_ptr -#include -#include - -#include -#include - -#include "test.hxx" // Get XSD_CXX11 defined. - -#include - -using namespace std; -using namespace test; -using namespace xercesc; - -namespace xml = xsd::cxx::xml; - -void -print (type& t) -{ - if (t.att ()) - cout << *t.att () << endl; - - type::any_attribute_set& as (t.any_attribute ()); - - for (type::any_attribute_iterator i (as.begin ()); i != as.end (); ++i) - { - cout << xml::transcode (i->getTextContent ()) << endl; - } - - cout << xml::transcode (t.any ().getTextContent ()) << endl - << t.foo () << endl; - - if (t.any1 ()) - cout << xml::transcode (t.any1 ()->getTextContent ()) << endl; - - cout << t.bar () << endl; - - type::any2_sequence& es (t.any2 ()); - - for (type::any2_iterator i (es.begin ()); i != es.end (); ++i) - { - cout << xml::transcode (i->getTextContent ()) << endl; - } - - cout << endl; -} - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " test.xml" << endl; - return 1; - } - - XMLPlatformUtils::Initialize (); - - try - { - // Test accessors/modifiers for various cardinalities. - // - type t; - - DOMDocument& doc (t.dom_document ()); - - // one - // - { - DOMElement* e (doc.createElement (xml::string ("a").c_str ())); - t.any (*e); - e->release (); - assert (xml::transcode (t.any ().getTagName ()) == "a"); - - t.any (doc.createElement (xml::string ("b").c_str ())); - assert (xml::transcode (t.any ().getTagName ()) == "b"); - } - - // optional - // - { - assert (!t.any1 ().present ()); - - DOMElement* e (doc.createElement (xml::string ("a").c_str ())); - t.any1 (*e); - e->release (); - assert (t.any1 ().present ()); - assert (xml::transcode (t.any1 ().get ().getTagName ()) == "a"); - - t.any1 (doc.createElement (xml::string ("b").c_str ())); - assert (xml::transcode (t.any1 ()->getTagName ()) == "b"); - - type::any1_optional c ( - doc.createElement (xml::string ("c").c_str ()), doc); - t.any1 (c); - assert (xml::transcode (t.any1 ()->getTagName ()) == "c"); - } - - - // sequence - // - { - type::any2_sequence& s (t.any2 ()); - - DOMElement* e (doc.createElement (xml::string ("a").c_str ())); - s.push_back (*e); - e->release (); - s.push_back (doc.createElement (xml::string ("b").c_str ())); - assert (s.size () == 2); - - for (type::any2_iterator i (s.begin ()); i != s.end (); ++i) - { - if (i == s.begin ()) - assert (xml::transcode (i->getTagName ()) == "a"); - else - assert (xml::transcode ((*i).getTagName ()) == "b"); - } - - // copy c-tor - type::any2_sequence cs (s, doc); - assert (cs.size () == 2); - assert (xml::transcode (cs[0].getTagName ()) == "a"); - assert (xml::transcode (cs[1].getTagName ()) == "b"); - - // assignment - t.any2 (cs); - assert (s.size () == 2); - assert (xml::transcode (s[0].getTagName ()) == "a"); - assert (xml::transcode (s[1].getTagName ()) == "b"); - } - - // anyAttribute - // - { - type::any_attribute_set& s (t.any_attribute ()); - - DOMAttr* a (doc.createAttribute (xml::string ("a").c_str ())); - s.insert (*a); - a->release (); - s.insert (doc.createAttribute (xml::string ("b").c_str ())); - assert (s.size () == 2); - - assert (s.find ("a") != s.end ()); - assert (s.find ("b") != s.end ()); - - for (type::any_attribute_iterator i (s.begin ()); i != s.end (); ++i) - { - assert (xml::transcode (i->getName ()) == "a" || - xml::transcode ((*i).getName ()) == "b"); - } - - // copy c-tor - type::any_attribute_set cs (s, doc); - assert (cs.size () == 2); - assert (cs.count ("a")); - assert (cs.count ("b")); - - // assignment - t.any_attribute (cs); - assert (s.size () == 2); - assert (s.count ("a")); - assert (s.count ("b")); - } - - // Test parsing - // - XSD_AUTO_PTR r (root (argv[1])); - print (*r); - - // Test serialization. - // - xml_schema::namespace_infomap map; - - map["t"].name = "test"; - map["t"].schema = "test.xsd"; - map["o"].name = "other"; - - stringstream iostr; - root (iostr, *r, map); - - // cout << iostr.str () << endl - // << endl; - - XSD_AUTO_PTR copy (root (iostr, argv[1])); - assert (*copy == *r); - - print (*copy); - } - catch (xml_schema::exception const& e) - { - cerr << e << endl; - return 1; - } - - XMLPlatformUtils::Terminate (); -} diff --git a/tests/cxx/tree/wildcard/makefile b/tests/cxx/tree/wildcard/makefile deleted file mode 100644 index 39f4846..0000000 --- a/tests/cxx/tree/wildcard/makefile +++ /dev/null @@ -1,86 +0,0 @@ -# file : tests/cxx/tree/wildcard/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := test.xsd -cxx := driver.cxx - -obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) -dep := $(obj:.o=.o.d) - -driver := $(out_base)/driver -test := $(out_base)/.test -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 += --generate-wildcard --generate-default-ctor \ ---generate-from-base-ctor --generate-serialization --generate-comparison -$(gen): $(out_root)/xsd/xsd - -$(call include-dep,$(dep),$(obj),$(gen)) - -# Convenience alias for default target. -# -$(out_base)/: $(driver) - - -# Test. -# -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/test.xml $(src_base)/output - $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) - -# 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)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): xsd_options += --std $(cxx_standard) -$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) -endif - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/wildcard/output b/tests/cxx/tree/wildcard/output deleted file mode 100644 index b23b488..0000000 --- a/tests/cxx/tree/wildcard/output +++ /dev/null @@ -1,24 +0,0 @@ -att -any -o:any -t:any -o:one -foo -t:bar -bar -o:one1 -o:one2 -o:one3 - -att -any -o:any -t:any -o:one -foo -t:bar -bar -o:one1 -o:one2 -o:one3 - diff --git a/tests/cxx/tree/wildcard/test.xml b/tests/cxx/tree/wildcard/test.xml deleted file mode 100644 index b0c3267..0000000 --- a/tests/cxx/tree/wildcard/test.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - o:one - foo - t:bar - bar - o:one1 - o:one2 - o:one3 - - diff --git a/tests/cxx/tree/wildcard/test.xsd b/tests/cxx/tree/wildcard/test.xsd deleted file mode 100644 index 6c7b308..0000000 --- a/tests/cxx/tree/wildcard/test.xsd +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/tests/failed/test-00.xsd b/tests/failed/test-00.xsd deleted file mode 100644 index 5223f82..0000000 --- a/tests/failed/test-00.xsd +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/tests/makefile b/tests/makefile deleted file mode 100644 index 7c3a64f..0000000 --- a/tests/makefile +++ /dev/null @@ -1,14 +0,0 @@ -# file : tests/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make - -default := $(out_base)/ -test := $(out_base)/.test -clean := $(out_base)/.clean - -$(default): $(out_base)/cxx/ -$(test): $(out_base)/cxx/.test -$(clean): $(out_base)/cxx/.clean - -$(call import,$(src_base)/cxx/makefile) diff --git a/tests/morphing/anonymous/attribute-group/test.xsd b/tests/morphing/anonymous/attribute-group/test.xsd deleted file mode 100644 index 657be8a..0000000 --- a/tests/morphing/anonymous/attribute-group/test.xsd +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/morphing/anonymous/cyclic-inclusion/includee.xsd b/tests/morphing/anonymous/cyclic-inclusion/includee.xsd deleted file mode 100644 index 51f7916..0000000 --- a/tests/morphing/anonymous/cyclic-inclusion/includee.xsd +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - diff --git a/tests/morphing/anonymous/cyclic-inclusion/includer.xsd b/tests/morphing/anonymous/cyclic-inclusion/includer.xsd deleted file mode 100644 index 54e6b69..0000000 --- a/tests/morphing/anonymous/cyclic-inclusion/includer.xsd +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - diff --git a/tests/morphing/anonymous/group/test.xsd b/tests/morphing/anonymous/group/test.xsd deleted file mode 100644 index 73e07af..0000000 --- a/tests/morphing/anonymous/group/test.xsd +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/morphing/anonymous/test-000.xsd b/tests/morphing/anonymous/test-000.xsd deleted file mode 100644 index ce930d8..0000000 --- a/tests/morphing/anonymous/test-000.xsd +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/tests/morphing/anonymous/unstable/includee-1.xsd b/tests/morphing/anonymous/unstable/includee-1.xsd deleted file mode 100644 index 916816f..0000000 --- a/tests/morphing/anonymous/unstable/includee-1.xsd +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/tests/morphing/anonymous/unstable/includee-2.xsd b/tests/morphing/anonymous/unstable/includee-2.xsd deleted file mode 100644 index eb8222c..0000000 --- a/tests/morphing/anonymous/unstable/includee-2.xsd +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - diff --git a/tests/morphing/anonymous/unstable/includer.xsd b/tests/morphing/anonymous/unstable/includer.xsd deleted file mode 100644 index 4593b5f..0000000 --- a/tests/morphing/anonymous/unstable/includer.xsd +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - diff --git a/tests/processing/inheritance/test-000.xsd b/tests/processing/inheritance/test-000.xsd deleted file mode 100644 index ef1ef71..0000000 --- a/tests/processing/inheritance/test-000.xsd +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/processing/inheritance/test-001.xsd b/tests/processing/inheritance/test-001.xsd deleted file mode 100644 index 5afc997..0000000 --- a/tests/processing/inheritance/test-001.xsd +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/schema/anonymous/test.xsd b/tests/schema/anonymous/test.xsd deleted file mode 100644 index cba3300..0000000 --- a/tests/schema/anonymous/test.xsd +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/schema/any-attribute/test.xsd b/tests/schema/any-attribute/test.xsd deleted file mode 100644 index 55419c4..0000000 --- a/tests/schema/any-attribute/test.xsd +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/tests/schema/any-type/test.xsd b/tests/schema/any-type/test.xsd deleted file mode 100644 index 9e3ff79..0000000 --- a/tests/schema/any-type/test.xsd +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/tests/schema/any/fail.xsd b/tests/schema/any/fail.xsd deleted file mode 100644 index 2eb9513..0000000 --- a/tests/schema/any/fail.xsd +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/tests/schema/any/test.xsd b/tests/schema/any/test.xsd deleted file mode 100644 index ff896fd..0000000 --- a/tests/schema/any/test.xsd +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/tests/schema/attribute-group/global.xsd b/tests/schema/attribute-group/global.xsd deleted file mode 100644 index 6ee0539..0000000 --- a/tests/schema/attribute-group/global.xsd +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/schema/attribute/global.xsd b/tests/schema/attribute/global.xsd deleted file mode 100644 index e2dcc93..0000000 --- a/tests/schema/attribute/global.xsd +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/tests/schema/attribute/local.xsd b/tests/schema/attribute/local.xsd deleted file mode 100644 index 7a7a480..0000000 --- a/tests/schema/attribute/local.xsd +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/schema/attribute/ref.xsd b/tests/schema/attribute/ref.xsd deleted file mode 100644 index f6c3c10..0000000 --- a/tests/schema/attribute/ref.xsd +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/schema/cardinality/test.xsd b/tests/schema/cardinality/test.xsd deleted file mode 100644 index b27f923..0000000 --- a/tests/schema/cardinality/test.xsd +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/schema/chameleon/includer.xsd b/tests/schema/chameleon/includer.xsd deleted file mode 100644 index c93ea18..0000000 --- a/tests/schema/chameleon/includer.xsd +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - diff --git a/tests/schema/chameleon/schemas/includee.xsd b/tests/schema/chameleon/schemas/includee.xsd deleted file mode 100644 index d89b9c4..0000000 --- a/tests/schema/chameleon/schemas/includee.xsd +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - diff --git a/tests/schema/enumeration/test.xsd b/tests/schema/enumeration/test.xsd deleted file mode 100644 index b8253d9..0000000 --- a/tests/schema/enumeration/test.xsd +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/schema/forward/test.xsd b/tests/schema/forward/test.xsd deleted file mode 100644 index c7cc24e..0000000 --- a/tests/schema/forward/test.xsd +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/schema/group/global.xsd b/tests/schema/group/global.xsd deleted file mode 100644 index 27ccadf..0000000 --- a/tests/schema/group/global.xsd +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/schema/group/test.xsd b/tests/schema/group/test.xsd deleted file mode 100644 index 7527cbb..0000000 --- a/tests/schema/group/test.xsd +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/schema/import/importer.xsd b/tests/schema/import/importer.xsd deleted file mode 100644 index 82fc33c..0000000 --- a/tests/schema/import/importer.xsd +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/tests/schema/import/schemas/importee.xsd b/tests/schema/import/schemas/importee.xsd deleted file mode 100644 index 9b03315..0000000 --- a/tests/schema/import/schemas/importee.xsd +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - diff --git a/tests/schema/include/includer.xsd b/tests/schema/include/includer.xsd deleted file mode 100644 index c93ea18..0000000 --- a/tests/schema/include/includer.xsd +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - diff --git a/tests/schema/include/schemas/includee.xsd b/tests/schema/include/schemas/includee.xsd deleted file mode 100644 index 0a928f5..0000000 --- a/tests/schema/include/schemas/includee.xsd +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - diff --git a/tests/schema/inheritance/cycle.xsd b/tests/schema/inheritance/cycle.xsd deleted file mode 100644 index c705311..0000000 --- a/tests/schema/inheritance/cycle.xsd +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/schema/inheritance/sourced-forward/includee.xsd b/tests/schema/inheritance/sourced-forward/includee.xsd deleted file mode 100644 index 531027d..0000000 --- a/tests/schema/inheritance/sourced-forward/includee.xsd +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - diff --git a/tests/schema/inheritance/sourced-forward/includer.xsd b/tests/schema/inheritance/sourced-forward/includer.xsd deleted file mode 100644 index 7d18efc..0000000 --- a/tests/schema/inheritance/sourced-forward/includer.xsd +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - diff --git a/tests/schema/list/anonymous/test.xsd b/tests/schema/list/anonymous/test.xsd deleted file mode 100644 index 7db39ba..0000000 --- a/tests/schema/list/anonymous/test.xsd +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - diff --git a/tests/schema/list/any-simple-type/test.xsd b/tests/schema/list/any-simple-type/test.xsd deleted file mode 100644 index 29fe95c..0000000 --- a/tests/schema/list/any-simple-type/test.xsd +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/tests/schema/list/driver.cxx b/tests/schema/list/driver.cxx deleted file mode 100644 index 7bd46e9..0000000 --- a/tests/schema/list/driver.cxx +++ /dev/null @@ -1,13 +0,0 @@ -#include "test.hxx" - -typedef xmlns::test::IntList IntListImpl; -typedef xmlns::test::IntList IntListVoidImpl; -typedef xmlns::test::IntComplex IntComplexImpl; - -int -main () -{ - IntListImpl int_list_impl; - IntListVoidImpl int_list_void_impl; - IntComplexImpl int_complex_impl; -} diff --git a/tests/schema/list/test.xsd b/tests/schema/list/test.xsd deleted file mode 100644 index e16a58d..0000000 --- a/tests/schema/list/test.xsd +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/schema/no-namespace/test.xsd b/tests/schema/no-namespace/test.xsd deleted file mode 100644 index b426e8a..0000000 --- a/tests/schema/no-namespace/test.xsd +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - diff --git a/tests/schema/recursive/test.xsd b/tests/schema/recursive/test.xsd deleted file mode 100644 index 6efc7d2..0000000 --- a/tests/schema/recursive/test.xsd +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/schema/ref-type/idref.xsd b/tests/schema/ref-type/idref.xsd deleted file mode 100644 index 49ebe40..0000000 --- a/tests/schema/ref-type/idref.xsd +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/schema/ref-type/idrefs.xsd b/tests/schema/ref-type/idrefs.xsd deleted file mode 100644 index b68ed03..0000000 --- a/tests/schema/ref-type/idrefs.xsd +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/schema/ref-type/invalid-0.xsd b/tests/schema/ref-type/invalid-0.xsd deleted file mode 100644 index 7ce82ed..0000000 --- a/tests/schema/ref-type/invalid-0.xsd +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - diff --git a/tests/schema/ref-type/invalid-1.xsd b/tests/schema/ref-type/invalid-1.xsd deleted file mode 100644 index d989065..0000000 --- a/tests/schema/ref-type/invalid-1.xsd +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - diff --git a/tests/schema/restriction/test.xsd b/tests/schema/restriction/test.xsd deleted file mode 100644 index 331ba78..0000000 --- a/tests/schema/restriction/test.xsd +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/schema/union/test.xsd b/tests/schema/union/test.xsd deleted file mode 100644 index 706f6f2..0000000 --- a/tests/schema/union/test.xsd +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/version b/version deleted file mode 100644 index 672ac56..0000000 --- a/version +++ /dev/null @@ -1 +0,0 @@ -4.1.0.a11 diff --git a/xsd-examples/.gitignore b/xsd-examples/.gitignore new file mode 100644 index 0000000..d87c74c --- /dev/null +++ b/xsd-examples/.gitignore @@ -0,0 +1,32 @@ +# Compiler/linker output. +# +*.d +*.t +*.i +*.ii +*.o +*.obj +*.so +*.dll +*.a +*.lib +*.exp +*.pdb +*.ilk +*.exe +*.exe.dlls/ +*.exe.manifest +*.pc + +# Test executables. +# +driver + +# XSD-generated files. +# +test.?xx + +# Testscript output directories (can be symlinks). +# +test +test-driver diff --git a/xsd-examples/README b/xsd-examples/README new file mode 100644 index 0000000..023334d --- /dev/null +++ b/xsd-examples/README @@ -0,0 +1,21 @@ +This package contains a number of examples that show how to use XSD, the +XML Schema to C++ data binding compiler and the generated C++ Tree and +Parser classes. See the README files in example directories for more +information on each example. + +The package source code is in the public domain. + +The project page is at https://www.codesynthesis.com/projects/xsd/. + +The easiest way to build this package is with the bpkg package manager: + +$ mkdir xsd-examples/ +$ cd xsd-examples/ +$ bpkg create cc +$ bpkg build xsd-examples@https://pkg.cppget.org/1/stable + +But if you don't want to use the package manager, then you can also build it +manually using the standard build2 build system. + +Send bug reports or any other feedback to the xsd-users@codesynthesis.com +mailing list. diff --git a/xsd-examples/UNLICENSE b/xsd-examples/UNLICENSE new file mode 100644 index 0000000..68a49da --- /dev/null +++ b/xsd-examples/UNLICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/xsd-examples/build/.gitignore b/xsd-examples/build/.gitignore new file mode 100644 index 0000000..4a730a3 --- /dev/null +++ b/xsd-examples/build/.gitignore @@ -0,0 +1,3 @@ +config.build +root/ +bootstrap/ diff --git a/xsd-examples/build/bootstrap.build b/xsd-examples/build/bootstrap.build new file mode 100644 index 0000000..d98c460 --- /dev/null +++ b/xsd-examples/build/bootstrap.build @@ -0,0 +1,9 @@ +# file : build/bootstrap.build +# license : not copyrighted - public domain + +project = xsd-examples + +using version +using config +using dist +using test diff --git a/xsd-examples/build/root.build b/xsd-examples/build/root.build new file mode 100644 index 0000000..5d7a5b4 --- /dev/null +++ b/xsd-examples/build/root.build @@ -0,0 +1,38 @@ +# file : build/root.build +# license : not copyrighted - public domain + +define xsd: file +xsd{*}: extension = xsd + +define xml: file +xml{*}: extension = xml + +define map: file +map{*}: extension = map + +cxx.std = latest + +using cxx + +hxx{*}: extension = hxx +ixx{*}: extension = ixx +txx{*}: extension = txx +cxx{*}: extension = cxx + +if ($cxx.target.system == 'win32-msvc') + cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + +if ($cxx.class == 'msvc') + cxx.coptions += /wd4251 /wd4275 /wd4800 + +# Setup the xsd that we are using. +# +import xsd = xsd%exe{xsd} + +# Every exe{} in this project is by default a test. +# +exe{*}: test = true + +# Specify the test target for cross-testing. +# +test.target = $cxx.target diff --git a/xsd-examples/buildfile b/xsd-examples/buildfile new file mode 100644 index 0000000..3f8fb1b --- /dev/null +++ b/xsd-examples/buildfile @@ -0,0 +1,4 @@ +# file : buildfile +# license : not copyrighted - public domain + +./: {*/ -build/} doc{README} legal{UNLICENSE} manifest diff --git a/xsd-examples/cxx/parser/.gitignore b/xsd-examples/cxx/parser/.gitignore new file mode 100644 index 0000000..5a7b950 --- /dev/null +++ b/xsd-examples/cxx/parser/.gitignore @@ -0,0 +1 @@ +*-pskel.?xx diff --git a/xsd-examples/cxx/parser/README b/xsd-examples/cxx/parser/README new file mode 100644 index 0000000..01906c7 --- /dev/null +++ b/xsd-examples/cxx/parser/README @@ -0,0 +1,45 @@ +This directory contains a number of examples that show how to use +the C++/Parser mapping. The following list gives an overview of +each example. See the README files in example directories for +more information on each example. + +hello + A simple "Hello, world!" example that shows how to parse XML + documents. + +generated + Shows how to use the sample implementation and test driver + generation feature. This example does not have any hand-written + C++ code; everything is generated by the XSD compiler. + +library + Shows how to handle more complex data structures and construct + a custom in-memory object model. + +mixin + Shows how to reuse implementations of base parsers in derived + parsers using the mixin C++ idiom. + +wildcard + Shows how to parse the XML data matched by XML Schema wildcards + (any and anyAttribute). + +multiroot + Shows how to handle XML vocabularies with multiple root elements. + +polymorphism + Shows how to use XML Schema polymorphism features such as the + xsi:type attribute and substitution groups. + +polyroot + Shows how to handle the xsi:type attribute when it is used on root + elements. + +performance + Measures the performance of XML parsing. This example also shows how + to structure your code to achieve the maximum performance for this + operation. + +mixed + Shows how to handle raw, "type-less content" such as mixed content + models, anyType/anySimpleType, and any/anyAttribute. \ No newline at end of file diff --git a/xsd-examples/cxx/parser/buildfile b/xsd-examples/cxx/parser/buildfile new file mode 100644 index 0000000..fbbd35c --- /dev/null +++ b/xsd-examples/cxx/parser/buildfile @@ -0,0 +1,4 @@ +# file : cxx/parser/buildfile +# license : not copyrighted - public domain + +./: */ doc{README} diff --git a/xsd-examples/cxx/parser/generated/.gitignore b/xsd-examples/cxx/parser/generated/.gitignore new file mode 100644 index 0000000..a67418e --- /dev/null +++ b/xsd-examples/cxx/parser/generated/.gitignore @@ -0,0 +1,2 @@ +library-pimpl.?xx +library-driver.?xx diff --git a/xsd-examples/cxx/parser/generated/README b/xsd-examples/cxx/parser/generated/README new file mode 100644 index 0000000..ca56974 --- /dev/null +++ b/xsd-examples/cxx/parser/generated/README @@ -0,0 +1,32 @@ +This example shows how to use the sample implementation and test +driver generation feature of the C++/Parser mapping. This example +does not have any hand-written C++ code; everything is generated +by the XSD compiler. + +The example consists of the following files: + +library.xsd + XML Schema which describes a library of books. + +library.xml + Sample XML instance document. + +library-pskel.hxx +library-pskel.cxx + Parser skeletons generated by XSD from library.xsd. + +library-pimpl.hxx +library-pimpl.cxx + Sample parser implementations that print the XML data to STDOUT. + These are generated by XSD from library.xsd with the + --generate-print-impl option. + +library-driver.cxx + Sample driver for the example. It is generated by XSD from + library.xsd with the --generate-test-driver option. + + +To run the example on the sample XML instance document simply +execute: + +$ ./library-driver library.xml diff --git a/xsd-examples/cxx/parser/generated/buildfile b/xsd-examples/cxx/parser/generated/buildfile new file mode 100644 index 0000000..5e4adac --- /dev/null +++ b/xsd-examples/cxx/parser/generated/buildfile @@ -0,0 +1,32 @@ +# file : cxx/parser/generated/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx ixx cxx}{library-pskel} \ + {hxx cxx}{library-pimpl} \ + { cxx}{library-driver} \ + $libs + +exe{driver}: xml{library}: test.input = true + +<{hxx ixx cxx}{library-pskel} \ + {hxx cxx}{library-pimpl} \ + { cxx}{library-driver}>: xsd{library} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --generate-print-impl \ + --generate-test-driver \ + --force-overwrite \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-examples/cxx/parser/generated/library.xml b/xsd-examples/cxx/parser/generated/library.xml new file mode 100644 index 0000000..1c84b9b --- /dev/null +++ b/xsd-examples/cxx/parser/generated/library.xml @@ -0,0 +1,52 @@ + + + + + + + + 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/xsd-examples/cxx/parser/generated/library.xsd b/xsd-examples/cxx/parser/generated/library.xsd new file mode 100644 index 0000000..4d64a48 --- /dev/null +++ b/xsd-examples/cxx/parser/generated/library.xsd @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/parser/hello/README b/xsd-examples/cxx/parser/hello/README new file mode 100644 index 0000000..97449de --- /dev/null +++ b/xsd-examples/cxx/parser/hello/README @@ -0,0 +1,28 @@ +This is a "Hello, world!" example that shows how to use the +C++/Parser mapping to parse XML instance documents. + +The example consists of the following files: + +hello.xsd + XML Schema which describes "hello" instance documents. + +hello.xml + Sample XML instance document. + +hello-pskel.hxx +hello-pskel.cxx + Parser skeletons generated by XSD from hello.xsd. + +driver.cxx + A parser implementation and a driver for the example. The + parser implementation simply prints the data to STDERR. + The driver first constructs a parser instance from the + parser implementation mentioned above and a couple of + predefined parsers for the XML Schema built-in types. + In then invokes this parser instance to parse the input + file. + +To run the example on the sample XML instance document simply +execute: + +$ ./driver hello.xml diff --git a/xsd-examples/cxx/parser/hello/buildfile b/xsd-examples/cxx/parser/hello/buildfile new file mode 100644 index 0000000..2df4a7f --- /dev/null +++ b/xsd-examples/cxx/parser/hello/buildfile @@ -0,0 +1,24 @@ +# file : cxx/parser/hello/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -hello-pskel} {hxx ixx cxx}{hello-pskel} $libs + +exe{driver}: xml{hello}: test.input = true + +<{hxx ixx cxx}{hello-pskel}>: xsd{hello} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-examples/cxx/parser/hello/driver.cxx b/xsd-examples/cxx/parser/hello/driver.cxx new file mode 100644 index 0000000..024d2fc --- /dev/null +++ b/xsd-examples/cxx/parser/hello/driver.cxx @@ -0,0 +1,67 @@ +// file : cxx/parser/hello/driver.cxx +// copyright : not copyrighted - public domain + +#include +#include + +#include "hello-pskel.hxx" + +using namespace std; + +struct hello_pimpl: hello_pskel +{ + virtual void + greeting (const string& greeting) + { + greeting_ = greeting; + } + + virtual void + name (const string& name) + { + cout << greeting_ << ", " << name << "!" << endl; + } + +private: + string greeting_; +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " hello.xml" << endl; + return 1; + } + + try + { + // Construct the parser. + // + xml_schema::string_pimpl string_p; + hello_pimpl hello_p; + + hello_p.greeting_parser (string_p); + hello_p.name_parser (string_p); + + // Parse the XML instance document. The second argument to the + // document's constructor is the document's root element name. + // + xml_schema::document doc_p (hello_p, "hello"); + + hello_p.pre (); + doc_p.parse (argv[1]); + hello_p.post_hello (); + } + 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/xsd-examples/cxx/parser/hello/hello.xml b/xsd-examples/cxx/parser/hello/hello.xml new file mode 100644 index 0000000..1f5adad --- /dev/null +++ b/xsd-examples/cxx/parser/hello/hello.xml @@ -0,0 +1,19 @@ + + + + + + + Hello + + sun + moon + world + + diff --git a/xsd-examples/cxx/parser/hello/hello.xsd b/xsd-examples/cxx/parser/hello/hello.xsd new file mode 100644 index 0000000..81907d6 --- /dev/null +++ b/xsd-examples/cxx/parser/hello/hello.xsd @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/parser/library/README b/xsd-examples/cxx/parser/library/README new file mode 100644 index 0000000..3f515f6 --- /dev/null +++ b/xsd-examples/cxx/parser/library/README @@ -0,0 +1,44 @@ +This example shows how to use the C++/Parser mapping to construct +a custom in-memory object model from XML instance documents. + +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 + Types that describe a library of books in C++. These are + hand-written. + +library.map + Type map. It maps XML Schema types defined in library.xsd + to the C++ types defined in library.hxx. + +library-pskel.hxx +library-pskel.ixx +library-pskel.cxx + Parser skeletons generated by XSD from library.xsd and + library.map. + +library-pimpl.hxx +library-pimpl.cxx + Parser implementations that construct the custom in-memory + object model from an XML instance using the types from + library.hxx. These are hand-written implementations of + the parser skeletons defined in library-pskel.hxx. + +driver.cxx + Driver for the example. It first constructs a parser + instance from all the individual parsers found in + library-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 + in-memory object model to STDERR. + +To run the example on the sample XML instance document simply +execute: + +$ ./driver library.xml diff --git a/xsd-examples/cxx/parser/library/buildfile b/xsd-examples/cxx/parser/library/buildfile new file mode 100644 index 0000000..40810b3 --- /dev/null +++ b/xsd-examples/cxx/parser/library/buildfile @@ -0,0 +1,25 @@ +# file : cxx/parser/library/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -library-pskel} {hxx ixx cxx}{library-pskel} $libs + +exe{driver}: xml{library}: test.input = true + +<{hxx ixx cxx}{library-pskel}>: xsd{library} map{library} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --type-map $path($<[1]) \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/xsd-examples/cxx/parser/library/driver.cxx b/xsd-examples/cxx/parser/library/driver.cxx new file mode 100644 index 0000000..d718e53 --- /dev/null +++ b/xsd-examples/cxx/parser/library/driver.cxx @@ -0,0 +1,109 @@ +// file : cxx/parser/library/driver.cxx +// copyright : not copyrighted - public domain + +#include + +#include "library.hxx" +#include "library-pimpl.hxx" + +using std::cerr; +using std::endl; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " library.xml" << endl; + return 1; + } + + try + { + using namespace library; + + + // Construct the parser. + // + xml_schema::id_pimpl id_p; + xml_schema::idref_pimpl idref_p; + xml_schema::string_pimpl string_p; + xml_schema::boolean_pimpl boolean_p; + + isbn_pimpl isbn_p; + + title_pimpl title_p; + title_p.lang_parser (string_p); + + genre_pimpl genre_p; + + author_pimpl author_p; + author_p.parsers (string_p, // name + string_p, // born + string_p, // died + idref_p); // recommends + + book_pimpl book_p; + book_p.parsers (isbn_p, // isbn + title_p, // title + genre_p, // genre + author_p, // author + boolean_p, // available + id_p); // id + + catalog_pimpl catalog_p; + catalog_p.book_parser (book_p); + + + // Parse the XML instance document. + // + xml_schema::document doc_p ( + catalog_p, + "http://www.codesynthesis.com/library", // root element namespace + "catalog"); // root element name + + catalog_p.pre (); + doc_p.parse (argv[1]); + catalog c (catalog_p.post_catalog ()); + + + // Let's print what we've got. + // + for (catalog::const_iterator bi (c.begin ()); bi != c.end (); ++bi) + { + cerr << endl + << "ID : " << bi->id () << endl + << "ISBN : " << bi->isbn () << endl + << "Title : " << bi->title () << endl + << "Genre : " << bi->genre () << endl; + + for (book::authors::const_iterator ai (bi->author ().begin ()); + ai != bi->author ().end (); + ++ai) + { + cerr << "Author : " << ai->name () << endl; + cerr << " Born : " << ai->born () << endl; + + if (!ai->died ().empty ()) + cerr << " Died : " << ai->died () << endl; + + if (!ai->recommends ().empty ()) + { + cerr << " Recommends : " << ai->recommends () << endl; + } + } + + cerr << "Available : " << std::boolalpha << bi->available () << 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/xsd-examples/cxx/parser/library/library-pimpl.cxx b/xsd-examples/cxx/parser/library/library-pimpl.cxx new file mode 100644 index 0000000..852b90d --- /dev/null +++ b/xsd-examples/cxx/parser/library/library-pimpl.cxx @@ -0,0 +1,183 @@ +// file : cxx/parser/library/library-pimpl.cxx +// copyright : not copyrighted - public domain + +#include "library-pimpl.hxx" + +namespace library +{ + // isbn_impl + // + isbn isbn_pimpl:: + post_isbn () + { + return post_unsigned_int (); + } + + // title_pimpl + // + void title_pimpl:: + _pre () + { + title_.lang (""); + } + + void title_pimpl:: + lang (const std::string& lang) + { + title_.lang (lang); + } + + title title_pimpl:: + post_title () + { + title_.assign (post_string ()); + return title_; + } + + // genre_pimpl + // + genre genre_pimpl:: + post_genre () + { + genre r (romance); + std::string v (post_string ()); + + if (v == "romance") r = romance; else + if (v == "fiction") r = fiction; else + if (v == "horror") r = horror; else + if (v == "history") r = history; else + if (v == "philosophy") r = philosophy; + + return r; + } + + // person_pimpl + // + void person_pimpl:: + _pre () + { + person_.died (""); + } + + void person_pimpl:: + name (const std::string& name) + { + person_.name (name); + } + + void person_pimpl:: + born (const std::string& born) + { + person_.born (born); + } + + void person_pimpl:: + died (const std::string& died) + { + person_.died (died); + } + + person person_pimpl:: + post_person () + { + return person_; + } + + // author_pimpl + // + void author_pimpl:: + _pre () + { + person_pimpl::_pre (); + author_.recommends (""); + } + + void author_pimpl:: + recommends (const std::string& recommends) + { + author_.recommends (recommends); + } + + author author_pimpl:: + post_author () + { + person p (post_person ()); + + author_.name (p.name ()); + author_.born (p.born ()); + author_.died (p.died ()); + + return author_; + } + + // book_pimpl + // + void book_pimpl:: + _pre () + { + book_.author ().clear (); + } + + void book_pimpl:: + isbn (library::isbn isbn) + { + book_.isbn (isbn); + } + + void book_pimpl:: + title (const library::title& title) + { + book_.title (title); + } + + void book_pimpl:: + genre (library::genre genre) + { + book_.genre (genre); + } + + void book_pimpl:: + author (const library::author& author) + { + book_.author ().push_back (author); + } + + void book_pimpl:: + available (bool available) + { + book_.available (available); + } + + void book_pimpl:: + id (const std::string& id) + { + book_.id (id); + } + + book book_pimpl:: + post_book () + { + return book_; + } + + // catalog_pimpl + // + void catalog_pimpl:: + _pre () + { + catalog_.clear (); + } + + void catalog_pimpl:: + book (const library::book& book) + { + catalog_.push_back (book); + } + + catalog catalog_pimpl:: + post_catalog () + { + return catalog_; + } +} + diff --git a/xsd-examples/cxx/parser/library/library-pimpl.hxx b/xsd-examples/cxx/parser/library/library-pimpl.hxx new file mode 100644 index 0000000..fb8ba24 --- /dev/null +++ b/xsd-examples/cxx/parser/library/library-pimpl.hxx @@ -0,0 +1,135 @@ +// file : cxx/parser/library/library-pimpl.hxx +// copyright : not copyrighted - public domain + +#ifndef LIBRARY_PIMPL_HXX +#define LIBRARY_PIMPL_HXX + +#include "library.hxx" +#include "library-pskel.hxx" + +namespace library +{ + // + // + struct isbn_pimpl: isbn_pskel, xml_schema::unsigned_int_pimpl + { + virtual isbn + post_isbn (); + }; + + // + // + struct title_pimpl: title_pskel, xml_schema::string_pimpl + { + virtual void + _pre (); + + virtual void + lang (const std::string&); + + virtual title + post_title (); + + private: + title title_; + }; + + // + // + struct genre_pimpl: genre_pskel, xml_schema::string_pimpl + { + virtual genre + post_genre (); + }; + + // + // + struct person_pimpl: virtual person_pskel + { + virtual void + _pre (); + + virtual void + name (const std::string&); + + virtual void + born (const std::string&); + + virtual void + died (const std::string&); + + virtual person + post_person (); + + private: + person person_; + }; + + // + // + struct author_pimpl: author_pskel, person_pimpl + { + virtual void + _pre (); + + virtual void + recommends (const std::string&); + + virtual author + post_author (); + + private: + author author_; + }; + + // + // + struct book_pimpl: book_pskel + { + virtual void + _pre (); + + virtual void + isbn (library::isbn); + + virtual void + title (const library::title&); + + virtual void + genre (library::genre); + + virtual void + author (const library::author&); + + virtual void + available (bool); + + virtual void + id (const std::string&); + + virtual book + post_book (); + + private: + book book_; + }; + + // + // + struct catalog_pimpl: catalog_pskel + { + virtual void + _pre (); + + virtual void + book (const library::book&); + + virtual catalog + post_catalog (); + + private: + catalog catalog_; + }; +} + +#endif // LIBRARY_PIMPL_HXX diff --git a/xsd-examples/cxx/parser/library/library.hxx b/xsd-examples/cxx/parser/library/library.hxx new file mode 100644 index 0000000..844e474 --- /dev/null +++ b/xsd-examples/cxx/parser/library/library.hxx @@ -0,0 +1,241 @@ +// file : cxx/parser/library/library.hxx +// copyright : not copyrighted - public domain + +#ifndef LIBRARY_HXX +#define LIBRARY_HXX + +#include +#include + +namespace library +{ + // + // + typedef unsigned int isbn; + + + // + // + struct title: std::string + { + // lang + // + const std::string& + lang () const + { + return lang_; + } + + void + lang (const std::string& lang) + { + lang_ = lang; + } + + private: + std::string lang_; + }; + + + // + // + enum genre + { + romance, + fiction, + horror, + history, + philosophy + }; + + + // + // + struct person + { + // name + // + const std::string& + name () const + { + return name_; + } + + void + name (const std::string& name) + { + name_ = name; + } + + // born + // + const std::string& + born () const + { + return born_; + } + + void + born (const std::string& born) + { + born_ = born; + } + + + // died + // + const std::string& + died () const + { + return died_; + } + + void + died (const std::string& died) + { + died_ = died; + } + + private: + std::string name_; + std::string born_; + std::string died_; + }; + + + // + // + struct author: person + { + // recommends + // + const std::string& + recommends () const + { + return recommends_; + } + + void + recommends (const std::string& recommends) + { + recommends_ = recommends; + } + + private: + std::string recommends_; + }; + + + // + // + struct book + { + // isbn + // + library::isbn + isbn () const + { + return isbn_; + } + + void + isbn (const library::isbn& isbn) + { + isbn_ = isbn; + } + + + // title + // + library::title + title () const + { + return title_; + } + + void + title (const library::title& title) + { + title_ = title; + } + + + // genre + // + library::genre + genre () const + { + return genre_; + } + + void + genre (const library::genre& genre) + { + genre_ = genre; + } + + + // author + // + typedef std::vector authors; + + const authors& + author () const + { + return author_; + } + + authors& + author () + { + return author_; + } + + + // available + // + bool + available () const + { + return available_; + } + + void + available (bool available) + { + available_ = available; + } + + + // id + // + const std::string& + id () const + { + return id_; + } + + void + id (const std::string& id) + { + id_ = id; + } + + private: + library::isbn isbn_; + library::title title_; + library::genre genre_; + + authors author_; + + bool available_; + std::string id_; + }; + + + // + // + typedef std::vector catalog; +} + +#endif // LIBRARY_HXX diff --git a/xsd-examples/cxx/parser/library/library.map b/xsd-examples/cxx/parser/library/library.map new file mode 100644 index 0000000..4bca410 --- /dev/null +++ b/xsd-examples/cxx/parser/library/library.map @@ -0,0 +1,15 @@ +# file : cxx/parser/library/library.map +# copyright : not copyrighted - public domain + +namespace http://www.codesynthesis.com/library ::library +{ + include "library.hxx"; + + isbn isbn isbn; + title title; + genre genre genre; + person person; + author author; + book book; + catalog catalog; +} diff --git a/xsd-examples/cxx/parser/library/library.xml b/xsd-examples/cxx/parser/library/library.xml new file mode 100644 index 0000000..1c84b9b --- /dev/null +++ b/xsd-examples/cxx/parser/library/library.xml @@ -0,0 +1,52 @@ + + + + + + + + 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/xsd-examples/cxx/parser/library/library.xsd b/xsd-examples/cxx/parser/library/library.xsd new file mode 100644 index 0000000..4d64a48 --- /dev/null +++ b/xsd-examples/cxx/parser/library/library.xsd @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/parser/mixed/README b/xsd-examples/cxx/parser/mixed/README new file mode 100644 index 0000000..23ace6f --- /dev/null +++ b/xsd-examples/cxx/parser/mixed/README @@ -0,0 +1,49 @@ +This example shows how to handle raw, "type-less content" such as +mixed content models, anyType/anySimpleType, and any/anyAttribute +in the C++/Parser mapping. + +In this example we use mixed content model to describe text +with embedded links, e.g., + + This paragraph talks about time. + +The example transforms such text into plain text with +references, e.g., + + This paragraph talks about time[0]. + + [0] uri + +The example consists of the following files: + +text.xsd + XML Schema which describes "text with links" instance + documents. + +text.xml + Sample XML instance document. + +anchor.hxx + Anchor type that captures the information about a link. + +text.map + Type map. It maps XML Schema anchor types defined in + text.xsd to C++ anchor class defined in anchor.hxx. + +text-pskel.hxx +text-pskel.cxx + Parser skeletons generated by XSD from text.xsd and + text.map. + +driver.cxx + A parser implementation and a driver for the example. The + parser implementation prints the transformed text to STDOUT. + The driver first constructs a parser instance from the parser + implementation mentioned above and a couple of predefined + parsers for the XML Schema built-in types. In then invokes + this parser instance to parse the input file. + +To run the example on the sample XML instance document simply +execute: + +$ ./driver text.xml diff --git a/xsd-examples/cxx/parser/mixed/anchor.hxx b/xsd-examples/cxx/parser/mixed/anchor.hxx new file mode 100644 index 0000000..6cc6cd4 --- /dev/null +++ b/xsd-examples/cxx/parser/mixed/anchor.hxx @@ -0,0 +1,33 @@ +// file : cxx/parser/mixed/anchor.hxx +// copyright : not copyrighted - public domain + +#ifndef ANCHOR_HXX +#define ANCHOR_HXX + +#include + +struct anchor +{ + anchor (const std::string& text, const std::string& uri) + : uri_ (uri), text_ (text) + { + } + + const std::string& + text () const + { + return text_; + } + + const std::string& + uri () const + { + return uri_; + } + +private: + std::string uri_; + std::string text_; +}; + +#endif // ANCHOR_HXX diff --git a/xsd-examples/cxx/parser/mixed/buildfile b/xsd-examples/cxx/parser/mixed/buildfile new file mode 100644 index 0000000..0079444 --- /dev/null +++ b/xsd-examples/cxx/parser/mixed/buildfile @@ -0,0 +1,25 @@ +# file : cxx/parser/mixed/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -text-pskel} {hxx ixx cxx}{text-pskel} $libs + +exe{driver}: xml{text}: test.input = true + +<{hxx ixx cxx}{text-pskel}>: xsd{text} map{text} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --type-map $path($<[1]) \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/xsd-examples/cxx/parser/mixed/driver.cxx b/xsd-examples/cxx/parser/mixed/driver.cxx new file mode 100644 index 0000000..c00bfd7 --- /dev/null +++ b/xsd-examples/cxx/parser/mixed/driver.cxx @@ -0,0 +1,100 @@ +// file : cxx/parser/mixed/driver.cxx +// copyright : not copyrighted - public domain + +#include +#include +#include + +#include "anchor.hxx" +#include "text-pskel.hxx" + +using namespace std; + +struct anchor_pimpl: anchor_pskel, xml_schema::string_pimpl +{ + virtual void + href (const std::string& uri) + { + uri_ = uri; + } + + virtual anchor + post_anchor () + { + return anchor (post_string (), uri_); + } + +private: + std::string uri_; +}; + + +struct text_pimpl: text_pskel +{ + virtual void + a (const anchor& a) + { + cout << a.text () << "[" << anchors_.size () << "]"; + anchors_.push_back (a); + } + + virtual void + _any_characters (const xml_schema::ro_string& s) + { + cout << s; + } + + virtual void + post_text () + { + for (anchors::const_iterator i (anchors_.begin ()); + i != anchors_.end (); + ++i) + { + cout << "[" << i - anchors_.begin () << "] " << i->uri () << endl; + } + } + +private: + typedef vector anchors; + anchors anchors_; +}; + + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " text.xml" << endl; + return 1; + } + + try + { + // Construct the parser. + // + xml_schema::string_pimpl string_p; + anchor_pimpl anchor_p; + text_pimpl text_p; + + anchor_p.href_parser (string_p); + text_p.a_parser (anchor_p); + + xml_schema::document doc_p (text_p, "text"); + + text_p.pre (); + doc_p.parse (argv[1]); + text_p.post_text (); + } + 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/xsd-examples/cxx/parser/mixed/text.map b/xsd-examples/cxx/parser/mixed/text.map new file mode 100644 index 0000000..0daa79b --- /dev/null +++ b/xsd-examples/cxx/parser/mixed/text.map @@ -0,0 +1,6 @@ +# file : cxx/parser/mixed/text.map +# copyright : not copyrighted - public domain + +include "anchor.hxx"; + +anchor ::anchor; diff --git a/xsd-examples/cxx/parser/mixed/text.xml b/xsd-examples/cxx/parser/mixed/text.xml new file mode 100644 index 0000000..1ce4eec --- /dev/null +++ b/xsd-examples/cxx/parser/mixed/text.xml @@ -0,0 +1,17 @@ + + + + + + +The first paragraph of this text talks about time. + +And this paragraph talks about space. + + diff --git a/xsd-examples/cxx/parser/mixed/text.xsd b/xsd-examples/cxx/parser/mixed/text.xsd new file mode 100644 index 0000000..e9d6e39 --- /dev/null +++ b/xsd-examples/cxx/parser/mixed/text.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/parser/mixin/README b/xsd-examples/cxx/parser/mixin/README new file mode 100644 index 0000000..343e379 --- /dev/null +++ b/xsd-examples/cxx/parser/mixin/README @@ -0,0 +1,34 @@ +This example shows how to reuse implementations of base parsers +in derived parsers using the mixin C++ idiom. + +The example consists of the following files: + +schema.xsd + XML Schema which defined two data types: base and + derived. + +instance.xml + Sample XML instance document. + +types.hxx + C++ classes that correspond to the base and derived + types in schema.xsd. + +schema.map + Type map. It maps XML Schema types defined in schema.xsd + to C++ types defined in types.hxx. + +schema-pskel.hxx +schema-pskel.cxx + Parser skeletons generated by XSD from schema.xsd and + schema.map. + +driver.cxx + Parser implementations and a driver for the example. It + shows how to mix the implementation of the base parser + into the derived parser. + +To run the example on the sample XML instance document simply +execute: + +$ ./driver instance.xml diff --git a/xsd-examples/cxx/parser/mixin/buildfile b/xsd-examples/cxx/parser/mixin/buildfile new file mode 100644 index 0000000..4d4d751 --- /dev/null +++ b/xsd-examples/cxx/parser/mixin/buildfile @@ -0,0 +1,25 @@ +# file : cxx/parser/mixin/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -schema-pskel} {hxx ixx cxx}{schema-pskel} $libs + +exe{driver}: xml{instance}: test.input = true + +<{hxx ixx cxx}{schema-pskel}>: xsd{schema} map{schema} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --type-map $path($<[1]) \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/xsd-examples/cxx/parser/mixin/driver.cxx b/xsd-examples/cxx/parser/mixin/driver.cxx new file mode 100644 index 0000000..7a5ac94 --- /dev/null +++ b/xsd-examples/cxx/parser/mixin/driver.cxx @@ -0,0 +1,103 @@ +// file : cxx/parser/mixin/driver.cxx +// copyright : not copyrighted - public domain + +#include +#include + +#include "types.hxx" +#include "schema-pskel.hxx" + +using namespace std; + +struct base_pimpl: virtual base_pskel +{ + virtual void + pre () + { + base_.reset (new ::base); + } + + virtual void + a (bool v) + { + base_->a (v); + } + + virtual base* + post_base () + { + return base_.release (); + } + +protected: + unique_ptr base_; +}; + +// Implement derived parser by mixing-in base's implementation. +// +struct derived_pimpl: derived_pskel, base_pimpl +{ + virtual void + pre () + { + // Override base's pre() with the new implementation that + // instantiates derived instead of base. + // + base_.reset (new ::derived); + } + + virtual void + b (int v) + { + // We could also store a pointer to derived in derived_impl to + // avoid casting. + // + static_cast< ::derived* > (base_.get ())->b (v); + } + + virtual derived* + post_derived () + { + return static_cast (base_.release ()); + } +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " instance.xml" << endl; + return 1; + } + + try + { + // Construct the parser. + // + xml_schema::boolean_pimpl bool_p; + xml_schema::int_pimpl int_p; + derived_pimpl derived_p; + + derived_p.parsers (bool_p, int_p); + + xml_schema::document doc_p (derived_p, "root"); + + derived_p.pre (); + doc_p.parse (argv[1]); + unique_ptr d (derived_p.post_derived ()); + + cerr << "a: " << boolalpha << d->a () << endl; + cerr << "b: " << d->b () << 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/xsd-examples/cxx/parser/mixin/instance.xml b/xsd-examples/cxx/parser/mixin/instance.xml new file mode 100644 index 0000000..90e2757 --- /dev/null +++ b/xsd-examples/cxx/parser/mixin/instance.xml @@ -0,0 +1,16 @@ + + + + + + + true + 1 + + diff --git a/xsd-examples/cxx/parser/mixin/schema.map b/xsd-examples/cxx/parser/mixin/schema.map new file mode 100644 index 0000000..a6ffa76 --- /dev/null +++ b/xsd-examples/cxx/parser/mixin/schema.map @@ -0,0 +1,7 @@ +# file : cxx/parser/mixin/schema.map +# copyright : not copyrighted - public domain + +include "types.hxx"; + +base ::base*; +derived ::derived*; diff --git a/xsd-examples/cxx/parser/mixin/schema.xsd b/xsd-examples/cxx/parser/mixin/schema.xsd new file mode 100644 index 0000000..891241e --- /dev/null +++ b/xsd-examples/cxx/parser/mixin/schema.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/parser/mixin/types.hxx b/xsd-examples/cxx/parser/mixin/types.hxx new file mode 100644 index 0000000..887b29e --- /dev/null +++ b/xsd-examples/cxx/parser/mixin/types.hxx @@ -0,0 +1,43 @@ +// file : cxx/parser/mixin/types.hxx +// copyright : not copyrighted - public domain + +#ifndef TYPES_HXX +#define TYPES_HXX + +struct base +{ + bool + a () const + { + return a_; + } + + void + a (bool v) + { + a_ = v; + } + +private: + bool a_; +}; + +struct derived: base +{ + int + b () const + { + return b_; + } + + void + b (int v) + { + b_ = v; + } + +private: + int b_; +}; + +#endif // TYPES_HXX diff --git a/xsd-examples/cxx/parser/multiroot/README b/xsd-examples/cxx/parser/multiroot/README new file mode 100644 index 0000000..041dfec --- /dev/null +++ b/xsd-examples/cxx/parser/multiroot/README @@ -0,0 +1,51 @@ +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/xsd-examples/cxx/parser/multiroot/balance.xml b/xsd-examples/cxx/parser/multiroot/balance.xml new file mode 100644 index 0000000..60a6882 --- /dev/null +++ b/xsd-examples/cxx/parser/multiroot/balance.xml @@ -0,0 +1,16 @@ + + + + + + + 123456789 + + diff --git a/xsd-examples/cxx/parser/multiroot/buildfile b/xsd-examples/cxx/parser/multiroot/buildfile new file mode 100644 index 0000000..6b0f604 --- /dev/null +++ b/xsd-examples/cxx/parser/multiroot/buildfile @@ -0,0 +1,24 @@ +# file : cxx/parser/multiroot/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} xml{balance deposit withdraw} + +exe{driver}: {hxx cxx}{* -protocol-pskel} {hxx ixx cxx}{protocol-pskel} $libs \ + testscript + +<{hxx ixx cxx}{protocol-pskel}>: xsd{protocol} map{protocol} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --type-map $path($<[1]) \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/xsd-examples/cxx/parser/multiroot/deposit.xml b/xsd-examples/cxx/parser/multiroot/deposit.xml new file mode 100644 index 0000000..3d32c59 --- /dev/null +++ b/xsd-examples/cxx/parser/multiroot/deposit.xml @@ -0,0 +1,17 @@ + + + + + + + 123456789 + 1000000 + + diff --git a/xsd-examples/cxx/parser/multiroot/driver.cxx b/xsd-examples/cxx/parser/multiroot/driver.cxx new file mode 100644 index 0000000..ea854b9 --- /dev/null +++ b/xsd-examples/cxx/parser/multiroot/driver.cxx @@ -0,0 +1,161 @@ +// file : cxx/parser/multiroot/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_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::unique_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::unique_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/xsd-examples/cxx/parser/multiroot/protocol-pimpl.cxx b/xsd-examples/cxx/parser/multiroot/protocol-pimpl.cxx new file mode 100644 index 0000000..05fbd31 --- /dev/null +++ b/xsd-examples/cxx/parser/multiroot/protocol-pimpl.cxx @@ -0,0 +1,46 @@ +// file : 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/xsd-examples/cxx/parser/multiroot/protocol-pimpl.hxx b/xsd-examples/cxx/parser/multiroot/protocol-pimpl.hxx new file mode 100644 index 0000000..1b53604 --- /dev/null +++ b/xsd-examples/cxx/parser/multiroot/protocol-pimpl.hxx @@ -0,0 +1,48 @@ +// file : 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/xsd-examples/cxx/parser/multiroot/protocol.hxx b/xsd-examples/cxx/parser/multiroot/protocol.hxx new file mode 100644 index 0000000..3c1a10a --- /dev/null +++ b/xsd-examples/cxx/parser/multiroot/protocol.hxx @@ -0,0 +1,61 @@ +// file : 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/xsd-examples/cxx/parser/multiroot/protocol.map b/xsd-examples/cxx/parser/multiroot/protocol.map new file mode 100644 index 0000000..90536ea --- /dev/null +++ b/xsd-examples/cxx/parser/multiroot/protocol.map @@ -0,0 +1,11 @@ +# file : 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/xsd-examples/cxx/parser/multiroot/protocol.xsd b/xsd-examples/cxx/parser/multiroot/protocol.xsd new file mode 100644 index 0000000..a33fed2 --- /dev/null +++ b/xsd-examples/cxx/parser/multiroot/protocol.xsd @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/parser/multiroot/testscript b/xsd-examples/cxx/parser/multiroot/testscript new file mode 100644 index 0000000..76329f7 --- /dev/null +++ b/xsd-examples/cxx/parser/multiroot/testscript @@ -0,0 +1,6 @@ +# file : cxx/parser/multiroot/testscript +# license : not copyrighted - public domain + +$* $src_base/balance.xml 2>| : balance +$* $src_base/deposit.xml 2>| : deposit +$* $src_base/withdraw.xml 2>| : withdraw diff --git a/xsd-examples/cxx/parser/multiroot/withdraw.xml b/xsd-examples/cxx/parser/multiroot/withdraw.xml new file mode 100644 index 0000000..8b2efe0 --- /dev/null +++ b/xsd-examples/cxx/parser/multiroot/withdraw.xml @@ -0,0 +1,17 @@ + + + + + + + 123456789 + 1000000 + + diff --git a/xsd-examples/cxx/parser/performance/.gitignore b/xsd-examples/cxx/parser/performance/.gitignore new file mode 100644 index 0000000..19c9761 --- /dev/null +++ b/xsd-examples/cxx/parser/performance/.gitignore @@ -0,0 +1,7 @@ +driver-expat +driver-xerces +gen + +# Testscript output directory (can be symlink). +# +test-gen diff --git a/xsd-examples/cxx/parser/performance/README b/xsd-examples/cxx/parser/performance/README new file mode 100644 index 0000000..46137d0 --- /dev/null +++ b/xsd-examples/cxx/parser/performance/README @@ -0,0 +1,46 @@ +This example measures the performance of XML parsing in the C++/Parser +mapping. It also shows how to structure your code to achieve the maximum +performance for this operation. + +The example consists of the following files: + +test.xsd + XML Schema which describes the test vocabulary. + +test-50k.xml + Test XML document. + +gen.cxx + Program to generate a test document of desired size. + +time.hxx +time.cxx + Class definition that represents time. + +test-pskel.hxx +test-pskel.ixx +test-pskel.cxx + Parser skeletons generated by the XSD compiler from test.xsd. + +driver.cxx + Driver for the example. It first parses the command line arguments + and reads the entire document into a memory buffer. It then creates + a SAX parser and pre-parses and caches the schema if validation is + enabled (Xerces-C++ only). Finally, it runs the performance + measurement loop which on each iteration parses the XML document + from the in-memory buffer. + +To run the example on a test XML document simply execute: + +$ ./driver test-50k.xml + +The -v option can be used to turn on validation in the underlying XML +parser (only makes sense for Xerces-C++, off by default). The -i option +can be used to specify the number of parsing iterations (1000 by default). +For example: + +$ ./driver -v -i 100 test-50k.xml + +To generate the test document execute, for example: + +$ ./gen 633 test-100k.xml diff --git a/xsd-examples/cxx/parser/performance/buildfile b/xsd-examples/cxx/parser/performance/buildfile new file mode 100644 index 0000000..10111d6 --- /dev/null +++ b/xsd-examples/cxx/parser/performance/buildfile @@ -0,0 +1,57 @@ +# file : cxx/parser/performance/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} + +import libxerces = libxerces-c%lib{xerces-c} +import libexpat = libexpat%lib{expat} + +./: doc{README} + +# exe{driver-{xerces,expat}} +# +for p: 'xerces' 'expat' +{ + # Make sure that obje{time} doesn't depend on the parser library that varies + # for different exe{driver-*} targets. Think of -I... options passed to the + # compiler while compiling time.cxx, which would vary depending on exe + # target time.cxx is a prerequisite of. + # + ./: exe{driver-$p}: obje{driver-$p time} \ + {hxx ixx cxx}{test-$p-pskel} \ + $libs $(lib$p) + + exe{driver-$p}: xml{test-50k}: test.input = true + + obje{driver-$p}: cxx{driver} $libs $(lib$p) + + <{hxx ixx cxx}{test-$p-pskel}>: xsd{test} $xsd + { + # Note: we can't use $p in the buildscript since it will be substituted by + # the latest $p value. + # + parser = $p + } + {{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -$parser-pskel \ + --xml-parser $parser \ + --output-dir $out_base \ + $path($<[0]) + }} +} + +obje{time}: {hxx cxx}{time} + +# exe{gen} +# +./: exe{gen}: cxx{gen} testscript{gen} + +# Build options. +# +cxx.poptions =+ "-I$out_base" "-I$src_base" + +obje{driver-xerces}: cxx.poptions += -DXERCES_PARSER diff --git a/xsd-examples/cxx/parser/performance/driver.cxx b/xsd-examples/cxx/parser/performance/driver.cxx new file mode 100644 index 0000000..4ac0265 --- /dev/null +++ b/xsd-examples/cxx/parser/performance/driver.cxx @@ -0,0 +1,346 @@ +// file : cxx/parser/performance/driver.cxx +// copyright : not copyrighted - public domain + +#include +#include // std::unique_ptr +#include // std::size_t +#include +#include +#include + +#include "time.hxx" + +#ifdef XERCES_PARSER +# include "test-xerces-pskel.hxx" + +# include +# include +# include +# include +# include +# include + +# include +# include +#else +# include "test-expat-pskel.hxx" +#endif + +// No-op parser implementation. +// +namespace test +{ + struct enum_pimpl: enum_pskel, xml_schema::string_pimpl + { + virtual void + post_enum () + { + } + }; + + struct record_pimpl: record_pskel + { + virtual void + int_ (unsigned int) + { + } + + virtual void + double_ (double) + { + } + + virtual void + name (const std::string&) + { + } + + virtual void + string (const std::string&) + { + } + + virtual void + choice1 (const std::string&) + { + } + + virtual void + choice2 (const std::string&) + { + } + + virtual void + choice3 (const std::string&) + { + } + + virtual void + choice4 (const std::string&) + { + } + + virtual void + apple (bool) + { + } + + virtual void + orange (unsigned long long) + { + } + }; + + struct root_pimpl: root_pskel + { + }; +} + +using namespace std; + +int +main (int argc, char* argv[]) +{ + if (argc < 2) + { + cerr << "usage: " << argv[0] << " [-v] [-i ] test.xml" << endl + << "\t -v turn on validation (default is off)" << endl + << "\t -i number of iterations to perform (default is 1000)" << endl; + return 1; + } + + bool validate (false); + unsigned long iter (1000); + const char* file (0); + + // Parse command line arguments. + // + for (int i (1); i < argc; ++i) + { + string arg (argv[i]); + + if (arg == "-v") + { + validate = true; + } + else if (arg == "-i") + { + if (++i == argc) + { + cerr << "argument expected for the -i option" << endl; + return 1; + } + + iter = 0; + istringstream is (argv[i]); + is >> iter; + + if (iter == 0) + { + cerr << "invalid argument for the -i option" << endl; + return 1; + } + } + else + { + file = argv[i]; + break; + } + } + + if (file == 0) + { + cerr << "no input file specified" << endl; + return 1; + } + + try + { + // Instantiate and connect parsers. + // + xml_schema::unsigned_int_pimpl unsigned_int_p; + xml_schema::double_pimpl double_p; + xml_schema::ncname_pimpl ncname_p; + xml_schema::string_pimpl string_p; + xml_schema::boolean_pimpl boolean_p; + xml_schema::unsigned_long_pimpl unsigned_long_p; + + test::enum_pimpl enum_p; + test::record_pimpl record_p; + test::root_pimpl root_p; + + record_p.parsers (unsigned_int_p, + double_p, + ncname_p, + string_p, + string_p, + string_p, + string_p, + string_p, + enum_p, + boolean_p, + unsigned_long_p); + + root_p.parsers (record_p); + + // Read the fine into in-memory buffer. + // + ifstream ifs; + ifs.exceptions (ios_base::failbit); + ifs.open (file, ios::in | ios::ate); + + size_t size (ifs.tellg ()); + ifs.seekg (0, ios::beg); + + char* buf = new char[size]; + ifs.read (buf, size); + ifs.close (); + + cerr << "document size: " << size << " bytes" << endl + << "iterations: " << iter << endl; + + os::time time (0); + xml_schema::document doc (root_p, "test", "root"); + +#ifdef _XERCES_VERSION + + // Xerces-C++ as the underlying XML parser. + // + using namespace xercesc; + + namespace xml = xsd::cxx::xml; + namespace parser = xsd::cxx::parser; + + XMLPlatformUtils::Initialize (); + + { + MemBufInputSource is ( + reinterpret_cast (buf), size, file, false); + is.setCopyBufToStream (false); + + unique_ptr parser (XMLReaderFactory::createXMLReader ()); + + parser->setFeature (XMLUni::fgSAX2CoreNameSpaces, true); + parser->setFeature (XMLUni::fgSAX2CoreNameSpacePrefixes, true); + parser->setFeature (XMLUni::fgXercesValidationErrorAsFatal, true); + + if (validate) + { + parser->setFeature (XMLUni::fgSAX2CoreValidation, true); + parser->setFeature (XMLUni::fgXercesSchema, true); + parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); + + // Xerces-C++ 3.1.0 is the first version with working multi import + // support. + // +#if _XERCES_VERSION >= 30100 + parser->setFeature (XMLUni::fgXercesHandleMultipleImports, true); +#endif + + // Initialize the schema cache. To detect schema errors we will + // need an error handler. + // + parser::error_handler eh; + xml::sax::bits::error_handler_proxy ehp (eh); + parser->setErrorHandler (&ehp); + + if (!parser->loadGrammar ("test.xsd", Grammar::SchemaGrammarType, true)) + { + // In Xerces-C++ grammar loading failure results in just a warning. + // Make it a fatal error. + // + eh.handle ("test.xsd", 0, 0, + parser::error_handler::severity::fatal, + "unable to load schema"); + } + + eh.throw_if_failed (); + parser->setFeature (XMLUni::fgXercesUseCachedGrammarInParse, true); + +#if _XERCES_VERSION >= 30100 + parser->setFeature (XMLUni::fgXercesLoadSchema, false); +#endif + } + else + { + parser->setFeature (XMLUni::fgSAX2CoreValidation, false); + parser->setFeature (XMLUni::fgXercesSchema, false); + parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); + } + + os::time start; + + for (unsigned long i (0); i < iter; ++i) + { + root_p.pre (); + doc.parse (is, *parser); + root_p.post_root (); + } + + os::time end; + time = end - start; + } + + XMLPlatformUtils::Terminate (); + +#else + + XSD_UNUSED (validate); + + // Expat as the underlying XML parser. + // + XML_Parser xml_parser (XML_ParserCreateNS (0, ' ')); + string public_id (file); + + os::time start; + + for (unsigned long i (0); i < iter; ++i) + { + // Using the low-level Expat-specific API to parse the memory + // buffer. + // + root_p.pre (); + doc.parse_begin (xml_parser, public_id); + + XML_Parse (xml_parser, buf, size, 1); + + doc.parse_end (); + root_p.post_root (); + + XML_ParserReset (xml_parser, 0); + } + + os::time end; + time = end - start; + + XML_ParserFree (xml_parser); + +#endif + + delete[] buf; + + cerr << "time: " << time << " sec" << endl; + + double ms (time.sec () * 1000000ULL + time.nsec () / 1000ULL); + + // Calculate throughput in documents/sec. + // + double tpd ((iter / ms) * 1000000); + cerr << "throughput: " << tpd << " documents/sec" << endl; + + // Calculate throughput in MBytes/sec. + // + double tpb (((size * iter) / ms) * 1000000/(1024*1024)); + cerr << "throughput: " << tpb << " MBytes/sec" << endl; + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + return 1; + } + catch (std::ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-examples/cxx/parser/performance/gen.cxx b/xsd-examples/cxx/parser/performance/gen.cxx new file mode 100644 index 0000000..5c11343 --- /dev/null +++ b/xsd-examples/cxx/parser/performance/gen.cxx @@ -0,0 +1,79 @@ +// file : cxx/parser/performance/gen.cxx +// copyright : not copyrighted - public domain + +#include +#include +#include + +using namespace std; + +static const char* enums[] = +{ + "romance", + "fiction", + "horror", + "history", + "philosophy" +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 3) + { + cerr << "usage: " << argv[0] << " " << endl; + return 1; + } + + unsigned long n (0); + istringstream is (argv[1]); + is >> n; + + if (n == 0) + { + cerr << "record count argument should be a positive number" << endl; + return 1; + } + + ofstream ofs (argv[2]); + + if (!ofs.is_open ()) + { + cerr << "unable to open '" << argv[2] << "' in write mode" << endl; + return 1; + } + + ofs << ""; + + unsigned short ch (1), en (0); + + for (unsigned long i (0); i < n; ++i) + { + ofs << "" + << "42" + << "42345.4232" + << "name123_45"; + + if (i % 2 == 1) + ofs << "one two three"; + + ofs << "" << ch << " choice" + << "" << enums[en] << "" + << ""; + + if (++ch > 4) + ch = 1; + + if (++en > 4) + en = 0; + } + + ofs << ""; +} diff --git a/xsd-examples/cxx/parser/performance/gen.testscript b/xsd-examples/cxx/parser/performance/gen.testscript new file mode 100644 index 0000000..1dc6d66 --- /dev/null +++ b/xsd-examples/cxx/parser/performance/gen.testscript @@ -0,0 +1,9 @@ +# file : cxx/parser/performance/gen.testscript +# license : not copyrighted - public domain + +: 50k +: +{ + $* 317 test-50k.xml &test-50k.xml; + cat test-50k.xml >>>$src_base/test-50k.xml +} diff --git a/xsd-examples/cxx/parser/performance/test-50k.xml b/xsd-examples/cxx/parser/performance/test-50k.xml new file mode 100644 index 0000000..42e22f3 --- /dev/null +++ b/xsd-examples/cxx/parser/performance/test-50k.xml @@ -0,0 +1 @@ +4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction \ No newline at end of file diff --git a/xsd-examples/cxx/parser/performance/test.xsd b/xsd-examples/cxx/parser/performance/test.xsd new file mode 100644 index 0000000..450a800 --- /dev/null +++ b/xsd-examples/cxx/parser/performance/test.xsd @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/parser/performance/time.cxx b/xsd-examples/cxx/parser/performance/time.cxx new file mode 100644 index 0000000..c8c1002 --- /dev/null +++ b/xsd-examples/cxx/parser/performance/time.cxx @@ -0,0 +1,46 @@ +// file : cxx/parser/performance/time.cxx +// copyright : not copyrighted - public domain + +#include "time.hxx" + +#if defined (WIN32) || defined (__WIN32__) +# define WIN32_LEAN_AND_MEAN +# include // GetSystemTimeAsFileTime +#else +# include // gettimeofday +# include // timeval +#endif + +#include // std::ostream +#include // std::setfill, std::setw + +namespace os +{ + time:: + time () + { +#if defined (WIN32) || defined (__WIN32__) + FILETIME ft; + GetSystemTimeAsFileTime (&ft); + unsigned long long v ( + ((unsigned long long) (ft.dwHighDateTime) << 32) + ft.dwLowDateTime); + + sec_ = static_cast (v / 10000000ULL); + nsec_ = static_cast ((v % 10000000ULL) * 100); +#else + timeval tv; + if (gettimeofday(&tv, 0) != 0) + throw failed (); + + sec_ = static_cast (tv.tv_sec); + nsec_ = static_cast (tv.tv_usec * 1000); +#endif + } + + std::ostream& + operator<< (std::ostream& o, time const& t) + { + return o << t.sec () << '.' + << std::setfill ('0') << std::setw (9) << t.nsec (); + } +} diff --git a/xsd-examples/cxx/parser/performance/time.hxx b/xsd-examples/cxx/parser/performance/time.hxx new file mode 100644 index 0000000..a22f671 --- /dev/null +++ b/xsd-examples/cxx/parser/performance/time.hxx @@ -0,0 +1,110 @@ +// file : cxx/parser/performance/time.hxx +// copyright : not copyrighted - public domain + +#ifndef TIME_HXX +#define TIME_HXX + +#include // std::ostream& + +namespace os +{ + class time + { + public: + class failed {}; + + // Create a time object representing the current time. + // + time (); + + time (unsigned long long nsec) + { + sec_ = static_cast (nsec / 1000000000ULL); + nsec_ = static_cast (nsec % 1000000000ULL); + } + + time (unsigned long sec, unsigned long nsec) + { + sec_ = sec; + nsec_ = nsec; + } + + public: + unsigned long + sec () const + { + return sec_; + } + + unsigned long + nsec () const + { + return nsec_; + } + + public: + class overflow {}; + class underflow {}; + + time + operator+= (time const& b) + { + unsigned long long tmp = 0ULL + nsec_ + b.nsec_; + + sec_ += static_cast (b.sec_ + tmp / 1000000000ULL); + nsec_ = static_cast (tmp % 1000000000ULL); + + return *this; + } + + time + operator-= (time const& b) + { + if (*this < b) + throw underflow (); + + sec_ -= b.sec_; + + if (nsec_ < b.nsec_) + { + --sec_; + nsec_ += 1000000000ULL - b.nsec_; + } + else + nsec_ -= b.nsec_; + + return *this; + } + + friend time + operator+ (time const& a, time const& b) + { + time r (a); + r += b; + return r; + } + + friend time + operator- (time const& a, time const& b) + { + time r (a); + r -= b; + return r; + } + + friend bool + operator < (time const& a, time const& b) + { + return (a.sec_ < b.sec_) || (a.sec_ == b.sec_ && a.nsec_ < b.nsec_); + } + + private: + unsigned long sec_; + unsigned long nsec_; + }; + + std::ostream& + operator<< (std::ostream&, time const&); +} + +#endif // TIME_HXX diff --git a/xsd-examples/cxx/parser/polymorphism/README b/xsd-examples/cxx/parser/polymorphism/README new file mode 100644 index 0000000..60a97e9 --- /dev/null +++ b/xsd-examples/cxx/parser/polymorphism/README @@ -0,0 +1,30 @@ +This example shows how to handle XML Schema polymorphism features such +as xsi:type attributes and substitution groups in the C++/Parser mapping. +The case when xsi:type is used on root elements is covered in the +polyroot examples. + +The example consists of the following files: + +supermen.xsd + XML Schema which describes the "supermen" instance documents. + +supermen.xml + Sample XML instance document. + +supermen-pskel.hxx +supermen-pskel.cxx + Parser skeletons generated by the XSD compiler from supermen.xsd. + Note the use of the --generate-polymorphic command line option. + +supermen-pimpl.hxx +supermen-pimpl.cxx + Parser implementations that print the XML data to STDOUT. + +driver.cxx + Driver for the example. It first constructs a parser instance from + all the individual parsers found in supermen-pimpl.hxx. It then invokes + this parser instance to parse the input file. + +To run the example on the sample XML instance document simply execute: + +$ ./driver supermen.xml diff --git a/xsd-examples/cxx/parser/polymorphism/buildfile b/xsd-examples/cxx/parser/polymorphism/buildfile new file mode 100644 index 0000000..de088cf --- /dev/null +++ b/xsd-examples/cxx/parser/polymorphism/buildfile @@ -0,0 +1,25 @@ +# file : cxx/parser/polymorphism/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -supermen-pskel} {hxx ixx cxx}{supermen-pskel} $libs + +exe{driver}: xml{supermen}: test.input = true + +<{hxx ixx cxx}{supermen-pskel}>: xsd{supermen} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --generate-polymorphic \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-examples/cxx/parser/polymorphism/driver.cxx b/xsd-examples/cxx/parser/polymorphism/driver.cxx new file mode 100644 index 0000000..879aa5c --- /dev/null +++ b/xsd-examples/cxx/parser/polymorphism/driver.cxx @@ -0,0 +1,70 @@ +// file : cxx/parser/polymorphism/driver.cxx +// copyright : not copyrighted - public domain + +#include + +#include "supermen-pimpl.hxx" + +using std::cerr; +using std::endl; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " supermen.xml" << endl; + return 1; + } + + try + { + // Construct the parser. + // + xml_schema::string_pimpl string_p; + xml_schema::boolean_pimpl boolean_p; + xml_schema::unsigned_int_pimpl unsigned_int_p; + + person_pimpl person_p; + superman_pimpl superman_p; + batman_pimpl batman_p; + + xml_schema::parser_map_impl person_map; + + supermen_pimpl supermen_p; + + + person_p.parsers (string_p); + superman_p.parsers (string_p, boolean_p); + batman_p.parsers (string_p, boolean_p, unsigned_int_p); + + // Here we are specifying a parser map which containes several parsers + // that can be used to parse the person element. + // + person_map.insert (person_p); + person_map.insert (superman_p); + person_map.insert (batman_p); + + supermen_p.person_parser (person_map); + + // Parse the XML document. The last argument to the document's + // constructor indicates that we are parsing polymorphic XML + // documents. + // + xml_schema::document doc_p (supermen_p, "supermen", true); + + supermen_p.pre (); + doc_p.parse (argv[1]); + supermen_p.post_supermen (); + } + 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/xsd-examples/cxx/parser/polymorphism/supermen-pimpl.cxx b/xsd-examples/cxx/parser/polymorphism/supermen-pimpl.cxx new file mode 100644 index 0000000..efed827 --- /dev/null +++ b/xsd-examples/cxx/parser/polymorphism/supermen-pimpl.cxx @@ -0,0 +1,85 @@ +// file : cxx/parser/polymorphism/supermen-pimpl.cxx +// copyright : not copyrighted - public domain +// + +#include + +#include "supermen-pimpl.hxx" + +using std::cout; +using std::endl; + +// person_pimpl +// +void person_pimpl:: +pre () +{ + cout << "starting to parse person" << endl; +} + +void person_pimpl:: +name (const std::string& v) +{ + cout << "name: " << v << endl; +} + +void person_pimpl:: +post_person () +{ + cout << "finished parsing person" << endl + << endl; +} + +// superman_pimpl +// +void superman_pimpl:: +pre () +{ + cout << "starting to parse superman" << endl; +} + +void superman_pimpl:: +can_fly (bool v) +{ + cout << "can-fly: " << v << endl; +} + +void superman_pimpl:: +post_person () +{ + post_superman (); +} + +void superman_pimpl:: +post_superman () +{ + cout << "finished parsing superman" << endl + << endl; +} + +// batman_pimpl +// +void batman_pimpl:: +pre () +{ + cout << "starting to parse batman" << endl; +} + +void batman_pimpl:: +wing_span (unsigned int v) +{ + cout << "wing-span: " << v << endl; +} + +void batman_pimpl:: +post_superman () +{ + post_batman (); +} + +void batman_pimpl:: +post_batman () +{ + cout << "finished parsing batman" << endl + << endl; +} diff --git a/xsd-examples/cxx/parser/polymorphism/supermen-pimpl.hxx b/xsd-examples/cxx/parser/polymorphism/supermen-pimpl.hxx new file mode 100644 index 0000000..0d103b5 --- /dev/null +++ b/xsd-examples/cxx/parser/polymorphism/supermen-pimpl.hxx @@ -0,0 +1,68 @@ +// file : cxx/parser/polymorphism/supermen-pimpl.hxx +// copyright : not copyrighted - public domain + +#ifndef SUPERMEN_PIMPL_HXX +#define SUPERMEN_PIMPL_HXX + +#include "supermen-pskel.hxx" + +class person_pimpl: public virtual person_pskel +{ +public: + virtual void + pre (); + + virtual void + name (const std::string&); + + virtual void + post_person (); +}; + +class superman_pimpl: public virtual superman_pskel, + public person_pimpl +{ +public: + virtual void + pre (); + + virtual void + can_fly (bool); + + // By default, post_superman() calls post_person(). In case of + // polymorphic parsing we want the opposite: post_person() calls + // post_superman(). + // + virtual void + post_person (); + + virtual void + post_superman (); +}; + +class batman_pimpl: public virtual batman_pskel, + public superman_pimpl +{ +public: + virtual void + pre (); + + virtual void + wing_span (unsigned int); + + // By default, post_batman() calls post_superman(). In case of + // polymorphic parsing we want the opposite: post_superman() + // calls post_batman(). + // + virtual void + post_superman (); + + virtual void + post_batman (); +}; + +class supermen_pimpl: public supermen_pskel +{ +}; + +#endif // SUPERMEN_PIMPL_HXX diff --git a/xsd-examples/cxx/parser/polymorphism/supermen.xml b/xsd-examples/cxx/parser/polymorphism/supermen.xml new file mode 100644 index 0000000..f569161 --- /dev/null +++ b/xsd-examples/cxx/parser/polymorphism/supermen.xml @@ -0,0 +1,25 @@ + + + + + + + + John Doe + + + + James "007" Bond + + + + Bruce Wayne + + + diff --git a/xsd-examples/cxx/parser/polymorphism/supermen.xsd b/xsd-examples/cxx/parser/polymorphism/supermen.xsd new file mode 100644 index 0000000..d63762b --- /dev/null +++ b/xsd-examples/cxx/parser/polymorphism/supermen.xsd @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/parser/polyroot/README b/xsd-examples/cxx/parser/polyroot/README new file mode 100644 index 0000000..f41b91c --- /dev/null +++ b/xsd-examples/cxx/parser/polyroot/README @@ -0,0 +1,36 @@ +This example shows how to handle the xsi:type attributes when it is used +on root elements. For general coverage of XML Schema polymorphism handling +in the C++/Parser mapping see the polymorphism example. + +The example consists of the following files: + +supermen.xsd + XML Schema which describes the "supermen" instance documents. + +person.xml +superman.xml +batman.xml + Sample XML instance documents. + +supermen-pskel.hxx +supermen-pskel.cxx + Parser skeletons generated by the XSD compiler from supermen.xsd. + Note the use of the --generate-polymorphic command line option. + +supermen-pimpl.hxx +supermen-pimpl.cxx + Parser implementations that print the XML data to STDOUT. + +driver.cxx + Driver for the example. It implements a custom document parser + that determines which XML Schema type is being parsed and uses + the corresponding parser implementation. The driver first + constructs a parser instance from all the individual parsers + found in supermen-pimpl.hxx. In then invokes this parser instance + to parse the input file. + +To run the example on the sample XML instance documents simply execute: + +$ ./driver person.xml +$ ./driver superman.xml +$ ./driver batman.xml diff --git a/xsd-examples/cxx/parser/polyroot/batman.xml b/xsd-examples/cxx/parser/polyroot/batman.xml new file mode 100644 index 0000000..600ad6f --- /dev/null +++ b/xsd-examples/cxx/parser/polyroot/batman.xml @@ -0,0 +1,16 @@ + + + + + + + Bruce Wayne + + diff --git a/xsd-examples/cxx/parser/polyroot/buildfile b/xsd-examples/cxx/parser/polyroot/buildfile new file mode 100644 index 0000000..6ae0fdc --- /dev/null +++ b/xsd-examples/cxx/parser/polyroot/buildfile @@ -0,0 +1,24 @@ +# file : cxx/parser/polyroot/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} xml{batman person superman} + +exe{driver}: {hxx cxx}{* -supermen-pskel} {hxx ixx cxx}{supermen-pskel} $libs \ + testscript + +<{hxx ixx cxx}{supermen-pskel}>: xsd{supermen} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --generate-polymorphic \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/xsd-examples/cxx/parser/polyroot/driver.cxx b/xsd-examples/cxx/parser/polyroot/driver.cxx new file mode 100644 index 0000000..986c8c0 --- /dev/null +++ b/xsd-examples/cxx/parser/polyroot/driver.cxx @@ -0,0 +1,138 @@ +// file : cxx/parser/polyroot/driver.cxx +// copyright : not copyrighted - public domain + +#include +#include +#include + +#include "supermen-pimpl.hxx" + +using std::cerr; +using std::endl; +using xml_schema::ro_string; + +// Customize the xml_schema::document object to handle polymorphic +// root element. For more information see the multiroot example. +// +class document: public xml_schema::document +{ +public: + document (const xml_schema::parser_map& parser_map) + : xml_schema::document (true), // Indicate polymorphic parsing. + parser_map_ (parser_map) + { + } + +protected: + // This function is called to obtain the root element type parser. + // If the returned pointer is 0 then the whole document content + // is ignored. The type argument contains the XML Schema type + // if xsi:type attribute was specified for this element and 0 + // otherwise. + // + virtual xml_schema::parser_base* + start_root_element (const ro_string& ns, + const ro_string& name, + const ro_string* type) + { + if (name != "person" || !ns.empty ()) + return 0; + + xml_schema::parser_base* base; + + // Search the parser map. + // + if (type == 0) + { + // No xsi:type. Static type should be used. + // + ro_string st (person_pskel::_static_type ()); + base = parser_map_.find (st); + } + else + { + base = parser_map_.find (*type); + } + + if (base != 0) + { + parser_used_ = dynamic_cast (base); + parser_used_->pre (); + } + else + parser_used_ = 0; // No parser for this type. + + return parser_used_; + } + + // 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 */) + { + // Instead of caching the current parser in parser_used_, we + // could also dynamic_cast the parser argument to the person_pskel + // type. + // + if (parser_used_) + parser_used_->post_person (); + } + + +private: + const xml_schema::parser_map& parser_map_; + person_pskel* parser_used_; +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " instance.xml" << endl; + return 1; + } + + try + { + // Construct the parser. + // + xml_schema::string_pimpl string_p; + xml_schema::boolean_pimpl boolean_p; + xml_schema::unsigned_int_pimpl unsigned_int_p; + + person_pimpl person_p; + superman_pimpl superman_p; + batman_pimpl batman_p; + + person_p.parsers (string_p); + superman_p.parsers (string_p, boolean_p); + batman_p.parsers (string_p, boolean_p, unsigned_int_p); + + // Parse the XML document. + // + xml_schema::parser_map_impl person_map; + + person_map.insert (person_p); + person_map.insert (superman_p); + person_map.insert (batman_p); + + document doc_p (person_map); + + doc_p.parse (argv[1]); + } + 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/xsd-examples/cxx/parser/polyroot/person.xml b/xsd-examples/cxx/parser/polyroot/person.xml new file mode 100644 index 0000000..2182457 --- /dev/null +++ b/xsd-examples/cxx/parser/polyroot/person.xml @@ -0,0 +1,15 @@ + + + + + + + John Doe + + diff --git a/xsd-examples/cxx/parser/polyroot/superman.xml b/xsd-examples/cxx/parser/polyroot/superman.xml new file mode 100644 index 0000000..97dbf1b --- /dev/null +++ b/xsd-examples/cxx/parser/polyroot/superman.xml @@ -0,0 +1,16 @@ + + + + + + + James "007" Bond + + diff --git a/xsd-examples/cxx/parser/polyroot/supermen-pimpl.cxx b/xsd-examples/cxx/parser/polyroot/supermen-pimpl.cxx new file mode 100644 index 0000000..d35e1fd --- /dev/null +++ b/xsd-examples/cxx/parser/polyroot/supermen-pimpl.cxx @@ -0,0 +1,85 @@ +// file : cxx/parser/polyroot/supermen-pimpl.cxx +// copyright : not copyrighted - public domain +// + +#include + +#include "supermen-pimpl.hxx" + +using std::cout; +using std::endl; + +// person_pimpl +// +void person_pimpl:: +pre () +{ + cout << "starting to parse person" << endl; +} + +void person_pimpl:: +name (const std::string& v) +{ + cout << "name: " << v << endl; +} + +void person_pimpl:: +post_person () +{ + cout << "finished parsing person" << endl + << endl; +} + +// superman_pimpl +// +void superman_pimpl:: +pre () +{ + cout << "starting to parse superman" << endl; +} + +void superman_pimpl:: +can_fly (bool v) +{ + cout << "can-fly: " << v << endl; +} + +void superman_pimpl:: +post_person () +{ + post_superman (); +} + +void superman_pimpl:: +post_superman () +{ + cout << "finished parsing superman" << endl + << endl; +} + +// batman_pimpl +// +void batman_pimpl:: +pre () +{ + cout << "starting to parse batman" << endl; +} + +void batman_pimpl:: +wing_span (unsigned int v) +{ + cout << "wing-span: " << v << endl; +} + +void batman_pimpl:: +post_superman () +{ + post_batman (); +} + +void batman_pimpl:: +post_batman () +{ + cout << "finished parsing batman" << endl + << endl; +} diff --git a/xsd-examples/cxx/parser/polyroot/supermen-pimpl.hxx b/xsd-examples/cxx/parser/polyroot/supermen-pimpl.hxx new file mode 100644 index 0000000..17ce7ff --- /dev/null +++ b/xsd-examples/cxx/parser/polyroot/supermen-pimpl.hxx @@ -0,0 +1,64 @@ +// file : cxx/parser/polyroot/supermen-pimpl.hxx +// copyright : not copyrighted - public domain + +#ifndef SUPERMEN_PIMPL_HXX +#define SUPERMEN_PIMPL_HXX + +#include "supermen-pskel.hxx" + +class person_pimpl: public virtual person_pskel +{ +public: + virtual void + pre (); + + virtual void + name (const std::string&); + + virtual void + post_person (); +}; + +class superman_pimpl: public virtual superman_pskel, + public person_pimpl +{ +public: + virtual void + pre (); + + virtual void + can_fly (bool); + + // By default, post_superman() calls post_person(). In case of + // polymorphic parsing we want the opposite: post_person() calls + // post_superman(). + // + virtual void + post_person (); + + virtual void + post_superman (); +}; + +class batman_pimpl: public virtual batman_pskel, + public superman_pimpl +{ +public: + virtual void + pre (); + + virtual void + wing_span (unsigned int); + + // By default, post_batman() calls post_superman(). In case of + // polymorphic parsing we want the opposite: post_superman() + // calls post_batman(). + // + virtual void + post_superman (); + + virtual void + post_batman (); +}; + +#endif // SUPERMEN_PIMPL_HXX diff --git a/xsd-examples/cxx/parser/polyroot/supermen.xsd b/xsd-examples/cxx/parser/polyroot/supermen.xsd new file mode 100644 index 0000000..e397b50 --- /dev/null +++ b/xsd-examples/cxx/parser/polyroot/supermen.xsd @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/parser/polyroot/testscript b/xsd-examples/cxx/parser/polyroot/testscript new file mode 100644 index 0000000..c5ad682 --- /dev/null +++ b/xsd-examples/cxx/parser/polyroot/testscript @@ -0,0 +1,6 @@ +# file : cxx/parser/polyroot/testscript +# license : not copyrighted - public domain + +$* $src_base/batman.xml >| : batman +$* $src_base/person.xml >| : person +$* $src_base/superman.xml >| : superman diff --git a/xsd-examples/cxx/parser/wildcard/README b/xsd-examples/cxx/parser/wildcard/README new file mode 100644 index 0000000..89f9aa9 --- /dev/null +++ b/xsd-examples/cxx/parser/wildcard/README @@ -0,0 +1,27 @@ +This example shows how to parse the XML data matched by XML Schema +wildcards (any and anyAttribute) in the C++/Parser mapping. The +example consists of the following files: + +email.xsd + XML Schema which describes a simple email format with the + extensible envelope type. + +email.xml + Sample email message. + +email-pskel.hxx +email-pskel.cxx + Parser skeletons generated by XSD from email.xsd. + +driver.cxx + Parser implementations and a driver for the example. The + parser implementations simply print the data to STDERR. + The driver first constructs parser instances from the + parser implementations mentioned above and a couple of + predefined parsers for the XML Schema built-in types. + In then invokes the parser instances to parse the input + file. + +To run the example on the sample XML instance document simply execute: + +$ ./driver email.xml diff --git a/xsd-examples/cxx/parser/wildcard/buildfile b/xsd-examples/cxx/parser/wildcard/buildfile new file mode 100644 index 0000000..93e2dc8 --- /dev/null +++ b/xsd-examples/cxx/parser/wildcard/buildfile @@ -0,0 +1,24 @@ +# file : cxx/parser/wildcard/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -email-pskel} {hxx ixx cxx}{email-pskel} $libs + +exe{driver}: xml{email}: test.input = true + +<{hxx ixx cxx}{email-pskel}>: xsd{email} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-examples/cxx/parser/wildcard/driver.cxx b/xsd-examples/cxx/parser/wildcard/driver.cxx new file mode 100644 index 0000000..cb7a754 --- /dev/null +++ b/xsd-examples/cxx/parser/wildcard/driver.cxx @@ -0,0 +1,239 @@ +// file : cxx/parser/wildcard/driver.cxx +// copyright : not copyrighted - public domain + +#include +#include +#include + +#include "email-pskel.hxx" + +using namespace std; +using xml_schema::ro_string; + +class binary_pimpl: public email::binary_pskel, + public xml_schema::base64_binary_pimpl +{ +public: + virtual void + name (const string& n) + { + cerr << "binary: " << n << endl; + } + + virtual void + mime (const string& t) + { + cerr << "type: " << t << endl + << endl; + } + + virtual void + post_binary () + { + unique_ptr buf (post_base64_binary ()); + + cerr << "size: " << buf->size () << endl + << endl; + } +}; + +class envelope_pimpl: public email::envelope_pskel +{ +public: + envelope_pimpl (xml_schema::unsigned_int_pskel& uint_p, + xml_schema::string_pskel& string_p, + email::binary_pskel& binary_p) + : depth_ (0), cur_ (0), + uint_p_ (uint_p), string_p_ (string_p), binary_p_ (binary_p) + { + } + + virtual void + to (const string& addr) + { + cerr << "To: " << addr << endl; + } + + virtual void + from (const string& addr) + { + cerr << "From: " << addr << endl; + } + + virtual void + subject (const string& s) + { + cerr << "Subject: " << s << endl; + } + + // Wildcard handling. All wildcard events are routed to these + // four functions. It is our job to dispatch them to the right + // parsers. + // + virtual void + _start_any_element (const ro_string& ns, + const ro_string& name, + const ro_string* type) + { + if (depth_++ > 0) + { + // Nested wildcard element. + // + if (cur_) + cur_->_start_element (ns, name, type); + } + else + { + // Top-level element matched by the any wildcard. + // + if (ns == "http://www.codesynthesis.com/email") + { + if (name == "text") + { + cur_ = &string_p_; + string_p_.pre (); + string_p_._pre_impl (); + } + else if (name == "binary") + { + cur_ = &binary_p_; + binary_p_.pre (); + binary_p_._pre_impl (); + } + } + + if (cur_ == 0) + { + cerr << "Unknown wildcard content: " << ns << "#" << name << endl; + } + } + } + + virtual void + _end_any_element (const ro_string& ns, const ro_string& name) + { + if (--depth_ > 0) + { + if (cur_) + cur_->_end_element (ns, name); + } + else + { + if (ns == "http://www.codesynthesis.com/email") + { + if (name == "text") + { + string_p_._post_impl (); + string text (string_p_.post_string ()); + + cerr << text << endl + << endl; + } + else if (name == "binary") + { + binary_p_._post_impl (); + binary_p_.post_binary (); + } + } + + cur_ = 0; + } + } + + virtual void + _any_attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value) + { + if (depth_ > 0) + { + // Nested wildcard attribute. + // + if (cur_) + cur_->_attribute (ns, name, value); + } + else + { + // Top-level attribute matched by the anyAttribute wildcard. + // + if (ns == "http://www.codesynthesis.com/email" && name == "thread-id") + { + uint_p_.pre (); + uint_p_._pre_impl (); + uint_p_._characters (value); + uint_p_._post_impl (); + unsigned int tid (uint_p_.post_unsigned_int ()); + + cerr << "Thread-id: " << tid << endl; + } + } + } + + virtual void + _any_characters (const ro_string& s) + { + if (depth_ > 0) + { + if (cur_) + cur_->_characters (s); + } + } + +private: + size_t depth_; + xml_schema::parser_base* cur_; + + // Parsers for the unsigned int, string and binary types. + // +private: + xml_schema::unsigned_int_pskel& uint_p_; + xml_schema::string_pskel& string_p_; + email::binary_pskel& binary_p_; +}; + + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " email.xml" << endl; + return 1; + } + + try + { + // Construct the parser. + // + xml_schema::unsigned_int_pimpl unsigned_int_p; + xml_schema::string_pimpl string_p; + binary_pimpl binary_p; + envelope_pimpl envelope_p (unsigned_int_p, string_p, binary_p); + + binary_p.parsers (string_p, // name + string_p); // mime + + envelope_p.parsers (string_p, // to + string_p, // from + string_p); // subject + + // Parse the XML instance document. + // + xml_schema::document doc_p (envelope_p, + "http://www.codesynthesis.com/email", + "message"); + envelope_p.pre (); + doc_p.parse (argv[1]); + envelope_p.post_envelope (); + } + 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/xsd-examples/cxx/parser/wildcard/email.xml b/xsd-examples/cxx/parser/wildcard/email.xml new file mode 100644 index 0000000..482103b --- /dev/null +++ b/xsd-examples/cxx/parser/wildcard/email.xml @@ -0,0 +1,31 @@ + + + + + + + Jane Doe <jane@doe.com> + John Doe <john@doe.com> + Surfing pictures + + +Hi Jane, + +Here are cool pictures of me surfing. + +Cheers, +John + + + YmFzZTY0IGJpbmFyeQ== + YmFzZTY0IGJpbmFyeQ== + + diff --git a/xsd-examples/cxx/parser/wildcard/email.xsd b/xsd-examples/cxx/parser/wildcard/email.xsd new file mode 100644 index 0000000..6aec20c --- /dev/null +++ b/xsd-examples/cxx/parser/wildcard/email.xsd @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/README b/xsd-examples/cxx/tree/README new file mode 100644 index 0000000..83ffcab --- /dev/null +++ b/xsd-examples/cxx/tree/README @@ -0,0 +1,84 @@ +This directory contains a number of examples that show how to use +the C++/Tree mapping. The following list gives an overview of +each example. See the README files in example directories for +more information on each example. + +hello + A simple "Hello, world!" example that shows how to parse XML + documents. + +library + Shows hot to handle more complex data structures, use the + ID/IDREF cross-referencing mechanism, use the xsd:enumeration + to C++ enum mapping, modify the object model, and serialize + the modified object model back to XML. + +polymorphism + Shows how to use XML Schema polymorphism features such as the + xsi:type attribute and substitution groups. + +order/ + A collection of examples that show how to use ordered types to + capture and maintain content order. + +xpath + Shows how to use the C++/Tree mapping together with XPath. + +wildcard + Shows how to use the optional wildcard mapping to parse, access, + modify, and serialize the XML data matched by XML Schema wildcards + (any and anyAttribute). + +mixed + Shows how to access the underlying DOM nodes to handle raw, "type- + less content" such as mixed content models, anyType/anySimpleType, + and any/anyAttribute. + +multiroot + Shows how to handle XML vocabularies with multiple root elements. + See also the messaging example. + +messaging + Shows how to handle XML vocabularies with multiple root elements + using the element type and element map features of the C++/Tree + mapping. + +caching + Shows how to parse several XML documents while reusing the + underlying XML parser and caching the schemas used for validation. + +embedded + Shows how to embed the binary representation of the schema grammar + into an application and then use it with the C++/Tree mapping to + parse and validate XML documents. + +secure + Shows how to perform more secure XML parsing by disabling the XML + External Entity (XXE) Processing. + +performance + Measures the performance of parsing and serialization. This example + also shows how to structure your code to achieve the maximum + performance for these two operations. + +custom/ + A collection of examples that show how to customize the C++/Tree + mapping by using custom C++ classes instead of or in addition to + the generated ones. See the accompanying README file for an + overview of each example in this directory. + +streaming + Shows how to perform stream-oriented, partially in-memory XML + processing using the C++/Tree mapping. With the partially in-memory + parsing and serialization only a part of the object model is in + memory at any given time. With this approach we can process parts + of the document as they become available as well as handle documents + that are too large to fit into memory. + +compression + Shows how to compress an XML document during serialization and decompress + it during parsing using the zlib library. + +binary/ + A collection of examples that show how to serialize the object model + into a number of predefined and custom binary formats. diff --git a/xsd-examples/cxx/tree/binary/README b/xsd-examples/cxx/tree/binary/README new file mode 100644 index 0000000..365551e --- /dev/null +++ b/xsd-examples/cxx/tree/binary/README @@ -0,0 +1,16 @@ +This directory contains a number of examples that show how to serialize +the object model into a number of predefined and custom binary formats. +The following list gives an overview of each example: + +boost + Shows how to save/load the object model to/from a custom format + using the Boost serialization library as an example. + +cdr + Shows how to save/load the object model to/from CDR (Common Data + Representation) binary format using ACE CDR streams. + +xdr + Shows how to save/load the object model to/from XDR (eXternal Data + Representation) binary format using the XDR API provided as part of + Sun RPC. diff --git a/xsd-examples/cxx/tree/binary/boost/.gitignore b/xsd-examples/cxx/tree/binary/boost/.gitignore new file mode 100644 index 0000000..c116ec1 --- /dev/null +++ b/xsd-examples/cxx/tree/binary/boost/.gitignore @@ -0,0 +1 @@ +library.?xx diff --git a/xsd-examples/cxx/tree/binary/boost/README b/xsd-examples/cxx/tree/binary/boost/README new file mode 100644 index 0000000..6cdd2dd --- /dev/null +++ b/xsd-examples/cxx/tree/binary/boost/README @@ -0,0 +1,49 @@ +This example shows how to save/load the object model to/from a custom +format using the Boost serialization library as an example. You will +need the Boost serialization library[1] installed in order to build +and run this example. + +[1] http://www.boost.org + +The example consists of the following files: + +library.xsd + XML Schema which describes a library of books. + +library.xml + Sample XML instance document. + +boost-archive-extraction.hxx +boost-archive-insertion.hxx + Boost archive insertion and extraction operators for fundamental + types. You will need to provide a similar set of operators for + your own stream types. + +library-prologue.hxx + Contains a number of #include directives that are inserted into + the generated code by the XSD compiler. The included files are: + boost/archive/text_oarchive.hpp, boost/archive/text_oarchive.hpp, + boost-archive-insertion.hxx, and boost-archive-insertion.hxx. + +library.hxx +library.cxx + C++ types that represent the given vocabulary as well as Boost + archive insertion and extraction operations. These are generated + by the XSD compiler from library.xsd. The --hxx-prologue-file + option is used to insert the contents of the library-prologue.hxx + file into the generated header file. The --generate-insertion and + --generate-extraction options are used to generate the insertion + and extraction operations for text_oarchive and text_iarchive + types. + +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 text_oarchive and loads it back from + text_iarchive. Additionally, it prints the resulting text + representation as well as the content of the object model before + saving it to text_oarchive and after loading it from text_iarchive. + +To run the example on the sample XML instance document simply execute: + +$ ./driver library.xml diff --git a/xsd-examples/cxx/tree/binary/boost/boost-archive-extraction.hxx b/xsd-examples/cxx/tree/binary/boost/boost-archive-extraction.hxx new file mode 100644 index 0000000..93241da --- /dev/null +++ b/xsd-examples/cxx/tree/binary/boost/boost-archive-extraction.hxx @@ -0,0 +1,188 @@ +// file : cxx/tree/binary/boost/boost-archive-insertion.cxx +// copyright : not copyrighted - public domain + +#ifndef BOOST_ARCHIVE_EXTRACTION_HXX +#define BOOST_ARCHIVE_EXTRACTION_HXX + +#include // std::size_t +#include + +#include +#include + +#include + +namespace xsd +{ + namespace cxx + { + namespace tree + { + // as_size + // + template + inline istream& + operator>> (istream& s, istream_common::as_size& x) + { + std::size_t r; + s.impl () >> r; + x.x_ = static_cast (r); + return s; + } + + // 8-bit + // + template + inline istream& + operator>> (istream& s, istream_common::as_int8& x) + { + boost::int8_t r; + s.impl () >> r; + x.x_ = static_cast (r); + return s; + } + + template + inline istream& + operator>> (istream& s, istream_common::as_uint8& x) + { + boost::uint8_t r; + s.impl () >> r; + x.x_ = static_cast (r); + return s; + } + + + // 16-bit + // + template + inline istream& + operator>> (istream& s, istream_common::as_int16& x) + { + boost::int16_t r; + s.impl () >> r; + x.x_ = static_cast (r); + return s; + } + + template + inline istream& + operator>> (istream& s, istream_common::as_uint16& x) + { + boost::uint16_t r; + s.impl () >> r; + x.x_ = static_cast (r); + return s; + } + + + // 32-bit + // + template + inline istream& + operator>> (istream& s, istream_common::as_int32& x) + { + boost::int32_t r; + s.impl () >> r; + x.x_ = static_cast (r); + return s; + } + + template + inline istream& + operator>> (istream& s, istream_common::as_uint32& x) + { + boost::uint32_t r; + s.impl () >> r; + x.x_ = static_cast (r); + return s; + } + + + // 64-bit + // + template + inline istream& + operator>> (istream& s, istream_common::as_int64& x) + { + boost::int64_t r; + s.impl () >> r; + x.x_ = static_cast (r); + return s; + } + + template + inline istream& + operator>> (istream& s, istream_common::as_uint64& x) + { + boost::uint64_t r; + s.impl () >> r; + x.x_ = static_cast (r); + return s; + } + + + // Boolean + // + template + inline istream& + operator>> (istream& s, istream_common::as_bool& x) + { + bool r; + s.impl () >> r; + x.x_ = static_cast (r); + return s; + } + + + // Floating-point + // + template + inline istream& + operator>> (istream& s, istream_common::as_float32& x) + { + float r; + s.impl () >> r; + x.x_ = static_cast (r); + return s; + } + + template + inline istream& + operator>> (istream& s, istream_common::as_float64& x) + { + double r; + s.impl () >> r; + x.x_ = static_cast (r); + return s; + } + + // Extraction of std::basic_string. + // + + template + inline istream& + operator>> (istream& s, std::basic_string& x) + { + s.impl () >> x; + return s; + } + + + // Extraction of a binary buffer. + // + template + istream& + operator>> (istream& s, buffer& x) + { + std::size_t size; + s.impl () >> size; + x.size (size); + s.impl ().load_binary (x.data (), size); + return s; + } + } + } +} + +#endif // BOOST_ARCHIVE_EXTRACTION_HXX diff --git a/xsd-examples/cxx/tree/binary/boost/boost-archive-insertion.hxx b/xsd-examples/cxx/tree/binary/boost/boost-archive-insertion.hxx new file mode 100644 index 0000000..b2f7936 --- /dev/null +++ b/xsd-examples/cxx/tree/binary/boost/boost-archive-insertion.hxx @@ -0,0 +1,177 @@ +// file : cxx/tree/binary/boost/boost-archive-insertion.cxx +// copyright : not copyrighted - public domain + +#ifndef BOOST_ARCHIVE_INSERTION_HXX +#define BOOST_ARCHIVE_INSERTION_HXX + +#include // std::size_t +#include + +#include +#include + +#include + +namespace xsd +{ + namespace cxx + { + namespace tree + { + // as_size + // + template + inline ostream& + operator<< (ostream& s, ostream_common::as_size x) + { + std::size_t v (static_cast (x.x_)); + s.impl () << v; + return s; + } + + // 8-bit + // + template + inline ostream& + operator<< (ostream& s, ostream_common::as_int8 x) + { + boost::int8_t v (static_cast (x.x_)); + s.impl () << v; + return s; + } + + template + inline ostream& + operator<< (ostream& s, ostream_common::as_uint8 x) + { + boost::uint8_t v (static_cast (x.x_)); + s.impl () << v; + return s; + } + + + // 16-bit + // + template + inline ostream& + operator<< (ostream& s, ostream_common::as_int16 x) + { + boost::int16_t v (static_cast (x.x_)); + s.impl () << v; + return s; + } + + template + inline ostream& + operator<< (ostream& s, ostream_common::as_uint16 x) + { + boost::uint16_t v (static_cast (x.x_)); + s.impl () << v; + return s; + } + + + // 32-bit + // + template + inline ostream& + operator<< (ostream& s, ostream_common::as_int32 x) + { + boost::int32_t v (static_cast (x.x_)); + s.impl () << v; + return s; + } + + template + inline ostream& + operator<< (ostream& s, ostream_common::as_uint32 x) + { + boost::uint32_t v (static_cast (x.x_)); + s.impl () << v; + return s; + } + + + // 64-bit + // + template + inline ostream& + operator<< (ostream& s, ostream_common::as_int64 x) + { + boost::int64_t v (static_cast (x.x_)); + s.impl () << v; + return s; + } + + template + inline ostream& + operator<< (ostream& s, ostream_common::as_uint64 x) + { + boost::uint64_t v (static_cast (x.x_)); + s.impl () << v; + return s; + } + + + // Boolean + // + template + inline ostream& + operator<< (ostream& s, ostream_common::as_bool x) + { + bool v (static_cast (x.x_)); + s.impl () << v; + return s; + } + + + // Floating-point + // + template + inline ostream& + operator<< (ostream& s, ostream_common::as_float32 x) + { + float v (static_cast (x.x_)); + s.impl () << v; + return s; + } + + template + inline ostream& + operator<< (ostream& s, ostream_common::as_float64 x) + { + double v (static_cast (x.x_)); + s.impl () << v; + return s; + } + + + // Insertion of std::basic_string. + // + template + inline ostream& + operator<< (ostream& s, const std::basic_string& x) + { + s.impl () << x; + return s; + } + + + // Insertion of a binary buffer. + // + template + ostream& + operator<< (ostream& s, const buffer& x) + { + // Boost.Serialization needs an lvalue. + // + std::size_t size (x.size()); + s.impl () << size; + s.impl ().save_binary (x.data (), x.size ()); + return s; + } + } + } +} + +#endif // BOOST_ARCHIVE_INSERTION_HXX diff --git a/xsd-examples/cxx/tree/binary/boost/buildfile b/xsd-examples/cxx/tree/binary/boost/buildfile new file mode 100644 index 0000000..4306273 --- /dev/null +++ b/xsd-examples/cxx/tree/binary/boost/buildfile @@ -0,0 +1,32 @@ +# file : cxx/tree/binary/boost/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} +import libs += libboost-serialization%lib{boost_serialization} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -library} {hxx ixx cxx}{library} $libs + +exe{driver}: xml{library}: test.input = true + +<{hxx ixx cxx}{library}>: xsd{library} hxx{library-prologue} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-ostream \ + --hxx-prologue-file $path($<[1]) \ + --generate-insertion 'boost::archive::text_oarchive' \ + --generate-extraction 'boost::archive::text_iarchive' \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-examples/cxx/tree/binary/boost/driver.cxx b/xsd-examples/cxx/tree/binary/boost/driver.cxx new file mode 100644 index 0000000..d1d08d9 --- /dev/null +++ b/xsd-examples/cxx/tree/binary/boost/driver.cxx @@ -0,0 +1,72 @@ +// file : cxx/tree/binary/boost/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include // std::memcpy +#include +#include + +// You can generate insertion/extraction code for other archive +// types (for example, binary, XML, etc). +// +#include +#include + +#include "library.hxx" + +using std::cerr; +using std::endl; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " library.xml" << endl; + return 1; + } + + try + { + using namespace library; + using boost::archive::text_oarchive; + using boost::archive::text_iarchive; + + // Read in the file. + // + std::unique_ptr c (catalog_ (argv[1])); + + cerr << *c << endl; + + // Save into a text archive. + // + std::ostringstream ostr; + text_oarchive oa (ostr); + xml_schema::ostream os (oa); + + os << *c; + + // Print the text representation. + // + std::string str (ostr.str ()); + + cerr << endl + << "text representation: " << endl + << str << endl; + + // Load from a text archive. + // + std::istringstream istr (str); + text_iarchive ia (istr); + xml_schema::istream is (ia); + + std::unique_ptr copy (new catalog (is)); + + cerr << *copy << endl; + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-examples/cxx/tree/binary/boost/library-prologue.hxx b/xsd-examples/cxx/tree/binary/boost/library-prologue.hxx new file mode 100644 index 0000000..ba0d35f --- /dev/null +++ b/xsd-examples/cxx/tree/binary/boost/library-prologue.hxx @@ -0,0 +1,9 @@ +// Include declarations for the archive types. +// +#include +#include + +// Include insertion/extraction operators for fundamental types. +// +#include "boost-archive-insertion.hxx" +#include "boost-archive-extraction.hxx" diff --git a/xsd-examples/cxx/tree/binary/boost/library.xml b/xsd-examples/cxx/tree/binary/boost/library.xml new file mode 100644 index 0000000..6368f44 --- /dev/null +++ b/xsd-examples/cxx/tree/binary/boost/library.xml @@ -0,0 +1,52 @@ + + + + + + + + 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/xsd-examples/cxx/tree/binary/boost/library.xsd b/xsd-examples/cxx/tree/binary/boost/library.xsd new file mode 100644 index 0000000..3959788 --- /dev/null +++ b/xsd-examples/cxx/tree/binary/boost/library.xsd @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/binary/cdr/.gitignore b/xsd-examples/cxx/tree/binary/cdr/.gitignore new file mode 100644 index 0000000..c116ec1 --- /dev/null +++ b/xsd-examples/cxx/tree/binary/cdr/.gitignore @@ -0,0 +1 @@ +library.?xx diff --git a/xsd-examples/cxx/tree/binary/cdr/README b/xsd-examples/cxx/tree/binary/cdr/README new file mode 100644 index 0000000..914d27c --- /dev/null +++ b/xsd-examples/cxx/tree/binary/cdr/README @@ -0,0 +1,36 @@ +This example shows how to save/load the object model to/from CDR +(Common Data Representation) binary format using ACE CDR streams. +Support for other data representation streams can be easily added. You +will need the ACE library[1] installed in order to build and run this +example. + +[1] http://www.cs.wustl.edu/~schmidt/ACE.html + +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 ACE CDR + 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 ACE_OuputCDR and loads it back from + ACE_InputCDR. Additionally, it prints the resulting binary + representation as well as the content of the object model before + saving it to the CDR stream and after loading it from the CDR stream. + +To run the example on the sample XML instance document simply execute: + +$ ./driver library.xml diff --git a/xsd-examples/cxx/tree/binary/cdr/buildfile b/xsd-examples/cxx/tree/binary/cdr/buildfile new file mode 100644 index 0000000..d78a56a --- /dev/null +++ b/xsd-examples/cxx/tree/binary/cdr/buildfile @@ -0,0 +1,28 @@ +# file : cxx/tree/binary/cdr/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} +import libs += libace%lib{ACE} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -library} {hxx ixx cxx}{library} $libs + +exe{driver}: xml{library}: test.input = true + +<{hxx ixx cxx}{library}>: xsd{library} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-ostream \ + --generate-insertion 'ACE_OutputCDR' \ + --generate-extraction 'ACE_InputCDR' \ + --generate-comparison \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-examples/cxx/tree/binary/cdr/driver.cxx b/xsd-examples/cxx/tree/binary/cdr/driver.cxx new file mode 100644 index 0000000..2ab0674 --- /dev/null +++ b/xsd-examples/cxx/tree/binary/cdr/driver.cxx @@ -0,0 +1,87 @@ +// file : cxx/tree/binary/cdr/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include // std::memcpy +#include + +#include // ACE_HEX_DUMP +#include + +// The following two headers define XSD-specific insertion/extraction +// operations for ACE CDR streams. You can use the content of these +// headers as a guide to implementing insertion/extraction to/from +// your own data representation streams: +// +// xsd/cxx/tree/ace-cdr-stream-insertion.hxx +// xsd/cxx/tree/ace-cdr-stream-extraction.hxx + +#include "library.hxx" + +using std::cerr; +using std::endl; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " library.xml" << endl; + return 1; + } + + try + { + using namespace library; + + // Read in the file. + // + std::unique_ptr c (catalog_ (argv[1])); + + cerr << *c << endl; + + // Save to a CDR stream. + // + ACE_OutputCDR ace_ocdr; + xml_schema::ostream ocdr (ace_ocdr); + + ocdr << *c; + + // Print the binary representation and at the same time save + // it into a continuous buffer. + // + cerr << endl + << "binary representation size: " << ace_ocdr.total_length () << endl; + + xml_schema::buffer buf (ace_ocdr.total_length ()); + char* data (buf.data ()); + + for (const ACE_Message_Block* mb = ace_ocdr.begin (); + mb != 0; + mb = mb->cont ()) + { + std::memcpy (data, mb->rd_ptr (), mb->length ()); + data += mb->length (); + + ACE_HEX_DUMP ((LM_DEBUG, mb->rd_ptr (), mb->length ())); + } + + // Load from a CDR stream. Note that ACE_InputCDR expects the + // buffer to be properly aligned. Since our buffer is dynamically + // allocated, its alignment should be good enough. + // + ACE_InputCDR ace_icdr (buf.data (), buf.size ()); + xml_schema::istream icdr (ace_icdr); + + std::unique_ptr copy (new catalog (icdr)); + + cerr << *copy << endl; + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + return 1; + } + + return 0; // ACE makes our main() an ordinary function. +} diff --git a/xsd-examples/cxx/tree/binary/cdr/library.xml b/xsd-examples/cxx/tree/binary/cdr/library.xml new file mode 100644 index 0000000..5700131 --- /dev/null +++ b/xsd-examples/cxx/tree/binary/cdr/library.xml @@ -0,0 +1,52 @@ + + + + + + + + 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/xsd-examples/cxx/tree/binary/cdr/library.xsd b/xsd-examples/cxx/tree/binary/cdr/library.xsd new file mode 100644 index 0000000..c7f056e --- /dev/null +++ b/xsd-examples/cxx/tree/binary/cdr/library.xsd @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/binary/xdr/.gitignore b/xsd-examples/cxx/tree/binary/xdr/.gitignore new file mode 100644 index 0000000..c116ec1 --- /dev/null +++ b/xsd-examples/cxx/tree/binary/xdr/.gitignore @@ -0,0 +1 @@ +library.?xx diff --git a/xsd-examples/cxx/tree/binary/xdr/README b/xsd-examples/cxx/tree/binary/xdr/README new file mode 100644 index 0000000..e02b2b9 --- /dev/null +++ b/xsd-examples/cxx/tree/binary/xdr/README @@ -0,0 +1,36 @@ +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 on most UNIX and GNU/Linux systems as part +of Sun RPC (libtirpc-dev package on Debian/Ubuntu, libtirpc-devel +package on Fedora/RHEL, and as a part of the Standard C Library on +FreeBSD and MacOS). 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/xsd-examples/cxx/tree/binary/xdr/buildfile b/xsd-examples/cxx/tree/binary/xdr/buildfile new file mode 100644 index 0000000..92f0c48 --- /dev/null +++ b/xsd-examples/cxx/tree/binary/xdr/buildfile @@ -0,0 +1,30 @@ +# file : cxx/tree/binary/xdr/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +if ($cxx.target.class == 'linux') + import libs += libtirpc%lib{tirpc} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -library} {hxx ixx cxx}{library} $libs + +exe{driver}: xml{library}: test.input = true + +<{hxx ixx cxx}{library}>: xsd{library} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-ostream \ + --generate-insertion 'XDR' \ + --generate-extraction 'XDR' \ + --generate-comparison \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-examples/cxx/tree/binary/xdr/driver.cxx b/xsd-examples/cxx/tree/binary/xdr/driver.cxx new file mode 100644 index 0000000..f706ebf --- /dev/null +++ b/xsd-examples/cxx/tree/binary/xdr/driver.cxx @@ -0,0 +1,148 @@ +// file : cxx/tree/binary/xdr/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_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::unique_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::unique_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/xsd-examples/cxx/tree/binary/xdr/library.xml b/xsd-examples/cxx/tree/binary/xdr/library.xml new file mode 100644 index 0000000..05ed593 --- /dev/null +++ b/xsd-examples/cxx/tree/binary/xdr/library.xml @@ -0,0 +1,52 @@ + + + + + + + + 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/xsd-examples/cxx/tree/binary/xdr/library.xsd b/xsd-examples/cxx/tree/binary/xdr/library.xsd new file mode 100644 index 0000000..8e1b316 --- /dev/null +++ b/xsd-examples/cxx/tree/binary/xdr/library.xsd @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/buildfile b/xsd-examples/cxx/tree/buildfile new file mode 100644 index 0000000..3345cfb --- /dev/null +++ b/xsd-examples/cxx/tree/buildfile @@ -0,0 +1,6 @@ +# file : cxx/tree/buildfile +# license : not copyrighted - public domain + +# Exclude examples which depend on not yet packaged libraries. +# +./: {*/ -binary/ -xpath/} doc{README} diff --git a/xsd-examples/cxx/tree/caching/.gitignore b/xsd-examples/cxx/tree/caching/.gitignore new file mode 100644 index 0000000..c116ec1 --- /dev/null +++ b/xsd-examples/cxx/tree/caching/.gitignore @@ -0,0 +1 @@ +library.?xx diff --git a/xsd-examples/cxx/tree/caching/README b/xsd-examples/cxx/tree/caching/README new file mode 100644 index 0000000..64dffb3 --- /dev/null +++ b/xsd-examples/cxx/tree/caching/README @@ -0,0 +1,29 @@ +This example shows how to use the C++/Tree mapping to parse several +XML documents while reusing the underlying XML parser and caching the +schemas used for validation. + +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 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 library.xsd. + +driver.cxx + Driver for the example. It first sets up the Xerces-C++ DOM parser + and caches the library.xsd schema for validation. It then performs + ten iterations that parse the input file to a DOM document using + the DOM parser and call one of the parsing functions that constructs + the object model from this DOM document. On each iteration the driver + prints a number of books in the object model to STDERR. + +To run the example on the sample XML instance document simply execute: + +$ ./driver library.xml library.xsd diff --git a/xsd-examples/cxx/tree/caching/buildfile b/xsd-examples/cxx/tree/caching/buildfile new file mode 100644 index 0000000..cb369b7 --- /dev/null +++ b/xsd-examples/cxx/tree/caching/buildfile @@ -0,0 +1,27 @@ +# file : cxx/tree/caching/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -library} {hxx ixx cxx}{library} $libs + +exe{driver}: {xml xsd}{library}: test.input = true + +<{hxx ixx cxx}{library}>: xsd{library} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-examples/cxx/tree/caching/driver.cxx b/xsd-examples/cxx/tree/caching/driver.cxx new file mode 100644 index 0000000..9cabbd4 --- /dev/null +++ b/xsd-examples/cxx/tree/caching/driver.cxx @@ -0,0 +1,165 @@ +// file : cxx/tree/caching/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include +#include + +#include +#include // chLatin_* +#include +#include // xercesc::Grammar +#include + +#include +#include +#include + +#include + +#include "library.hxx" + +using namespace std; + +int +main (int argc, char* argv[]) +{ + if (argc != 3) + { + cerr << "usage: " << argv[0] << " library.xml library.xsd" << 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 + { + using namespace xercesc; + namespace xml = xsd::cxx::xml; + namespace tree = xsd::cxx::tree; + + 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::unique_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 validation. + // + conf->setParameter (XMLUni::fgDOMValidate, true); + conf->setParameter (XMLUni::fgXercesSchema, true); + 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 + + // Set error handler. + // + tree::error_handler eh; + xml::dom::bits::error_handler_proxy ehp (eh); + conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp); + + // Initialize the schema cache. + // + if (!parser->loadGrammar (argv[2], Grammar::SchemaGrammarType, true)) + { + // In Xerces-C++ grammar loading failure results in just a warning. + // Make it a fatal error. + // + eh.handle (argv[2], 0, 0, + tree::error_handler::severity::fatal, + "unable to load schema"); + } + + eh.throw_if_failed (); + + // Use the loaded grammar during parsing. + // + conf->setParameter (XMLUni::fgXercesUseCachedGrammarInParse, true); + + // Disable loading schemas via other means (e.g., schemaLocation). + // + conf->setParameter (XMLUni::fgXercesLoadSchema, false); + + // We will release the DOM document ourselves. + // + conf->setParameter (XMLUni::fgXercesUserAdoptsDOMDocument, true); + + // Parse XML documents. + // + for (unsigned long i (0); i < 10; ++i) + { + ifstream ifs; + ifs.exceptions (ifstream::badbit | ifstream::failbit); + ifs.open (argv[1]); + + // Wrap the standard input stream. + // + xml::sax::std_input_source isrc (ifs, argv[1]); + Wrapper4InputSource wrap (&isrc, false); + + // Parse XML to DOM. + // + xml_schema::dom::unique_ptr doc (parser->parse (&wrap)); + + eh.throw_if_failed (); + + // Parse DOM to the object model. + // + unique_ptr c (library::catalog_ (*doc)); + + cerr << "catalog with " << c->book ().size () << " books" << 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/xsd-examples/cxx/tree/caching/library.xml b/xsd-examples/cxx/tree/caching/library.xml new file mode 100644 index 0000000..b36786f --- /dev/null +++ b/xsd-examples/cxx/tree/caching/library.xml @@ -0,0 +1,52 @@ + + + + + + + + 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/xsd-examples/cxx/tree/caching/library.xsd b/xsd-examples/cxx/tree/caching/library.xsd new file mode 100644 index 0000000..2dd5037 --- /dev/null +++ b/xsd-examples/cxx/tree/caching/library.xsd @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/compression/.gitignore b/xsd-examples/cxx/tree/compression/.gitignore new file mode 100644 index 0000000..f7293f9 --- /dev/null +++ b/xsd-examples/cxx/tree/compression/.gitignore @@ -0,0 +1,2 @@ +library.?xx +out.xml.gz diff --git a/xsd-examples/cxx/tree/compression/README b/xsd-examples/cxx/tree/compression/README new file mode 100644 index 0000000..f163970 --- /dev/null +++ b/xsd-examples/cxx/tree/compression/README @@ -0,0 +1,48 @@ +This example shows how to compress an XML document during serialization +and decompress it during parsing. The example uses the compression +functionality provided by the zlib library[1] which needs to be installed +in order to build and run this example. It should also be fairly straight- +forward to modify the code in this example to use other compression +libraries. + +[1] http://www.zlib.net + +The example consists of the following files: + +library.xsd + XML Schema which describes a library of books. + +library.xml.gz + Sample XML instance document compressed using the gzip format. + +compressed-format-target.hxx +compressed-format-target.cxx + Implementation of the Xerces-C++ XMLFormatTarget interface with the on- + the-fly compression support. You can use it in your application to add + XML compression. + +compressed-input-source.hxx +compressed-input-source.cxx + Implementation of the Xerces-C++ InputSource interface with the on-the- + fly decompression support. You can use it in your application to add + XML decompression. + +library.hxx +library.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 library.xsd. + +driver.cxx + Driver for the example. It first creates the compressed_input_source + object and passes it to one of the parsing functions that constructs + the object model from the compressed input file. It then prints the + content of the object model to STDERR. Finally, the driver creates the + compressed_format_target object and passes it to one of the serialization + functions which converts the object model back to the compressed XML. + +To run the example on the sample XML document simply execute: + +$ ./driver library.xml.gz + +The serialization output is written to the out.xml.gz file. diff --git a/xsd-examples/cxx/tree/compression/buildfile b/xsd-examples/cxx/tree/compression/buildfile new file mode 100644 index 0000000..6997339 --- /dev/null +++ b/xsd-examples/cxx/tree/compression/buildfile @@ -0,0 +1,28 @@ +# file : cxx/tree/compression/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} +import libs += libz%lib{z} + +./: exe{driver} file{library.xml.gz} doc{README} + +exe{driver}: {hxx cxx}{* -library} {hxx ixx cxx}{library} $libs testscript + +<{hxx ixx cxx}{library}>: xsd{library} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --generate-ostream \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-examples/cxx/tree/compression/compressed-format-target.cxx b/xsd-examples/cxx/tree/compression/compressed-format-target.cxx new file mode 100644 index 0000000..2d150a0 --- /dev/null +++ b/xsd-examples/cxx/tree/compression/compressed-format-target.cxx @@ -0,0 +1,152 @@ +// file : cxx/tree/compression/compressed-format-target.cxx +// copyright : not copyrighted - public domain + +#include +#include // std::memcpy + +#include "compressed-format-target.hxx" + +using namespace std; + +// +// compression_failure +// + +const char* compression_failure:: +what () const throw () +{ + return "compression failure"; +} + +// +// compressed_format_target +// + +compressed_format_target:: +compressed_format_target (ostream& os, compression_type t) + : os_ (os), closed_ (false), n_ (0) + { + zs_.zalloc = Z_NULL; + zs_.zfree = Z_NULL; + zs_.opaque = Z_NULL; + + int window = 0; + + switch (t) + { + case raw: + { + window = -15; + break; + } + case zlib: + { + window = 15; + break; + } + case gzip: + { + window = 16 + 15; + break; + } + } + + int r (deflateInit2 (&zs_, + Z_DEFAULT_COMPRESSION, + Z_DEFLATED, + window, + 8, + Z_DEFAULT_STRATEGY)); + if (r != Z_OK) + throw compression_failure (r); + } + +compressed_format_target:: +~compressed_format_target () +{ + try + { + // Close the free the compression stream. + // + if (!closed_) + close (); + } + catch (...) + { + } + + deflateEnd (&zs_); +} + +void compressed_format_target:: +writeChars (const XMLByte* const buf, + const XMLSize_t size, + xercesc::XMLFormatter* const) +{ + // Flush the buffer if the block is too large or if we don't have + // any space left. + // + if ((size >= buf_size_ / 8 || n_ + size > buf_size_) && n_ != 0) + { + write (in_, n_); + n_ = 0; + } + + if (size < buf_size_ / 8) + { + memcpy (in_ + n_, reinterpret_cast (buf), size); + n_ += size; + } + else + write (reinterpret_cast (buf), size); +} + + +void compressed_format_target:: +flush () +{ + if (n_ != 0) + { + write (in_, n_); + n_ = 0; + } + + if (!os_.fail ()) + os_.flush (); +} + +void compressed_format_target:: +close () +{ + write (in_, n_, true); + n_ = 0; + + if (!os_.fail ()) + os_.flush (); + + closed_ = true; +} + +void compressed_format_target:: +write (const char* buf, size_t size, bool flush) +{ + zs_.next_in = reinterpret_cast (const_cast (buf)); + zs_.avail_in = static_cast (size); + + do + { + zs_.next_out = reinterpret_cast (out_); + zs_.avail_out = buf_size_; + + int r (deflate (&zs_, flush ? Z_FINISH : Z_NO_FLUSH)); + + if (r != Z_OK && r != Z_BUF_ERROR && r != Z_STREAM_END) + throw compression_failure (r); + + size_t n (buf_size_ - zs_.avail_out); + + if (!os_.fail () && n > 0) + os_.write (out_, static_cast (n)); + + } while (zs_.avail_out == 0); +} diff --git a/xsd-examples/cxx/tree/compression/compressed-format-target.hxx b/xsd-examples/cxx/tree/compression/compressed-format-target.hxx new file mode 100644 index 0000000..0061cfa --- /dev/null +++ b/xsd-examples/cxx/tree/compression/compressed-format-target.hxx @@ -0,0 +1,91 @@ +// file : cxx/tree/compression/compressed-format-target.hxx +// copyright : not copyrighted - public domain + +#ifndef COMPRESSED_FORMAT_TARGET_HXX +#define COMPRESSED_FORMAT_TARGET_HXX + +#include + +#include +#include // std::size_t +#include + +#include + +struct compression_failure: std::exception +{ + explicit + compression_failure (int code) + : code_ (code) + { + } + + int + code () const + { + return code_; + } + + const char* + message () const + { + return zError (code_); + } + + virtual const char* + what () const throw (); + +private: + int code_; +}; + +// Xerces-C++ XMLFormatTarget interface implementation with on-the-fly, +// zlib-based compression. +// +class compressed_format_target: public xercesc::XMLFormatTarget +{ +public: + enum compression_type + { + raw, + zlib, + gzip + }; + + compressed_format_target (std::ostream&, compression_type); + + virtual + ~compressed_format_target (); + + virtual void + writeChars (const XMLByte* const buf, + const XMLSize_t size, + xercesc::XMLFormatter* const); + + virtual void + flush (); + + // Close the compressed stream by writing out the zlib or gzip trailer. + // This function is automatically called from the destructor but you + // may want to call it explicitly to be able to catch any exceptions + // that it might throw. + // + void + close (); + +private: + void + write (const char* buf, std::size_t size, bool flush = false); + +private: + std::ostream& os_; + z_stream zs_; + bool closed_; + + static const std::size_t buf_size_ = 65536; + char in_[buf_size_]; + char out_[buf_size_]; + size_t n_; +}; + +#endif // COMPRESSED_FORMAT_TARGET_HXX diff --git a/xsd-examples/cxx/tree/compression/compressed-input-source.cxx b/xsd-examples/cxx/tree/compression/compressed-input-source.cxx new file mode 100644 index 0000000..03be960 --- /dev/null +++ b/xsd-examples/cxx/tree/compression/compressed-input-source.cxx @@ -0,0 +1,195 @@ +// file : cxx/tree/compression/compressed-input-source.cxx +// copyright : not copyrighted - public domain + +#include + +#include + +#include "compressed-input-source.hxx" + +using namespace std; +using namespace xercesc; +namespace xml = xsd::cxx::xml; + +// +// decompression_failure +// + +const char* decompression_failure:: +what () const throw () +{ + return "decompression failure"; +} + +// +// compressed_input_source +// + +compressed_input_source:: +compressed_input_source (istream& is, compression_type t) + : is_ (&is), type_ (t) +{ +} + +compressed_input_source:: +compressed_input_source (istream& is, + compression_type t, + const string& sysid) + : InputSource (xml::string (sysid).c_str ()), is_ (&is), type_ (t) +{ +} + +compressed_input_source:: +compressed_input_source (istream& is, + compression_type t, + const string& sysid, + const string& pubid) + : xercesc::InputSource (xml::string (sysid).c_str (), + xml::string (pubid).c_str ()), + is_ (&is), + type_ (t) +{ +} + +BinInputStream* compressed_input_source:: +makeStream () const +{ + if (is_ == 0) + throw copy (); + + istream& is (*is_); + is_ = 0; + return new compressed_input_stream ( + is, static_cast (type_)); +} + +// +// compressed_input_stream +// + +compressed_input_stream:: +compressed_input_stream (istream& is, compression_type t) + : is_ (is), end_ (false), pos_ (0) +{ + zs_.zalloc = Z_NULL; + zs_.zfree = Z_NULL; + zs_.opaque = Z_NULL; + zs_.next_in = Z_NULL; + zs_.avail_in = 0; + + int window = 0; + + switch (t) + { + case raw: + { + window = -15; + break; + } + case zlib: + { + window = 15; + break; + } + case gzip: + { + window = 16 + 15; + break; + } + } + + int r (inflateInit2 (&zs_, window)); + + if (r != Z_OK) + throw decompression_failure (r); +} + +compressed_input_stream:: +~compressed_input_stream () +{ + inflateEnd (&zs_); +} + +XMLFilePos compressed_input_stream:: +curPos () const +{ + return static_cast (pos_); +} + +XMLSize_t compressed_input_stream:: +readBytes (XMLByte* const buf, const XMLSize_t size) +{ + if (end_) + return 0; + + // Keep calling inflate() until we fill up the buffer or reach the + // end of stream. If we run out of input data, call the underlying + // stream for more. + // + zs_.next_out = reinterpret_cast (buf); + zs_.avail_out = static_cast (size); + + int r; + + do + { + if (zs_.avail_in == 0) + { + zs_.avail_in = static_cast (read ()); + zs_.next_in = reinterpret_cast (const_cast (in_)); + + if (zs_.avail_in == 0) + throw decompression_failure (Z_DATA_ERROR); + } + + r = inflate (&zs_, Z_NO_FLUSH); + + if (r != Z_OK && r != Z_STREAM_END) + throw decompression_failure (r); + + } while (r != Z_STREAM_END && zs_.avail_out != 0); + + if (r == Z_STREAM_END) + end_ = true; + + size_t n (size - zs_.avail_out); + pos_ += n; + + return static_cast (n); +} + +const XMLCh* compressed_input_stream:: +getContentType () const +{ + return 0; +} + +size_t compressed_input_stream:: +read () +{ + // Some implementations don't clear gcount if you call read() on a + // stream that is in the eof state. + // + if (is_.eof ()) + return 0; + + // Unset the exception failbit while we are working with the stream. + // + ios_base::iostate old (is_.exceptions ()); + is_.exceptions (old & ~ios_base::failbit); + + is_.read (in_, static_cast (buf_size_)); + + // Clear the fail bit if it was caused by eof and restore the original + // exception state. If there are any pending errors then the exception + // will be thrown now. + // + if (is_.fail () && is_.eof ()) + is_.clear (is_.rdstate () & ~ios_base::failbit); + + is_.exceptions (old); + + // Make sure that if we failed, we won't be called again. + // + return !is_.fail () ? static_cast (is_.gcount ()) : 0; +} diff --git a/xsd-examples/cxx/tree/compression/compressed-input-source.hxx b/xsd-examples/cxx/tree/compression/compressed-input-source.hxx new file mode 100644 index 0000000..706433b --- /dev/null +++ b/xsd-examples/cxx/tree/compression/compressed-input-source.hxx @@ -0,0 +1,121 @@ +// file : cxx/tree/compression/compressed-input-source.hxx +// copyright : not copyrighted - public domain + +#ifndef COMPRESSED_INPUT_SOURCE_HXX +#define COMPRESSED_INPUT_SOURCE_HXX + +#include + +#include +#include +#include // std::size_t +#include + +#include +#include + +struct decompression_failure: std::exception +{ + explicit + decompression_failure (int code) + : code_ (code) + { + } + + int + code () const + { + return code_; + } + + const char* + message () const + { + return zError (code_); + } + + virtual const char* + what () const throw (); + +private: + int code_; +}; + +// Xerces-C++ InputSource interface implementation with on-the-fly, zlib- +// based decompression. +// +class compressed_input_source: public xercesc::InputSource +{ +public: + enum compression_type + { + raw, + zlib, + gzip + }; + + compressed_input_source (std::istream&, compression_type); + + compressed_input_source (std::istream&, + compression_type, + const std::string& system_id); + + compressed_input_source (std::istream&, + compression_type, + const std::string& system_id, + const std::string& public_id); + + struct copy {}; + + // Throws the copy exception if this function is called more than once. + // + virtual xercesc::BinInputStream* + makeStream () const; + +private: + mutable std::istream* is_; + compression_type type_; +}; + +// Xerces-C++ BinInputStream interface implementation with on-the-fly, zlib- +// based decompression. +// +class compressed_input_stream: public xercesc::BinInputStream +{ +public: + enum compression_type + { + raw, + zlib, + gzip + }; + + compressed_input_stream (std::istream&, compression_type); + + virtual + ~compressed_input_stream (); + + virtual XMLFilePos + curPos () const; + + virtual XMLSize_t + readBytes (XMLByte* const buf, const XMLSize_t size); + + virtual const XMLCh* + getContentType () const; + +private: + std::size_t + read (); + +private: + std::istream& is_; + z_stream zs_; + bool end_; + + static const std::size_t buf_size_ = 65536; + char in_[buf_size_]; + std::size_t pos_; // Current decompressed stream position. +}; + +#endif // COMPRESSED_INPUT_SOURCE_HXX diff --git a/xsd-examples/cxx/tree/compression/driver.cxx b/xsd-examples/cxx/tree/compression/driver.cxx new file mode 100644 index 0000000..15d842b --- /dev/null +++ b/xsd-examples/cxx/tree/compression/driver.cxx @@ -0,0 +1,124 @@ +// file : cxx/tree/compression/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include +#include + +#include + +#include "library.hxx" + +#include "compressed-input-source.hxx" +#include "compressed-format-target.hxx" + +using namespace std; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " library.xml.gz" << endl; + return 1; + } + + int r (0); + + // We need to initialize the Xerces-C++ runtime because we are + // using the Xerces-C++ input/output interfaces. + // + xercesc::XMLPlatformUtils::Initialize (); + + try + { + using namespace library; + + // Read in the XML file and obtain its object model. + // + ifstream ifs; + ifs.exceptions (ifstream::badbit | ifstream::failbit); + ifs.open (argv[1], ifstream::in | ifstream::binary); + + compressed_input_source cis (ifs, compressed_input_source::gzip, argv[1]); + + unique_ptr c ( + catalog_ (cis, xml_schema::flags::dont_initialize)); + + + // Let's print what we've got. + // + for (catalog::book_const_iterator bi (c->book ().begin ()); + bi != c->book ().end (); + ++bi) + { + cerr << endl + << "ID : " << bi->id () << endl + << "ISBN : " << bi->isbn () << endl + << "Title : " << bi->title () << endl + << "Genre : " << bi->genre () << endl; + + for (book::author_const_iterator ai (bi->author ().begin ()); + ai != bi->author ().end (); + ++ai) + { + cerr << "Author : " << ai->name () << endl; + cerr << " Born : " << ai->born () << endl; + + if (ai->died ()) + cerr << " Died : " << *ai->died () << endl; + + if (ai->recommends ()) + cerr << " Recommends : " << (*ai->recommends ())->title () << endl; + } + + cerr << "Available : " << std::boolalpha << bi->available () << endl; + } + + // Prepare namespace mapping and schema location information. + // + xml_schema::namespace_infomap map; + + map["lib"].name = "http://www.codesynthesis.com/library"; + map["lib"].schema = "library.xsd"; + + ofstream ofs; + ofs.exceptions (ofstream::badbit | ofstream::failbit | ofstream::eofbit); + ofs.open ("out.xml.gz", ofstream::out | ofstream::binary); + + compressed_format_target cft (ofs, compressed_format_target::gzip); + + // Write it out. + // + catalog_ (cft, *c, map, "UTF-8", xml_schema::flags::dont_initialize); + + // Write out the compression stream trailer. If we don't do this + // explicitly, it will be done automatically in the cft's destructor + // but then any exceptions that might be throws will be ignored. + // + cft.close(); + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + r = 1; + } + catch (const compression_failure& e) + { + cerr << "compression failure: " << e.message () << endl; + r = 1; + } + catch (const decompression_failure& e) + { + cerr << "decompression failure: " << e.message () << endl; + r = 1; + } + catch (const ios_base::failure&) + { + cerr << "file open or read/write failure" << endl; + r = 1; + } + + xercesc::XMLPlatformUtils::Terminate (); + return r; +} diff --git a/xsd-examples/cxx/tree/compression/library.xml.gz b/xsd-examples/cxx/tree/compression/library.xml.gz new file mode 100644 index 0000000..dd71159 Binary files /dev/null and b/xsd-examples/cxx/tree/compression/library.xml.gz differ diff --git a/xsd-examples/cxx/tree/compression/library.xsd b/xsd-examples/cxx/tree/compression/library.xsd new file mode 100644 index 0000000..a741e7e --- /dev/null +++ b/xsd-examples/cxx/tree/compression/library.xsd @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/compression/testscript b/xsd-examples/cxx/tree/compression/testscript new file mode 100644 index 0000000..649de5a --- /dev/null +++ b/xsd-examples/cxx/tree/compression/testscript @@ -0,0 +1,4 @@ +# file : cxx/tree/compression/testscript +# license : not copyrighted - public domain + +$* $src_base/library.xml.gz &out.xml.gz 2>| : compressed-out diff --git a/xsd-examples/cxx/tree/custom/README b/xsd-examples/cxx/tree/custom/README new file mode 100644 index 0000000..b2a65b5 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/README @@ -0,0 +1,40 @@ +This directory contains a number of examples that show how to customize the +C++/Tree mapping. The following list gives an overview of each example: + +calendar + Shows how to customize XML Schema built-in types by mapping xsd:date + built-in type to the date class from the Boost date_time library. + +comments + 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. + +contacts + Shows how to map a user-defined XML Schema type to a custom C++ class. + This example presents the simple case where the customized type is not + used as a base in the same schema. + +double + Shows how to customize parsing and serialization code for the xsd:double + XML Schema built-in type. It can be used as a guide on how to customize + built-in XML Schema types that are mapped to fundamental C++ types. + +mixed + Shows how to use type customization to parse and serialize mixed content. + +taxonomy + Shows how to map user-defined XML Schema types to custom C++ classes. + This example presents the complex case where the customized types are + inherited from in the same schema. + +wildcard + Shows how to use type customization to parse and serialize a specific + attribute that is matched by a wildcard (anyAttribute). + +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 diff --git a/xsd-examples/cxx/tree/custom/buildfile b/xsd-examples/cxx/tree/custom/buildfile new file mode 100644 index 0000000..e650f99 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/buildfile @@ -0,0 +1,6 @@ +# file : cxx/tree/custom/buildfile +# license : not copyrighted - public domain + +# Exclude examples which depend on not yet packaged libraries. +# +./: {*/ -calendar/} diff --git a/xsd-examples/cxx/tree/custom/calendar/.gitignore b/xsd-examples/cxx/tree/custom/calendar/.gitignore new file mode 100644 index 0000000..2f35b6b --- /dev/null +++ b/xsd-examples/cxx/tree/custom/calendar/.gitignore @@ -0,0 +1,2 @@ +calendar.?xx +xml-schema.hxx diff --git a/xsd-examples/cxx/tree/custom/calendar/README b/xsd-examples/cxx/tree/custom/calendar/README new file mode 100644 index 0000000..f7f6989 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/calendar/README @@ -0,0 +1,47 @@ +This example shows how to customize the XML Schema built-in types by mapping +xsd:date built-in type to the date class from the Boost date_time library. +You will need the Boost date_time library[1] installed in order to build +and run this example. For more information on the C++/Tree mapping +customization see the C++/Tree Mapping Customization Guide[2]. + +[1] http://www.boost.org +[2] http://wiki.codesynthesis.com/Tree/Customization_guide + +The example consists of the following files: + +calendar.xsd + XML Schema definition for a simple calendar format. + +calendar.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:date type. + +calendar.hxx +calendar.ixx +calendar.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 calendar.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::date 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:date + 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 calendar events to STDERR. + +To run the example on the sample XML instance document simply execute: + +$ ./driver calendar.xml diff --git a/xsd-examples/cxx/tree/custom/calendar/buildfile b/xsd-examples/cxx/tree/custom/calendar/buildfile new file mode 100644 index 0000000..3c26122 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/calendar/buildfile @@ -0,0 +1,47 @@ +# file : cxx/tree/custom/calendar/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} +import libs += libboost-date-time%lib{boost_date_time} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -calendar -xml-schema} \ + {hxx ixx cxx}{calendar} \ + {hxx }{xml-schema} \ + $libs + +exe{driver}: xml{calendar}: test.input = true + +<{hxx ixx cxx}{calendar}>: xsd{calendar} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --extern-xml-schema xml-schema.xsd \ + --output-dir $out_base \ + $path($<[0]) +}} + +hxx{xml-schema}: $xsd +{{ + diag xsd gen ($>[0]) + + # Note that the specified xml-schema.xsd doesn't exist and is only used to + # deduce the generated header name. + # + $xsd cxx-tree --std c++11 \ + --generate-xml-schema \ + --custom-type date \ + --hxx-epilogue '#include "xml-schema-custom.hxx"' \ + --output-dir $out_base \ + xml-schema.xsd +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-examples/cxx/tree/custom/calendar/calendar.xml b/xsd-examples/cxx/tree/custom/calendar/calendar.xml new file mode 100644 index 0000000..8fff59c --- /dev/null +++ b/xsd-examples/cxx/tree/custom/calendar/calendar.xml @@ -0,0 +1,22 @@ + + + + + + + + Don't forget to change the tire. + + + + Can be cancelled if it is too cold. + + + diff --git a/xsd-examples/cxx/tree/custom/calendar/calendar.xsd b/xsd-examples/cxx/tree/custom/calendar/calendar.xsd new file mode 100644 index 0000000..8b36c34 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/calendar/calendar.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/custom/calendar/driver.cxx b/xsd-examples/cxx/tree/custom/calendar/driver.cxx new file mode 100644 index 0000000..fdecf57 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/calendar/driver.cxx @@ -0,0 +1,39 @@ +// file : cxx/tree/custom/calendar/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include + +#include "calendar.hxx" + +using std::cerr; +using std::endl; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " calendar.xml" << endl; + return 1; + } + + try + { + using namespace calendar; + + std::unique_ptr e (events_ (argv[1])); + + for (events::event_const_iterator i (e->event ().begin ()); + i != e->event ().end (); ++i) + { + cerr << i->date () << " " << i->title () << endl + << *i << endl; + } + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-examples/cxx/tree/custom/calendar/xml-schema-custom.cxx b/xsd-examples/cxx/tree/custom/calendar/xml-schema-custom.cxx new file mode 100644 index 0000000..2bfe0f2 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/calendar/xml-schema-custom.cxx @@ -0,0 +1,56 @@ +// file : cxx/tree/custom/calendar/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 // xsd::cxx::xml::transcode +#include // xsd::cxx::tree::text_content + +using namespace boost; +using namespace boost::gregorian; + +namespace xml_schema +{ + date:: + date (const xercesc::DOMElement& e, flags f, container* c) + : simple_type (e, f, c), + gregorian::date ( + from_simple_string ( + xsd::cxx::tree::text_content (e))) + { + } + + date:: + date (const xercesc::DOMAttr& a, flags f, container* c) + : simple_type (a, f, c), + gregorian::date ( + from_simple_string ( + xsd::cxx::xml::transcode (a.getValue ()))) + { + } + + date:: + date (const std::string& s, + const xercesc::DOMElement* e, + flags f, + container* c) + : simple_type (s, e, f, c), + gregorian::date (from_simple_string (s)) + { + } + + date:: + date (const date& d, flags f, container* c) + : simple_type (d, f, c), + gregorian::date (d) + { + } + + date* date:: + _clone (flags f, container* c) const + { + return new date (*this, f, c); + } +} diff --git a/xsd-examples/cxx/tree/custom/calendar/xml-schema-custom.hxx b/xsd-examples/cxx/tree/custom/calendar/xml-schema-custom.hxx new file mode 100644 index 0000000..f8f8218 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/calendar/xml-schema-custom.hxx @@ -0,0 +1,33 @@ +// file : cxx/tree/custom/calendar/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 // boost::gregorian::date + +namespace xml_schema +{ + class date: public simple_type, + public boost::gregorian::date + { + public: + // Parsing c-tors: element, attribute, and list item. + // + date (const xercesc::DOMElement&, flags = 0, container* = 0); + date (const xercesc::DOMAttr&, flags = 0, container* = 0); + date (const std::string&, + const xercesc::DOMElement*, + flags = 0, + container* = 0); + + // Copy c-tor and _clone. + // + date (const date&, flags = 0, container* = 0); + + virtual date* + _clone (flags = 0, container* = 0) const; + }; +} diff --git a/xsd-examples/cxx/tree/custom/comments/.gitignore b/xsd-examples/cxx/tree/custom/comments/.gitignore new file mode 100644 index 0000000..78cfc67 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/comments/.gitignore @@ -0,0 +1,2 @@ +people.?xx +xml-schema.hxx diff --git a/xsd-examples/cxx/tree/custom/comments/README b/xsd-examples/cxx/tree/custom/comments/README new file mode 100644 index 0000000..8fd69d0 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/comments/README @@ -0,0 +1,57 @@ +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/xsd-examples/cxx/tree/custom/comments/buildfile b/xsd-examples/cxx/tree/custom/comments/buildfile new file mode 100644 index 0000000..093a6cc --- /dev/null +++ b/xsd-examples/cxx/tree/custom/comments/buildfile @@ -0,0 +1,48 @@ +# file : cxx/tree/custom/comments/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -people -xml-schema} \ + {hxx ixx cxx}{people} \ + {hxx }{xml-schema} \ + $libs + +exe{driver}: xml{people}: test.input = true + +<{hxx ixx cxx}{people}>: xsd{people} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --extern-xml-schema xml-schema.xsd \ + --output-dir $out_base \ + $path($<[0]) +}} + +hxx{xml-schema}: $xsd +{{ + diag xsd gen ($>[0]) + + # Note that the specified xml-schema.xsd doesn't exist and is only used to + # deduce the generated header name. + # + $xsd cxx-tree --std c++11 \ + --generate-xml-schema \ + --generate-serialization \ + --custom-type anyType=/type_base \ + --hxx-epilogue '#include "xml-schema-custom.hxx"' \ + --output-dir $out_base \ + xml-schema.xsd +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-examples/cxx/tree/custom/comments/dom-parse.cxx b/xsd-examples/cxx/tree/custom/comments/dom-parse.cxx new file mode 100644 index 0000000..2fa6a70 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/comments/dom-parse.cxx @@ -0,0 +1,93 @@ +// file : 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::unique_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::unique_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::unique_ptr doc (parser->parse (&wrap)); + + eh.throw_if_failed > (); + + return doc; +} diff --git a/xsd-examples/cxx/tree/custom/comments/dom-parse.hxx b/xsd-examples/cxx/tree/custom/comments/dom-parse.hxx new file mode 100644 index 0000000..83c3dd4 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/comments/dom-parse.hxx @@ -0,0 +1,23 @@ +// file : 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::unique_ptr +parse (std::istream& is, + const std::string& id, + bool validate); + +#endif // DOM_PARSE diff --git a/xsd-examples/cxx/tree/custom/comments/driver.cxx b/xsd-examples/cxx/tree/custom/comments/driver.cxx new file mode 100644 index 0000000..5588273 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/comments/driver.cxx @@ -0,0 +1,90 @@ +// file : cxx/tree/custom/commens/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_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::unique_ptr doc ( + parse (ifs, argv[1], true)); + + // Parse the DOM document to the object model. + // + unique_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/xsd-examples/cxx/tree/custom/comments/people.xml b/xsd-examples/cxx/tree/custom/comments/people.xml new file mode 100644 index 0000000..08d69e9 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/comments/people.xml @@ -0,0 +1,20 @@ + + + + + + + + + Joe Dirt + 28 + + + diff --git a/xsd-examples/cxx/tree/custom/comments/people.xsd b/xsd-examples/cxx/tree/custom/comments/people.xsd new file mode 100644 index 0000000..20f265f --- /dev/null +++ b/xsd-examples/cxx/tree/custom/comments/people.xsd @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/custom/comments/xml-schema-custom.cxx b/xsd-examples/cxx/tree/custom/comments/xml-schema-custom.cxx new file mode 100644 index 0000000..265e0cb --- /dev/null +++ b/xsd-examples/cxx/tree/custom/comments/xml-schema-custom.cxx @@ -0,0 +1,117 @@ +// file : 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/xsd-examples/cxx/tree/custom/comments/xml-schema-custom.hxx b/xsd-examples/cxx/tree/custom/comments/xml-schema-custom.hxx new file mode 100644 index 0000000..01a4f9c --- /dev/null +++ b/xsd-examples/cxx/tree/custom/comments/xml-schema-custom.hxx @@ -0,0 +1,60 @@ +// file : 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); + + type& + operator= (const type&) = default; + + 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&); +} diff --git a/xsd-examples/cxx/tree/custom/contacts/.gitignore b/xsd-examples/cxx/tree/custom/contacts/.gitignore new file mode 100644 index 0000000..43c214d --- /dev/null +++ b/xsd-examples/cxx/tree/custom/contacts/.gitignore @@ -0,0 +1 @@ +contacts.?xx diff --git a/xsd-examples/cxx/tree/custom/contacts/README b/xsd-examples/cxx/tree/custom/contacts/README new file mode 100644 index 0000000..072ede3 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/contacts/README @@ -0,0 +1,40 @@ +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/xsd-examples/cxx/tree/custom/contacts/buildfile b/xsd-examples/cxx/tree/custom/contacts/buildfile new file mode 100644 index 0000000..190306c --- /dev/null +++ b/xsd-examples/cxx/tree/custom/contacts/buildfile @@ -0,0 +1,25 @@ +# file : cxx/tree/custom/contacts/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -contacts} {hxx ixx cxx}{contacts} $libs + +exe{driver}: xml{contacts}: test.input = true + +<{hxx ixx cxx}{contacts}>: xsd{contacts} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --custom-type contact=/contact_base \ + --hxx-epilogue '#include "contacts-custom.hxx"' \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/xsd-examples/cxx/tree/custom/contacts/contacts-custom.cxx b/xsd-examples/cxx/tree/custom/contacts/contacts-custom.cxx new file mode 100644 index 0000000..208b00f --- /dev/null +++ b/xsd-examples/cxx/tree/custom/contacts/contacts-custom.cxx @@ -0,0 +1,50 @@ +// file : cxx/tree/custom/contacts/contacts-custom.cxx +// copyright : not copyrighted - public domain + +#include + +// 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/xsd-examples/cxx/tree/custom/contacts/contacts-custom.hxx b/xsd-examples/cxx/tree/custom/contacts/contacts-custom.hxx new file mode 100644 index 0000000..a5bc893 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/contacts/contacts-custom.hxx @@ -0,0 +1,43 @@ +// file : 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 // 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/xsd-examples/cxx/tree/custom/contacts/contacts.xml b/xsd-examples/cxx/tree/custom/contacts/contacts.xml new file mode 100644 index 0000000..884c25e --- /dev/null +++ b/xsd-examples/cxx/tree/custom/contacts/contacts.xml @@ -0,0 +1,20 @@ + + + + + + + + Joe Dirt + joe@dirt.com + 555 DIRT + + + diff --git a/xsd-examples/cxx/tree/custom/contacts/contacts.xsd b/xsd-examples/cxx/tree/custom/contacts/contacts.xsd new file mode 100644 index 0000000..5348810 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/contacts/contacts.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/custom/contacts/driver.cxx b/xsd-examples/cxx/tree/custom/contacts/driver.cxx new file mode 100644 index 0000000..a0c7510 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/contacts/driver.cxx @@ -0,0 +1,38 @@ +// file : cxx/tree/custom/contacts/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include + +#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::unique_ptr 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/xsd-examples/cxx/tree/custom/double/.gitignore b/xsd-examples/cxx/tree/custom/double/.gitignore new file mode 100644 index 0000000..5cc7f75 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/double/.gitignore @@ -0,0 +1,2 @@ +order.?xx +xml-schema.hxx diff --git a/xsd-examples/cxx/tree/custom/double/README b/xsd-examples/cxx/tree/custom/double/README new file mode 100644 index 0000000..15348d2 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/double/README @@ -0,0 +1,62 @@ +This example shows how to customize parsing and serialization code for the +xsd:double XML Schema built-in type using the type customization mechanism +provided by the C++/Tree Mapping. For more information on type customization +see the C++/Tree Mapping Customization Guide, particularly sections 1 and 4: + +http://wiki.codesynthesis.com/Tree/Customization_guide + +In this example our schema uses xsd:double to represent a price. There are +two potential problems with this choice of a price type. First, xsd:double +can be serialized in the scientific notation which would be an unusual way +of representing a price. Second, we would like to limit the number of +fraction digits in our prices to 2. Furthermore, we would like to always +have two fraction digits, even if one or both of them are zeros, for +example: 12.99, 12.90, 12.00. + +In case we can modify the schema, a better approach would be to define the +price type as a restriction of the xsd:decimal type (always fixed notation) +and specify the fractionDigits facet to limit the number of fraction digits +to 2. However, there is no way in XML Schema to specify that there should +always be exactly 2 fraction digits. Therefore, it may still be desirable +to customize this price type to get the required serialization behavior. + +Finally, it is worth noting that the behavior achieved in this example via +type customization can also be achieved by compiling your code with the +following macros defined: + +XSD_TREE_DOUBLE_FIXED +XSD_TREE_DOUBLE_PRECISION 2 + +However, the type customization approach while requiring more work is +cleaner since it does not rely on global macro definitions. + +This example consists of the following files: + +order.xsd + XML Schema definition for a simple order vocabulary. + +double-custom.hxx +double-custom.cxx + Custom parsing and serialization code for the xsd:double types. The + double-custom.hxx file is included at the end of the xml-schema.hxx + file described below. + +xml-schema.hxx + C++ types for XML Schema built-in types. This header file is generated + by the XSD compiler using the --generate-xml-schema option. The + --custom-type option is used to customize the xsd:double type. The + --hxx-epilogue option is used to include the double-custom.hxx file + at the end of this file. + +order.hxx +order.cxx + C++ types generated from order.xsd. The --extern-xml-schema option + is used to include xml-schema.hxx into order.hxx. + +driver.cxx + Test driver for the example. It creates a sample order and then + writes it to XML to test the custom xsd:double serialization code. + +To run the example simply execute: + +$ ./driver diff --git a/xsd-examples/cxx/tree/custom/double/buildfile b/xsd-examples/cxx/tree/custom/double/buildfile new file mode 100644 index 0000000..258191a --- /dev/null +++ b/xsd-examples/cxx/tree/custom/double/buildfile @@ -0,0 +1,46 @@ +# file : cxx/tree/custom/double/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -order -xml-schema} \ + {hxx ixx cxx}{order} \ + {hxx }{xml-schema} \ + $libs + +<{hxx ixx cxx}{order}>: xsd{order} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --extern-xml-schema xml-schema.xsd \ + --output-dir $out_base \ + $path($<[0]) +}} + +hxx{xml-schema}: $xsd +{{ + diag xsd gen ($>[0]) + + # Note that the specified xml-schema.xsd doesn't exist and is only used to + # deduce the generated header name. + # + $xsd cxx-tree --std c++11 \ + --generate-xml-schema \ + --generate-serialization \ + --custom-type double=double \ + --hxx-epilogue '#include "double-custom.hxx"' \ + --output-dir $out_base \ + xml-schema.xsd +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-examples/cxx/tree/custom/double/double-custom.cxx b/xsd-examples/cxx/tree/custom/double/double-custom.cxx new file mode 100644 index 0000000..bfec6e0 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/double/double-custom.cxx @@ -0,0 +1,96 @@ +// file : cxx/tree/custom/double/double-custom.cxx +// copyright : not copyrighted - public domain + +// Include xml-schema.hxx instead of double-custom.hxx here. +// +#include "xml-schema.hxx" + +#include +#include +#include + +#include +#include + +using namespace std; + +// Parsing. +// +namespace xsd +{ + namespace cxx + { + namespace tree + { + double traits:: + create (const std::string& s, + const xercesc::DOMElement*, + flags, + type*) + { + // This type cannot have whitespaces in its values. As result we + // don't need to waste time collapsing whitespaces. All we need to + // do is trim the string representation which can be done without + // copying. + // + ro_string tmp (s); + trim (tmp); + + zc_istream is (tmp); + is.imbue (locale::classic ()); + + double t; + is >> t; + + return t; + } + } + } +} + +// Serialization. +// +namespace XERCES_CPP_NAMESPACE +{ + void + operator<< (xercesc::DOMElement& e, const xml_schema::as_double& d) + { + ostringstream os; + os.imbue (locale::classic ()); + + os.precision (2); + os << fixed << d.x; + + e << os.str (); + } + + void + operator<< (xercesc::DOMAttr& a, const xml_schema::as_double& d) + { + ostringstream os; + os.imbue (locale::classic ()); + + os.precision (2); + os << fixed << d.x; + + a << os.str (); + } +} + +namespace xsd +{ + namespace cxx + { + namespace tree + { + void + operator<< (xml_schema::list_stream& ls, + const xml_schema::as_double& d) + { + ls.os_.imbue (locale::classic ()); + ls.os_.precision (2); + ls.os_ << fixed << d.x; + } + } + } +} diff --git a/xsd-examples/cxx/tree/custom/double/double-custom.hxx b/xsd-examples/cxx/tree/custom/double/double-custom.hxx new file mode 100644 index 0000000..cb74442 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/double/double-custom.hxx @@ -0,0 +1,67 @@ +// file : cxx/tree/custom/double/double-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 // xml::transcode +#include // text_content + +// Parsing. +// +namespace xsd +{ + namespace cxx + { + namespace tree + { + template<> + struct traits + { + static double + create (const xercesc::DOMElement& e, flags f, type* c) + { + return create (text_content (e), 0, f, c); + } + + static double + create (const xercesc::DOMAttr& a, flags f, type* c) + { + return create (xml::transcode (a.getValue ()), 0, f, c); + } + + static double + create (const std::string& s, + const xercesc::DOMElement*, + flags, + type*); + }; + } + } +} + +// Serialization. +// +namespace XERCES_CPP_NAMESPACE +{ + void + operator<< (xercesc::DOMElement& e, const xml_schema::as_double& d); + + void + operator<< (xercesc::DOMAttr& a, const xml_schema::as_double& d); +} + +namespace xsd +{ + namespace cxx + { + namespace tree + { + void + operator<< (xml_schema::list_stream& ls, + const xml_schema::as_double& d); + } + } +} diff --git a/xsd-examples/cxx/tree/custom/double/driver.cxx b/xsd-examples/cxx/tree/custom/double/driver.cxx new file mode 100644 index 0000000..e3f1800 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/double/driver.cxx @@ -0,0 +1,31 @@ +// file : cxx/tree/custom/double/driver.cxx +// copyright : not copyrighted - public domain + +#include + +#include "order.hxx" + +using std::cerr; +using std::endl; + +int +main () +{ + try + { + // Order one Airbus A380. + // + order o; + o.item ().push_back (item ("Airbus A380", 317000000.90)); + + + // Serialize. + // + order_ (std::cout, o); + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-examples/cxx/tree/custom/double/order.xsd b/xsd-examples/cxx/tree/custom/double/order.xsd new file mode 100644 index 0000000..8066975 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/double/order.xsd @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/custom/mixed/.gitignore b/xsd-examples/cxx/tree/custom/mixed/.gitignore new file mode 100644 index 0000000..83d0a51 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/mixed/.gitignore @@ -0,0 +1 @@ +people.?xx diff --git a/xsd-examples/cxx/tree/custom/mixed/README b/xsd-examples/cxx/tree/custom/mixed/README new file mode 100644 index 0000000..7b56812 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/mixed/README @@ -0,0 +1,50 @@ +This example shows how to use type customization to parse and serialize +mixed content. The example achieves this by customizing the type with +the mixed content model to include a DOM document that stores the data +as a raw XML representation. The customized type also provides its own +parsing constructor and serialization operator where the mixed content +is extracted from and inserted back to DOM, respectively. The use of +DOM for mixed content storage is one of the options. You may find other +data structures (e.g., a string) more suitable depending on your situation. + +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: + +people.xsd + XML Schema definition for a simple person record vocabulary. Each + record includes the bio element which represents arbitrary XHTML + fragments as mixed content. + +people.xml + Sample XML instance document. + +people.hxx +people.ixx +people.cxx + C++ types that represent the given 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 --custom-type option in order to customize the bio type. + +people-custom.hxx + Header file which defines our own bio class by inheriting from the + generated bio_base. It is included at the end of people.hxx using + the --hxx-epilogue option. + +people-custom.cxx + Source file which contains the implementation of our bio 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 data to STDERR, including the bio information converted to text. + Finally, the driver serializes the object model back to XML. + +To run the example on the sample XML instance document simply execute: + +$ ./driver people.xml diff --git a/xsd-examples/cxx/tree/custom/mixed/buildfile b/xsd-examples/cxx/tree/custom/mixed/buildfile new file mode 100644 index 0000000..9da936e --- /dev/null +++ b/xsd-examples/cxx/tree/custom/mixed/buildfile @@ -0,0 +1,30 @@ +# file : cxx/tree/custom/mixed/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -people} {hxx ixx cxx}{people} $libs + +exe{driver}: xml{people}: test.input = true + +<{hxx ixx cxx}{people}>: xsd{people} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --custom-type bio=/bio_base \ + --hxx-epilogue '#include "people-custom.hxx"' \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-examples/cxx/tree/custom/mixed/driver.cxx b/xsd-examples/cxx/tree/custom/mixed/driver.cxx new file mode 100644 index 0000000..08c83e0 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/mixed/driver.cxx @@ -0,0 +1,122 @@ +// file : cxx/tree/custom/mixed/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include + +#include +#include + +#include "people.hxx" + +// The following transcode() utility function is handy when working with +// Xerces. Include it after the generated header in order to get only char +// or wchar_t version depending on how you compiled your schemas. +// +#include + +using std::cerr; +using std::endl; +using namespace xercesc; + +void +xhtml2txt (const DOMElement*); + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " people.xml" << endl; + return 1; + } + + int r (0); + + // The Xerces-C++ DOM document that will be used to store the XHTML + // fragments "out-live" the call to the parsing function. Therefore + // we need to initialize the Xerces-C++ runtime ourselves. + // + XMLPlatformUtils::Initialize (); + + try + { + using namespace people; + + // Parse. + // + std::unique_ptr d ( + directory_ (argv[1], xml_schema::flags::dont_initialize)); + + // Print what we've got. + // + const directory::person_sequence& s (d->person ()); + + for (directory::person_const_iterator i (s.begin ()); i != s.end (); ++i) + { + cerr << "First : " << i->first_name () << endl + << "Last : " << i->last_name () << endl + << "Gender : " << i->gender () << endl + << "Age : " << i->age () << endl; + + const bio& b (i->bio ()); + const DOMElement* xhtml (b.xhtml ()); + + if (xhtml != 0) + { + cerr << "Bio : " << endl; + xhtml2txt (xhtml); + } + + cerr << endl; + } + + // Serialize. + // + xml_schema::namespace_infomap map; + + map["ppl"].name = "http://www.codesynthesis.com/people"; + map["ppl"].schema = "people.xsd"; + + directory_ ( + std::cout, *d, map, "UTF-8", xml_schema::flags::dont_initialize); + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + r = 1; + } + + XMLPlatformUtils::Terminate (); + return r; +} + +// Primitive XHTML to text converter that just prints all the text +// nodes and ignores everything else. +// +void +xhtml2txt (const DOMElement* e) +{ + namespace xml = xsd::cxx::xml; + + for (const DOMNode* n (e->getFirstChild ()); + n != 0; + n = n->getNextSibling ()) + { + switch (n->getNodeType ()) + { + case DOMNode::TEXT_NODE: + { + cerr << xml::transcode (n->getTextContent ()); + break; + } + case DOMNode::ELEMENT_NODE: + { + xhtml2txt (static_cast (n)); + break; + } + default: + break; // Ignore all other nodes (e.g., comments, etc). + } + } +} diff --git a/xsd-examples/cxx/tree/custom/mixed/people-custom.cxx b/xsd-examples/cxx/tree/custom/mixed/people-custom.cxx new file mode 100644 index 0000000..bd03fcc --- /dev/null +++ b/xsd-examples/cxx/tree/custom/mixed/people-custom.cxx @@ -0,0 +1,89 @@ +// file : cxx/tree/custom/mixed/people-custom.cxx +// copyright : not copyrighted - public domain + +#include + +// Include people.hxx instead of people-custom.hxx here. +// +#include "people.hxx" + +namespace people +{ + using namespace xercesc; + + const XMLCh ls[] = {chLatin_L, chLatin_S, chNull}; + + bio:: + bio () + : xhtml_ (0) + { + DOMImplementation* impl ( + DOMImplementationRegistry::getDOMImplementation (ls)); + + doc_.reset (impl->createDocument ()); + } + + bio:: + bio (const DOMElement& e, + xml_schema::flags f, + xml_schema::container* c) + : bio_base (e, f, c), xhtml_ (0) + { + DOMImplementation* impl ( + DOMImplementationRegistry::getDOMImplementation (ls)); + + doc_.reset (impl->createDocument ()); + + // Copy the xhtml element. Assume the first child element in + // e is always xhtml. + // + for (DOMNode* n (e.getFirstChild ()); n != 0; n = n->getNextSibling ()) + { + if (n->getNodeType () == DOMNode::ELEMENT_NODE) + { + xhtml_ = static_cast (doc_->importNode (n, true)); + break; + } + } + } + + bio:: + bio (const bio& d, + xml_schema::flags f, + xml_schema::container* c) + : bio_base (d, f, c), xhtml_ (0) + { + DOMImplementation* impl ( + DOMImplementationRegistry::getDOMImplementation (ls)); + + doc_.reset (impl->createDocument ()); + + xhtml_ = static_cast ( + doc_->importNode (const_cast (d.xhtml_), true)); + } + + bio* bio:: + _clone (xml_schema::flags f, xml_schema::container* c) const + { + return new bio (*this, f, c); + } + + void + operator<< (DOMElement& e, const bio& x) + { + // Allow our base to serialize first. + // + const bio_base& b (x); + e << b; + + // Copy the XHTML fragment if we have one. + // + const DOMElement* xhtml (x.xhtml ()); + + if (xhtml != 0) + { + DOMDocument* doc (e.getOwnerDocument ()); + e.appendChild (doc->importNode (const_cast (xhtml), true)); + } + } +} diff --git a/xsd-examples/cxx/tree/custom/mixed/people-custom.hxx b/xsd-examples/cxx/tree/custom/mixed/people-custom.hxx new file mode 100644 index 0000000..2ab949d --- /dev/null +++ b/xsd-examples/cxx/tree/custom/mixed/people-custom.hxx @@ -0,0 +1,83 @@ +// file : cxx/tree/custom/mixed/people-custom.hxx +// copyright : not copyrighted - public domain + +// Do not include this file directly, use people.hxx instead. This +// file is included into generated people.hxx so we do not need to +// guard against multiple inclusions. +// + +#include +#include + +namespace people +{ + class bio: public bio_base + { + // Standard constructors. + // + public: + bio (); + + bio (const xercesc::DOMElement&, + xml_schema::flags = 0, + xml_schema::container* = 0); + + bio (const bio&, + xml_schema::flags = 0, + xml_schema::container* = 0); + + virtual bio* + _clone (xml_schema::flags = 0, + xml_schema::container* = 0) const; + + // XHTML bio as a DOM document. + // + public: + const xercesc::DOMElement* + xhtml () const + { + return xhtml_; + } + + xercesc::DOMElement* + xhtml () + { + return xhtml_; + } + + // The element should belong to the DOMDocument returned by + // the dom_document() functions. + // + void + xhtml (xercesc::DOMElement* e) + { + assert (e->getOwnerDocument () == doc_.get ()); + + if (xhtml_ != 0) + xhtml_->release (); + + xhtml_ = e; + } + + const xercesc::DOMDocument& + dom_document () const + { + return *doc_; + } + + xercesc::DOMDocument& + dom_document () + { + return *doc_; + } + + private: + xercesc::DOMElement* xhtml_; + xml_schema::dom::unique_ptr doc_; + }; + + // Serialization operator. + // + void + operator<< (xercesc::DOMElement&, const bio&); +} diff --git a/xsd-examples/cxx/tree/custom/mixed/people.xml b/xsd-examples/cxx/tree/custom/mixed/people.xml new file mode 100644 index 0000000..4033f95 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/mixed/people.xml @@ -0,0 +1,38 @@ + + + + + + + + John + Doe + male + 32 + + +

Married to Jane Doe.

+
+
+
+ + + Jane + Doe + female + 28 + + +

Married to John Doe.

+
+
+
+ +
diff --git a/xsd-examples/cxx/tree/custom/mixed/people.xsd b/xsd-examples/cxx/tree/custom/mixed/people.xsd new file mode 100644 index 0000000..739861b --- /dev/null +++ b/xsd-examples/cxx/tree/custom/mixed/people.xsd @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/custom/taxonomy/.gitignore b/xsd-examples/cxx/tree/custom/taxonomy/.gitignore new file mode 100644 index 0000000..71428ab --- /dev/null +++ b/xsd-examples/cxx/tree/custom/taxonomy/.gitignore @@ -0,0 +1,2 @@ +people.?xx +people-fwd.hxx diff --git a/xsd-examples/cxx/tree/custom/taxonomy/README b/xsd-examples/cxx/tree/custom/taxonomy/README new file mode 100644 index 0000000..c2e425a --- /dev/null +++ b/xsd-examples/cxx/tree/custom/taxonomy/README @@ -0,0 +1,53 @@ +This example shows how to map user-defined XML Schema types to custom C++ +classes. It presents the complex case where the customized types are +inherited from in the same schema. For the simple case see the contacts +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: + +people.xsd + XML Schema definition for a simple people database. + +people.xml + Sample XML instance document. + +people-fwd.hxx +people.hxx +people.ixx +people.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 people.xsd with the + --custom-type option in order to customize the person, superman, and + batman types. Generation of the people-fwd.hxx forward declaration + file is requested with the --generate-forward option. Note also that + we use the --generate-polymorphic command line option as well as + --polymorphic-type to mark the type hierarchy starting with the + person type as polymorphic. + +people-custom-fwd.hxx + Header file which forward-declares our own person, superman, and batman + as class templates. It is included at the beginning of people-fwd.hxx + using the --fwd-prologue option. + +people-custom.hxx + Header file which defines our own person, superman, and batman class + templates by inheriting from the generated person_base, superman_base, + and batman_base. It is included at the beginning of people.hxx using + the --hxx-prologue option. + +people-custom.cxx + Source file which contains the implementations and instantiations of + our person, superman, and batman class templates. + +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 database to STDERR. + +To run the example on the sample XML instance document simply execute: + +$ ./driver people.xml diff --git a/xsd-examples/cxx/tree/custom/taxonomy/buildfile b/xsd-examples/cxx/tree/custom/taxonomy/buildfile new file mode 100644 index 0000000..9267c68 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/taxonomy/buildfile @@ -0,0 +1,31 @@ +# file : cxx/tree/custom/taxonomy/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -people} {hxx ixx cxx}{people} hxx{people-fwd} $libs + +exe{driver}: xml{people}: test.input = true + +<{hxx ixx cxx}{people} hxx{people-fwd}>: xsd{people} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-forward \ + --generate-polymorphic \ + --polymorphic-type person \ + --custom-type "person=person_impl/person_base" \ + --custom-type "superman=superman_impl/superman_base" \ + --custom-type "batman=batman_impl/batman_base" \ + --fwd-prologue '#include "people-custom-fwd.hxx"' \ + --hxx-prologue '#include "people-custom.hxx"' \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/xsd-examples/cxx/tree/custom/taxonomy/driver.cxx b/xsd-examples/cxx/tree/custom/taxonomy/driver.cxx new file mode 100644 index 0000000..f719bbb --- /dev/null +++ b/xsd-examples/cxx/tree/custom/taxonomy/driver.cxx @@ -0,0 +1,38 @@ +// file : cxx/tree/custom/taxonomy/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include + +#include "people.hxx" + +using std::cerr; +using std::endl; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " people.xml" << endl; + return 1; + } + + try + { + using namespace people; + + std::unique_ptr c (catalog_ (argv[1])); + + for (catalog::person_const_iterator i (c->person ().begin ()); + i != c->person ().end (); ++i) + { + i->print (cerr); + } + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-examples/cxx/tree/custom/taxonomy/people-custom-fwd.hxx b/xsd-examples/cxx/tree/custom/taxonomy/people-custom-fwd.hxx new file mode 100644 index 0000000..1b59a54 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/taxonomy/people-custom-fwd.hxx @@ -0,0 +1,19 @@ +// file : cxx/tree/custom/taxonomy/people-custom-fwd.hxx +// copyright : not copyrighted - public domain + +// Do not include this file directly, use people-fwd.hxx instead. This +// file is included into generated people-fwd.hxx so we do not need to +// guard against multiple inclusions. +// + +namespace people +{ + template + class person_impl; + + template + class superman_impl; + + template + class batman_impl; +} diff --git a/xsd-examples/cxx/tree/custom/taxonomy/people-custom.cxx b/xsd-examples/cxx/tree/custom/taxonomy/people-custom.cxx new file mode 100644 index 0000000..decc847 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/taxonomy/people-custom.cxx @@ -0,0 +1,156 @@ +// file : cxx/tree/custom/taxonomy/people-custom.cxx +// copyright : not copyrighted - public domain + +#include + +// Include people.hxx instead of people-custom.hxx here. +// +#include "people.hxx" + +namespace people +{ + // person_impl + // + template + person_impl:: + person_impl (const xml_schema::string& name) + : base (name) + { + } + + template + person_impl:: + person_impl (const xercesc::DOMElement& e, + xml_schema::flags f, + xml_schema::container* c) + : base (e, f, c) + { + } + + template + person_impl:: + person_impl (const person_impl& p, + xml_schema::flags f, + xml_schema::container* c) + : base (p, f, c) + { + } + + template + person_impl* person_impl:: + _clone (xml_schema::flags f, xml_schema::container* c) const + { + return new person_impl (*this, f, c); + } + + template + void person_impl:: + print (std::ostream& os) const + { + os << this->name () << std::endl; + } + + // Explicitly instantiate person_impl class template for person_base. + // + template class person_impl; + + + // superman_impl + // + template + superman_impl:: + superman_impl (const xml_schema::string& name, bool can_fly) + : base (name, can_fly) + { + } + + template + superman_impl:: + superman_impl (const xercesc::DOMElement& e, + xml_schema::flags f, + xml_schema::container* c) + : base (e, f, c) + { + } + + template + superman_impl:: + superman_impl (const superman_impl& s, + xml_schema::flags f, + xml_schema::container* c) + : base (s, f, c) + { + } + + template + superman_impl* superman_impl:: + _clone (xml_schema::flags f, xml_schema::container* c) const + { + return new superman_impl (*this, f, c); + } + + template + void superman_impl:: + print (std::ostream& os) const + { + if (this->can_fly ()) + os << "Flying superman "; + else + os << "Superman "; + + os << this->name () << std::endl; + } + + // Explicitly instantiate superman_impl class template for superman_base. + // + template class superman_impl; + + + // batman_impl + // + template + batman_impl:: + batman_impl (const xml_schema::string& name, + bool can_fly, + unsigned int wing_span) + : base (name, can_fly, wing_span) + { + } + + template + batman_impl:: + batman_impl (const xercesc::DOMElement& e, + xml_schema::flags f, + xml_schema::container* c) + : base (e, f, c) + { + } + + template + batman_impl:: + batman_impl (const batman_impl& s, + xml_schema::flags f, + xml_schema::container* c) + : base (s, f, c) + { + } + + template + batman_impl* batman_impl:: + _clone (xml_schema::flags f, xml_schema::container* c) const + { + return new batman_impl (*this, f, c); + } + + template + void batman_impl:: + print (std::ostream& os) const + { + os << "Batman " << this->name () << " with " << + this->wing_span () << "m wing span" << std::endl; + } + + // Explicitly instantiate batman_impl class template for batman_base. + // + template class batman_impl; +} diff --git a/xsd-examples/cxx/tree/custom/taxonomy/people-custom.hxx b/xsd-examples/cxx/tree/custom/taxonomy/people-custom.hxx new file mode 100644 index 0000000..58c94c4 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/taxonomy/people-custom.hxx @@ -0,0 +1,105 @@ +// file : cxx/tree/custom/taxonomy/people-custom.hxx +// copyright : not copyrighted - public domain + +// Do not include this file directly, use people.hxx instead. This +// file is included into generated people.hxx so we do not need to +// guard against multiple inclusions. +// + +#include // std::ostream + +// Include people-fwd.hxx here so that we can refer to the generated +// types. +// +#include "people-fwd.hxx" + +namespace people +{ + // + // + template + class person_impl: public base + { + public: + person_impl (const xml_schema::string& name); + + person_impl (const xercesc::DOMElement&, + xml_schema::flags = 0, + xml_schema::container* = 0); + + person_impl (const person_impl&, + xml_schema::flags = 0, + xml_schema::container* = 0); + + person_impl& + operator= (const person_impl&) = default; + + virtual person_impl* + _clone (xml_schema::flags = 0, + xml_schema::container* = 0) const; + + public: + virtual void + print (std::ostream&) const; + }; + + + // + // + template + class superman_impl: public base + { + public: + superman_impl (const xml_schema::string& name, bool can_fly); + + superman_impl (const xercesc::DOMElement&, + xml_schema::flags = 0, + xml_schema::container* = 0); + + superman_impl (const superman_impl&, + xml_schema::flags = 0, + xml_schema::container* = 0); + + virtual superman_impl* + _clone (xml_schema::flags = 0, + xml_schema::container* = 0) const; + + superman_impl& + operator= (const superman_impl&) = default; + + public: + virtual void + print (std::ostream&) const; + }; + + + // + // + template + class batman_impl: public base + { + public: + batman_impl (const xml_schema::string& name, + bool can_fly, + unsigned int wing_span); + + batman_impl (const xercesc::DOMElement&, + xml_schema::flags = 0, + xml_schema::container* = 0); + + batman_impl (const batman_impl&, + xml_schema::flags = 0, + xml_schema::container* = 0); + + batman_impl& + operator= (const batman_impl&) = default; + + virtual batman_impl* + _clone (xml_schema::flags = 0, + xml_schema::container* = 0) const; + + public: + virtual void + print (std::ostream&) const; + }; +} diff --git a/xsd-examples/cxx/tree/custom/taxonomy/people.xml b/xsd-examples/cxx/tree/custom/taxonomy/people.xml new file mode 100644 index 0000000..831c547 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/taxonomy/people.xml @@ -0,0 +1,26 @@ + + + + + + + + Joe Dirt + + + + James "007" Bond + + + + Bruce Wayne + + + diff --git a/xsd-examples/cxx/tree/custom/taxonomy/people.xsd b/xsd-examples/cxx/tree/custom/taxonomy/people.xsd new file mode 100644 index 0000000..b07f338 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/taxonomy/people.xsd @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/custom/wildcard/.gitignore b/xsd-examples/cxx/tree/custom/wildcard/.gitignore new file mode 100644 index 0000000..f32cbe8 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/wildcard/.gitignore @@ -0,0 +1 @@ +wildcard.?xx diff --git a/xsd-examples/cxx/tree/custom/wildcard/README b/xsd-examples/cxx/tree/custom/wildcard/README new file mode 100644 index 0000000..70eaea4 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/wildcard/README @@ -0,0 +1,45 @@ +This example shows how to use type customization to parse and serialize +a specific attribute that is matched by a wildcard (anyAttribute). The +example achieves this by customizing the type to include the data +members and accessors/modifiers that represent the attribute as well as +the parsing constructor and serialization operator where the attribute +value is extracted from and inserted back to DOM, respectively. 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: + +wildcard.xsd + XML Schema definition for simple data type and element. + +wildcard.xml + Sample XML instance document. + +wildcard.hxx +wildcard.ixx +wildcard.cxx + C++ types that represent the given 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 wildcard.xsd + with the --custom-type option in order to customize the data type. + +wildcard-custom.hxx + Header file which defines our own data class by inheriting from the + generated data_base. It is included at the end of wildcard.hxx using + the --hxx-epilogue option. + +wildcard-custom.cxx + Source file which contains the implementation of our data 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 data to STDERR, including the extra attribute. Finally, the driver + serializes the object model back to XML. + +To run the example on the sample XML instance document simply execute: + +$ ./driver wildcard.xml diff --git a/xsd-examples/cxx/tree/custom/wildcard/buildfile b/xsd-examples/cxx/tree/custom/wildcard/buildfile new file mode 100644 index 0000000..e386709 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/wildcard/buildfile @@ -0,0 +1,27 @@ +# file : cxx/tree/custom/wildcard/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -wildcard} {hxx ixx cxx}{wildcard} $libs + +exe{driver}: xml{wildcard}: test.input = true + +<{hxx ixx cxx}{wildcard}>: xsd{wildcard} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --generate-ostream \ + --custom-type data=/data_base \ + --hxx-epilogue '#include "wildcard-custom.hxx"' \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/xsd-examples/cxx/tree/custom/wildcard/driver.cxx b/xsd-examples/cxx/tree/custom/wildcard/driver.cxx new file mode 100644 index 0000000..43fae82 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/wildcard/driver.cxx @@ -0,0 +1,47 @@ +// file : cxx/tree/custom/wildcard/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include + +#include "wildcard.hxx" + +using std::cerr; +using std::endl; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " wildcard.xml" << endl; + return 1; + } + + try + { + using namespace wildcard; + + // Parse. + // + std::unique_ptr d (data_ (argv[1])); + + // Print. + // + cerr << *d << endl; + + // Serialize. + // + xml_schema::namespace_infomap map; + + map["wc"].name = "http://www.codesynthesis.com/wildcard"; + map["wc"].schema = "wildcard.xsd"; + + data_ (std::cout, *d, map); + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-examples/cxx/tree/custom/wildcard/wildcard-custom.cxx b/xsd-examples/cxx/tree/custom/wildcard/wildcard-custom.cxx new file mode 100644 index 0000000..16798d2 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/wildcard/wildcard-custom.cxx @@ -0,0 +1,84 @@ +// file : cxx/tree/custom/wildcard/wildcard-custom.cxx +// copyright : not copyrighted - public domain + +#include + +// Include wildcard.hxx instead of wildcard-custom.hxx here. +// +#include "wildcard.hxx" + +namespace wildcard +{ + data:: + data (const xml_schema::string& d) + : data_base (d), scope_present_ (false) + { + } + + data:: + data (const xercesc::DOMElement& e, + xml_schema::flags f, + xml_schema::container* c) + : data_base (e, f, c), scope_present_ (false) + { + // Check if we've got the scope attribute. + // + namespace xml = xsd::cxx::xml; + xml::string name ("scope"); + + if (e.hasAttribute (name.c_str ())) + { + scope (xml::transcode (e.getAttribute (name.c_str ()))); + } + } + + data:: + data (const data& d, + xml_schema::flags f, + xml_schema::container* c) + : data_base (d, f, c), + scope_present_ (d.scope_present_), + scope_ (d.scope_) + { + } + + data* data:: + _clone (xml_schema::flags f, xml_schema::container* c) const + { + return new data (*this, f, c); + } + + void + operator<< (xercesc::DOMElement& e, const data& x) + { + // Use our base to serialize data and id. + // + const data_base& b (x); + e << b; + + // Add the scope attribute if present. + // + if (x.scope_present ()) + { + namespace xml = xsd::cxx::xml; + xml::string name ("scope"); + xml::string value (x.scope ()); + + e.setAttribute (name.c_str (), value.c_str ()); + } + } + + std::ostream& + operator<< (std::ostream& os, const data& x) + { + // Use our base to print date and id. + // + const data_base& b (x); + os << b; + + if (x.scope_present ()) + os << std::endl << "scope: " << x.scope (); + + return os; + } +} diff --git a/xsd-examples/cxx/tree/custom/wildcard/wildcard-custom.hxx b/xsd-examples/cxx/tree/custom/wildcard/wildcard-custom.hxx new file mode 100644 index 0000000..e789a86 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/wildcard/wildcard-custom.hxx @@ -0,0 +1,66 @@ +// file : cxx/tree/custom/wildcard/wildcard-custom.hxx +// copyright : not copyrighted - public domain + +// Do not include this file directly, use wildcard.hxx instead. This +// file is included into generated wildcard.hxx so we do not need to +// guard against multiple inclusions. +// + +namespace wildcard +{ + class data: public data_base + { + // Standard constructors. + // + public: + data (const xml_schema::string&); + + data (const xercesc::DOMElement&, + xml_schema::flags = 0, + xml_schema::container* = 0); + + data (const data&, + xml_schema::flags = 0, + xml_schema::container* = 0); + + virtual data* + _clone (xml_schema::flags = 0, + xml_schema::container* = 0) const; + + // Our customizations. + // + public: + bool + scope_present () const + { + return scope_present_; + } + + const xml_schema::string& + scope () const + { + return scope_; + } + + void + scope (const xml_schema::string& s) + { + scope_present_ = true; + scope_ = s; + } + + private: + bool scope_present_; + xml_schema::string scope_; + }; + + // Serialization operator. + // + void + operator<< (xercesc::DOMElement&, const data&); + + // std::ostream insertion operator. + // + std::ostream& + operator<< (std::ostream&, const data&); +} diff --git a/xsd-examples/cxx/tree/custom/wildcard/wildcard.xml b/xsd-examples/cxx/tree/custom/wildcard/wildcard.xml new file mode 100644 index 0000000..8f6ba65 --- /dev/null +++ b/xsd-examples/cxx/tree/custom/wildcard/wildcard.xml @@ -0,0 +1,14 @@ + + + + +abc123 diff --git a/xsd-examples/cxx/tree/custom/wildcard/wildcard.xsd b/xsd-examples/cxx/tree/custom/wildcard/wildcard.xsd new file mode 100644 index 0000000..a19be3f --- /dev/null +++ b/xsd-examples/cxx/tree/custom/wildcard/wildcard.xsd @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/embedded/.gitignore b/xsd-examples/cxx/tree/embedded/.gitignore new file mode 100644 index 0000000..9023e82 --- /dev/null +++ b/xsd-examples/cxx/tree/embedded/.gitignore @@ -0,0 +1,3 @@ +xsdbin +library.?xx +library-schema.?xx diff --git a/xsd-examples/cxx/tree/embedded/README b/xsd-examples/cxx/tree/embedded/README new file mode 100644 index 0000000..266a8ff --- /dev/null +++ b/xsd-examples/cxx/tree/embedded/README @@ -0,0 +1,48 @@ +This example shows how to embed the binary representation of the schema +grammar into an application and then use it with the C++/Tree mapping to +parse and validate XML documents. This example is similar to the 'caching' +example except that it loads the binary representation of the schemas +embedded into the application instead of pre-parsing external schema files. + +The example consists of the following files: + +xsdbin.cxx + Tool for converting one or more XML Schema files to the compressed binary + representation. The output is written as a pair of C++ source files + containing the array with the binary data. Use the --help option to see + the tool's usage information. + +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 and a set of parsing + functions that convert XML instance documents to a tree-like in-memory + object model. These are generated by the XSD compiler from library.xsd. + +library-schema.hxx +library-schema.cxx + Binary representation of the library.xsd schema. These files are generated + by the xsdbin tool. + +grammar-input-stream.hxx +grammar-input-stream.cxx + Input stream implementation with the special-purpose schema grammar + decompression algorithm. It is used to load the binary schema representation + produced by the xsdbin tool. + +driver.cxx + Driver for the example. It first sets up the Xerces-C++ DOM parser and + loads the embedded binary schema grammar for validation. It then performs + ten iterations that parse the input file to a DOM document using the DOM + parser and call one of the parsing functions that constructs the object + model from this DOM document. On each iteration the driver prints a number + of books in the object model to STDERR. + +To run the example on the sample XML instance document simply execute: + +$ ./driver library.xml diff --git a/xsd-examples/cxx/tree/embedded/buildfile b/xsd-examples/cxx/tree/embedded/buildfile new file mode 100644 index 0000000..c8e7808 --- /dev/null +++ b/xsd-examples/cxx/tree/embedded/buildfile @@ -0,0 +1,46 @@ +# file : cxx/tree/embedded/buildfile +# license : not copyrighted - public domain + +import libxsd = libxsd%lib{xsd} +import libxerces = libxerces-c%lib{xerces-c} + +./: exe{driver} exe{xsdbin} doc{README} + +# exe{driver} +# +exe{driver}: {hxx cxx}{* -xsdbin -library -library-schema} \ + {hxx ixx cxx}{library} \ + {hxx cxx}{library-schema} \ + $libxsd $libxerces + +exe{driver}: xml{library}: test.input = true + +<{hxx ixx cxx}{library}>: xsd{library} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --output-dir $out_base \ + $path($<[0]) +}} + +<{hxx cxx}{library-schema}>: xsd{library} exe{xsdbin} +{{ + diag xsdbin ($<[0]) # @@ TMP + + ($<[1]) --output-dir $out_base $path($<[0]) +}} + +# exe{xsdbin} +# +exe{xsdbin}: cxx{xsdbin} $libxerces +exe{xsdbin}: test = false + +# Build options. +# +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-examples/cxx/tree/embedded/driver.cxx b/xsd-examples/cxx/tree/embedded/driver.cxx new file mode 100644 index 0000000..445d046 --- /dev/null +++ b/xsd-examples/cxx/tree/embedded/driver.cxx @@ -0,0 +1,183 @@ +// file : cxx/tree/embedded/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include +#include + +#include +#include // chLatin_* +#include +#include // xercesc::Grammar +#include + +#include + +#include +#include +#include +#include + +#include + +#include "library.hxx" +#include "library-schema.hxx" +#include "grammar-input-stream.hxx" + +using namespace std; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " library.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 + { + using namespace xercesc; + namespace xml = xsd::cxx::xml; + namespace tree = xsd::cxx::tree; + + // Create and load the grammar pool. + // + MemoryManager* mm (XMLPlatformUtils::fgMemoryManager); + + unique_ptr gp (new XMLGrammarPoolImpl (mm)); + + try + { + grammar_input_stream is (library_schema, sizeof (library_schema)); + gp->deserializeGrammars(&is); + } + catch(const XSerializationException& e) + { + cerr << "unable to load schema: " << + xml::transcode (e.getMessage ()) << endl; + return 1; + } + + // Lock the grammar pool. This is necessary if we plan to use the + // same grammar pool in multiple threads (this way we can reuse the + // same grammar in multiple parsers). Locking the pool disallows any + // modifications to the pool, such as an attempt by one of the threads + // to cache additional schemas. + // + gp->lockPool (); + + // Get an implementation of the Load-Store (LS) interface. + // + const XMLCh ls_id [] = {chLatin_L, chLatin_S, chNull}; + + DOMImplementation* impl ( + DOMImplementationRegistry::getDOMImplementation (ls_id)); + + xml::dom::unique_ptr parser ( + impl->createLSParser ( + DOMImplementationLS::MODE_SYNCHRONOUS, 0, mm, gp.get ())); + + 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 validation. + // + conf->setParameter (XMLUni::fgDOMValidate, true); + conf->setParameter (XMLUni::fgXercesSchema, true); + 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 + + // Use the loaded grammar during parsing. + // + conf->setParameter (XMLUni::fgXercesUseCachedGrammarInParse, true); + + // Disable loading schemas via other means (e.g., schemaLocation). + // + conf->setParameter (XMLUni::fgXercesLoadSchema, false); + + // 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); + + // Parse XML documents. + // + for (unsigned long i (0); i < 10; ++i) + { + ifstream ifs; + ifs.exceptions (ifstream::badbit | ifstream::failbit); + ifs.open (argv[1]); + + // Wrap the standard input stream. + // + xml::sax::std_input_source isrc (ifs, argv[1]); + Wrapper4InputSource wrap (&isrc, false); + + // Parse XML to DOM. + // + xml_schema::dom::unique_ptr doc (parser->parse (&wrap)); + + eh.throw_if_failed (); + + // Parse DOM to the object model. + // + unique_ptr c (library::catalog_ (*doc)); + + cerr << "catalog with " << c->book ().size () << " books" << 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/xsd-examples/cxx/tree/embedded/grammar-input-stream.cxx b/xsd-examples/cxx/tree/embedded/grammar-input-stream.cxx new file mode 100644 index 0000000..118ecb0 --- /dev/null +++ b/xsd-examples/cxx/tree/embedded/grammar-input-stream.cxx @@ -0,0 +1,95 @@ +// file : cxx/tree/embedded/grammar-input-stream.cxx +// copyright : not copyrighted - public domain + +#include +#include "grammar-input-stream.hxx" + +grammar_input_stream:: +grammar_input_stream (const XMLByte* data, std::size_t size) + : data_ (data), + size_ (size), + pos_ (0), + vpos_ (0), + cseq_ (0), + add_zero_ (false) +{ +} + +XMLFilePos grammar_input_stream:: +curPos () const +{ + return static_cast (vpos_); +} + +XMLSize_t grammar_input_stream:: +readBytes (XMLByte* const buf, const XMLSize_t size) +{ + std::size_t i (0); + + // Add a zero from the alternating sequence if it didn't + // fit on the previous read. + // + if (add_zero_) + { + buf[i++] = 0; + add_zero_ = false; + } + + // If have an unfinished sequential sequence, output it now. + // + if (cseq_ != 0 && !alt_) + { + for (; cseq_ != 0 && i < size; --cseq_) + buf[i++] = 0; + } + + for (; i < size && pos_ < size_;) + { + XMLByte b = buf[i++] = data_[pos_++]; + + // See if we are in a compression sequence. + // + if (cseq_ != 0) + { + if (i < size) + buf[i++] = 0; + else + add_zero_ = true; // Add it on the next read. + + cseq_--; + continue; + } + + // If we are not in a compression sequence and this byte is + // not zero then we are done. + // + if (b != 0) + continue; + + // We have a zero. + // + assert (pos_ < size_); // There has to be another byte. + unsigned char v (static_cast (data_[pos_++])); + alt_ = (v & 128) != 0; + cseq_ = v & 127; + + // If it is a sequential sequence, output as many zeros as + // we can. + // + if (!alt_) + { + for (; cseq_ != 0 && i < size; --cseq_) + buf[i++] = 0; + } + } + + vpos_ += i; + + return static_cast (i); +} + +const XMLCh* grammar_input_stream:: +getContentType () const +{ + return 0; +} diff --git a/xsd-examples/cxx/tree/embedded/grammar-input-stream.hxx b/xsd-examples/cxx/tree/embedded/grammar-input-stream.hxx new file mode 100644 index 0000000..701be31 --- /dev/null +++ b/xsd-examples/cxx/tree/embedded/grammar-input-stream.hxx @@ -0,0 +1,40 @@ +// file : cxx/tree/embedded/grammar-input-stream.hxx +// copyright : not copyrighted - public domain + +#ifndef GRAMMAR_INPUT_STREAM_HXX +#define GRAMMAR_INPUT_STREAM_HXX + +#include +#include + +// Memory buffer input stream with the special-purpose schema +// grammar decompression. +// +class grammar_input_stream: public xercesc::BinInputStream +{ +public : + grammar_input_stream (const XMLByte* data, std::size_t size); + + virtual XMLFilePos + curPos () const; + + virtual XMLSize_t + readBytes (XMLByte* const buf, const XMLSize_t size); + + virtual const XMLCh* + getContentType () const; + +private : + const XMLByte* data_; + std::size_t size_; + std::size_t pos_; + std::size_t vpos_; + + // Compression data. + // + size_t cseq_; // Number of bytes left in a compression sequence. + bool alt_; // Alternating or sequential sequence. + bool add_zero_; // Add a zero on the next read. +}; + +#endif // GRAMMAR_INPUT_STREAM_HXX diff --git a/xsd-examples/cxx/tree/embedded/library.xml b/xsd-examples/cxx/tree/embedded/library.xml new file mode 100644 index 0000000..f2816e7 --- /dev/null +++ b/xsd-examples/cxx/tree/embedded/library.xml @@ -0,0 +1,52 @@ + + + + + + + + 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/xsd-examples/cxx/tree/embedded/library.xsd b/xsd-examples/cxx/tree/embedded/library.xsd new file mode 100644 index 0000000..0ffee32 --- /dev/null +++ b/xsd-examples/cxx/tree/embedded/library.xsd @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/embedded/xsdbin.cxx b/xsd-examples/cxx/tree/embedded/xsdbin.cxx new file mode 100644 index 0000000..3539c52 --- /dev/null +++ b/xsd-examples/cxx/tree/embedded/xsdbin.cxx @@ -0,0 +1,494 @@ +// file : cxx/tree/embedded/xsdbin.cxx +// copyright : not copyrighted - public domain + +// This program loads the XML Schema file(s) and converts them to +// the Xerces-C++ binary schema format which can then be embedded +// into C++ programs and used to validate XML documents. The output +// is written as a C++ source file containing the array with the +// binary data. +// + +#include +#include // std::unique_ptr +#include // std::size_t +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include + +using namespace std; +using namespace xercesc; + +class error_handler: public ErrorHandler +{ +public: + error_handler () + : failed_ (false) + { + } + + bool + failed () const + { + return failed_; + } + + enum severity {s_warning, s_error, s_fatal}; + + virtual void + warning (const SAXParseException&); + + virtual void + error (const SAXParseException&); + + virtual void + fatalError (const SAXParseException&); + + virtual void + resetErrors () + { + failed_ = false; + } + + void + handle (const SAXParseException&, severity); + +private: + bool failed_; +}; + +void +cxx_escape (string&); + +int +main (int argc, char* argv[]) +{ + const char* hxx_suffix = "-schema.hxx"; + const char* cxx_suffix = "-schema.cxx"; + + string name; + string base; + string outdir; + + struct usage + { + usage (bool e = true): error (e) {} + bool error; + }; + + int argi (1); + bool multi_import (true); + bool verbose (false); + + try + { + for (; argi < argc; ++argi) + { + string a (argv[argi]); + + if (a == "--help") + throw usage (false); + else if (a == "--verbose") + { + verbose = true; + } + else if (a == "--hxx-suffix") + { + if (++argi >= argc) + throw usage (); + + hxx_suffix = argv[argi]; + } + else if (a == "--cxx-suffix") + { + if (++argi >= argc) + throw usage (); + + cxx_suffix = argv[argi]; + } + else if (a == "--output-dir") + { + if (++argi >= argc) + throw usage (); + + outdir = argv[argi]; + } + else if (a == "--array-name") + { + if (++argi >= argc) + throw usage (); + + name = argv[argi]; + } + else if (a == "--disable-multi-import") + { + multi_import = false; + } + else + break; + } + + if (argi >= argc) + { + cerr << "no input file specified" << endl; + throw usage (); + } + + base = argv[argi]; + } + catch (usage const& e) + { + ostream& o (e.error ? cerr : cout); + + o << "Usage: " << argv[0] << " [options] " << endl + << "Options:" << endl + << " --help Print usage information and exit." << endl + << " --verbose Print progress information." << endl + << " --output-dir Write generated files to ." << endl + << " --hxx-suffix Header file suffix instead of '-schema.hxx'." << endl + << " --cxx-suffix Source file suffix instead of '-schema.cxx'." << endl + << " --array-name Binary data array name." << endl + << " --disable-multi-import Disable multiple import support." << endl + << endl; + + return e.error ? 0 : 1; + } + + XMLPlatformUtils::Initialize (); + + { + MemoryManager* mm (XMLPlatformUtils::fgMemoryManager); + + unique_ptr gp (new XMLGrammarPoolImpl (mm)); + + // Load the schemas into grammar pool. + // + { + unique_ptr parser ( + XMLReaderFactory::createXMLReader (mm, gp.get ())); + + parser->setFeature (XMLUni::fgSAX2CoreNameSpaces, true); + parser->setFeature (XMLUni::fgSAX2CoreNameSpacePrefixes, true); + parser->setFeature (XMLUni::fgSAX2CoreValidation, true); + parser->setFeature (XMLUni::fgXercesSchema, true); + parser->setFeature (XMLUni::fgXercesSchemaFullChecking, true); + parser->setFeature (XMLUni::fgXercesValidationErrorAsFatal, true); + + // Xerces-C++ 3.1.0 is the first version with working multi import + // support. + // +#if _XERCES_VERSION >= 30100 + parser->setFeature (XMLUni::fgXercesHandleMultipleImports, multi_import); +#endif + + error_handler eh; + parser->setErrorHandler (&eh); + + for (; argi < argc; ++argi) + { + if (verbose) + cerr << "loading " << argv[argi] << endl; + + if (!parser->loadGrammar (argv[argi], Grammar::SchemaGrammarType, true)) + { + cerr << argv[argi] << ": error: unable to load" << endl; + return 1; + } + + if (eh.failed ()) + return 1; + } + } + + // Get the binary representation. + // + BinMemOutputStream data; + + try + { + gp->serializeGrammars (&data); + } + catch (const XSerializationException& e) + { + char* msg (XMLString::transcode (e.getMessage ())); + cerr << "error: " << msg << endl; + XMLString::release (&msg); + return 1; + } + + size_t n (static_cast (data.curPos ())); + const unsigned char* buf ( + static_cast (data.getRawBuffer ())); + + if (verbose) + cerr << "uncomressed data size " << n << " bytes" << endl; + + // Compress zeros. + // + size_t cn (0); + unsigned char* cbuf = new unsigned char[n]; + + size_t cseq (0); // Number of bytes left in a compression sequence. + bool alt (false); // Alternating or sequential sequence. + + for (size_t i (0); i < n;) + { + unsigned char v (buf[i++]); + + // See if we are in a compression sequence. + // + if (cseq != 0) + { + // See if this byte needs to be copied. + // + if (alt && cseq % 2 == 0) + cbuf[cn++] = v; + + cseq--; + continue; + } + + // If we are not in a compression sequence and this byte is + // not zero then simply copy it. + // + if (v != 0) + { + cbuf[cn++] = v; + continue; + } + + // We have a zero. + // + cbuf[cn++] = 0; + + // See if we can start a new compression sequence. + // + if (i < n) + { + if (buf[i] == 0) + { + // Sequential sequence. See how far it runs. + // + alt = false; + + for (cseq = 1; cseq < 127 && cseq + i < n; cseq++) + if (buf[cseq + i] != 0) + break; + } + else if (i + 1 < n && buf[i + 1] == 0) + { + // Alternating sequence. See how far it runs. + // + alt = true; + + for (cseq = 1; cseq < 127 && cseq * 2 + i + 1 < n; cseq++) + { + if (buf[cseq * 2 + i + 1] != 0) + break; + + // For longer sequences prefer sequential to alternating. + // + if (cseq > 2 && + buf[cseq * 2 + i] == 0 && + buf[(cseq - 1) * 2 + i] == 0 && + buf[(cseq - 2) * 2 + i] == 0) + { + cseq -= 2; + break; + } + } + + cseq *= 2; + } + } + + if (cseq != 0) + { + cbuf[cn++] = static_cast ( + alt ? (128 | cseq / 2) : cseq); + } + else + cbuf[cn++] = 0; + } + + if (verbose) + cerr << "comressed data size " << cn << " bytes" << endl; + + buf = cbuf; + n = cn; + + // Figure out the file names. + // + string::size_type p (base.rfind ('/')), p1 (base.rfind ('\\')); + + if (p1 != string::npos && (p == string::npos || p1 > p)) + p = p1; + + if (p != string::npos) + base = string (base, p + 1); + + p = base.rfind ('.'); + + if (p != string::npos) + base.resize (p); + + string hxx (base + hxx_suffix); + string cxx (base + cxx_suffix); + + if (!outdir.empty ()) + { +#if defined (WIN32) || defined (__WIN32__) + hxx = outdir + '\\' + hxx; + cxx = outdir + '\\' + cxx; +#else + hxx = outdir + '/' + hxx; + cxx = outdir + '/' + cxx; +#endif + } + + if (name.empty ()) + { + name = base + "_schema"; + cxx_escape (name); + } + + // Write header. + // + { + ofstream os (hxx.c_str ()); + + if (!os.is_open ()) + { + cerr << hxx << ": error: unable to open" << endl; + return 1; + } + + os << "// Automatically generated. Do not edit." << endl + << "//" << endl + << endl + << "#include " << endl + << endl + << "extern const XMLByte " << name << "[" << n << "UL];" << endl; + } + + { + ofstream os (cxx.c_str ()); + + if (!os.is_open ()) + { + cerr << cxx << ": error: unable to open" << endl; + return 1; + } + + os << "// Automatically generated. Do not edit." << endl + << "//" << endl + << endl + << "#include " << endl + << "#include " << endl + << endl + << "#if XERCES_GRAMMAR_SERIALIZATION_LEVEL != " << + XERCES_GRAMMAR_SERIALIZATION_LEVEL << endl + << "# error incompatible Xerces-C++ version detected" << endl + << "#endif" << endl + << endl + << "extern const XMLByte " << name << "[" << n << "UL] =" << endl + << "{"; + + for (size_t i (0); i < n; ++i) + { + if (i != 0) + os << ','; + + os << (i % 12 == 0 ? "\n " : " ") << "0x"; + os.width (2); + os.fill ('0'); + os << hex << static_cast (buf[i]); + } + + os << endl + << "};" << endl + << endl; + } + + delete[] cbuf; + } + + XMLPlatformUtils::Terminate (); +} + +void +cxx_escape (string& s) +{ + for (string::size_type i (0); i < s.size (); ++i) + { + char& c (s[i]); + + if (i == 0) + { + if (!((c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + c == '_')) + c = '_'; + } + else + { + if (!((c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + (c >= '0' && c <= '9') || + c == '_')) + c = '_'; + } + } +} + +void error_handler:: +warning (const SAXParseException& e) +{ + handle (e, s_warning); +} + +void error_handler:: +error (const SAXParseException& e) +{ + failed_ = true; + handle (e, s_error); +} + +void error_handler:: +fatalError (const SAXParseException& e) +{ + failed_ = true; + handle (e, s_fatal); +} + +void error_handler:: +handle (const SAXParseException& e, severity s) +{ + const XMLCh* xid (e.getPublicId ()); + + if (xid == 0) + xid = e.getSystemId (); + + char* id (XMLString::transcode (xid)); + char* msg (XMLString::transcode (e.getMessage ())); + + cerr << id << ":" + << e.getLineNumber () << ":" << e.getColumnNumber () << " " + << (s == s_warning ? "warning: " : "error: ") << msg << endl; + + XMLString::release (&id); + XMLString::release (&msg); +} diff --git a/xsd-examples/cxx/tree/hello/.gitignore b/xsd-examples/cxx/tree/hello/.gitignore new file mode 100644 index 0000000..d73130a --- /dev/null +++ b/xsd-examples/cxx/tree/hello/.gitignore @@ -0,0 +1 @@ +hello.?xx diff --git a/xsd-examples/cxx/tree/hello/README b/xsd-examples/cxx/tree/hello/README new file mode 100644 index 0000000..bb98584 --- /dev/null +++ b/xsd-examples/cxx/tree/hello/README @@ -0,0 +1,26 @@ +This is a "Hello, world!" example that shows how to use the C++/Tree +mapping to access XML instance documents described by XML Schema +definitions. + +The example consists of the following files: + +hello.xsd + XML Schema which describes "hello" instance documents. + +hello.xml + Sample XML instance document. + +hello.hxx +hello.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 hello.xsd. + +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 content of the object model to STDERR. + +To run the example on the sample XML instance document simply execute: + +$ ./driver hello.xml diff --git a/xsd-examples/cxx/tree/hello/buildfile b/xsd-examples/cxx/tree/hello/buildfile new file mode 100644 index 0000000..241d6f1 --- /dev/null +++ b/xsd-examples/cxx/tree/hello/buildfile @@ -0,0 +1,23 @@ +# file : cxx/tree/hello/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -hello} {hxx ixx cxx}{hello} $libs + +exe{driver}: xml{hello}: test.input = true + +<{hxx ixx cxx}{hello}>: xsd{hello} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-examples/cxx/tree/hello/driver.cxx b/xsd-examples/cxx/tree/hello/driver.cxx new file mode 100644 index 0000000..7c8cec0 --- /dev/null +++ b/xsd-examples/cxx/tree/hello/driver.cxx @@ -0,0 +1,36 @@ +// file : cxx/tree/hello/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include + +#include "hello.hxx" + +using namespace std; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " hello.xml" << endl; + return 1; + } + + try + { + unique_ptr h (hello (argv[1])); + + for (hello_t::name_const_iterator i (h->name ().begin ()); + i != h->name ().end (); + ++i) + { + cout << h->greeting () << ", " << *i << "!" << endl; + } + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-examples/cxx/tree/hello/hello.xml b/xsd-examples/cxx/tree/hello/hello.xml new file mode 100644 index 0000000..b534d21 --- /dev/null +++ b/xsd-examples/cxx/tree/hello/hello.xml @@ -0,0 +1,19 @@ + + + + + + + Hello + + sun + moon + world + + diff --git a/xsd-examples/cxx/tree/hello/hello.xsd b/xsd-examples/cxx/tree/hello/hello.xsd new file mode 100644 index 0000000..a945ecf --- /dev/null +++ b/xsd-examples/cxx/tree/hello/hello.xsd @@ -0,0 +1,52 @@ + + + + + + + + + + + The hello_t type consists of a greeting phrase and a + collection of names to which this greeting applies. + + + + + + + + + The greeting element contains the greeting phrase + for this hello object. + + + + + + + + The name elements contains names to be greeted. + + + + + + + + + + + The hello element is a root of the Hello XML vocabulary. + Every conforming document should start with this element. + + + + + diff --git a/xsd-examples/cxx/tree/library/.gitignore b/xsd-examples/cxx/tree/library/.gitignore new file mode 100644 index 0000000..c116ec1 --- /dev/null +++ b/xsd-examples/cxx/tree/library/.gitignore @@ -0,0 +1 @@ +library.?xx diff --git a/xsd-examples/cxx/tree/library/README b/xsd-examples/cxx/tree/library/README new file mode 100644 index 0000000..0b8638c --- /dev/null +++ b/xsd-examples/cxx/tree/library/README @@ -0,0 +1,32 @@ +This example shows how to use the C++/Tree mapping to parse XML documents +into a tree-like in-memory object model, modify this object model, and +finally serialize it back to XML. + +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.ixx +library.cxx + C++ types that represent the given vocabulary, a set of parsing + functions that convert XML 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 library.xsd. + +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 content of the object model to STDERR. Finally, the driver modifies + the object model and serializes it back to XML. + +To run the example on the sample XML instance document simply execute: + +$ ./driver library.xml + +This example also shows how to use the ID/IDREF cross-referencing +mechanism and the xsd:enumeration to C++ enum mapping. diff --git a/xsd-examples/cxx/tree/library/buildfile b/xsd-examples/cxx/tree/library/buildfile new file mode 100644 index 0000000..4ab023b --- /dev/null +++ b/xsd-examples/cxx/tree/library/buildfile @@ -0,0 +1,25 @@ +# file : cxx/tree/library/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -library} {hxx ixx cxx}{library} $libs + +exe{driver}: xml{library}: test.input = true + +<{hxx ixx cxx}{library}>: xsd{library} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-ostream \ + --generate-serialization \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-examples/cxx/tree/library/driver.cxx b/xsd-examples/cxx/tree/library/driver.cxx new file mode 100644 index 0000000..9086891 --- /dev/null +++ b/xsd-examples/cxx/tree/library/driver.cxx @@ -0,0 +1,130 @@ +// file : cxx/tree/library/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include + +#include "library.hxx" + +using std::cerr; +using std::endl; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " library.xml" << endl; + return 1; + } + + try + { + using namespace library; + + // Read in the XML file and obtain its object model. + // + std::unique_ptr c (catalog_ (argv[1])); + + + // Let's print what we've got. + // + for (catalog::book_const_iterator bi (c->book ().begin ()); + bi != c->book ().end (); + ++bi) + { + cerr << endl + << "ID : " << bi->id () << endl + << "ISBN : " << bi->isbn () << endl + << "Title : " << bi->title () << endl + << "Genre : " << bi->genre () << endl; + + for (book::author_const_iterator ai (bi->author ().begin ()); + ai != bi->author ().end (); + ++ai) + { + cerr << "Author : " << ai->name () << endl; + cerr << " Born : " << ai->born () << endl; + + if (ai->died ()) + cerr << " Died : " << *ai->died () << endl; + + if (ai->recommends ()) + cerr << " Recommends : " << (*ai->recommends ())->title () << endl; + } + + cerr << "Available : " << std::boolalpha << bi->available () << endl; + } + + + // Now we are going to modify the object model and serialize it + // back to XML. + // + + catalog::book_sequence& books (c->book ()); + + + // Get rid of all unavailable books. + // + for (catalog::book_iterator bi (books.begin ()); bi != books.end ();) + { + if (!bi->available ()) + bi = books.erase (bi); + else + ++bi; + } + + + // Insert a new book. + // + book b (679776443, // ISBN + "Dead Souls", // Title + genre::philosophy, // Genre + "DS"); // ID + + b.author ().push_back (author ("Nikolai Gogol", + xml_schema::date (1809, 3, 31))); + + books.insert (books.begin (), b); + + + // Because we removed all unavailable books, some IDREFs might be + // broken. Let's fix this. + // + for (catalog::book_iterator bi (books.begin ()); bi != books.end (); ++bi) + { + for (book::author_iterator ai (bi->author ().begin ()); + ai != bi->author ().end (); + ++ai) + { + author::recommends_optional& c (ai->recommends ()); + + if (c.present ()) + { + author::recommends_type& ref (c.get ()); + + if (!ref) + c.reset (); + } + } + } + + + // Prepare namespace mapping and schema location information. + // + xml_schema::namespace_infomap map; + + map["lib"].name = "http://www.codesynthesis.com/library"; + map["lib"].schema = "library.xsd"; + + + // Write it out. + // + catalog_ (std::cout, *c, map); + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-examples/cxx/tree/library/library.xml b/xsd-examples/cxx/tree/library/library.xml new file mode 100644 index 0000000..d048aa4 --- /dev/null +++ b/xsd-examples/cxx/tree/library/library.xml @@ -0,0 +1,52 @@ + + + + + + + + 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/xsd-examples/cxx/tree/library/library.xsd b/xsd-examples/cxx/tree/library/library.xsd new file mode 100644 index 0000000..4db07ef --- /dev/null +++ b/xsd-examples/cxx/tree/library/library.xsd @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/messaging/.gitignore b/xsd-examples/cxx/tree/messaging/.gitignore new file mode 100644 index 0000000..f493b6c --- /dev/null +++ b/xsd-examples/cxx/tree/messaging/.gitignore @@ -0,0 +1 @@ +protocol.?xx diff --git a/xsd-examples/cxx/tree/messaging/README b/xsd-examples/cxx/tree/messaging/README new file mode 100644 index 0000000..435a4cf --- /dev/null +++ b/xsd-examples/cxx/tree/messaging/README @@ -0,0 +1,58 @@ +This example shows how to handle XML vocabularies with multiple +root elements using the element type and element map features +of the C++/Tree mapping. The main purpose of element types is +to distinguish object models with the same root type but with +different root elements. The element map allows uniform parsing +and serialization of multiple root elements. + +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. Note that some request + and response elements are of the same type. + +balance.xml +withdraw.xml +deposit.xml + Sample XML instances for the protocol requests. + +protocol.hxx +protocol.cxx + C++ types that represent the given vocabulary. These are + generated by the XSD compiler from protocol.xsd. Generation of + element types instead of parsing and serialization functions is + requested with the --generate-element-type option. Generation of + the element map is requested with the --generate-element-map + option. + +dom-parse.hxx +dom-parse.cxx + Definition and implementation of the parse() function that + parses an XML document to a DOM document. + +dom-serialize.hxx +dom-serialize.cxx + Definition and implementation of the serialize() function that + serializes a DOM document to XML. + +driver.cxx + Driver for the example. It first calls the above-mentioned parse() + function to parse the input file to a DOM document. It then calls + the parse() function on the element map to parse the root document + element to the object model. The object model is returned as a + pointer to xml_schema::element_type which is a common base type for + all element types. The driver then determines which request it has + received either using RTTI or by comparing the root element names. + Once the request type is determined, information about it is printed + to STDERR and the corresponding response is created. Finally, the + driver serializes the opaque response object to a DOM document + using the element map and then serializes this DOM document to + STDOUT using the above-mentioned serialize() function. + +To run the example on the sample XML request documents simply +execute: + +$ ./driver balance.xml +$ ./driver withdraw.xml +$ ./driver deposit.xml diff --git a/xsd-examples/cxx/tree/messaging/balance.xml b/xsd-examples/cxx/tree/messaging/balance.xml new file mode 100644 index 0000000..27c1509 --- /dev/null +++ b/xsd-examples/cxx/tree/messaging/balance.xml @@ -0,0 +1,16 @@ + + + + + + + 123456789 + + diff --git a/xsd-examples/cxx/tree/messaging/buildfile b/xsd-examples/cxx/tree/messaging/buildfile new file mode 100644 index 0000000..62fadda --- /dev/null +++ b/xsd-examples/cxx/tree/messaging/buildfile @@ -0,0 +1,29 @@ +# file : cxx/tree/messaging/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} xml{balance deposit withdraw} doc{README} + +exe{driver}: {hxx cxx}{* -protocol} {hxx ixx cxx}{protocol} $libs testscript + +<{hxx ixx cxx}{protocol}>: xsd{protocol} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --root-element-all \ + --generate-element-type \ + --generate-element-map \ + --generate-serialization \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-examples/cxx/tree/messaging/deposit.xml b/xsd-examples/cxx/tree/messaging/deposit.xml new file mode 100644 index 0000000..5be2a0a --- /dev/null +++ b/xsd-examples/cxx/tree/messaging/deposit.xml @@ -0,0 +1,17 @@ + + + + + + + 123456789 + 1000000 + + diff --git a/xsd-examples/cxx/tree/messaging/dom-parse.cxx b/xsd-examples/cxx/tree/messaging/dom-parse.cxx new file mode 100644 index 0000000..3ae5787 --- /dev/null +++ b/xsd-examples/cxx/tree/messaging/dom-parse.cxx @@ -0,0 +1,93 @@ +// file : cxx/tree/messaging/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::unique_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::unique_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::unique_ptr doc (parser->parse (&wrap)); + + eh.throw_if_failed > (); + + return doc; +} diff --git a/xsd-examples/cxx/tree/messaging/dom-parse.hxx b/xsd-examples/cxx/tree/messaging/dom-parse.hxx new file mode 100644 index 0000000..b73c52d --- /dev/null +++ b/xsd-examples/cxx/tree/messaging/dom-parse.hxx @@ -0,0 +1,22 @@ +// file : cxx/tree/messaging/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::unique_ptr +parse (std::istream& is, + const std::string& id, + bool validate); + +#endif // DOM_PARSE diff --git a/xsd-examples/cxx/tree/messaging/dom-serialize.cxx b/xsd-examples/cxx/tree/messaging/dom-serialize.cxx new file mode 100644 index 0000000..b32c5a2 --- /dev/null +++ b/xsd-examples/cxx/tree/messaging/dom-serialize.cxx @@ -0,0 +1,64 @@ +// file : cxx/tree/messaging/dom-serialize.cxx +// copyright : not copyrighted - public domain + +#include "dom-serialize.hxx" + +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include + +using namespace xercesc; +namespace xml = xsd::cxx::xml; +namespace tree = xsd::cxx::tree; + +void +serialize (std::ostream& os, + const xercesc::DOMDocument& doc, + const std::string& encoding) +{ + const XMLCh ls_id [] = {chLatin_L, chLatin_S, chNull}; + + // Get an implementation of the Load-Store (LS) interface. + // + DOMImplementation* impl ( + DOMImplementationRegistry::getDOMImplementation (ls_id)); + + tree::error_handler eh; + xml::dom::bits::error_handler_proxy ehp (eh); + + xml::dom::ostream_format_target oft (os); + + // Create a DOMSerializer. + // + xml::dom::unique_ptr writer ( + impl->createLSSerializer ()); + + DOMConfiguration* conf (writer->getDomConfig ()); + + // Set error handler. + // + conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp); + + // Set some generally nice features. + // + conf->setParameter (XMLUni::fgDOMWRTDiscardDefaultContent, true); + conf->setParameter (XMLUni::fgDOMWRTFormatPrettyPrint, true); + conf->setParameter (XMLUni::fgDOMWRTXercesPrettyPrint, false); + + xml::dom::unique_ptr out (impl->createLSOutput ()); + out->setEncoding (xml::string (encoding).c_str ()); + out->setByteStream (&oft); + + writer->write (&doc, out.get ()); + + eh.throw_if_failed > (); +} diff --git a/xsd-examples/cxx/tree/messaging/dom-serialize.hxx b/xsd-examples/cxx/tree/messaging/dom-serialize.hxx new file mode 100644 index 0000000..bf1e290 --- /dev/null +++ b/xsd-examples/cxx/tree/messaging/dom-serialize.hxx @@ -0,0 +1,20 @@ +// file : cxx/tree/messaging/dom-serialize.hxx +// copyright : not copyrighted - public domain + +#ifndef DOM_SERIALIZE +#define DOM_SERIALIZE + +#include +#include + +#include + +// Serialize a DOM document to XML which is written to the standard +// output stream. +// +void +serialize (std::ostream& os, + const xercesc::DOMDocument& doc, + const std::string& encoding = "UTF-8"); + +#endif // DOM_SERIALIZE diff --git a/xsd-examples/cxx/tree/messaging/driver.cxx b/xsd-examples/cxx/tree/messaging/driver.cxx new file mode 100644 index 0000000..a358014 --- /dev/null +++ b/xsd-examples/cxx/tree/messaging/driver.cxx @@ -0,0 +1,146 @@ +// file : cxx/tree/messaging/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include +#include +#include +#include + +#include +#include + +#include + +#include "dom-parse.hxx" +#include "dom-serialize.hxx" + +#include "protocol.hxx" + +using namespace std; +using namespace protocol; +using namespace xercesc; + +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. + // + XMLPlatformUtils::Initialize (); + + try + { + ifstream ifs; + ifs.exceptions (ifstream::badbit | ifstream::failbit); + ifs.open (argv[1]); + + unique_ptr req, res; + + // Parse the XML request to a DOM document using the parse() + // function from dom-parse.hxx. + // + { + xml_schema::dom::unique_ptr doc ( + parse (ifs, argv[1], true)); + + DOMElement& root (*doc->getDocumentElement ()); + + req = xml_schema::element_map::parse (root); + } + + // We can test which request we've got either using RTTI or by + // comparing the element names, as shown below. + // + if (balance* b = dynamic_cast (req.get ())) + { + account_t& a (b->value ()); + + cerr << "balance request for acc# " << a.account () << endl; + + res.reset (new success (balance_t (a.account (), 1000))); + } + else if (req->_name () == withdraw::name ()) + { + withdraw& w (static_cast (*req)); + change_t& c (w.value ()); + + wcerr << "withdrawal request for acc# " << c.account () << ", " + << "amount: " << c.amount () << endl; + + if (c.amount () > 1000) + res.reset (new insufficient_funds (balance_t (c.account (), 1000))); + else + res.reset (new success (balance_t (c.account (), 1000 - c.amount ()))); + + } + else if (req->_name () == deposit::name ()) + { + deposit& d (static_cast (*req)); + change_t& c (d.value ()); + + wcerr << "deposit request for acc# " << c.account () << ", " + << "amount: " << c.amount () << endl; + + res.reset (new success (balance_t (c.account (), 1000 + c.amount ()))); + } + + // Serialize the response to a DOM document. + // + namespace xml = xsd::cxx::xml; + + const XMLCh ls_id [] = {chLatin_L, chLatin_S, chNull}; + + DOMImplementation* impl ( + DOMImplementationRegistry::getDOMImplementation (ls_id)); + + const string& name (res->_name ()); + const string& ns (res->_namespace ()); + + xml_schema::dom::unique_ptr doc ( + impl->createDocument ( + xml::string (ns).c_str (), + xml::string ("p:" + name).c_str (), + 0)); + + xml_schema::element_map::serialize (*doc->getDocumentElement (), *res); + + // Serialize the DOM document to XML using the serialize() function + // from dom-serialize.hxx. + // + cout << "response:" << endl + << endl; + + serialize (cout, *doc); + } + catch (const xml_schema::no_element_info& e) + { + // This exception indicates that we tried to parse or serialize + // an unknown element. + // + cerr << "unknown request: " << e.element_namespace () << "#" << + e.element_name () << endl; + r = 1; + } + 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; + } + + XMLPlatformUtils::Terminate (); + return r; +} diff --git a/xsd-examples/cxx/tree/messaging/protocol.xsd b/xsd-examples/cxx/tree/messaging/protocol.xsd new file mode 100644 index 0000000..4a28ac3 --- /dev/null +++ b/xsd-examples/cxx/tree/messaging/protocol.xsd @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/messaging/testscript b/xsd-examples/cxx/tree/messaging/testscript new file mode 100644 index 0000000..c9df49f --- /dev/null +++ b/xsd-examples/cxx/tree/messaging/testscript @@ -0,0 +1,6 @@ +# file : cxx/tree/messaging/testscript +# license : not copyrighted - public domain + +$* $src_base/balance.xml >| 2>| : balance +$* $src_base/withdraw.xml >| 2>| : withdraw +$* $src_base/deposit.xml >| 2>| : deposit diff --git a/xsd-examples/cxx/tree/messaging/withdraw.xml b/xsd-examples/cxx/tree/messaging/withdraw.xml new file mode 100644 index 0000000..e9ef526 --- /dev/null +++ b/xsd-examples/cxx/tree/messaging/withdraw.xml @@ -0,0 +1,17 @@ + + + + + + + 123456789 + 1000000 + + diff --git a/xsd-examples/cxx/tree/mixed/.gitignore b/xsd-examples/cxx/tree/mixed/.gitignore new file mode 100644 index 0000000..cbeac00 --- /dev/null +++ b/xsd-examples/cxx/tree/mixed/.gitignore @@ -0,0 +1 @@ +text.?xx diff --git a/xsd-examples/cxx/tree/mixed/README b/xsd-examples/cxx/tree/mixed/README new file mode 100644 index 0000000..fc23faa --- /dev/null +++ b/xsd-examples/cxx/tree/mixed/README @@ -0,0 +1,45 @@ +This example shows how to access the underlying DOM nodes in the +C++/Tree mapping in order to handle raw, "type-less content" such +as mixed content models, anyType/anySimpleType, and any/anyAttribute. + +For an alternative (and recommended) approach that employs ordered +types see the order/mixed example. + +For an alternative approach that employes type customization see +examples in the custom/ directory, in particular, custom/mixed and +custom/wildcard. + +In this example we use mixed content model to describe text with +embedded links, e.g., + + This paragraph talks about time. + +The example transforms such text into plain text with references, e.g., + + This paragraph talks about time[0]. + + [0] uri + +The example consists of the following files: + +text.xsd + XML Schema which describes "text with links" instance documents. + +text.xml + Sample XML instance document. + +text.hxx +text.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 text.xsd. + +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 uses + both the underlying DOM and statically-typed mapping to perform the + transformation. + +To run the example on the sample XML instance document simply execute: + +$ ./driver text.xml diff --git a/xsd-examples/cxx/tree/mixed/buildfile b/xsd-examples/cxx/tree/mixed/buildfile new file mode 100644 index 0000000..4c1be8e --- /dev/null +++ b/xsd-examples/cxx/tree/mixed/buildfile @@ -0,0 +1,27 @@ +# file : cxx/tree/mixed/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -text} {hxx ixx cxx}{text} $libs + +exe{driver}: xml{text}: test.input = true + +<{hxx ixx cxx}{text}>: xsd{text} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-examples/cxx/tree/mixed/driver.cxx b/xsd-examples/cxx/tree/mixed/driver.cxx new file mode 100644 index 0000000..cf64e7f --- /dev/null +++ b/xsd-examples/cxx/tree/mixed/driver.cxx @@ -0,0 +1,122 @@ +// file : cxx/tree/mixed/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include + +#include + +#include "text.hxx" + +// The following transcode() utility function is handy when working with +// Xerces. Include it after the generated header in order to get only char +// or wchar_t version depending on how you compiled your schemas. +// +#include + +using std::cout; +using std::cerr; +using std::endl; +using std::unique_ptr; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " text.xml" << endl; + return 1; + } + + using namespace xercesc; + + int r (0); + + // The Xerces-C++ DOM objects that will be associated with the + // document tree "out-live" the call to the parsing function. + // Therefore we need to initialize the Xerces-C++ runtime + // ourselves. + // + XMLPlatformUtils::Initialize (); + + try + { + unique_ptr t ( + text_ (argv[1], + xml_schema::flags::keep_dom | + xml_schema::flags::dont_initialize)); + + // The DOM association can be recreated in a copy (the underlying + // DOM document is cloned) if explicitly requested with the keep_dom + // flag and only if this copy is "complete", i.e., made from the root + // of the tree. + // + text copy (*t, xml_schema::flags::keep_dom); + + // Print text. + // + { + namespace xml = xsd::cxx::xml; + + unsigned long ref (0); + DOMNode* root (copy._node ()); + + for (DOMNode* n (root->getFirstChild ()); + n != 0; + n = n->getNextSibling ()) + { + switch (n->getNodeType ()) + { + case DOMNode::TEXT_NODE: + { + cout << xml::transcode (n->getTextContent ()); + break; + } + case DOMNode::ELEMENT_NODE: + { + // Let's get back to a tree node from this DOM node. + // + xml_schema::type& t ( + *reinterpret_cast ( + n->getUserData (xml_schema::dom::tree_node_key))); + + anchor& a (dynamic_cast (t)); + + cout << a << "[" << ref << "]"; + + // Or we could continue using DOM interface: + // + //cout << xml::transcode (n->getTextContent ()) + // << "[" << ref << "]"; + + ++ref; + break; + } + default: + break; // Ignore all other nodes (e.g., comments, etc). + } + } + } + + // Print references. + // + { + unsigned long r (0); + + for (text::a_const_iterator i (copy.a ().begin ()); + i != copy.a ().end (); + ++i, ++r) + { + cout << "[" << r << "] " << i->href () << endl; + } + } + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + r = 1; + } + + XMLPlatformUtils::Terminate (); + return r; +} diff --git a/xsd-examples/cxx/tree/mixed/text.xml b/xsd-examples/cxx/tree/mixed/text.xml new file mode 100644 index 0000000..dfe730e --- /dev/null +++ b/xsd-examples/cxx/tree/mixed/text.xml @@ -0,0 +1,17 @@ + + + + + + +The first paragraph of this text talks about time. + +And this paragraph talks about space. + + diff --git a/xsd-examples/cxx/tree/mixed/text.xsd b/xsd-examples/cxx/tree/mixed/text.xsd new file mode 100644 index 0000000..f3c023d --- /dev/null +++ b/xsd-examples/cxx/tree/mixed/text.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/multiroot/.gitignore b/xsd-examples/cxx/tree/multiroot/.gitignore new file mode 100644 index 0000000..f493b6c --- /dev/null +++ b/xsd-examples/cxx/tree/multiroot/.gitignore @@ -0,0 +1 @@ +protocol.?xx diff --git a/xsd-examples/cxx/tree/multiroot/README b/xsd-examples/cxx/tree/multiroot/README new file mode 100644 index 0000000..b742422 --- /dev/null +++ b/xsd-examples/cxx/tree/multiroot/README @@ -0,0 +1,45 @@ +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/xsd-examples/cxx/tree/multiroot/balance.xml b/xsd-examples/cxx/tree/multiroot/balance.xml new file mode 100644 index 0000000..5f4a441 --- /dev/null +++ b/xsd-examples/cxx/tree/multiroot/balance.xml @@ -0,0 +1,16 @@ + + + + + + + 123456789 + + diff --git a/xsd-examples/cxx/tree/multiroot/buildfile b/xsd-examples/cxx/tree/multiroot/buildfile new file mode 100644 index 0000000..dc10588 --- /dev/null +++ b/xsd-examples/cxx/tree/multiroot/buildfile @@ -0,0 +1,26 @@ +# file : cxx/tree/multiroot/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} xml{balance deposit withdraw} doc{README} + +exe{driver}: {hxx cxx}{* -protocol} {hxx ixx cxx}{protocol} $libs testscript + +<{hxx ixx cxx}{protocol}>: xsd{protocol} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-examples/cxx/tree/multiroot/deposit.xml b/xsd-examples/cxx/tree/multiroot/deposit.xml new file mode 100644 index 0000000..9db2a2a --- /dev/null +++ b/xsd-examples/cxx/tree/multiroot/deposit.xml @@ -0,0 +1,17 @@ + + + + + + + 123456789 + 1000000 + + diff --git a/xsd-examples/cxx/tree/multiroot/dom-parse.cxx b/xsd-examples/cxx/tree/multiroot/dom-parse.cxx new file mode 100644 index 0000000..e67c187 --- /dev/null +++ b/xsd-examples/cxx/tree/multiroot/dom-parse.cxx @@ -0,0 +1,93 @@ +// file : 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::unique_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::unique_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::unique_ptr doc (parser->parse (&wrap)); + + eh.throw_if_failed > (); + + return doc; +} diff --git a/xsd-examples/cxx/tree/multiroot/dom-parse.hxx b/xsd-examples/cxx/tree/multiroot/dom-parse.hxx new file mode 100644 index 0000000..3699a77 --- /dev/null +++ b/xsd-examples/cxx/tree/multiroot/dom-parse.hxx @@ -0,0 +1,22 @@ +// file : 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::unique_ptr +parse (std::istream& is, + const std::string& id, + bool validate); + +#endif // DOM_PARSE diff --git a/xsd-examples/cxx/tree/multiroot/driver.cxx b/xsd-examples/cxx/tree/multiroot/driver.cxx new file mode 100644 index 0000000..d22c25e --- /dev/null +++ b/xsd-examples/cxx/tree/multiroot/driver.cxx @@ -0,0 +1,124 @@ +// file : cxx/tree/multiroot/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_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. +// +unique_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::unique_ptr doc (parse (is, id, true)); + + DOMElement* root (doc->getDocumentElement ()); + + string ns (xml::transcode (root->getNamespaceURI ())); + string name (xml::transcode (root->getLocalName ())); + + unique_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]); + + unique_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/xsd-examples/cxx/tree/multiroot/protocol.xsd b/xsd-examples/cxx/tree/multiroot/protocol.xsd new file mode 100644 index 0000000..2fe9456 --- /dev/null +++ b/xsd-examples/cxx/tree/multiroot/protocol.xsd @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/multiroot/testscript b/xsd-examples/cxx/tree/multiroot/testscript new file mode 100644 index 0000000..383bed4 --- /dev/null +++ b/xsd-examples/cxx/tree/multiroot/testscript @@ -0,0 +1,6 @@ +# file : cxx/tree/multiroot/testscript +# license : not copyrighted - public domain + +$* $src_base/balance.xml 2>| : balance +$* $src_base/withdraw.xml 2>| : withdraw +$* $src_base/deposit.xml 2>| : deposit diff --git a/xsd-examples/cxx/tree/multiroot/withdraw.xml b/xsd-examples/cxx/tree/multiroot/withdraw.xml new file mode 100644 index 0000000..f98ad16 --- /dev/null +++ b/xsd-examples/cxx/tree/multiroot/withdraw.xml @@ -0,0 +1,17 @@ + + + + + + + 123456789 + 1000000 + + diff --git a/xsd-examples/cxx/tree/order/README b/xsd-examples/cxx/tree/order/README new file mode 100644 index 0000000..7125a2d --- /dev/null +++ b/xsd-examples/cxx/tree/order/README @@ -0,0 +1,11 @@ +This directory contains a number of examples that show how to use ordered +types to capture and maintain content order. The following list gives an +overview of each example: + +element + Shows how to use ordered types to capture and maintain element order, + including element wildcards. + +mixed + Shows how to use ordered types to capture mixed content text and to + maintain order information between elements and text. diff --git a/xsd-examples/cxx/tree/order/element/.gitignore b/xsd-examples/cxx/tree/order/element/.gitignore new file mode 100644 index 0000000..2fff792 --- /dev/null +++ b/xsd-examples/cxx/tree/order/element/.gitignore @@ -0,0 +1 @@ +transactions.?xx diff --git a/xsd-examples/cxx/tree/order/element/README b/xsd-examples/cxx/tree/order/element/README new file mode 100644 index 0000000..19f2381 --- /dev/null +++ b/xsd-examples/cxx/tree/order/element/README @@ -0,0 +1,35 @@ +This example shows how to use ordered types to capture and maintain +element order, including element wildcards. + +The example consists of the following files: + +transactions.xsd + XML Schema which describes various bank transactions. A batch of + transactions can contain any number of different transactions in + any order but the order of transaction in the batch is significant. + +library.xml + Sample XML instance document. + +transactions.hxx +transactions.cxx + C++ types that represent the given vocabulary as well as a set of + parsing and serialization functions. These are generated by XSD + from transactions.xsd. Note that the --ordered-type option is + used to indicate to the XSD compiler that the batch type is + ordered. We also use the --generate-wildcard option to enable + wildcard support. An element wildcard is used in the batch to + allow transaction extensions. + +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 + iterates over transactions in the batch using the content order + sequence. The driver then performs various modifications of the + object model while showing how to maintain the content order. + Finally, it saves the modified transaction batch back to XML to + verify that the content order is preserved in the output document. + +To run the example on the sample XML instance document simply execute: + +$ ./driver transactions.xml diff --git a/xsd-examples/cxx/tree/order/element/buildfile b/xsd-examples/cxx/tree/order/element/buildfile new file mode 100644 index 0000000..eb3834e --- /dev/null +++ b/xsd-examples/cxx/tree/order/element/buildfile @@ -0,0 +1,30 @@ +# file : cxx/tree/order/element/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -transactions} {hxx ixx cxx}{transactions} $libs + +exe{driver}: xml{transactions}: test.input = true + +<{hxx ixx cxx}{transactions}>: xsd{transactions} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --generate-wildcard \ + --ordered-type batch \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-examples/cxx/tree/order/element/driver.cxx b/xsd-examples/cxx/tree/order/element/driver.cxx new file mode 100644 index 0000000..2f62700 --- /dev/null +++ b/xsd-examples/cxx/tree/order/element/driver.cxx @@ -0,0 +1,147 @@ +// file : cxx/tree/order/element/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include +#include + +#include +#include + +#include "transactions.hxx" + +// The following string class keeps us sane when working with Xerces. +// Include it after the generated header in order to get only char or +// wchar_t version depending on how you compiled your schemas. +// +#include + +using std::cerr; +using std::endl; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " transactions.xml" << endl; + return 1; + } + + using namespace xercesc; + + int r (0); + + // The Xerces-C++ DOM objects that will be used to store the + // content matched by the wildcard "out-lives" the call to the + // parsing function. Therefore we need to initialize the + // Xerces-C++ runtime ourselves. + // + XMLPlatformUtils::Initialize (); + + try + { + using namespace transactions; + + // Parse the batch. + // + std::unique_ptr b ( + batch_ (argv[1], xml_schema::flags::dont_initialize)); + + // Print what we've got in content order. + // + for (batch::content_order_const_iterator i (b->content_order ().begin ()); + i != b->content_order ().end (); + ++i) + { + switch (i->id) + { + case batch::balance_id: + { + const balance& t (b->balance ()[i->index]); + cerr << t.account () << " balance" << endl; + break; + } + case batch::withdraw_id: + { + const withdraw& t (b->withdraw ()[i->index]); + cerr << t.account () << " withdraw " << t.amount () << endl; + break; + } + case batch::deposit_id: + { + const deposit& t (b->deposit ()[i->index]); + cerr << t.account () << " deposit " << t.amount () << endl; + break; + } + case batch::any_id: + { + namespace xml = xsd::cxx::xml; + + const DOMElement& e (b->any ()[i->index]); + cerr << xml::transcode (e.getLocalName ()) << endl; + break; + } + default: + { + assert (false); // Unknown content id. + } + } + } + + cerr << endl; + + // Modify the transaction batch. First remove the last transaction. + // Note that we have to update both the content itself and content + // order sequences. + // + batch::content_order_sequence& co (b->content_order ()); + + co.pop_back (); + b->withdraw ().pop_back (); + + // Now add a few more transactions. Again we have to add both the + // content and its ordering. The order information consists of the + // content id and, in case of a sequence, the index. + // + b->deposit ().push_back (deposit (123456789, 100000)); + co.push_back ( + batch::content_order_type ( + batch::deposit_id, b->deposit ().size () - 1)); + + // The next transaction we add at the beginning of the batch. + // + b->balance ().push_back (balance (123456789)); + co.insert (co.begin (), + batch::content_order_type ( + batch::balance_id, b->balance ().size () - 1)); + + // Note also that when we merely modify the content of one + // of the elements in place, we don't need to update its + // order. For example: + // + b->deposit ()[0].amount (2000000); + + // Serialize the modified transaction batch back to XML. + // + xml_schema::namespace_infomap map; + + map[""].name = "http://www.codesynthesis.com/transactions"; + map[""].schema = "transactions.xsd"; + map["te"].name = "http://www.codesynthesis.com/transactions-extras"; + + batch_ (std::cout, + *b, + map, + "UTF-8", + xml_schema::flags::dont_initialize); + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + r = 1; + } + + XMLPlatformUtils::Terminate (); + return r; +} diff --git a/xsd-examples/cxx/tree/order/element/transactions.xml b/xsd-examples/cxx/tree/order/element/transactions.xml new file mode 100644 index 0000000..7af9ab1 --- /dev/null +++ b/xsd-examples/cxx/tree/order/element/transactions.xml @@ -0,0 +1,32 @@ + + + + + + + 123456789 + 1000000 + + + + 123456789 + + + + 123456789 + 500000 + + + + 123456789 + 500000 + + diff --git a/xsd-examples/cxx/tree/order/element/transactions.xsd b/xsd-examples/cxx/tree/order/element/transactions.xsd new file mode 100644 index 0000000..7a63c9f --- /dev/null +++ b/xsd-examples/cxx/tree/order/element/transactions.xsd @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/order/mixed/.gitignore b/xsd-examples/cxx/tree/order/mixed/.gitignore new file mode 100644 index 0000000..cbeac00 --- /dev/null +++ b/xsd-examples/cxx/tree/order/mixed/.gitignore @@ -0,0 +1 @@ +text.?xx diff --git a/xsd-examples/cxx/tree/order/mixed/README b/xsd-examples/cxx/tree/order/mixed/README new file mode 100644 index 0000000..e66c1ad --- /dev/null +++ b/xsd-examples/cxx/tree/order/mixed/README @@ -0,0 +1,45 @@ +This example shows how to use ordered types to capture mixed content +text and to maintain order information between elements and text. + +In this example we use mixed content model to describe text with +embedded links in the form: + + This paragraph talks about time. + +The example transforms such text into plain text with references in +the form: + + This paragraph talks about time[uri]. + +It also saves the modified text back to XML in order to verify the +element and text order. + +The example consists of the following files: + +text.xsd + XML Schema which describes "text with links" instance documents. + +text.xml + Sample XML instance document. + +text.hxx +text.cxx + C++ types that represent the given vocabulary as well as a set of + parsing and serialization functions. These are generated by XSD + from text.xsd. Note that the --ordered-type-mixed option is used + to indicate to the XSD compiler that all types with mixed content + should be automatically treated as ordered. + +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 + iterates over the text and elements in the content order to convert + the document to its plain text representation. The driver then adds + another paragraph of text and a link to the object model while showing + how to maintain the content order. Finally, it saves the modified + text back to XML to verify that the content order is preserved in + the output document. + +To run the example on the sample XML instance document simply execute: + +$ ./driver text.xml diff --git a/xsd-examples/cxx/tree/order/mixed/buildfile b/xsd-examples/cxx/tree/order/mixed/buildfile new file mode 100644 index 0000000..149bca0 --- /dev/null +++ b/xsd-examples/cxx/tree/order/mixed/buildfile @@ -0,0 +1,25 @@ +# file : cxx/tree/order/mixed/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -text} {hxx ixx cxx}{text} $libs + +exe{driver}: xml{text}: test.input = true + +<{hxx ixx cxx}{text}>: xsd{text} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --ordered-type-mixed \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-examples/cxx/tree/order/mixed/driver.cxx b/xsd-examples/cxx/tree/order/mixed/driver.cxx new file mode 100644 index 0000000..a18f4ad --- /dev/null +++ b/xsd-examples/cxx/tree/order/mixed/driver.cxx @@ -0,0 +1,89 @@ +// file : cxx/tree/order/mixed/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include +#include + +#include "text.hxx" + +using std::cerr; +using std::endl; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " text.xml" << endl; + return 1; + } + + try + { + std::unique_ptr t (text_ (argv[1])); + + // Print what we've got in content order. + // + for (text::content_order_const_iterator i (t->content_order ().begin ()); + i != t->content_order ().end (); + ++i) + { + switch (i->id) + { + case text::a_id: + { + const anchor& a (t->a ()[i->index]); + cerr << a << "[" << a.href () << "]"; + break; + } + case text::text_content_id: + { + const xml_schema::string& s (t->text_content ()[i->index]); + cerr << s; + break; + } + default: + { + assert (false); // Unknown content id. + } + } + } + + cerr << endl; + + // Modify the document. Note that we have to update both the content + // itself and content order sequences. + // + typedef text::content_order_type order_type; + + text::content_order_sequence& co (t->content_order ()); + text::text_content_sequence& tc (t->text_content ()); + + tc.push_back ("The last paragraph doesn't talk about "); + co.push_back (order_type (text::text_content_id, tc.size () - 1)); + + t->a ().push_back (anchor ("anything", "http://en.wikipedia.org")); + co.push_back (order_type (text::a_id, t->a ().size () - 1)); + + tc.push_back (" in particular.\n\n"); + co.push_back (order_type (text::text_content_id, tc.size () - 1)); + + // Serialize the modified document back to XML. + // + xml_schema::namespace_infomap map; + + map[""].schema = "text.xsd"; + + text_ (std::cout, + *t, + map, + "UTF-8", + xml_schema::flags::dont_pretty_print); + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-examples/cxx/tree/order/mixed/text.xml b/xsd-examples/cxx/tree/order/mixed/text.xml new file mode 100644 index 0000000..3d7476d --- /dev/null +++ b/xsd-examples/cxx/tree/order/mixed/text.xml @@ -0,0 +1,17 @@ + + + + + + +The first paragraph of this text talks about time. + +And this paragraph talks about space. + + diff --git a/xsd-examples/cxx/tree/order/mixed/text.xsd b/xsd-examples/cxx/tree/order/mixed/text.xsd new file mode 100644 index 0000000..b55d214 --- /dev/null +++ b/xsd-examples/cxx/tree/order/mixed/text.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/performance/.gitignore b/xsd-examples/cxx/tree/performance/.gitignore new file mode 100644 index 0000000..b143f97 --- /dev/null +++ b/xsd-examples/cxx/tree/performance/.gitignore @@ -0,0 +1,5 @@ +gen + +# Testscript output directory (can be symlink). +# +test-gen diff --git a/xsd-examples/cxx/tree/performance/README b/xsd-examples/cxx/tree/performance/README new file mode 100644 index 0000000..0206387 --- /dev/null +++ b/xsd-examples/cxx/tree/performance/README @@ -0,0 +1,62 @@ +This example measures the performance of parsing and serialization in +the C++/Tree mapping. It also shows how to structure your code to +achieve the maximum performance for these two operations. + +The example consists of the following files: + +test.xsd + XML Schema which describes the test vocabulary. + +test-50k.xml + Test XML document. + +gen.cxx + Program to generate a test document of desired size. + +time.hxx +time.cxx + Class definition that represents time. + +test.hxx +test.ixx +test.cxx + C++ types that represent the given vocabulary, a set of parsing + functions that convert XML 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 the XSD compiler from + test.xsd. + +parsing.cxx + Parsing performance test. It first reads the entire document into + a memory buffer. It then creates a DOM parser and pre-parses and + caches the schema if validation is enabled. Finally, it runs the + performance measurement loop which on each iteration parses the + XML document from the in-memory buffer into DOM and then DOM to + the object model. + +serialization.cxx + Serialization performance test. It first parses the XML document + into the object model. It then creates a memory buffer into which + the document is serialized and a DOM serializer. Finally, it runs + the performance measurement loop which on each iteration serializes + the object model to DOM and DOM to XML. + +driver.cxx + Driver for the example. It first parses the command line arguments. + It then initializes the Xerces-C++ runtime and calls the parsing + and serialization tests described above. + +To run the example on a test XML document simply execute: + +$ ./driver test-50k.xml + +The -v option can be used to turn on validation in the underlying XML +parser (off by default). The -i option can be used to specify the +number of parsing and serialization iterations (1000 by default). For +example: + +$ ./driver -v -i 100 test-50k.xml + +To generate the test document execute, for example: + +$ ./gen 633 test-100k.xml diff --git a/xsd-examples/cxx/tree/performance/buildfile b/xsd-examples/cxx/tree/performance/buildfile new file mode 100644 index 0000000..e9faeef --- /dev/null +++ b/xsd-examples/cxx/tree/performance/buildfile @@ -0,0 +1,36 @@ +# file : cxx/tree/performance/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: doc{README} + +# exe{driver} +# +./: exe{driver}: {hxx cxx}{* -gen -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test-50k}: test.input = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --output-dir $out_base \ + $path($<[0]) +}} + +# exe{gen} +# +./: exe{gen}: cxx{gen} testscript{gen} + +# Build options. +# +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-examples/cxx/tree/performance/driver.cxx b/xsd-examples/cxx/tree/performance/driver.cxx new file mode 100644 index 0000000..b156f84 --- /dev/null +++ b/xsd-examples/cxx/tree/performance/driver.cxx @@ -0,0 +1,90 @@ +// file : cxx/tree/performance/driver.cxx +// copyright : not copyrighted - public domain + +#include +#include +#include + +#include + +using namespace std; + +// See parsing.cxx +// +bool +parsing (const char* file, unsigned long iter, bool validate); + +// See serialization.cxx +// +bool +serialization (const char* file, unsigned long iter); + +int +main (int argc, char* argv[]) +{ + if (argc < 2) + { + cerr << "usage: " << argv[0] << " [-v] [-i ] test.xml" << endl + << "\t -v turn on validation (default is off)" << endl + << "\t -i number of iterations to perform (default is 1000)" << endl; + return 1; + } + + bool validate (false); + unsigned long iter (1000); + const char* file (0); + + // Parse command line arguments. + // + for (int i (1); i < argc; ++i) + { + std::string arg (argv[i]); + + if (arg == "-v") + { + validate = true; + } + else if (arg == "-i") + { + if (++i == argc) + { + cerr << "argument expected for the -i option" << endl; + return 1; + } + + iter = 0; + istringstream is (argv[i]); + is >> iter; + + if (iter == 0) + { + cerr << "invalid argument for the -i option" << endl; + return 1; + } + } + else + { + file = argv[i]; + break; + } + } + + if (file == 0) + { + cerr << "no input file specified" << endl; + return 1; + } + + int r (0); + + xercesc::XMLPlatformUtils::Initialize (); + + // Call parsing and serialization tests. + // + if (!parsing (file, iter, validate) || !serialization (file, iter)) + r = 1; + + xercesc::XMLPlatformUtils::Terminate (); + + return r; +} diff --git a/xsd-examples/cxx/tree/performance/gen.cxx b/xsd-examples/cxx/tree/performance/gen.cxx new file mode 100644 index 0000000..b6392c0 --- /dev/null +++ b/xsd-examples/cxx/tree/performance/gen.cxx @@ -0,0 +1,76 @@ +#include +#include +#include + +using namespace std; + +static const char* enums[] = +{ + "romance", + "fiction", + "horror", + "history", + "philosophy" +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 3) + { + cerr << "usage: " << argv[0] << " " << endl; + return 1; + } + + unsigned long n (0); + istringstream is (argv[1]); + is >> n; + + if (n == 0) + { + cerr << "record count argument should be a positive number" << endl; + return 1; + } + + ofstream ofs (argv[2]); + + if (!ofs.is_open ()) + { + cerr << "unable to open '" << argv[2] << "' in write mode" << endl; + return 1; + } + + ofs << ""; + + unsigned short ch (1), en (0); + + for (unsigned long i (0); i < n; ++i) + { + ofs << "" + << "42" + << "42345.4232" + << "name123_45"; + + if (i % 2 == 1) + ofs << "one two three"; + + ofs << "" << ch << " choice" + << "" << enums[en] << "" + << ""; + + if (++ch > 4) + ch = 1; + + if (++en > 4) + en = 0; + } + + ofs << ""; +} diff --git a/xsd-examples/cxx/tree/performance/gen.testscript b/xsd-examples/cxx/tree/performance/gen.testscript new file mode 100644 index 0000000..deefc05 --- /dev/null +++ b/xsd-examples/cxx/tree/performance/gen.testscript @@ -0,0 +1,9 @@ +# file : cxx/tree/performance/gen.testscript +# license : not copyrighted - public domain + +: 50k +: +{ + $* 317 test-50k.xml &test-50k.xml; + cat test-50k.xml >>>$src_base/test-50k.xml +} diff --git a/xsd-examples/cxx/tree/performance/parsing.cxx b/xsd-examples/cxx/tree/performance/parsing.cxx new file mode 100644 index 0000000..c41b57d --- /dev/null +++ b/xsd-examples/cxx/tree/performance/parsing.cxx @@ -0,0 +1,172 @@ +// file : cxx/tree/performance/parsing.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include // std::size_t +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include + +#include + +#include +#include + +#include "time.hxx" +#include "test.hxx" + +using namespace std; + +bool +parsing (const char* file, unsigned long iter, bool validate) +{ + try + { + cerr << "parsing:" << endl; + + ifstream ifs; + ifs.exceptions (ios_base::failbit); + ifs.open (file, ios::in | ios::ate); + + size_t size (ifs.tellg ()); + ifs.seekg (0, ios::beg); + + char* buf = new char[size]; + ifs.read (buf, size); + ifs.close (); + + cerr << " document size: " << size << " bytes" << endl + << " iterations: " << iter << endl; + + // Create XML parser that we are going to use in all iterations. + // + using namespace xercesc; + + const XMLCh ls_id[] = + {xercesc::chLatin_L, xercesc::chLatin_S, xercesc::chNull}; + + DOMImplementation* impl ( + DOMImplementationRegistry::getDOMImplementation (ls_id)); + + // Use the error handler implementation provided by the XSD runtime. + // + xsd::cxx::tree::error_handler eh; + xsd::cxx::xml::dom::bits::error_handler_proxy ehp (eh); + + xml_schema::dom::unique_ptr parser ( + impl->createLSParser (DOMImplementationLS::MODE_SYNCHRONOUS, 0)); + + DOMConfiguration* conf (parser->getDomConfig ()); + + conf->setParameter (XMLUni::fgDOMComments, false); + conf->setParameter (XMLUni::fgDOMDatatypeNormalization, true); + conf->setParameter (XMLUni::fgDOMEntities, false); + conf->setParameter (XMLUni::fgDOMNamespaces, true); + conf->setParameter (XMLUni::fgDOMElementContentWhitespace, false); + + // Set error handler. + // + conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp); + + if (validate) + { + conf->setParameter (XMLUni::fgDOMValidate, true); + conf->setParameter (XMLUni::fgXercesSchema, true); + 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 + + // If we are validating, pre-load and cache the schema. + // + if (!parser->loadGrammar ("test.xsd", Grammar::SchemaGrammarType, true)) + { + // In Xerces-C++ grammar loading failure results in just a warning. + // Make it a fatal error. + // + eh.handle ("test.xsd", 0, 0, + xsd::cxx::tree::error_handler::severity::fatal, + "unable to load schema"); + } + + eh.throw_if_failed (); + conf->setParameter (XMLUni::fgXercesUseCachedGrammarInParse, true); + conf->setParameter (XMLUni::fgXercesLoadSchema, false); + } + else + { + conf->setParameter (XMLUni::fgDOMValidate, false); + conf->setParameter (XMLUni::fgXercesSchema, false); + conf->setParameter (XMLUni::fgXercesSchemaFullChecking, false); + } + + conf->setParameter (XMLUni::fgXercesUserAdoptsDOMDocument, true); + + // Create memory buffer input source. + // + MemBufInputSource is ( + reinterpret_cast (buf), size, file, false); + is.setCopyBufToStream (false); + Wrapper4InputSource wis (&is, false); + + // Parsing loop. + // + os::time start; + + for (unsigned long i (0); i < iter; ++i) + { + // First parse XML to DOM reusing the parser we created above. + // + xml_schema::dom::unique_ptr doc (parser->parse (&wis)); + eh.throw_if_failed (); + + // Then parse DOM to the object model. + // + unique_ptr r (test::root_ (*doc)); + } + + os::time end; + os::time time (end - start); + + delete[] buf; + + cerr << " time: " << time << " sec" << endl; + + double ms (time.sec () * 1000000ULL + time.nsec () / 1000ULL); + + // Calculate throughput in documents/sec. + // + double tpd ((iter / ms) * 1000000); + cerr << " throughput: " << tpd << " documents/sec" << endl; + + // Calculate throughput in MBytes/sec. + // + double tpb (((size * iter) / ms) * 1000000/(1024*1024)); + cerr << " throughput: " << tpb << " MBytes/sec" << endl; + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + return false; + } + catch (std::ios_base::failure const&) + { + cerr << "io failure" << endl; + return false; + } + + return true; +} diff --git a/xsd-examples/cxx/tree/performance/serialization.cxx b/xsd-examples/cxx/tree/performance/serialization.cxx new file mode 100644 index 0000000..e81fcbd --- /dev/null +++ b/xsd-examples/cxx/tree/performance/serialization.cxx @@ -0,0 +1,132 @@ +// file : cxx/tree/performance/serialization.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include // std::size_t +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include + +#include "time.hxx" +#include "test.hxx" + +using namespace std; + +bool +serialization (const char* file, unsigned long iter) +{ + try + { + using namespace xercesc; + + cerr << "serialization:" << endl; + + // Get the object model using the standard parsing function. + // + unique_ptr r ( + test::root_ (file, + xml_schema::flags::dont_initialize | + xml_schema::flags::dont_validate)); + + // Serialize it to the in-memory buffer. This makes sure the buffer + // pre-allocates enough memory. + // + xml_schema::namespace_infomap map; + map["t"].name = "test"; + map["t"].schema = "test.xsd"; + + MemBufFormatTarget ft (10240); + test::root_ (ft, *r, map, "UTF-8", + xml_schema::flags::dont_initialize | + xml_schema::flags::dont_pretty_print | + xml_schema::flags::no_xml_declaration); + + size_t size (ft.getLen ()); + cerr << " document size: " << size << " bytes" << endl + << " iterations: " << iter << endl; + + // Create XML serializer that we are going to use in all iterations. + // + const XMLCh ls_id[] = + {xercesc::chLatin_L, xercesc::chLatin_S, xercesc::chNull}; + + DOMImplementation* impl ( + DOMImplementationRegistry::getDOMImplementation (ls_id)); + + // Use the error handler implementation provided by the XSD runtime. + // + xsd::cxx::tree::error_handler eh; + xsd::cxx::xml::dom::bits::error_handler_proxy ehp (eh); + + xml_schema::dom::unique_ptr writer ( + impl->createLSSerializer ()); + + DOMConfiguration* conf (writer->getDomConfig ()); + + conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp); + conf->setParameter (XMLUni::fgDOMXMLDeclaration, false); + + xml_schema::dom::unique_ptr out (impl->createLSOutput ()); + + out->setByteStream (&ft); + + // Serialization loop. + // + os::time start; + + for (unsigned long i (0); i < iter; ++i) + { + // First serialize the object model to DOM. + // + xml_schema::dom::unique_ptr doc (test::root_ (*r, map)); + + ft.reset (); + + // Then serialize DOM to XML reusing the serializer we created above. + // + writer->write (doc.get (), out.get ()); + eh.throw_if_failed (); + } + + os::time end; + os::time time (end - start); + + cerr << " time: " << time << " sec" << endl; + + double ms (time.sec () * 1000000ULL + time.nsec () / 1000ULL); + + // Calculate throughput in documents/sec. + // + double tpd ((iter / ms) * 1000000); + cerr << " throughput: " << tpd << " documents/sec" << endl; + + // Calculate throughput in MBytes/sec. + // + double tpb (((size * iter) / ms) * 1000000/(1024*1024)); + cerr << " throughput: " << tpb << " MBytes/sec" << endl; + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + return false; + } + catch (std::ios_base::failure const&) + { + cerr << "io failure" << endl; + return false; + } + + return true; +} diff --git a/xsd-examples/cxx/tree/performance/test-50k.xml b/xsd-examples/cxx/tree/performance/test-50k.xml new file mode 100644 index 0000000..42e22f3 --- /dev/null +++ b/xsd-examples/cxx/tree/performance/test-50k.xml @@ -0,0 +1 @@ +4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction4242345.4232name123_45one two three2 choicehorror4242345.4232name123_453 choicehistory4242345.4232name123_45one two three4 choicephilosophy4242345.4232name123_451 choiceromance4242345.4232name123_45one two three2 choicefiction4242345.4232name123_453 choicehorror4242345.4232name123_45one two three4 choicehistory4242345.4232name123_451 choicephilosophy4242345.4232name123_45one two three2 choiceromance4242345.4232name123_453 choicefiction4242345.4232name123_45one two three4 choicehorror4242345.4232name123_451 choicehistory4242345.4232name123_45one two three2 choicephilosophy4242345.4232name123_453 choiceromance4242345.4232name123_45one two three4 choicefiction4242345.4232name123_451 choicehorror4242345.4232name123_45one two three2 choicehistory4242345.4232name123_453 choicephilosophy4242345.4232name123_45one two three4 choiceromance4242345.4232name123_451 choicefiction \ No newline at end of file diff --git a/xsd-examples/cxx/tree/performance/test.xsd b/xsd-examples/cxx/tree/performance/test.xsd new file mode 100644 index 0000000..98ee921 --- /dev/null +++ b/xsd-examples/cxx/tree/performance/test.xsd @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/performance/time.cxx b/xsd-examples/cxx/tree/performance/time.cxx new file mode 100644 index 0000000..48385a1 --- /dev/null +++ b/xsd-examples/cxx/tree/performance/time.cxx @@ -0,0 +1,46 @@ +// file : cxx/tree/performance/time.cxx +// copyright : not copyrighted - public domain + +#include "time.hxx" + +#if defined (WIN32) || defined (__WIN32__) +# define WIN32_LEAN_AND_MEAN +# include // GetSystemTimeAsFileTime +#else +# include // gettimeofday +# include // timeval +#endif + +#include // std::ostream +#include // std::setfill, std::setw + +namespace os +{ + time:: + time () + { +#if defined (WIN32) || defined (__WIN32__) + FILETIME ft; + GetSystemTimeAsFileTime (&ft); + unsigned long long v ( + ((unsigned long long) (ft.dwHighDateTime) << 32) + ft.dwLowDateTime); + + sec_ = static_cast (v / 10000000ULL); + nsec_ = static_cast ((v % 10000000ULL) * 100); +#else + timeval tv; + if (gettimeofday(&tv, 0) != 0) + throw failed (); + + sec_ = static_cast (tv.tv_sec); + nsec_ = static_cast (tv.tv_usec * 1000); +#endif + } + + std::ostream& + operator<< (std::ostream& o, time const& t) + { + return o << t.sec () << '.' + << std::setfill ('0') << std::setw (9) << t.nsec (); + } +} diff --git a/xsd-examples/cxx/tree/performance/time.hxx b/xsd-examples/cxx/tree/performance/time.hxx new file mode 100644 index 0000000..b05414b --- /dev/null +++ b/xsd-examples/cxx/tree/performance/time.hxx @@ -0,0 +1,110 @@ +// file : cxx/tree/performance/time.hxx +// copyright : not copyrighted - public domain + +#ifndef TIME_HXX +#define TIME_HXX + +#include // std::ostream& + +namespace os +{ + class time + { + public: + class failed {}; + + // Create a time object representing the current time. + // + time (); + + time (unsigned long long nsec) + { + sec_ = static_cast (nsec / 1000000000ULL); + nsec_ = static_cast (nsec % 1000000000ULL); + } + + time (unsigned long sec, unsigned long nsec) + { + sec_ = sec; + nsec_ = nsec; + } + + public: + unsigned long + sec () const + { + return sec_; + } + + unsigned long + nsec () const + { + return nsec_; + } + + public: + class overflow {}; + class underflow {}; + + time + operator+= (time const& b) + { + unsigned long long tmp = 0ULL + nsec_ + b.nsec_; + + sec_ += static_cast (b.sec_ + tmp / 1000000000ULL); + nsec_ = static_cast (tmp % 1000000000ULL); + + return *this; + } + + time + operator-= (time const& b) + { + if (*this < b) + throw underflow (); + + sec_ -= b.sec_; + + if (nsec_ < b.nsec_) + { + --sec_; + nsec_ += 1000000000ULL - b.nsec_; + } + else + nsec_ -= b.nsec_; + + return *this; + } + + friend time + operator+ (time const& a, time const& b) + { + time r (a); + r += b; + return r; + } + + friend time + operator- (time const& a, time const& b) + { + time r (a); + r -= b; + return r; + } + + friend bool + operator < (time const& a, time const& b) + { + return (a.sec_ < b.sec_) || (a.sec_ == b.sec_ && a.nsec_ < b.nsec_); + } + + private: + unsigned long sec_; + unsigned long nsec_; + }; + + std::ostream& + operator<< (std::ostream&, time const&); +} + +#endif // TIME_HXX diff --git a/xsd-examples/cxx/tree/polymorphism/.gitignore b/xsd-examples/cxx/tree/polymorphism/.gitignore new file mode 100644 index 0000000..f2e9b04 --- /dev/null +++ b/xsd-examples/cxx/tree/polymorphism/.gitignore @@ -0,0 +1 @@ +supermen.?xx diff --git a/xsd-examples/cxx/tree/polymorphism/README b/xsd-examples/cxx/tree/polymorphism/README new file mode 100644 index 0000000..6e54e49 --- /dev/null +++ b/xsd-examples/cxx/tree/polymorphism/README @@ -0,0 +1,32 @@ +This example shows how to use XML Schema polymorphism features such as +xsi:type attributes and substitution groups in the C++/Tree mapping. + +The example consists of the following files: + +supermen.xsd + XML Schema which describes the "supermen" instance documents. + +supermen.xml + Sample XML instance document. + +supermen.hxx +supermen.cxx + C++ types that represent the given 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 supermen.xsd. + Note also that we use the --generate-polymorphic command line option + and that we don't need to use --polymorphic-type to explicitly mark + types as polymorphic because this is automatically deduced by the + XSD compiler from the substitution groups used in the supermen.xsd + schema. + +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 content of the object model to STDERR. Finally, the driver serializes + the object model back to XML. + +To run the example on the sample XML instance document simply execute: + +$ ./driver instance.xml diff --git a/xsd-examples/cxx/tree/polymorphism/buildfile b/xsd-examples/cxx/tree/polymorphism/buildfile new file mode 100644 index 0000000..754c6c2 --- /dev/null +++ b/xsd-examples/cxx/tree/polymorphism/buildfile @@ -0,0 +1,26 @@ +# file : cxx/tree/polymorphism/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -supermen} {hxx ixx cxx}{supermen} $libs + +exe{driver}: xml{supermen}: test.input = true + +<{hxx ixx cxx}{supermen}>: xsd{supermen} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-polymorphic \ + --generate-serialization \ + --root-element-last \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-examples/cxx/tree/polymorphism/driver.cxx b/xsd-examples/cxx/tree/polymorphism/driver.cxx new file mode 100644 index 0000000..6458170 --- /dev/null +++ b/xsd-examples/cxx/tree/polymorphism/driver.cxx @@ -0,0 +1,59 @@ +// file : cxx/tree/polymorphism/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include + +#include "supermen.hxx" + +using std::cerr; +using std::endl; +using std::unique_ptr; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " supermen.xml" << endl; + return 1; + } + + try + { + unique_ptr sm (supermen_ (argv[1])); + + supermen copy (*sm); // Dynamic types are preserved in copies. + + // Print what we've got. + // + for (supermen::person_const_iterator i (copy.person ().begin ()); + i != copy.person ().end (); + ++i) + { + cerr << i->name (); + + if (const superman* s = dynamic_cast (&*i)) + { + if (s->can_fly ()) + cerr << ", flying superman"; + else + cerr << ", superman"; + } + + cerr << endl; + } + + // Serialize back to XML. + // + xml_schema::namespace_infomap map; + map[""].schema = "supermen.xsd"; + + supermen_ (std::cout, copy, map); + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-examples/cxx/tree/polymorphism/supermen.xml b/xsd-examples/cxx/tree/polymorphism/supermen.xml new file mode 100644 index 0000000..08430fa --- /dev/null +++ b/xsd-examples/cxx/tree/polymorphism/supermen.xml @@ -0,0 +1,25 @@ + + + + + + + + John Doe + + + + James "007" Bond + + + + Bruce Wayne + + + diff --git a/xsd-examples/cxx/tree/polymorphism/supermen.xsd b/xsd-examples/cxx/tree/polymorphism/supermen.xsd new file mode 100644 index 0000000..cf5ff0c --- /dev/null +++ b/xsd-examples/cxx/tree/polymorphism/supermen.xsd @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/secure/.gitignore b/xsd-examples/cxx/tree/secure/.gitignore new file mode 100644 index 0000000..c116ec1 --- /dev/null +++ b/xsd-examples/cxx/tree/secure/.gitignore @@ -0,0 +1 @@ +library.?xx diff --git a/xsd-examples/cxx/tree/secure/README b/xsd-examples/cxx/tree/secure/README new file mode 100644 index 0000000..649f0a3 --- /dev/null +++ b/xsd-examples/cxx/tree/secure/README @@ -0,0 +1,41 @@ +This example shows how to perform more secure XML parsing by disabling +the XML External Entity (XXE) Processing. If XML Schema validation is +used, then it would also make sense to pre-load the known schemas and +to disable loading of any external schemas, for example, via the +schemaLocation attribute found in the XML documents. See the comment +in driver.cxx for more information on how to achieve this. + +The example consists of the following files: + +library.xsd + XML Schema which describes a library of books. + +library.xml + Sample XML instance document. It includes (commented out) DOCTYPE + declarations with internal and external subsets that the parser + will refuse to process. + +library.hxx +library.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 the XSD compiler from library.xsd. + +secure-dom-parser.hxx +secure-dom-parser.cxx + A secure Xerces-C++ DOM parser implementation that disables processing + of internal/external DTD subsets. + +driver.cxx + Driver for the example. It first sets up the secure DOM parser. It then + parses the input file to a DOM document using the secure DOM parser and + calls one of the parsing functions that constructs the object model from + this DOM document. Finally, the driver prints a number of books in the + object model to STDERR. + +To run the example on the sample XML instance document simply execute: + +$ ./driver library.xml + +To verify that DTD processing is disabled, uncomment a different DOCTYPE +version in the sample document. diff --git a/xsd-examples/cxx/tree/secure/buildfile b/xsd-examples/cxx/tree/secure/buildfile new file mode 100644 index 0000000..b1ca71f --- /dev/null +++ b/xsd-examples/cxx/tree/secure/buildfile @@ -0,0 +1,27 @@ +# file : cxx/tree/secure/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -library} {hxx ixx cxx}{library} $libs + +exe{driver}: xml{library}: test.input = true + +<{hxx ixx cxx}{library}>: xsd{library} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-examples/cxx/tree/secure/driver.cxx b/xsd-examples/cxx/tree/secure/driver.cxx new file mode 100644 index 0000000..7b6886f --- /dev/null +++ b/xsd-examples/cxx/tree/secure/driver.cxx @@ -0,0 +1,141 @@ +// file : cxx/tree/secure/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include "library.hxx" +#include "secure-dom-parser.hxx" + +using namespace std; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " library.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 + { + using namespace xercesc; + namespace xml = xsd::cxx::xml; + namespace tree = xsd::cxx::tree; + + xml::dom::unique_ptr parser (new SecureDOMParser ()); + + 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 validation. + // + conf->setParameter (XMLUni::fgDOMValidate, true); + conf->setParameter (XMLUni::fgXercesSchema, true); + 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 + + // Disable loading schemas via other means (e.g., schemaLocation). + // + // Note: this might be a good idea though if you need validation, + // you will need to pre-load the schema via other means. See the + // 'caching' and 'embedded' examples for different approaches. + // Both of them can be used with SecureDOMParser. + // + // conf->setParameter (XMLUni::fgXercesLoadSchema, false); + + // 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); + + // Parse the XML document. + // + ifstream ifs; + ifs.exceptions (ifstream::badbit | ifstream::failbit); + ifs.open (argv[1]); + + // Wrap the standard input stream. + // + xml::sax::std_input_source isrc (ifs, argv[1]); + Wrapper4InputSource wrap (&isrc, false); + + // Parse XML to DOM. + // + xml_schema::dom::unique_ptr doc (parser->parse (&wrap)); + + eh.throw_if_failed (); + + // Parse DOM to the object model. + // + unique_ptr c (library::catalog_ (*doc)); + + cerr << "catalog with " << c->book ().size () << " books" << 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/xsd-examples/cxx/tree/secure/library.xml b/xsd-examples/cxx/tree/secure/library.xml new file mode 100644 index 0000000..fa5f044 --- /dev/null +++ b/xsd-examples/cxx/tree/secure/library.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + 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/xsd-examples/cxx/tree/secure/library.xsd b/xsd-examples/cxx/tree/secure/library.xsd new file mode 100644 index 0000000..f80da3c --- /dev/null +++ b/xsd-examples/cxx/tree/secure/library.xsd @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/secure/secure-dom-parser.cxx b/xsd-examples/cxx/tree/secure/secure-dom-parser.cxx new file mode 100644 index 0000000..8eb7a28 --- /dev/null +++ b/xsd-examples/cxx/tree/secure/secure-dom-parser.cxx @@ -0,0 +1,24 @@ +// file : cxx/tree/secure/secure-dom-parser.cxx +// copyright : not copyrighted - public domain + +#include "secure-dom-parser.hxx" + +#include +#include + +using namespace xercesc; + +void SecureDOMParser:: +doctypeDecl (const DTDElementDecl& e, + const XMLCh* const pub_id, + const XMLCh* const sys_id, + const bool hasi, + const bool hase) +{ + if (hasi || hase) + ThrowXMLwithMemMgr(RuntimeException, + XMLExcepts::Gen_NoDTDValidator, + fMemoryManager); + + DOMLSParserImpl::doctypeDecl (e, pub_id, sys_id, hasi, hase); +} diff --git a/xsd-examples/cxx/tree/secure/secure-dom-parser.hxx b/xsd-examples/cxx/tree/secure/secure-dom-parser.hxx new file mode 100644 index 0000000..d70dff0 --- /dev/null +++ b/xsd-examples/cxx/tree/secure/secure-dom-parser.hxx @@ -0,0 +1,25 @@ +// file : cxx/tree/secure/secure-dom-parser.hxx +// copyright : not copyrighted - public domain + +#ifndef SECURE_DOM_PARSER_HXX +#define SECURE_DOM_PARSER_HXX + +#include + +class SecureDOMParser: public xercesc::DOMLSParserImpl +{ +public: + SecureDOMParser (xercesc::MemoryManager* mm = + xercesc::XMLPlatformUtils::fgMemoryManager, + xercesc::XMLGrammarPool* gp = 0) + : DOMLSParserImpl (0, mm, gp) {} + + virtual void + doctypeDecl (const xercesc::DTDElementDecl& root, + const XMLCh* const public_id, + const XMLCh* const system_id, + const bool has_internal, + const bool has_external); +}; + +#endif // SECURE_DOM_PARSER_HXX diff --git a/xsd-examples/cxx/tree/streaming/.gitignore b/xsd-examples/cxx/tree/streaming/.gitignore new file mode 100644 index 0000000..db4a6e9 --- /dev/null +++ b/xsd-examples/cxx/tree/streaming/.gitignore @@ -0,0 +1 @@ +position.?xx diff --git a/xsd-examples/cxx/tree/streaming/README b/xsd-examples/cxx/tree/streaming/README new file mode 100644 index 0000000..5a467e0 --- /dev/null +++ b/xsd-examples/cxx/tree/streaming/README @@ -0,0 +1,51 @@ +This example shows how to perform stream-oriented, partially in-memory +XML processing using the C++/Tree mapping. With the partially in-memory +parsing and serialization only a part of the object model is in memory at +any given time. With this approach we can process parts of the document +as they become available as well as handle documents that are too large +to fit into memory. + +The example consists of the following files: + +position.xsd + XML Schema which describes a simple object position vocabulary. The + position is represented as a potentially large series of latitude and + longitude measurements. + +position.xml + Sample object position document. + +position.hxx +position.cxx + C++ types that represent the position vocabulary as well as parsing + and serialization functions. These are generated by XSD from + position.xsd. + +parser.hxx +parser.cxx + Stream-oriented DOM parser implementation that is built on top of the + Xerces-C++ SAX2 parser in the progressive parsing mode. This parser + allows us to parse an XML document as a series of DOM fragments. + +serializer.hxx +serializer.cxx + Stream-oriented DOM serializer implementation that allows us to + serialize an XML Document as a series of object model fragments. + +grammar-input-stream.hxx +grammar-input-stream.cxx + Input stream implementation with the special-purpose schema grammar + decompression algorithm. It is used internally by the streaming parser. + +driver.cxx + Driver for the example. It parses the input file into a series of DOM + fragments which are then parsed into the object model fragments. The + driver prints the information from the document as it becomes available. + It also serializes the object model fragments into a new XML document + (out.xml). + +To run the example simply execute: + +$ ./driver position.xml + +The serialization results are written to the out.xml file. diff --git a/xsd-examples/cxx/tree/streaming/buildfile b/xsd-examples/cxx/tree/streaming/buildfile new file mode 100644 index 0000000..8c34b17 --- /dev/null +++ b/xsd-examples/cxx/tree/streaming/buildfile @@ -0,0 +1,26 @@ +# file : cxx/tree/streaming/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} xml{position} doc{README} + +exe{driver}: {hxx cxx}{* -position} {hxx ixx cxx}{position} $libs testscript + +<{hxx ixx cxx}{position}>: xsd{position} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-examples/cxx/tree/streaming/driver.cxx b/xsd-examples/cxx/tree/streaming/driver.cxx new file mode 100644 index 0000000..8a70f58 --- /dev/null +++ b/xsd-examples/cxx/tree/streaming/driver.cxx @@ -0,0 +1,139 @@ +// file : cxx/tree/streaming/driver.cxx +// copyright : not copyrighted - public domain + +#include +#include + +#include + +#include // xml::string + +#include "parser.hxx" +#include "serializer.hxx" +#include "position.hxx" + +using namespace std; +using namespace xercesc; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " position.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 + { + using namespace op; + namespace xml = xsd::cxx::xml; + + // Parse and serialize at the same time, in the streaming mode. + // + + ifstream ifs; + ifs.exceptions (ifstream::badbit | ifstream::failbit); + ifs.open (argv[1]); + + ofstream ofs; + ofs.exceptions (ios_base::badbit | ios_base::failbit); + ofs.open ("out.xml"); + + xml_schema::namespace_infomap ns_map; + ns_map["op"].name = "http://www.codesynthesis.com/op"; + ns_map["op"].schema = "position.xsd"; + + parser p; + serializer s; + + p.start (ifs, argv[1], true); + s.start (ofs); + + typedef xml_schema::dom::unique_ptr document_ptr; + + // Peek at the root element. This way we only get the "carcase" + // of the document, that is, the root element with its name, all + // the attributes, and namespace declarations but without any of + // the nested elements. + // + document_ptr docr (p.peek ()); + bool parsed (false); + + // Parse first-level elements. + // + for (document_ptr doc1 (p.peek ()); doc1.get () != 0; doc1 = p.peek ()) + { + // Check whether it is an element that we should stream (position) or + // just add to the root (header). + // + string n1 (xml::transcode ( + doc1->getDocumentElement ()->getLocalName ())); + + // If we see the first streaming element, then parse the root carcase. + // + if (!parsed && n1 == "position") + { + object o (*docr->getDocumentElement ()); + + cerr << "id: " << o.id () << endl + << "name: " << o.header ().name () << endl + << "type: " << o.header ().type () << endl; + + // Start serializing the document by writing out the root carcase. + // Note that we leave it open so that we can serialize more elements. + // + s.next_open (ns_map["op"].name, "op:object", ns_map, o); + parsed = true; + } + + // Handle elements that need streaming. + // + if (n1 == "position") + { + // Position has no nested elements that we need to stream so we + // finish parsing it in one go. + // + doc1 = p.next (move (doc1)); + position pos (*doc1->getDocumentElement ()); + + cerr << "lat: " << pos.lat () << " lon: " << pos.lon () << endl; + + // Serialize it (append) to the root element. + // + s.next ("position", pos); + } + else + { + // Element that doesn't require streaming (header in our case). Add + // to the root element and finish parsing. + // + docr = p.next (move (doc1), move (docr)); + } + } + + // Close the root element in serializer. + // + s.next_close ("op:object"); + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + r = 1; + } + catch (const ios_base::failure&) + { + cerr << "io failure" << endl; + r = 1; + } + + xercesc::XMLPlatformUtils::Terminate (); + return r; +} diff --git a/xsd-examples/cxx/tree/streaming/grammar-input-stream.cxx b/xsd-examples/cxx/tree/streaming/grammar-input-stream.cxx new file mode 100644 index 0000000..6f17f33 --- /dev/null +++ b/xsd-examples/cxx/tree/streaming/grammar-input-stream.cxx @@ -0,0 +1,96 @@ +// file : cxx/tree/streaming/grammar-input-stream.cxx +// author : Boris Kolpackov +// copyright : not copyrighted - public domain + +#include +#include "grammar-input-stream.hxx" + +grammar_input_stream:: +grammar_input_stream (const XMLByte* data, std::size_t size) + : data_ (data), + size_ (size), + pos_ (0), + vpos_ (0), + cseq_ (0), + add_zero_ (false) +{ +} + +XMLFilePos grammar_input_stream:: +curPos () const +{ + return static_cast (vpos_); +} + +XMLSize_t grammar_input_stream:: +readBytes (XMLByte* const buf, const XMLSize_t size) +{ + std::size_t i (0); + + // Add a zero from the alternating sequence if it didn't + // fit on the previous read. + // + if (add_zero_) + { + buf[i++] = 0; + add_zero_ = false; + } + + // If have an unfinished sequential sequence, output it now. + // + if (cseq_ != 0 && !alt_) + { + for (; cseq_ != 0 && i < size; --cseq_) + buf[i++] = 0; + } + + for (; i < size && pos_ < size_;) + { + XMLByte b = buf[i++] = data_[pos_++]; + + // See if we are in a compression sequence. + // + if (cseq_ != 0) + { + if (i < size) + buf[i++] = 0; + else + add_zero_ = true; // Add it on the next read. + + cseq_--; + continue; + } + + // If we are not in a compression sequence and this byte is + // not zero then we are done. + // + if (b != 0) + continue; + + // We have a zero. + // + assert (pos_ < size_); // There has to be another byte. + unsigned char v (static_cast (data_[pos_++])); + alt_ = (v & 128) != 0; + cseq_ = v & 127; + + // If it is a sequential sequence, output as many zeros as + // we can. + // + if (!alt_) + { + for (; cseq_ != 0 && i < size; --cseq_) + buf[i++] = 0; + } + } + + vpos_ += i; + + return static_cast (i); +} + +const XMLCh* grammar_input_stream:: +getContentType () const +{ + return 0; +} diff --git a/xsd-examples/cxx/tree/streaming/grammar-input-stream.hxx b/xsd-examples/cxx/tree/streaming/grammar-input-stream.hxx new file mode 100644 index 0000000..17e6913 --- /dev/null +++ b/xsd-examples/cxx/tree/streaming/grammar-input-stream.hxx @@ -0,0 +1,41 @@ +// file : cxx/tree/streaming/grammar-input-stream.hxx +// author : Boris Kolpackov +// copyright : not copyrighted - public domain + +#ifndef GRAMMAR_INPUT_STREAM_HXX +#define GRAMMAR_INPUT_STREAM_HXX + +#include +#include + +// Memory buffer input stream with the special-purpose schema +// grammar decompression. +// +class grammar_input_stream: public xercesc::BinInputStream +{ +public : + grammar_input_stream (const XMLByte* data, std::size_t size); + + virtual XMLFilePos + curPos () const; + + virtual XMLSize_t + readBytes (XMLByte* const buf, const XMLSize_t size); + + virtual const XMLCh* + getContentType () const; + +private : + const XMLByte* data_; + std::size_t size_; + std::size_t pos_; + std::size_t vpos_; + + // Compression data. + // + size_t cseq_; // Number of bytes left in a compression sequence. + bool alt_; // Alternating or sequential sequence. + bool add_zero_; // Add a zero on the next read. +}; + +#endif // GRAMMAR_INPUT_STREAM_HXX diff --git a/xsd-examples/cxx/tree/streaming/parser.cxx b/xsd-examples/cxx/tree/streaming/parser.cxx new file mode 100644 index 0000000..064dc77 --- /dev/null +++ b/xsd-examples/cxx/tree/streaming/parser.cxx @@ -0,0 +1,371 @@ +#include +#include // std::move() + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include // xercesc::Grammar +#include + +#include +#include + +#include +#include + +#include "parser.hxx" +#include "grammar-input-stream.hxx" + +using namespace std; +using namespace xercesc; + +namespace xml = xsd::cxx::xml; +namespace tree = xsd::cxx::tree; + +typedef parser::document_ptr document_ptr; + +class parser_impl: public DefaultHandler +{ +public: + parser_impl (const XMLByte* grammar, size_t grammar_size); + + void + start (istream& is, const string& id, bool validate); + + document_ptr + peek (); + + document_ptr + next (document_ptr doc = document_ptr (), + document_ptr outer_doc = document_ptr ()); + + // SAX event handlers. + // +private: + virtual void + startElement (const XMLCh* const uri, + const XMLCh* const lname, + const XMLCh* const qname, + const Attributes& attributes); + + virtual void + endElement (const XMLCh* const uri, + const XMLCh* const lname, + const XMLCh* const qname); + + virtual void + characters (const XMLCh* const s, + const XMLSize_t length); + +private: + // SAX parser. + // + bool clean_; + unique_ptr grammar_pool_; + unique_ptr parser_; + XMLPScanToken token_; + tree::error_handler error_handler_; + xml::sax::bits::error_handler_proxy error_proxy_; + unique_ptr isrc_; + + size_t depth_; + size_t whitespace_depth_; // Depth at which to ignore whitespaces. + + bool peek_; + size_t next_depth_; // Depth at which next() should work. + + // DOM document being built. + // + DOMImplementation& dom_impl_; + document_ptr doc_; + DOMElement* cur_; +}; + +const XMLCh ls[] = {chLatin_L, chLatin_S, chNull}; + +parser_impl:: +parser_impl (const XMLByte* grammar, size_t grammar_size) + : clean_ (true), + error_proxy_ (error_handler_), + dom_impl_ (*DOMImplementationRegistry::getDOMImplementation (ls)) +{ + MemoryManager* mm (XMLPlatformUtils::fgMemoryManager); + + if (grammar != 0) + { + assert (grammar_size != 0); + grammar_pool_.reset (new XMLGrammarPoolImpl (mm)); + + grammar_input_stream is (grammar, grammar_size); + grammar_pool_->deserializeGrammars(&is); + grammar_pool_->lockPool (); + } + + parser_.reset (XMLReaderFactory::createXMLReader (mm, grammar_pool_.get ())); + + parser_->setFeature (XMLUni::fgSAX2CoreNameSpaces, true); + parser_->setFeature (XMLUni::fgSAX2CoreNameSpacePrefixes, true); + parser_->setFeature (XMLUni::fgXercesValidationErrorAsFatal, true); + parser_->setFeature (XMLUni::fgXercesSchemaFullChecking, false); + + // Xerces-C++ 3.1.0 is the first version with working multi import + // support. It also allows us to disable buffering in the parser + // so that the data is parsed and returned as soon as it is + // available. + // +#if _XERCES_VERSION >= 30100 + parser_->setFeature (XMLUni::fgXercesHandleMultipleImports, true); + + XMLSize_t lwm = 0; + parser_->setProperty (XMLUni::fgXercesLowWaterMark, &lwm); +#endif + + parser_->setErrorHandler (&error_proxy_); + parser_->setContentHandler (this); +} + +void parser_impl:: +start (istream& is, const string& id, bool val) +{ + // Reset our state. + // + depth_ = 0; + peek_ = false; + doc_.reset (); + error_handler_.reset (); + + if (!clean_) + parser_->parseReset (token_); + else + clean_ = false; + + isrc_.reset (new xml::sax::std_input_source (is, id)); + + parser_->setFeature (XMLUni::fgSAX2CoreValidation, val); + parser_->setFeature (XMLUni::fgXercesSchema, val); + + if (val && grammar_pool_.get () != 0) + { + // Use the loaded grammar during parsing. + // + parser_->setFeature (XMLUni::fgXercesUseCachedGrammarInParse, true); + + // Disable loading schemas via other means (e.g., schemaLocation). + // + parser_->setFeature (XMLUni::fgXercesLoadSchema, false); + } + + parser_->parseFirst (*isrc_, token_); + error_handler_.throw_if_failed > (); +} + +document_ptr parser_impl:: +peek () +{ + bool r (true); + + size_t d (depth_); + whitespace_depth_ = d; + + peek_ = true; + + // Parse (skip whitespace content) until the depth increases or we get + // a document. The latter test covers cases where both start + // and end events will trigger and therefore leave the depth unchanged. + // + while (r && depth_ == d && doc_.get () == 0) + { + r = parser_->parseNext (token_); + error_handler_.throw_if_failed > (); + } + + if (!r) + return document_ptr (); + + return move (doc_); +} + +document_ptr parser_impl:: +next (document_ptr doc, document_ptr outer_doc) +{ + assert (peek_ == (doc.get () != 0)); + + // Install doc/outer_doc as the document we are parsing. + // + if (doc.get () != 0) + { + if (outer_doc.get () != 0) + { + // Move doc to outer_doc. + // + doc_ = move (outer_doc); + cur_ = static_cast ( + doc_->importNode (doc->getDocumentElement (), true)); + doc_->getDocumentElement ()->appendChild (cur_); + } + else + { + doc_ = move (doc); + cur_ = doc_->getDocumentElement (); + } + + // This handles the case where we get both start and + // end events in peek(). In this case the element is fully parsed + // and next() has nothing to do. + // + if (depth_ != next_depth_) + { + peek_ = false; + return move (doc_); + } + } + + bool r (true); + + // If we peeked, then we have already seen the start tag and our + // return depth is one above the current depth. + // + size_t d (peek_ ? depth_ - 1 : depth_); + whitespace_depth_ = d; + + peek_ = false; + + // Keep calling parseNext() until we either move to a greater depth or + // get a document. This way we skip the text (presumably whitespaces) + // that may be preceding this chunk. + // + while (r && depth_ == d && doc_.get () == 0) + { + parser_->parseNext (token_); + error_handler_.throw_if_failed > (); + } + + if (!r) + return document_ptr (); + + // If we are not at our start depth, keep calling parseNext() until we + // get there again. + // + while (r && depth_ != d) + { + r = parser_->parseNext (token_); + error_handler_.throw_if_failed > (); + } + + if (!r) + return document_ptr (); + + return move (doc_); +} + +// DOM builder. +// + +void parser_impl:: +startElement (const XMLCh* const uri, + const XMLCh* const /*lname*/, + const XMLCh* const qname, + const Attributes& attr) +{ + if (doc_.get () == 0) + { + doc_.reset (dom_impl_.createDocument (uri, qname, 0)); + cur_ = doc_->getDocumentElement (); + } + else + { + DOMElement* e = doc_->createElementNS (uri, qname); + cur_->appendChild (e); + cur_ = e; + } + + // Set attributes. + // + for (XMLSize_t i (0), end (attr.getLength()); i < end; ++i) + { + const XMLCh* qn (attr.getQName (i)); + const XMLCh* ns (attr.getURI (i)); + + // When SAX2 reports the xmlns attribute, it does not include + // the proper attribute namespace. So we have to detect and + // handle this case. + // + if (XMLString::equals (qn, XMLUni::fgXMLNSString)) + ns = XMLUni::fgXMLNSURIName; + + cur_->setAttributeNS (ns, qn, attr.getValue (i)); + } + + depth_++; + + if (peek_) + next_depth_ = depth_; +} + +void parser_impl:: +endElement (const XMLCh* const /*uri*/, + const XMLCh* const /*lname*/, + const XMLCh* const /*qname*/) +{ + // We have an element parent only on depth 2 or greater. + // + if (--depth_ > 1) + cur_ = static_cast (cur_->getParentNode ()); +} + +void parser_impl:: +characters (const XMLCh* const s, const XMLSize_t length) +{ + const XMLCh empty[] = {chNull}; + + // Ignore text content (presumably whitespaces) while looking for + // the next element. + // + if (depth_ > whitespace_depth_) + { + DOMText* t = doc_->createTextNode (empty); + static_cast (t)->appendData (s, length); + cur_->appendChild (t); + } +} + +// +// parser +// + +parser:: +~parser () +{ +} + +parser:: +parser (const XMLByte* grammar, size_t grammar_size) + : impl_ (new parser_impl (grammar, grammar_size)) +{ +} + +void parser:: +start (istream& is, const string& id, bool val) +{ + return impl_->start (is, id, val); +} + +document_ptr parser:: +peek () +{ + return impl_->peek (); +} + +document_ptr parser:: +next (document_ptr doc, document_ptr outer_doc) +{ + return impl_->next (move (doc), move (outer_doc)); +} diff --git a/xsd-examples/cxx/tree/streaming/parser.hxx b/xsd-examples/cxx/tree/streaming/parser.hxx new file mode 100644 index 0000000..605d236 --- /dev/null +++ b/xsd-examples/cxx/tree/streaming/parser.hxx @@ -0,0 +1,67 @@ +#ifndef PARSER_HXX +#define PARSER_HXX + +#include +#include +#include // std::size_t +#include // std::unique_ptr + +#include + +#include + +class parser_impl; + +class parser +{ +public: + // We can specify embedded XML Schema grammar to be used by the parser + // that was created by the xsdbin utility from the 'embedded' example. + // + parser (const XMLByte* grammar = 0, std::size_t grammar_size = 0); + ~parser (); + + // The start function prepares everything for parsing a new document. + // + void + start (std::istream& is, const std::string& id, bool validate); + + typedef xsd::cxx::xml::dom::unique_ptr document_ptr; + + // The peek function parses just the next element (ignoring any + // preceding content assuming it is whitespace) without parsing + // any of its nested content (but it includes the element's + // attributes). It returns NULL if there are no more elements + // at this level (there could still be on outer levels in case + // of nested streaming). + // + document_ptr + peek (); + + // The next function parses (or finishes parsing after peek) the + // next element including its nested content. It returns NULL if + // there are no more elements at this level (there could still + // be on outer levels in case of nested streaming). + // + // If doc is not NULL, then it should be the document returned + // by peek(). That is, a document with only the root element. + // In this case next() finishes parsing this element. + // + // If outer_doc is not NULL, then next() will first add doc to + // outer_doc as a child of the document root. + // + document_ptr + next (document_ptr doc = document_ptr (), + document_ptr outer_doc = document_ptr ()); + +private: + parser (const parser&); + + parser& + operator= (const parser&); + +private: + std::unique_ptr impl_; +}; + +#endif // PARSER_HXX diff --git a/xsd-examples/cxx/tree/streaming/position.xml b/xsd-examples/cxx/tree/streaming/position.xml new file mode 100644 index 0000000..3308306 --- /dev/null +++ b/xsd-examples/cxx/tree/streaming/position.xml @@ -0,0 +1,29 @@ + + + + + + +
+ Lion's Head + rock +
+ + + + + + + + + + +
diff --git a/xsd-examples/cxx/tree/streaming/position.xsd b/xsd-examples/cxx/tree/streaming/position.xsd new file mode 100644 index 0000000..0fbcf87 --- /dev/null +++ b/xsd-examples/cxx/tree/streaming/position.xsd @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/streaming/serializer.cxx b/xsd-examples/cxx/tree/streaming/serializer.cxx new file mode 100644 index 0000000..b903a49 --- /dev/null +++ b/xsd-examples/cxx/tree/streaming/serializer.cxx @@ -0,0 +1,636 @@ +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include "serializer.hxx" + +using namespace std; +using namespace xercesc; + +namespace xml = xsd::cxx::xml; +namespace tree = xsd::cxx::tree; + +static const XMLCh gEOLSeq[] = +{ + chLF, chNull +}; + +static const XMLCh gUTF8[] = +{ + chLatin_U, chLatin_T, chLatin_F, chDash, chDigit_8, chNull +}; + +static const XMLCh gEndElement[] = +{ + chOpenAngle, chForwardSlash, chNull +}; + +static const int DISCARD_DEFAULT_CONTENT_ID = 0x1; +static const int ENTITIES_ID = 0x2; +static const int FORMAT_PRETTY_PRINT_1ST_LEVEL_ID = 0xA; + +class StreamingDOMSerializer: public DOMLSSerializerImpl +{ +public: + StreamingDOMSerializer (MemoryManager* manager) + : DOMLSSerializerImpl (manager) + { + } + + bool + startOpen (const DOMElement* e, DOMLSOutput* const destination) + { + const DOMDocument* docu (e->getOwnerDocument ()); + assert (docu != 0); + + // Code adapted from DOMLSSerializerImpl::write(). + // + target_ = destination->getByteStream(); + + fEncodingUsed = gUTF8; + + const XMLCh* lsEncoding=destination->getEncoding(); + if (lsEncoding && *lsEncoding) + { + fEncodingUsed = lsEncoding; + } + else if (docu) + { + const XMLCh* tmpEncoding = docu->getInputEncoding(); + + if ( tmpEncoding && *tmpEncoding) + { + fEncodingUsed = tmpEncoding; + } + else + { + tmpEncoding = docu->getXmlEncoding(); + + if ( tmpEncoding && *tmpEncoding) + { + fEncodingUsed = tmpEncoding; + } + } + } + + fNewLineUsed = (fNewLine && *fNewLine)? fNewLine : gEOLSeq; + + fDocumentVersion = (docu->getXmlVersion() && *(docu->getXmlVersion())) + ? docu->getXmlVersion() + : XMLUni::fgVersion1_0; + + fErrorCount = 0; + + fLineFeedInTextNodePrinted = false; + fLastWhiteSpaceInTextNode = 0; + + level_ = 0; + namespace_map_.clear (); + + fFormatter = new (fMemoryManager) XMLFormatter( fEncodingUsed + ,fDocumentVersion + ,target_ + ,XMLFormatter::NoEscapes + ,XMLFormatter::UnRep_CharRef + ,fMemoryManager); + formatter_.reset (fFormatter); + + // Write out the XML declaration, etc. Here we assume that the document + // has no children (i.e., no root element). + // + processNode (docu, 0); + fLineFeedInTextNodePrinted = true; + + return writeOpen (e); + } + + bool + writeOpen (const DOMElement* e) + { + // Code adapted from the first part of ELEMENT_NODE case in + // DOMLSSerializerImpl::processNode(). + // + + if (!fLineFeedInTextNodePrinted) + { + if(level_ == 1 && getFeature(FORMAT_PRETTY_PRINT_1ST_LEVEL_ID)) + printNewLine(); + + printNewLine(); + } + else + { + fLineFeedInTextNodePrinted = false; + } + + printIndent(level_); + + RefHashTableOf* namespaceMap = NULL; + + *fFormatter << XMLFormatter::NoEscapes << chOpenAngle << + e->getNodeName (); + + setURCharRef(); + DOMNamedNodeMap *attributes = e->getAttributes(); + XMLSize_t attrCount = attributes->getLength(); + + const XMLCh* prefix = e->getPrefix(); + const XMLCh* uri = e->getNamespaceURI(); + if((uri && uri[0]) || + ((prefix==0 || prefix[0]==0) && isDefaultNamespacePrefixDeclared())) + { + if(prefix==0 || prefix[0]==0) + prefix=XMLUni::fgZeroLenString; + if(!isNamespaceBindingActive(prefix, uri)) + { + if(namespaceMap==NULL) + { + namespaceMap=new (fMemoryManager) RefHashTableOf(12, false, fMemoryManager); + fNamespaceStack->addElement(namespaceMap); + } + namespaceMap->put((void*)prefix,(XMLCh*)uri); + *fFormatter << XMLFormatter::NoEscapes + << chSpace << XMLUni::fgXMLNSString; + + if(!XMLString::equals(prefix,XMLUni::fgZeroLenString)) + *fFormatter << chColon << prefix; + + *fFormatter << chEqual << chDoubleQuote + << XMLFormatter::AttrEscapes + << uri + << XMLFormatter::NoEscapes + << chDoubleQuote; + } + } + + bool discard = getFeature(DISCARD_DEFAULT_CONTENT_ID); + for (XMLSize_t i = 0; i < attrCount; i++) + { + DOMAttr* attribute = (DOMAttr*)attributes->item(i); + + if (discard && !((DOMAttr*)attribute )->getSpecified()) + continue; + + // if this attribute is a namespace declaration, add it to the namespace map for the current level + const XMLCh* ns = attribute->getNamespaceURI(); + if (ns != 0 ) + { + if(XMLString::equals(ns, XMLUni::fgXMLNSURIName)) + { + if(namespaceMap==NULL) + { + namespaceMap=new (fMemoryManager) RefHashTableOf(12, false, fMemoryManager); + fNamespaceStack->addElement(namespaceMap); + } + const XMLCh* nsPrefix = attribute->getLocalName(); + if(XMLString::equals(attribute->getNodeName(),XMLUni::fgXMLNSString)) + nsPrefix = XMLUni::fgZeroLenString; + if(namespaceMap->containsKey((void*)nsPrefix)) + continue; + namespaceMap->put((void*)attribute->getLocalName(),(XMLCh*)attribute->getNodeValue()); + } + else if(!XMLString::equals(ns, XMLUni::fgXMLURIName)) + { + // check if the namespace for the current node is already defined + const XMLCh* prefix = attribute->getPrefix(); + if(prefix && prefix[0]) + { + const XMLCh* uri = attribute->getNamespaceURI(); + if(!isNamespaceBindingActive(prefix, uri)) + { + if(namespaceMap==NULL) + { + namespaceMap=new (fMemoryManager) RefHashTableOf(12, false, fMemoryManager); + fNamespaceStack->addElement(namespaceMap); + } + namespaceMap->put((void*)prefix,(XMLCh*)uri); + + *fFormatter << XMLFormatter::NoEscapes + << chSpace << XMLUni::fgXMLNSString << chColon << prefix + << chEqual << chDoubleQuote + << XMLFormatter::AttrEscapes + << uri + << XMLFormatter::NoEscapes + << chDoubleQuote; + } + } + } + } + + if (XMLString::equals(ns, XMLUni::fgXMLNSURIName) || checkFilter(attribute) == DOMNodeFilter::FILTER_ACCEPT) + { + *fFormatter << XMLFormatter::NoEscapes + << chSpace << attribute->getNodeName() + << chEqual << chDoubleQuote + << XMLFormatter::AttrEscapes; + + if (getFeature(ENTITIES_ID)) + { + DOMNode* child = attribute->getFirstChild(); + while( child != 0) + { + if(child->getNodeType()==DOMNode::TEXT_NODE) + *fFormatter << child->getNodeValue(); + else if(child->getNodeType()==DOMNode::ENTITY_REFERENCE_NODE) + *fFormatter << XMLFormatter::NoEscapes + << chAmpersand << child->getNodeName() << chSemiColon + << XMLFormatter::AttrEscapes; + child = child->getNextSibling(); + } + } + else + *fFormatter << attribute->getNodeValue(); + + *fFormatter << XMLFormatter::NoEscapes << chDoubleQuote; + } + } + + *fFormatter << XMLFormatter::NoEscapes << chCloseAngle; + + // Keep track of whether we have added a namespace map for this + // element. Used to pop it in writeClose(). + // + namespace_map_.push_back (namespaceMap != 0); + + level_++; + + DOMNode* child = e->getFirstChild(); + while (child != 0) + { + processNode (child, level_); + child = child->getNextSibling(); + } + + return fErrorCount == 0; + } + + bool + writeClose (const XMLCh* name) + { + // Code adapted from the second part of ELEMENT_NODE case in + // DOMLSSerializerImpl::processNode(). + // + level_--; + + // Assume we are not on the same line (nodeLine != fCurrentLine). + // + { + if (!fLineFeedInTextNodePrinted) + { + printNewLine(); + } + else + { + fLineFeedInTextNodePrinted = false; + } + + if(level_ == 0 && getFeature(FORMAT_PRETTY_PRINT_1ST_LEVEL_ID)) + printNewLine(); + + printIndent(level_); + } + + *fFormatter << XMLFormatter::NoEscapes << gEndElement << + name << chCloseAngle; + + if (namespace_map_.back ()) + fNamespaceStack->removeLastElement(); + + namespace_map_.pop_back (); + + if (level_ == 0) + { + printNewLine(); + target_->flush (); + } + + return fErrorCount == 0; + } + + bool + write (const DOMElement* e) + { + processNode (e, level_); + return fErrorCount == 0; + } + + using DOMLSSerializerImpl::write; // Whole document. + +public: + // Update the namespace stack to point to the strings from the + // new document's string pool. + // + void + update_namespace_stack (DOMDocument& d) + { + DOMDocumentImpl& di (dynamic_cast (d)); + + for (XMLSize_t i (0); i != fNamespaceStack->size (); ++i) + { + RefHashTableOf& t (*fNamespaceStack->elementAt (i)); + RefHashTableOfEnumerator e (&t, false, fMemoryManager); + while (e.hasMoreElements ()) + { + XMLCh* k ((XMLCh*) (e.nextElementKey ())); + XMLCh* v (t.get (k)); + t.put ((void*) (di.getPooledString (k)), + (XMLCh*) (di.getPooledString (v))); + } + } + } + +private: + XMLFormatTarget* target_; + std::unique_ptr formatter_; + int level_; + + std::vector namespace_map_; +}; + +class serializer_impl +{ +public: + typedef serializer::namespace_infomap namespace_infomap; + + serializer_impl (); + + void + start (ostream& os, const string& encoding); + + DOMElement* + create (const string& name, const namespace_infomap&); + + DOMElement* + create (const string& ns, const string& qname, const namespace_infomap&); + + void + serialize (xml::dom::unique_ptr); + + void + serialize_open (xml::dom::unique_ptr); + + void + serialize_close (const string&); + +private: + void + clear_document (); + +private: + bool start_; + + // Serializer. + // + xml::dom::unique_ptr out_; + xml::dom::unique_ptr serializer_; + + unique_ptr oft_; + + tree::error_handler error_handler_; + xml::dom::bits::error_handler_proxy error_proxy_; + + // DOM document that we use to create the elements. + // + DOMImplementation& dom_impl_; + xml::dom::unique_ptr doc_; + vector element_stack_; + + size_t element_count_; // Number of elements serialized using current doc. + static const size_t element_count_limit_ = 500; +}; + +const XMLCh ls[] = {chLatin_L, chLatin_S, chNull}; + +serializer_impl:: +serializer_impl () + : error_proxy_ (error_handler_), + dom_impl_ (*DOMImplementationRegistry::getDOMImplementation (ls)) +{ + serializer_.reset ( + new (XMLPlatformUtils::fgMemoryManager) + StreamingDOMSerializer (XMLPlatformUtils::fgMemoryManager)); + + DOMConfiguration* conf (serializer_->getDomConfig ()); + conf->setParameter (XMLUni::fgDOMErrorHandler, &error_proxy_); + conf->setParameter (XMLUni::fgDOMXMLDeclaration, true); + conf->setParameter (XMLUni::fgDOMWRTDiscardDefaultContent, true); + conf->setParameter (XMLUni::fgDOMWRTFormatPrettyPrint, true); + conf->setParameter (XMLUni::fgDOMWRTXercesPrettyPrint, false); +} + +void serializer_impl:: +start (ostream& os, const string& encoding) +{ + element_stack_.clear (); + doc_.reset (dom_impl_.createDocument ()); + element_count_ = 0; + + error_handler_.reset (); + oft_.reset (new xml::dom::ostream_format_target (os)); + + out_.reset (dom_impl_.createLSOutput ()); + out_->setEncoding (xml::string (encoding).c_str ()); + out_->setByteStream (oft_.get ()); + + start_ = true; +} + +DOMElement* serializer_impl:: +create (const string& name, const namespace_infomap& map) +{ + DOMElement* r (doc_->createElement (xml::string (name).c_str ())); + + if (!map.empty ()) + xml::dom::add_namespaces (*r, map); + + // Add the element as the child of the stack "tip" so that it + // "sees" all the namespace declarations active from this point. + // + if (!element_stack_.empty ()) + element_stack_.back ()->appendChild (r); + + return r; +} + +DOMElement* serializer_impl:: +create (const string& ns, const string& qname, const namespace_infomap& map) +{ + DOMElement* r ( + doc_->createElementNS ( + xml::string (ns).c_str (), xml::string (qname).c_str ())); + + if (!map.empty ()) + xml::dom::add_namespaces (*r, map); + + // Add the element as the child of the stack "tip" so that it + // "sees" all the namespace declarations active from this point. + // + if (!element_stack_.empty ()) + element_stack_.back ()->appendChild (r); + + return r; +} + +void serializer_impl:: +serialize (xml::dom::unique_ptr p) +{ + DOMElement* e (p.get ()); + + if (start_) + { + serializer_->write (e, out_.get ()); + start_ = false; + } + else + serializer_->write (e); + + error_handler_.throw_if_failed > (); + + // Remove this element from its parent before we release. + // + if (!element_stack_.empty ()) + element_stack_.back ()->removeChild (e); + + p.reset (); // Release it before we may clear the document below. + + if (element_count_++ > element_count_limit_) + clear_document (); +} + +void serializer_impl:: +serialize_open (xml::dom::unique_ptr p) +{ + DOMElement* e (p.get ()); + + if (start_) + { + serializer_->startOpen (e, out_.get ()); + start_ = false; + } + else + serializer_->writeOpen (e); + + error_handler_.throw_if_failed > (); + + // Add this element to the element stack. serialize_close() is + // responsible for its removal and releasing. + // + element_stack_.push_back (e); + p.release (); +} + +void serializer_impl:: +serialize_close (const string& name) +{ + serializer_->writeClose (xml::string (name).c_str ()); + error_handler_.throw_if_failed > (); + + // Release the element. + // + DOMElement* e (element_stack_.back ()); + element_stack_.pop_back (); + + if (!element_stack_.empty ()) + element_stack_.back ()->removeChild (e); + + e->release (); + + if (element_count_++ > element_count_limit_) + clear_document (); +} + +void serializer_impl:: +clear_document () +{ + // Re-create the document in order to force deallocation of its + // internal heap. While Xerces-C++ DOM tries to re-use memory, + // it still accumulates no longer used memory blocks. + // + xml::dom::unique_ptr doc (dom_impl_.createDocument ()); + + if (!element_stack_.empty ()) + { + DOMElement* e ( + static_cast ( + doc->importNode (element_stack_.front (), true))); + + for (vector::iterator i (element_stack_.begin ()); + i != element_stack_.end (); + ++i) + { + *i = e; + e = static_cast (e->getFirstChild ()); + } + } + + // Update the namespace stack to use the new document. + // + serializer_->update_namespace_stack (*doc); + + doc_ = move (doc); + element_count_ = 0; +} + +// +// serializer +// + +serializer:: +~serializer () +{ +} + +serializer:: +serializer () + : impl_ (new serializer_impl) +{ +} + +void serializer:: +start (ostream& os, const string& encoding) +{ + impl_->start (os, encoding); +} + +DOMElement* serializer:: +create (const string& name, const namespace_infomap& map) +{ + return impl_->create (name, map); +} + +DOMElement* serializer:: +create (const string& ns, const string& qname, const namespace_infomap& map) +{ + return impl_->create (ns, qname, map); +} + +void serializer:: +serialize (xml::dom::unique_ptr e) +{ + impl_->serialize (move (e)); +} + +void serializer:: +serialize_open (xml::dom::unique_ptr e) +{ + impl_->serialize_open (move (e)); +} + +void serializer:: +serialize_close (const string& name) +{ + impl_->serialize_close (name); +} diff --git a/xsd-examples/cxx/tree/streaming/serializer.hxx b/xsd-examples/cxx/tree/streaming/serializer.hxx new file mode 100644 index 0000000..585bd76 --- /dev/null +++ b/xsd-examples/cxx/tree/streaming/serializer.hxx @@ -0,0 +1,209 @@ +// file : cxx/tree/streaming/serializer.hxx +// author : Boris Kolpackov +// copyright : not copyrighted - public domain + +#ifndef SERIALIZER_HXX +#define SERIALIZER_HXX + +#include +#include +#include // std::unique_ptr + +#include + +#include +#include // namespace_infomap + +class serializer_impl; + +class serializer +{ +public: + typedef xsd::cxx::xml::dom::namespace_infomap namespace_infomap; + + ~serializer (); + serializer (); + + // Start the serialization process. + // + void + start (std::ostream& is, const std::string& encoding = "UTF-8"); + + // Serialize next object model fragment into an element with the specified + // name. + // + template + void + next (const std::string& name, const T& x); + + // Serialize next object model fragment into an element with the specified + // name and namespace declarations. + // + template + void + next (const std::string& name, const namespace_infomap&, const T& x); + + // Serialize next object model fragment into an element with the specified + // namespace and qualified name. + // + template + void + next (const std::string& ns, const std::string& name, const T& x); + + // Serialize next object model fragment into an element with the specified + // namespace and qualified name as well as namespace declarations. + // + template + void + next (const std::string& ns, + const std::string& name, + const namespace_infomap&, + const T& x); + + // The next_open/close functions are like next() but split into two steps. + // next_open() serializes the object model fragment into an element leaving + // it open while next_close() closes the element. + // + template + void + next_open (const std::string& name, const T& x); + + template + void + next_open (const std::string& name, const namespace_infomap&, const T& x); + + template + void + next_open (const std::string& ns, const std::string& name, const T& x); + + template + void + next_open (const std::string& ns, + const std::string& name, + const namespace_infomap&, + const T& x); + + void + next_close (const std::string& name); + +private: + serializer (const serializer&); + + serializer& + operator= (const serializer&); + +private: + xercesc::DOMElement* + create (const std::string& name, const namespace_infomap&); + + xercesc::DOMElement* + create (const std::string& ns, + const std::string& name, + const namespace_infomap&); + + void + serialize (xsd::cxx::xml::dom::unique_ptr); + + void + serialize_open (xsd::cxx::xml::dom::unique_ptr); + + void + serialize_close (const std::string& name); + +private: + std::unique_ptr impl_; +}; + +template +inline void serializer:: +next (const std::string& name, const T& x) +{ + xsd::cxx::xml::dom::unique_ptr e ( + create (name, namespace_infomap ())); + *e << x; + serialize (std::move (e)); +} + +template +inline void serializer:: +next (const std::string& name, const namespace_infomap& map, const T& x) +{ + xsd::cxx::xml::dom::unique_ptr e (create (name, map)); + *e << x; + serialize (std::move (e)); +} + +template +inline void serializer:: +next (const std::string& ns, const std::string& name, const T& x) +{ + xsd::cxx::xml::dom::unique_ptr e ( + create (ns, name, namespace_infomap ())); + *e << x; + serialize (std::move (e)); +} + +template +inline void serializer:: +next (const std::string& ns, + const std::string& name, + const namespace_infomap& map, + const T& x) +{ + xsd::cxx::xml::dom::unique_ptr e ( + create (ns, name, map)); + + *e << x; + serialize (std::move (e)); +} + +template +inline void serializer:: +next_open (const std::string& name, const T& x) +{ + xsd::cxx::xml::dom::unique_ptr e ( + create (name, namespace_infomap ())); + *e << x; + serialize_open (std::move (e)); +} + +template +inline void serializer:: +next_open (const std::string& name, const namespace_infomap& map, const T& x) +{ + xsd::cxx::xml::dom::unique_ptr e (create (name, map)); + *e << x; + serialize_open (std::move (e)); +} + +template +inline void serializer:: +next_open (const std::string& ns, const std::string& name, const T& x) +{ + xsd::cxx::xml::dom::unique_ptr e ( + create (ns, name, namespace_infomap ())); + *e << x; + serialize_open (std::move (e)); +} + +template +inline void serializer:: +next_open (const std::string& ns, + const std::string& name, + const namespace_infomap& map, + const T& x) +{ + xsd::cxx::xml::dom::unique_ptr e ( + create (ns, name, map)); + + *e << x; + serialize_open (std::move (e)); +} + +inline void serializer:: +next_close (const std::string& name) +{ + serialize_close (name); +} + +#endif // SERIALIZER_HXX diff --git a/xsd-examples/cxx/tree/streaming/testscript b/xsd-examples/cxx/tree/streaming/testscript new file mode 100644 index 0000000..d3c744d --- /dev/null +++ b/xsd-examples/cxx/tree/streaming/testscript @@ -0,0 +1,10 @@ +# file : cxx/tree/streaming/testscript +# license : not copyrighted - public domain + +: position +: +{ + $* $src_base/position.xml 2>| &out.xml; + echo '' >|; + cat out.xml >| +} diff --git a/xsd-examples/cxx/tree/wildcard/.gitignore b/xsd-examples/cxx/tree/wildcard/.gitignore new file mode 100644 index 0000000..234645e --- /dev/null +++ b/xsd-examples/cxx/tree/wildcard/.gitignore @@ -0,0 +1 @@ +email.?xx diff --git a/xsd-examples/cxx/tree/wildcard/README b/xsd-examples/cxx/tree/wildcard/README new file mode 100644 index 0000000..d451509 --- /dev/null +++ b/xsd-examples/cxx/tree/wildcard/README @@ -0,0 +1,34 @@ +This example shows how to use the optional wildcard mapping provided +by C++/Tree to parse, access, modify, and serialize the XML data +matched by XML Schema wildcards (any and anyAttribute). For an +alternative approach that employes type customization see the +custom/wildcard example. + +The example consists of the following files: + +email.xsd + XML Schema which describes a simple email format with the + extensible envelope type. + +email.xml + Sample email message. + +email.hxx +email.ixx +email.cxx + C++ types that represent the given 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 email.xsd. + Note that the --generate-wildcard option is used to request the + wildcard mapping. + +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 content of the object model to STDERR. Next the driver creates a + reply email which is then serialized to XML. + +To run the example on the sample XML instance document simply execute: + +$ ./driver email.xml diff --git a/xsd-examples/cxx/tree/wildcard/buildfile b/xsd-examples/cxx/tree/wildcard/buildfile new file mode 100644 index 0000000..5bc63c5 --- /dev/null +++ b/xsd-examples/cxx/tree/wildcard/buildfile @@ -0,0 +1,30 @@ +# file : cxx/tree/wildcard/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -email} {hxx ixx cxx}{email} $libs + +exe{driver}: xml{email}: test.input = true + +<{hxx ixx cxx}{email}>: xsd{email} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-wildcard \ + --generate-serialization \ + --root-element message \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-examples/cxx/tree/wildcard/driver.cxx b/xsd-examples/cxx/tree/wildcard/driver.cxx new file mode 100644 index 0000000..146a2d9 --- /dev/null +++ b/xsd-examples/cxx/tree/wildcard/driver.cxx @@ -0,0 +1,159 @@ +// file : cxx/tree/wildcard/driver.cxx +// copyright : not copyrighted - public domain + +#include +#include // std::unique_ptr +#include // std::memcpy +#include + +#include +#include + +#include "email.hxx" + +// The following string class keeps us sane when working with Xerces. +// Include it after the generated header in order to get only char or +// wchar_t version depending on how you compiled your schemas. +// +#include + +using std::cerr; +using std::endl; +using std::string; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " email.xml" << endl; + return 1; + } + + using namespace xercesc; + + int r (0); + + // The Xerces-C++ DOM objects that will be used to store the + // content matched by wildcards "out-live" the call to the + // parsing function. Therefore we need to initialize the + // Xerces-C++ runtime ourselves. + // + XMLPlatformUtils::Initialize (); + + try + { + using namespace email; + namespace xml = xsd::cxx::xml; + + // Read in the message. + // + std::unique_ptr msg ( + message (argv[1], xml_schema::flags::dont_initialize)); + + // Print what we've got. + // + cerr << "To: " << msg->to () << endl + << "From: " << msg->from () << endl + << "Subject: " << msg->subject () << endl; + + envelope::any_sequence& body (msg->any ()); + + for (envelope::any_iterator i (body.begin ()); i != body.end (); ++i) + { + DOMElement& e (*i); + string name (xml::transcode (e.getLocalName ())); + + if (name == "text") + { + // Create object representation for the text element. + // + xml_schema::string text (e); + + cerr << text << endl + << endl; + } + else if (name == "binary") + { + // Create object representation for the binary element. + // + binary bin (e); + + cerr << "binary: " << bin.name () << " type: " << bin.mime () << endl + << endl; + } + else + { + cerr << "unknown body type: " << name << endl; + } + } + + // Create a reply message. + // + envelope reply (msg->from (), msg->to (), "Re: " + msg->subject ()); + + // Copy the thread-id attribute from the original message if any. + // + envelope::any_attribute_set& as (msg->any_attribute ()); + envelope::any_attribute_iterator ti ( + as.find ("http://www.codesynthesis.com/email", "thread-id")); + + if (ti != as.end ()) + reply.any_attribute ().insert (*ti); + + // Add a text body. + // + DOMDocument& doc (reply.dom_document ()); + envelope::any_sequence& rbody (reply.any ()); + + xml_schema::string text ("Hi!\n\n" + "Indeed nice pictures. Check out mine.\n\n" + "Jane"); + + DOMElement* e ( + doc.createElementNS ( + xml::string ("http://www.codesynthesis.com/email").c_str (), + xml::string ("eml:text").c_str ())); + + *e << text; + rbody.push_back (e); + + // Add a (fake) image. + // + binary pic ("pic.jpg", "image/jpeg"); + pic.size (3); + std::memcpy (pic.data (), "123", 3); + + e = doc.createElementNS ( + xml::string ("http://www.codesynthesis.com/email").c_str (), + xml::string ("eml:binary").c_str ()); + + *e << pic; + rbody.push_back (e); + + + // Prepare namespace mapping and schema location information for + // serialization. + // + xml_schema::namespace_infomap map; + + map["eml"].name = "http://www.codesynthesis.com/email"; + map["eml"].schema = "email.xsd"; + + // Write it out. + // + message (std::cout, + reply, + map, + "UTF-8", + xml_schema::flags::dont_initialize); + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + r = 1; + } + + XMLPlatformUtils::Terminate (); + return r; +} diff --git a/xsd-examples/cxx/tree/wildcard/email.xml b/xsd-examples/cxx/tree/wildcard/email.xml new file mode 100644 index 0000000..a9331e5 --- /dev/null +++ b/xsd-examples/cxx/tree/wildcard/email.xml @@ -0,0 +1,31 @@ + + + + + + + Jane Doe <jane@doe.com> + John Doe <john@doe.com> + Surfing pictures + + +Hi Jane, + +Here are cool pictures of me surfing. + +Cheers, +John + + + YmFzZTY0IGJpbmFyeQ== + YmFzZTY0IGJpbmFyeQ== + + diff --git a/xsd-examples/cxx/tree/wildcard/email.xsd b/xsd-examples/cxx/tree/wildcard/email.xsd new file mode 100644 index 0000000..c051e85 --- /dev/null +++ b/xsd-examples/cxx/tree/wildcard/email.xsd @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/cxx/tree/xpath/.gitignore b/xsd-examples/cxx/tree/xpath/.gitignore new file mode 100644 index 0000000..83d0a51 --- /dev/null +++ b/xsd-examples/cxx/tree/xpath/.gitignore @@ -0,0 +1 @@ +people.?xx diff --git a/xsd-examples/cxx/tree/xpath/README b/xsd-examples/cxx/tree/xpath/README new file mode 100644 index 0000000..1187743 --- /dev/null +++ b/xsd-examples/cxx/tree/xpath/README @@ -0,0 +1,43 @@ +This example shows how to use the C++/Tree mapping together with XPath. +In particular, it shows how to execute an XPath query on the underlying +DOM document and then handle the result using the more convenient object +model representation. For more information on maintaining association +with the underlying DOM document, refer to Section 5.1, "DOM Association" +in the C++/Tree Mapping User Manual. + +You will need the XQilla library[1] which provides XQuery and XPath 2 +support on top of Xerces-C++ in order to build and run this example. + +[1] http://xqilla.sourceforge.net + +The example consists of the following files: + +people.xsd + XML Schema definition for a simple person record vocabulary. + +people.xml + Sample XML instance document. + +people.hxx +people.cxx + C++ types that represent the person record 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 people.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 using XQilla-provided DOM + Implementation with support for XPath 2. It then parses the DOM + document to the object model. Finally, it prepares and executes + an XPath query on the underlying DOM document and then handles + the result by getting back from the returned DOM nodes to object + model nodes. + +To run the example on the sample XML document simply execute: + +$ ./driver people.xml diff --git a/xsd-examples/cxx/tree/xpath/buildfile b/xsd-examples/cxx/tree/xpath/buildfile new file mode 100644 index 0000000..c6f090a --- /dev/null +++ b/xsd-examples/cxx/tree/xpath/buildfile @@ -0,0 +1,28 @@ +# file : cxx/tree/xpath/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} +import libs += libxqilla%lib{xqilla} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -people} {hxx ixx cxx}{people} $libs + +exe{driver}: xml{people}: test.input = true + +<{hxx ixx cxx}{people}>: xsd{people} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-examples/cxx/tree/xpath/dom-parse.cxx b/xsd-examples/cxx/tree/xpath/dom-parse.cxx new file mode 100644 index 0000000..f033de6 --- /dev/null +++ b/xsd-examples/cxx/tree/xpath/dom-parse.cxx @@ -0,0 +1,88 @@ +// file : cxx/tree/xpath/dom-parse.cxx +// copyright : not copyrighted - public domain + +#include "dom-parse.hxx" + +#include + +#include +#include + +#include +#include + +#include +#include + +using namespace xercesc; +namespace xml = xsd::cxx::xml; +namespace tree = xsd::cxx::tree; + +xml::dom::unique_ptr +parse (std::istream& is, + const std::string& id, + bool validate, + DOMImplementation* impl) +{ + xml::dom::unique_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::unique_ptr doc (parser->parse (&wrap)); + + eh.throw_if_failed > (); + + return doc; +} diff --git a/xsd-examples/cxx/tree/xpath/dom-parse.hxx b/xsd-examples/cxx/tree/xpath/dom-parse.hxx new file mode 100644 index 0000000..61dbbfe --- /dev/null +++ b/xsd-examples/cxx/tree/xpath/dom-parse.hxx @@ -0,0 +1,25 @@ +// file : cxx/tree/xpath/dom-parse.hxx +// copyright : not copyrighted - public domain + +#ifndef DOM_PARSE +#define DOM_PARSE + +#include +#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::unique_ptr +parse (std::istream& is, + const std::string& id, + bool validate, + xercesc::DOMImplementation*); + +#endif // DOM_PARSE diff --git a/xsd-examples/cxx/tree/xpath/driver.cxx b/xsd-examples/cxx/tree/xpath/driver.cxx new file mode 100644 index 0000000..246f804 --- /dev/null +++ b/xsd-examples/cxx/tree/xpath/driver.cxx @@ -0,0 +1,137 @@ +// file : cxx/tree/xpath/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include // std::move() +#include +#include +#include + +#include + +#include + +#include // xml::string, xml::transcode + +#include "dom-parse.hxx" + +#include "people.hxx" + +using namespace std; +using namespace xercesc; +namespace xml = xsd::cxx::xml; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " people.xml" << endl; + return 1; + } + + int r (0); + + // Initialise Xerces-C++ and XQilla. + // + XQillaPlatformUtils::initialize(); + + // Get the XQilla DOMImplementation object with support for XPath. + // + DOMImplementation* impl ( + DOMImplementationRegistry::getDOMImplementation( + xml::string ("XPath2 3.0").c_str ())); + + try + { + using namespace people; + + ifstream ifs; + ifs.exceptions (ifstream::badbit | ifstream::failbit); + ifs.open (argv[1]); + + // Parse the XML file to DOM using the XQilla DOMImplementation. + // + xml_schema::dom::unique_ptr dom ( + parse (ifs, argv[1], true, impl)); + + // Parse the DOM document to the object model. We also request that + // the DOM document to be associated with the object model. + // + std::unique_ptr d ( + directory_ (move (dom), + xml_schema::flags::keep_dom | xml_schema::flags::own_dom)); + + // Obtain the root element and document corresponding to the + // directory object. + // + DOMElement* root (static_cast (d->_node ())); + DOMDocument* doc (root->getOwnerDocument ()); + + // Obtain namespace resolver. + // + xml_schema::dom::unique_ptr resolver ( + doc->createNSResolver (root)); + + // Set the namespace prefix for the people namespace that we can + // use reliably in XPath expressions regardless of what is used + // in XML documents. + // + resolver->addNamespaceBinding ( + xml::string ("p").c_str (), + xml::string ("http://www.codesynthesis.com/people").c_str ()); + + // Create XPath expression. + // + xml_schema::dom::unique_ptr expr ( + doc->createExpression ( + xml::string ("p:directory/person[age > 30]").c_str (), + resolver.get ())); + + // Execute the query. + // + xml_schema::dom::unique_ptr r ( + expr->evaluate (doc, DOMXPathResult::ITERATOR_RESULT_TYPE, 0)); + + // Iterate over the result. + // + cerr << "Records matching the query:" << endl; + + while (r->iterateNext ()) + { + DOMNode* n (r->getNodeValue ()); + + // Obtain the object model node corresponding to this DOM node. + // + person* p ( + static_cast ( + n->getUserData (xml_schema::dom::tree_node_key))); + + // Print the data using the object model. + // + cerr << endl + << "First : " << p->first_name () << endl + << "Last : " << p->last_name () << endl + << "Gender : " << p->gender () << endl + << "Age : " << p->age () << endl; + } + } + catch(const DOMException& e) + { + cerr << xml::transcode (e.getMessage ()) << std::endl; + r = 1; + } + 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; + } + + XQillaPlatformUtils::terminate(); + return r; +} diff --git a/xsd-examples/cxx/tree/xpath/people.xml b/xsd-examples/cxx/tree/xpath/people.xml new file mode 100644 index 0000000..3ce6e38 --- /dev/null +++ b/xsd-examples/cxx/tree/xpath/people.xml @@ -0,0 +1,28 @@ + + + + + + + + John + Doe + male + 32 + + + + Jane + Doe + female + 28 + + + diff --git a/xsd-examples/cxx/tree/xpath/people.xsd b/xsd-examples/cxx/tree/xpath/people.xsd new file mode 100644 index 0000000..951d410 --- /dev/null +++ b/xsd-examples/cxx/tree/xpath/people.xsd @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-examples/manifest b/xsd-examples/manifest new file mode 100644 index 0000000..456f833 --- /dev/null +++ b/xsd-examples/manifest @@ -0,0 +1,17 @@ +: 1 +name: xsd-examples +version: 4.2.0-b.1.z +project: xsd +summary: XML Schema to C++ data binding compiler examples +license: Unlicence +description-file: README +url: https://www.codesynthesis.com/projects/xsd/ +doc-url: https://www.codesynthesis.com/projects/xsd/ +src-url: https://git.codesynthesis.com/cgit/xsd/xsd/tree/xsd-examples/ +email: xsd-users@codesynthesis.com ; Mailing list +depends: * build2 >= 0.13.0 +depends: * bpkg >= 0.13.0 +depends: libxsd == $ +depends: libxerces-c ^3.0.0 +depends: libexpat ^2.1.0 +depends: libz ^1.2.1100 diff --git a/xsd-tests/.gitignore b/xsd-tests/.gitignore new file mode 100644 index 0000000..d87c74c --- /dev/null +++ b/xsd-tests/.gitignore @@ -0,0 +1,32 @@ +# Compiler/linker output. +# +*.d +*.t +*.i +*.ii +*.o +*.obj +*.so +*.dll +*.a +*.lib +*.exp +*.pdb +*.ilk +*.exe +*.exe.dlls/ +*.exe.manifest +*.pc + +# Test executables. +# +driver + +# XSD-generated files. +# +test.?xx + +# Testscript output directories (can be symlinks). +# +test +test-driver diff --git a/xsd-tests/FLOSSE b/xsd-tests/FLOSSE new file mode 120000 index 0000000..be6df3d --- /dev/null +++ b/xsd-tests/FLOSSE @@ -0,0 +1 @@ +../FLOSSE \ No newline at end of file diff --git a/xsd-tests/GPLv2 b/xsd-tests/GPLv2 new file mode 120000 index 0000000..08e5586 --- /dev/null +++ b/xsd-tests/GPLv2 @@ -0,0 +1 @@ +../GPLv2 \ No newline at end of file diff --git a/xsd-tests/LICENSE b/xsd-tests/LICENSE new file mode 120000 index 0000000..ea5b606 --- /dev/null +++ b/xsd-tests/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/xsd-tests/README b/xsd-tests/README new file mode 100644 index 0000000..1b529ab --- /dev/null +++ b/xsd-tests/README @@ -0,0 +1,8 @@ +This package contains tests for the XSD to C++ data binding compiler. + +See the LICENSE file for distribution conditions. + +The project page is at https://www.codesynthesis.com/projects/xsd/. + +Send bug reports or any other feedback to the xsd-users@codesynthesis.com +mailing list. diff --git a/xsd-tests/build/.gitignore b/xsd-tests/build/.gitignore new file mode 100644 index 0000000..4a730a3 --- /dev/null +++ b/xsd-tests/build/.gitignore @@ -0,0 +1,3 @@ +config.build +root/ +bootstrap/ diff --git a/xsd-tests/build/bootstrap.build b/xsd-tests/build/bootstrap.build new file mode 100644 index 0000000..49ad78f --- /dev/null +++ b/xsd-tests/build/bootstrap.build @@ -0,0 +1,9 @@ +# file : build/bootstrap.build +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +project = xsd-tests + +using version +using config +using dist +using test diff --git a/xsd-tests/build/root.build b/xsd-tests/build/root.build new file mode 100644 index 0000000..63c3bb4 --- /dev/null +++ b/xsd-tests/build/root.build @@ -0,0 +1,40 @@ +# file : build/root.build +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +define xsd: file +xsd{*}: extension = xsd + +define xml: file +xml{*}: extension = xml + +define map: file +map{*}: extension = map + +using in + +cxx.std = latest + +using cxx + +hxx{*}: extension = hxx +ixx{*}: extension = ixx +txx{*}: extension = txx +cxx{*}: extension = cxx + +if ($cxx.target.system == 'win32-msvc') + cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + +if ($cxx.class == 'msvc') + cxx.coptions += /wd4251 /wd4275 /wd4800 + +# Setup the xsd that we are testing. +# +import xsd = xsd%exe{xsd} + +# Every exe{} in this project is by default a test. +# +exe{*}: test = true + +# Specify the test target for cross-testing. +# +test.target = $cxx.target diff --git a/xsd-tests/buildfile b/xsd-tests/buildfile new file mode 100644 index 0000000..e783791 --- /dev/null +++ b/xsd-tests/buildfile @@ -0,0 +1,4 @@ +# file : buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +./: {*/ -build/} doc{README} legal{GPLv2 LICENSE FLOSSE} manifest diff --git a/xsd-tests/clash/.gitignore b/xsd-tests/clash/.gitignore new file mode 100644 index 0000000..7349df1 --- /dev/null +++ b/xsd-tests/clash/.gitignore @@ -0,0 +1,2 @@ +clash.?xx +foo.?xx diff --git a/xsd-tests/clash/buildfile b/xsd-tests/clash/buildfile new file mode 100644 index 0000000..e99dccf --- /dev/null +++ b/xsd-tests/clash/buildfile @@ -0,0 +1,27 @@ +# file : clash/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +fs = foo clash + +exe{driver}: {hxx cxx}{* -{$fs}} {hxx cxx}{$fs} $libs + +for f: $fs +{ + <{hxx cxx}{$f}>: xsd{$f} $xsd + {{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) + }} +} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/clash/clash.xsd b/xsd-tests/clash/clash.xsd new file mode 100644 index 0000000..8458908 --- /dev/null +++ b/xsd-tests/clash/clash.xsd @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/clash/driver.cxx b/xsd-tests/clash/driver.cxx new file mode 100644 index 0000000..478e71a --- /dev/null +++ b/xsd-tests/clash/driver.cxx @@ -0,0 +1,10 @@ +// file : clash/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "foo.hxx" +#include "clash.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/clash/foo.xsd b/xsd-tests/clash/foo.xsd new file mode 100644 index 0000000..8a06ba8 --- /dev/null +++ b/xsd-tests/clash/foo.xsd @@ -0,0 +1,11 @@ + + + + + + + diff --git a/xsd-tests/code/name-conflict/buildfile b/xsd-tests/code/name-conflict/buildfile new file mode 100644 index 0000000..3a724f9 --- /dev/null +++ b/xsd-tests/code/name-conflict/buildfile @@ -0,0 +1,22 @@ +# file : code/name-conflict/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx cxx}{test} $libs + +<{hxx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/code/name-conflict/driver.cxx b/xsd-tests/code/name-conflict/driver.cxx new file mode 100644 index 0000000..a6eb4fe --- /dev/null +++ b/xsd-tests/code/name-conflict/driver.cxx @@ -0,0 +1,9 @@ +// file : code/name-conflict/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "test.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/code/name-conflict/test.xsd b/xsd-tests/code/name-conflict/test.xsd new file mode 100644 index 0000000..a017cc8 --- /dev/null +++ b/xsd-tests/code/name-conflict/test.xsd @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/code/name-escaping/buildfile b/xsd-tests/code/name-escaping/buildfile new file mode 100644 index 0000000..c252afd --- /dev/null +++ b/xsd-tests/code/name-escaping/buildfile @@ -0,0 +1,22 @@ +# file : code/name-escaping/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx cxx}{test} $libs + +<{hxx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/code/name-escaping/driver.cxx b/xsd-tests/code/name-escaping/driver.cxx new file mode 100644 index 0000000..8d74030 --- /dev/null +++ b/xsd-tests/code/name-escaping/driver.cxx @@ -0,0 +1,9 @@ +// file : code/name-escaping/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "test.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/code/name-escaping/test.xsd b/xsd-tests/code/name-escaping/test.xsd new file mode 100644 index 0000000..08c7530 --- /dev/null +++ b/xsd-tests/code/name-escaping/test.xsd @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/.gitignore b/xsd-tests/cxx/parser/.gitignore new file mode 100644 index 0000000..5a7b950 --- /dev/null +++ b/xsd-tests/cxx/parser/.gitignore @@ -0,0 +1 @@ +*-pskel.?xx diff --git a/xsd-tests/cxx/parser/built-in/buildfile b/xsd-tests/cxx/parser/built-in/buildfile new file mode 100644 index 0000000..0522c9a --- /dev/null +++ b/xsd-tests/cxx/parser/built-in/buildfile @@ -0,0 +1,23 @@ +# file : cxx/parser/built-in/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/built-in/driver.cxx b/xsd-tests/cxx/parser/built-in/driver.cxx new file mode 100644 index 0000000..008bc2d --- /dev/null +++ b/xsd-tests/cxx/parser/built-in/driver.cxx @@ -0,0 +1,529 @@ +// file : cxx/parser/built-in/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test built-in type parsing. +// + +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; +using xml_schema::ro_string; + +struct any_type_pimpl: xml_schema::any_type_pimpl +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + _start_any_element (ro_string const&, + ro_string const& n, + ro_string const*) + { + cout << " start any element '" << n << "'" << endl; + } + + virtual void + _end_any_element (ro_string const&, ro_string const& n) + { + cout << " end any element '" << n << "'" << endl; + } + + virtual void + _any_attribute (ro_string const&, + ro_string const& n, + ro_string const& v) + { + cout << " any attribute " << n << " = '" << v << "'" << endl; + } + + virtual void + _any_characters (ro_string const& s) + { + cout << " any text: '" << s << "'" << endl; + } + + virtual void + post_any_type () + { + cout << "}" << endl + << endl; + } +}; + +struct any_simple_type_pimpl: xml_schema::any_simple_type_pimpl +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + _any_characters (ro_string const& s) + { + cout << " any text: '" << s << "'" << endl; + } + + virtual void + post_any_simple_type () + { + cout << "}" << endl + << endl; + } +}; + +struct type_pimpl: type_pskel +{ + virtual void + boolean (bool v) + { + cout << v << endl; + } + + virtual void + byte (signed char v) + { + cout << short (v) << endl; + } + + virtual void + unsigned_byte (unsigned char v) + { + cout << (unsigned short) (v) << endl; + } + + virtual void + short_ (short v) + { + cout << v << endl; + } + + virtual void + unsigned_short (unsigned short v) + { + cout << v << endl; + } + + virtual void + int_ (int v) + { + cout << v << endl; + } + + virtual void + unsigned_int (unsigned int v) + { + cout << v << endl; + } + + virtual void + long_ (long long v) + { + cout << v << endl; + } + + virtual void + unsigned_long (unsigned long long v) + { + cout << v << endl; + } + + virtual void + integer (long long v) + { + cout << v << endl; + } + + virtual void + negative_integer (long long v) + { + cout << v << endl; + } + + + virtual void + non_positive_integer (long long v) + { + cout << v << endl; + } + + + virtual void + positive_integer (unsigned long long v) + { + cout << v << endl; + } + + virtual void + non_negative_integer (unsigned long long v) + { + cout << v << endl; + } + + virtual void + float_ (float v) + { + cout << v << endl; + } + + virtual void + double_ (double v) + { + cout << v << endl; + } + + virtual void + decimal (double v) + { + cout << v << endl; + } + + virtual void + string (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + normalized_string (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + token (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + name (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + nmtoken (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + nmtokens (xml_schema::string_sequence const& s) + { + cout << "'"; + + for (xml_schema::string_sequence::const_iterator i (s.begin ()); + i != s.end (); ++i) + cout << *i << " "; + + cout << "'" << endl; + } + + virtual void + ncname (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + id (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + idref (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + idrefs (xml_schema::string_sequence const& s) + { + cout << "'"; + + for (xml_schema::string_sequence::const_iterator i (s.begin ()); + i != s.end (); ++i) + cout << *i << " "; + + cout << "'" << endl; + } + + virtual void + language (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + uri (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + qname (xml_schema::qname const& v) + { + cout << "'" << v.prefix () << ":" << v.name () << "'" << endl; + } + + virtual void + base64_binary (XSD_AUTO_PTR v) + { + std::string tmp (v->data (), v->size ()); + cout << "'" << tmp << "'" << endl; + } + + virtual void + hex_binary (XSD_AUTO_PTR v) + { + std::string tmp (v->data (), v->size ()); + cout << "'" << tmp << "'" << endl; + } + + virtual void + gday (xml_schema::gday const& v) + { + cout << v.day (); + + if (v.zone_present ()) + cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () + << ':' << v.zone_minutes (); + + cout << endl; + } + + virtual void + gmonth (xml_schema::gmonth const& v) + { + cout << v.month (); + + if (v.zone_present ()) + cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () + << ':' << v.zone_minutes (); + + cout << endl; + } + + virtual void + gyear (xml_schema::gyear const& v) + { + cout << v.year (); + + if (v.zone_present ()) + cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () + << ':' << v.zone_minutes (); + + cout << endl; + } + + virtual void + gmonth_day (xml_schema::gmonth_day const& v) + { + cout << v.month () << '-' << v.day (); + + if (v.zone_present ()) + cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () + << ':' << v.zone_minutes (); + + cout << endl; + } + + virtual void + gyear_month (xml_schema::gyear_month const& v) + { + cout << v.year () << '-' << v.month (); + + if (v.zone_present ()) + cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () + << ':' << v.zone_minutes (); + + cout << endl; + } + + virtual void + date (xml_schema::date const& v) + { + cout << v.year () << '-' << v.month () << '-' << v.day (); + + if (v.zone_present ()) + cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () + << ':' << v.zone_minutes (); + + cout << endl; + } + + virtual void + time (xml_schema::time const& v) + { + cout << v.hours () << ':' << v.minutes () << ':' << v.seconds (); + + if (v.zone_present ()) + cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () + << ':' << v.zone_minutes (); + + cout << endl; + } + + virtual void + date_time (xml_schema::date_time const& v) + { + cout << v.year () << '-' << v.month () << '-' << v.day () << 'T' + << v.hours () << ':' << v.minutes () << ':' << v.seconds (); + + if (v.zone_present ()) + cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () + << ':' << v.zone_minutes (); + + cout << endl; + } + + virtual void + duration (xml_schema::duration const& v) + { + cout << (v.negative () ? "-" : "") << 'P' + << v.years () << 'Y' + << v.months () << 'M' + << v.days () << 'D' + << 'T' + << v.hours () << 'H' + << v.minutes () << 'M' + << v.seconds () << 'S' + << endl; + } +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + any_type_pimpl any_type_p; + any_simple_type_pimpl any_simple_type_p; + + xml_schema::boolean_pimpl boolean_p; + + xml_schema::byte_pimpl byte_p; + xml_schema::unsigned_byte_pimpl unsigned_byte_p; + xml_schema::short_pimpl short_p; + xml_schema::unsigned_short_pimpl unsigned_short_p; + xml_schema::int_pimpl int_p; + xml_schema::unsigned_int_pimpl unsigned_int_p; + xml_schema::long_pimpl long_p; + xml_schema::unsigned_long_pimpl unsigned_long_p; + + xml_schema::integer_pimpl integer_p; + xml_schema::negative_integer_pimpl negative_integer_p; + xml_schema::non_positive_integer_pimpl non_positive_integer_p; + xml_schema::positive_integer_pimpl positive_integer_p; + xml_schema::non_negative_integer_pimpl non_negative_integer_p; + + xml_schema::float_pimpl float_p; + xml_schema::double_pimpl double_p; + xml_schema::decimal_pimpl decimal_p; + + xml_schema::string_pimpl string_p; + xml_schema::normalized_string_pimpl normalized_string_p; + xml_schema::token_pimpl token_p; + xml_schema::name_pimpl name_p; + xml_schema::nmtoken_pimpl nmtoken_p; + xml_schema::nmtokens_pimpl nmtokens_p; + xml_schema::ncname_pimpl ncname_p; + xml_schema::id_pimpl id_p; + xml_schema::idref_pimpl idref_p; + xml_schema::idrefs_pimpl idrefs_p; + + xml_schema::language_pimpl language_p; + xml_schema::uri_pimpl uri_p; + xml_schema::qname_pimpl qname_p; + + xml_schema::base64_binary_pimpl base64_binary_p; + xml_schema::hex_binary_pimpl hex_binary_p; + + xml_schema::gday_pimpl gday_p; + xml_schema::gmonth_pimpl gmonth_p; + xml_schema::gyear_pimpl gyear_p; + xml_schema::gmonth_day_pimpl gmonth_day_p; + xml_schema::gyear_month_pimpl gyear_month_p; + xml_schema::date_pimpl date_p; + xml_schema::time_pimpl time_p; + xml_schema::date_time_pimpl date_time_p; + xml_schema::duration_pimpl duration_p; + + type_pimpl type_p; + + type_p.parsers (any_type_p, + any_simple_type_p, + boolean_p, + byte_p, + unsigned_byte_p, + short_p, + unsigned_short_p, + int_p, + unsigned_int_p, + long_p, + unsigned_long_p, + integer_p, + negative_integer_p, + non_positive_integer_p, + positive_integer_p, + non_negative_integer_p, + float_p, + double_p, + decimal_p, + string_p, + normalized_string_p, + token_p, + name_p, + nmtoken_p, + nmtokens_p, + ncname_p, + id_p, + idref_p, + idrefs_p, + language_p, + uri_p, + qname_p, + base64_binary_p, + hex_binary_p, + gday_p, + gmonth_p, + gyear_p, + gmonth_day_p, + gyear_month_p, + date_p, + time_p, + date_time_p, + duration_p); + + xml_schema::document doc_p (type_p, "test", "root"); + + type_p.pre (); + doc_p.parse (argv[1]); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (std::ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/built-in/output b/xsd-tests/cxx/parser/built-in/output new file mode 100644 index 0000000..756abcd --- /dev/null +++ b/xsd-tests/cxx/parser/built-in/output @@ -0,0 +1,164 @@ +{ + any attribute x = 'x' + any text: ' + ' + start any element 'a' + any text: 'a' + end any element 'a' + any text: ' + ' + start any element 'any-type' + any attribute x = 'xxx' + any text: 'aaa' + start any element 'a' + any text: 'bbb' + end any element 'a' + any text: 'ccc' + end any element 'any-type' + any text: ' + ' +} + +{ + any text: '123abc' +} + +1 +0 +1 +0 +0 +127 +-128 +123 +0 +255 +123 +0 +32767 +-32768 +-12345 +0 +65535 +12345 +0 +2147483647 +-2147483648 +-1234567890 +0 +4294967295 +1234567890 +0 +9223372036854775807 +-9223372036854775808 +-1234567890123456789 +0 +18446744073709551615 +12345678901234567890 +0 +2147483647 +-2147483648 +-1234567890 +-2147483648 +-1234567890 +0 +-2147483648 +-1234567890 +4294967295 +1234567890 +0 +4294967295 +1234567890 +0 +0 +-0 +inf +-inf +nan +123.567 +123.567 +-1.23567e+07 +-4.5e-06 +0 +0 +-0 +inf +-inf +nan +123.567 +123.567 +-1.23567e+07 +-4.5e-06 +0 +0 +-0 +123.567 +123.567 +-123.567 +'string space +newline + ' +' string space newline ' +'string space newline' +'as123:345-.abs' +'1as123:345-.abs' +'abc 123 ' +'as123_345-.abs' +'as123_345-.abs' +'abc' +'a123' +'as123_345-.abs' +'abc a123 ' +'x' +'en' +'en-us' +'one-two-three-four44-seven77-eight888' +'' +'relative' +'#id' +'http://www.example.com/foo#bar' +':schemaLocation' +'xsi:schemaLocation' +'12345abcjk' +'a' +'ab' +'abc' +'' +'12345abcjk' +12+12:0 +1 +31 +15+0:0 +15-14:0 +10+12:0 +1 +12+0:0 +2007+12:0 +1 +-20000+0:0 +10-28+12:0 +12-31 +1-1+0:0 +2007-12+12:0 +-2007-10 +20007-10+0:0 +-20007-1 +2007-12-26+12:0 +-2007-10-15 +20007-12-31+0:0 +-20007-1-1 +12:46:23.456+12:0 +12:13:14 +12:13:14+0:0 +2007-12-26T12:13:14.123+12:0 +-2007-10-15T12:13:14 +20007-12-31T12:13:14+0:0 +-20007-1-1T12:13:14 +-P2007Y13M32DT25H61M61.123S +P1Y0M0DT0H0M0S +P0Y1M0DT0H0M0S +P0Y0M1DT0H0M0S +P0Y0M0DT1H0M0S +P0Y0M0DT0H1M0S +P0Y0M0DT0H0M1.1S +P1Y0M0DT0H0M1S diff --git a/xsd-tests/cxx/parser/built-in/test.xml b/xsd-tests/cxx/parser/built-in/test.xml new file mode 100644 index 0000000..8d9332a --- /dev/null +++ b/xsd-tests/cxx/parser/built-in/test.xml @@ -0,0 +1,199 @@ + + + + a + aaabbbccc + + + 123abc + + 1 + 0 + true + false + + 0 + +127 + -128 + 123 + + 0 + 255 + 123 + + 0 + +32767 + -32768 + -12345 + + 0 + 65535 + 12345 + + 0 + +2147483647 + -2147483648 + -1234567890 + + 0 + 4294967295 + 1234567890 + + 0 + +9223372036854775807 + -9223372036854775808 + -1234567890123456789 + + 0 + 18446744073709551615 + 12345678901234567890 + + 0 + +2147483647 + -02147483648 + -1234567890 + + -02147483648 + -1234567890 + + 0 + -02147483648 + -1234567890 + + 4294967295 + +01234567890 + + 0 + 4294967295 + +01234567890 + + 0 + +0 + -0 + INF + -INF + NaN + 123.567 + +123.567 + -123.567e5 + -.45E-5 + + 0 + +0 + -0 + INF + -INF + NaN + 123.567 + +123.567 + -123.567e5 + -.45E-5 + + 0 + +0 + -0 + 123.567 + +123.567 + -123.567 + + string space +newline + + + string space +newline + + + + string space +newline + + + + as123:345-.abs + + 1as123:345-.abs + + abc 123 + + as123_345-.abs + + as123_345-.abs + abc + a123 + + as123_345-.abs + + abc a123 + + x + en + en-us + one-two-three-four44-seven77-eight888 + + + relative + #id + http://www.example.com/foo#bar + + schemaLocation + xsi:schemaLocation + + MTIzND + VhYmNqaw = = + YQ== + YWI= + YWJj + + + 31323334356162636a6b + + ---12+12:00 + ---01 + ---31 + ---15Z + ---15-14:00 + + --10+12:00 + --01 + --12Z + + 2007+12:00 + 0001 + -20000Z + + --10-28+12:00 + --12-31 + --01-01Z + + 2007-12+12:00 + -2007-10 + 20007-10Z + -20007-01 + + 2007-12-26+12:00 + -2007-10-15 + 20007-12-31Z + -20007-01-01 + + + + + + 2007-12-26T12:13:14.123+12:00 + -2007-10-15T12:13:14 + 20007-12-31T12:13:14Z + -20007-01-01T12:13:14 + + -P2007Y13M32DT25H61M61.123S + P1Y + P1M + P1D + PT1H + PT1M + PT1.1S + P1YT1S + + diff --git a/xsd-tests/cxx/parser/built-in/test.xsd b/xsd-tests/cxx/parser/built-in/test.xsd new file mode 100644 index 0000000..9c00eb4 --- /dev/null +++ b/xsd-tests/cxx/parser/built-in/test.xsd @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/enumeration/buildfile b/xsd-tests/cxx/parser/enumeration/buildfile new file mode 100644 index 0000000..05163df --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/buildfile @@ -0,0 +1,24 @@ +# file : cxx/parser/enumeration/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel}>: xsd{test} map{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --type-map $path($<[1]) \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/xsd-tests/cxx/parser/enumeration/driver.cxx b/xsd-tests/cxx/parser/enumeration/driver.cxx new file mode 100644 index 0000000..4776ee2 --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/driver.cxx @@ -0,0 +1,81 @@ +// file : cxx/parser/enumeration/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test xsd:enumeration parsing. +// + +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace xml_schema; + +struct digit_pimpl: test::digit_pskel, int_pimpl +{ +}; + +struct gender_pimpl: test::gender_pskel, string_pimpl +{ + virtual ::gender + post_gender () + { + std::string str (post_string ()); + + if (str == "male") + return male; + else + return female; + } +}; + +struct type_pimpl: test::type_pskel +{ + virtual void + digit (int i) + { + cout << i << endl; + } + + virtual void + gender (::gender g) + { + cout << g << endl; + } +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + digit_pimpl digit_p; + gender_pimpl gender_p; + type_pimpl type_p; + + type_p.parsers (digit_p, gender_p); + + document doc_p (type_p, "test", "root"); + + type_p.pre (); + doc_p.parse (argv[1]); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (std::ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/enumeration/gender.hxx b/xsd-tests/cxx/parser/enumeration/gender.hxx new file mode 100644 index 0000000..a2e5cd8 --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/gender.hxx @@ -0,0 +1,13 @@ +// file : tests/cxx/parser/enumeration/gender.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef GENDER_HXX +#define GENDER_HXX + +enum gender +{ + male, + female +}; + +#endif // GENDER_HXX diff --git a/xsd-tests/cxx/parser/enumeration/output b/xsd-tests/cxx/parser/enumeration/output new file mode 100644 index 0000000..16db301 --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/output @@ -0,0 +1,3 @@ +1 +0 +1 diff --git a/xsd-tests/cxx/parser/enumeration/test.map b/xsd-tests/cxx/parser/enumeration/test.map new file mode 100644 index 0000000..f8868d6 --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/test.map @@ -0,0 +1,7 @@ +namespace test +{ + include "gender.hxx"; + + digit int int; + gender ::gender ::gender; +} diff --git a/xsd-tests/cxx/parser/enumeration/test.xml b/xsd-tests/cxx/parser/enumeration/test.xml new file mode 100644 index 0000000..a6fa893 --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/test.xml @@ -0,0 +1,10 @@ + + + 1 + + male + female + + diff --git a/xsd-tests/cxx/parser/enumeration/test.xsd b/xsd-tests/cxx/parser/enumeration/test.xsd new file mode 100644 index 0000000..ded3a18 --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/test.xsd @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/generated-impl/.gitignore b/xsd-tests/cxx/parser/generated-impl/.gitignore new file mode 100644 index 0000000..21b434c --- /dev/null +++ b/xsd-tests/cxx/parser/generated-impl/.gitignore @@ -0,0 +1,2 @@ +test-pimpl.?xx +test-driver.?xx diff --git a/xsd-tests/cxx/parser/generated-impl/buildfile b/xsd-tests/cxx/parser/generated-impl/buildfile new file mode 100644 index 0000000..8710a77 --- /dev/null +++ b/xsd-tests/cxx/parser/generated-impl/buildfile @@ -0,0 +1,31 @@ +# file : cxx/parser/generated-impl/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx ixx cxx}{test-pskel} \ + {hxx cxx}{test-pimpl} \ + { cxx}{test-driver} \ + $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel} \ + {hxx cxx}{test-pimpl} \ + { cxx}{test-driver}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --generate-print-impl \ + --generate-test-driver \ + --force-overwrite \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/generated-impl/output b/xsd-tests/cxx/parser/generated-impl/output new file mode 100644 index 0000000..7c58647 --- /dev/null +++ b/xsd-tests/cxx/parser/generated-impl/output @@ -0,0 +1,122 @@ +gender: male +foo: foo +gender: male +int: 0 +int: 1 +int: 2 +int: 3 +foo: foo +int: 3 +int: 2 +int: 1 +int: 0 +union: 9 +foo: foo +union: string +x: x +a: aaa +x: x +y: y +a: aaa +b: bbb +boolean: 1 +boolean: 0 +boolean: 1 +boolean: 0 +byte: 0 +byte: 123 +byte: -123 +unsigned-byte: 0 +unsigned-byte: 123 +short: 0 +short: -1234 +short: 1234 +unsigned-short: 0 +unsigned-short: 1234 +int: 0 +int: -12345 +int: 12345 +unsigned-int: 0 +unsigned-int: 12345 +long: 0 +long: -123456 +long: 123456 +unsigned-long: 0 +unsigned-long: 123456 +integer: 0 +integer: -123456 +integer: 123456 +negative-integer: -123456 +non-positive-integer: 0 +non-positive-integer: -123456 +positive-integer: 123456 +non-negative-integer: 0 +non-negative-integer: 123456 +float: 0 +float: 1.123 +float: -1.123 +double: 0 +double: 1.1234 +double: -1.1234 +decimal: 0 +decimal: 1.1234 +decimal: -1.1234 +string: string space newline +normalized-string: string space newline +token: string space newline +name: as123:345-.abs +nmtoken: 1as123:345-.abs +nmtokens: abc 123 +ncname: as123_345-.abs +id: abc +id: a123 +idref: abc +idrefs: abc a123 +language: en +language: en-us +uri: http://www.example.com/foo#bar +qname: schemaLocation +qname: xsi:schemaLocation +base64_binary: 10 bytes +base64_binary: 1 bytes +base64_binary: 2 bytes +base64_binary: 3 bytes +hex_binary: 0 bytes +hex_binary: 10 bytes +gday: ---12+12:0 +gday: ---1 +gday: ---31 +gday: ---15+0:0 +gday: ---15-14:0 +gmonth: --10+12:0 +gmonth: --1 +gmonth: --12+0:0 +gyear: 2007+12:0 +gyear: 1 +gyear: -20000+0:0 +gmonth_day: --10-28+12:0 +gmonth_day: --12-31 +gmonth_day: --1-1+0:0 +gyear_month: 2007-12+12:0 +gyear_month: -2007-10 +gyear_month: 20007-10+0:0 +gyear_month: -20007-1 +date: 2007-12-26+12:0 +date: -2007-10-15 +date: 20007-12-31+0:0 +date: -20007-1-1 +time: 12:46:23.456+12:0 +time: 12:13:14 +time: 12:13:14+0:0 +date_time: 2007-12-26T12:13:14.123+12:0 +date_time: -2007-10-15T12:13:14 +date_time: 20007-12-31T12:13:14+0:0 +date_time: -20007-1-1T12:13:14 +duration: -P2007Y13M32DT25H61M61.123S +duration: P1Y0M0DT0H0M0S +duration: P0Y1M0DT0H0M0S +duration: P0Y0M1DT0H0M0S +duration: P0Y0M0DT1H0M0S +duration: P0Y0M0DT0H1M0S +duration: P0Y0M0DT0H0M1.1S +duration: P1Y0M0DT0H0M1S diff --git a/xsd-tests/cxx/parser/generated-impl/test.xml b/xsd-tests/cxx/parser/generated-impl/test.xml new file mode 100644 index 0000000..2f29a39 --- /dev/null +++ b/xsd-tests/cxx/parser/generated-impl/test.xml @@ -0,0 +1,168 @@ + + + male + male + + 0 1 2 3 + 3 2 1 0 + + 9 + string + + + aaa + + + + aaa + bbb + + + aaabbbccc + abc123 + + 1 + 0 + true + false + + 0 + 123 + -123 + + 0 + 123 + + 0 + -1234 + 1234 + + 0 + 1234 + + 0 + -12345 + 12345 + + 0 + 12345 + + 0 + -123456 + 123456 + + 0 + 123456 + + 0 + -123456 + 123456 + + -123456 + + 0 + -123456 + + 123456 + + 0 + 123456 + + 0 + 1.123 + -1.123 + + 0 + 1.1234 + -1.1234 + + 0 + 1.1234 + -1.1234 + + string space newline + + string space newline + + string space newline + + as123:345-.abs + + 1as123:345-.abs + + abc 123 + + as123_345-.abs + + abc + a123 + + abc + + abc a123 + + en + en-us + + http://www.example.com/foo#bar + + schemaLocation + xsi:schemaLocation + + MTIzNDVhYmNqaw== + YQ== + YWI= + YWJj + + + 31323334356162636a6b + + ---12+12:00 + ---01 + ---31 + ---15Z + ---15-14:00 + + --10+12:00 + --01 + --12Z + + 2007+12:00 + 0001 + -20000Z + + --10-28+12:00 + --12-31 + --01-01Z + + 2007-12+12:00 + -2007-10 + 20007-10Z + -20007-01 + + 2007-12-26+12:00 + -2007-10-15 + 20007-12-31Z + -20007-01-01 + + + + + + 2007-12-26T12:13:14.123+12:00 + -2007-10-15T12:13:14 + 20007-12-31T12:13:14Z + -20007-01-01T12:13:14 + + -P2007Y13M32DT25H61M61.123S + P1Y + P1M + P1D + PT1H + PT1M + PT1.1S + P1YT1S + + diff --git a/xsd-tests/cxx/parser/generated-impl/test.xsd b/xsd-tests/cxx/parser/generated-impl/test.xsd new file mode 100644 index 0000000..7bc8f23 --- /dev/null +++ b/xsd-tests/cxx/parser/generated-impl/test.xsd @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/list/buildfile b/xsd-tests/cxx/parser/list/buildfile new file mode 100644 index 0000000..426101e --- /dev/null +++ b/xsd-tests/cxx/parser/list/buildfile @@ -0,0 +1,23 @@ +# file : cxx/parser/list/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/list/driver.cxx b/xsd-tests/cxx/parser/list/driver.cxx new file mode 100644 index 0000000..382da5b --- /dev/null +++ b/xsd-tests/cxx/parser/list/driver.cxx @@ -0,0 +1,105 @@ +// file : cxx/parser/list/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test xsd:list parsing. +// + +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; + +struct string_list_pimpl: string_list_pskel +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + item (string const& v) + { + cout << " '" << v << "'" << endl; + } + + virtual void + post_string_list () + { + cout << "}" << endl + << endl; + } +}; + +struct string_list_lang_pimpl: string_list_lang_pskel +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + item (string const& v) + { + cout << " '" << v << "'" << endl; + } + + virtual void + lang (string const& v) + { + cout << " lang: '" << v << "'" << endl; + } + + virtual void + post_string_list_lang () + { + cout << "}" << endl + << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + string_list_pimpl string_list_p; + string_list_lang_pimpl string_list_lang_p; + type_pimpl type_p; + + string_list_p.parsers (string_p); + string_list_lang_p.parsers (string_p, string_p); + type_p.parsers (string_list_p, string_list_lang_p); + + xml_schema::document doc_p (type_p, "test", "root"); + + type_p.pre (); + doc_p.parse (argv[1]); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/list/output b/xsd-tests/cxx/parser/list/output new file mode 100644 index 0000000..3642c4d --- /dev/null +++ b/xsd-tests/cxx/parser/list/output @@ -0,0 +1,26 @@ +{ +} + +{ +} + +{ +} + +{ + 'one' +} + +{ + 'one' + 'two' + 'three' +} + +{ + lang: 'en' + 'one' + 'two' + 'three' +} + diff --git a/xsd-tests/cxx/parser/list/test.xml b/xsd-tests/cxx/parser/list/test.xml new file mode 100644 index 0000000..52229db --- /dev/null +++ b/xsd-tests/cxx/parser/list/test.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + one + + + one two + three + + + + one two + three + + + diff --git a/xsd-tests/cxx/parser/list/test.xsd b/xsd-tests/cxx/parser/list/test.xsd new file mode 100644 index 0000000..79bd084 --- /dev/null +++ b/xsd-tests/cxx/parser/list/test.xsd @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/name-clash/inheritance/buildfile b/xsd-tests/cxx/parser/name-clash/inheritance/buildfile new file mode 100644 index 0000000..4bd7b48 --- /dev/null +++ b/xsd-tests/cxx/parser/name-clash/inheritance/buildfile @@ -0,0 +1,24 @@ +# file : cxx/parser/name-clash/inheritance/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-validation \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/name-clash/inheritance/driver.cxx b/xsd-tests/cxx/parser/name-clash/inheritance/driver.cxx new file mode 100644 index 0000000..9e9b905 --- /dev/null +++ b/xsd-tests/cxx/parser/name-clash/inheritance/driver.cxx @@ -0,0 +1,62 @@ +// file : cxx/parser/name-clash/inheritance/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test for name clashes across inheritance hierarchy. +// + +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; + +struct derived_pimpl: derived_pskel +{ + virtual void + e (string const& v) + { + cout << "e: " << v << endl; + } + + virtual void + e1 (string const& v) + { + cout << "e1: " << v << endl; + } +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + derived_pimpl derived_p; + + derived_p.parsers (string_p, string_p); + + xml_schema::document doc_p (derived_p, "test", "root"); + + derived_p.pre (); + doc_p.parse (argv[1]); + derived_p.post_derived (); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (std::ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/name-clash/inheritance/output b/xsd-tests/cxx/parser/name-clash/inheritance/output new file mode 100644 index 0000000..4efd51b --- /dev/null +++ b/xsd-tests/cxx/parser/name-clash/inheritance/output @@ -0,0 +1,2 @@ +e: e +e1: e1 diff --git a/xsd-tests/cxx/parser/name-clash/inheritance/test.xml b/xsd-tests/cxx/parser/name-clash/inheritance/test.xml new file mode 100644 index 0000000..8c17101 --- /dev/null +++ b/xsd-tests/cxx/parser/name-clash/inheritance/test.xml @@ -0,0 +1,8 @@ + + + e + e1 + + diff --git a/xsd-tests/cxx/parser/name-clash/inheritance/test.xsd b/xsd-tests/cxx/parser/name-clash/inheritance/test.xsd new file mode 100644 index 0000000..62a782e --- /dev/null +++ b/xsd-tests/cxx/parser/name-clash/inheritance/test.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/buildfile b/xsd-tests/cxx/parser/polymorphism/recursive/buildfile new file mode 100644 index 0000000..629645b --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/recursive/buildfile @@ -0,0 +1,24 @@ +# file : cxx/parser/polymorphism/recursive/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-polymorphic \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/driver.cxx b/xsd-tests/cxx/parser/polymorphism/recursive/driver.cxx new file mode 100644 index 0000000..26793a0 --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/recursive/driver.cxx @@ -0,0 +1,68 @@ +// file : cxx/parser/polymorphism/recursive/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test polymorphic recursive parsing. +// + +#include +#include + +#include "test-pskel.hxx" +#include "test-pimpl.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::int_pimpl int_p; + + root_pimpl root_p; + expression_pimpl expression_p; + recursive_pimpl recursive_p; + value_a_pimpl value_a_p; + value_b_pimpl value_b_p; + + xml_schema::parser_map_impl expression_map; + + // Connect the parsers together. + // + root_p.parsers (expression_p); + expression_map.insert(value_a_p); + expression_map.insert(value_b_p); + expression_map.insert(recursive_p); + + root_p.expression_parser(expression_map); + + recursive_p.parsers(expression_p); + recursive_p.expression_parser(expression_map); + + value_a_p.parsers(int_p); + value_b_p.parsers(int_p); + + xml_schema::document doc_p (root_p, "test", "root", true); + + root_p.pre (); + doc_p.parse (argv[1]); + root_p.post_root (); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (std::ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/output b/xsd-tests/cxx/parser/polymorphism/recursive/output new file mode 100644 index 0000000..28a835f --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/recursive/output @@ -0,0 +1,22 @@ +root start +recursive start +value_a begin +value->constant +value: post_expression override +value_a: post_value override +value_a end +recursive->expression event +recursive start +value_b begin +value->constant +value: post_expression override +value_b: post_value override +value_b end +recursive->expression event +recursive: post_expression override +recursive end +recursive->expression event +recursive: post_expression override +recursive end +root->expression +root end diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.cxx b/xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.cxx new file mode 100644 index 0000000..7c7f410 --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.cxx @@ -0,0 +1,147 @@ +// file : cxx/parser/polymorphism/recursive/pimpl.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include "test-pimpl.hxx" + +using namespace std; + +namespace test +{ + // root_pimpl + // + + void root_pimpl:: + pre () + { + cout << "root start" << endl; + } + + void root_pimpl:: + expression () + { + cout << "root->expression" << endl; + } + + void root_pimpl:: + post_root () + { + cout << "root end" << endl; + } + + // expression_pimpl + // + + void expression_pimpl:: + pre () + { + cout << "expression begin" << endl; + } + + void expression_pimpl:: + post_expression () + { + cout << "expression end" << endl; + } + + // recursive_pimpl + // + + void recursive_pimpl:: + pre () + { + cout << "recursive start" << endl; + } + + void recursive_pimpl:: + expression () + { + cout << "recursive->expression event" << endl; + } + + void recursive_pimpl:: + post_expression () + { + cout << "recursive: post_expression override" << endl; + post_recursive (); + } + + void recursive_pimpl:: + post_recursive () + { + cout << "recursive end" << endl; + } + + // value_pimpl + // + + void value_pimpl:: + pre () + { + cout << "value begin" << endl; + } + + void value_pimpl:: + constant (int) + { + cout << "value->constant" << endl; + } + + void value_pimpl:: + post_expression () + { + cout << "value: post_expression override" << endl; + post_value (); + } + + void value_pimpl:: + post_value () + { + cout << "value end" << endl; + } + + // value_a_pimpl + // + + void value_a_pimpl:: + pre () + { + cout << "value_a begin" << endl; + } + + void value_a_pimpl:: + post_value () + { + cout << "value_a: post_value override" << endl; + post_value_a (); + } + + void value_a_pimpl:: + post_value_a () + { + cout << "value_a end" << endl; + } + + // value_b_pimpl + // + + void value_b_pimpl:: + pre () + { + cout << "value_b begin" << endl; + } + + void value_b_pimpl:: + post_value () + { + cout << "value_b: post_value override" << endl; + post_value_b (); + } + + void value_b_pimpl:: + post_value_b () + { + cout << "value_b end" << endl; + } +} diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.hxx b/xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.hxx new file mode 100644 index 0000000..928b880 --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.hxx @@ -0,0 +1,94 @@ +// file : cxx/parser/polymorphism/recursive/pimpl.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef TEST_PIMPL_HXX +#define TEST_PIMPL_HXX + +#include "test-pskel.hxx" + +namespace test +{ + class root_pimpl: public virtual root_pskel + { + public: + virtual void + pre (); + + virtual void + expression (); + + virtual void + post_root (); + }; + + class expression_pimpl: public virtual expression_pskel + { + public: + virtual void + pre (); + + virtual void + post_expression (); + }; + + class recursive_pimpl: public virtual recursive_pskel, + public expression_pimpl + { + public: + virtual void + pre (); + + virtual void + expression (); + + virtual void + post_expression (); + + virtual void + post_recursive (); + }; + + class value_pimpl: public virtual value_pskel, public expression_pimpl + { + public: + virtual void + pre (); + + virtual void + constant (int); + + virtual void + post_expression (); + + virtual void + post_value (); + }; + + class value_a_pimpl: public virtual value_a_pskel, public value_pimpl + { + public: + virtual void + pre (); + + virtual void + post_value (); + + virtual void + post_value_a (); + }; + + class value_b_pimpl: public virtual value_b_pskel, public value_pimpl + { + public: + virtual void + pre (); + + virtual void + post_value (); + + virtual void + post_value_b (); + }; +} + +#endif // TEST_PIMPL_HXX diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/test.xml b/xsd-tests/cxx/parser/polymorphism/recursive/test.xml new file mode 100644 index 0000000..42035ba --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/recursive/test.xml @@ -0,0 +1,15 @@ + + + + + 1 + + + + 2 + + + + diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/test.xsd b/xsd-tests/cxx/parser/polymorphism/recursive/test.xsd new file mode 100644 index 0000000..affcc8a --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/recursive/test.xsd @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/polymorphism/same-type/buildfile b/xsd-tests/cxx/parser/polymorphism/same-type/buildfile new file mode 100644 index 0000000..d98e917 --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/same-type/buildfile @@ -0,0 +1,24 @@ +# file : cxx/parser/polymorphism/same-type/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-polymorphic \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/polymorphism/same-type/driver.cxx b/xsd-tests/cxx/parser/polymorphism/same-type/driver.cxx new file mode 100644 index 0000000..6da4a0a --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/same-type/driver.cxx @@ -0,0 +1,62 @@ +// file : cxx/parser/polymorphism/same-type/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test substitution group and xsi:type that don't change the type. +// + +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; + +struct base_pimpl: base_pskel +{ + virtual void + a (string const& v) + { + cout << v << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + base_pimpl base_p; + type_pimpl type_p; + + base_p.parsers (string_p); + type_p.parsers (base_p); + + xml_schema::document doc_p (type_p, "test", "root", true); + + type_p.pre (); + doc_p.parse (argv[1]); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (std::ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/polymorphism/same-type/output b/xsd-tests/cxx/parser/polymorphism/same-type/output new file mode 100644 index 0000000..d418277 --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/same-type/output @@ -0,0 +1,4 @@ +a1 +a2 +a3 +a4 diff --git a/xsd-tests/cxx/parser/polymorphism/same-type/test.xml b/xsd-tests/cxx/parser/polymorphism/same-type/test.xml new file mode 100644 index 0000000..f8b6d1e --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/same-type/test.xml @@ -0,0 +1,10 @@ + + + a1 + a2 + a3 + a4 + + diff --git a/xsd-tests/cxx/parser/polymorphism/same-type/test.xsd b/xsd-tests/cxx/parser/polymorphism/same-type/test.xsd new file mode 100644 index 0000000..a4157d3 --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/same-type/test.xsd @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/recursive/buildfile b/xsd-tests/cxx/parser/recursive/buildfile new file mode 100644 index 0000000..237855c --- /dev/null +++ b/xsd-tests/cxx/parser/recursive/buildfile @@ -0,0 +1,24 @@ +# file : cxx/parser/recursive/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-validation \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/recursive/driver.cxx b/xsd-tests/cxx/parser/recursive/driver.cxx new file mode 100644 index 0000000..c93fd35 --- /dev/null +++ b/xsd-tests/cxx/parser/recursive/driver.cxx @@ -0,0 +1,139 @@ +// file : cxx/parser/recursive/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test recursive parser invocation. +// + +#include +#include + +#include "test-pskel.hxx" + +using namespace std; + +struct sub_pimpl: sub_type_pskel +{ + virtual void + pre () + { + cout << "sub::pre" << endl; + } + + virtual void + sub () + { + cout << "sub::sub" << endl; + } + + virtual void + sub2 () + { + cout << "sub::sub2" << endl; + } + + virtual void + name (string const& n) + { + cout << "sub::name: " << n << endl; + } + + virtual void + post_sub_type () + { + cout << "sub::post" << endl; + } +}; + +struct indir_pimpl: indir_type_pskel +{ + virtual void + pre () + { + cout << "indir::pre" << endl; + } + + virtual void + sub () + { + cout << "indir::sub" << endl; + } + + virtual void + name (string const& n) + { + cout << "indir::name: " << n << endl; + } + + virtual void + post_indir_type () + { + cout << "indir::post" << endl; + } +}; + +struct test_pimpl: test_type_pskel +{ + virtual void + pre () + { + cout << "test::pre" << endl; + } + + virtual void + sub () + { + cout << "test::sub" << endl; + } + + virtual void + name (string const& n) + { + cout << "test::name: " << n << endl; + } + + virtual void + post_test_type () + { + cout << "test::post" << endl; + } +}; + + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + + sub_pimpl sub_p; + indir_pimpl indir_p; + test_pimpl test_p; + + sub_p.parsers (sub_p, indir_p, sub_p, string_p); + indir_p.parsers (sub_p, string_p); + test_p.parsers (sub_p, string_p); + + xml_schema::document doc_p (test_p, "test"); + + test_p.pre (); + doc_p.parse (argv[1]); + test_p.post_test_type (); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/recursive/output b/xsd-tests/cxx/parser/recursive/output new file mode 100644 index 0000000..f26fb72 --- /dev/null +++ b/xsd-tests/cxx/parser/recursive/output @@ -0,0 +1,22 @@ +test::pre +test::name: testName +sub::pre +sub::name: subName +sub::pre +sub::name: sub-subName +sub::post +sub::sub +indir::pre +indir::name: sub-indirName +sub::pre +sub::name: sub-indir-subName +sub::post +indir::sub +indir::post +sub::pre +sub::name: sub-sub2Name +sub::post +sub::sub2 +sub::post +test::sub +test::post diff --git a/xsd-tests/cxx/parser/recursive/test.xml b/xsd-tests/cxx/parser/recursive/test.xml new file mode 100644 index 0000000..f6c219d --- /dev/null +++ b/xsd-tests/cxx/parser/recursive/test.xml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/xsd-tests/cxx/parser/recursive/test.xsd b/xsd-tests/cxx/parser/recursive/test.xsd new file mode 100644 index 0000000..33e1d2d --- /dev/null +++ b/xsd-tests/cxx/parser/recursive/test.xsd @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/test-template/buildfile b/xsd-tests/cxx/parser/test-template/buildfile new file mode 100644 index 0000000..9f7f5d3 --- /dev/null +++ b/xsd-tests/cxx/parser/test-template/buildfile @@ -0,0 +1,23 @@ +# file : cxx/parser/test-template/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/test-template/driver.cxx b/xsd-tests/cxx/parser/test-template/driver.cxx new file mode 100644 index 0000000..333c6fd --- /dev/null +++ b/xsd-tests/cxx/parser/test-template/driver.cxx @@ -0,0 +1,66 @@ +// file : cxx/parser/test-template/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Insert test description here. +// + +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; + +struct type_pimpl: type_pskel +{ + virtual void + pre () + { + } + + virtual void + a (string const& v) + { + cout << v << endl; + } + + virtual void + post_type () + { + } +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + type_pimpl type_p; + + type_p.parsers (string_p); + + xml_schema::document doc_p (type_p, "test", "root"); + + type_p.pre (); + doc_p.parse (argv[1]); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (std::ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/test-template/output b/xsd-tests/cxx/parser/test-template/output new file mode 100644 index 0000000..7898192 --- /dev/null +++ b/xsd-tests/cxx/parser/test-template/output @@ -0,0 +1 @@ +a diff --git a/xsd-tests/cxx/parser/test-template/test.xml b/xsd-tests/cxx/parser/test-template/test.xml new file mode 100644 index 0000000..624a80c --- /dev/null +++ b/xsd-tests/cxx/parser/test-template/test.xml @@ -0,0 +1,7 @@ + + + a + + diff --git a/xsd-tests/cxx/parser/test-template/test.xsd b/xsd-tests/cxx/parser/test-template/test.xsd new file mode 100644 index 0000000..07bebc7 --- /dev/null +++ b/xsd-tests/cxx/parser/test-template/test.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/union/buildfile b/xsd-tests/cxx/parser/union/buildfile new file mode 100644 index 0000000..1a8615c --- /dev/null +++ b/xsd-tests/cxx/parser/union/buildfile @@ -0,0 +1,23 @@ +# file : cxx/parser/union/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/union/driver.cxx b/xsd-tests/cxx/parser/union/driver.cxx new file mode 100644 index 0000000..c5b5c71 --- /dev/null +++ b/xsd-tests/cxx/parser/union/driver.cxx @@ -0,0 +1,60 @@ +// file : cxx/parser/union/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test xsd:union parsing. +// + +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; + +struct int_string_union_pimpl: int_string_union_pskel +{ + virtual void + _characters (const xml_schema::ro_string& s) + { + cout << "'" << s << "'" << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + int_string_union_pimpl int_string_union_p; + type_pimpl type_p; + + type_p.parsers (int_string_union_p); + + xml_schema::document doc_p (type_p, "test", "root"); + + type_p.pre (); + doc_p.parse (argv[1]); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (std::ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/union/output b/xsd-tests/cxx/parser/union/output new file mode 100644 index 0000000..a92ffc3 --- /dev/null +++ b/xsd-tests/cxx/parser/union/output @@ -0,0 +1,2 @@ +'one' +'1' diff --git a/xsd-tests/cxx/parser/union/test.xml b/xsd-tests/cxx/parser/union/test.xml new file mode 100644 index 0000000..5b3e799 --- /dev/null +++ b/xsd-tests/cxx/parser/union/test.xml @@ -0,0 +1,10 @@ + + + + + one + 1 + + diff --git a/xsd-tests/cxx/parser/union/test.xsd b/xsd-tests/cxx/parser/union/test.xsd new file mode 100644 index 0000000..5bf3d47 --- /dev/null +++ b/xsd-tests/cxx/parser/union/test.xsd @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/validation/all/buildfile b/xsd-tests/cxx/parser/validation/all/buildfile new file mode 100644 index 0000000..555843e --- /dev/null +++ b/xsd-tests/cxx/parser/validation/all/buildfile @@ -0,0 +1,22 @@ +# file : cxx/parser/validation/all/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs \ + testscript + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-validation \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/validation/all/driver.cxx b/xsd-tests/cxx/parser/validation/all/driver.cxx new file mode 100644 index 0000000..a8cbcca --- /dev/null +++ b/xsd-tests/cxx/parser/validation/all/driver.cxx @@ -0,0 +1,98 @@ +// file : cxx/parser/validation/all/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the all compositor validation. +// + +#include +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; + +struct all_pimpl: all_pskel +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + b (string const& v) + { + cout << " b = " << v << endl; + } + + virtual void + c (string const& v) + { + cout << " c = " << v << endl; + } + + virtual void + post_all () + { + cout << "}" << endl + << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + all_pimpl all_p; + type_pimpl type_p; + + all_p.parsers (string_p, string_p, string_p); + type_p.parsers (all_p); + + xml_schema::document doc_p (type_p, "test", "root"); + + try + { + ifstream ifs (argv[1]); + type_p.pre (); + doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cout << " " << e << endl + << "}" << endl + << endl; + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/validation/all/test.xsd b/xsd-tests/cxx/parser/validation/all/test.xsd new file mode 100644 index 0000000..1f670e3 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/all/test.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/validation/all/testscript b/xsd-tests/cxx/parser/validation/all/testscript new file mode 100644 index 0000000..e93e59c --- /dev/null +++ b/xsd-tests/cxx/parser/validation/all/testscript @@ -0,0 +1,190 @@ +# file : cxx/parser/validation/all/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +test.arguments += test.xml + +: all-combinations +: +{ + cat <=test.xml; + + + + + a + b + c + + + + a + c + b + + + + b + a + c + + + + b + c + a + + + + c + a + b + + + + c + b + a + + + + + a + b + + + + a + b + + + EOI + + $* >>EOO + { + a = a + b = b + c = c + } + + { + a = a + c = c + b = b + } + + { + b = b + a = a + c = c + } + + { + b = b + c = c + a = a + } + + { + c = c + a = a + b = b + } + + { + c = c + b = b + a = a + } + + { + a = a + b = b + } + + { + a = a + b = b + } + + EOO +} + +: required-not-present +: +{ + cat <=test.xml; + + + + + a + c + + + + EOI + + $* >>EOO + { + a = a + c = c + :9:9 error: expected element 'b' + } + + EOO +} + +: absent +: +{ + cat <=test.xml; + + + + + + + + EOI + + $* >>EOO + { + :7:9 error: expected element 'a' + } + + EOO +} + +: unexpected +: +{ + cat <=test.xml; + + + + + a + b + a + + + + EOI + + $* >>EOO + { + a = a + b = b + :9:7 error: unexpected element 'a' + } + + EOO +} diff --git a/xsd-tests/cxx/parser/validation/any/buildfile b/xsd-tests/cxx/parser/validation/any/buildfile new file mode 100644 index 0000000..57135f4 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/any/buildfile @@ -0,0 +1,24 @@ +# file : cxx/parser/validation/any/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-validation \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/validation/any/driver.cxx b/xsd-tests/cxx/parser/validation/any/driver.cxx new file mode 100644 index 0000000..1eceda6 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/any/driver.cxx @@ -0,0 +1,121 @@ +// file : cxx/parser/validation/any/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the any particle validation. +// + +#include +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; +using xml_schema::ro_string; + +struct any_a_pimpl: any_a_pskel +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + x (string const& v) + { + cout << " x = " << v << endl; + } + + virtual void + _start_any_element (ro_string const&, + ro_string const& n, + ro_string const*) + { + cout << " start any element '" << n << "'" << endl; + } + + virtual void + _end_any_element (ro_string const&, ro_string const& n) + { + cout << " end any element '" << n << "'" << endl; + } + + virtual void + _any_attribute (ro_string const&, + ro_string const& n, + ro_string const& v) + { + cout << " any attribute " << n << " = '" << v << "'" << endl; + } + + virtual void + _any_characters (ro_string const& s) + { + cout << " any text: '" << s << "'" << endl; + } + + virtual void + post_any_a () + { + cout << "}" << endl + << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + any_a_pimpl any_a_p; + type_pimpl type_p; + + any_a_p.parsers (string_p, string_p); + type_p.parsers (any_a_p); + + xml_schema::document doc_p (type_p, "test", "root"); + + try + { + ifstream ifs (argv[1]); + type_p.pre (); + doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cout << " " << e << endl + << "}" << endl + << endl; + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/validation/any/output b/xsd-tests/cxx/parser/validation/any/output new file mode 100644 index 0000000..a1cc6e3 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/any/output @@ -0,0 +1,29 @@ +{ + start any element 'any' + end any element 'any' +} + +{ + start any element 'any' + any attribute x = 'xxx' + any text: 'aaa' + start any element 'a' + any text: 'bbb' + end any element 'a' + any text: 'ccc' + end any element 'any' +} + +{ + x = x + a = a + start any element 'any' + any attribute x = 'xxx' + any text: 'aaa' + start any element 'a' + any text: 'bbb' + end any element 'a' + any text: 'ccc' + end any element 'any' +} + diff --git a/xsd-tests/cxx/parser/validation/any/test.xml b/xsd-tests/cxx/parser/validation/any/test.xml new file mode 100644 index 0000000..f1a0c83 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/any/test.xml @@ -0,0 +1,21 @@ + + + + + + + + + + aaabbbccc + + + + a + aaabbbccc + + + diff --git a/xsd-tests/cxx/parser/validation/any/test.xsd b/xsd-tests/cxx/parser/validation/any/test.xsd new file mode 100644 index 0000000..c05aeb5 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/any/test.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/validation/attribute/buildfile b/xsd-tests/cxx/parser/validation/attribute/buildfile new file mode 100644 index 0000000..d486193 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/attribute/buildfile @@ -0,0 +1,24 @@ +# file : cxx/parser/validation/attribute/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-validation \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/validation/attribute/driver.cxx b/xsd-tests/cxx/parser/validation/attribute/driver.cxx new file mode 100644 index 0000000..4710564 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/attribute/driver.cxx @@ -0,0 +1,197 @@ +// file : cxx/parser/validation/attribute/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test attribute and attribute wildcard (anyAttribute) validation. +// + +#include +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; +using xml_schema::ro_string; + +struct pass_a_pimpl: pass_a_pskel +{ + virtual void + pre () + { + cout << "pass-a" << endl + << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + b (string const& v) + { + cout << " b = " << v << endl; + } + + virtual void + _any_attribute (ro_string const& ns, + ro_string const& name, + ro_string const& value) + { + cout << " any: " << ns << "#" << name << " = " << value << endl; + } + + virtual void + post_pass_a () + { + cout << "}" << endl + << endl; + } +}; + +struct pass_b_pimpl: pass_b_pskel +{ + virtual void + pre () + { + cout << "pass-b" << endl + << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + b (string const& v) + { + cout << " b = " << v << endl; + } + + virtual void + _any_attribute (ro_string const& ns, + ro_string const& name, + ro_string const& value) + { + cout << " any: " << ns << "#" << name << " = " << value << endl; + } + + virtual void + post_pass_b () + { + cout << "}" << endl + << endl; + } +}; + +struct pass_c_pimpl: pass_c_pskel +{ + virtual void + pre () + { + cout << "pass-c" << endl + << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + b (string const& v) + { + cout << " b = " << v << endl; + } + + virtual void + post_pass_c () + { + cout << "}" << endl + << endl; + } +}; + +struct fail_pimpl: fail_pskel +{ + virtual void + pre () + { + cout << "fail" << endl + << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + post_fail () + { + cout << "}" << endl + << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + pass_a_pimpl pass_a_p; + pass_b_pimpl pass_b_p; + pass_c_pimpl pass_c_p; + fail_pimpl fail_p; + type_pimpl type_p; + + pass_a_p.parsers (string_p, string_p); + pass_b_p.parsers (string_p, string_p); + pass_c_p.parsers (string_p, string_p); + fail_p.parsers (string_p); + type_p.parsers (pass_a_p, pass_b_p, pass_c_p, fail_p); + + xml_schema::document doc_p (type_p, "test", "root"); + + try + { + ifstream ifs (argv[1]); + type_p.pre (); + doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cout << " " << e << endl + << "}" << endl + << endl; + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/validation/attribute/output b/xsd-tests/cxx/parser/validation/attribute/output new file mode 100644 index 0000000..847b054 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/attribute/output @@ -0,0 +1,24 @@ +pass-a +{ + b = b + any: test#foo = foo + any: test#bar = bar +} + +pass-b +{ + a = a + b = b +} + +pass-c +{ + a = a + b = b +} + +fail +{ + :8:10 error: expected attribute 'a' +} + diff --git a/xsd-tests/cxx/parser/validation/attribute/test.xml b/xsd-tests/cxx/parser/validation/attribute/test.xml new file mode 100644 index 0000000..b994d1a --- /dev/null +++ b/xsd-tests/cxx/parser/validation/attribute/test.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/xsd-tests/cxx/parser/validation/attribute/test.xsd b/xsd-tests/cxx/parser/validation/attribute/test.xsd new file mode 100644 index 0000000..833eb8e --- /dev/null +++ b/xsd-tests/cxx/parser/validation/attribute/test.xsd @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/validation/built-in/any-type/buildfile b/xsd-tests/cxx/parser/validation/built-in/any-type/buildfile new file mode 100644 index 0000000..a6f366b --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/any-type/buildfile @@ -0,0 +1,24 @@ +# file : cxx/parser/validation/built-in/any-type/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-validation \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/validation/built-in/any-type/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/any-type/driver.cxx new file mode 100644 index 0000000..cbeb864 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/any-type/driver.cxx @@ -0,0 +1,154 @@ +// file : cxx/parser/validation/built-in/any-type/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the anyType and anySimpleType validation. +// + +#include +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; +using xml_schema::ro_string; + +struct any_type_pimpl: xml_schema::any_type_pimpl +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + _start_any_element (ro_string const&, + ro_string const& n, + ro_string const*) + { + cout << " start any element '" << n << "'" << endl; + } + + virtual void + _end_any_element (ro_string const&, ro_string const& n) + { + cout << " end any element '" << n << "'" << endl; + } + + virtual void + _any_attribute (ro_string const&, + ro_string const& n, + ro_string const& v) + { + cout << " any attribute " << n << " = '" << v << "'" << endl; + } + + virtual void + _any_characters (ro_string const& s) + { + cout << " any text: '" << s << "'" << endl; + } + + virtual void + post_any_type () + { + cout << "}" << endl + << endl; + } +}; + +struct any_simple_type_pimpl: xml_schema::any_simple_type_pimpl +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + _any_characters (ro_string const& s) + { + cout << " any text: '" << s << "'" << endl; + } + + virtual void + post_any_simple_type () + { + cout << "}" << endl + << endl; + } +}; + +struct any_extension_pimpl: virtual any_extension_pskel, + any_type_pimpl + +{ + virtual void + x (const string& v) + { + cout << " x = " << v << endl; + } +}; + +struct any_simple_extension_pimpl: virtual any_simple_extension_pskel, + any_simple_type_pimpl +{ + virtual void + x (const string& v) + { + cout << " x = " << v << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + + any_type_pimpl any_type_p; + any_simple_type_pimpl any_simple_type_p; + + any_extension_pimpl any_extension_p; + any_simple_extension_pimpl any_simple_extension_p; + + type_pimpl type_p; + + any_extension_p.parsers (string_p); + any_simple_extension_p.parsers (string_p); + + type_p.parsers (any_type_p, + any_extension_p, + any_simple_extension_p, + any_simple_type_p); + + xml_schema::document doc_p (type_p, "test", "root"); + + ifstream ifs (argv[1]); + type_p.pre (); + doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/any-type/output b/xsd-tests/cxx/parser/validation/built-in/any-type/output new file mode 100644 index 0000000..84d7b3a --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/any-type/output @@ -0,0 +1,99 @@ +{ + any text: '123abc' +} + +{ + any text: ' + ' + start any element 'any' + end any element 'any' + any text: ' + ' +} + +{ + any text: ' + ' + start any element 'any' + any attribute x = 'xxx' + any text: 'aaa' + start any element 'a' + any text: 'bbb' + end any element 'a' + any text: 'ccc' + end any element 'any' + any text: ' + ' +} + +{ + any attribute x = 'x' + any text: ' + ' + start any element 'a' + any text: 'a' + end any element 'a' + any text: ' + ' + start any element 'any' + any attribute x = 'xxx' + any text: 'aaa' + start any element 'a' + any text: 'bbb' + end any element 'a' + any text: 'ccc' + end any element 'any' + any text: ' + ' +} + +{ + any text: ' + ' + start any element 'any' + end any element 'any' + any text: ' + ' +} + +{ + any text: ' + ' + start any element 'any' + any attribute x = 'xxx' + any text: 'aaa' + start any element 'a' + any text: 'bbb' + end any element 'a' + any text: 'ccc' + end any element 'any' + any text: ' + ' +} + +{ + x = x + any text: ' + ' + start any element 'a' + any text: 'a' + end any element 'a' + any text: ' + ' + start any element 'any' + any attribute x = 'xxx' + any text: 'aaa' + start any element 'a' + any text: 'bbb' + end any element 'a' + any text: 'ccc' + end any element 'any' + any text: ' + ' +} + +{ + x = x + any text: 'abc123' +} + diff --git a/xsd-tests/cxx/parser/validation/built-in/any-type/test.xml b/xsd-tests/cxx/parser/validation/built-in/any-type/test.xml new file mode 100644 index 0000000..7875b7e --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/any-type/test.xml @@ -0,0 +1,41 @@ + + + + + + + + + + aaabbbccc + + + + a + aaabbbccc + + + + + + + + + + aaabbbccc + + + + a + aaabbbccc + + + + + abc123 + + diff --git a/xsd-tests/cxx/parser/validation/built-in/any-type/test.xsd b/xsd-tests/cxx/parser/validation/built-in/any-type/test.xsd new file mode 100644 index 0000000..86a4e13 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/any-type/test.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/validation/built-in/binary/buildfile b/xsd-tests/cxx/parser/validation/built-in/binary/buildfile new file mode 100644 index 0000000..fd1594f --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/binary/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/binary/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/binary/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/binary/driver.cxx new file mode 100644 index 0000000..3fe20ec --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/binary/driver.cxx @@ -0,0 +1,153 @@ +// file : cxx/parser/validation/built-in/binary/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in base64Binary and hexBinary types validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + typedef xsd::cxx::parser::buffer buffer; + + // Good. + // + + // hexBinary + // + { + hex_binary_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters (" "); + p._post (); + assert (*p.post_hex_binary () == buffer ()); + } + + { + hex_binary_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n313"); + p._characters ("23334356162636a6b "); + p._post (); + assert (*p.post_hex_binary () == buffer ("12345abcjk", 10)); + } + + // base64Binary + // + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("MTIzND "); + p._characters ("VhYmNqaw = = "); + p._post (); + assert (*p.post_base64_binary () == buffer ("12345abcjk", 10)); + } + + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("YQ=="); + p._post (); + assert (*p.post_base64_binary () == buffer ("a", 1)); + } + + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("YWI="); + p._post (); + assert (*p.post_base64_binary () == buffer ("ab", 2)); + } + + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("YWJj"); + p._post (); + assert (*p.post_base64_binary () == buffer ("abc", 3)); + } + + // Bad + // + + // hexBinary + // + { + hex_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("313"); + assert (test_post_fail (p)); + } + + { + hex_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("313233343X6162636a6b"); + assert (test_post_fail (p)); + } + + // base64Binary + // + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("YQ"); + assert (test_post_fail (p)); + } + + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("=="); + assert (test_post_fail (p)); + } + + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("MTIzNDVhYmNqaw=A"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/boolean/buildfile b/xsd-tests/cxx/parser/validation/built-in/boolean/buildfile new file mode 100644 index 0000000..259614e --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/boolean/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/boolean/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/boolean/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/boolean/driver.cxx new file mode 100644 index 0000000..f1499cd --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/boolean/driver.cxx @@ -0,0 +1,145 @@ +// file : cxx/parser/validation/built-in/boolean/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in boolean type validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +bool +test_post_fail (boolean_pimpl& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters ("true"); + p._post (); + assert (p.post_boolean ()); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters ("1"); + p._post (); + assert (p.post_boolean ()); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters ("false"); + p._post (); + assert (!p.post_boolean ()); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (!p.post_boolean ()); + } + + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters (" true "); + p._post (); + assert (p.post_boolean ()); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters (" "); + p._characters (" \n "); + p._characters (" fa"); + p._characters ("l"); + p._characters ("se "); + p._characters (" \n "); + p._characters (" "); + p._post (); + assert (!p.post_boolean ()); + } + + // Bad + // + { + boolean_pimpl p; + p.pre (); + p._pre (); + //p._characters (""); + assert (test_post_fail (p)); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters (""); + assert (test_post_fail (p)); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters (" "); + assert (test_post_fail (p)); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters (" "); + assert (test_post_fail (p)); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters ("fal"); + p._characters ("s "); + p._characters ("e"); + assert (test_post_fail (p)); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters ("01"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/byte/buildfile b/xsd-tests/cxx/parser/validation/built-in/byte/buildfile new file mode 100644 index 0000000..87de911 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/byte/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/byte/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/byte/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/byte/driver.cxx new file mode 100644 index 0000000..b533cfd --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/byte/driver.cxx @@ -0,0 +1,256 @@ +// file : cxx/parser/validation/built-in/byte/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in byte and unsigned byte types validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("123"); + p._post (); + assert (p.post_byte () == 123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("\t +123 \n "); + p._post (); + assert (p.post_byte () == 123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-123"); + p._post (); + assert (p.post_byte () == -123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("+123"); + p._post (); + assert (p.post_byte () == 123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("0000000000000000123"); + p._post (); + assert (p.post_byte () == 123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("+0000000000000000123"); + p._post (); + assert (p.post_byte () == 123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0000000000000000123"); + p._post (); + assert (p.post_byte () == -123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("\t \n"); + p._characters (" -"); + p._characters ("00000"); + p._characters ("001"); + p._characters ("23 \n\t"); + p._post (); + assert (p.post_byte () == -123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-128"); + p._post (); + assert (p.post_byte () == -128); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("127"); + p._post (); + assert (p.post_byte () == 127); + } + + { + unsigned_byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("+123"); + p._post (); + assert (p.post_unsigned_byte () == 123); + } + + { + unsigned_byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_unsigned_byte () == 0); + } + + { + unsigned_byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("255"); + p._post (); + assert (p.post_unsigned_byte () == 255); + } + + // Bad + // + { + byte_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters (""); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n \t "); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("+"); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-"); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("++01"); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("--01"); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-01"); + p._characters (" "); + p._characters ("23 "); + assert (test_post_fail (p)); + } + + { + unsigned_byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-123"); + assert (test_post_fail (p)); + } + + // Ranges + // + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-129"); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("128"); + assert (test_post_fail (p)); + } + + { + unsigned_byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("256"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/date-time/buildfile b/xsd-tests/cxx/parser/validation/built-in/date-time/buildfile new file mode 100644 index 0000000..47791e5 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/date-time/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/date-time/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/date-time/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/date-time/driver.cxx new file mode 100644 index 0000000..da02a50 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/date-time/driver.cxx @@ -0,0 +1,1533 @@ +// file : cxx/parser/validation/built-in/date-time/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in date and time types validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + typedef xsd::cxx::parser::gday gday; + typedef xsd::cxx::parser::gmonth gmonth; + typedef xsd::cxx::parser::gyear gyear; + typedef xsd::cxx::parser::gmonth_day gmonth_day; + typedef xsd::cxx::parser::gyear_month gyear_month; + typedef xsd::cxx::parser::date date; + typedef xsd::cxx::parser::time time; + typedef xsd::cxx::parser::date_time date_time; + typedef xsd::cxx::parser::duration duration; + + // Good. + // + + // gday & time zone parsing + // + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("---1"); + p._characters ("2+12:00"); + p._post (); + assert (p.post_gday () == gday (12, 12, 00)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---01"); + p._post (); + assert (p.post_gday () == gday (1)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---31"); + p._post (); + assert (p.post_gday () == gday (31)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---15Z"); + p._post (); + assert (p.post_gday () == gday (15, 0, 0)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---15-14:00"); + p._post (); + assert (p.post_gday () == gday (15, -14, 0)); + } + + // gmonth + // + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("--1"); + p._characters ("0+12:00"); + p._post (); + assert (p.post_gmonth () == gmonth (10, 12, 0)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("--01"); + p._post (); + assert (p.post_gmonth () == gmonth (1)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12Z"); + p._post (); + assert (p.post_gmonth () == gmonth (12, 0, 0)); + } + + // gyear + // + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("20"); + p._characters ("07+12:00"); + p._post (); + assert (p.post_gyear () == gyear (2007, 12, 00)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("0001"); + p._post (); + assert (p.post_gyear () == gyear (1)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("-20000Z"); + p._post (); + assert (p.post_gyear () == gyear (-20000, 0, 0)); + } + + // gmonth_day + // + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("--1"); + p._characters ("0-28+12:00 "); + p._post (); + assert (p.post_gmonth_day () == gmonth_day (10, 28, 12, 00)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12-31"); + p._post (); + assert (p.post_gmonth_day () == gmonth_day (12, 31)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--01-01Z"); + p._post (); + assert (p.post_gmonth_day () == gmonth_day (1, 1, 0, 0)); + } + + // gyear_month + // + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("200"); + p._characters ("7-12+12:00 "); + p._post (); + assert (p.post_gyear_month () == gyear_month (2007, 12, 12, 00)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("-2007-10"); + p._post (); + assert (p.post_gyear_month () == gyear_month (-2007, 10)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("20007-10Z"); + p._post (); + assert (p.post_gyear_month () == gyear_month (20007, 10, 0, 0)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("-20007-01"); + p._post (); + assert (p.post_gyear_month () == gyear_month (-20007, 1)); + } + + // date + // + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("200"); + p._characters ("7-12-26+12:00 "); + p._post (); + assert (p.post_date () == date (2007, 12, 26, 12, 0)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("-2007-10-15"); + p._post (); + assert (p.post_date () == date (-2007, 10, 15)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("20007-12-31Z"); + p._post (); + assert (p.post_date () == date (20007, 12, 31, 0, 0)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("-20007-01-01"); + p._post (); + assert (p.post_date () == date (-20007, 1, 1)); + } + + // time + // + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("12:"); + p._characters ("46:23.456+12:00 "); + p._post (); + assert (p.post_time () == time (12, 46, 23.456, 12, 0)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("12:13:14"); + p._post (); + assert (p.post_time () == time (12, 13, 14.0)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("12:13:14Z"); + p._post (); + assert (p.post_time () == time (12, 13, 14.0, 0, 0)); + } + + // date_time + // + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("200"); + p._characters ("7-12-26T12:13:14.123+12:00 "); + p._post (); + assert (p.post_date_time () == + date_time (2007, 12, 26, 12, 13, 14.123, 12, 0)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("-2007-10-15T12:13:14"); + p._post (); + assert (p.post_date_time () == date_time (-2007, 10, 15, 12, 13, 14.0)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("20007-12-31T12:13:14Z"); + p._post (); + assert (p.post_date_time () == + date_time (20007, 12, 31, 12, 13, 14.0, 0, 0)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("-20007-01-01T12:13:14"); + p._post (); + assert (p.post_date_time () == date_time (-20007, 1, 1, 12, 13, 14.0)); + } + + // duration + // + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("-P200"); + p._characters ("7Y13M32DT25H61M61.123S "); + p._post (); + assert (p.post_duration () == + duration (true, 2007, 13, 32, 25, 61, 61.123)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1Y"); + p._post (); + assert (p.post_duration () == duration (false, 1, 0, 0, 0, 0, 0.0)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1M"); + p._post (); + assert (p.post_duration () == duration (false, 0, 1, 0, 0, 0, 0.0)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1D"); + p._post (); + assert (p.post_duration () == duration (false, 0, 0, 1, 0, 0, 0.0)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT1H"); + p._post (); + assert (p.post_duration () == duration (false, 0, 0, 0, 1, 0, 0.0)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT1M"); + p._post (); + assert (p.post_duration () == duration (false, 0, 0, 0, 0, 1, 0.0)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT1.1S"); + p._post (); + assert (p.post_duration () == duration (false, 0, 0, 0, 0, 0, 1.1)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1YT1S"); + p._post (); + assert (p.post_duration () == duration (false, 1, 0, 0, 0, 0, 1.0)); + } + + // Bad + // + + // gday & time zone parsing + // + { + gday_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---1"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---00"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---32"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---2X"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12asd"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12X"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---1212:00"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12+2:00"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12+1200"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12+15:00"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12+12:60"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12+14:01"); + assert (test_post_fail (p)); + } + + // gmonth + // + { + gmonth_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("-12"); + assert (test_post_fail (p)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("--00"); + assert (test_post_fail (p)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("--13"); + assert (test_post_fail (p)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("--1X"); + assert (test_post_fail (p)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("--11+12:3o"); + assert (test_post_fail (p)); + } + + // gyear + // + { + gyear_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("207"); + assert (test_post_fail (p)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("-207"); + assert (test_post_fail (p)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0000"); + assert (test_post_fail (p)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("20X7"); + assert (test_post_fail (p)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007+12:3o"); + assert (test_post_fail (p)); + } + + // gmonth_day + // + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("-12-12"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--1212"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12?12"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--00-12"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12-00"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--13-23"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12-32"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--1X-12"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12-2X"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--11-11+12:3o"); + assert (test_post_fail (p)); + } + + // gyear_month + // + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("207-01"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("-207-01"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("0000-01"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("20X7-01"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007?12"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-0"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-00"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-13"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-1X"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01+12:3o"); + assert (test_post_fail (p)); + } + + // date + // + { + date_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("207-01-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("-207-01-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("0000-01-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("20X7-01-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007?01-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-0-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-00-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-13-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-1X-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10?12"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-0"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-00"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-32"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-2X"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01+12:3o"); + assert (test_post_fail (p)); + } + + // time + // + { + time_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("1:01:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2X:01:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23?01:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:0:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:60:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:4X:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10?12"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10:"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10:0"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10:01."); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10:60"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10:2X"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("24:01:00"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("24:00:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:01:01+12:3o"); + assert (test_post_fail (p)); + } + + // date_time + // + { + date_time_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("207-01-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("-207-01-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("0000-01-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("20X7-01-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007?01-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-0-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-00-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-13-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-1X-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10?12T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-0T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-00T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-32T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-2XT12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T1:01:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T2X:01:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23?01:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:0:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:60:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:4X:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10?12"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10:"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10:0"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10:01."); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10:60"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10:2X"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T24:01:00"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T24:00:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:01:01+12:3o"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T12:13:14+12:3o"); + assert (test_post_fail (p)); + } + + // duration + // + { + duration_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007Y"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("-2007Y"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P-2007Y"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P-1M"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P-1D"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT-1H"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT-1M"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT-1.1S"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1H1M1S"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1M1Y"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT1S1H"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT1H1Y"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1Ygarbage"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1YT"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/float/buildfile b/xsd-tests/cxx/parser/validation/built-in/float/buildfile new file mode 100644 index 0000000..ca0eac1 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/float/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/float/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/float/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/float/driver.cxx new file mode 100644 index 0000000..bb67eb7 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/float/driver.cxx @@ -0,0 +1,285 @@ +// file : cxx/parser/validation/built-in/float/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in float, double, and decimal types validation. +// +#include +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + + // float + // + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters (" 0000123.456 "); + p._post (); + assert (p.post_float () == 123.456F); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("-12.345E2"); + p._post (); + assert (p.post_float () == -12.345E2F); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_float () == 0.0F); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0"); + p._post (); + assert (p.post_float () == -0.0F); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("INF"); + p._post (); + assert (isinf (p.post_float ())); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("-INF"); + p._post (); + assert (isinf (p.post_float ())); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("NaN"); + p._post (); + assert (isnan (p.post_float ())); + } + + // double + // + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters (" 0000123.456789 "); + p._post (); + assert (p.post_double () == 123.456789); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("-12.3456789E2"); + p._post (); + assert (p.post_double () == -12.3456789E2); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_double () == 0.0); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0"); + p._post (); + assert (p.post_double () == -0.0); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("INF"); + p._post (); + assert (isinf (p.post_double ())); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("-INF"); + p._post (); + assert (isinf (p.post_double ())); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("NaN"); + p._post (); + assert (isnan (p.post_double ())); + } + + // decimal + // + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters (" 0000123.456789 "); + p._post (); + assert (p.post_decimal () == 123.456789); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("-123.45678912345"); + p._post (); + assert (p.post_decimal () == -123.45678912345); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_decimal () == 0.0); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0"); + p._post (); + assert (p.post_decimal () == -0.0); + } + + + // Bad + // + + // float + // + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("+INF"); + assert (test_post_fail (p)); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("1.45 E2"); + assert (test_post_fail (p)); + } + + // double + // + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("+INF"); + assert (test_post_fail (p)); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("1.45 E2"); + assert (test_post_fail (p)); + } + + // decimal + // + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("INF"); + assert (test_post_fail (p)); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("+INF"); + assert (test_post_fail (p)); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("-INF"); + assert (test_post_fail (p)); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("NaN"); + assert (test_post_fail (p)); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("1.45 2"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/int/buildfile b/xsd-tests/cxx/parser/validation/built-in/int/buildfile new file mode 100644 index 0000000..51bdf12 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/int/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/int/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/int/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/int/driver.cxx new file mode 100644 index 0000000..d31d206 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/int/driver.cxx @@ -0,0 +1,116 @@ +// file : cxx/parser/validation/built-in/int/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in int and unsigned int types validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + { + int_pimpl p; + p.pre (); + p._pre (); + p._characters ("-2147483648"); + p._post (); + assert (p.post_int () == -2147483648); + } + + { + int_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_int () == 0); + } + + { + int_pimpl p; + p.pre (); + p._pre (); + p._characters ("2147483647"); + p._post (); + assert (p.post_int () == 2147483647); + } + + { + unsigned_int_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_unsigned_int () == 0); + } + + { + unsigned_int_pimpl p; + p.pre (); + p._pre (); + p._characters ("4294967295"); + p._post (); + assert (p.post_unsigned_int () == 4294967295); + } + + // Bad + // + + { + unsigned_int_pimpl p; + p.pre (); + p._pre (); + p._characters ("-123"); + assert (test_post_fail (p)); + } + + + // Ranges + // + { + int_pimpl p; + p.pre (); + p._pre (); + p._characters ("-2147483649"); + assert (test_post_fail (p)); + } + + { + int_pimpl p; + p.pre (); + p._pre (); + p._characters ("2147483648"); + assert (test_post_fail (p)); + } + + { + unsigned_int_pimpl p; + p.pre (); + p._pre (); + p._characters ("4294967296"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/integer/buildfile b/xsd-tests/cxx/parser/validation/built-in/integer/buildfile new file mode 100644 index 0000000..4d63a19 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/integer/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/integer/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/integer/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/integer/driver.cxx new file mode 100644 index 0000000..3a5fdd5 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/integer/driver.cxx @@ -0,0 +1,303 @@ +// file : cxx/parser/validation/built-in/integer/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in integer & friends types validation. +// +#include + +#include +#include +#include + +#include +#include + +using namespace std; +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + + std::string min; + std::string max; + std::string umax; + + { + ostringstream ostr; + ostr << LLONG_MIN; + min = ostr.str (); + } + + { + ostringstream ostr; + ostr << LLONG_MAX; + max = ostr.str (); + } + + { + ostringstream ostr; + ostr << ULLONG_MAX; + umax = ostr.str (); + } + + // integer + // + { + integer_pimpl p; + p.pre (); + p._pre (); + p._characters (min.c_str ()); + p._post (); + assert (p.post_integer () == LLONG_MIN); + } + + { + integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_integer () == 0); + } + + { + integer_pimpl p; + p.pre (); + p._pre (); + p._characters (max.c_str ()); + p._post (); + assert (p.post_integer () == LLONG_MAX); + } + + // negative_integer + // + { + negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (min.c_str ()); + p._post (); + assert (p.post_negative_integer () == LLONG_MIN); + } + + { + negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("-1"); + p._post (); + assert (p.post_negative_integer () == -1); + } + + // non_positive_integer + // + { + non_positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (min.c_str ()); + p._post (); + assert (p.post_non_positive_integer () == LLONG_MIN); + } + + { + non_positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("+0"); + p._post (); + assert (p.post_non_positive_integer () == 0); + } + + // positive_integer + // + { + positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("1"); + p._post (); + assert (p.post_positive_integer () == 1); + } + + { + positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (umax.c_str ()); + p._post (); + assert (p.post_positive_integer () == ULLONG_MAX); + } + + // non_negative_integer + // + /* + { + non_negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0"); + p._post (); + assert (p.post_non_negative_integer () == 0); + } + */ + + { + non_negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_non_negative_integer () == 0); + } + + { + non_negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (umax.c_str ()); + p._post (); + assert (p.post_non_negative_integer () == ULLONG_MAX); + } + + + // Bad + // + + std::string past_min (min); + std::string past_max (max); + std::string past_umax (umax); + + assert (*past_min.rbegin () != '9'); + assert (*past_max.rbegin () != '9'); + assert (*past_umax.rbegin () != '9'); + + (*past_min.rbegin ())++; + (*past_max.rbegin ())++; + (*past_umax.rbegin ())++; + + // integer + // + { + integer_pimpl p; + p.pre (); + p._pre (); + p._characters (past_min.c_str ()); + assert (test_post_fail (p)); + } + + { + integer_pimpl p; + p.pre (); + p._pre (); + p._characters (past_max.c_str ()); + assert (test_post_fail (p)); + } + + // negative_integer + // + { + negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (past_min.c_str ()); + assert (test_post_fail (p)); + } + + { + negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0"); + assert (test_post_fail (p)); + } + + { + negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("1"); + assert (test_post_fail (p)); + } + + // non_positive_integer + // + { + non_positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (past_min.c_str ()); + assert (test_post_fail (p)); + } + + { + non_positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("1"); + assert (test_post_fail (p)); + } + + // positive_integer + // + { + positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("-1"); + assert (test_post_fail (p)); + } + + { + positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("+0"); + assert (test_post_fail (p)); + } + + { + positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (past_umax.c_str ()); + assert (test_post_fail (p)); + } + + // non_negative_integer + // + { + non_negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("-1"); + assert (test_post_fail (p)); + } + + { + non_negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (past_umax.c_str ()); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/long/buildfile b/xsd-tests/cxx/parser/validation/built-in/long/buildfile new file mode 100644 index 0000000..285ad70 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/long/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/long/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/long/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/long/driver.cxx new file mode 100644 index 0000000..a4ab565 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/long/driver.cxx @@ -0,0 +1,116 @@ +// file : cxx/parser/validation/built-in/long/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in long and unsigned long types validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + { + long_pimpl p; + p.pre (); + p._pre (); + p._characters ("-9223372036854775808"); + p._post (); + assert (p.post_long () == (-9223372036854775807LL - 1)); + } + + { + long_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_long () == 0); + } + + { + long_pimpl p; + p.pre (); + p._pre (); + p._characters ("9223372036854775807"); + p._post (); + assert (p.post_long () == 9223372036854775807LL); + } + + { + unsigned_long_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_unsigned_long () == 0); + } + + { + unsigned_long_pimpl p; + p.pre (); + p._pre (); + p._characters ("18446744073709551615"); + p._post (); + assert (p.post_unsigned_long () == 18446744073709551615ULL); + } + + // Bad + // + + { + unsigned_long_pimpl p; + p.pre (); + p._pre (); + p._characters ("-123"); + assert (test_post_fail (p)); + } + + + // Ranges + // + { + long_pimpl p; + p.pre (); + p._pre (); + p._characters ("-9223372036854775809"); + assert (test_post_fail (p)); + } + + { + long_pimpl p; + p.pre (); + p._pre (); + p._characters ("9223372036854775808"); + assert (test_post_fail (p)); + } + + { + unsigned_long_pimpl p; + p.pre (); + p._pre (); + p._characters ("18446744073709551616"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/qname/buildfile b/xsd-tests/cxx/parser/validation/built-in/qname/buildfile new file mode 100644 index 0000000..47d644c --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/qname/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/qname/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/qname/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/qname/driver.cxx new file mode 100644 index 0000000..85acd1c --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/qname/driver.cxx @@ -0,0 +1,105 @@ +// file : cxx/parser/validation/built-in/qname/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in QName type validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +bool +test_post_fail (qname_pimpl& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + typedef xsd::cxx::parser::qname qname; + + // Good. + // + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters (" xsi"); + p._characters (":"); + p._characters ("schemaLocation"); + p._post (); + assert (p.post_qname () == qname ("xsi", "schemaLocation")); + } + + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters ("schemaLocation"); + p._post (); + assert (p.post_qname () == qname ("schemaLocation")); + } + + + // Bad + // + { + qname_pimpl p; + p.pre (); + p._pre (); + //p._characters (""); + assert (test_post_fail (p)); + } + + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters (":"); + assert (test_post_fail (p)); + } + + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters ("xsi:"); + assert (test_post_fail (p)); + } + + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters (":schemaLocation"); + assert (test_post_fail (p)); + } + + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters ("x?i:schemaLocation"); + assert (test_post_fail (p)); + } + + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters ("xsi:schema Location"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/short/buildfile b/xsd-tests/cxx/parser/validation/built-in/short/buildfile new file mode 100644 index 0000000..782b404 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/short/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/short/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/short/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/short/driver.cxx new file mode 100644 index 0000000..7c79b22 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/short/driver.cxx @@ -0,0 +1,116 @@ +// file : cxx/parser/validation/built-in/short/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in short and unsigned short types validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + { + short_pimpl p; + p.pre (); + p._pre (); + p._characters ("-32768"); + p._post (); + assert (p.post_short () == -32768); + } + + { + short_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_short () == 0); + } + + { + short_pimpl p; + p.pre (); + p._pre (); + p._characters ("32767"); + p._post (); + assert (p.post_short () == 32767); + } + + { + unsigned_short_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_unsigned_short () == 0); + } + + { + unsigned_short_pimpl p; + p.pre (); + p._pre (); + p._characters ("65535"); + p._post (); + assert (p.post_unsigned_short () == 65535); + } + + // Bad + // + + { + unsigned_short_pimpl p; + p.pre (); + p._pre (); + p._characters ("-1234"); + assert (test_post_fail (p)); + } + + + // Ranges + // + { + short_pimpl p; + p.pre (); + p._pre (); + p._characters ("-32769"); + assert (test_post_fail (p)); + } + + { + short_pimpl p; + p.pre (); + p._pre (); + p._characters ("32768"); + assert (test_post_fail (p)); + } + + { + unsigned_short_pimpl p; + p.pre (); + p._pre (); + p._characters ("65536"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/string/buildfile b/xsd-tests/cxx/parser/validation/built-in/string/buildfile new file mode 100644 index 0000000..83e5f7a --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/string/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/string/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/string/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/string/driver.cxx new file mode 100644 index 0000000..920385a --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/string/driver.cxx @@ -0,0 +1,512 @@ +// file : cxx/parser/validation/built-in/string/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in string & friends types validation. +// +#include +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post_impl (); // List implementation needs this to be post_impl. + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + typedef xsd::cxx::parser::string_sequence strings; + + // Good. + // + + // string + // + { + string_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" aaa "); + p._characters ("bbb"); + p._characters (" "); + p._post (); + assert (p.post_string () == " \n\t aaa bbb "); + } + + // normalized_string + // + { + normalized_string_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" aaa \n\t "); + p._characters (" bbb"); + p._characters (" "); + p._post (); + assert (p.post_normalized_string () == " aaa bbb "); + } + + // token + // + { + token_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" aaa \n\t "); + p._characters (" bbb \n\t"); + p._characters (" "); + p._post (); + assert (p.post_token () == "aaa bbb"); + } + + // name + // + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" a:b-c_d123 "); + p._characters (" "); + p._post (); + assert (p.post_name () == "a:b-c_d123"); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" _12 "); + p._characters (" "); + p._post (); + assert (p.post_name () == "_12"); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" :12 "); + p._characters (" "); + p._post (); + assert (p.post_name () == ":12"); + } + + // nmtoken + // + { + nmtoken_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" 123a:b-c_d123 "); + p._characters (" \n\t"); + p._characters (" "); + p._post (); + assert (p.post_nmtoken () == "123a:b-c_d123"); + } + + // nmtokens + // + { + strings s; + s.push_back ("123"); + s.push_back ("abc"); + + nmtokens_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" 123 "); + p._characters (" \n\t abc "); + p._characters (" "); + p._post (); + assert (p.post_nmtokens () == s); + } + + // ncname + // + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" a.b-c_d123 "); + p._characters (" "); + p._post (); + assert (p.post_ncname () == "a.b-c_d123"); + } + + // id + // + { + id_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" a.b-c_d123 "); + p._characters (" "); + p._post (); + assert (p.post_id () == "a.b-c_d123"); + } + + // idref + // + { + idref_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" a.b-c_d123 "); + p._characters (" "); + p._post (); + assert (p.post_idref () == "a.b-c_d123"); + } + + // idrefs + // + { + strings s; + s.push_back ("a123"); + s.push_back ("abc"); + + idrefs_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" a123 "); + p._characters (" \n\t abc "); + p._characters (" "); + p._post (); + assert (p.post_idrefs () == s); + } + + // language + // + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters (" x "); + p._post (); + assert (p.post_language () == "x"); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters (" en "); + p._post (); + assert (p.post_language () == "en"); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters (" en"); + p._characters ("-us "); + p._post (); + assert (p.post_language () == "en-us"); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters ("one-two-three-four44-seven77-eight888"); + p._post (); + assert (p.post_language () == "one-two-three-four44-seven77-eight888"); + } + + + // Bad + // + + // name + // + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters (""); + assert (test_post_fail (p)); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters (".a"); + assert (test_post_fail (p)); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters ("-a"); + assert (test_post_fail (p)); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters ("1a"); + assert (test_post_fail (p)); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters ("a,b"); + assert (test_post_fail (p)); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters ("a b"); + assert (test_post_fail (p)); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters ("a p; + p.pre (); + p._pre (); + p._characters (""); + assert (test_post_fail (p)); + } + + { + nmtoken_pimpl p; + p.pre (); + p._pre (); + p._characters ("a,b"); + assert (test_post_fail (p)); + } + + { + nmtoken_pimpl p; + p.pre (); + p._pre (); + p._characters ("a b"); + assert (test_post_fail (p)); + } + + { + nmtoken_pimpl p; + p.pre (); + p._pre (); + p._characters ("a p; + p.pre (); + p._pre (); + p._characters (" "); + p._characters (" \t\n "); + assert (test_post_fail (p)); + } + + { + nmtokens_pimpl p; + p.pre (); + p._pre (); + p._characters ("ab a,b"); + assert (test_post_fail (p)); + } + + // ncname + // + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters (""); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters (".a"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters ("-a"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters (":a"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters ("1a"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters ("1:a"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters ("a,b"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters ("a b"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters ("a p; + p.pre (); + p._pre (); + p._characters ("a b"); + assert (test_post_fail (p)); + } + + // idref + // + { + idref_pimpl p; + p.pre (); + p._pre (); + p._characters ("a b"); + assert (test_post_fail (p)); + } + + // idrefs + // + { + idrefs_pimpl p; + p.pre (); + p._pre (); + p._characters (" "); + p._characters (" \t\n "); + assert (test_post_fail (p)); + } + + { + idrefs_pimpl p; + p.pre (); + p._pre (); + p._characters ("ab a p; + p.pre (); + p._pre (); + p._characters (" "); + assert (test_post_fail (p)); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters ("en-"); + assert (test_post_fail (p)); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters ("a1"); + assert (test_post_fail (p)); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters ("en+us"); + assert (test_post_fail (p)); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters ("en-nine99999"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/uri/buildfile b/xsd-tests/cxx/parser/validation/built-in/uri/buildfile new file mode 100644 index 0000000..a8fdf82 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/uri/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/uri/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/uri/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/uri/driver.cxx new file mode 100644 index 0000000..dcc9242 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/uri/driver.cxx @@ -0,0 +1,53 @@ +// file : cxx/parser/validation/built-in/uri/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in anyURI type validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +int +main () +{ + // Good. + // + { + uri_pimpl p; + p.pre (); + p._pre (); + p._characters (" "); + p._post (); + assert (p.post_uri () == ""); + } + + { + uri_pimpl p; + p.pre (); + p._pre (); + p._characters ("relative"); + p._post (); + assert (p.post_uri () == "relative"); + } + + { + uri_pimpl p; + p.pre (); + p._pre (); + p._characters ("#id"); + p._post (); + assert (p.post_uri () == "#id"); + } + + { + uri_pimpl p; + p.pre (); + p._pre (); + p._characters ("http://www.example.com/foo#bar"); + p._post (); + assert (p.post_uri () == "http://www.example.com/foo#bar"); + } +} diff --git a/xsd-tests/cxx/parser/validation/choice/buildfile b/xsd-tests/cxx/parser/validation/choice/buildfile new file mode 100644 index 0000000..adf0832 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/choice/buildfile @@ -0,0 +1,22 @@ +# file : cxx/parser/validation/choice/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs \ + testscript + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-validation \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/validation/choice/driver.cxx b/xsd-tests/cxx/parser/validation/choice/driver.cxx new file mode 100644 index 0000000..4a52c5d --- /dev/null +++ b/xsd-tests/cxx/parser/validation/choice/driver.cxx @@ -0,0 +1,126 @@ +// file : cxx/parser/validation/choice/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the choice compositor validation. +// + +#include +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; +using xml_schema::ro_string; + +struct choice_pimpl: choice_pskel +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + b (string const& v) + { + cout << " b = " << v << endl; + } + + virtual void + c (string const& v) + { + cout << " c = " << v << endl; + } + + virtual void + d (string const& v) + { + cout << " d = " << v << endl; + } + + virtual void + _start_any_element (ro_string const& ns, + ro_string const& name, + ro_string const*) + { + cout << " any: " << ns << "#" << name << endl + << " {" << endl; + } + + virtual void + _any_characters (ro_string const& v) + { + cout << " chars = " << v << endl; + } + + virtual void + _end_any_element (ro_string const&, ro_string const&) + { + cout << " }" << endl; + } + + virtual void + post_choice () + { + cout << "}" << endl + << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + choice_pimpl choice_p; + type_pimpl type_p; + + choice_p.parsers (string_p, string_p, string_p, string_p); + type_p.parsers (choice_p); + + xml_schema::document doc_p (type_p, "test", "root"); + + try + { + ifstream ifs (argv[1]); + type_p.pre (); + doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cout << " " << e << endl + << "}" << endl + << endl; + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/validation/choice/test.xsd b/xsd-tests/cxx/parser/validation/choice/test.xsd new file mode 100644 index 0000000..8132bbb --- /dev/null +++ b/xsd-tests/cxx/parser/validation/choice/test.xsd @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/validation/choice/testscript b/xsd-tests/cxx/parser/validation/choice/testscript new file mode 100644 index 0000000..c5f5afa --- /dev/null +++ b/xsd-tests/cxx/parser/validation/choice/testscript @@ -0,0 +1,179 @@ +# file : cxx/parser/validation/choice/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +test.arguments += test.xml + +: valid +: +{ + cat <=test.xml; + + + + a + + b + + + + c + d + + any + + a + + + + c + d + + d + + a + + + + EOI + + $* >>EOO + { + a = a + b = b + } + + { + c = c + d = d + any: other#any + { + chars = any + } + a = a + } + + { + c = c + d = d + d = d + a = a + } + + EOO +} + +: absent1 +: +{ + cat <=test.xml; + + + + + + + + EOI + + $* >>EOO + { + :8:12 error: expected element 'a' + } + + EOO +} + +: absent2 +: +{ + cat <=test.xml; + + + + + c + d + + any + + a + b + + + + EOI + + $* >>EOO + { + c = c + d = d + any: other#any + { + chars = any + } + a = a + :14:8 error: unexpected element 'b' + } + + EOO +} + +: absent3 +: +{ + cat <=test.xml; + + + + + c + + + + EOI + + $* >>EOO + { + c = c + :9:12 error: expected element 'd' + } + + EOO +} + +: absent4 +: +{ + cat <=test.xml; + + + + + x + + + + EOI + + $* >>EOO + { + :8:8 error: expected element 'a' instead of 'x' + } + + EOO +} diff --git a/xsd-tests/cxx/parser/validation/restriction/buildfile b/xsd-tests/cxx/parser/validation/restriction/buildfile new file mode 100644 index 0000000..4c415bf --- /dev/null +++ b/xsd-tests/cxx/parser/validation/restriction/buildfile @@ -0,0 +1,22 @@ +# file : cxx/parser/validation/restriction/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs \ + testscript + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-validation \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/validation/restriction/driver.cxx b/xsd-tests/cxx/parser/validation/restriction/driver.cxx new file mode 100644 index 0000000..206b9f8 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/restriction/driver.cxx @@ -0,0 +1,107 @@ +// file : cxx/parser/validation/restriction/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the restriction compositor validation. +// + +#include +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; + +struct base_a_pimpl: base_a_pskel +{ +}; + +struct restriction_a_pimpl: restriction_a_pskel +{ +}; + +struct extension_b_pimpl: extension_b_pskel +{ +}; + +struct restriction_b_pimpl: restriction_b_pskel +{ +}; + +struct type_b_pimpl: type_b_pskel +{ +}; + +struct type_r_pimpl: type_r_pskel +{ +}; + + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + base_a_pimpl base_a_p; + restriction_a_pimpl restriction_a_p; + extension_b_pimpl extension_b_p; + restriction_b_pimpl restriction_b_p; + type_b_pimpl type_b_p; + type_r_pimpl type_r_p; + + base_a_p.parsers (string_p, string_p, string_p, + string_p, string_p, string_p); + + restriction_a_p.parsers (string_p, string_p, string_p, + string_p, string_p, string_p); + + extension_b_p.parsers (string_p, string_p, string_p, + string_p, string_p); + + restriction_b_p.parsers (string_p, string_p, string_p, + string_p, string_p); + + type_b_p.parsers (base_a_p, extension_b_p); + type_r_p.parsers (restriction_a_p, restriction_b_p); + + xml_schema::document doc_b_p (type_b_p, "test", "root"); + xml_schema::document doc_r_p (type_r_p, "test", "root"); + + { + ifstream ifs (argv[1]); + type_b_p.pre (); + doc_b_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_b_p.post_type_b (); + } + + try + { + ifstream ifs (argv[1]); + type_r_p.pre (); + doc_r_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_r_p.post_type_r (); + } + catch (xml_schema::exception const& e) + { + cout << e << endl; + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/validation/restriction/test.xsd b/xsd-tests/cxx/parser/validation/restriction/test.xsd new file mode 100644 index 0000000..158ded5 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/restriction/test.xsd @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/validation/restriction/testscript b/xsd-tests/cxx/parser/validation/restriction/testscript new file mode 100644 index 0000000..ea5a4e8 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/restriction/testscript @@ -0,0 +1,159 @@ +# file : cxx/parser/validation/all/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +test.arguments += test.xml + +: valid +: +{ + cat <=test.xml; + + + + a + b + c + + + + a + b + c + + + + a + b + + + + a + c + + + + a + + + + EOI + + $* +} + +: invalid1 +: +{ + cat <=test.xml; + + + + + b + c + + + + EOI + + $* >>EOO + :7:8 error: expected element 'a' instead of 'b' + EOO +} + +: invalid2 +: +{ + cat <=test.xml; + + + + + a + b + c + + + + EOI + + $* >>EOO + :10:19 error: expected attribute 'z' + EOO +} + +: invalid3 +: +{ + cat <=test.xml; + + + + + a + b + c + + a + b + c + + + + EOI + + $* >>EOO + :11:8 error: unexpected element 'a' + EOO +} + +: invalid4 +: +{ + cat <=test.xml; + + + + + b + + + + EOI + + $* >>EOO + :7:8 error: expected element 'a' instead of 'b' + EOO +} + +: invalid5 +: +{ + cat <=test.xml; + + + + + a + b + + + + EOI + + $* >>EOO + :9:19 error: expected attribute 'y' + EOO +} diff --git a/xsd-tests/cxx/parser/validation/sequence/buildfile b/xsd-tests/cxx/parser/validation/sequence/buildfile new file mode 100644 index 0000000..b205091 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/sequence/buildfile @@ -0,0 +1,22 @@ +# file : cxx/parser/validation/sequence/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs \ + testscript + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-validation \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/validation/sequence/driver.cxx b/xsd-tests/cxx/parser/validation/sequence/driver.cxx new file mode 100644 index 0000000..6b5bf70 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/sequence/driver.cxx @@ -0,0 +1,139 @@ +// file : cxx/parser/validation/sequence/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the sequence compositor validation. +// + +#include +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; +using xml_schema::ro_string; + +struct sequence_pimpl: sequence_pskel +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + b (string const& v) + { + cout << " b = " << v << endl; + } + + virtual void + c (string const& v) + { + cout << " c = " << v << endl; + } + + virtual void + d (string const& v) + { + cout << " d = " << v << endl; + } + + virtual void + e (string const& v) + { + cout << " e = " << v << endl; + } + + virtual void + f (string const& v) + { + cout << " f = " << v << endl; + } + + virtual void + _start_any_element (ro_string const& ns, + ro_string const& name, + ro_string const*) + { + cout << " any: " << ns << "#" << name << endl + << " {" << endl; + } + + virtual void + _any_characters (ro_string const& v) + { + cout << " chars = " << v << endl; + } + + virtual void + _end_any_element (ro_string const&, ro_string const&) + { + cout << " }" << endl; + } + + virtual void + post_sequence () + { + cout << "}" << endl + << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + sequence_pimpl sequence_p; + type_pimpl type_p; + + sequence_p.parsers (string_p, string_p, string_p, + string_p, string_p, string_p); + type_p.parsers (sequence_p); + + xml_schema::document doc_p (type_p, "test", "root"); + + try + { + ifstream ifs (argv[1]); + type_p.pre (); + doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cout << " " << e << endl + << "}" << endl + << endl; + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/validation/sequence/test.xsd b/xsd-tests/cxx/parser/validation/sequence/test.xsd new file mode 100644 index 0000000..8753f54 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/sequence/test.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/validation/sequence/testscript b/xsd-tests/cxx/parser/validation/sequence/testscript new file mode 100644 index 0000000..deebb9f --- /dev/null +++ b/xsd-tests/cxx/parser/validation/sequence/testscript @@ -0,0 +1,328 @@ +# file : cxx/parser/validation/sequence/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +test.arguments += test.xml + +: valid +: +{ + cat <=test.xml; + + + + c + d + aaabbbccc + f + e + + + + a + b + c + d + d + d + any + f + e + e + + + + a + b + c + d + d + d + any + f + e + e + + c + d + any + f + e + + + + EOI + + $* >>EOO + { + c = c + d = d + any: test#any + { + chars = aaa + any: #a + { + chars = bbb + } + chars = ccc + } + f = f + e = e + } + + { + a = a + b = b + c = c + d = d + d = d + d = d + any: other#any + { + chars = any + } + f = f + e = e + e = e + } + + { + a = a + b = b + c = c + d = d + d = d + d = d + any: other#any + { + chars = any + } + f = f + e = e + e = e + c = c + d = d + any: test#any + { + chars = any + } + f = f + e = e + } + + EOO +} + +: invalid1 +: +{ + cat <=test.xml; + + + + + + + + EOI + + $* >>EOO + { + :8:14 error: expected element 'a' + } + + EOO +} + +: invalid2 +: +{ + cat <=test.xml; + + + + + c + d + any + f + e + + c + d + any + f + e + + c + d + any + f + e + + + + EOI + + $* >>EOO + { + c = c + d = d + any: test#any + { + chars = any + } + f = f + e = e + c = c + d = d + any: test#any + { + chars = any + } + f = f + e = e + :20:8 error: unexpected element 'c' + } + + EOO +} + +: invalid3 +: +{ + cat <=test.xml; + + + + + a + a + c + d + any + f + e + + + + EOI + + $* >>EOO + { + a = a + :9:8 error: expected element 'b' instead of 'a' + } + + EOO +} + +: invalid4 +: +{ + cat <=test.xml; + + + + + d + any + f + e + + + + EOI + + $* >>EOO + { + :8:8 error: expected element 'a' instead of 'd' + } + + EOO +} + +: invalid5 +: +{ + cat <=test.xml; + + + + + c + d + any + f + e + + + + EOI + + $* >>EOO + { + c = c + d = d + :10:13 error: expected element '##targetNamespace#*' instead of 'other1#any' + } + + EOO +} + +: invalid6 +: +{ + cat <=test.xml; + + + + + c + d + any + f + e + e + e + + + + EOI + + $* >>EOO + { + c = c + d = d + any: test#any + { + chars = any + } + f = f + e = e + e = e + :14:8 error: unexpected element 'e' + } + + EOO +} diff --git a/xsd-tests/cxx/tree/any-type/buildfile b/xsd-tests/cxx/tree/any-type/buildfile new file mode 100644 index 0000000..c65c403 --- /dev/null +++ b/xsd-tests/cxx/tree/any-type/buildfile @@ -0,0 +1,26 @@ +# file : cxx/tree/any-type/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --generate-any-type \ + --generate-ostream \ + --generate-comparison \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/any-type/driver.cxx b/xsd-tests/cxx/tree/any-type/driver.cxx new file mode 100644 index 0000000..a8fccf6 --- /dev/null +++ b/xsd-tests/cxx/tree/any-type/driver.cxx @@ -0,0 +1,144 @@ +// file : cxx/tree/any-type/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test anyType and anySimpleType content extraction. +// + +#include // std::auto_ptr/unique_ptr +#include // std::move +#include +#include + +#include +#include + +#include "test.hxx" // Get XSD_CXX11 defined. + +#include + +using namespace std; +using namespace test; +using namespace xercesc; + +namespace xml = xsd::cxx::xml; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + XMLPlatformUtils::Initialize (); + + try + { + // Test parsing + // + XSD_AUTO_PTR r (root (argv[1])); + + // Test API. + // + { + assert (type::a_default_value ().text_content () == "default value"); + } + + { + xml_schema::simple_type x ("fox"); + assert (x.text_content () == "fox"); + x.text_content ("foo"); + assert (x.text_content () == "foo"); + x.text_content ().clear (); + assert (x.text_content () == ""); + x.text_content () = "baz"; + r->s ().push_back (x); + } + + { + xml_schema::type x; + + DOMDocument& doc (x.dom_content_document ()); + + // Copy. + // + DOMElement* e (doc.createElement (xml::string ("dummy").c_str ())); + e->setAttribute (xml::string ("x").c_str (), + xml::string ("foo").c_str ()); + e->setTextContent (xml::string ("data").c_str ()); + x.dom_content ().set (*e); + e->release (); + + r->t ().push_back (x); + } + + { + XSD_AUTO_PTR x (new xml_schema::type); + + DOMDocument& doc (x->dom_content_document ()); + + // Assume ownership. + // + DOMElement* e (doc.createElement (xml::string ("dummy").c_str ())); + e->setAttribute (xml::string ("x").c_str (), + xml::string ("foo").c_str ()); + e->setTextContent (xml::string ("data").c_str ()); + x->dom_content ().set (e); + +#ifdef XSD_CXX11 + r->t ().push_back (std::move (x)); +#else + r->t ().push_back (x); +#endif + } + + // Test printing. + // + cout << *r << endl + << endl; + + // Test serialization. + // + xml_schema::namespace_infomap map; + + map["t"].name = "test"; + map["t"].schema = "test.xsd"; + map["o"].name = "other"; + + stringstream iostr; + root (iostr, *r, map); + + cout << iostr.str () << endl + << endl; + + { + XSD_AUTO_PTR r1 (root (iostr, argv[1])); + + // Xerces-C++ mis-indentation of mixed content messes this up. + // assert (*r == *r); + + stringstream iostr; + root (iostr, *r1, map); + + cout << iostr.str () << endl + << endl; + } + + // Test comparison. + // + assert (*r == *r); + + // Test copy c-tor. + // + type copy (*r); + assert (copy == *r); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + + XMLPlatformUtils::Terminate (); +} diff --git a/xsd-tests/cxx/tree/any-type/output b/xsd-tests/cxx/tree/any-type/output new file mode 100644 index 0000000..580e7db --- /dev/null +++ b/xsd-tests/cxx/tree/any-type/output @@ -0,0 +1,73 @@ + +t: +t: +t: +t: +t: +t: +t: +t: +s: +s: simple +s: baz +l: one two three +a: any simple content + + + + + + any + any + + + nested 1 + nested 2 + + more + + mi + nested 1x + nested 2ed + content + + data + data + + simple + baz + one two three + + + + + + + + any + any + + + nested 1 + nested 2 + + more + + mi + + nested 1x + + nested 2ed + + content + + + data + data + + simple + baz + one two three + + + diff --git a/xsd-tests/cxx/tree/any-type/test.xml b/xsd-tests/cxx/tree/any-type/test.xml new file mode 100644 index 0000000..7c9035a --- /dev/null +++ b/xsd-tests/cxx/tree/any-type/test.xml @@ -0,0 +1,26 @@ + + + + + any + any + + + nested 1 + nested 2 + + more + + minested 1xnested 2edcontent + + + simple + + one two three + + diff --git a/xsd-tests/cxx/tree/any-type/test.xsd b/xsd-tests/cxx/tree/any-type/test.xsd new file mode 100644 index 0000000..37dcc8d --- /dev/null +++ b/xsd-tests/cxx/tree/any-type/test.xsd @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/binary/cdr/buildfile b/xsd-tests/cxx/tree/binary/cdr/buildfile new file mode 100644 index 0000000..7a1c5b4 --- /dev/null +++ b/xsd-tests/cxx/tree/binary/cdr/buildfile @@ -0,0 +1,25 @@ +# file : cxx/tree/binary/cdr/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} +import libs += libace%lib{ACE} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-insertion 'ACE_OutputCDR' \ + --generate-extraction 'ACE_InputCDR' \ + --generate-comparison \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/binary/cdr/driver.cxx b/xsd-tests/cxx/tree/binary/cdr/driver.cxx new file mode 100644 index 0000000..fe74bb5 --- /dev/null +++ b/xsd-tests/cxx/tree/binary/cdr/driver.cxx @@ -0,0 +1,143 @@ +// file : tests/cxx/tree/binary/cdr/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test non-polymorphic binary serialization to ACE CDR. +// + +#include // std::auto_ptr/unique_ptr +#include +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + XSD_AUTO_PTR r (root (argv[1])); + + // Save to a CDR stream. + // + ACE_OutputCDR ace_ocdr; + xml_schema::ostream ocdr (ace_ocdr); + ocdr << *r; + + // Load from a CDR stream. + // + ACE_InputCDR ace_icdr (ace_ocdr); + xml_schema::istream icdr (ace_icdr); + XSD_AUTO_PTR c (new type (icdr)); + + // Compare the two. + // + assert (r->list () == c->list ()); + assert (r->union_ () == c->union_ ()); + assert (r->enumeration () == c->enumeration ()); + + type::complex_sequence rs (r->complex ()), cs (c->complex ()); + + for (type::complex_iterator ri (rs.begin ()), ci (cs.begin ()); + ri != rs.end () && ci != rs.end (); ++ri, ++ci) + { + assert (ri->a () == ci->a ()); + if (ri->b ()) + assert (ri->b () == ci->b ()); + assert (ri->c () == ci->c ()); + + assert (ri->x () == ci->x ()); + if (ri->y ()) + assert (ri->y () == ci->y ()); + } + + // integers + // + assert (r->byte () == c->byte ()); + assert (r->unsigned_byte () == c->unsigned_byte ()); + assert (r->short_ () == c->short_ ()); + assert (r->unsigned_short () == c->unsigned_short ()); + assert (r->int_ () == c->int_ ()); + assert (r->unsigned_int () == c->unsigned_int ()); + assert (r->long_ () == c->long_ ()); + assert (r->unsigned_long () == c->unsigned_long ()); + assert (r->integer () == c->integer ()); + assert (r->non_positive_integer () == c->non_positive_integer ()); + assert (r->non_negative_integer () == c->non_negative_integer ()); + assert (r->positive_integer () == c->positive_integer ()); + assert (r->negative_integer () == c->negative_integer ()); + + // boolean + // + assert (r->boolean () == c->boolean ()); + + // floats + // + assert (r->float_ () == c->float_ ()); + assert (r->double_ () == c->double_ ()); + assert (r->decimal () == c->decimal ()); + + // strings + // + assert (r->string () == c->string ()); + assert (r->normalized_string () == c->normalized_string ()); + assert (r->token () == c->token ()); + assert (r->name () == c->name ()); + assert (r->name_token () == c->name_token ()); + assert (r->name_tokens () == c->name_tokens ()); + assert (r->ncname () == c->ncname ()); + assert (r->language () == c->language ()); + + // qualified name + // + assert (r->qname () == c->qname ()); + + // ID/IDREF + // + assert (r->id () == c->id ()); + assert (r->id_ref () == c->id_ref ()); + assert (r->id_refs () == c->id_refs ()); + + // URI + // + assert (r->any_uri () == c->any_uri ()); + + // binary + // + assert (r->base64_binary () == c->base64_binary ()); + assert (r->hex_binary () == c->hex_binary ()); + + // date/time + // + assert (r->day () == c->day ()); + assert (r->month () == c->month ()); + assert (r->year () == c->year ()); + assert (r->month_day () == c->month_day ()); + assert (r->year_month () == c->year_month ()); + assert (r->date () == c->date ()); + assert (r->time () == c->time ()); + assert (r->date_time () == c->date_time ()); + assert (r->duration () == c->duration ()); + + // anySimpleType + // + assert (!r->any_simple_type_attr ().text_content ().empty ()); + assert (r->any_simple_type_attr () == c->any_simple_type_attr ()); + + assert (!r->any_simple_type ().text_content ().empty ()); + assert (r->any_simple_type () == c->any_simple_type ()); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/binary/cdr/test.xml b/xsd-tests/cxx/tree/binary/cdr/test.xml new file mode 100644 index 0000000..5cedd98 --- /dev/null +++ b/xsd-tests/cxx/tree/binary/cdr/test.xml @@ -0,0 +1,93 @@ + + + 1 2 3 + + abc + + left + + + aaa + + + aaa + bbb + c + cc + ccc + + + + + 65 + 66 + -222 + 57005 + -57005 + 3735928559 + -3735928559 + 16045690984833335023 + -3735928559 + -3735928559 + 3735928559 + 3735928559 + -3735928559 + + + + true + + + + 1234.1234 + 12345678.12345678 + 1234567812345678.1234567812345678 + + + + string + normalized string + one two three + name + name-token + name tokens + ncname + en-us + + + xsi:schemaLocation + + + + elements1 + elements2 + elements1 + elements1 elements2 + + + + http://www.codesynthesis.com + + + + YmFzZTY0IGJpbmFyeQ== + 6865782052696E617279 + + + + 2001-10-26+02:00 + 2001-10-26T21:32:52+02:00 + P1Y2M3DT5H20M30S + ---01+02:00 + --11+02:00 + --11-02+02:00 + 2001+02:00 + 2001-11+02:00 + + + any simple content in element + + diff --git a/xsd-tests/cxx/tree/binary/cdr/test.xsd b/xsd-tests/cxx/tree/binary/cdr/test.xsd new file mode 100644 index 0000000..0629e94 --- /dev/null +++ b/xsd-tests/cxx/tree/binary/cdr/test.xsd @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/binary/polymorphic/buildfile b/xsd-tests/cxx/tree/binary/polymorphic/buildfile new file mode 100644 index 0000000..d34ef27 --- /dev/null +++ b/xsd-tests/cxx/tree/binary/polymorphic/buildfile @@ -0,0 +1,27 @@ +# file : cxx/tree/binary/polymorphic/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} +import libs += libace%lib{ACE} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-polymorphic \ + --root-element-last \ + --generate-insertion 'ACE_OutputCDR' \ + --generate-extraction 'ACE_InputCDR' \ + --generate-comparison \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/binary/polymorphic/driver.cxx b/xsd-tests/cxx/tree/binary/polymorphic/driver.cxx new file mode 100644 index 0000000..15ebf17 --- /dev/null +++ b/xsd-tests/cxx/tree/binary/polymorphic/driver.cxx @@ -0,0 +1,164 @@ +// file : tests/cxx/tree/binary/polymorphic/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test polymorphic binary serialization. +// + +#include // std::auto_ptr/unique_ptr +#include +#include +#include + +#include // ACE_HEX_DUMP + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + XSD_AUTO_PTR r (root (argv[1])); + + // Save to a CDR stream. + // + ACE_OutputCDR ace_ocdr; + xml_schema::ostream ocdr (ace_ocdr); + ocdr << *r; + + /* + // Print the binary representation. + // + cerr << "binary representation size: " << ace_ocdr.total_length () << endl; + + for (const ACE_Message_Block* mb = ace_ocdr.begin (); + mb != 0; + mb = mb->cont ()) + { + ACE_HEX_DUMP ((LM_DEBUG, mb->rd_ptr (), mb->length ())); + } + */ + + // Load from a CDR stream. + // + ACE_InputCDR ace_icdr (ace_ocdr); + xml_schema::istream icdr (ace_icdr); + XSD_AUTO_PTR c (new type (icdr)); + + // Compare the two. + // + assert (r->list () == c->list ()); + assert (r->union_ () == c->union_ ()); + assert (r->enumeration () == c->enumeration ()); + + { + complex& rc (dynamic_cast (r->base ())); + complex& cc (dynamic_cast (c->base ())); + + assert (rc.a () == cc.a ()); + if (rc.b ()) + assert (rc.b () == cc.b ()); + assert (rc.c () == cc.c ()); + + assert (rc.x () == cc.x ()); + if (rc.y ()) + assert (rc.y () == cc.y ()); + } + + { + complex& rc (dynamic_cast (r->sbase ())); + complex& cc (dynamic_cast (c->sbase ())); + + assert (rc.a () == cc.a ()); + if (rc.b ()) + assert (rc.b () == cc.b ()); + assert (rc.c () == cc.c ()); + + assert (rc.x () == cc.x ()); + if (rc.y ()) + assert (rc.y () == cc.y ()); + } + + // integers + // + assert (r->byte () == c->byte ()); + assert (r->unsigned_byte () == c->unsigned_byte ()); + assert (r->short_ () == c->short_ ()); + assert (r->unsigned_short () == c->unsigned_short ()); + assert (r->int_ () == c->int_ ()); + assert (r->unsigned_int () == c->unsigned_int ()); + assert (r->long_ () == c->long_ ()); + assert (r->unsigned_long () == c->unsigned_long ()); + assert (r->integer () == c->integer ()); + assert (r->non_positive_integer () == c->non_positive_integer ()); + assert (r->non_negative_integer () == c->non_negative_integer ()); + assert (r->positive_integer () == c->positive_integer ()); + assert (r->negative_integer () == c->negative_integer ()); + + // boolean + // + assert (r->boolean () == c->boolean ()); + + // floats + // + assert (r->float_ () == c->float_ ()); + assert (r->double_ () == c->double_ ()); + assert (r->decimal () == c->decimal ()); + + // strings + // + assert (r->string () == c->string ()); + assert (r->normalized_string () == c->normalized_string ()); + assert (r->token () == c->token ()); + assert (r->name () == c->name ()); + assert (r->name_token () == c->name_token ()); + assert (r->name_tokens () == c->name_tokens ()); + assert (r->ncname () == c->ncname ()); + assert (r->language () == c->language ()); + + // qualified name + // + assert (r->qname () == c->qname ()); + + // ID/IDREF + // + assert (r->id () == c->id ()); + assert (r->id_ref () == c->id_ref ()); + assert (r->id_refs () == c->id_refs ()); + + // URI + // + assert (r->any_uri () == c->any_uri ()); + + // binary + // + assert (r->base64_binary () == c->base64_binary ()); + assert (r->hex_binary () == c->hex_binary ()); + + // date/time + // + assert (r->date () == c->date ()); + assert (r->date_time () == c->date_time ()); + assert (r->duration () == c->duration ()); + assert (r->day () == c->day ()); + assert (r->month () == c->month ()); + assert (r->month_day () == c->month_day ()); + assert (r->year () == c->year ()); + assert (r->year_month () == c->year_month ()); + assert (r->time () == c->time ()); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/binary/polymorphic/test.xml b/xsd-tests/cxx/tree/binary/polymorphic/test.xml new file mode 100644 index 0000000..ad3a403 --- /dev/null +++ b/xsd-tests/cxx/tree/binary/polymorphic/test.xml @@ -0,0 +1,92 @@ + + + 1 2 3 + + abc + + left + + + aaa + + + + aaa + bbb + c + cc + ccc + + + + + 65 + 66 + -222 + 57005 + -57005 + 3735928559 + -3735928559 + 16045690984833335023 + -3735928559 + -3735928559 + 3735928559 + 3735928559 + -3735928559 + + + + true + + + + 1234.1234 + 12345678.12345678 + 1234567812345678.1234567812345678 + + + + string + normalized string + one two three + name + name-token + name tokens + ncname + en-us + + + xsi:schemaLocation + + + + elements1 + elements2 + elements1 + elements1 elements2 + + + + http://www.codesynthesis.com + + + + YmFzZTY0IGJpbmFyeQ== + 6865782052696E617279 + + + + 2001-10-26+02:00 + 2001-10-26T21:32:52+02:00 + P1Y2M3DT5H20M30S + ---01+02:00 + --11+02:00 + --11-02+02:00 + 2001+02:00 + 2001-11+02:00 + + + + diff --git a/xsd-tests/cxx/tree/binary/polymorphic/test.xsd b/xsd-tests/cxx/tree/binary/polymorphic/test.xsd new file mode 100644 index 0000000..8c214e5 --- /dev/null +++ b/xsd-tests/cxx/tree/binary/polymorphic/test.xsd @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/binary/xdr-ordered/buildfile b/xsd-tests/cxx/tree/binary/xdr-ordered/buildfile new file mode 100644 index 0000000..09414c7 --- /dev/null +++ b/xsd-tests/cxx/tree/binary/xdr-ordered/buildfile @@ -0,0 +1,28 @@ +# file : cxx/tree/binary/xdr-ordered/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +if ($cxx.target.class == 'linux') + import libs += libtirpc%lib{tirpc} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-insertion 'XDR' \ + --generate-extraction 'XDR' \ + --generate-comparison \ + --ordered-type-all \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/binary/xdr-ordered/driver.cxx b/xsd-tests/cxx/tree/binary/xdr-ordered/driver.cxx new file mode 100644 index 0000000..d61a645 --- /dev/null +++ b/xsd-tests/cxx/tree/binary/xdr-ordered/driver.cxx @@ -0,0 +1,206 @@ +// file : tests/cxx/tree/binary/xdr-ordered/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test non-polymorphic ordered binary serialization to XDR. +// +// Note: just a copy of xdr test with --ordered-type-all option. +// + +#include // std::auto_ptr/unique_ptr +#include // std::memcpy +#include +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +extern "C" int +overflow (void* p, char* buf, int in) +{ + xml_schema::buffer* dst (reinterpret_cast (p)); + + size_t n (static_cast (in)), size (dst->size ()); + dst->size (size + n); + memcpy (dst->data () + size, buf, n); + + return static_cast (n); +} + +struct underflow_info +{ + xml_schema::buffer* buf; + std::size_t pos; +}; + +extern "C" int +underflow (void* p, char* buf, int in) +{ + underflow_info* ui (reinterpret_cast (p)); + + size_t n (static_cast (in)), size (ui->buf->size () - ui->pos); + n = size > n ? n : size; + + memcpy (buf, ui->buf->data () + ui->pos, n); + ui->pos += n; + + return static_cast (n); +} + +// The xdrrec_create function (used below) has slightly different +// prototypes on different platforms. To make this test 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] << " test.xml" << endl; + return 1; + } + + try + { + XSD_AUTO_PTR r (root (argv[1])); + + xdrrec_create_p xdrrec_create_ = + reinterpret_cast (::xdrrec_create); + + // 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; + xsd::cxx::tree::ostream oxdr (xdr); + oxdr << *r; + xdrrec_endofrecord (&xdr, true); // flush the data + xdr_destroy (&xdr); + + // 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); + xsd::cxx::tree::istream ixdr (xdr); + XSD_AUTO_PTR c (new type (ixdr)); + xdr_destroy (&xdr); + + // Compare the two. + // + assert (r->list () == c->list ()); + assert (r->union_ () == c->union_ ()); + assert (r->enumeration () == c->enumeration ()); + + type::complex_sequence rs (r->complex ()), cs (c->complex ()); + + for (type::complex_iterator ri (rs.begin ()), ci (cs.begin ()); + ri != rs.end () && ci != rs.end (); ++ri, ++ci) + { + assert (ri->a () == ci->a ()); + if (ri->b ()) + assert (ri->b () == ci->b ()); + assert (ri->c () == ci->c ()); + + assert (ri->x () == ci->x ()); + if (ri->y ()) + assert (ri->y () == ci->y ()); + } + + // integers + // + assert (r->byte () == c->byte ()); + assert (r->unsigned_byte () == c->unsigned_byte ()); + assert (r->short_ () == c->short_ ()); + assert (r->unsigned_short () == c->unsigned_short ()); + assert (r->int_ () == c->int_ ()); + assert (r->unsigned_int () == c->unsigned_int ()); + assert (r->long_ () == c->long_ ()); + assert (r->unsigned_long () == c->unsigned_long ()); + assert (r->integer () == c->integer ()); + assert (r->non_positive_integer () == c->non_positive_integer ()); + assert (r->non_negative_integer () == c->non_negative_integer ()); + assert (r->positive_integer () == c->positive_integer ()); + assert (r->negative_integer () == c->negative_integer ()); + + // boolean + // + assert (r->boolean () == c->boolean ()); + + // floats + // + assert (r->float_ () == c->float_ ()); + assert (r->double_ () == c->double_ ()); + assert (r->decimal () == c->decimal ()); + + // strings + // + assert (r->string () == c->string ()); + assert (r->normalized_string () == c->normalized_string ()); + assert (r->token () == c->token ()); + assert (r->name () == c->name ()); + assert (r->name_token () == c->name_token ()); + assert (r->name_tokens () == c->name_tokens ()); + assert (r->ncname () == c->ncname ()); + assert (r->language () == c->language ()); + + // qualified name + // + assert (r->qname () == c->qname ()); + + // ID/IDREF + // + assert (r->id () == c->id ()); + assert (r->id_ref () == c->id_ref ()); + assert (r->id_refs () == c->id_refs ()); + + // URI + // + assert (r->any_uri () == c->any_uri ()); + + // binary + // + assert (r->base64_binary () == c->base64_binary ()); + assert (r->hex_binary () == c->hex_binary ()); + + // date/time + // + assert (r->date () == c->date ()); + assert (r->date_time () == c->date_time ()); + assert (r->duration () == c->duration ()); + assert (r->day () == c->day ()); + assert (r->month () == c->month ()); + assert (r->month_day () == c->month_day ()); + assert (r->year () == c->year ()); + assert (r->year_month () == c->year_month ()); + assert (r->time () == c->time ()); + + // anySimpleType + // + assert (!r->any_simple_type_attr ().text_content ().empty ()); + assert (r->any_simple_type_attr () == c->any_simple_type_attr ()); + + assert (!r->any_simple_type ().text_content ().empty ()); + assert (r->any_simple_type () == c->any_simple_type ()); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/binary/xdr-ordered/test.xml b/xsd-tests/cxx/tree/binary/xdr-ordered/test.xml new file mode 100644 index 0000000..5cedd98 --- /dev/null +++ b/xsd-tests/cxx/tree/binary/xdr-ordered/test.xml @@ -0,0 +1,93 @@ + + + 1 2 3 + + abc + + left + + + aaa + + + aaa + bbb + c + cc + ccc + + + + + 65 + 66 + -222 + 57005 + -57005 + 3735928559 + -3735928559 + 16045690984833335023 + -3735928559 + -3735928559 + 3735928559 + 3735928559 + -3735928559 + + + + true + + + + 1234.1234 + 12345678.12345678 + 1234567812345678.1234567812345678 + + + + string + normalized string + one two three + name + name-token + name tokens + ncname + en-us + + + xsi:schemaLocation + + + + elements1 + elements2 + elements1 + elements1 elements2 + + + + http://www.codesynthesis.com + + + + YmFzZTY0IGJpbmFyeQ== + 6865782052696E617279 + + + + 2001-10-26+02:00 + 2001-10-26T21:32:52+02:00 + P1Y2M3DT5H20M30S + ---01+02:00 + --11+02:00 + --11-02+02:00 + 2001+02:00 + 2001-11+02:00 + + + any simple content in element + + diff --git a/xsd-tests/cxx/tree/binary/xdr-ordered/test.xsd b/xsd-tests/cxx/tree/binary/xdr-ordered/test.xsd new file mode 100644 index 0000000..0629e94 --- /dev/null +++ b/xsd-tests/cxx/tree/binary/xdr-ordered/test.xsd @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/binary/xdr/buildfile b/xsd-tests/cxx/tree/binary/xdr/buildfile new file mode 100644 index 0000000..b8fc2f4 --- /dev/null +++ b/xsd-tests/cxx/tree/binary/xdr/buildfile @@ -0,0 +1,27 @@ +# file : cxx/tree/binary/xdr/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +if ($cxx.target.class == 'linux') + import libs += libtirpc%lib{tirpc} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-insertion 'XDR' \ + --generate-extraction 'XDR' \ + --generate-comparison \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/binary/xdr/driver.cxx b/xsd-tests/cxx/tree/binary/xdr/driver.cxx new file mode 100644 index 0000000..04606ea --- /dev/null +++ b/xsd-tests/cxx/tree/binary/xdr/driver.cxx @@ -0,0 +1,204 @@ +// file : tests/cxx/tree/binary/xdr/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test non-polymorphic binary serialization to XDR. +// + +#include // std::auto_ptr/unique_ptr +#include // std::memcpy +#include +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +extern "C" int +overflow (void* p, char* buf, int in) +{ + xml_schema::buffer* dst (reinterpret_cast (p)); + + size_t n (static_cast (in)), size (dst->size ()); + dst->size (size + n); + memcpy (dst->data () + size, buf, n); + + return static_cast (n); +} + +struct underflow_info +{ + xml_schema::buffer* buf; + std::size_t pos; +}; + +extern "C" int +underflow (void* p, char* buf, int in) +{ + underflow_info* ui (reinterpret_cast (p)); + + size_t n (static_cast (in)), size (ui->buf->size () - ui->pos); + n = size > n ? n : size; + + memcpy (buf, ui->buf->data () + ui->pos, n); + ui->pos += n; + + return static_cast (n); +} + +// The xdrrec_create function (used below) has slightly different +// prototypes on different platforms. To make this test 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] << " test.xml" << endl; + return 1; + } + + try + { + XSD_AUTO_PTR r (root (argv[1])); + + xdrrec_create_p xdrrec_create_ = + reinterpret_cast (::xdrrec_create); + + // 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; + xsd::cxx::tree::ostream oxdr (xdr); + oxdr << *r; + xdrrec_endofrecord (&xdr, true); // flush the data + xdr_destroy (&xdr); + + // 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); + xsd::cxx::tree::istream ixdr (xdr); + XSD_AUTO_PTR c (new type (ixdr)); + xdr_destroy (&xdr); + + // Compare the two. + // + assert (r->list () == c->list ()); + assert (r->union_ () == c->union_ ()); + assert (r->enumeration () == c->enumeration ()); + + type::complex_sequence rs (r->complex ()), cs (c->complex ()); + + for (type::complex_iterator ri (rs.begin ()), ci (cs.begin ()); + ri != rs.end () && ci != rs.end (); ++ri, ++ci) + { + assert (ri->a () == ci->a ()); + if (ri->b ()) + assert (ri->b () == ci->b ()); + assert (ri->c () == ci->c ()); + + assert (ri->x () == ci->x ()); + if (ri->y ()) + assert (ri->y () == ci->y ()); + } + + // integers + // + assert (r->byte () == c->byte ()); + assert (r->unsigned_byte () == c->unsigned_byte ()); + assert (r->short_ () == c->short_ ()); + assert (r->unsigned_short () == c->unsigned_short ()); + assert (r->int_ () == c->int_ ()); + assert (r->unsigned_int () == c->unsigned_int ()); + assert (r->long_ () == c->long_ ()); + assert (r->unsigned_long () == c->unsigned_long ()); + assert (r->integer () == c->integer ()); + assert (r->non_positive_integer () == c->non_positive_integer ()); + assert (r->non_negative_integer () == c->non_negative_integer ()); + assert (r->positive_integer () == c->positive_integer ()); + assert (r->negative_integer () == c->negative_integer ()); + + // boolean + // + assert (r->boolean () == c->boolean ()); + + // floats + // + assert (r->float_ () == c->float_ ()); + assert (r->double_ () == c->double_ ()); + assert (r->decimal () == c->decimal ()); + + // strings + // + assert (r->string () == c->string ()); + assert (r->normalized_string () == c->normalized_string ()); + assert (r->token () == c->token ()); + assert (r->name () == c->name ()); + assert (r->name_token () == c->name_token ()); + assert (r->name_tokens () == c->name_tokens ()); + assert (r->ncname () == c->ncname ()); + assert (r->language () == c->language ()); + + // qualified name + // + assert (r->qname () == c->qname ()); + + // ID/IDREF + // + assert (r->id () == c->id ()); + assert (r->id_ref () == c->id_ref ()); + assert (r->id_refs () == c->id_refs ()); + + // URI + // + assert (r->any_uri () == c->any_uri ()); + + // binary + // + assert (r->base64_binary () == c->base64_binary ()); + assert (r->hex_binary () == c->hex_binary ()); + + // date/time + // + assert (r->date () == c->date ()); + assert (r->date_time () == c->date_time ()); + assert (r->duration () == c->duration ()); + assert (r->day () == c->day ()); + assert (r->month () == c->month ()); + assert (r->month_day () == c->month_day ()); + assert (r->year () == c->year ()); + assert (r->year_month () == c->year_month ()); + assert (r->time () == c->time ()); + + // anySimpleType + // + assert (!r->any_simple_type_attr ().text_content ().empty ()); + assert (r->any_simple_type_attr () == c->any_simple_type_attr ()); + + assert (!r->any_simple_type ().text_content ().empty ()); + assert (r->any_simple_type () == c->any_simple_type ()); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/binary/xdr/test.xml b/xsd-tests/cxx/tree/binary/xdr/test.xml new file mode 100644 index 0000000..5cedd98 --- /dev/null +++ b/xsd-tests/cxx/tree/binary/xdr/test.xml @@ -0,0 +1,93 @@ + + + 1 2 3 + + abc + + left + + + aaa + + + aaa + bbb + c + cc + ccc + + + + + 65 + 66 + -222 + 57005 + -57005 + 3735928559 + -3735928559 + 16045690984833335023 + -3735928559 + -3735928559 + 3735928559 + 3735928559 + -3735928559 + + + + true + + + + 1234.1234 + 12345678.12345678 + 1234567812345678.1234567812345678 + + + + string + normalized string + one two three + name + name-token + name tokens + ncname + en-us + + + xsi:schemaLocation + + + + elements1 + elements2 + elements1 + elements1 elements2 + + + + http://www.codesynthesis.com + + + + YmFzZTY0IGJpbmFyeQ== + 6865782052696E617279 + + + + 2001-10-26+02:00 + 2001-10-26T21:32:52+02:00 + P1Y2M3DT5H20M30S + ---01+02:00 + --11+02:00 + --11-02+02:00 + 2001+02:00 + 2001-11+02:00 + + + any simple content in element + + diff --git a/xsd-tests/cxx/tree/binary/xdr/test.xsd b/xsd-tests/cxx/tree/binary/xdr/test.xsd new file mode 100644 index 0000000..0629e94 --- /dev/null +++ b/xsd-tests/cxx/tree/binary/xdr/test.xsd @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/buildfile b/xsd-tests/cxx/tree/buildfile new file mode 100644 index 0000000..cfaf0bd --- /dev/null +++ b/xsd-tests/cxx/tree/buildfile @@ -0,0 +1,6 @@ +# file : cxx/tree/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Exclude tests which depend on not yet packaged libraries. +# +./: {*/ -binary/} diff --git a/xsd-tests/cxx/tree/built-in/.gitignore b/xsd-tests/cxx/tree/built-in/.gitignore new file mode 100644 index 0000000..f86b7a2 --- /dev/null +++ b/xsd-tests/cxx/tree/built-in/.gitignore @@ -0,0 +1 @@ +types.?xx diff --git a/xsd-tests/cxx/tree/built-in/buildfile b/xsd-tests/cxx/tree/built-in/buildfile new file mode 100644 index 0000000..8ee8585 --- /dev/null +++ b/xsd-tests/cxx/tree/built-in/buildfile @@ -0,0 +1,25 @@ +# file : cxx/tree/build-in/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -types} {hxx ixx cxx}{types} $libs testscript + +<{hxx ixx cxx}{types}>: xsd{types} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-ostream \ + --generate-serialization \ + --char-type char \ + --generate-default-ctor \ + --generate-from-base-ctor \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/built-in/driver.cxx b/xsd-tests/cxx/tree/built-in/driver.cxx new file mode 100644 index 0000000..4141290 --- /dev/null +++ b/xsd-tests/cxx/tree/built-in/driver.cxx @@ -0,0 +1,93 @@ +// file : cxx/tree/built-in/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test built-in type mapping. +// + +#include // std::auto_ptr/unique_ptr +#include +#include + + +#include "types.hxx" + +using std::cerr; +using std::endl; + +int +main (int argc, char* argv[]) +{ + if (argc != 4) + { + cerr << "usage: " << argv[0] << " elements.xml attributes.xml inherited.xml" << endl; + return 1; + } + + XSD_AUTO_PTR elements ( + xmlns::test::elements (argv[1])); + + XSD_AUTO_PTR attributes ( + xmlns::test::attributes (argv[2])); + + XSD_AUTO_PTR inherited ( + xmlns::test::inherited (argv[3])); + + cerr << "elements:" << *elements << endl + << endl + << "attributes:" << *attributes << endl + << endl + << "inherited:" << *inherited << endl; + + // Test parsing/serialization. + // + + xml_schema::namespace_infomap map; + + map["test"].name = "http://www.codesynthesis.com/xmlns/test"; + map["test"].schema = "types.xsd"; + + { + std::ostringstream ostr; + xmlns::test::elements (ostr, *elements, map); + + std::istringstream istr (ostr.str ()); + XSD_AUTO_PTR elements1 ( + xmlns::test::elements (istr)); + + std::ostringstream ostr1; + xmlns::test::elements (ostr1, *elements1, map); + + if (ostr.str () != ostr1.str ()) + return 1; + } + + { + std::ostringstream ostr; + xmlns::test::attributes (ostr, *attributes, map); + + std::istringstream istr (ostr.str ()); + XSD_AUTO_PTR attributes1 ( + xmlns::test::attributes (istr)); + + std::ostringstream ostr1; + xmlns::test::attributes (ostr1, *attributes1, map); + + if (ostr.str () != ostr1.str ()) + return 1; + } + + { + std::ostringstream ostr; + xmlns::test::inherited (ostr, *inherited, map); + + std::istringstream istr (ostr.str ()); + XSD_AUTO_PTR inherited1 ( + xmlns::test::inherited (istr)); + + std::ostringstream ostr1; + xmlns::test::inherited (ostr1, *inherited1, map); + + if (ostr.str () != ostr1.str ()) + return 1; + } +} diff --git a/xsd-tests/cxx/tree/built-in/testscript b/xsd-tests/cxx/tree/built-in/testscript new file mode 100644 index 0000000..4dae039 --- /dev/null +++ b/xsd-tests/cxx/tree/built-in/testscript @@ -0,0 +1,394 @@ +# file : cxx/tree/any-type/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +: types +: +{ + cat <=elements.xml; + + + + + 65 + 66 + -222 + 57005 + -57005 + 3735928559 + -3735928559 + 16045690984833335023 + -3735928559 + -3735928559 + 3735928559 + 3735928559 + -3735928559 + + + + true + + + + 1234.1234 + 12345678.12345678 + 12345678.12345678 + + + + string + normalized + string + + one + two three + name + name-token + name tokens + ncname + en-us + + + xsi:schemaLocation + + + + elements1 + elements2 + elements1 + elements1 elements2 + + + + http://www.codesynthesis.com + + + + YmFzZTY0IGJpbmFyeQ== + 6865782052696E617279 + + + + 2001-10-26+02:00 + 2001-10-26T21:32:52+02:00 + P1Y2M3DT5H20M30S + ---01+02:00 + --11+02:00 + --11-02+02:00 + 2001+02:00 + 2001-11+02:00 + + + + + + + + EOI + + cat <=attributes.xml; + + + EOI + + cat <=inherited.xml; + + + + + 65 + 66 + -222 + 57005 + -57005 + 3735928559 + -3735928559 + 16045690984833335023 + -3735928559 + -3735928559 + 3735928559 + 3735928559 + -3735928559 + + + + true + + + + 1234.1234 + 12345678.12345678 + 12345678.12345678 + + + + string + normalized + string + + one + two three + name + name-token + name tokens + ncname + en-us + + + xsi:schemaLocation + + + + elements1 + elements2 + elements1 + elements1 elements2 + + + + http://www.codesynthesis.com + + + + YmFzZTY0IGJpbmFyeQ== + 6865782052696E617279 + + + + 2001-10-26+02:00 + 2001-10-26T21:32:52+02:00 + P1Y2M3DT5H20M30S + ---01+02:00 + --11+02:00 + --11-02+02:00 + 2001+02:00 + 2001-11+02:00 + + + + + + + + EOI + + ln -s $src_base/types.xsd ./; + + $* elements.xml attributes.xml inherited.xml 2>>EOE + elements: + byte: A + unsigned_byte: B + short: -222 + unsigned_short: 57005 + int: -57005 + unsigned_int: 3735928559 + long: -3735928559 + unsigned_long: 16045690984833335023 + integer: -3735928559 + non_positive_integer: -3735928559 + non_negative_integer: 3735928559 + positive_integer: 3735928559 + negative_integer: -3735928559 + boolean: 1 + float: 1234.12 + double: 1.23457e+07 + decimal: 1.23457e+07 + string: string + normalized_string: normalized string + token: one two three + name: name + name_token: name-token + name_tokens: name tokens + ncname: ncname + language: en-us + qname: http://www.w3.org/2001/XMLSchema-instance#schemaLocation + id: elements1 + id: elements2 + id_ref: elements1 + id_refs: elements1 elements2 + any_uri: http://www.codesynthesis.com + base64_binary: YmFzZTY0IGJpbmFyeQ== + + hex_binary: 6865782052696E617279 + date: 2001-10-26+02:00 + date_time: 2001-10-26T21:32:52.000000+02:00 + duration: P1Y2M3DT5H20M30.000000S + day: 01+02:00 + month: 11+02:00 + month_day: 11-02+02:00 + year: 2001+02:00 + year_month: 2001-11+02:00 + time: 21:32:52.000000+02:00 + + attributes: + byte: A + unsigned_byte: B + short: -222 + unsigned_short: 57005 + int: -57005 + unsigned_int: 3735928559 + long: -3735928559 + unsigned_long: 16045690984833335023 + integer: -3735928559 + non_positive_integer: -3735928559 + non_negative_integer: 3735928559 + positive_integer: 3735928559 + negative_integer: -3735928559 + boolean: 0 + float: 1234.12 + double: 1.23457e+07 + decimal: 1.23457e+07 + string: string + normalized_string: normalized string + token: one two three + name: name + name_token: name-token + name_tokens: name tokens + ncname: ncname + language: en-us + qname: http://www.w3.org/2001/XMLSchema-instance#schemaLocation + id: attributes + id_ref: attributes + id_refs: attributes + any_uri: http://www.codesynthesis.com + base64_binary: YmFzZTY0IGJpbmFyeQ== + + hex_binary: 6865782052696E617279 + date: 2001-10-26+02:00 + date_time: 2001-10-26T21:32:52.000000+02:00 + duration: P1Y2M3DT5H20M30.000000S + day: 01+02:00 + month: 11+02:00 + month_day: 11-02+02:00 + year: 2001+02:00 + year_month: 2001-11+02:00 + time: 21:32:52.000000+02:00 + + inherited: + byte: A + unsigned_byte: B + short: -222 + unsigned_short: 57005 + int: -57005 + unsigned_int: 3735928559 + long: -3735928559 + unsigned_long: 16045690984833335023 + integer: -3735928559 + non_positive_integer: -3735928559 + non_negative_integer: 3735928559 + positive_integer: 3735928559 + negative_integer: -3735928559 + boolean: 1 + float: 1234.12 + double: 1.23457e+07 + decimal: 1.23457e+07 + string: string + normalized_string: normalized string + token: one two three + name: name + name_token: name-token + name_tokens: name tokens + ncname: ncname + language: en-us + qname: http://www.w3.org/2001/XMLSchema-instance#schemaLocation + id: elements1 + id: elements2 + id_ref: elements1 + id_refs: elements1 elements2 + any_uri: http://www.codesynthesis.com + base64_binary: YmFzZTY0IGJpbmFyeQ== + + hex_binary: 6865782052696E617279 + date: 2001-10-26+02:00 + date_time: 2001-10-26T21:32:52.000000+02:00 + duration: P1Y2M3DT5H20M30.000000S + day: 01+02:00 + month: 11+02:00 + month_day: 11-02+02:00 + year: 2001+02:00 + year_month: 2001-11+02:00 + time: 21:32:52.000000+02:00 + EOE +} diff --git a/xsd-tests/cxx/tree/built-in/types.xsd b/xsd-tests/cxx/tree/built-in/types.xsd new file mode 100644 index 0000000..22582cb --- /dev/null +++ b/xsd-tests/cxx/tree/built-in/types.xsd @@ -0,0 +1,460 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/chameleon/.gitignore b/xsd-tests/cxx/tree/chameleon/.gitignore new file mode 100644 index 0000000..4ec7484 --- /dev/null +++ b/xsd-tests/cxx/tree/chameleon/.gitignore @@ -0,0 +1 @@ +includer.?xx diff --git a/xsd-tests/cxx/tree/chameleon/buildfile b/xsd-tests/cxx/tree/chameleon/buildfile new file mode 100644 index 0000000..cec3b01 --- /dev/null +++ b/xsd-tests/cxx/tree/chameleon/buildfile @@ -0,0 +1,24 @@ +# file : cxx/tree/chameleon/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -includer} {hxx ixx cxx}{includer} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{includer}>: xsd{includer includee} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-ostream \ + --root-element root \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/chameleon/driver.cxx b/xsd-tests/cxx/tree/chameleon/driver.cxx new file mode 100644 index 0000000..c22ca55 --- /dev/null +++ b/xsd-tests/cxx/tree/chameleon/driver.cxx @@ -0,0 +1,35 @@ +// file : cxx/tree/chameleon/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test chameleon inclusion. +// + +#include // std::auto_ptr/unique_ptr +#include + +#include "includer.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + XSD_AUTO_PTR r (root (argv[1])); + + cout << *r << endl; + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/chameleon/includee.xsd b/xsd-tests/cxx/tree/chameleon/includee.xsd new file mode 100644 index 0000000..531a7d0 --- /dev/null +++ b/xsd-tests/cxx/tree/chameleon/includee.xsd @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/chameleon/includer.xsd b/xsd-tests/cxx/tree/chameleon/includer.xsd new file mode 100644 index 0000000..a1c850a --- /dev/null +++ b/xsd-tests/cxx/tree/chameleon/includer.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/chameleon/output b/xsd-tests/cxx/tree/chameleon/output new file mode 100644 index 0000000..c40f715 --- /dev/null +++ b/xsd-tests/cxx/tree/chameleon/output @@ -0,0 +1,3 @@ + +a: a +b: b diff --git a/xsd-tests/cxx/tree/chameleon/test.xml b/xsd-tests/cxx/tree/chameleon/test.xml new file mode 100644 index 0000000..12ff279 --- /dev/null +++ b/xsd-tests/cxx/tree/chameleon/test.xml @@ -0,0 +1,8 @@ + + + a + b + + diff --git a/xsd-tests/cxx/tree/comparison/buildfile b/xsd-tests/cxx/tree/comparison/buildfile new file mode 100644 index 0000000..507a703 --- /dev/null +++ b/xsd-tests/cxx/tree/comparison/buildfile @@ -0,0 +1,22 @@ +# file : cxx/tree/comparison/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-comparison \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/comparison/driver.cxx b/xsd-tests/cxx/tree/comparison/driver.cxx new file mode 100644 index 0000000..aa7b66d --- /dev/null +++ b/xsd-tests/cxx/tree/comparison/driver.cxx @@ -0,0 +1,38 @@ +// file : cxx/tree/comparison/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test generated comparison operators. +// + +#include // std::auto_ptr/unique_ptr +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + XSD_AUTO_PTR r (root (argv[1])); + + type::complex_sequence s (r->complex ()); + + assert (s[0] == s[0]); + assert (s[0] != s[1]); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/comparison/test.xml b/xsd-tests/cxx/tree/comparison/test.xml new file mode 100644 index 0000000..b5d8158 --- /dev/null +++ b/xsd-tests/cxx/tree/comparison/test.xml @@ -0,0 +1,19 @@ + + + + 123 + abc + abc + def + + + + 123 + abc + abc + xyz + + + diff --git a/xsd-tests/cxx/tree/comparison/test.xsd b/xsd-tests/cxx/tree/comparison/test.xsd new file mode 100644 index 0000000..c234add --- /dev/null +++ b/xsd-tests/cxx/tree/comparison/test.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/compilation/buildfile b/xsd-tests/cxx/tree/compilation/buildfile new file mode 100644 index 0000000..bec2b4b --- /dev/null +++ b/xsd-tests/cxx/tree/compilation/buildfile @@ -0,0 +1,20 @@ +# file : cxx/tree/compilation/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/compilation/driver.cxx b/xsd-tests/cxx/tree/compilation/driver.cxx new file mode 100644 index 0000000..5c5ab39 --- /dev/null +++ b/xsd-tests/cxx/tree/compilation/driver.cxx @@ -0,0 +1,116 @@ +// file : cxx/tree/compilation/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Make sure the runtime library compiles by explicitly instantiating +// all the types. +// + +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +template class xsd::cxx::tree::simple_type; + +// String types. +// +template class xsd::cxx::tree::string< char, xml_schema::simple_type >; +template class xsd::cxx::tree::normalized_string< char, xml_schema::string >; +template class xsd::cxx::tree::token< char, xml_schema::normalized_string >; +template class xsd::cxx::tree::name< char, xml_schema::token >; +template class xsd::cxx::tree::nmtoken< char, xml_schema::token >; +template class xsd::cxx::tree::nmtokens< char, xml_schema::simple_type, xml_schema::nmtoken >; +template class xsd::cxx::tree::ncname< char, xml_schema::name >; +template class xsd::cxx::tree::language< char, xml_schema::token >; + +// ID/IDREF. +// +template class xsd::cxx::tree::id< char, xml_schema::ncname >; +template class xsd::cxx::tree::idref< char, xml_schema::ncname, xml_schema::type >; +template class xsd::cxx::tree::idrefs< char, xml_schema::simple_type, xml_schema::idref >; + +// URI. +// +template class xsd::cxx::tree::uri< char, xml_schema::simple_type >; + +// Qualified name. +// +template class xsd::cxx::tree::qname< char, xml_schema::simple_type, xml_schema::uri, xml_schema::ncname >; + +// Binary. +// +template class xsd::cxx::tree::buffer< char >; +template class xsd::cxx::tree::base64_binary< char, xml_schema::simple_type >; +template class xsd::cxx::tree::hex_binary< char, xml_schema::simple_type >; + +// Date/time. +// +template class xsd::cxx::tree::date< char, xml_schema::simple_type >; +template class xsd::cxx::tree::date_time< char, xml_schema::simple_type >; +template class xsd::cxx::tree::duration< char, xml_schema::simple_type >; +template class xsd::cxx::tree::gday< char, xml_schema::simple_type >; +template class xsd::cxx::tree::gmonth< char, xml_schema::simple_type >; +template class xsd::cxx::tree::gmonth_day< char, xml_schema::simple_type >; +template class xsd::cxx::tree::gyear< char, xml_schema::simple_type >; +template class xsd::cxx::tree::gyear_month< char, xml_schema::simple_type >; +template class xsd::cxx::tree::time< char, xml_schema::simple_type >; + +// Entity. +// +template class xsd::cxx::tree::entity< char, xml_schema::ncname >; +template class xsd::cxx::tree::entities< char, xml_schema::simple_type, xml_schema::entity >; + +// Namespace information and list stream. Used in +// serialization functions. +// +template class xsd::cxx::xml::dom::namespace_info < char >; +template class xsd::cxx::xml::dom::namespace_infomap < char >; +template class xsd::cxx::tree::list_stream < char >; + +// Flags and properties. +// +template class xsd::cxx::tree::properties< char >; + +// Exceptions. +// +template class xsd::cxx::tree::exception< char >; +template class xsd::cxx::tree::parsing< char >; +template class xsd::cxx::tree::expected_element< char >; +template class xsd::cxx::tree::unexpected_element< char >; +template class xsd::cxx::tree::expected_attribute< char >; +template class xsd::cxx::tree::unexpected_enumerator< char >; +template class xsd::cxx::tree::expected_text_content< char >; +template class xsd::cxx::tree::no_type_info< char >; +template class xsd::cxx::tree::not_derived< char >; +template class xsd::cxx::tree::duplicate_id< char >; +template class xsd::cxx::tree::serialization< char >; +template class xsd::cxx::tree::no_prefix_mapping< char >; +template class xsd::cxx::tree::bounds< char >; + +// Parsing/serialization diagnostics. +// +template class xsd::cxx::tree::error< char >; +template class xsd::cxx::tree::diagnostics< char >; + +// Error handler interface. +// +template class xsd::cxx::xml::error_handler< char >; + + +// +// +template class xsd::cxx::tree::fundamental_base; +template class xsd::cxx::tree::one; +template class xsd::cxx::tree::one; +template class xsd::cxx::tree::optional; +template class xsd::cxx::tree::optional; +template class xsd::cxx::tree::sequence; +template class xsd::cxx::tree::sequence; + + +int +main () +{ +} diff --git a/xsd-tests/cxx/tree/compilation/test.xsd b/xsd-tests/cxx/tree/compilation/test.xsd new file mode 100644 index 0000000..07bebc7 --- /dev/null +++ b/xsd-tests/cxx/tree/compilation/test.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/complex/ctor/buildfile b/xsd-tests/cxx/tree/complex/ctor/buildfile new file mode 100644 index 0000000..53e32b7 --- /dev/null +++ b/xsd-tests/cxx/tree/complex/ctor/buildfile @@ -0,0 +1,25 @@ +# file : cxx/tree/complex/ctor/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-default-ctor \ + --generate-from-base-ctor \ + --generate-doxygen \ + --generate-polymorphic \ + --polymorphic-type-all \ + --generate-comparison \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/complex/ctor/driver.cxx b/xsd-tests/cxx/tree/complex/ctor/driver.cxx new file mode 100644 index 0000000..7beaa93 --- /dev/null +++ b/xsd-tests/cxx/tree/complex/ctor/driver.cxx @@ -0,0 +1,122 @@ +// file : cxx/tree/complex/ctor/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test generation of varous complex type constructors. +// + +#include +#include + +#include "test.hxx" + +#ifdef XSD_CXX11 +# include // std::move +# define XSD_MOVE(x) std::move(x) +#else +# define XSD_MOVE(x) x +#endif + +using namespace std; +using namespace test; + +int +main () +{ + // Test case A. + // + { + a_base b1; + a_base b2 ("abc"); // empty ultimate base + required + a_base b3 ("abc", "foo"); // ultimate base + required + + a_derived a1; + a_derived a2 ("foo", "bar"); // empty ultimate base + required + a_derived a3 (b3, "bar"); // base + required + a_derived a4 ("abc", "foo", "bar"); // ultimate base + required + } + + // Test case B. + // + { + b_simple s ("base"); + b_base b ("base", "foo"); + b_derived d ("base", "foo", "bar"); + b_type t ("base"); + } + + // Test case C. + // + { + c_simple s (c_enum::a); + c_base b (c_enum::a, "foo"); + c_derived d (c_enum::a, "foo", "bar"); + c_type t (c_enum::a); + } + + // Test case D. + // + { + d_simple s (1); + d_base b (1, "foo"); + d_derived d (1, "foo", "bar"); + d_type t (1); + } + + // Test case E. + // + { + // e_base + // + e_base b1 (1, "foo", e_complex_type ("bar")); + + XSD_AUTO_PTR c2 (new e_complex_type ("bar")); + e_base b2 (1, "foo", XSD_MOVE (c2)); + + XSD_AUTO_PTR s3 (new e_simple_type ("foo")); + XSD_AUTO_PTR c3 (new e_complex_type ("bar")); + e_base b3 (1, XSD_MOVE (s3), XSD_MOVE (c3)); + + assert (b1 == b2); + assert (b1 == b3); + + // e_derived + // + e_derived d1 (1, "foo", e_complex_type ("bar"), + true, "baz", e_complex_type ("biz")); + + XSD_AUTO_PTR c2a (new e_complex_type ("bar")); + XSD_AUTO_PTR c2b (new e_complex_type ("biz")); + e_derived d2 (1, "foo", XSD_MOVE (c2a), true, "baz", XSD_MOVE (c2b)); + + XSD_AUTO_PTR s3a (new e_simple_type ("foo")); + XSD_AUTO_PTR s3b (new xml_schema::string ("baz")); + XSD_AUTO_PTR c3a (new e_complex_type ("bar")); + XSD_AUTO_PTR c3b (new e_complex_type ("biz")); + e_derived d3 (1, + XSD_MOVE (s3a), + XSD_MOVE (c3a), + true, + XSD_MOVE (s3b), + XSD_MOVE (c3b)); + + assert (d1 == d2); + assert (d1 == d3); + + } + + // Test case F. + // + { + f_type f1 (xml_schema::type (), 1, "foo", f_complex_type ("bar")); + + XSD_AUTO_PTR c2 (new f_complex_type ("bar")); + f_type f2 (1, "foo", XSD_MOVE (c2)); + + XSD_AUTO_PTR s3 (new f_simple_type ("foo")); + XSD_AUTO_PTR c3 (new f_complex_type ("bar")); + f_type f3 (1, XSD_MOVE (s3), XSD_MOVE (c3)); + + assert (f1 == f2); + assert (f1 == f3); + } +} diff --git a/xsd-tests/cxx/tree/complex/ctor/test.xsd b/xsd-tests/cxx/tree/complex/ctor/test.xsd new file mode 100644 index 0000000..b8dd95e --- /dev/null +++ b/xsd-tests/cxx/tree/complex/ctor/test.xsd @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/containment/buildfile b/xsd-tests/cxx/tree/containment/buildfile new file mode 100644 index 0000000..1d0272b --- /dev/null +++ b/xsd-tests/cxx/tree/containment/buildfile @@ -0,0 +1,20 @@ +# file : cxx/tree/containment/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-default-ctor \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/containment/driver.cxx b/xsd-tests/cxx/tree/containment/driver.cxx new file mode 100644 index 0000000..65c17fc --- /dev/null +++ b/xsd-tests/cxx/tree/containment/driver.cxx @@ -0,0 +1,118 @@ +// file : cxx/tree/containment/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test tree node containment. +// + +#include // std::auto_ptr/unique_ptr +#include + +#include "test.hxx" + +#ifdef XSD_CXX11 +# include // std::move +# define XSD_MOVE(x) std::move(x) +#else +# define XSD_MOVE(x) x +#endif + +using namespace std; +using namespace test; + +int +main () +{ + // Change of a container in a sub-tree without ID. + // + { + XSD_AUTO_PTR i (new inner ()); + i->ref ("foo"); + + outer o; + o.i (XSD_MOVE (i)); + o.ref ("foo"); + + assert (o.i ()->ref ()->get () == 0); + assert (o.ref ()->get () == 0); + } + + // Change of container in a sub-tree with ID inside. + // + { + XSD_AUTO_PTR i (new inner ()); + inner* p (i.get ()); + i->id ("foo"); + i->ref ("foo"); + assert (i->ref ()->get () == p); + + outer o; + o.i (XSD_MOVE (i)); + o.ref ("foo"); + + assert (o.i ()->ref ()->get () == p); + assert (o.ref ()->get () == p); + } + + // Change of a container in ID. + // + { + XSD_AUTO_PTR id (new xml_schema::id ("foo")); + + inner i; + i.id (XSD_MOVE (id)); + i.ref ("foo"); + assert (i.ref ()->get () == &i); + } + + // Change of a container in a type derived from ID with ID inside. + // + { + XSD_AUTO_PTR id (new id_ex ("foo")); + id_ex* p (id.get ()); + id->id ("bar"); + + inner i; + i.id_ex (XSD_MOVE (id)); + + i.ref ("foo"); + assert (i.ref ()->get () == &i); + + i.ref ("bar"); + assert (i.ref ()->get () == p); + } + + // IDREF lists + // + { + id i1 ("a"), i2 ("b"); + + XSD_AUTO_PTR ic (new ids); + ic->id ().push_back (i1); + ic->id ().push_back (i2); + + XSD_AUTO_PTR r1 (new xml_schema::idrefs); + r1->push_back (xml_schema::idref ("a")); + r1->push_back (xml_schema::idref ("b")); + + XSD_AUTO_PTR r2 (new idref_list); + r2->push_back (xml_schema::idref ("a")); + r2->push_back (xml_schema::idref ("b")); + + XSD_AUTO_PTR rc1 (new idrefs1); + XSD_AUTO_PTR rc2 (new idrefs2); + + rc1->idrefs (XSD_MOVE (r1)); + rc2->idrefs (XSD_MOVE (r2)); + + model m; + m.ids (XSD_MOVE (ic)); + m.idrefs1 (XSD_MOVE (rc1)); + m.idrefs2 (XSD_MOVE (rc2)); + + assert (m.idrefs1 ().idrefs ()[0].get () != 0); + assert (m.idrefs1 ().idrefs ()[1].get () != 0); + + assert (m.idrefs2 ().idrefs ()[0].get () != 0); + assert (m.idrefs2 ().idrefs ()[1].get () != 0); + } +} diff --git a/xsd-tests/cxx/tree/containment/test.xsd b/xsd-tests/cxx/tree/containment/test.xsd new file mode 100644 index 0000000..72c9379 --- /dev/null +++ b/xsd-tests/cxx/tree/containment/test.xsd @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/default/general/buildfile b/xsd-tests/cxx/tree/default/general/buildfile new file mode 100644 index 0000000..4e482ce --- /dev/null +++ b/xsd-tests/cxx/tree/default/general/buildfile @@ -0,0 +1,26 @@ +# file : cxx/tree/default/general/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --generate-ostream \ + --generate-default-ctor \ + --generate-from-base-ctor \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/default/general/driver.cxx b/xsd-tests/cxx/tree/default/general/driver.cxx new file mode 100644 index 0000000..7031636 --- /dev/null +++ b/xsd-tests/cxx/tree/default/general/driver.cxx @@ -0,0 +1,37 @@ +// file : cxx/tree/default/general/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test default attribute/element values. +// + +#include // std::auto_ptr/unique_ptr +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + XSD_AUTO_PTR r (root (argv[1], xml_schema::flags::dont_validate)); + + xml_schema::namespace_infomap map; + map["t"].name = "test"; + root (cout, *r, map); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/default/general/output b/xsd-tests/cxx/tree/default/general/output new file mode 100644 index 0000000..396a698 --- /dev/null +++ b/xsd-tests/cxx/tree/default/general/output @@ -0,0 +1,15 @@ + + + + + + + diff --git a/xsd-tests/cxx/tree/default/general/test.xml b/xsd-tests/cxx/tree/default/general/test.xml new file mode 100644 index 0000000..11bd0a7 --- /dev/null +++ b/xsd-tests/cxx/tree/default/general/test.xml @@ -0,0 +1,16 @@ + + + + + + + diff --git a/xsd-tests/cxx/tree/default/general/test.xsd b/xsd-tests/cxx/tree/default/general/test.xsd new file mode 100644 index 0000000..9d9cd38 --- /dev/null +++ b/xsd-tests/cxx/tree/default/general/test.xsd @@ -0,0 +1,241 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/default/omit/buildfile b/xsd-tests/cxx/tree/default/omit/buildfile new file mode 100644 index 0000000..407ab1e --- /dev/null +++ b/xsd-tests/cxx/tree/default/omit/buildfile @@ -0,0 +1,27 @@ +# file : cxx/tree/default/omit/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --generate-ostream \ + --generate-default-ctor \ + --generate-from-base-ctor \ + --omit-default-attributes \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/default/omit/driver.cxx b/xsd-tests/cxx/tree/default/omit/driver.cxx new file mode 100644 index 0000000..3dcc0d8 --- /dev/null +++ b/xsd-tests/cxx/tree/default/omit/driver.cxx @@ -0,0 +1,46 @@ +// file : cxx/tree/default/omit/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test default attribute omission from the output. +// + +#include // std::auto_ptr/unique_ptr +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + XSD_AUTO_PTR r (root (argv[1], xml_schema::flags::dont_validate)); + + cout << *r << endl + << "default x: " << derived::x_default_value () << endl + << "default y: " << derived::y_default_value () << endl + << "fixed p: " << derived::p_default_value () << endl + << "fixed q1: " << derived::q1_default_value () << endl + << "fixed q2: " << derived::q2_default_value () << endl; + + // Serialize. + // + xml_schema::namespace_infomap map; + map["t"].name = "test"; + root (cout, *r, map); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/default/omit/output b/xsd-tests/cxx/tree/default/omit/output new file mode 100644 index 0000000..150ad58 --- /dev/null +++ b/xsd-tests/cxx/tree/default/omit/output @@ -0,0 +1,19 @@ + +derived: +a: a +x: foo +q1: 1 +y: -20 +p: bar +q2: 2 +default x: foo +default y: -20 +fixed p: bar +fixed q1: 1 +fixed q2: 2 + + + + a + + diff --git a/xsd-tests/cxx/tree/default/omit/test.xml b/xsd-tests/cxx/tree/default/omit/test.xml new file mode 100644 index 0000000..dec39b4 --- /dev/null +++ b/xsd-tests/cxx/tree/default/omit/test.xml @@ -0,0 +1,9 @@ + + + + a + + + diff --git a/xsd-tests/cxx/tree/default/omit/test.xsd b/xsd-tests/cxx/tree/default/omit/test.xsd new file mode 100644 index 0000000..bfc68d4 --- /dev/null +++ b/xsd-tests/cxx/tree/default/omit/test.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/detach/buildfile b/xsd-tests/cxx/tree/detach/buildfile new file mode 100644 index 0000000..07f5f03 --- /dev/null +++ b/xsd-tests/cxx/tree/detach/buildfile @@ -0,0 +1,21 @@ +# file : cxx/tree/detach/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-detach \ + --generate-default-ctor \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/detach/driver.cxx b/xsd-tests/cxx/tree/detach/driver.cxx new file mode 100644 index 0000000..b632b5d --- /dev/null +++ b/xsd-tests/cxx/tree/detach/driver.cxx @@ -0,0 +1,108 @@ +// file : cxx/tree/detach/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the detach functionality. +// + +#include // std::auto_ptr/unique_ptr +#include + +#include "test.hxx" + +#ifdef XSD_CXX11 +# include // std::move +# define XSD_MOVE(x) std::move(x) +#else +# define XSD_MOVE(x) x +#endif + +using namespace std; +using namespace test; + +int +main () +{ + using test::ref; + + // Construct the model. + // + object o1 ("o1"); + o1.data ().push_back ("1-1"); + o1.data ().push_back ("1-2"); + o1.data ().push_back ("1-3"); + + object o2 ("o2"); + o1.data ().push_back ("2-1"); + o1.data ().push_back ("2-2"); + o1.data ().push_back ("2-3"); + + object o3 ("o3"); + o1.data ().push_back ("3-1"); + o1.data ().push_back ("3-2"); + o1.data ().push_back ("3-3"); + + object o4 ("o4"); + o1.data ().push_back ("4-1"); + o1.data ().push_back ("4-2"); + o1.data ().push_back ("4-3"); + + subtree s1; + s1.o ().push_back (o1); + s1.o ().push_back (o2); + s1.r ().push_back (ref ("o2")); + s1.r ().push_back (ref ("o3")); + + subtree s2; + s2.o ().push_back (o3); + s2.o ().push_back (o4); + s2.r ().push_back (ref ("o4")); + s2.r ().push_back (ref ("o1")); + + model m; + m.one (s1); + m.opt (s2); + + // Detach one. + // + XSD_AUTO_PTR p (m.detach_one ()); + assert (p->_container () == 0); + assert (p->r ()[0].get () == &p->o ()[1]); + assert (m.opt ()->r ()[1].get () == 0); + + m.one (XSD_MOVE (p)); + assert (m.opt ()->r ()[1].get () == &m.one ().o ()[0]); + p = m.detach_one (); + + model m1; + m1.one (XSD_MOVE (p)); + m1.opt (s2); + assert (m1.opt ()->r ()[1].get () == &m1.one ().o ()[0]); + + p = m1.detach_one (); + m.seq ().push_back (XSD_MOVE (p)); + + // Detach opt. + // + p = m.opt ().detach (); + assert (!m.opt ()); + assert (p->_container () == 0); + assert (p->r ()[0].get () == &p->o ()[1]); + assert (m.seq ()[0].r ()[1].get () == 0); + + m.seq ().push_back (XSD_MOVE (p)); + + // Detach seq. + // + p = m.seq ().detach_back (); + assert (p->_container () == 0); + assert (p->r ()[0].get () == &p->o ()[1]); + assert (m.seq ()[0].r ()[1].get () == 0); + + m.seq ().push_back (XSD_MOVE (p)); + assert (m.seq ()[0].r ()[1].get () == &m.seq ()[1].o ()[0]); + + m.seq ().detach (m.seq ().begin (), p); + assert (p->_container () == 0); + assert (p->r ()[0].get () == &p->o ()[1]); + assert (m.seq ()[0].r ()[1].get () == 0); +} diff --git a/xsd-tests/cxx/tree/detach/test.xsd b/xsd-tests/cxx/tree/detach/test.xsd new file mode 100644 index 0000000..b9f5166 --- /dev/null +++ b/xsd-tests/cxx/tree/detach/test.xsd @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/dom-association/buildfile b/xsd-tests/cxx/tree/dom-association/buildfile new file mode 100644 index 0000000..85593e5 --- /dev/null +++ b/xsd-tests/cxx/tree/dom-association/buildfile @@ -0,0 +1,27 @@ +# file : cxx/tree/dom-association/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-ostream \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/tree/dom-association/dom-parse.cxx b/xsd-tests/cxx/tree/dom-association/dom-parse.cxx new file mode 100644 index 0000000..281eb2c --- /dev/null +++ b/xsd-tests/cxx/tree/dom-association/dom-parse.cxx @@ -0,0 +1,95 @@ +// file : cxx/tree/dom-association/dom-parse.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#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; + +XSD_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)); + + XSD_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); + + XSD_DOM_AUTO_PTR doc (parser->parse (&wrap)); + + eh.throw_if_failed > (); + + return doc; +} diff --git a/xsd-tests/cxx/tree/dom-association/dom-parse.hxx b/xsd-tests/cxx/tree/dom-association/dom-parse.hxx new file mode 100644 index 0000000..f14a53b --- /dev/null +++ b/xsd-tests/cxx/tree/dom-association/dom-parse.hxx @@ -0,0 +1,23 @@ +// file : cxx/tree/dom-association/dom-parse.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#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_DOM_AUTO_PTR +parse (std::istream& is, + const std::string& id, + bool validate); + +#endif // DOM_PARSE diff --git a/xsd-tests/cxx/tree/dom-association/driver.cxx b/xsd-tests/cxx/tree/dom-association/driver.cxx new file mode 100644 index 0000000..d85e105 --- /dev/null +++ b/xsd-tests/cxx/tree/dom-association/driver.cxx @@ -0,0 +1,71 @@ +// file : cxx/tree/dom-association/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test DOM association/ownership. +// + +#include // std::auto_ptr/unique_ptr +#include +#include + +#include + +#include "dom-parse.hxx" +#include "test.hxx" + +using namespace std; +using namespace test; +using namespace xercesc; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + int r (0); + + XMLPlatformUtils::Initialize (); + + try + { + ifstream ifs; + ifs.exceptions (ifstream::badbit | ifstream::failbit); + ifs.open (argv[1]); + + DOMDocument* ptr; + +#ifdef XSD_CXX11 + xml_schema::dom::unique_ptr doc (parse (ifs, argv[1], true)); + ptr = doc.get (); + unique_ptr r ( + root (std::move (doc), + xml_schema::flags::keep_dom | xml_schema::flags::own_dom)); +#else + xml_schema::dom::auto_ptr doc (parse (ifs, argv[1], true)); + ptr = doc.get (); + auto_ptr r ( + root (doc, + xml_schema::flags::keep_dom | xml_schema::flags::own_dom)); +#endif + + assert (doc.get () == 0); + assert (r->_node ()->getOwnerDocument () == ptr); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + r = 1; + } + catch (const std::ios_base::failure&) + { + cerr << argv[1] << ": unable to open or read failure" << endl; + r = 1; + } + + XMLPlatformUtils::Terminate (); + return r; +} diff --git a/xsd-tests/cxx/tree/dom-association/output b/xsd-tests/cxx/tree/dom-association/output new file mode 100644 index 0000000..e69de29 diff --git a/xsd-tests/cxx/tree/dom-association/test.xml b/xsd-tests/cxx/tree/dom-association/test.xml new file mode 100644 index 0000000..624a80c --- /dev/null +++ b/xsd-tests/cxx/tree/dom-association/test.xml @@ -0,0 +1,7 @@ + + + a + + diff --git a/xsd-tests/cxx/tree/dom-association/test.xsd b/xsd-tests/cxx/tree/dom-association/test.xsd new file mode 100644 index 0000000..07bebc7 --- /dev/null +++ b/xsd-tests/cxx/tree/dom-association/test.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/encoding/char/iso-8859-1/buildfile b/xsd-tests/cxx/tree/encoding/char/iso-8859-1/buildfile new file mode 100644 index 0000000..bdea527 --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/char/iso-8859-1/buildfile @@ -0,0 +1,25 @@ +# file : cxx/tree/encoding/char/iso-8859-1/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --char-encoding iso8859-1 \ + --generate-doxygen \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/encoding/char/iso-8859-1/driver.cxx b/xsd-tests/cxx/tree/encoding/char/iso-8859-1/driver.cxx new file mode 100644 index 0000000..e356815 --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/char/iso-8859-1/driver.cxx @@ -0,0 +1,74 @@ +// file : cxx/tree/encoding/char/iso-8859-1/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test ISO-8859-1 encoding. +// + +#include // std::auto_ptr/unique_ptr +#include +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + try + { + root (argv[1]); + return 1; + } + catch (xsd::cxx::xml::iso8859_1_unrepresentable const&) + { + } + + xsd::cxx::xml::char_transcoder::unrep_char ('?'); + XSD_AUTO_PTR r (root (argv[1])); + + { + type::a_sequence const& s (r->a ()); + + if (s[0] != "abc" || + s[1] != "\xE6" || + s[2] != "\xA2\xA3\xA4\xA5" || + s[3] != "??") + { + cerr << "invalid encoding" << endl; + return 1; + } + } + + { + type::b_sequence const& s (r->b ()); + + if (s[0] != strenum::abc || + s[1] != strenum::a_c || + s[2] != strenum::cxx__bc) + { + cerr << "invalid encoding" << endl; + return 1; + } + } + + xml_schema::namespace_infomap map; + map["t"].name = "test"; + + root (std::cout, *r, map, "ISO-8859-1"); + } + catch (xml_schema::exception const& e) + { + cerr << "xml_schema::exception: " << e.what () << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/encoding/char/iso-8859-1/output b/xsd-tests/cxx/tree/encoding/char/iso-8859-1/output new file mode 100644 index 0000000..cb73faa --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/char/iso-8859-1/output @@ -0,0 +1,10 @@ + + + abc + æ + ¢£¤¥ + ?? + abc + aâc + âòbc + diff --git a/xsd-tests/cxx/tree/encoding/char/iso-8859-1/test.xml b/xsd-tests/cxx/tree/encoding/char/iso-8859-1/test.xml new file mode 100644 index 0000000..cc05f8d --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/char/iso-8859-1/test.xml @@ -0,0 +1,14 @@ + + + abc + æ + ¢£¤¥ + Āꪪ + + abc + aâc + âòbc + + diff --git a/xsd-tests/cxx/tree/encoding/char/iso-8859-1/test.xsd b/xsd-tests/cxx/tree/encoding/char/iso-8859-1/test.xsd new file mode 100644 index 0000000..31b8901 --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/char/iso-8859-1/test.xsd @@ -0,0 +1,31 @@ + + + + + + + + Test enum. Valid values are: + abc + aâc + òbc + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/encoding/char/lcp/buildfile b/xsd-tests/cxx/tree/encoding/char/lcp/buildfile new file mode 100644 index 0000000..d935b09 --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/char/lcp/buildfile @@ -0,0 +1,24 @@ +# file : cxx/tree/encoding/char/lcp/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --char-encoding lcp \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/encoding/char/lcp/driver.cxx b/xsd-tests/cxx/tree/encoding/char/lcp/driver.cxx new file mode 100644 index 0000000..97c0875 --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/char/lcp/driver.cxx @@ -0,0 +1,40 @@ +// file : cxx/tree/encoding/char/lcp/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test local code page encoding (--char-encoding lcp). +// The test just makes sure it still compiles and works. +// + +#include // std::auto_ptr/unique_ptr +#include +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + XSD_AUTO_PTR r (root (argv[1])); + + xml_schema::namespace_infomap map; + map["t"].name = "test"; + + root (std::cout, *r, map); + } + catch (xml_schema::exception const& e) + { + cerr << "xml_schema::exception: " << e.what () << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/encoding/char/lcp/output b/xsd-tests/cxx/tree/encoding/char/lcp/output new file mode 100644 index 0000000..368826d --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/char/lcp/output @@ -0,0 +1,4 @@ + + + abcd + diff --git a/xsd-tests/cxx/tree/encoding/char/lcp/test.xml b/xsd-tests/cxx/tree/encoding/char/lcp/test.xml new file mode 100644 index 0000000..772512e --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/char/lcp/test.xml @@ -0,0 +1,7 @@ + + + abcd + + diff --git a/xsd-tests/cxx/tree/encoding/char/lcp/test.xsd b/xsd-tests/cxx/tree/encoding/char/lcp/test.xsd new file mode 100644 index 0000000..1e264e3 --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/char/lcp/test.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/encoding/char/utf-8/buildfile b/xsd-tests/cxx/tree/encoding/char/utf-8/buildfile new file mode 100644 index 0000000..4d48165 --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/char/utf-8/buildfile @@ -0,0 +1,24 @@ +# file : cxx/tree/encoding/char/utf-8/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --generate-doxygen \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/encoding/char/utf-8/driver.cxx b/xsd-tests/cxx/tree/encoding/char/utf-8/driver.cxx new file mode 100644 index 0000000..7892667 --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/char/utf-8/driver.cxx @@ -0,0 +1,63 @@ +// file : cxx/tree/encoding/char/utf-8/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test UTF-8 encoding. +// + +#include // std::auto_ptr/unique_ptr +#include +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + XSD_AUTO_PTR r (root (argv[1])); + + { + type::a_sequence const& s (r->a ()); + + if (s[0] != "abc" || + s[1] != "\xD5\x95" || + s[2] != "\xEA\xAA\xAA") + { + cerr << "invalid encoding" << endl; + return 1; + } + } + + { + type::b_sequence const& s (r->b ()); + + if (s[0] != strenum::abc || + s[1] != strenum::a_c || + s[2] != strenum::cxx_bc) + { + cerr << "invalid encoding" << endl; + return 1; + } + } + + xml_schema::namespace_infomap map; + map["t"].name = "test"; + + root (std::cout, *r, map, "ASCII"); + } + catch (xml_schema::exception const& e) + { + cerr << "xml_schema::exception: " << e.what () << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/encoding/char/utf-8/output b/xsd-tests/cxx/tree/encoding/char/utf-8/output new file mode 100644 index 0000000..fdfef4c --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/char/utf-8/output @@ -0,0 +1,9 @@ + + + abc + Օ + + abc + aՕc + ꪪbc + diff --git a/xsd-tests/cxx/tree/encoding/char/utf-8/test.xml b/xsd-tests/cxx/tree/encoding/char/utf-8/test.xml new file mode 100644 index 0000000..0d3e27a --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/char/utf-8/test.xml @@ -0,0 +1,13 @@ + + + abc + Օ + + + abc + aՕc + ꪪbc + + diff --git a/xsd-tests/cxx/tree/encoding/char/utf-8/test.xsd b/xsd-tests/cxx/tree/encoding/char/utf-8/test.xsd new file mode 100644 index 0000000..d5ee868 --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/char/utf-8/test.xsd @@ -0,0 +1,31 @@ + + + + + + + + Test enum. Valid values are: + abc + aՕc + ꪪbc + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/encoding/wchar/buildfile b/xsd-tests/cxx/tree/encoding/wchar/buildfile new file mode 100644 index 0000000..f640976 --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/wchar/buildfile @@ -0,0 +1,25 @@ +# file : cxx/tree/encoding/wchar/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --char-type wchar_t \ + --generate-doxygen \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/encoding/wchar/driver.cxx b/xsd-tests/cxx/tree/encoding/wchar/driver.cxx new file mode 100644 index 0000000..dbcbcba --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/wchar/driver.cxx @@ -0,0 +1,55 @@ +// file : cxx/tree/encoding/wchar/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the wide character mapping. +// + +#include // std::auto_ptr/unique_ptr +#include +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + // Use dont_validate because we do not have instance's system id (path). + // + std::ifstream ifs (argv[1]); + XSD_AUTO_PTR r (root (ifs, xml_schema::flags::dont_validate)); + + { + type::b_sequence const& s (r->b ()); + + if (s[0] != strenum::abc || + s[1] != strenum::a__c || + s[2] != strenum::cxx__bc || + s[3] != strenum::ab__) + { + cerr << "invalid encoding" << endl; + return 1; + } + } + + xml_schema::namespace_infomap map; + map[L"t"].name = L"test"; + + root (std::cout, *r, map, L"ASCII"); + } + catch (xml_schema::exception const& e) + { + cerr << "xml_schema::exception: " << e.what () << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/encoding/wchar/output b/xsd-tests/cxx/tree/encoding/wchar/output new file mode 100644 index 0000000..e0eaef0 --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/wchar/output @@ -0,0 +1,10 @@ + + + abc + ῿퟿ + ကჿ + abc + a῿퟿c + ကჿbc + abကჿ + diff --git a/xsd-tests/cxx/tree/encoding/wchar/test.xml b/xsd-tests/cxx/tree/encoding/wchar/test.xml new file mode 100644 index 0000000..9abb1b6 --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/wchar/test.xml @@ -0,0 +1,14 @@ + + + abc + ῿퟿ + ကჿ + + abc + a῿퟿c + ကჿbc + abကჿ + + diff --git a/xsd-tests/cxx/tree/encoding/wchar/test.xsd b/xsd-tests/cxx/tree/encoding/wchar/test.xsd new file mode 100644 index 0000000..0151d2f --- /dev/null +++ b/xsd-tests/cxx/tree/encoding/wchar/test.xsd @@ -0,0 +1,33 @@ + + + + + + + + Test enum. Valid values are: + abc + a῿퟿c + ကჿbc + abကჿ + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/enumeration/ctor/buildfile b/xsd-tests/cxx/tree/enumeration/ctor/buildfile new file mode 100644 index 0000000..96be1ce --- /dev/null +++ b/xsd-tests/cxx/tree/enumeration/ctor/buildfile @@ -0,0 +1,22 @@ +# file : cxx/tree/enumeration/ctor/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-default-ctor \ + --generate-from-base-ctor \ + --generate-doxygen \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/enumeration/ctor/driver.cxx b/xsd-tests/cxx/tree/enumeration/ctor/driver.cxx new file mode 100644 index 0000000..c5ea1f2 --- /dev/null +++ b/xsd-tests/cxx/tree/enumeration/ctor/driver.cxx @@ -0,0 +1,30 @@ +// file : cxx/tree/enumeration/ctor/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test enumeration constructors. +// +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main () +{ + // Test ctor(const char*). + // + { + string_enum se ("a"); + type t ("a", 1); + } + + // Test ctor(const std::string&) + // + { + string const s ("c"); + string_enum se (s); + type t (s, 3); + } +} diff --git a/xsd-tests/cxx/tree/enumeration/ctor/test.xsd b/xsd-tests/cxx/tree/enumeration/ctor/test.xsd new file mode 100644 index 0000000..c5d625a --- /dev/null +++ b/xsd-tests/cxx/tree/enumeration/ctor/test.xsd @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/enumeration/inheritance/buildfile b/xsd-tests/cxx/tree/enumeration/inheritance/buildfile new file mode 100644 index 0000000..184c95c --- /dev/null +++ b/xsd-tests/cxx/tree/enumeration/inheritance/buildfile @@ -0,0 +1,23 @@ +# file : cxx/tree/enumeration/inheritance/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-ostream \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/enumeration/inheritance/driver.cxx b/xsd-tests/cxx/tree/enumeration/inheritance/driver.cxx new file mode 100644 index 0000000..b517b1f --- /dev/null +++ b/xsd-tests/cxx/tree/enumeration/inheritance/driver.cxx @@ -0,0 +1,53 @@ +// file : cxx/tree/enumeration/inheritance/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Insert test description here. +// + +#include // std::auto_ptr/unique_ptr +#include +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + XSD_AUTO_PTR r (root (argv[1])); + + switch (*r) + { + case top_bottom::top: + { + cout << "top" << endl; + break; + } + case top_bottom::bottom: + { + cout << "bottom" << endl; + break; + } + default: // Suppress warning. + { + assert (false); + break; + } + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/enumeration/inheritance/output b/xsd-tests/cxx/tree/enumeration/inheritance/output new file mode 100644 index 0000000..fef12e2 --- /dev/null +++ b/xsd-tests/cxx/tree/enumeration/inheritance/output @@ -0,0 +1 @@ +bottom diff --git a/xsd-tests/cxx/tree/enumeration/inheritance/test.xml b/xsd-tests/cxx/tree/enumeration/inheritance/test.xml new file mode 100644 index 0000000..1de9043 --- /dev/null +++ b/xsd-tests/cxx/tree/enumeration/inheritance/test.xml @@ -0,0 +1,3 @@ +bottom diff --git a/xsd-tests/cxx/tree/enumeration/inheritance/test.xsd b/xsd-tests/cxx/tree/enumeration/inheritance/test.xsd new file mode 100644 index 0000000..cf2eeb1 --- /dev/null +++ b/xsd-tests/cxx/tree/enumeration/inheritance/test.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/float/buildfile b/xsd-tests/cxx/tree/float/buildfile new file mode 100644 index 0000000..4872a2f --- /dev/null +++ b/xsd-tests/cxx/tree/float/buildfile @@ -0,0 +1,24 @@ +# file : cxx/tree/float/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/float/driver.cxx b/xsd-tests/cxx/tree/float/driver.cxx new file mode 100644 index 0000000..0f7455f --- /dev/null +++ b/xsd-tests/cxx/tree/float/driver.cxx @@ -0,0 +1,53 @@ +// file : cxx/tree/float/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test floating point (xsd:{float, double, decimal}) type parsing +// and serialization. +// + +#include // std::auto_ptr/unique_ptr +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + XSD_AUTO_PTR r (root (argv[1])); + + r->simple ().push_back (12.129456); + r->simple ().push_back (123.129456); + r->simple ().push_back (1234.129456); + + r->s (12.129456); + + r->complex ().push_back (12.129456); + r->complex ().push_back (123.129456); + r->complex ().push_back (1234.129456); + r->complex ().push_back (-12.12); + r->complex ().push_back (-123.12); + + r->s (12.129456); + + xml_schema::namespace_infomap map; + + map["t"].name = "test"; + root (cout, *r, map); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/float/output b/xsd-tests/cxx/tree/float/output new file mode 100644 index 0000000..399e28c --- /dev/null +++ b/xsd-tests/cxx/tree/float/output @@ -0,0 +1,35 @@ + + + 0 + 1 + 1e+06 + 1e-07 + 0 1 1e+06 1e-07 + 0 + 1 + 100000000000000 + 1e-15 + 0 1 100000000000000 1e-15 + 0 + 1 + 10000 + 100000000000000 + 0.000000000000001 + 0 1 100000000000000 0.000000000000001 + 0 + 1 + 12.34 + 0.12 + 12.13 + 123.1 + 1234 + 0 + 1 + 12.34 + 0.12 + 12.13 + 123.1 + 1234 + -12.12 + -123.1 + diff --git a/xsd-tests/cxx/tree/float/test.xml b/xsd-tests/cxx/tree/float/test.xml new file mode 100644 index 0000000..e5124a4 --- /dev/null +++ b/xsd-tests/cxx/tree/float/test.xml @@ -0,0 +1,35 @@ + + + 0.0 + 1.0 + 1000000.0 + 0.0000001 + 0.0 1.0 1000000.0 0.0000001 + + 0.0 + 1.0 + 100000000000000.0 + 0.000000000000001 + 0.0 1.0 100000000000000.0 0.000000000000001 + + 0.0 + 1.0 + 10000 + 100000000000000.0 + 0.000000000000001 + 0.0 1.0 100000000000000.0 0.000000000000001 + + 0.0 + 1.0 + 12.34 + 0.12 + + 0.0 + 1.0 + 12.34 + 0.12 + + diff --git a/xsd-tests/cxx/tree/float/test.xsd b/xsd-tests/cxx/tree/float/test.xsd new file mode 100644 index 0000000..c02678d --- /dev/null +++ b/xsd-tests/cxx/tree/float/test.xsd @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/list/ctor/buildfile b/xsd-tests/cxx/tree/list/ctor/buildfile new file mode 100644 index 0000000..2155f95 --- /dev/null +++ b/xsd-tests/cxx/tree/list/ctor/buildfile @@ -0,0 +1,22 @@ +# file : cxx/tree/list/ctor/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-default-ctor \ + --generate-from-base-ctor \ + --generate-doxygen \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/list/ctor/driver.cxx b/xsd-tests/cxx/tree/list/ctor/driver.cxx new file mode 100644 index 0000000..5673e67 --- /dev/null +++ b/xsd-tests/cxx/tree/list/ctor/driver.cxx @@ -0,0 +1,50 @@ +// file : cxx/tree/list/ctor/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test list constructors. +// +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main () +{ + // Test ctor() + // + { + string_list sl; + + xml_schema::nmtokens nt; + xml_schema::idrefs id; + } + + // Test ctor(size_type, const X&) + // + { + string_list sl (10, "abc"); + size_type st (10, 123); + + xml_schema::nmtokens nt (10, "abc"); + xml_schema::idrefs id (10, "abc"); + } + + // Test ctor(const I& begin, const I& end) + // + { + string_list sl1 (10, "abc"); + string_list sl2 (sl1.begin (), sl1.end ()); + + I i1 (10, 123); + I i2 (i1.begin (), i1.end ()); + + xml_schema::nmtokens nt1 (10, "abc"); + xml_schema::nmtokens nt2 (nt1.begin (), nt1.end ()); + + xml_schema::idrefs id1 (10, "abc"); + xml_schema::idrefs id2 (id1.begin (), id1.end ()); + } +} diff --git a/xsd-tests/cxx/tree/list/ctor/test.xsd b/xsd-tests/cxx/tree/list/ctor/test.xsd new file mode 100644 index 0000000..f090bb8 --- /dev/null +++ b/xsd-tests/cxx/tree/list/ctor/test.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/name-clash/inheritance/buildfile b/xsd-tests/cxx/tree/name-clash/inheritance/buildfile new file mode 100644 index 0000000..530c42f --- /dev/null +++ b/xsd-tests/cxx/tree/name-clash/inheritance/buildfile @@ -0,0 +1,23 @@ +# file : cxx/tree/name-clash/inheritance/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-ostream \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/name-clash/inheritance/driver.cxx b/xsd-tests/cxx/tree/name-clash/inheritance/driver.cxx new file mode 100644 index 0000000..634c56a --- /dev/null +++ b/xsd-tests/cxx/tree/name-clash/inheritance/driver.cxx @@ -0,0 +1,35 @@ +// file : cxx/tree/name-clash/inheritance/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test for name clashes across inheritance hierarchy. +// + +#include // std::auto_ptr/unique_ptr +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + XSD_AUTO_PTR r (root (argv[1])); + + cout << *r << endl; + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/name-clash/inheritance/output b/xsd-tests/cxx/tree/name-clash/inheritance/output new file mode 100644 index 0000000..54565bb --- /dev/null +++ b/xsd-tests/cxx/tree/name-clash/inheritance/output @@ -0,0 +1,3 @@ + +e: e +e: e1 diff --git a/xsd-tests/cxx/tree/name-clash/inheritance/test.xml b/xsd-tests/cxx/tree/name-clash/inheritance/test.xml new file mode 100644 index 0000000..8c17101 --- /dev/null +++ b/xsd-tests/cxx/tree/name-clash/inheritance/test.xml @@ -0,0 +1,8 @@ + + + e + e1 + + diff --git a/xsd-tests/cxx/tree/name-clash/inheritance/test.xsd b/xsd-tests/cxx/tree/name-clash/inheritance/test.xsd new file mode 100644 index 0000000..b83d7df --- /dev/null +++ b/xsd-tests/cxx/tree/name-clash/inheritance/test.xsd @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/naming/camel/buildfile b/xsd-tests/cxx/tree/naming/camel/buildfile new file mode 100644 index 0000000..8a8410c --- /dev/null +++ b/xsd-tests/cxx/tree/naming/camel/buildfile @@ -0,0 +1,25 @@ +# file : cxx/tree/naming/camel/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --type-naming ucc \ + --function-naming lcc \ + --generate-ostream \ + --generate-comparison \ + --generate-wildcard \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/naming/camel/driver.cxx b/xsd-tests/cxx/tree/naming/camel/driver.cxx new file mode 100644 index 0000000..600b3ff --- /dev/null +++ b/xsd-tests/cxx/tree/naming/camel/driver.cxx @@ -0,0 +1,154 @@ +// file : cxx/tree/naming/camel/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test camel case (upper for types, lower for functions) naming style. +// + +#include +#include + +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main () +{ + xercesc::XMLPlatformUtils::Initialize (); + + try + { + // Enum 'value' type. + // + { + Gender::Value v; + v = Gender::female; + XSD_UNUSED (v); + } + + // Anonymous type. + // + { + Foo f ("a", "b"); + + if (f.a () != "a" || f.b () != "b") + return 1; + } + + // Type name and accessors/modifiers. + // + { + Type t ("bar"); + + // foo + // + { + Type::FooType* p = 0; + XSD_UNUSED (p); + + Type::FooOptional o; + + if (t.foo ().present ()) + return 1; + + t.foo (o); + } + + // bar + // + { + Type::BarType* p = 0; + XSD_UNUSED (p); + + if (t.bar () != "bar") + return 1; + + t.bar ("barbar"); + } + + // baz + // + { + Type::BazType* p = 0; + XSD_UNUSED (p); + + Type::BazSequence s; + Type::BazIterator i (s.begin ()); + Type::BazConstIterator ci (s.begin ()); + XSD_UNUSED (i); + XSD_UNUSED (ci); + + if (t.baz () != s) + return 1; + + t.baz (s); + } + + // any + // + { + Type::AnySequence s (t.domDocument ()); + Type::AnyIterator i (s.begin ()); + Type::AnyConstIterator ci (s.begin ()); + XSD_UNUSED (i); + XSD_UNUSED (ci); + + if (t.any () != s) + return 1; + + t.any (s); + } + + // foo + // + { + Type::FoxType x = Type::foxDefaultValue (); + + if (t.fox () != x) + return 1; + + t.fox ("fox"); + } + + // any_attribute + // + { + Type::AnyAttributeSet s (t.domDocument ()); + Type::AnyAttributeIterator i (s.begin ()); + Type::AnyAttributeConstIterator ci (s.begin ()); + XSD_UNUSED (i); + XSD_UNUSED (ci); + + if (t.anyAttribute () != s) + return 1; + + t.anyAttribute (s); + } + } + + // Parsing/serialization functions. + // + { + istringstream is ("foo"); + root (is, xml_schema::Flags::dont_validate); + } + + { + ostringstream os; + xml_schema::NamespaceInfomap m; + m["t"].name = "test"; + + root (os, "foo", m); + } + } + catch (xml_schema::Exception const& e) + { + cerr << e << endl; + return 1; + } + + xercesc::XMLPlatformUtils::Terminate (); +} diff --git a/xsd-tests/cxx/tree/naming/camel/test.xsd b/xsd-tests/cxx/tree/naming/camel/test.xsd new file mode 100644 index 0000000..7d0a745 --- /dev/null +++ b/xsd-tests/cxx/tree/naming/camel/test.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/naming/java/buildfile b/xsd-tests/cxx/tree/naming/java/buildfile new file mode 100644 index 0000000..5d4b447 --- /dev/null +++ b/xsd-tests/cxx/tree/naming/java/buildfile @@ -0,0 +1,25 @@ +# file : cxx/tree/naming/java/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --type-naming java \ + --function-naming java \ + --generate-ostream \ + --generate-comparison \ + --generate-wildcard \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/naming/java/driver.cxx b/xsd-tests/cxx/tree/naming/java/driver.cxx new file mode 100644 index 0000000..b47ff74 --- /dev/null +++ b/xsd-tests/cxx/tree/naming/java/driver.cxx @@ -0,0 +1,153 @@ +// file : cxx/tree/naming/java/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test Java naming style. +// + +#include +#include + +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main () +{ + xercesc::XMLPlatformUtils::Initialize (); + + try + { + // Enum 'value' type. + // + { + Gender::Value v; + v = Gender::female; + XSD_UNUSED (v); + } + + // Anonymous type. + // + { + Foo f ("a", "b"); + + if (f.getA () != "a" || f.getB () != "b") + return 1; + } + + // Type name and accessors/modifiers. + // + { + Type t ("bar"); + + // foo + // + { + Type::FooType* p = 0; + XSD_UNUSED (p); + Type::FooOptional o; + + if (t.getFoo ().present ()) + return 1; + + t.setFoo (o); + } + + // bar + // + { + Type::BarType* p = 0; + XSD_UNUSED (p); + + if (t.getBar () != "bar") + return 1; + + t.setBar ("barbar"); + } + + // baz + // + { + Type::BazType* p = 0; + XSD_UNUSED (p); + + Type::BazSequence s; + Type::BazIterator i (s.begin ()); + Type::BazConstIterator ci (s.begin ()); + XSD_UNUSED (i); + XSD_UNUSED (ci); + + if (t.getBaz () != s) + return 1; + + t.setBaz (s); + } + + // any + // + { + Type::AnySequence s (t.getDomDocument ()); + Type::AnyIterator i (s.begin ()); + Type::AnyConstIterator ci (s.begin ()); + XSD_UNUSED (i); + XSD_UNUSED (ci); + + if (t.getAny () != s) + return 1; + + t.setAny (s); + } + + // foo + // + { + Type::FoxType x = Type::getFoxDefaultValue (); + + if (t.getFox () != x) + return 1; + + t.setFox ("fox"); + } + + // any_attribute + // + { + Type::AnyAttributeSet s (t.getDomDocument ()); + Type::AnyAttributeIterator i (s.begin ()); + Type::AnyAttributeConstIterator ci (s.begin ()); + XSD_UNUSED (i); + XSD_UNUSED (ci); + + if (t.getAnyAttribute () != s) + return 1; + + t.setAnyAttribute (s); + } + } + + // Parsing/serialization functions. + // + { + istringstream is ("foo"); + parseRoot (is, xml_schema::Flags::dont_validate); + } + + { + ostringstream os; + xml_schema::NamespaceInfomap m; + m["t"].name = "test"; + + serializeRoot (os, "foo", m); + } + } + catch (xml_schema::Exception const& e) + { + cerr << e << endl; + return 1; + } + + xercesc::XMLPlatformUtils::Terminate (); +} diff --git a/xsd-tests/cxx/tree/naming/java/test.xsd b/xsd-tests/cxx/tree/naming/java/test.xsd new file mode 100644 index 0000000..f525534 --- /dev/null +++ b/xsd-tests/cxx/tree/naming/java/test.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/naming/knr/buildfile b/xsd-tests/cxx/tree/naming/knr/buildfile new file mode 100644 index 0000000..c4c2287 --- /dev/null +++ b/xsd-tests/cxx/tree/naming/knr/buildfile @@ -0,0 +1,25 @@ +# file : cxx/tree/naming/knr/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --type-naming knr \ + --function-naming knr \ + --generate-ostream \ + --generate-comparison \ + --generate-wildcard \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/naming/knr/driver.cxx b/xsd-tests/cxx/tree/naming/knr/driver.cxx new file mode 100644 index 0000000..8c75dd9 --- /dev/null +++ b/xsd-tests/cxx/tree/naming/knr/driver.cxx @@ -0,0 +1,154 @@ +// file : cxx/tree/naming/knr/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test K&R naming style. +// + +#include +#include + +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main () +{ + xercesc::XMLPlatformUtils::Initialize (); + + try + { + // Enum 'value' type. + // + { + gender::value v; + v = gender::female; + XSD_UNUSED (v); + } + + // Anonymous type. + // + { + foo f ("a", "b"); + + if (f.a () != "a" || f.b () != "b") + return 1; + } + + // Type name and accessors/modifiers. + // + { + type t ("bar"); + + // foo + // + { + type::foo_type* p = 0; + XSD_UNUSED (p); + + type::foo_optional o; + + if (t.foo ().present ()) + return 1; + + t.foo (o); + } + + // bar + // + { + type::bar_type* p = 0; + XSD_UNUSED (p); + + if (t.bar () != "bar") + return 1; + + t.bar ("barbar"); + } + + // baz + // + { + type::baz_type* p = 0; + XSD_UNUSED (p); + + type::baz_sequence s; + type::baz_iterator i (s.begin ()); + type::baz_const_iterator ci (s.begin ()); + XSD_UNUSED (i); + XSD_UNUSED (ci); + + if (t.baz () != s) + return 1; + + t.baz (s); + } + + // any + // + { + type::any_sequence s (t.dom_document ()); + type::any_iterator i (s.begin ()); + type::any_const_iterator ci (s.begin ()); + XSD_UNUSED (i); + XSD_UNUSED (ci); + + if (t.any () != s) + return 1; + + t.any (s); + } + + // foo + // + { + type::fox_type x = type::fox_default_value (); + + if (t.fox () != x) + return 1; + + t.fox ("fox"); + } + + // any_attribute + // + { + type::any_attribute_set s (t.dom_document ()); + type::any_attribute_iterator i (s.begin ()); + type::any_attribute_const_iterator ci (s.begin ()); + XSD_UNUSED (i); + XSD_UNUSED (ci); + + if (t.any_attribute () != s) + return 1; + + t.any_attribute (s); + } + } + + // Parsing/serialization functions. + // + { + istringstream is ("foo"); + root (is, xml_schema::flags::dont_validate); + } + + { + ostringstream os; + xml_schema::namespace_infomap m; + m["t"].name = "test"; + + root (os, "foo", m); + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + + xercesc::XMLPlatformUtils::Terminate (); +} diff --git a/xsd-tests/cxx/tree/naming/knr/test.xsd b/xsd-tests/cxx/tree/naming/knr/test.xsd new file mode 100644 index 0000000..4361544 --- /dev/null +++ b/xsd-tests/cxx/tree/naming/knr/test.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/order/buildfile b/xsd-tests/cxx/tree/order/buildfile new file mode 100644 index 0000000..91c3cb7 --- /dev/null +++ b/xsd-tests/cxx/tree/order/buildfile @@ -0,0 +1,37 @@ +# file : cxx/tree/order/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --generate-wildcard \ + --generate-comparison \ + --ordered-type t1_base \ + --ordered-type t1_derived \ + --ordered-type t2_base \ + --ordered-type t2_derived \ + --ordered-type t3_type \ + --ordered-type t4_base \ + --ordered-type t4_derived \ + --ordered-type t5_base \ + --ordered-type t5_derived \ + --ordered-type t6_base \ + --ordered-type t6_derived \ + --ordered-type t7_type \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/order/driver.cxx b/xsd-tests/cxx/tree/order/driver.cxx new file mode 100644 index 0000000..f1902ba --- /dev/null +++ b/xsd-tests/cxx/tree/order/driver.cxx @@ -0,0 +1,64 @@ +// file : cxx/tree/order/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test ordered type support. +// + +#include // std::auto_ptr/unique_ptr +#include +#include + +#include +#include + +#include "test.hxx" + +using namespace std; +using namespace test; +using namespace xercesc; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + XMLPlatformUtils::Initialize (); + + try + { + XSD_AUTO_PTR r (root_ (argv[1], xml_schema::flags::dont_initialize)); + + root c (*r); + assert (c == *r); + + for (root::t1_const_iterator j (r->t1 ().begin ()); + j != r->t1 ().end (); ++j) + { + const t1_derived& d (*j); + + for (t1_derived::content_order_const_iterator i ( + d.content_order ().begin ()); i != d.content_order ().end (); ++i) + { + cout << i->id << ' ' << i->index << endl; + } + } + + xml_schema::namespace_infomap map; + + map["t"].name = "test"; + map["t1"].name = "test1"; + + root_ (cout, *r, map, "UTF-8", xml_schema::flags::dont_initialize); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + + XMLPlatformUtils::Terminate (); +} diff --git a/xsd-tests/cxx/tree/order/output b/xsd-tests/cxx/tree/order/output new file mode 100644 index 0000000..73442fe --- /dev/null +++ b/xsd-tests/cxx/tree/order/output @@ -0,0 +1,92 @@ +2 0 +1 0 +1 1 +2 1 +3 0 +4 0 +3 1 +4 1 + + + + b1 + a1 + a2 + b2 + c1 + d1 + e1 + d2 + f1 + + + b1 + a1 + b2 + a2 + + + a1 + b1 + c1 + c2 + + + a1 + c1 + + + t1 + + b1 + t2 + + a1 + t3 + + b2 + t4 + + a2 + t5 + + d1 + t6 + + c1 + t7 + + + + t5a + + + t1 + + b1 + t2 + + a1 + t3 + + a2 + t4 + + b2 + t5 + + + + t6 + + + t1 + + a1 + t2 + + b1 + t3 + + + diff --git a/xsd-tests/cxx/tree/order/test.xml b/xsd-tests/cxx/tree/order/test.xml new file mode 100644 index 0000000..cd82936 --- /dev/null +++ b/xsd-tests/cxx/tree/order/test.xml @@ -0,0 +1,71 @@ + + + b1 + a1 + a2 + b2 + c1 + d1 + e1 + d2 + f1 + + + b1 + a1 + b2 + a2 + + + a1 + b1 + c1 + c2 + + + a1 + c1 + + + t1 + b1 + t2 + a1 + t3 + b2 + t4 + a2 + t5 + d1 + t6 + c1 + t7 + + + t5a + + + t1 + b1 + t2 + a1 + t3 + a2 + t4 + b2 + t5 + + + t6 + + + t1 + a1 + t2 + b1 + t3 + + diff --git a/xsd-tests/cxx/tree/order/test.xsd b/xsd-tests/cxx/tree/order/test.xsd new file mode 100644 index 0000000..c30c027 --- /dev/null +++ b/xsd-tests/cxx/tree/order/test.xsd @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/polymorphism/comparison/buildfile b/xsd-tests/cxx/tree/polymorphism/comparison/buildfile new file mode 100644 index 0000000..0bb0b77 --- /dev/null +++ b/xsd-tests/cxx/tree/polymorphism/comparison/buildfile @@ -0,0 +1,25 @@ +# file : cxx/tree/polymorphism/comparison/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --generate-polymorphic \ + --polymorphic-type base \ + --generate-comparison \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/polymorphism/comparison/driver.cxx b/xsd-tests/cxx/tree/polymorphism/comparison/driver.cxx new file mode 100644 index 0000000..cadb225 --- /dev/null +++ b/xsd-tests/cxx/tree/polymorphism/comparison/driver.cxx @@ -0,0 +1,85 @@ +// file : cxx/tree/polymorphism/comparison/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test comparison of polymorphic object models. +// + +#include // std::auto_ptr/unique_ptr +#include +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + XSD_AUTO_PTR r (root (argv[1])); + + // Equals. + // + { + derived1 d ("a", 1); + d.b ("b"); + type r1 (d); + + assert (*r == r1); + } + + // Values are not equal. + // + { + derived1 d ("a", 1); + d.b ("c"); + type r1 (d); + + assert (*r != r1); + } + + // Values are not equal. + // + { + derived1 d ("a", 2); + d.b ("b"); + type r1 (d); + + assert (*r != r1); + } + + // Different types. + // + { + derived2 d ("a", 1); + d.c ().push_back ("c"); + type r1 (d); + + assert (*r != r1); + } + + xml_schema::namespace_infomap map; + + map["t"].name = "test"; + + stringstream s; + root (s, *r, map); + + XSD_AUTO_PTR c (root (s, xml_schema::flags::dont_validate)); + + assert (*r == *c); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/polymorphism/comparison/test.xml b/xsd-tests/cxx/tree/polymorphism/comparison/test.xml new file mode 100644 index 0000000..0b8c125 --- /dev/null +++ b/xsd-tests/cxx/tree/polymorphism/comparison/test.xml @@ -0,0 +1,7 @@ + + + a1b + + diff --git a/xsd-tests/cxx/tree/polymorphism/comparison/test.xsd b/xsd-tests/cxx/tree/polymorphism/comparison/test.xsd new file mode 100644 index 0000000..364d1b3 --- /dev/null +++ b/xsd-tests/cxx/tree/polymorphism/comparison/test.xsd @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/polymorphism/ostream/buildfile b/xsd-tests/cxx/tree/polymorphism/ostream/buildfile new file mode 100644 index 0000000..2237c73 --- /dev/null +++ b/xsd-tests/cxx/tree/polymorphism/ostream/buildfile @@ -0,0 +1,26 @@ +# file : cxx/tree/polymorphism/ostream/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-polymorphic \ + --polymorphic-type-all \ + --root-element root \ + --generate-ostream \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/polymorphism/ostream/driver.cxx b/xsd-tests/cxx/tree/polymorphism/ostream/driver.cxx new file mode 100644 index 0000000..b030be9 --- /dev/null +++ b/xsd-tests/cxx/tree/polymorphism/ostream/driver.cxx @@ -0,0 +1,34 @@ +// file : cxx/tree/polymorphism/ostream/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test printing of polymorphic object models. +// + +#include // std::auto_ptr/unique_ptr +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + XSD_AUTO_PTR r (root (argv[1])); + cout << *r << endl; + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/polymorphism/ostream/output b/xsd-tests/cxx/tree/polymorphism/ostream/output new file mode 100644 index 0000000..e7fbd68 --- /dev/null +++ b/xsd-tests/cxx/tree/polymorphism/ostream/output @@ -0,0 +1,18 @@ + +base: +a: a +fund: 1 +base: +a: a +fund: 1 +b: b +base: +a: a +fund: 1 +c: c1 +c: c2 +base: +a: a +fund: 1 +d: d1 +d: d2 diff --git a/xsd-tests/cxx/tree/polymorphism/ostream/test.xml b/xsd-tests/cxx/tree/polymorphism/ostream/test.xml new file mode 100644 index 0000000..5409d2a --- /dev/null +++ b/xsd-tests/cxx/tree/polymorphism/ostream/test.xml @@ -0,0 +1,10 @@ + + + a1 + a1b + a1c1c2 + a1d1d2 + + diff --git a/xsd-tests/cxx/tree/polymorphism/ostream/test.xsd b/xsd-tests/cxx/tree/polymorphism/ostream/test.xsd new file mode 100644 index 0000000..688cd5a --- /dev/null +++ b/xsd-tests/cxx/tree/polymorphism/ostream/test.xsd @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/polymorphism/same-type/buildfile b/xsd-tests/cxx/tree/polymorphism/same-type/buildfile new file mode 100644 index 0000000..46720d6 --- /dev/null +++ b/xsd-tests/cxx/tree/polymorphism/same-type/buildfile @@ -0,0 +1,25 @@ +# file : cxx/tree/polymorphism/same-type/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-polymorphic \ + --root-element root \ + --generate-ostream \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/polymorphism/same-type/driver.cxx b/xsd-tests/cxx/tree/polymorphism/same-type/driver.cxx new file mode 100644 index 0000000..94f82f5 --- /dev/null +++ b/xsd-tests/cxx/tree/polymorphism/same-type/driver.cxx @@ -0,0 +1,35 @@ +// file : cxx/tree/polymorphism/same-type/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test substitution group and xsi:type that don't change the type. +// + +#include // std::auto_ptr/unique_ptr +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + XSD_AUTO_PTR r (root (argv[1])); + + cout << *r << endl; + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/polymorphism/same-type/output b/xsd-tests/cxx/tree/polymorphism/same-type/output new file mode 100644 index 0000000..04b5cbf --- /dev/null +++ b/xsd-tests/cxx/tree/polymorphism/same-type/output @@ -0,0 +1,9 @@ + +base: +a: a1 +base: +a: a2 +base: +a: a3 +base: +a: a4 diff --git a/xsd-tests/cxx/tree/polymorphism/same-type/test.xml b/xsd-tests/cxx/tree/polymorphism/same-type/test.xml new file mode 100644 index 0000000..f8b6d1e --- /dev/null +++ b/xsd-tests/cxx/tree/polymorphism/same-type/test.xml @@ -0,0 +1,10 @@ + + + a1 + a2 + a3 + a4 + + diff --git a/xsd-tests/cxx/tree/polymorphism/same-type/test.xsd b/xsd-tests/cxx/tree/polymorphism/same-type/test.xsd new file mode 100644 index 0000000..a4157d3 --- /dev/null +++ b/xsd-tests/cxx/tree/polymorphism/same-type/test.xsd @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/prefix/.gitignore b/xsd-tests/cxx/tree/prefix/.gitignore new file mode 100644 index 0000000..2457930 --- /dev/null +++ b/xsd-tests/cxx/tree/prefix/.gitignore @@ -0,0 +1,2 @@ +bar.?xx +foo.?xx diff --git a/xsd-tests/cxx/tree/prefix/bar.xsd b/xsd-tests/cxx/tree/prefix/bar.xsd new file mode 100644 index 0000000..4e20902 --- /dev/null +++ b/xsd-tests/cxx/tree/prefix/bar.xsd @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/prefix/buildfile b/xsd-tests/cxx/tree/prefix/buildfile new file mode 100644 index 0000000..7ac81de --- /dev/null +++ b/xsd-tests/cxx/tree/prefix/buildfile @@ -0,0 +1,31 @@ +# file : cxx/tree/prefix/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +fs = foo bar test + +exe{driver}: {hxx cxx}{* -{$fs}} {hxx ixx cxx}{$fs} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +for f: $fs +{ + <{hxx ixx cxx}{$f}>: xsd{$f} $xsd + {{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --generate-polymorphic \ + --polymorphic-type 'foo#base' \ + --root-element root \ + --output-dir $out_base \ + $path($<[0]) + }} +} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/prefix/driver.cxx b/xsd-tests/cxx/tree/prefix/driver.cxx new file mode 100644 index 0000000..bd2e46d --- /dev/null +++ b/xsd-tests/cxx/tree/prefix/driver.cxx @@ -0,0 +1,34 @@ +// file : cxx/tree/prefix/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test automatic prefix assignment. +// + +#include // std::auto_ptr/unique_ptr +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + XSD_AUTO_PTR r (root (argv[1])); + root (std::cout, *r); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/prefix/foo.xsd b/xsd-tests/cxx/tree/prefix/foo.xsd new file mode 100644 index 0000000..97a35cf --- /dev/null +++ b/xsd-tests/cxx/tree/prefix/foo.xsd @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/prefix/output b/xsd-tests/cxx/tree/prefix/output new file mode 100644 index 0000000..9801a23 --- /dev/null +++ b/xsd-tests/cxx/tree/prefix/output @@ -0,0 +1,18 @@ + + + + 123 + + + + 1 + 2 + + + + + 1 + 2 + + + diff --git a/xsd-tests/cxx/tree/prefix/test.xml b/xsd-tests/cxx/tree/prefix/test.xml new file mode 100644 index 0000000..b6d0dd6 --- /dev/null +++ b/xsd-tests/cxx/tree/prefix/test.xml @@ -0,0 +1,19 @@ + + + + 123 + + + + 12 + + + + 12 + + + diff --git a/xsd-tests/cxx/tree/prefix/test.xsd b/xsd-tests/cxx/tree/prefix/test.xsd new file mode 100644 index 0000000..421fdc0 --- /dev/null +++ b/xsd-tests/cxx/tree/prefix/test.xsd @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/test-template/buildfile b/xsd-tests/cxx/tree/test-template/buildfile new file mode 100644 index 0000000..b50e6c3 --- /dev/null +++ b/xsd-tests/cxx/tree/test-template/buildfile @@ -0,0 +1,23 @@ +# file : cxx/tree/test-template/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-ostream \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/test-template/driver.cxx b/xsd-tests/cxx/tree/test-template/driver.cxx new file mode 100644 index 0000000..5257279 --- /dev/null +++ b/xsd-tests/cxx/tree/test-template/driver.cxx @@ -0,0 +1,35 @@ +// file : cxx/tree/test-template/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Insert test description here. +// + +#include // std::auto_ptr/unique_ptr +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + XSD_AUTO_PTR r (root (argv[1])); + + cout << *r << endl; + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/tree/test-template/output b/xsd-tests/cxx/tree/test-template/output new file mode 100644 index 0000000..2a50681 --- /dev/null +++ b/xsd-tests/cxx/tree/test-template/output @@ -0,0 +1,2 @@ + +a: a diff --git a/xsd-tests/cxx/tree/test-template/test.xml b/xsd-tests/cxx/tree/test-template/test.xml new file mode 100644 index 0000000..624a80c --- /dev/null +++ b/xsd-tests/cxx/tree/test-template/test.xml @@ -0,0 +1,7 @@ + + + a + + diff --git a/xsd-tests/cxx/tree/test-template/test.xsd b/xsd-tests/cxx/tree/test-template/test.xsd new file mode 100644 index 0000000..07bebc7 --- /dev/null +++ b/xsd-tests/cxx/tree/test-template/test.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/types-only/buildfile b/xsd-tests/cxx/tree/types-only/buildfile new file mode 100644 index 0000000..fa02277 --- /dev/null +++ b/xsd-tests/cxx/tree/types-only/buildfile @@ -0,0 +1,20 @@ +# file : cxx/tree/types-only/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --suppress-parsing \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/types-only/driver.cxx b/xsd-tests/cxx/tree/types-only/driver.cxx new file mode 100644 index 0000000..730b807 --- /dev/null +++ b/xsd-tests/cxx/tree/types-only/driver.cxx @@ -0,0 +1,30 @@ +// file : cxx/tree/types-only/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test that code generated without parsing and serialization functions +// still compiles. +// + +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main () +{ + color_enum red (color_enum::red); + red_blue_enum blue (red_blue_enum::blue); + + long_string_union num ("123"); + + string_list list; + list.push_back ("Hello"); + list.push_back ("World"); + + complex_type t ("Hello, World!", "foo", color_enum::red); + + anon a ("Hello, World!"); +} diff --git a/xsd-tests/cxx/tree/types-only/test.xsd b/xsd-tests/cxx/tree/types-only/test.xsd new file mode 100644 index 0000000..9f02240 --- /dev/null +++ b/xsd-tests/cxx/tree/types-only/test.xsd @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/union/ctor/buildfile b/xsd-tests/cxx/tree/union/ctor/buildfile new file mode 100644 index 0000000..6715cb6 --- /dev/null +++ b/xsd-tests/cxx/tree/union/ctor/buildfile @@ -0,0 +1,22 @@ +# file : cxx/tree/union/ctor/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-default-ctor \ + --generate-from-base-ctor \ + --generate-doxygen \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/union/ctor/driver.cxx b/xsd-tests/cxx/tree/union/ctor/driver.cxx new file mode 100644 index 0000000..246eea8 --- /dev/null +++ b/xsd-tests/cxx/tree/union/ctor/driver.cxx @@ -0,0 +1,30 @@ +// file : cxx/tree/union/ctor/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test union constructors. +// +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main () +{ + // Test ctor(const std::string&) + // + { + string const s ("123"); + int_string_union u (s); + type t (s); + } + + // Test ctor(const char*). + // + { + int_string_union u ("123"); + type t ("123"); + } +} diff --git a/xsd-tests/cxx/tree/union/ctor/test.xsd b/xsd-tests/cxx/tree/union/ctor/test.xsd new file mode 100644 index 0000000..9601093 --- /dev/null +++ b/xsd-tests/cxx/tree/union/ctor/test.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/tree/wildcard/buildfile b/xsd-tests/cxx/tree/wildcard/buildfile new file mode 100644 index 0000000..67edcdc --- /dev/null +++ b/xsd-tests/cxx/tree/wildcard/buildfile @@ -0,0 +1,27 @@ +# file : cxx/tree/wildcard/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx ixx cxx}{test} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --generate-serialization \ + --generate-wildcard \ + --generate-default-ctor \ + --generate-from-base-ctor \ + --generate-comparison \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/tree/wildcard/driver.cxx b/xsd-tests/cxx/tree/wildcard/driver.cxx new file mode 100644 index 0000000..e3040c7 --- /dev/null +++ b/xsd-tests/cxx/tree/wildcard/driver.cxx @@ -0,0 +1,203 @@ +// file : cxx/tree/wildcard/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test wildcard (any & anyAttribute) mapping. +// + +#include // std::auto_ptr/unique_ptr +#include +#include + +#include +#include + +#include "test.hxx" // Get XSD_CXX11 defined. + +#include + +using namespace std; +using namespace test; +using namespace xercesc; + +namespace xml = xsd::cxx::xml; + +void +print (type& t) +{ + if (t.att ()) + cout << *t.att () << endl; + + type::any_attribute_set& as (t.any_attribute ()); + + for (type::any_attribute_iterator i (as.begin ()); i != as.end (); ++i) + { + cout << xml::transcode (i->getTextContent ()) << endl; + } + + cout << xml::transcode (t.any ().getTextContent ()) << endl + << t.foo () << endl; + + if (t.any1 ()) + cout << xml::transcode (t.any1 ()->getTextContent ()) << endl; + + cout << t.bar () << endl; + + type::any2_sequence& es (t.any2 ()); + + for (type::any2_iterator i (es.begin ()); i != es.end (); ++i) + { + cout << xml::transcode (i->getTextContent ()) << endl; + } + + cout << endl; +} + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + XMLPlatformUtils::Initialize (); + + try + { + // Test accessors/modifiers for various cardinalities. + // + type t; + + DOMDocument& doc (t.dom_document ()); + + // one + // + { + DOMElement* e (doc.createElement (xml::string ("a").c_str ())); + t.any (*e); + e->release (); + assert (xml::transcode (t.any ().getTagName ()) == "a"); + + t.any (doc.createElement (xml::string ("b").c_str ())); + assert (xml::transcode (t.any ().getTagName ()) == "b"); + } + + // optional + // + { + assert (!t.any1 ().present ()); + + DOMElement* e (doc.createElement (xml::string ("a").c_str ())); + t.any1 (*e); + e->release (); + assert (t.any1 ().present ()); + assert (xml::transcode (t.any1 ().get ().getTagName ()) == "a"); + + t.any1 (doc.createElement (xml::string ("b").c_str ())); + assert (xml::transcode (t.any1 ()->getTagName ()) == "b"); + + type::any1_optional c ( + doc.createElement (xml::string ("c").c_str ()), doc); + t.any1 (c); + assert (xml::transcode (t.any1 ()->getTagName ()) == "c"); + } + + + // sequence + // + { + type::any2_sequence& s (t.any2 ()); + + DOMElement* e (doc.createElement (xml::string ("a").c_str ())); + s.push_back (*e); + e->release (); + s.push_back (doc.createElement (xml::string ("b").c_str ())); + assert (s.size () == 2); + + for (type::any2_iterator i (s.begin ()); i != s.end (); ++i) + { + if (i == s.begin ()) + assert (xml::transcode (i->getTagName ()) == "a"); + else + assert (xml::transcode ((*i).getTagName ()) == "b"); + } + + // copy c-tor + type::any2_sequence cs (s, doc); + assert (cs.size () == 2); + assert (xml::transcode (cs[0].getTagName ()) == "a"); + assert (xml::transcode (cs[1].getTagName ()) == "b"); + + // assignment + t.any2 (cs); + assert (s.size () == 2); + assert (xml::transcode (s[0].getTagName ()) == "a"); + assert (xml::transcode (s[1].getTagName ()) == "b"); + } + + // anyAttribute + // + { + type::any_attribute_set& s (t.any_attribute ()); + + DOMAttr* a (doc.createAttribute (xml::string ("a").c_str ())); + s.insert (*a); + a->release (); + s.insert (doc.createAttribute (xml::string ("b").c_str ())); + assert (s.size () == 2); + + assert (s.find ("a") != s.end ()); + assert (s.find ("b") != s.end ()); + + for (type::any_attribute_iterator i (s.begin ()); i != s.end (); ++i) + { + assert (xml::transcode (i->getName ()) == "a" || + xml::transcode ((*i).getName ()) == "b"); + } + + // copy c-tor + type::any_attribute_set cs (s, doc); + assert (cs.size () == 2); + assert (cs.count ("a")); + assert (cs.count ("b")); + + // assignment + t.any_attribute (cs); + assert (s.size () == 2); + assert (s.count ("a")); + assert (s.count ("b")); + } + + // Test parsing + // + XSD_AUTO_PTR r (root (argv[1])); + print (*r); + + // Test serialization. + // + xml_schema::namespace_infomap map; + + map["t"].name = "test"; + map["t"].schema = "test.xsd"; + map["o"].name = "other"; + + stringstream iostr; + root (iostr, *r, map); + + // cout << iostr.str () << endl + // << endl; + + XSD_AUTO_PTR copy (root (iostr, argv[1])); + assert (*copy == *r); + + print (*copy); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + + XMLPlatformUtils::Terminate (); +} diff --git a/xsd-tests/cxx/tree/wildcard/output b/xsd-tests/cxx/tree/wildcard/output new file mode 100644 index 0000000..b23b488 --- /dev/null +++ b/xsd-tests/cxx/tree/wildcard/output @@ -0,0 +1,24 @@ +att +any +o:any +t:any +o:one +foo +t:bar +bar +o:one1 +o:one2 +o:one3 + +att +any +o:any +t:any +o:one +foo +t:bar +bar +o:one1 +o:one2 +o:one3 + diff --git a/xsd-tests/cxx/tree/wildcard/test.xml b/xsd-tests/cxx/tree/wildcard/test.xml new file mode 100644 index 0000000..b0c3267 --- /dev/null +++ b/xsd-tests/cxx/tree/wildcard/test.xml @@ -0,0 +1,19 @@ + + + o:one + foo + t:bar + bar + o:one1 + o:one2 + o:one3 + + diff --git a/xsd-tests/cxx/tree/wildcard/test.xsd b/xsd-tests/cxx/tree/wildcard/test.xsd new file mode 100644 index 0000000..6c7b308 --- /dev/null +++ b/xsd-tests/cxx/tree/wildcard/test.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/failed/.gitignore b/xsd-tests/failed/.gitignore new file mode 100644 index 0000000..f691ede --- /dev/null +++ b/xsd-tests/failed/.gitignore @@ -0,0 +1 @@ +test-*.?xx diff --git a/xsd-tests/failed/buildfile b/xsd-tests/failed/buildfile new file mode 100644 index 0000000..8739001 --- /dev/null +++ b/xsd-tests/failed/buildfile @@ -0,0 +1,27 @@ +# file : failed/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +fs = test-00 + +exe{driver}: {hxx cxx}{* -{$fs}} {hxx cxx}{$fs} $libs + +for f: $fs +{ + <{hxx cxx}{$f}>: xsd{$f} $xsd + {{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) + }} +} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/failed/driver.cxx b/xsd-tests/failed/driver.cxx new file mode 100644 index 0000000..a84b24c --- /dev/null +++ b/xsd-tests/failed/driver.cxx @@ -0,0 +1,9 @@ +// file : failed/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "test-00.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/failed/test-00.xsd b/xsd-tests/failed/test-00.xsd new file mode 100644 index 0000000..5223f82 --- /dev/null +++ b/xsd-tests/failed/test-00.xsd @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/xsd-tests/manifest b/xsd-tests/manifest new file mode 100644 index 0000000..7e2e893 --- /dev/null +++ b/xsd-tests/manifest @@ -0,0 +1,15 @@ +: 1 +name: xsd-tests +version: 4.2.0-b.1.z +project: xsd +summary: XML Schema to C++ data binding compiler tests +license: other: GPL-2.0-only with Xerces-C++ linking exception and FLOSS exception +description-file: README +url: https://www.codesynthesis.com/projects/xsd/ +doc-url: https://www.codesynthesis.com/projects/xsd/ +src-url: https://git.codesynthesis.com/cgit/xsd/xsd/tree/xsd-tests/ +email: xsd-users@codesynthesis.com ; Mailing list +depends: * build2 >= 0.13.0 +depends: * bpkg >= 0.13.0 +depends: libxsd == $ +depends: libxerces-c ^3.0.0 diff --git a/xsd-tests/morphing/anonymous/attribute-group/buildfile b/xsd-tests/morphing/anonymous/attribute-group/buildfile new file mode 100644 index 0000000..3df24fc --- /dev/null +++ b/xsd-tests/morphing/anonymous/attribute-group/buildfile @@ -0,0 +1,22 @@ +# file : morphing/anonymous/attribute-group/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx cxx}{test} $libs + +<{hxx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/morphing/anonymous/attribute-group/driver.cxx b/xsd-tests/morphing/anonymous/attribute-group/driver.cxx new file mode 100644 index 0000000..1632d7d --- /dev/null +++ b/xsd-tests/morphing/anonymous/attribute-group/driver.cxx @@ -0,0 +1,9 @@ +// file : morphing/anonymous/attribute-group/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "test.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/morphing/anonymous/attribute-group/test.xsd b/xsd-tests/morphing/anonymous/attribute-group/test.xsd new file mode 100644 index 0000000..657be8a --- /dev/null +++ b/xsd-tests/morphing/anonymous/attribute-group/test.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/morphing/anonymous/basic/buildfile b/xsd-tests/morphing/anonymous/basic/buildfile new file mode 100644 index 0000000..e2573e7 --- /dev/null +++ b/xsd-tests/morphing/anonymous/basic/buildfile @@ -0,0 +1,22 @@ +# file : morphing/anonymous/basic/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx cxx}{test} $libs + +<{hxx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/morphing/anonymous/basic/driver.cxx b/xsd-tests/morphing/anonymous/basic/driver.cxx new file mode 100644 index 0000000..fc289eb --- /dev/null +++ b/xsd-tests/morphing/anonymous/basic/driver.cxx @@ -0,0 +1,9 @@ +// file : morphing/anonymous/basic/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "test.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/morphing/anonymous/basic/test.xsd b/xsd-tests/morphing/anonymous/basic/test.xsd new file mode 100644 index 0000000..ce930d8 --- /dev/null +++ b/xsd-tests/morphing/anonymous/basic/test.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/morphing/anonymous/cyclic-inclusion/.gitignore b/xsd-tests/morphing/anonymous/cyclic-inclusion/.gitignore new file mode 100644 index 0000000..b27b7d8 --- /dev/null +++ b/xsd-tests/morphing/anonymous/cyclic-inclusion/.gitignore @@ -0,0 +1,2 @@ +includee.?xx +includer.?xx diff --git a/xsd-tests/morphing/anonymous/cyclic-inclusion/buildfile b/xsd-tests/morphing/anonymous/cyclic-inclusion/buildfile new file mode 100644 index 0000000..d25143a --- /dev/null +++ b/xsd-tests/morphing/anonymous/cyclic-inclusion/buildfile @@ -0,0 +1,27 @@ +# file : morphing/anonymous/cyclic-inclusion/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +fs = includee includer + +exe{driver}: {hxx cxx}{* -{$fs}} {hxx cxx}{$fs} $libs + +for f: $fs +{ + <{hxx cxx}{$f}>: xsd{$f} $xsd + {{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) + }} +} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/morphing/anonymous/cyclic-inclusion/driver.cxx b/xsd-tests/morphing/anonymous/cyclic-inclusion/driver.cxx new file mode 100644 index 0000000..9046ee4 --- /dev/null +++ b/xsd-tests/morphing/anonymous/cyclic-inclusion/driver.cxx @@ -0,0 +1,10 @@ +// file : morphing/anonymous/cyclic-inclusion/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "includee.hxx" +#include "includer.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/morphing/anonymous/cyclic-inclusion/includee.xsd b/xsd-tests/morphing/anonymous/cyclic-inclusion/includee.xsd new file mode 100644 index 0000000..51f7916 --- /dev/null +++ b/xsd-tests/morphing/anonymous/cyclic-inclusion/includee.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/xsd-tests/morphing/anonymous/cyclic-inclusion/includer.xsd b/xsd-tests/morphing/anonymous/cyclic-inclusion/includer.xsd new file mode 100644 index 0000000..54e6b69 --- /dev/null +++ b/xsd-tests/morphing/anonymous/cyclic-inclusion/includer.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/xsd-tests/morphing/anonymous/group/buildfile b/xsd-tests/morphing/anonymous/group/buildfile new file mode 100644 index 0000000..9cedf39 --- /dev/null +++ b/xsd-tests/morphing/anonymous/group/buildfile @@ -0,0 +1,22 @@ +# file : morphing/anonymous/group/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx cxx}{test} $libs + +<{hxx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/morphing/anonymous/group/driver.cxx b/xsd-tests/morphing/anonymous/group/driver.cxx new file mode 100644 index 0000000..2a76396 --- /dev/null +++ b/xsd-tests/morphing/anonymous/group/driver.cxx @@ -0,0 +1,9 @@ +// file : morphing/anonymous/group/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "test.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/morphing/anonymous/group/test.xsd b/xsd-tests/morphing/anonymous/group/test.xsd new file mode 100644 index 0000000..73e07af --- /dev/null +++ b/xsd-tests/morphing/anonymous/group/test.xsd @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/morphing/anonymous/unstable/.gitignore b/xsd-tests/morphing/anonymous/unstable/.gitignore new file mode 100644 index 0000000..c1b04fd --- /dev/null +++ b/xsd-tests/morphing/anonymous/unstable/.gitignore @@ -0,0 +1 @@ +includee-*.?xx diff --git a/xsd-tests/morphing/anonymous/unstable/buildfile b/xsd-tests/morphing/anonymous/unstable/buildfile new file mode 100644 index 0000000..e83cee7 --- /dev/null +++ b/xsd-tests/morphing/anonymous/unstable/buildfile @@ -0,0 +1,31 @@ +# file : morphing/anonymous/unstable/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +fs = includee-1 includee-2 + +./: {hxx cxx}{$fs} + +# Make sure that the schema files are compilable. +# +for f: $fs +{ + <{hxx cxx}{$f}>: xsd{$f} $xsd + {{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) + }} +} + +# Test that the invalid schema files compilation expectedly fails. +# +./: testscript xsd{** -{$fs}} $xsd + +testscript{*}: +{ + test = $xsd + test.arguments = cxx-tree --std c++11 +} diff --git a/xsd-tests/morphing/anonymous/unstable/includee-1.xsd b/xsd-tests/morphing/anonymous/unstable/includee-1.xsd new file mode 100644 index 0000000..916816f --- /dev/null +++ b/xsd-tests/morphing/anonymous/unstable/includee-1.xsd @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/xsd-tests/morphing/anonymous/unstable/includee-2.xsd b/xsd-tests/morphing/anonymous/unstable/includee-2.xsd new file mode 100644 index 0000000..c0eda26 --- /dev/null +++ b/xsd-tests/morphing/anonymous/unstable/includee-2.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/xsd-tests/morphing/anonymous/unstable/includer.xsd b/xsd-tests/morphing/anonymous/unstable/includer.xsd new file mode 100644 index 0000000..4593b5f --- /dev/null +++ b/xsd-tests/morphing/anonymous/unstable/includer.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/xsd-tests/morphing/anonymous/unstable/testscript b/xsd-tests/morphing/anonymous/unstable/testscript new file mode 100644 index 0000000..a9057e1 --- /dev/null +++ b/xsd-tests/morphing/anonymous/unstable/testscript @@ -0,0 +1,11 @@ +# file : morphing/anonymous/unstable/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +: unstable-conflict +: +$* --output-dir $~ $src_base/includer.xsd 2>>/"EOE" != 0 + $src_base/includee-2.xsd:8:28: error: element name 'base' creates an unstable conflict when used as a type name + $src_base/includee-1.xsd:8:31: info: conflicting type is defined here + $src_base/includee-2.xsd:8:28: info: use --anonymous-regex to resolve this conflict + $src_base/includee-2.xsd:8:28: info: and don't forget to pass the same option when translating 'includee-2.xsd' and all the schemas that refer to it + EOE diff --git a/xsd-tests/processing/inheritance/.gitignore b/xsd-tests/processing/inheritance/.gitignore new file mode 100644 index 0000000..2c7adec --- /dev/null +++ b/xsd-tests/processing/inheritance/.gitignore @@ -0,0 +1,3 @@ +driver-??? +driver-???.?xx +test-*.?xx diff --git a/xsd-tests/processing/inheritance/buildfile b/xsd-tests/processing/inheritance/buildfile new file mode 100644 index 0000000..09e64a4 --- /dev/null +++ b/xsd-tests/processing/inheritance/buildfile @@ -0,0 +1,36 @@ +# file : processing/inheritance/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +for nm: 000 001 +{ + dr = "driver-$nm" + sc = "test-$nm" + + ./: exe{$dr}: cxx{$dr} {hxx cxx}{$sc} $libs + + cxx{$dr}: in{driver} + { + # Note: we can't use $nm$ in driver.cxx.in since it will be substituted by + # the latest $nm value. + # + num = $nm + } + + <{hxx cxx}{$sc}>: xsd{$sc} $xsd + {{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) + }} +} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/processing/inheritance/driver.cxx.in b/xsd-tests/processing/inheritance/driver.cxx.in new file mode 100644 index 0000000..df18427 --- /dev/null +++ b/xsd-tests/processing/inheritance/driver.cxx.in @@ -0,0 +1,9 @@ +// file : processing/inheritance/driver.cxx.in +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "test-$num$.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/processing/inheritance/test-000.xsd b/xsd-tests/processing/inheritance/test-000.xsd new file mode 100644 index 0000000..ef1ef71 --- /dev/null +++ b/xsd-tests/processing/inheritance/test-000.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/processing/inheritance/test-001.xsd b/xsd-tests/processing/inheritance/test-001.xsd new file mode 100644 index 0000000..5afc997 --- /dev/null +++ b/xsd-tests/processing/inheritance/test-001.xsd @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/anonymous/buildfile b/xsd-tests/schema/anonymous/buildfile new file mode 100644 index 0000000..cc01697 --- /dev/null +++ b/xsd-tests/schema/anonymous/buildfile @@ -0,0 +1,22 @@ +# file : schema/anonymous/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx cxx}{test} $libs + +<{hxx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/schema/anonymous/driver.cxx b/xsd-tests/schema/anonymous/driver.cxx new file mode 100644 index 0000000..f902fdb --- /dev/null +++ b/xsd-tests/schema/anonymous/driver.cxx @@ -0,0 +1,9 @@ +// file : schema/anonymous/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "test.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/schema/anonymous/test.xsd b/xsd-tests/schema/anonymous/test.xsd new file mode 100644 index 0000000..cba3300 --- /dev/null +++ b/xsd-tests/schema/anonymous/test.xsd @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/any-attribute/buildfile b/xsd-tests/schema/any-attribute/buildfile new file mode 100644 index 0000000..e4275a4 --- /dev/null +++ b/xsd-tests/schema/any-attribute/buildfile @@ -0,0 +1,12 @@ +# file : schema/any-attribute/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Test that the invalid schema files compilation expectedly fails. +# +./: testscript xsd{*} $xsd + +testscript{*}: +{ + test = $xsd + test.arguments = cxx-tree --std c++11 +} diff --git a/xsd-tests/schema/any-attribute/test.xsd b/xsd-tests/schema/any-attribute/test.xsd new file mode 100644 index 0000000..55419c4 --- /dev/null +++ b/xsd-tests/schema/any-attribute/test.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/any-attribute/testscript b/xsd-tests/schema/any-attribute/testscript new file mode 100644 index 0000000..d9da7c1 --- /dev/null +++ b/xsd-tests/schema/any-attribute/testscript @@ -0,0 +1,8 @@ +# file : schema/any-attribute/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +: decl-after-any-attribute +: +$* --output-dir $~ $src_base/test.xsd 2>>/"EOE" != 0 + $src_base/test.xsd:12:44: error: anyAttribute must not be followed by other declarations + EOE diff --git a/xsd-tests/schema/any-type/buildfile b/xsd-tests/schema/any-type/buildfile new file mode 100644 index 0000000..e575562 --- /dev/null +++ b/xsd-tests/schema/any-type/buildfile @@ -0,0 +1,24 @@ +# file : schema/any-type/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx cxx}{test} $libs + +<{hxx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) 2>>?~%EOE% + %.+(warning F00\d|info):.+%.+ + EOE +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/schema/any-type/driver.cxx b/xsd-tests/schema/any-type/driver.cxx new file mode 100644 index 0000000..a94f099 --- /dev/null +++ b/xsd-tests/schema/any-type/driver.cxx @@ -0,0 +1,9 @@ +// file : schema/any-type/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "test.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/schema/any-type/test.xsd b/xsd-tests/schema/any-type/test.xsd new file mode 100644 index 0000000..9e3ff79 --- /dev/null +++ b/xsd-tests/schema/any-type/test.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/any/.gitignore b/xsd-tests/schema/any/.gitignore new file mode 100644 index 0000000..fca6147 --- /dev/null +++ b/xsd-tests/schema/any/.gitignore @@ -0,0 +1,5 @@ +driver-test +driver-fail +driver-test.?xx +driver-fail.?xx +fail.?xx diff --git a/xsd-tests/schema/any/buildfile b/xsd-tests/schema/any/buildfile new file mode 100644 index 0000000..6b76348 --- /dev/null +++ b/xsd-tests/schema/any/buildfile @@ -0,0 +1,47 @@ +# file : schema/any/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +for sc: test fail +{ + dr = "driver-$sc" + + ./: exe{$dr}: cxx{$dr} {hxx cxx}{$sc} $libs + + cxx{$dr}: in{driver} + { + # Note: we can't use $sc$ in driver.cxx.in since it will be substituted by + # the latest $sc value. + # + sch = $sc + } +} + +<{hxx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) +}} + +<{hxx cxx}{fail}>: xsd{fail} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) 2>>?~%EOE% + %.+(warning T001:|info:).+%{9} + EOE +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/schema/any/driver.cxx.in b/xsd-tests/schema/any/driver.cxx.in new file mode 100644 index 0000000..9c36761 --- /dev/null +++ b/xsd-tests/schema/any/driver.cxx.in @@ -0,0 +1,9 @@ +// file : schema/any/driver.cxx.in +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "$sch$.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/schema/any/fail.xsd b/xsd-tests/schema/any/fail.xsd new file mode 100644 index 0000000..2eb9513 --- /dev/null +++ b/xsd-tests/schema/any/fail.xsd @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/any/test.xsd b/xsd-tests/schema/any/test.xsd new file mode 100644 index 0000000..ff896fd --- /dev/null +++ b/xsd-tests/schema/any/test.xsd @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/attribute-group/.gitignore b/xsd-tests/schema/attribute-group/.gitignore new file mode 100644 index 0000000..a935c30 --- /dev/null +++ b/xsd-tests/schema/attribute-group/.gitignore @@ -0,0 +1 @@ +global.?xx diff --git a/xsd-tests/schema/attribute-group/buildfile b/xsd-tests/schema/attribute-group/buildfile new file mode 100644 index 0000000..b9ca83b --- /dev/null +++ b/xsd-tests/schema/attribute-group/buildfile @@ -0,0 +1,22 @@ +# file : schema/attribute-group/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -global} {hxx cxx}{global} $libs + +<{hxx cxx}{global}>: xsd{global} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/schema/attribute-group/driver.cxx b/xsd-tests/schema/attribute-group/driver.cxx new file mode 100644 index 0000000..328cef4 --- /dev/null +++ b/xsd-tests/schema/attribute-group/driver.cxx @@ -0,0 +1,9 @@ +// file : schema/attribute-group/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "global.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/schema/attribute-group/global.xsd b/xsd-tests/schema/attribute-group/global.xsd new file mode 100644 index 0000000..6ee0539 --- /dev/null +++ b/xsd-tests/schema/attribute-group/global.xsd @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/attribute/.gitignore b/xsd-tests/schema/attribute/.gitignore new file mode 100644 index 0000000..88cd012 --- /dev/null +++ b/xsd-tests/schema/attribute/.gitignore @@ -0,0 +1,3 @@ +global.?xx +local.?xx +ref.?xx diff --git a/xsd-tests/schema/attribute/buildfile b/xsd-tests/schema/attribute/buildfile new file mode 100644 index 0000000..00e5410 --- /dev/null +++ b/xsd-tests/schema/attribute/buildfile @@ -0,0 +1,27 @@ +# file : schema/attribute/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +fs = global local ref + +exe{driver}: {hxx cxx}{* -{$fs}} {hxx cxx}{$fs} $libs + +for f: $fs +{ + <{hxx cxx}{$f}>: xsd{$f} $xsd + {{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) + }} +} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/schema/attribute/driver.cxx b/xsd-tests/schema/attribute/driver.cxx new file mode 100644 index 0000000..3d29b36 --- /dev/null +++ b/xsd-tests/schema/attribute/driver.cxx @@ -0,0 +1,11 @@ +// file : schema/attribute/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "ref.hxx" +#include "global.hxx" +#include "local.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/schema/attribute/global.xsd b/xsd-tests/schema/attribute/global.xsd new file mode 100644 index 0000000..e2dcc93 --- /dev/null +++ b/xsd-tests/schema/attribute/global.xsd @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/attribute/local.xsd b/xsd-tests/schema/attribute/local.xsd new file mode 100644 index 0000000..7a7a480 --- /dev/null +++ b/xsd-tests/schema/attribute/local.xsd @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/attribute/ref.xsd b/xsd-tests/schema/attribute/ref.xsd new file mode 100644 index 0000000..d806ff3 --- /dev/null +++ b/xsd-tests/schema/attribute/ref.xsd @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/cardinality/buildfile b/xsd-tests/schema/cardinality/buildfile new file mode 100644 index 0000000..cfbb732 --- /dev/null +++ b/xsd-tests/schema/cardinality/buildfile @@ -0,0 +1,22 @@ +# file : schema/cardinality/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx cxx}{test} $libs + +<{hxx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/schema/cardinality/driver.cxx b/xsd-tests/schema/cardinality/driver.cxx new file mode 100644 index 0000000..d8b218e --- /dev/null +++ b/xsd-tests/schema/cardinality/driver.cxx @@ -0,0 +1,9 @@ +// file : schema/cardinality/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "test.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/schema/cardinality/test.xsd b/xsd-tests/schema/cardinality/test.xsd new file mode 100644 index 0000000..b27f923 --- /dev/null +++ b/xsd-tests/schema/cardinality/test.xsd @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/chameleon/.gitignore b/xsd-tests/schema/chameleon/.gitignore new file mode 100644 index 0000000..4ec7484 --- /dev/null +++ b/xsd-tests/schema/chameleon/.gitignore @@ -0,0 +1 @@ +includer.?xx diff --git a/xsd-tests/schema/chameleon/buildfile b/xsd-tests/schema/chameleon/buildfile new file mode 100644 index 0000000..0143422 --- /dev/null +++ b/xsd-tests/schema/chameleon/buildfile @@ -0,0 +1,27 @@ +# file : schema/chameleon/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +fs = includer schemas/includee + +exe{driver}: {hxx cxx}{** -{$fs}} {hxx cxx}{$fs} $libs + +for f: $fs +{ + <{hxx cxx}{$f}>: xsd{$f} $xsd + {{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $directory($path($>[0])) \ + $path($<[0]) + }} +} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/schema/chameleon/driver.cxx b/xsd-tests/schema/chameleon/driver.cxx new file mode 100644 index 0000000..7b408ef --- /dev/null +++ b/xsd-tests/schema/chameleon/driver.cxx @@ -0,0 +1,10 @@ +// file : schema/chameleon/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "includer.hxx" +#include "schemas/includee.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/schema/chameleon/includer.xsd b/xsd-tests/schema/chameleon/includer.xsd new file mode 100644 index 0000000..c93ea18 --- /dev/null +++ b/xsd-tests/schema/chameleon/includer.xsd @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/xsd-tests/schema/chameleon/schemas/.gitignore b/xsd-tests/schema/chameleon/schemas/.gitignore new file mode 100644 index 0000000..dcf4bb9 --- /dev/null +++ b/xsd-tests/schema/chameleon/schemas/.gitignore @@ -0,0 +1 @@ +includee.?xx diff --git a/xsd-tests/schema/chameleon/schemas/includee.xsd b/xsd-tests/schema/chameleon/schemas/includee.xsd new file mode 100644 index 0000000..d89b9c4 --- /dev/null +++ b/xsd-tests/schema/chameleon/schemas/includee.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/xsd-tests/schema/enumeration/buildfile b/xsd-tests/schema/enumeration/buildfile new file mode 100644 index 0000000..efb6b9e --- /dev/null +++ b/xsd-tests/schema/enumeration/buildfile @@ -0,0 +1,22 @@ +# file : schema/enumeration/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx cxx}{test} $libs + +<{hxx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/schema/enumeration/driver.cxx b/xsd-tests/schema/enumeration/driver.cxx new file mode 100644 index 0000000..406c8ab --- /dev/null +++ b/xsd-tests/schema/enumeration/driver.cxx @@ -0,0 +1,9 @@ +// file : schema/enumeration/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "test.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/schema/enumeration/test.xsd b/xsd-tests/schema/enumeration/test.xsd new file mode 100644 index 0000000..b8253d9 --- /dev/null +++ b/xsd-tests/schema/enumeration/test.xsd @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/forward/buildfile b/xsd-tests/schema/forward/buildfile new file mode 100644 index 0000000..969f99f --- /dev/null +++ b/xsd-tests/schema/forward/buildfile @@ -0,0 +1,22 @@ +# file : schema/forward/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx cxx}{test} $libs + +<{hxx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/schema/forward/driver.cxx b/xsd-tests/schema/forward/driver.cxx new file mode 100644 index 0000000..ee6519e --- /dev/null +++ b/xsd-tests/schema/forward/driver.cxx @@ -0,0 +1,9 @@ +// file : schema/forward/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "test.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/schema/forward/test.xsd b/xsd-tests/schema/forward/test.xsd new file mode 100644 index 0000000..c7cc24e --- /dev/null +++ b/xsd-tests/schema/forward/test.xsd @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/group/.gitignore b/xsd-tests/schema/group/.gitignore new file mode 100644 index 0000000..a935c30 --- /dev/null +++ b/xsd-tests/schema/group/.gitignore @@ -0,0 +1 @@ +global.?xx diff --git a/xsd-tests/schema/group/buildfile b/xsd-tests/schema/group/buildfile new file mode 100644 index 0000000..dd926dd --- /dev/null +++ b/xsd-tests/schema/group/buildfile @@ -0,0 +1,27 @@ +# file : schema/group/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +fs = test global + +exe{driver}: {hxx cxx}{* -{$fs}} {hxx cxx}{$fs} $libs + +for f: $fs +{ + <{hxx cxx}{$f}>: xsd{$f} $xsd + {{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) + }} +} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/schema/group/driver.cxx b/xsd-tests/schema/group/driver.cxx new file mode 100644 index 0000000..e754194 --- /dev/null +++ b/xsd-tests/schema/group/driver.cxx @@ -0,0 +1,10 @@ +// file : schema/group/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "test.hxx" +#include "global.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/schema/group/global.xsd b/xsd-tests/schema/group/global.xsd new file mode 100644 index 0000000..27ccadf --- /dev/null +++ b/xsd-tests/schema/group/global.xsd @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/group/test.xsd b/xsd-tests/schema/group/test.xsd new file mode 100644 index 0000000..7527cbb --- /dev/null +++ b/xsd-tests/schema/group/test.xsd @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/import/.gitignore b/xsd-tests/schema/import/.gitignore new file mode 100644 index 0000000..6cdf6db --- /dev/null +++ b/xsd-tests/schema/import/.gitignore @@ -0,0 +1 @@ +importer.?xx diff --git a/xsd-tests/schema/import/buildfile b/xsd-tests/schema/import/buildfile new file mode 100644 index 0000000..9e6aec5 --- /dev/null +++ b/xsd-tests/schema/import/buildfile @@ -0,0 +1,27 @@ +# file : schema/import/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +fs = importer schemas/importee + +exe{driver}: {hxx cxx}{** -{$fs}} {hxx cxx}{$fs} $libs + +for f: $fs +{ + <{hxx cxx}{$f}>: xsd{$f} $xsd + {{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $directory($path($>[0])) \ + $path($<[0]) + }} +} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/schema/import/driver.cxx b/xsd-tests/schema/import/driver.cxx new file mode 100644 index 0000000..a94b2f3 --- /dev/null +++ b/xsd-tests/schema/import/driver.cxx @@ -0,0 +1,9 @@ +// file : schema/import/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "importer.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/schema/import/importer.xsd b/xsd-tests/schema/import/importer.xsd new file mode 100644 index 0000000..82fc33c --- /dev/null +++ b/xsd-tests/schema/import/importer.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/import/schemas/.gitignore b/xsd-tests/schema/import/schemas/.gitignore new file mode 100644 index 0000000..945fcfc --- /dev/null +++ b/xsd-tests/schema/import/schemas/.gitignore @@ -0,0 +1 @@ +importee.?xx diff --git a/xsd-tests/schema/import/schemas/importee.xsd b/xsd-tests/schema/import/schemas/importee.xsd new file mode 100644 index 0000000..9b03315 --- /dev/null +++ b/xsd-tests/schema/import/schemas/importee.xsd @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/xsd-tests/schema/include/.gitignore b/xsd-tests/schema/include/.gitignore new file mode 100644 index 0000000..4ec7484 --- /dev/null +++ b/xsd-tests/schema/include/.gitignore @@ -0,0 +1 @@ +includer.?xx diff --git a/xsd-tests/schema/include/buildfile b/xsd-tests/schema/include/buildfile new file mode 100644 index 0000000..904e819 --- /dev/null +++ b/xsd-tests/schema/include/buildfile @@ -0,0 +1,27 @@ +# file : schema/include/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +fs = includer schemas/includee + +exe{driver}: {hxx cxx}{** -{$fs}} {hxx cxx}{$fs} $libs + +for f: $fs +{ + <{hxx cxx}{$f}>: xsd{$f} $xsd + {{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $directory($path($>[0])) \ + $path($<[0]) + }} +} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/schema/include/driver.cxx b/xsd-tests/schema/include/driver.cxx new file mode 100644 index 0000000..779d9d6 --- /dev/null +++ b/xsd-tests/schema/include/driver.cxx @@ -0,0 +1,9 @@ +// file : schema/include/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "includer.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/schema/include/includer.xsd b/xsd-tests/schema/include/includer.xsd new file mode 100644 index 0000000..c93ea18 --- /dev/null +++ b/xsd-tests/schema/include/includer.xsd @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/xsd-tests/schema/include/schemas/.gitignore b/xsd-tests/schema/include/schemas/.gitignore new file mode 100644 index 0000000..dcf4bb9 --- /dev/null +++ b/xsd-tests/schema/include/schemas/.gitignore @@ -0,0 +1 @@ +includee.?xx diff --git a/xsd-tests/schema/include/schemas/includee.xsd b/xsd-tests/schema/include/schemas/includee.xsd new file mode 100644 index 0000000..0a928f5 --- /dev/null +++ b/xsd-tests/schema/include/schemas/includee.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/xsd-tests/schema/inheritance/.gitignore b/xsd-tests/schema/inheritance/.gitignore new file mode 100644 index 0000000..9891c35 --- /dev/null +++ b/xsd-tests/schema/inheritance/.gitignore @@ -0,0 +1 @@ +cycle.?xx diff --git a/xsd-tests/schema/inheritance/buildfile b/xsd-tests/schema/inheritance/buildfile new file mode 100644 index 0000000..48c6dde --- /dev/null +++ b/xsd-tests/schema/inheritance/buildfile @@ -0,0 +1,30 @@ +# file : schema/inheritance/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +fs = cycle sourced-forward/includer + +./: {hxx cxx}{$fs} + +# Make sure that the schema files are compilable. +# +for f: $fs +{ + <{hxx cxx}{$f}>: xsd{$f} $xsd + {{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --output-dir $directory($path($>[0])) \ + $path($<[0]) + }} +} + +# Test that the invalid schema files compilation expectedly fails. +# +./: testscript xsd{** -{$fs}} $xsd + +testscript{*}: +{ + test = $xsd + test.arguments = cxx-tree --std c++11 +} diff --git a/xsd-tests/schema/inheritance/cycle.xsd b/xsd-tests/schema/inheritance/cycle.xsd new file mode 100644 index 0000000..c705311 --- /dev/null +++ b/xsd-tests/schema/inheritance/cycle.xsd @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/inheritance/sourced-forward/.gitignore b/xsd-tests/schema/inheritance/sourced-forward/.gitignore new file mode 100644 index 0000000..4ec7484 --- /dev/null +++ b/xsd-tests/schema/inheritance/sourced-forward/.gitignore @@ -0,0 +1 @@ +includer.?xx diff --git a/xsd-tests/schema/inheritance/sourced-forward/includee.xsd b/xsd-tests/schema/inheritance/sourced-forward/includee.xsd new file mode 100644 index 0000000..531027d --- /dev/null +++ b/xsd-tests/schema/inheritance/sourced-forward/includee.xsd @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/xsd-tests/schema/inheritance/sourced-forward/includer.xsd b/xsd-tests/schema/inheritance/sourced-forward/includer.xsd new file mode 100644 index 0000000..7d18efc --- /dev/null +++ b/xsd-tests/schema/inheritance/sourced-forward/includer.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/xsd-tests/schema/inheritance/testscript b/xsd-tests/schema/inheritance/testscript new file mode 100644 index 0000000..5cc649d --- /dev/null +++ b/xsd-tests/schema/inheritance/testscript @@ -0,0 +1,8 @@ +# file : schema/inheritance/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +: base-not-found +: +$* --output-dir $~ $src_base/sourced-forward/includee.xsd 2>>/"EOE" != 0 + $src_base/sourced-forward/includee.xsd:7:35: error: base type 'Base' not found in 'Derived' definition + EOE diff --git a/xsd-tests/schema/list/anonymous/test.xsd b/xsd-tests/schema/list/anonymous/test.xsd new file mode 100644 index 0000000..7db39ba --- /dev/null +++ b/xsd-tests/schema/list/anonymous/test.xsd @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/xsd-tests/schema/list/any-simple-type/test.xsd b/xsd-tests/schema/list/any-simple-type/test.xsd new file mode 100644 index 0000000..29fe95c --- /dev/null +++ b/xsd-tests/schema/list/any-simple-type/test.xsd @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/xsd-tests/schema/list/buildfile b/xsd-tests/schema/list/buildfile new file mode 100644 index 0000000..5d8f7fc --- /dev/null +++ b/xsd-tests/schema/list/buildfile @@ -0,0 +1,31 @@ +# file : schema/list/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +fs = test anonymous/test + +./: {hxx cxx}{$fs} + +# Make sure that the schema files are compilable. +# +for f: $fs +{ + <{hxx cxx}{$f}>: xsd{$f} $xsd + {{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $directory($path($>[0])) \ + $path($<[0]) + }} +} + +# Test that the invalid schema files compilation expectedly fails. +# +./: testscript xsd{** -{$fs}} $xsd + +testscript{*}: +{ + test = $xsd + test.arguments = cxx-tree --std c++11 +} diff --git a/xsd-tests/schema/list/test.xsd b/xsd-tests/schema/list/test.xsd new file mode 100644 index 0000000..e16a58d --- /dev/null +++ b/xsd-tests/schema/list/test.xsd @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/list/testscript b/xsd-tests/schema/list/testscript new file mode 100644 index 0000000..0916be0 --- /dev/null +++ b/xsd-tests/schema/list/testscript @@ -0,0 +1,8 @@ +# file : schema/list/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +: invalid-definition +: +$* --output-dir $~ $src_base/any-simple-type/test.xsd 2>>/"EOE" != 0 + $src_base/any-simple-type/test.xsd:9:45: error: item type definition must have variety of atomic or union where all member types must be atomic + EOE diff --git a/xsd-tests/schema/no-namespace/buildfile b/xsd-tests/schema/no-namespace/buildfile new file mode 100644 index 0000000..e407218 --- /dev/null +++ b/xsd-tests/schema/no-namespace/buildfile @@ -0,0 +1,22 @@ +# file : schema/no-namespace/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx cxx}{test} $libs + +<{hxx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/schema/no-namespace/driver.cxx b/xsd-tests/schema/no-namespace/driver.cxx new file mode 100644 index 0000000..ef62942 --- /dev/null +++ b/xsd-tests/schema/no-namespace/driver.cxx @@ -0,0 +1,9 @@ +// file : schema/no-namespace/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "test.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/schema/no-namespace/test.xsd b/xsd-tests/schema/no-namespace/test.xsd new file mode 100644 index 0000000..b426e8a --- /dev/null +++ b/xsd-tests/schema/no-namespace/test.xsd @@ -0,0 +1,15 @@ + + + + + + + + + + + + + diff --git a/xsd-tests/schema/recursive/buildfile b/xsd-tests/schema/recursive/buildfile new file mode 100644 index 0000000..34542c6 --- /dev/null +++ b/xsd-tests/schema/recursive/buildfile @@ -0,0 +1,22 @@ +# file : schema/recursive/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx cxx}{test} $libs + +<{hxx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/schema/recursive/driver.cxx b/xsd-tests/schema/recursive/driver.cxx new file mode 100644 index 0000000..55c33cd --- /dev/null +++ b/xsd-tests/schema/recursive/driver.cxx @@ -0,0 +1,9 @@ +// file : schema/recursive/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "test.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/schema/recursive/test.xsd b/xsd-tests/schema/recursive/test.xsd new file mode 100644 index 0000000..6efc7d2 --- /dev/null +++ b/xsd-tests/schema/recursive/test.xsd @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/ref-type/invalid/buildfile b/xsd-tests/schema/ref-type/invalid/buildfile new file mode 100644 index 0000000..42c7bfb --- /dev/null +++ b/xsd-tests/schema/ref-type/invalid/buildfile @@ -0,0 +1,12 @@ +# file : schema/ref-type/invalid/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Test that the invalid schema files compilation expectedly fails. +# +./: testscript xsd{*} $xsd + +testscript{*}: +{ + test = $xsd + test.arguments = cxx-tree --std c++11 +} diff --git a/xsd-tests/schema/ref-type/invalid/invalid-0.xsd b/xsd-tests/schema/ref-type/invalid/invalid-0.xsd new file mode 100644 index 0000000..7ce82ed --- /dev/null +++ b/xsd-tests/schema/ref-type/invalid/invalid-0.xsd @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/xsd-tests/schema/ref-type/invalid/invalid-1.xsd b/xsd-tests/schema/ref-type/invalid/invalid-1.xsd new file mode 100644 index 0000000..d989065 --- /dev/null +++ b/xsd-tests/schema/ref-type/invalid/invalid-1.xsd @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/xsd-tests/schema/ref-type/invalid/testscript b/xsd-tests/schema/ref-type/invalid/testscript new file mode 100644 index 0000000..ce2e049 --- /dev/null +++ b/xsd-tests/schema/ref-type/invalid/testscript @@ -0,0 +1,16 @@ +# file : schema/ref-type/invalid/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +: unresolvable-namespace-prefix +: +$* --output-dir $~ $src_base/invalid-0.xsd 2>>~%EOE%d != 0 + %\.+invalid-0.xsd:10:75: error: unable to resolve namespace ''% + %\.+invalid-0.xsd:11:77: error: unable to resolve namespace prefix 't' in 't:author'% + %\.+invalid-0.xsd:15:81: error: unable to resolve namespace 'http://www.codesynthesis.com/xmlns/phony'% + EOE + +: unresolvable-type +: +$* --output-dir $~ $src_base/invalid-1.xsd 2>>~%EOE%d != 0 + %\.+invalid-1.xsd:9:79: error: unable to resolve type 'author' in namespace 'http://www.codesynthesis.com/xmlns/test'% + EOE diff --git a/xsd-tests/schema/ref-type/valid/.gitignore b/xsd-tests/schema/ref-type/valid/.gitignore new file mode 100644 index 0000000..fd203ec --- /dev/null +++ b/xsd-tests/schema/ref-type/valid/.gitignore @@ -0,0 +1,6 @@ +driver-idref +driver-idrefs +driver-idref.?xx +driver-idrefs.?xx +idref.?xx +idrefs.?xx diff --git a/xsd-tests/schema/ref-type/valid/buildfile b/xsd-tests/schema/ref-type/valid/buildfile new file mode 100644 index 0000000..0534fce --- /dev/null +++ b/xsd-tests/schema/ref-type/valid/buildfile @@ -0,0 +1,35 @@ +# file : schema/ref-type/valid/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +for sc: idref idrefs +{ + dr = "driver-$sc" + + ./: exe{$dr}: cxx{$dr} {hxx cxx}{$sc} $libs + + cxx{$dr}: in{driver} + { + # Note: we can't use $sc$ in driver.cxx.in since it will be substituted by + # the latest $sc value. + # + sch = $sc + } + + <{hxx cxx}{$sc}>: xsd{$sc} $xsd + {{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) + }} +} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/schema/ref-type/valid/driver.cxx.in b/xsd-tests/schema/ref-type/valid/driver.cxx.in new file mode 100644 index 0000000..434aa40 --- /dev/null +++ b/xsd-tests/schema/ref-type/valid/driver.cxx.in @@ -0,0 +1,9 @@ +// file : schema/ref-type/valid/driver.cxx.in +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "$sch$.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/schema/ref-type/valid/idref.xsd b/xsd-tests/schema/ref-type/valid/idref.xsd new file mode 100644 index 0000000..49ebe40 --- /dev/null +++ b/xsd-tests/schema/ref-type/valid/idref.xsd @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/ref-type/valid/idrefs.xsd b/xsd-tests/schema/ref-type/valid/idrefs.xsd new file mode 100644 index 0000000..b68ed03 --- /dev/null +++ b/xsd-tests/schema/ref-type/valid/idrefs.xsd @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/restriction/buildfile b/xsd-tests/schema/restriction/buildfile new file mode 100644 index 0000000..c05718a --- /dev/null +++ b/xsd-tests/schema/restriction/buildfile @@ -0,0 +1,22 @@ +# file : schema/restriction/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx cxx}{test} $libs + +<{hxx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/schema/restriction/driver.cxx b/xsd-tests/schema/restriction/driver.cxx new file mode 100644 index 0000000..2ffeb74 --- /dev/null +++ b/xsd-tests/schema/restriction/driver.cxx @@ -0,0 +1,9 @@ +// file : schema/restriction/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "test.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/schema/restriction/test.xsd b/xsd-tests/schema/restriction/test.xsd new file mode 100644 index 0000000..331ba78 --- /dev/null +++ b/xsd-tests/schema/restriction/test.xsd @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/schema/union/buildfile b/xsd-tests/schema/union/buildfile new file mode 100644 index 0000000..00d0a83 --- /dev/null +++ b/xsd-tests/schema/union/buildfile @@ -0,0 +1,22 @@ +# file : schema/union/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +# Just make sure that the schema files and the xsd-generated C++ mappings are +# compilable. +# +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test} {hxx cxx}{test} $libs + +<{hxx cxx}{test}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --root-element-all \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/schema/union/driver.cxx b/xsd-tests/schema/union/driver.cxx new file mode 100644 index 0000000..45f290f --- /dev/null +++ b/xsd-tests/schema/union/driver.cxx @@ -0,0 +1,9 @@ +// file : schema/union/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include "test.hxx" + +int +main (int, char*[]) +{ +} diff --git a/xsd-tests/schema/union/test.xsd b/xsd-tests/schema/union/test.xsd new file mode 100644 index 0000000..706f6f2 --- /dev/null +++ b/xsd-tests/schema/union/test.xsd @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd/.gitignore b/xsd/.gitignore new file mode 100644 index 0000000..cece09c --- /dev/null +++ b/xsd/.gitignore @@ -0,0 +1,19 @@ +# Compiler/linker output. +# +*.d +*.t +*.i +*.ii +*.o +*.obj +*.so +*.dll +*.a +*.lib +*.exp +*.pdb +*.ilk +*.exe +*.exe.dlls/ +*.exe.manifest +*.pc diff --git a/xsd/FLOSSE b/xsd/FLOSSE new file mode 120000 index 0000000..be6df3d --- /dev/null +++ b/xsd/FLOSSE @@ -0,0 +1 @@ +../FLOSSE \ No newline at end of file diff --git a/xsd/GPLv2 b/xsd/GPLv2 new file mode 120000 index 0000000..08e5586 --- /dev/null +++ b/xsd/GPLv2 @@ -0,0 +1 @@ +../GPLv2 \ No newline at end of file diff --git a/xsd/INSTALL b/xsd/INSTALL new file mode 100644 index 0000000..3402df2 --- /dev/null +++ b/xsd/INSTALL @@ -0,0 +1,6 @@ +The easiest way to build this package is with the bpkg package manager: + +$ bpkg build xsd + +But if you don't want to use the package manager, then you can also build it +manually using the standard build2 build system. diff --git a/xsd/LICENSE b/xsd/LICENSE new file mode 120000 index 0000000..ea5b606 --- /dev/null +++ b/xsd/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/xsd/NEWS b/xsd/NEWS new file mode 100644 index 0000000..03f5942 --- /dev/null +++ b/xsd/NEWS @@ -0,0 +1,1220 @@ +Version 4.1.0 + +C++/Tree + + * Support for abstract XML Schema types. The corresponding C++ classes + now have _clone() declared pure virtual which prevents construction + of their instances. + +Version 4.0.0 + + * Xerces-C++ 2-series (2.8.0 and earlier) is no longer supported. + + * Visual Studio 2003 (7.1) is no longer supported. + + * HP aCC3 (HP-UX/PA-RISC) is no longer supported. + + * Oracle/Berkeley DB XML support has been removed since it no longer + supports the Xerces-C++-based document access. + + * New option, --std, specifies the C++ standard that the generated code + should conform to. Valid values are c++98 (default) and c++11. + + The C++ standard affects various aspects of the generated code that are + discussed in more detail in mapping-specific documentation (guides and + manuals). Overall, when C++11 is selected, the generated code relies on + the move semantics and uses std::unique_ptr instead of deprecated + std::auto_ptr. See also the documentation for the --std option in the + XSD compiler command line manual (man pages). + + * New option, --fat-type-file, triggers the placement of code corresponding + to global elements into type files instead of schema files in the file- + per-type mode. This option is primarily useful when trying to minimize + the amount of object code that is linked to an executable by packaging + compiled generated code into a static (archive) library. + +C++/Tree + + * Support for ordered types. C++/Tree flattens nested compositors which + sometimes can result in the loss of element ordering information that + could be significant to the application. Ordered types address this + problem. For more information, refer to Section 2.8.4, "Element Order" + in the C++/Tree Mapping User Manual. + + * Support for mixed content in ordered types. For more information, refer + to Section 2.13, "Mapping for Mixed Content Models" in the C++/Tree + Mapping User Manual. + + * xml_schema::type represents anyType content as a DOM fragment, similar + to wildcards. For more information, refer to Section 2.5.2, "Mapping + for anyType" in the C++/Tree Mapping User Manual. + + * xml_schema::simple_type represents anySimpleType content as a text + string. For more information, refer to Section 2.5.3, "Mapping for + anySimpleType" in the C++/Tree Mapping User Manual. + + * Improved streaming example that now provides better XML namespace + handling and supports streaming parsing and serialization at multiple + document levels. + + * New option, --generate-dep, triggers the generation of the make + dependency files (.d) for the generated C++ files. Other options + controlling dependency generation are: --generate-dep-only, + --dep-phony, --dep-target, --dep-suffix, and --dep-regex. For + details on this functionality, refer to the XSD compiler command + line manual (man pages). + + * New option, --suppress-assignment, suppresses the generation of copy + assignment operators for complex types. If this option is specified, + the copy assignment operators for such types are declared private and + left unimplemented. + + * Binary representation now stores string-based enumerations as integer + values corresponding to C++ enumerators instead of string literals. + + * Binary representation now pools polymorphic type-id strings in an + implicit string pool. The string pool support can also be used to + pool strings in other situations. For example, you can implement + string insertion/extraction operators for your stream to pool all + strings. This can be useful if your documents contain a large number + of repetitive strings. + + * New option, --polymorphic-plate, allows the creation of multiple + polymorphic map plates in the same application. For details, refer + to the XSD compiler command line manual (man pages). + + * To get the DOM association in the copy of an object model tree one + now needs to explicitly pass the xml_schema::flags::keep_dom flag as + the second argument to the copy constructor or clone() function. + +Version 3.3.0 + + * New option, --char-encoding, allows you to specify the character encoding + that should be used in the generated code. Valid values for the 'char' + character type are 'utf8' (default), 'iso8859-1' (new), 'lcp' (Xerces-C++ + local code page), and 'custom' (provides support for custom encodings). + Note that if you use a non-default character encoding and include some + libxsd headers (e.g., xsd/cxx/xml/string.hxx) directly, then you will + need to first include the correct xsd/cxx/xml/char-.hxx header, + where is iso8859-1, lcp, etc. This mechanism replaces the + XSD_USE_LCP macro. + + For the wchar_t character type the only valid value for this option is + 'auto' and the encoding is automatically selected between UTF-16 and + UTF-32, depending on the wchar_t type size. + + * When the XSD compiler is built with Xerces-C++ 3.1.0 or later, the + handling of multiple imports for the same namespace is enabled. Before, + all subsequent imports for a namespace were ignored which caused errors + in some schemas. Note that if your application has XML Schema validation + enabled, then you will also need to build it with Xerces-C++ 3.1.0 or + later to take advantage of this feature. + + * Automatic mapping for the urn-style XML namespaces. The last component + in the urn name is used to derive the C++ namespace name. + + * New option, --schema-file-regex, in combination with the existing + --type-file-regex, can be used to place the generated files into + subdirectories or to resolve file name conflicts in the file-per- + type mode (--file-per-type). + + * Warning id's have changed to start with a letter identifying the + component issuing the warning. F - compiler frontend, D - compiler + driver, P - C++/Parser mapping, T - C++/Tree mapping. + + * Strings used to match regular expressions supplied with the + --namespace-regex and --anonymous-regex options now include the file + component for the schema being compiled. + + * The XSD_NO_EXPORT macro can be used to omit code generated with the + --export/import-maps and, for C++/Tree, --generate-xml-schema options + during C++ compilation. This may be useful if you would like to use + the same generated code across multiple platforms. + + C++/Tree + + * New option, --generate-element-type, triggers the generation of types + instead of parsing/serialization functions for root elements. This + is primarily useful to distinguish object models with the same root + type but with different root elements. For more information, refer + to the messaging example and Section 2.9.1, "Element Types" in the + C++/Tree Mapping User Manual. To support the customization of the + element type naming the --element-type-regex option has been added. + See the NAMING CONVENTION section in the compiler command line manual + (man pages) for details. + + * New option, --generate-element-map, triggers the generation of a root + element map. The element map allows uniform parsing and serialization + of multiple root elements. This option can only be used together with + --generate-element-type. For more information, refer to the messaging + example and Section 2.9.2, "Element Map" in the C++/Tree Mapping + User Manual. + + * Prior to this version, if the --generate-polymorphic option is + specified, the compiler treats all types as potentially polymorphic. + Now by default only type hierarchies used in substitution groups and + those explicitly declared polymorphic with the new --polymorphic-type + option are treated as polymorphic. This results in smaller and faster + generated code. If you would like to continue using the old behavior, + you will need to specify --polymorphic-type-all. For more information, + on this change see Section 2.11, "Mapping for xsi:type and Substitution + Groups" in the C++/Tree Mapping User Manual. + + * New option, --generate-detach, triggers the generation of detach + functions for required elements and attributes. For optional and + sequence cardinalities the detach functions are now provided by the + respective containers even without this option. These functions, for + example, allow one to move sub-trees in the object model either within + the same tree or between different trees without copying. For more + information, refer to Section 2.8 "Mapping for Local Elements and + Attributes" in the C++/Tree Mapping User Manual. + + * New option, --export-xml-schema, causes the compiler to export/import + types in the XML Schema namespace using the export symbol provided + with the --export-symbol option. + + * New example, embedded, shows how to embed the binary representation of + the schema grammar into an application and then use it to parse and + validate XML documents. + + * New example, compression, shows how to compress an XML document during + serialization and decompress it during parsing using the zlib library. + + * New example, custom/mixed, shows how to use type customization to parse + and serialize mixed content. + + * The streaming example has been extended to show how to perform stream- + oriented, partially in-memory XML processing using the C++/Tree mapping. + With the partially in-memory parsing and serialization only a part of + the object model is in memory at any given time. With this approach one + can process parts of the document as they become available as well as + handle documents that are too large to fit into memory. + + * New default/fixed value initialization code. Now the default/fixed values + are parsed by the XSD compiler at compile time instead of the standard + parsing code at runtime. This will allow the compilation of schemas that + use the default/fixed values without support for XML parsing + (--suppress-parsing option). + + * Empty XML Schema enumeration values are now mapped to the 'empty' C++ + enumerator name instead of 'cxx'. + + * XML Schema union types with members that are enumeration types are + automatically converted to equivalent enumeration types with a union + of all the members' enumerators. + +Version 3.2.0 + + * New option, --disable-warning, disables printing of a warning with + the specified id. Specifying 'all' for the warning id disables all + warnings. + + * New options, --export-maps and --import-maps, provide support for + splitting a polymorphic type hierarchy across several Win32 DLLs. + See the compiler command line manual (man pages) for details. + + C++/Tree + + * During serialization the generated code automatically assigns + generic prefixes (p1, p2, etc) to XML namespaces used in the + vocabulary and for which no custom prefix-namespace mapping + was provided via the xml_schema::namespace_infomap argument. + The xml_schema::namespace_infomap argument in the serialization + functions is now default-initialized to an empty map. The + xml_schema::no_namespace_mapping and xml_schema::xsi_already_in_use + exceptions have been removed. + + * New example, performance, measures the performance of parsing and + serialization. This example also shows how to structure your code + to achieve the maximum performance for these two operations. + + * New example, xpath, shows how to use the C++/Tree mapping together + with XPath. + + * New options, --one-accessor-regex, --opt-accessor-regex, + --seq-accessor-regex, --one-modifier-regex, --opt-modifier-regex, + and --seq-modifier-regex, allow specification of transformations + for accessor and modifier function names for elements and attributes + with specific cardinalities. For more information see the NAMING + CONVENTION section in the compiler command line manual (man pages). + + * Support for comparison (--generate-comparison) and printing + (--generate-ostream) of polymorphic object models. + + * New serialization flag, xml_schema::flags::dont_pretty_print, + disables extra spaces and new lines that make the resulting XML + slightly bigger but easier to read. + + * New example, custom/double, shows how to customize parsing and + serialization code for the xsd:double XML Schema built-in type. + It can be used as a guide on how to customize built-in XML Schema + types that are mapped to fundamental C++ types. + + * Support for fractionDigits and totalDigits facets in serialization + of types derived from xsd:decimal. + + * New set of compile-time macros that control how the xsd:float, + xsd:double, and xsd:decimal types are serialized. The following + macros control the format: + + XSD_CXX_TREE_FLOAT_FIXED + XSD_CXX_TREE_FLOAT_SCIENTIFIC + XSD_CXX_TREE_DOUBLE_FIXED + XSD_CXX_TREE_DOUBLE_SCIENTIFIC + + The following macros control the precision: + + XSD_CXX_TREE_FLOAT_PRECISION_MAX + XSD_CXX_TREE_FLOAT_PRECISION + XSD_CXX_TREE_DOUBLE_PRECISION_MAX + XSD_CXX_TREE_DOUBLE_PRECISION + XSD_CXX_TREE_DECIMAL_PRECISION_MAX + XSD_CXX_TREE_DECIMAL_PRECISION + + If the *_PRECISION_MAX macro is defined then the maximum number of + potentially significant decimal digits that the type can represent + is used. Otherwise, if the *_PRECISION macro is defined then its + value is used. By default the precision is set to the number of + decimal digits that the type can represent without change. For + more information on these options, refer to the following paper: + + http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1822.pdf + + The old macro, XSD_FP_ALL_DIGITS, that was equivalent to defining + all three *_PRECISION_MAX macros has been removed. + + An alternative to using these macros is to customize the floating + point type as shown in the custom/double example. + + * An additional constructor is generated in situations where a type + contains one or more required element of complex type (that is, + it itself contains elements or attributes). In this constructor, + initializers for such elements are passed as std::auto_ptr and the + newly created instance is directly initialized with and assumes + ownership of the pointed to objects. This constructor is a logical + addition to the non-copying modifiers that were introduced in the + previous version. + + * Extra conversion operators in the fundamental_base class template + which is used to emulate inheritance from fundamental types are now + disabled by default since they cause problems on several compilers. + To enable them compile your code with the XSD_TREE_EXTRA_FUND_CONV + macro defined. + + C++/Parser + + * New options, --generate-xml-schema and --extern-xml-schema, trigger + generation of the mapping for the XML Schema namespace to a separate + header file and inclusion of that header into other generated header + files instead of generating the necessary declarations inline, + respectively. See the compiler command line manual (man pages) for + details. + + * New example, performance, measures the performance of XML parsing. + This example also shows how to structure your code to achieve the + maximum performance for this operation. + + * Type map files can now include comments. A comment starts with # + and ends with a new line or end of file. To specify a name that + contains # enclose it in "". + + * In type map files the optional argument type now defaults to the + return type if the return type ends with * or & (that is, it is + a pointer or a reference) and 'const return type&' otherwise. + + * The interface for polymorphic parsing has been simplified. Calling the + *_parser() functions multiple times to specify several parsers is no + longer supported. Instead you need to pass the xml_schema::parser_map + object which contains the parsers. For more information refer to + Section 5.4, "Support for Polymorphism" in the C++/Parser Mapping + Getting Started Guide. + + * The use of virtual inheritance has been reduced which results in a + much smaller object code size (more than factor of 2 on some tests) + and faster C++ compilation with less RAM used. + + * The low-level Expat-specific parsing API (parse_begin() and parse_end()) + has been extended to provide XML and XML Schema error translation to + exceptions or error handler calls. See Section 7.2, "Expat Document + Parser" in the C++/Parser Mapping Getting Started Guide for more + information. + +Version 3.1.0 + + * New option, --file-per-type, triggers generation of a separate set + of C++ files for each type defined in XML Schema. This compilation + mode is primarily useful when some of your schemas cannot be compiled + separately or have cyclic dependencies which involve inheritance. + Other new options that are useful in this compilation mode are + --type-file-regex, --type-file-regex-trace, and --file-list. See the + compiler command line manual (man pages) for more information. + + * New option, --options-file, allows additional command line options + to be provided in files, with one option per line. + + * New option, --reserved-name, allows insertion of additional names + with optional replacements to the list of names that should not be + used as identifiers. See the compiler command line manual (man pages) + for details. + + * New options, --location-map, --location-regex, and + --location-regex-trace, allow re-mapping of schema locations + specified in the include and import elements without modifying the + schema files. See the compiler command line manual (man pages) for + more information. + + * New option, --guard-prefix, allows specification of a prefix that + should be added to generated header inclusion guards. + + * New option, --file-list, triggers creation of a file with a list of + generated C++ files. This option is primarily useful in the file-per- + type compilation mode (--file-per-type) to create a list of generated + C++ files, for example, as a makefile fragment. Other new options + that are useful with --file-list are --file-list-prologue, + --file-list-epilogue, and --file-list-delim. See the compiler command + line manual (man pages) for more information. + + * Support for the upcoming Xerces-C++ 3.0.0 release. + + C++/Tree + + * New option, --generate-intellisense, triggers generation of workarounds + for IntelliSense bugs in Visual Studio 2005 (8.0). When this option is + used, the resulting code is slightly more verbose. IntelliSense in + Visual Studio 2008 (9.0) does not require these workarounds. Support + for IntelliSense in Visual Studio 2003 (7.1) is improved with this + option but is still incomplete. + + * New options, --type-naming and --function-naming, allow specification + of the type and function naming conventions that should be used in the + generated code. Supported values for --type-naming are: knr (K&R), ucc + (upper-camel-case), and java. Supported values for --function-naming + are: knr (K&R), lcc (lower-camel-case), and java. For more information + see the NAMING CONVENTION section in the compiler command line manual + (man pages). + + * New options, --type-regex, --accessor-regex, --modifier-regex, + --parser-regex, --serializer-regex, and --enumerator-regex, allow + specification of transformations for type, accessor function, + modifier function, parsing function, serialization function, and + enumerator names in order to produce the generated code using a + custom naming convention. For more information see the NAMING + CONVENTION section in the compiler command line manual (man pages). + + * Generated list classes now provide a complete set of constructors and + conform to the standard C++ sequence interface. + + * String-based types now provide two extra constructors that expect a + C string and std::string as their arguments. This allows direct + initialization of string-based types from string literals. + + * New implementations of the XML Schema date/time types (date, dateTime, + duration, gDay, gMonth, gMonthDay, gYear, gYearMonth, and time) that + represent the information in the numerical form. + + * New binary serialization examples: binary/boost, which shows how to + save/load the object model to/from a custom format using the Boost + serialization library as an example, and binary/xdr, which shows how to + save/load the object model to/from XDR (eXternal Data Representation) + binary format using the XDR API provided as part of Sun RPC. + + * The non-copying modifier functions can now be used to assemble object + models from scratch. For more information see Section 4.4, "Creating + the Object Model from Scratch" in the C++/Tree Mapping Getting Started + Guide as well as Section 2.8, "Mapping for Local Elements and Attributes" + in the C++/Tree Mapping User Manual. + + * Doxygen documentation was added to the XSD runtime for the built-in XML + Schema types, exceptions, etc. This allows linking of the generated + documentation to the XSD runtime documentation using the Doxygen tags + mechanism. The Doxygen configuration file for the XSD runtime is + provided in the documentation/cxx/tree/reference/ directory. + + * Support for customization of anyType. Because anyType is a base type + for every generated type, customizing it allows one to implement custom + functionality that spans the entire type system. See the comments + example in the examples/cxx/tree/custom/ directory. + + * New option, --omit-default-attributes, triggers generation of extra + checks that exclude attributes with default and fixed values from the + serialized XML documents. + + * The parsing functions that used to read from DOMInputSource were changed + to use InputSource to ease support of Xerces-C++ 3 and 2 series in the + same code base. + + * The parsing function that used to parse DOMDocument* was changed to + parse xml_schema::dom::auto_ptr& instead. If the keep_dom + and own_dom flags are specified then this parsing function resets the + passed automatic pointer and the returned object model assumes + ownership of the DOM document. xml_schema::dom::auto_ptr is a simple + automatic pointer for Xerces-C++ DOM with the same interface as + std::auto_ptr. + + * The xml_schema::tree_node_key DOM user data key was moved to + xml_schema::dom::tree_node_key. + + C++/Parser + + * New option, --generate-polymorphic, triggers generation of polymorphism- + aware code. This option should be used on XML vocabularies which use + xsi:type and/or substitution groups. For more information see Section + 5.4, "Support for Polymorphism" in the C++/Parser Mapping Getting + Started Guide we well as the polymorphism and polyroot examples in the + examples/cxx/parser/ directory. + + * The date/time types (date, dateTime, gDay, gMonth, gMonthDay, gYear, + gYearMonth, and time) now represent time zone in the numerical form. + + * In order to support parsing of polymorphic XML documents, the signatures + of the start_* functions (_start_element, _start_any_element, and + start_root_element) have changed to include a third argument of type + const ro_string*. This argument contains the resolved type name and + namespace in case the xsi:type attribute was specified. + +Version 3.0.0 + + * Anonymous type morphing (automatic type naming) is now performed by + default in both mappings. The --morph-anonymous option does not have + any effect but is preserved for backwards compatibility. A new option, + --preserve-anonymous, disables anonymous type morphing. This option is + useful together with --show-anonymous if you want to make sure your + schemas do not have any anonymous types. + + * A number of bugs fixed in both C++/Tree and C++/Parser mappings. + + C++/Tree + + * The new C++/Tree Mapping Getting Started Guide is available in the + documentation/cxx/tree/guide/ directory. + + * The type definitions for local elements and attributes in the form + name::type have been changed to name_type. For example, an element + bar in type foo with maxOccurs="unbounded" used to have its iterator + type defined as foo::bar::iterator. With this change it becomes + foo::bar_iterator. Furthermore, the container type name for sequence + elements has changed from foo::bar::container to foo::bar_sequence + and for optional elements and attributes from foo::bar::container + to foo::bar_optional. This is a backwards incompatible change and + may require application code adjustments (the C++ compiler will + pinpoint the affected places). + + * New option, --generate-doxygen, triggers generation of documentation + comments suitable for extraction by the Doxygen documentation system. + Documentation from annotations is added to the comments if present in + the schema. + + * New option, --generate-wildcard, triggers generation of the new + wildcard (any and anyAttribute) mapping. This mapping represents the + content matched by wildcards as DOM fragments. For more information on + the new mapping see Section 2.12, "Mapping for any and anyAttribute" + in the C++/Tree Mapping User Manual as well as the wildcard example in + the examples/cxx/tree/ directory. + + * New option, --generate-comparison, triggers generation of comparison + operators (== and !=) for complex types. Comparison is performed + memberwise. + + * Support for the RPC XDR binary stream in addition to ACE CDR. + + * New constructor is generated for complex types with ultimate bases + that are simple types and can be default-initialized. This constructor + includes initializers for all required members but omits the initializer + for the base type. See Section 2.7, "Mapping for Complex Types" in the + C++/Tree Mapping User Manual for more information. + + * Support for polymorphic binary serialization and extraction. Note that + the semantics of the --generate-insertion and --generate-extraction + options has changed. See the the compiler command line manual (man + pages) for details. + + * New parsing function with the DOMDocument* argument and the own_dom + flag allow the tree to assume the ownership of the DOM document + being parsed when DOM association is requested (keep_dom flag). + See the C++/Tree Mapping User Manual for more information. + + * New example, multiroot, shows how to handle XML vocabularies with + multiple root elements. + + * New example, caching, shows how to parse several XML documents while + reusing the underlying XML parser and caching the schemas used for + validation. + + * The mapping of built-in XML Schema type decimal has changed from + long double to double. The old mapping can be obtained by providing + a custom mapping for this type. + + * The xml_schema::errors type which is used in the xml_schema::parsing + and xml_schema::serialization exceptions has been renamed to + xml_schema::diagnostics and extended to include warnings in addition + to errors. + + * Serialization operators now clear the element being serialized to from + existing child nodes and attributes (except for special attributes such + as prefix-namespace mappings, etc.). + + * Improved built-in type parsing, including support for normalization and + whitespace collapsing. + + * Optimizations for the generated code size and compilation time, + including space optimizations for polymorphic parsing and + serialization. Optimizations for XML parsing speed. + + C++/Parser + + * The C++/Parser mapping have been significantly redesigned. See the new + Getting Started Guide in documentation/cxx/parser/guide/ for details. + + * The new C++/Parser Mapping Getting Started Guide is available in the + documentation/cxx/parser/guide/ directory. + + * The mapping now provides parser implementations for all built-in XML + Schema types. See Chapter 6, "Built-In XML Schema Type Parsers" in + the C++/Parser Mapping Getting Started Guide for more information. + + * The mapping now supports automatic generation of sample parser + implementations and a test driver. The --generate-noop-impl option + triggers generation of a sample implementation with empty function + bodies. The --generate-print-impl option triggers generation of a + sample implementation that prints the data stored in XML to STDOUT. + The --generate-test-driver option trigger generation of a test driver. + For more information on this feature see the compiler command line + manual (man pages) and the generated example in the examples/cxx/parser/ + directory. Other relevant options include: --force-overwrite, + --root-element-first, --root-element-last, and --root-element. + + * New example, wildcard, shows how to parse the XML data matched by + XML Schema wildcards (any and anyAttribute). + + * The xml_schema::document parser has been extended with overridable + virtual functions start_root_element and end_root_element to support + parsing of XML vocabularies with multiple document roots. See the + multiroot example in the examples/cxx/parser/ directory for more + information. + + * The xml_schema::errors type which is used in the xml_schema::parsing + exception has been renamed to xml_schema::diagnostics and extended to + include warnings in addition to errors. + +Version 2.3.1 + + * The compiler is now capable of translating multiple schemas with + one invocation. + + * New option, --sloc-limit, allows one to limit the amount of the + generated code. + + * New option, --proprietary-license, instructs the compiler not to + include the GPL banner in each generated file. Instead a short + notice about a required proprietary license is generated. You + should not use this option unless you have obtained a proprietary + license from Code Synthesis Tools CC. + + * The default encoding for the 'char' character type is now UTF-8. + To get the previous behavior (local code page via the Xerces-C++ + transcode functions) define the XSD_USE_LCP preprocessor macro + when compiling your source code. + + C++/Tree + + * The --parts option has been improved to split generated code more + evenly by analyzing the complexity of the generated schema constructs. + + * Ability to customize serialization, std::ostream, and binary + insertion/extraction operators. See examples/cxx/tree/custom/wildcard + for an example on how to handle XML Schema wildcards (xsd:any and + xsd:anyAttribute) by customizing the parsing constructor and + serialization operators. + + * Optimizations for the run-time memory consumption. + + * Optimizations for space in the generated code. + + * Number of bug fixes. + + C++/Parser + + * Proper handling of an xsd:any nested content. Nested elements, + attributes, and text are reported via _any_* hooks of the current + parser. + + * Number of bug fixes, mostly in the generated validation code. + + +Version 2.3.0 + + * Name conflicts across type inheritance hierarchies are now detected + and resolved via name escaping. + + C++/Tree + + * New option, --suppress-parsing, suppresses generation of the parsing + constructors and functions. This can be used to minimize the generated + code footprint when parsing from XML is not used. + + * New option, --generate-forward, triggers generation of a forward + declaration header file for types defined in the schema. A set of + --fwd-* options that control the resulting file name as well as + prologue and epilogue code are available. + + * New option, --generate-xml-schema, triggers generation of the mapping + for the XML Schema namespace to a separate header file. See the man + pages for details and examples/cxx/tree/custom/calendar for an example. + + * New option, --extern-xml-schema, triggers inclusion of a header + file for the XML Schema namespace instead of generating the + necessary declarations inline. See the man pages for details and + examples/cxx/tree/custom/calendar for an example. + + * New options, --custom-type and --custom-type-regex, instruct the + compiler to use custom C++ type for a type defined in the schema. + The standard mapping can still be generated (with a different name) + usually to be used as a base. Built-in XML Schema types can be + customized using this mechanism. See the man pages for details and + examples/cxx/tree/custom/* for examples. + + * The generated parsing constructors and serialization operators have + been changed to use the Xerces-C++ DOM elements and attributes + instead of the internal wrapper types. This should provide easier + integration with other code and libraries that use the Xerces-C++ + DOM types such as Berkeley DB XML. + + * New example, examples/cxx/tree/dbxml, shows how to use the C++/Tree + mapping on top of the Berkeley DB XML database. + + C++/Parser + + * Validation of the attribute structure in the generated code. + + * Validation of the character content models including mixed content in + the generated code. + + * Validation of the built-in XML Schema types. + + * Optimizations for space and time in the generated code. In particular + data coping during parsing and validation was significantly reduced. + + +Version 2.2.0 + + * Detection of a version mismatch between the generated code and + the runtime. + + C++/Tree + + * Escaping of a global element name that conflicts with a global type + name. This is a backwards-incompatible change. Previous versions + map them to the same name. + + * New options, --generate--insertion and --generate-extraction, + trigger generation of (binary) data representation stream + insertion and extraction operators, respectively. This allows + one to serialize/deserialize in-memory representation to/from + data representation streams such as XSD, CDR, etc. ACE CDR + streams are supported out of the box (see the binary example). + User-supplied streams can be used via an adaptation layer. + + * New serialization flag, no_xml_declaration, instructs the XML + serialization functions to omit an XML declaration. This is useful + for streaming serialization (see the streaming example). + + * Optimizations to reduce generated code size. + + + C++/Parser + + * New options, --generate-validation and --suppress-validation, + trigger and suppress generation of the validation code, + respectively. The validation code is the implementation of the + XML Schema validation in the generated code (also known as + "perfect" parser). In this version validation of the element + structure has been implemented. + + * New architecture for underlying XML parsers. This is a backwards- + incompatible change. Existing applications will have to be + modified. See examples for details. + + +Version 2.1.1 + + C++/Tree + + * New option, --namespace-map, allows direct mapping of XML Schema + namespaces to C++ namespaces without the use of regular expressions. + + * Further optimizations in the container code and enum mapping to + reduce generated code size. + + * Number of bug fixes in the generated code. + + + C++/Parser + + * New option, --namespace-map, allows direct mapping of XML Schema + namespaces to C++ namespaces without the use of regular expressions. + + +Version 2.1.0 + + * Automatic handling of forward inheritance. XML Schema allows + inheritance from yet undefined types while it is illegal to do + so in C++. Now the translator automatically handles forward + inheritance by re-arranging the schema during compilation. + + + C++/Tree + + * New enum mapping with support for inheritance. Enumerators are + now parsed using binary search instead of linear search. + + * Associated DOM nodes now retain "back" pointers to tree nodes. + + * Optimizations to reduce generated code size. + + + C++/Parser + + * Specialization for void. You can now use void as a hook argument + type if you don't want to pass any data between parsers. + + * Support for re-use of implementations of base parsers in derived + parsers using the mixin C++ idiom. See the examples/cxx/parser/mixin + for more information. + + * Support for uninitialized parser. If you don't provide a parser + for element/attribute, that element/attribute will be ignored + during parsing. + + +Version 2.0.0 + + * New cardinality calculator. This improves support for schemas that + use complex structures with repeated elements, e.g., + + + + + + + + + + + + + + + + * New identifier escaping code. With this feature xsd generates proper + code for schemas that use the same name for an element and an attribute + in the same type or use several elements/attributes with different + qualified names but with the same local name, e.g., + + + + + + + + + + + + + + + + + + + + + + + + + + C++/Tree + + * New option, --generate-polymorphic, triggers generation of + polymorphism-aware code. Before this release xsd used to always + generate polymorphism-aware code. However, it appears to be quite + wasteful in terms of the generated code size (up to 40%). You will + now need to explicitly specify this option if you use substitution + groups or xsi:type. A warning is issued if this option is not + specified but the schema makes use of substitution groups. + + * New options, --root-element-first, --root-element-last, + --root-element-all, --root-element-none, and --root-element, control + generation of parsing and serialization functions. With these options + you can avoid generating extra code for global elements that are not + document roots. See the man pages for details. + + * New options, --parts and -parts-suffix, allows you to split generated + source code into a number of parts. This is useful when translating + large, monolithic schemas and a C++ compiler is not able to compile + the resulting source code at once (usually due to insufficient memory). + + * New option, --generate-default-ctor, triggers generation of default + constructors even for types that have required members. Required + members of an instance constructed using such a constructor are not + initialized and accessing them results in undefined behavior. Thanks + to Jean-Francois Dube for suggesting this + feature. + + * New option, --generate-from-base-ctor, triggers generation of + constructors that expect an instance of a base type followed by all + required members. Thanks to Jean-Francois Dube + for suggesting this feature. + + * Information scopes for attributes and elements with default/fixed values + now define the public static default_value function which allows one to + obtain the default/fixed value for the element/attribute. Thanks to + Dave Moss for suggesting this feature. + + * MSVC 7.1 has a limit on the length of the "if else if" chain. This + results in ICE when compiling generated code for enumerations with + a large number of values. This version addresses this issue. Thanks + to Cyrille Chépélov for reporting this and + suggesting a fix. + + + C++/Parser + + * The parser construction API has changed. Now, for element 'foo', + the name of the parser modifier function is 'foo_parser'. Likewise, + operator() for setting all parsers at once has been changed to the + 'parsers' function. + + +Version 1.9.0 + + C++/Tree + + * The size modifier function in the base64_binary and hex_binary + built-in types automatically adjusts capacity if needed. + + * More internal names (names that start with _xsd_) were made + private or protected. + + C++/Parser + + * Typedef for the parser base in the xml_schema namespace. + + C++/Parser-E + + * C++/Parser mapping optimized for embedded systems. For now it + is equivalent to 'cxx-parser --xml-parser expat'. + + +Version 1.8.0 + + * Moved to the build 0.2 series. + + C++/Tree + + * Support for default and fixed values in attributes. An optional + attribute with a default or fixed value is mapped to the One + cardinality class instead of the Optional cardinality class. + + * Mapping for base64Binary and hexBinary has improved. Now these + types support a basic buffer abstraction and perform automatic + encoding and decoding. + + * Internal names are protected. We've noticed (via bug reports) a + wide use of internal names (names that start with _xsd_) in user + code. This is not portable and instead you should use public + names. To prevent this from happening in the future we've made + all internal names protected. + + C++/Parser + + * Support for Expat as the underlying XML parser in addition to + Xerces-C++. This allows one to use the C++/Parser mapping in + memory-constrained environments such as embedded systems. To + select Expat instead of Xerces-C++ (default) add + '--xml-parser expat' to the command line. At the moment only + 'char' (UTF-8) is supported as the base character type when + Expat is selected. + + * The invalid_instance exception has been renamed to parsing. + + * Generic error_handler interface has been added in addition + to Xerces-C++-specific DOMErrorHandler. It allows you to + handle parsing errors and warnings without having to deal + with Xerces-C++ specifics. + + * The default error handling behavior has changed in parsing + functions. Instead of printing errors and warnings to STDERR, + the errors are now collected and thrown as part of the parsing + exception. + + * In parsing functions, the name, namespace arguments order has + been reversed to be consistent with the one used in parsing + hooks. + +Version 1.7.0 + + * Number of bug fixes in libxsd and the generated code. + + C++/Tree + + * Comprehensive XML Schema C++/Tree Mapping User Manual. + + * Basic support for union. A simple type that is defined using + derivation by union is mapped to a C++ class that derives from + string. + + * The _clone function has its arguments default-initialized. + + * The invalid_instance exception has been renamed to parsing. + + * Generic error_handler interface has been added in addition + to Xerces-C++-specific DOMErrorHandler. It allows you to + handle parsing/serialization errors and warnings without + having to deal with Xerces-C++ specifics. See the user + manual for more information. + + * The default error handling behavior has changed in parsing + and serialization functions. Instead of printing errors and + warnings to STDERR, the errors are now collected and thrown + as part of the parsing/serialization exception. See the user + manual for more information. + + * The optional and sequence containers now support operators ==, + !=, <, >, <=, and >=. + + * Flags argument has been added to serialization functions. The + only flag that is currently supported is dont_initialize. + + * Generated code cleanups. + + C++/Parser + + * Basic support for union. A simple type that is defined using + derivation by union is mapped to a C++ class template that + is just an alias for the generic parser. You are expected to + override the _characters function in your implementation. + + * Properties argument to parsing functions which allows to + programmatically specify schemas for instance document + validation. + + * Flags argument to parsing functions. The following flags + are supported: + + dont_validate - do not validate instance documents + dont_initialize - do not initialize the Xerces-C++ runtime + +Version 1.6.0 + + * Number of bug fixes in libxsd and the generated code. + + C++/Tree + + * Support for xsi:type and substitution groups in parsing and + serialization. See examples/cxx/tree/polymorphism for a code + sample. + + * Properties argument to parsing functions which allows to + programmatically specify schemas for instance document + validation. + + * Extra checks in parsing code which prevents construction + of inconsistent in-memory representation from invalid + instance documents. Should be useful when validation is + disabled. + + * Accessors and modifier were made normal member functions. + Before they were implemented via functors. + + * Workaround for g++-3.3 bug# 16650: + + http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16650 + + C++/Parser + + * All "service" functions were renamed to start with '_'. + This should prevent hiding of service functions by + elements/attributes with the same names. + +Version 1.5.0 + + * Number of bug fixes in libxsd and the generated code. + + C++/Tree + + * Basic support for inheritance-by-restriction in complex types. + + * The following parsing flags have been introduced: + + keep_dom - keep association with underlying DOM nodes + dont_validate - do not validate instance documents + dont_initialize - do not initialize the Xerces-C++ runtime + + * "Type-less content" such as mixed content models, xsd:anyType/ + xsd:anySimpleType, and xsd:any/xsd:anyAttribute is supported by + exposing corresponding DOM nodes (see the keep_dom parsing flag). + Note that only a subset of XML Schema xsd:any functionality is + supported. The compiler will issue diagnostics for unsupported + cases. See examples/cxx/tree/mixed for a code sample. + + C++/Parser + + * Support for inheritance-by-restriction in complex types. + + * "Type-less content" such as mixed content models, xsd:anyType/ + xsd:anySimpleType, and xsd:any/xsd:anyAttribute is supported + by forwarding parsing events to a set of "unexpected" hooks. + Note that only a subset of XML Schema xsd:any functionality is + supported. The compiler will issue diagnostics for unsupported + cases. See examples/cxx/parser/mixed for a code sample. + +Version 1.4.0 + + * Number of improvements and bug fixes in the diagnostics code. + + * libxsd has been reorganized to provide a clean split of code with + regards to char/wchar_t use. It should be possible to use libxsd + and the xsd-generated code on platforms that lack wchar_t support, + such as mingw. + + C++/Tree + + * Work around for g++ bug# 23206. + + * Support for xsd:list. + + * Type/member name conflicts are auto-resolved. Such conflicts + occur when a type and an element or attribute withing this type + share the same name. + + * XML Schema extension, the 'refType' attribute, allows one to + specify referenced type for xsd:IDREF and xsd:IDREFS data types. + See examples/cxx/tree/library for details. + + * New option, --morph-anonymous, allows automatic morphing + of anonymous types to named ones. See the man pages for + details. + + * New option, --namespace-regex-trace, allows one to trace the + namespace mapping process. See the man pages for details. + + * Mapping for optional elements/attributes (cardinality 0..1) + has changed in a backwards-incompatible way. In the previous + version you would write: + + Bar& bar = ... + + if (bar.foo.present ()) // test + { + Foo& foo (bar.foo ()); // get + + bar.foo (Foo (...)); // set + + bar.foo.reset (); // reset + } + + Now you would write it like this: + + if (bar.foo ().present ()) // test + { + Foo& foo (bar.foo ().get ()); // get + + bar.foo (Foo (...)); // set + + bar.foo ().reset (); // reset + } + + Or using the pointer notation: + + if (bar.foo ()) // test + { + Foo& foo (*bar.foo ()); // get + + bar.foo (Foo (...)); // set + + bar.foo ().reset (); // reset + } + + C++/Parser + + * Support for xsd:list. + + * Type/member name conflicts are auto-resolved. Such conflicts + occur when a type and an element or attribute withing this type + share the same name. + + * New option, --namespace-regex-trace, allows one to trace the + namespace mapping process. See the man pages for details. + +Version 1.3.0 + + * Numerous bug fixes. + + * The XML subsystem of libxsd has been reorganized to provide + a clean split of DOM and SAX functionalities. + + C++/Parser + + * New option, --morph-anonymous, allows automatic morphing + of anonymous types to named ones. See the man pages for + details. + + C++/Tree + + * Additional parser functions provide support for reading + from std::istream. + +Version 1.2.0 + + C++/Parser + + * New backend that generates the C++/Parser mapping. + +Version 1.1.1 + + all backends + + * Bug fixes in the filesystem path handling logic. + +Version 1.1.0 + + C++/Tree + + * New option, --generate-serialization, triggers generation of + serialization functions. Serialization functions convert an in-memory + representation back to XML. + + * xsd::cxx::tree::vector has been extended to closely follow std::vector + API. This allows you to access and modify element sequences as if they + were of type std::vector. + + * Generated constructors from xml::attribute and xml::element are made + explicit. + + * The library example was extended to showcase modification and + serialization of the in-memory representation. + + * New "XML Schema C++/Tree Mapping Serialization Guide" has an in-depth + treatment of the serialization mechanisms provided by xsd. + +Version 1.0.1 + + all backends + + * Improved diagnostics. + + * Bug fixes in the schema inclusion/importing logic. + + C++/Tree + + * Two new options: --include-with-brackets and --include-prefix + +Version 1.0.0 + + * First public release. diff --git a/xsd/README b/xsd/README new file mode 100644 index 0000000..80d707f --- /dev/null +++ b/xsd/README @@ -0,0 +1,27 @@ +CodeSynthesis XSD is a W3C XML Schema to C++ data binding compiler. +It generates vocabulary-specific, statically-typed C++ mappings (also +called bindings) from XML Schema definitions. XSD supports two C++ +mappings: in-memory C++/Tree and event-driven C++/Parser. + +The C++/Tree mapping consists of types that represent the given +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. + +The C++/Parser mapping provides parser templates for data types +defined in XML Schema. Using these parser templates you can build +your own in-memory representations or perform immediate processing +of XML instance documents. + +See the NEWS file for the user-visible changes from the previous release. + +See the LICENSE file for distribution conditions. + +See the INSTALL file for prerequisites and installation instructions. + +See the doc/ directory for documentation. + +The project page is at https://www.codesynthesis.com/projects/xsd/. + +Send bug reports or any other feedback to the xsd-users@codesynthesis.com +mailing list. diff --git a/xsd/build/.gitignore b/xsd/build/.gitignore new file mode 100644 index 0000000..4a730a3 --- /dev/null +++ b/xsd/build/.gitignore @@ -0,0 +1,3 @@ +config.build +root/ +bootstrap/ diff --git a/xsd/build/bootstrap.build b/xsd/build/bootstrap.build new file mode 100644 index 0000000..aaf60f8 --- /dev/null +++ b/xsd/build/bootstrap.build @@ -0,0 +1,9 @@ +# file : build/bootstrap.build +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +project = xsd + +using version +using config +using dist +using install diff --git a/xsd/build/export.build b/xsd/build/export.build new file mode 100644 index 0000000..68ffad0 --- /dev/null +++ b/xsd/build/export.build @@ -0,0 +1,9 @@ +# file : build/export.build +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +$out_root/ +{ + include xsd/ +} + +export $out_root/xsd/exe{xsd} diff --git a/xsd/build/root.build b/xsd/build/root.build new file mode 100644 index 0000000..ace0237 --- /dev/null +++ b/xsd/build/root.build @@ -0,0 +1,37 @@ +# file : build/root.build +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +using in + +cxx.std = latest + +using cxx + +hxx{*}: extension = hxx +ixx{*}: extension = ixx +txx{*}: extension = txx +cxx{*}: extension = cxx + +if ($cxx.target.system == 'win32-msvc') + cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + +if ($cxx.class == 'msvc') + cxx.coptions += /wd4251 /wd4275 /wd4800 /wd4819 + +cxx.poptions =+ "-I$out_root" "-I$src_root" + +# Load the cli module but only if it's available. This way a distribution +# that includes pre-generated files can be built without installing cli. +# This is also the reason why we need to explicitly spell out individual +# source file prerequisites instead of using the cli.cxx{} group (it won't +# be there unless the module is configured). +# +using? cli + +# Extract the copyright notice from the LICENSE file. +# +# Note that cat is a builtin which means this is both portable and fast. +# +copyright = $process.run_regex(cat $src_root/LICENSE, \ + 'Copyright \(c\) (.+)\.', \ + '\1') diff --git a/xsd/buildfile b/xsd/buildfile new file mode 100644 index 0000000..298d3ce --- /dev/null +++ b/xsd/buildfile @@ -0,0 +1,8 @@ +# file : buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +./: {*/ -build/} doc{INSTALL NEWS README} legal{GPLv2 LICENSE FLOSSE} manifest + +# Don't install the INSTALL file. +# +doc{INSTALL}@./: install = false diff --git a/xsd/cxx/elements.cxx b/xsd/cxx/elements.cxx deleted file mode 100644 index 5ead15f..0000000 --- a/xsd/cxx/elements.cxx +++ /dev/null @@ -1,1319 +0,0 @@ -// file : xsd/cxx/elements.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include // std::toupper -#include -#include -#include -#include -#include - -using std::wcerr; -using std::endl; - -namespace CXX -{ - // - // - wchar_t - upcase (wchar_t c) - { - return std::toupper (c); - } - - namespace - { - wchar_t const* keywords[] = { - L"NULL", - L"and", - L"asm", - L"auto", - L"bitand", - L"bitor", - L"bool", - L"break", - L"case", - L"catch", - L"char", - L"class", - L"compl", - L"const", - L"const_cast", - L"continue", - L"default", - L"delete", - L"do", - L"double", - L"dynamic_cast", - L"else", - L"end_eq", - L"enum", - L"explicit", - L"export", - L"extern", - L"false", - L"float", - L"for", - L"friend", - L"goto", - L"if", - L"inline", - L"int", - L"long", - L"mutable", - L"namespace", - L"new", - L"not", - L"not_eq", - L"operator", - L"or", - L"or_eq", - L"private", - L"protected", - L"public", - L"register", - L"reinterpret_cast", - L"return", - L"short", - L"signed", - L"sizeof", - L"static", - L"static_cast", - L"struct", - L"switch", - L"template", - L"this", - L"throw", - L"true", - L"try", - L"typedef", - L"typeid", - L"typename", - L"union", - L"unsigned", - L"using", - L"virtual", - L"void", - L"volatile", - L"wchar_t", - L"while", - L"xor", - L"xor_eq" - }; - } - - // Context - // - - Context:: - Context (std::wostream& o, - SemanticGraph::Schema& root, - SemanticGraph::Path const& path, - options_type const& ops, - StringLiteralMap const* string_literal_map_) - : os (o), - schema_root (root), - schema_path (schema_path_), - options (ops), - std (ops.std ()), - char_type (char_type_), - char_encoding (char_encoding_), - L (L_), - string_type (string_type_), - auto_ptr (auto_ptr_), - string_literal_map (string_literal_map_), - type_exp (type_exp_), - inst_exp (inst_exp_), - inl (inl_), - ns_mapping_cache (ns_mapping_cache_), - schema_path_ (path), - xs_ns_ (0), - char_type_ (ops.char_type ()), - char_encoding_ (ops.char_encoding ()), - L_ (char_type == L"wchar_t" ? L"L" : L""), - inl_ (ops.generate_inline () ? L"inline\n" : L""), - cxx_id_expr_ (L"^(::)?([a-zA-Z_]\\w*)(::[a-zA-Z_]\\w*)*$"), - cxx_id_expr (cxx_id_expr_), - urn_mapping_ (L"#^urn.*:([a-zA-Z_].*)$#$1#"), - urn_mapping (urn_mapping_), - nsr_mapping (nsr_mapping_), - nsm_mapping (nsm_mapping_), - include_mapping (include_mapping_), - reserved_name_map (reserved_name_map_), - keyword_set (keyword_set_) - { - // Export symbol. - // - { - String es (ops.export_symbol ()); - type_exp_ = es ? es + L" " : es; - inst_exp_ = es ? es + L"\n" : es; - } - - // Resolve and cache XML Schema namespace. - // - { - SemanticGraph::Nameable* n; - - if (schema_root.names_begin ()->name () == - L"http://www.w3.org/2001/XMLSchema") - { - // schema_root is the XML Schema itself. - // - n = &schema_root.names_begin ()->named (); - } - else - { - // Otherwise, the first used schema is implied XML Schema. - // - SemanticGraph::Uses& u = *schema_root.uses_begin (); - assert (u.is_a ()); - n = &u.schema ().names_begin ()->named (); - } - - xs_ns_ = dynamic_cast (n); - } - - // String type. - // - if (char_type == L"char") - string_type_ = L"::std::string"; - else if (char_type == L"wchar_t") - string_type_ = L"::std::wstring"; - else - string_type_ = L"::std::basic_string< " + char_type + L" >"; - - // Automatic pointer type. - // - auto_ptr_ = std >= cxx_version::cxx11 - ? "::std::unique_ptr" - : "::std::auto_ptr"; - - // Default encoding. - // - if (!char_encoding) - { - if (char_type == L"char") - char_encoding = L"utf8"; - else - char_encoding = L"auto"; - } - - // Default mapping. - // - nsr_mapping_.push_back ( - Regex (L"#^.* (.*?/)??" L"(([a-zA-Z_]\\w*)(/[a-zA-Z_]\\w*)*)/?$#$2#")); - nsr_mapping_.push_back ( - Regex (L"#^.* http://www\\.w3\\.org/2001/XMLSchema$#xml_schema#")); - - // Custom regex mapping. - // - for (NarrowStrings::const_iterator i (ops.namespace_regex ().begin ()), - e (ops.namespace_regex ().end ()); i != e; ++i) - { - nsr_mapping_.push_back (Regex (String (*i))); - } - - // Custom direct mapping. - // - for (NarrowStrings::const_iterator i (ops.namespace_map ().begin ()), - e (ops.namespace_map ().end ()); i != e; ++i) - { - String s (*i); - - // Split the string in two parts at the last '='. - // - size_t pos (s.rfind ('=')); - - if (pos == String::npos) - throw InvalidNamespaceMapping (s, "delimiter ('=') not found"); - - // Empty xml_ns designates the no-namespace case. - // - String xml_ns (s, 0, pos); - String cxx_ns (s, pos + 1); - - if (!cxx_ns.empty () && !cxx_id_expr.match (cxx_ns)) - throw InvalidNamespaceMapping (s, "invalid C++ identifier"); - - nsm_mapping_[xml_ns] = cxx_ns; - } - - // Include path regex - // - for (NarrowStrings::const_iterator i (ops.include_regex ().begin ()), - e (ops.include_regex ().end ()); i != e; ++i) - { - include_mapping_.push_back (Regex (String (*i))); - } - - // Reserved names. - // - for (NarrowStrings::const_iterator i (ops.reserved_name ().begin ()), - e (ops.reserved_name ().end ()); i != e; ++i) - { - String s (*i); - - // Split the string in two parts at '='. - // - size_t pos (s.find ('=')); - - if (pos == String::npos) - reserved_name_map_[s] = L""; - else - reserved_name_map_[String (s, 0, pos)] = String (s, pos + 1); - } - - // Populate the keyword set. - // - for (size_t i (0); i < sizeof (keywords) / sizeof (char*); ++i) - keyword_set_.insert (keywords[i]); - } - - String Context:: - ns_name (SemanticGraph::Namespace& ns) - { - using SemanticGraph::Schema; - using SemanticGraph::Includes; - using SemanticGraph::Imports; - using SemanticGraph::Implies; - using SemanticGraph::Sources; - - String tmp; - MapMapping::const_iterator i (nsm_mapping.find (ns.name ())); - - if (i != nsm_mapping.end ()) - { - tmp = i->second; - } - else - { - SemanticGraph::Path path; - Schema& schema (dynamic_cast (ns.scope ())); - - if (schema.used_p ()) - { - // Here we need to detect a special multi-schema compilation - // case where the root schemas are imported into a special - // schema that doesn't have a namespace. - // - SemanticGraph::Uses& u (*schema.used_begin ()); - SemanticGraph::Schema& s (u.user ()); - - if (s.names_begin () != s.names_end ()) - path = u.path (); - } - else - path = schema_path; - - String pair; - - if (!path.empty ()) - { - path.normalize (); - - // Try to use the portable representation of the path. If that - // fails, fall back to the native representation. - // - try - { - pair = path.posix_string (); - } - catch (SemanticGraph::InvalidPath const&) - { - pair = path.string (); - } - } - - pair += L' ' + ns.name (); - - // Check cache first - // - MappingCache::const_iterator i (ns_mapping_cache.find (pair)); - - if (i != ns_mapping_cache.end ()) - { - tmp = i->second; - } - else - { - bool trace (options.namespace_regex_trace ()); - - if (trace) - wcerr << "namespace: '" << pair << "'" << endl; - - bool found (false); - Regex colon (L"#/#::#"); - - for (RegexMapping::const_reverse_iterator e (nsr_mapping.rbegin ()); - e != nsr_mapping.rend (); ++e) - { - if (trace) - wcerr << "try: '" << e->regex () << "' : "; - - if (e->match (pair)) - { - tmp = e->replace (pair); - tmp = colon.replace (tmp); // replace `/' with `::' - - // Check the result. - // - found = cxx_id_expr.match (tmp); - - if (trace) - wcerr << "'" << tmp << "' : "; - } - - if (trace) - wcerr << (found ? '+' : '-') << endl; - - if (found) - break; - } - - if (!found) - { - String const& n (ns.name ()); - - // Check if the name is valid by itself. - // - if (n.empty ()) - { - // Empty name denotes a no-namespace case. - // - tmp = n; - } - else - { - tmp = colon.replace (n); // replace `/' with `::' - - if (!cxx_id_expr.match (tmp)) - { - // See if this is a urn-style namespace. - // - if (urn_mapping.match (n)) - { - Regex filter (L"#[.:-]#_#"); - tmp = urn_mapping.replace (n); - tmp = filter.replace (tmp); - - if (!cxx_id_expr.match (tmp)) - throw NoNamespaceMapping ( - ns.file (), ns.line (), ns.column (), ns.name ()); - } - else - throw NoNamespaceMapping ( - ns.file (), ns.line (), ns.column (), ns.name ()); - } - } - } - - // Add the mapping to the cache. - // - ns_mapping_cache[pair] = tmp; - } - } - - - // Parse resulting namespace string and id() each name. - // - String r; - String::size_type b (0), e; - - do - { - e = tmp.find (L"::", b); - - String name (tmp, b, e == tmp.npos ? e : e - b); - - if (!name.empty ()) - r += L"::" + escape (name); - - b = e; - - if (b == tmp.npos) - break; - - b += 2; - - } while (true); - - return r; - } - - SemanticGraph::Namespace& Context:: - xs_ns () - { - return *xs_ns_; - } - - String Context:: - xs_ns_name () - { - return ns_name (*xs_ns_); - } - - SemanticGraph::Namespace& Context:: - namespace_ (SemanticGraph::Nameable& n) - { - // The basic idea goes like this: go up Names edges until you - // reach Namespace. There are, however, anonymous types which - // need special handling. In the case of an anonymous type we - // will go up the first Belongs edge (because the first edge - // is where the type was defined. - // - - if (n.named_p ()) - { - SemanticGraph::Scope& s (n.scope ()); - - SemanticGraph::Namespace* ns ( - dynamic_cast (&n)); - - return ns ? *ns : namespace_ (s); - } - else - { - SemanticGraph::Type& t (dynamic_cast (n)); - - SemanticGraph::Belongs& b (*t.classifies_begin ()); - - return namespace_ (b.instance ()); - } - } - - String Context:: - xml_ns_name (SemanticGraph::Nameable& n) - { - return namespace_ (n).name (); - } - - String Context:: - fq_name (SemanticGraph::Nameable& n, char const* name_key) - { - using namespace SemanticGraph; - - String r; - - if (dynamic_cast (&n)) - { - return L""; // Map to global namespace. - } - else if (SemanticGraph::Namespace* ns = - dynamic_cast (&n)) - { - r = ns_name (*ns); - } - else - { - r = fq_name (n.scope ()); - r += L"::"; - r += n.context ().get (name_key); - } - - return r; - } - - SemanticGraph::Type& Context:: - ultimate_base (SemanticGraph::Complex& c) - { - using namespace SemanticGraph; - - Type* b (&c.inherits ().base ()); - - while (true) - { - Complex* cb (dynamic_cast (b)); - - if (cb != 0 && cb->inherits_p ()) - { - b = &cb->inherits ().base (); - continue; - } - - break; - } - - return *b; - } - - String Context:: - escape (String const& name) - { - String r; - size_t n (name.size ()); - - // In most common cases we will have that many chars. - // - r.reserve (n); - - for (size_t i (0); i < n; ++i) - { - bool first (i == 0); - - unsigned int u (unicode_char (name, i)); // May advance i. - - if (first) - { - if (!((u >= 'a' && u <= 'z') || - (u >= 'A' && u <= 'Z') || - u == '_')) - r = (u >= '0' && u <= '9') ? L"cxx_" : L"cxx"; - } - - if (!((u >= 'a' && u <= 'z') || - (u >= 'A' && u <= 'Z') || - (u >= '0' && u <= '9') || - u == '_')) - r.push_back ('_'); - else - r.push_back (static_cast (u)); - } - - if (r.empty ()) - r = L"cxx"; - - // Custom reserved words. - // - ReservedNameMap::const_iterator i (reserved_name_map.find (r)); - - if (i != reserved_name_map.end ()) - { - if (i->second) - return i->second; - else - r += L'_'; - } - - // Keywords - // - if (keyword_set.find (r) != keyword_set.end ()) - { - r += L'_'; - - // Re-run custom words. - // - i = reserved_name_map.find (r); - - if (i != reserved_name_map.end ()) - { - if (i->second) - return i->second; - else - r += L'_'; - } - } - - return r; - } - - // String escaping. - // - - String - charlit (unsigned int u) - { - String r ("\\x"); - bool lead (true); - - for (int i (7); i >= 0; --i) - { - unsigned int x ((u >> (i * 4)) & 0x0F); - - if (lead) - { - if (x == 0) - continue; - - lead = false; - } - - r += x < 10 ? ('0' + x) : ('A' + x - 10); - } - - return r; - } - - String - strlit_ascii (String const& str) - { - String r; - size_t n (str.size ()); - - // In most common cases we will have that many chars. - // - r.reserve (n + 2); - - r += '"'; - - bool escape (false); - - for (size_t i (0); i < n; ++i) - { - unsigned int u (Context::unicode_char (str, i)); // May advance i. - - // [128 - ] - unrepresentable - // 127 - \x7F - // [32 - 126] - as is - // [0 - 31] - \X or \xXX - // - - if (u < 32 || u == 127) - { - switch (u) - { - case L'\n': - { - r += L"\\n"; - break; - } - case L'\t': - { - r += L"\\t"; - break; - } - case L'\v': - { - r += L"\\v"; - break; - } - case L'\b': - { - r += L"\\b"; - break; - } - case L'\r': - { - r += L"\\r"; - break; - } - case L'\f': - { - r += L"\\f"; - break; - } - case L'\a': - { - r += L"\\a"; - break; - } - default: - { - r += charlit (u); - escape = true; - break; - } - } - } - else if (u < 127) - { - if (escape) - { - // Close and open the string so there are no clashes. - // - r += '"'; - r += '"'; - - escape = false; - } - - switch (u) - { - case L'"': - { - r += L"\\\""; - break; - } - case L'\\': - { - r += L"\\\\"; - break; - } - default: - { - r += static_cast (u); - break; - } - } - } - else - { - // Unrepresentable character. - // - throw UnrepresentableCharacter (str, i + 1); - } - } - - r += '"'; - - return r; - } - - const unsigned int utf8_first_char_mask[5] = - { - 0x00, 0x00, 0xC0, 0xE0, 0xF0 - }; - - String - strlit_utf8 (String const& str) - { - String r; - size_t n (str.size ()); - - // In most common cases we will have that many chars. - // - r.reserve (n + 2); - - r += '"'; - - bool escape (false); - - for (size_t i (0); i < n; ++i) - { - unsigned int u (Context::unicode_char (str, i)); // May advance i. - - // [128 - ] - UTF-8 - // 127 - \x7F - // [32 - 126] - as is - // [0 - 31] - \X or \xXX - // - - if (u < 32 || u == 127) - { - switch (u) - { - case L'\n': - { - r += L"\\n"; - break; - } - case L'\t': - { - r += L"\\t"; - break; - } - case L'\v': - { - r += L"\\v"; - break; - } - case L'\b': - { - r += L"\\b"; - break; - } - case L'\r': - { - r += L"\\r"; - break; - } - case L'\f': - { - r += L"\\f"; - break; - } - case L'\a': - { - r += L"\\a"; - break; - } - default: - { - r += charlit (u); - escape = true; - break; - } - } - } - else if (u < 127) - { - if (escape) - { - // Close and open the string so there are no clashes. - // - r += '"'; - r += '"'; - - escape = false; - } - - switch (u) - { - case L'"': - { - r += L"\\\""; - break; - } - case L'\\': - { - r += L"\\\\"; - break; - } - default: - { - r += static_cast (u); - break; - } - } - } - else - { - unsigned int count (0); - unsigned int tmp[4]; - - if (u < 0x800) - count = 2; - else if (u < 0x10000) - count = 3; - else if (u < 0x110000) - count = 4; - - switch (count) - { - case 4: - { - tmp[3] = (u | 0x80UL) & 0xBFUL; - u >>= 6; - } - case 3: - { - tmp[2] = (u | 0x80UL) & 0xBFUL; - u >>= 6; - } - case 2: - { - tmp[1] = (u | 0x80UL) & 0xBFUL; - u >>= 6; - } - case 1: - { - tmp[0] = u | utf8_first_char_mask[count]; - break; - } - default: - assert (false); - } - - for (unsigned int j (0); j < count; ++j) - r += charlit (tmp[j]); - - escape = true; - } - } - - r += '"'; - - return r; - } - - String - strlit_iso8859_1 (String const& str) - { - String r; - size_t n (str.size ()); - - // In most common cases we will have that many chars. - // - r.reserve (n + 2); - - r += '"'; - - bool escape (false); - - for (size_t i (0); i < n; ++i) - { - unsigned int u (Context::unicode_char (str, i)); // May advance i. - - // [256 - ] - unrepresentable - // [127 - 255] - \xXX - // [32 - 126] - as is - // [0 - 31] - \X or \xXX - // - - if (u < 32) - { - switch (u) - { - case L'\n': - { - r += L"\\n"; - break; - } - case L'\t': - { - r += L"\\t"; - break; - } - case L'\v': - { - r += L"\\v"; - break; - } - case L'\b': - { - r += L"\\b"; - break; - } - case L'\r': - { - r += L"\\r"; - break; - } - case L'\f': - { - r += L"\\f"; - break; - } - case L'\a': - { - r += L"\\a"; - break; - } - default: - { - r += charlit (u); - escape = true; - break; - } - } - } - else if (u < 127) - { - if (escape) - { - // Close and open the string so there are no clashes. - // - r += '"'; - r += '"'; - - escape = false; - } - - switch (u) - { - case L'"': - { - r += L"\\\""; - break; - } - case L'\\': - { - r += L"\\\\"; - break; - } - default: - { - r += static_cast (u); - break; - } - } - } - else if (u < 256) - { - r += charlit (u); - escape = true; - } - else - { - // Unrepresentable character. - // - throw UnrepresentableCharacter (str, i + 1); - } - } - - r += '"'; - - return r; - } - - String - strlit_utf32 (String const& str) - { - String r; - size_t n (str.size ()); - - // In most common cases we will have that many chars. - // - r.reserve (n + 3); - - r += L"L\""; - - bool escape (false); - - for (size_t i (0); i < n; ++i) - { - unsigned int u (Context::unicode_char (str, i)); // May advance i. - - // [128 - ] - \xUUUUUUUU - // 127 - \x7F - // [32 - 126] - as is - // [0 - 31] - \X or \xXX - // - - if (u < 32 || u == 127) - { - switch (u) - { - case L'\n': - { - r += L"\\n"; - break; - } - case L'\t': - { - r += L"\\t"; - break; - } - case L'\v': - { - r += L"\\v"; - break; - } - case L'\b': - { - r += L"\\b"; - break; - } - case L'\r': - { - r += L"\\r"; - break; - } - case L'\f': - { - r += L"\\f"; - break; - } - case L'\a': - { - r += L"\\a"; - break; - } - default: - { - r += charlit (u); - escape = true; - break; - } - } - } - else if (u < 127) - { - if (escape) - { - // Close and open the string so there are no clashes. C++11 - // requires a space between " and L. - // - r += L"\" L\""; - escape = false; - } - - switch (u) - { - case L'"': - { - r += L"\\\""; - break; - } - case L'\\': - { - r += L"\\\\"; - break; - } - default: - { - r += static_cast (u); - break; - } - } - } - else - { - r += charlit (u); - escape = true; - } - } - - r += '"'; - - return r; - } - - String Context:: - strlit (String const& str) - { - // First see if we have a custom mapping. - // - assert (string_literal_map != 0); - StringLiteralMap::const_iterator i (string_literal_map->find (str)); - - if (i != string_literal_map->end ()) - return i->second; - - if (char_type == L"char") - { - if (char_encoding == L"utf8") - return strlit_utf8 (str); - else if (char_encoding == L"iso8859-1") - return strlit_iso8859_1 (str); - else - { - // For LCP, custom, and other unknown encodings, use ASCII. - // - return strlit_ascii (str); - } - } - else - return strlit_utf32 (str); - } - - String Context:: - comment (String const& str) - { - String r; - - wchar_t const* s (str.c_str ()); - size_t size (str.size ()); - - // In most common cases we will have that many chars. - // - r.reserve (size); - - for (wchar_t const* p (s); p < s + size; ++p) - { - unsigned int u (unicode_char (p)); // May advance p. - - // We are going to treat \v, \f and \n as unrepresentable - // here even though they can be present in C++ source code. - // - if (u > 127 || (u < 32 && u != '\t')) - r += L'?'; - else - r += static_cast (u); - } - - return r; - } - - String Context:: - process_include_path (String const& name) const - { - String path (String (options.include_prefix ()) + name); - bool trace (options.include_regex_trace ()); - - if (trace) - wcerr << "include: '" << path << "'" << endl; - - String r; - bool found (false); - - for (RegexMapping::const_reverse_iterator e (include_mapping.rbegin ()); - e != include_mapping.rend (); ++e) - { - if (trace) - wcerr << "try: '" << e->regex () << "' : "; - - if (e->match (path)) - { - r = e->replace (path); - found = true; - - if (trace) - wcerr << "'" << r << "' : "; - } - - if (trace) - wcerr << (found ? '+' : '-') << endl; - - if (found) - break; - } - - if (!found) - r = path; - - if (!r.empty () && r[0] != L'"' && r[0] != L'<') - { - wchar_t op (options.include_with_brackets () ? L'<' : L'"'); - wchar_t cl (options.include_with_brackets () ? L'>' : L'"'); - r = op + r + cl; - } - - return r; - } - - // Namespace - // - - void Namespace:: - pre (Type& n) - { - String ns (ctx_.ns_name (n)); - - String::size_type b (0), e; - - if (st_) - st_->enter (n, L"", ns ? false : true); - - do - { - e = ns.find (L"::", b); - - String name (ns, b, e == ns.npos ? e : e - b); - - if (!name.empty ()) - { - if (st_) - st_->enter (n, name, e == ns.npos); - - ctx_.os << "namespace " << name << "{"; - } - - b = e; - - if (b == ns.npos) - break; - - b += 2; - - } while (true); - } - - void Namespace:: - post (Type& n) - { - String ns (ctx_.ns_name (n)); - - String::size_type b (0), e; - - do - { - e = ns.find (L"::", b); - - String name (ns, b, e == ns.npos ? e : e - b); - - if (!name.empty ()) - { - ctx_.os << "}"; - - if (st_) - st_->leave (); - } - - - b = e; - - if (b == ns.npos) - break; - - b += 2; - - } - while (true); - - if (st_) - st_->leave (); - } -} diff --git a/xsd/cxx/elements.hxx b/xsd/cxx/elements.hxx deleted file mode 100644 index a316a0c..0000000 --- a/xsd/cxx/elements.hxx +++ /dev/null @@ -1,626 +0,0 @@ -// file : xsd/cxx/elements.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_ELEMENTS_HXX -#define CXX_ELEMENTS_HXX - -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - -#include -#include - -namespace CXX -{ - using std::endl; - - // On some platforms std::toupper can be something other than a - // function with C++ linkage. - // - wchar_t - upcase (wchar_t c); - - - // Exceptions. - // - - struct UnrepresentableCharacter - { - UnrepresentableCharacter (String const& str, size_t pos) - : str_ (str), pos_ (pos) - { - } - - String const& - string () const - { - return str_; - } - - size_t - position () const - { - return pos_; - } - - private: - String str_; - size_t pos_; - }; - - struct NoNamespaceMapping - { - NoNamespaceMapping (SemanticGraph::Path const& file, - size_t line, - size_t column, - String const& ns) - : file_ (file), - line_ (line), - column_ (column), - ns_ (ns) - { - } - - - SemanticGraph::Path const& - file () const - { - return file_; - } - - size_t - line () const - { - return line_; - } - - size_t - column () const - { - return column_; - } - - String const& - ns () const - { - return ns_; - } - - private: - SemanticGraph::Path file_; - size_t line_; - size_t column_; - String ns_; - }; - - struct InvalidNamespaceMapping - { - InvalidNamespaceMapping (String const& mapping, - String const& reason) - : mapping_ (mapping), reason_ (reason) - { - } - - String const& - mapping () const - { - return mapping_; - } - - String const& - reason () const - { - return reason_; - } - - private: - String mapping_; - String reason_; - }; - - // - // - class Context - { - public: - typedef cutl::re::wregex RegexPat; - typedef cutl::re::wregexsub Regex; - typedef std::vector RegexMapping; - typedef std::map MapMapping; - typedef std::map MappingCache; - - typedef std::map ReservedNameMap; - typedef std::set KeywordSet; - - typedef CXX::options options_type; - - public: - Context (std::wostream& o, - SemanticGraph::Schema& root, - SemanticGraph::Path const& path, - options_type const& ops, - StringLiteralMap const* custom_literals_map); - - protected: - Context (Context& c) - : os (c.os), - schema_root (c.schema_root), - schema_path (c.schema_path), - options (c.options), - std (c.std), - char_type (c.char_type), - char_encoding (c.char_encoding), - L (c.L), - string_type (c.string_type), - auto_ptr (c.auto_ptr), - string_literal_map (c.string_literal_map), - type_exp (c.type_exp), - inst_exp (c.inst_exp), - inl (c.inl), - ns_mapping_cache (c.ns_mapping_cache), - xs_ns_ (c.xs_ns_), - cxx_id_expr (c.cxx_id_expr), - urn_mapping (c.urn_mapping), - nsr_mapping (c.nsr_mapping), - nsm_mapping (c.nsm_mapping), - include_mapping (c.include_mapping), - reserved_name_map (c.reserved_name_map), - keyword_set (c.keyword_set) - { - } - - Context (Context& c, std::wostream& o) - : os (o), - schema_root (c.schema_root), - schema_path (c.schema_path), - options (c.options), - std (c.std), - char_type (c.char_type), - char_encoding (c.char_encoding), - L (c.L), - string_type (c.string_type), - auto_ptr (c.auto_ptr), - string_literal_map (c.string_literal_map), - type_exp (c.type_exp), - inst_exp (c.inst_exp), - inl (c.inl), - ns_mapping_cache (c.ns_mapping_cache), - xs_ns_ (c.xs_ns_), - cxx_id_expr (c.cxx_id_expr), - urn_mapping (c.urn_mapping), - nsr_mapping (c.nsr_mapping), - nsm_mapping (c.nsm_mapping), - include_mapping (c.include_mapping), - reserved_name_map (c.reserved_name_map), - keyword_set (c.keyword_set) - { - } - - public: - static String - unclash (String const& name, String const& new_name) - { - return name == new_name ? (new_name + L'_') : new_name; - } - - public: - // Return UTF-32 character starting at this position. Position is - // advanced by 1 if this Unicode character takes more than one - // underlying character. - // - static unsigned int - unicode_char (String const& str, size_t& pos); - - static unsigned int - unicode_char (wchar_t const*& p); - - // Escape C++ keywords and illegal characters. - // - String - escape (String const&); - - // Create a string literal so that it can be used in C++ source - // code. It includes "". - // - String - strlit (String const&); - - // Escape the string so that it can be used in C++ comment. - // - String - comment (String const&); - - // Translate XML namespace name to a C++ identifier. - // - String - ns_name (SemanticGraph::Namespace&); - - // XML Schema namespace. - // - SemanticGraph::Namespace& - xs_ns (); - - // C++ namespace for XML Schema. - // - String - xs_ns_name (); - - // - // - SemanticGraph::Namespace& - namespace_ (SemanticGraph::Nameable& n); - - // Original XML namespace name. - // - String - xml_ns_name (SemanticGraph::Nameable& ns); - - - // Fully-qualified C++ name. - // - String - fq_name (SemanticGraph::Nameable& n, char const* name_key = "name"); - - public: - static SemanticGraph::Type& - ultimate_base (SemanticGraph::Complex&); - - public: - String - process_include_path (String const&) const; - - public: - static bool - skip (SemanticGraph::Member& m) - { - // "Subsequent" local element. - // - return !m.scope ().is_a () && - m.context ().count ("min") == 0; - } - - static size_t - min (SemanticGraph::Member const& m) - { - return m.context ().get ("min"); - } - - static size_t - min (SemanticGraph::Any const& a) - { - return a.context ().get ("min"); - } - - static size_t - max (SemanticGraph::Member const& m) - { - return m.context ().get ("max"); - } - - static size_t - max (SemanticGraph::Any const& a) - { - return a.context ().get ("max"); - } - - public: - // Get escaped name. - // - static String const& - ename (SemanticGraph::Nameable const& n) - { - return n.context ().get ("name"); - } - - public: - std::wostream& os; - - SemanticGraph::Schema& schema_root; - SemanticGraph::Path const& schema_path; - - options_type const& options; - - cxx_version std; - - String& char_type; - String& char_encoding; - String& L; // string literal prefix - String& string_type; - String& auto_ptr; - - StringLiteralMap const* string_literal_map; - - String& type_exp; - String& inst_exp; - String& inl; - - public: - MappingCache& ns_mapping_cache; - - private: - SemanticGraph::Path const schema_path_; - - SemanticGraph::Namespace* xs_ns_; - - String char_type_; - String char_encoding_; - String L_; - String string_type_; - String auto_ptr_; - - String type_exp_; - String inst_exp_; - String inl_; - - private: - RegexPat const cxx_id_expr_; - RegexPat const& cxx_id_expr; - Regex urn_mapping_; - RegexMapping nsr_mapping_; - MapMapping nsm_mapping_; - Regex const& urn_mapping; - RegexMapping const& nsr_mapping; - MapMapping const& nsm_mapping; - MappingCache ns_mapping_cache_; - - RegexMapping include_mapping_; - RegexMapping const& include_mapping; - - ReservedNameMap const& reserved_name_map; - ReservedNameMap reserved_name_map_; - - KeywordSet const& keyword_set; - KeywordSet keyword_set_; - }; - - inline unsigned int Context:: - unicode_char (String const& str, size_t& pos) - { - if (sizeof (wchar_t) == 4) - { - return str[pos]; - } - else if (sizeof (wchar_t) == 2) - { - wchar_t x (str[pos]); - - if (x < 0xD800 || x > 0xDBFF) - return x; - else - return ((x - 0xD800) << 10) + (str[++pos] - 0xDC00) + 0x10000; - } - else - return 0; - } - - inline unsigned int Context:: - unicode_char (wchar_t const*& p) - { - if (sizeof (wchar_t) == 4) - { - return *p; - } - else if (sizeof (wchar_t) == 2) - { - wchar_t x (*p); - - if (x < 0xD800 || x > 0xDBFF) - return x; - else - return ((x - 0xD800) << 10) + (*(++p) - 0xDC00) + 0x10000; - } - else - return 0; - } - - // Sources traverser that goes into each schema only once. - // - struct Sources: Traversal::Sources - { - virtual void - traverse (SemanticGraph::Sources& s) - { - if (schemas_.insert (&s.schema ()).second) - Traversal::Sources::traverse (s); - } - - private: - std::set schemas_; - }; - - // Usual namespace mapping. - // - struct Namespace: Traversal::Namespace - { - struct ScopeTracker - { - // First scope name if always empty (global scope). The last flag - // signals the last scope. - // - virtual void - enter (Type&, String const& name, bool last) = 0; - - virtual void - leave () = 0; - }; - - - Namespace (Context& c) - : ctx_ (c), st_ (0) - { - } - - Namespace (Context& c, ScopeTracker& st) - : ctx_ (c), st_ (&st) - { - } - - virtual void - pre (Type&); - - virtual void - post (Type&); - - private: - Context& ctx_; - ScopeTracker* st_; - }; - - // - // - template - struct Has : X - { - Has (bool& result) - : result_ (result) - { - } - - virtual void - traverse (typename X::Type&) - { - result_ = true; - } - - private: - bool& result_; - }; - - // Checks if scope 'Y' names any of 'X' - // - template - bool - has (Y& y) - { - using SemanticGraph::Scope; - - bool result (false); - Has t (result); - - for (Scope::NamesIterator i (y.names_begin ()), e (y.names_end ()); - !result && i != e; ++i) - t.dispatch (i->named ()); - - return result; - } - - // Checks if the compositor has any particle of 'X' - // - template - bool - has_particle (SemanticGraph::Compositor& y) - { - using SemanticGraph::Compositor; - - bool result (false); - Has t (result); - - for (Compositor::ContainsIterator i (y.contains_begin ()), - e (y.contains_end ()); !result && i != e; ++i) - { - SemanticGraph::Particle& p (i->particle ()); - - t.dispatch (p); - - if (!result && p.is_a ()) - result = has_particle (dynamic_cast (p)); - } - - return result; - } - - // Specialization for Complex - // - template - bool - has_particle (SemanticGraph::Complex& c) - { - return c.contains_compositor_p () && - has_particle (c.contains_compositor ().compositor ()); - } - - // Fundamental type mapping helper. - // - struct Fundamental: Traversal::Fundamental::Type, - Traversal::Fundamental::String, - Traversal::Fundamental::NormalizedString, - Traversal::Fundamental::Token, - Traversal::Fundamental::Name, - Traversal::Fundamental::NameToken, - Traversal::Fundamental::NCName, - Traversal::Fundamental::Id, - Traversal::Fundamental::IdRef - { - virtual void - fundamental_type (SemanticGraph::Fundamental::Type& t) = 0; - - virtual void - fundamental_template (SemanticGraph::Fundamental::Type& t) = 0; - - virtual void - traverse (SemanticGraph::Fundamental::Type& t) - { - fundamental_type (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::String& t) - { - fundamental_template (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::NormalizedString& t) - { - fundamental_template (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Token& t) - { - fundamental_template (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Name& t) - { - fundamental_template (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::NameToken& t) - { - fundamental_template (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::NCName& t) - { - fundamental_template (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Id& t) - { - fundamental_template (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::IdRef& t) - { - fundamental_template (t); - } - }; -} - -#endif // CXX_TREE_ELEMENTS_HXX diff --git a/xsd/cxx/literal-map.cxx b/xsd/cxx/literal-map.cxx deleted file mode 100644 index f2515fe..0000000 --- a/xsd/cxx/literal-map.cxx +++ /dev/null @@ -1,261 +0,0 @@ -// file : xsd/cxx/literal-map.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include // std::auto_ptr -#include // std::size_t -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include - -#include - -#include - -using namespace std; -using namespace xercesc; -namespace XML = XSDFrontend::XML; - -namespace CXX -{ - class Handler: public DefaultHandler - { - public: - struct Failed {}; - - Handler (String const& file, StringLiteralMap& map) - : state_ (s_init), file_ (file), map_ (map) - { - } - - virtual void - setDocumentLocator (const Locator* const l) - { - locator_ = l; - } - - virtual void - startElement (const XMLCh* const, - const XMLCh* const lname, - const XMLCh* const, - const xercesc::Attributes&) - { - String n (XML::transcode (lname)); - - if (n == L"string-literal-map" && state_ == s_init) - state_ = s_map; - else if (n == L"entry" && state_ == s_map) - { - str_seen_ = false; - lit_seen_ = false; - state_ = s_entry; - } - else if (n == L"string" && state_ == s_entry) - { - str_seen_ = true; - str_.clear (); - state_ = s_string; - } - else if (n == L"literal" && state_ == s_entry) - { - lit_seen_ = true; - lit_.clear (); - state_ = s_literal; - } - else - { - wcerr << file_ << ":" << line () << ":" << col () << ": error: " - << "unexpected element '" << n << "'" << endl; - throw Failed (); - } - } - - virtual void - endElement (const XMLCh* const, - const XMLCh* const lname, - const XMLCh* const) - { - String n (XML::transcode (lname)); - - if (n == L"string-literal-map") - state_ = s_init; - else if (n == L"entry") - { - if (!str_seen_) - { - wcerr << file_ << ":" << line () << ":" << col () << ": error: " - << "expected 'string' element" << endl; - throw Failed (); - } - - if (!lit_seen_) - { - wcerr << file_ << ":" << line () << ":" << col () << ": error: " - << "expected 'literal' element" << endl; - throw Failed (); - } - - map_[str_] = lit_; - state_ = s_map; - } - else if (n == L"string") - state_ = s_entry; - else if (n == L"literal") - state_ = s_entry; - } - - virtual void - characters (const XMLCh* const s, const XMLSize_t length) - { - String str (XML::transcode (s, length)); - - if (state_ == s_string) - str_ += str; - else if (state_ == s_literal) - lit_ += str; - else - { - for (size_t i (0); i < str.size (); ++i) - { - wchar_t c (str[i]); - - if (c != 0x20 && c != 0x0A && c != 0x0D && c != 0x09) - { - wcerr << file_ << ":" << line () << ":" << col () << ": error: " - << "unexpected character data" << endl; - throw Failed (); - } - } - } - } - - // Error hanlding. - // - enum Severity {s_warning, s_error, s_fatal}; - - virtual void - warning (const SAXParseException& e) - { - handle (e, s_warning); - } - - virtual void - error (const SAXParseException& e) - { - handle (e, s_error); - } - - virtual void - fatalError (const SAXParseException& e) - { - handle (e, s_fatal); - } - - virtual void - resetErrors () - { - } - - void - handle (const SAXParseException& e, Severity s) - { - String msg (XML::transcode (e.getMessage ())); - - wcerr << file_ << ":" - << e.getLineNumber () << ":" << e.getColumnNumber () << ": " - << (s == s_warning ? "warning: " : "error: ") << msg << endl; - - if (s != s_warning) - throw Failed (); - } - - size_t - line () const - { - return locator_ != 0 - ? static_cast (locator_->getLineNumber ()) - : 0; - } - - size_t - col () const - { - return locator_ != 0 - ? static_cast (locator_->getColumnNumber ()) - : 0; - } - - private: - const Locator* locator_; - - enum - { - s_init, - s_map, - s_entry, - s_string, - s_literal - } state_; - - String file_; - StringLiteralMap& map_; - - bool str_seen_; - bool lit_seen_; - - String str_; - String lit_; - }; - - bool - read_literal_map (NarrowString const& file, StringLiteralMap& map) - { - try - { - // Try to open the file with fstream. This way we get to - // report the error in a consistent manner. - // - { - ifstream ifs (file.c_str ()); - if (!ifs.is_open ()) - { - wcerr << file.c_str () << ": unable to open in read mode" << endl; - return false; - } - } - - String wfile (file); - - LocalFileInputSource is (XML::XMLChString (wfile).c_str ()); - Handler h (wfile, map); - - auto_ptr parser ( - XMLReaderFactory::createXMLReader ()); - - parser->setFeature (XMLUni::fgSAX2CoreNameSpaces, true); - parser->setFeature (XMLUni::fgSAX2CoreNameSpacePrefixes, true); - parser->setFeature (XMLUni::fgSAX2CoreValidation, false); - parser->setFeature (XMLUni::fgXercesSchema, false); - parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); - - parser->setErrorHandler (&h); - parser->setContentHandler (&h); - - parser->parse (is); - } - catch (Handler::Failed const&) - { - return false; - } - - return true; - } -} diff --git a/xsd/cxx/literal-map.hxx b/xsd/cxx/literal-map.hxx deleted file mode 100644 index cce9bf5..0000000 --- a/xsd/cxx/literal-map.hxx +++ /dev/null @@ -1,19 +0,0 @@ -// file : xsd/cxx/literal-map.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_LITERAL_MAP_HXX -#define CXX_LITERAL_MAP_HXX - -#include - -#include - -namespace CXX -{ - typedef std::map StringLiteralMap; - - bool - read_literal_map (NarrowString const& file, StringLiteralMap& map); -} - -#endif // CXX_LITERAL_MAP_HXX diff --git a/xsd/cxx/option-types.cxx b/xsd/cxx/option-types.cxx deleted file mode 100644 index ec49d29..0000000 --- a/xsd/cxx/option-types.cxx +++ /dev/null @@ -1,47 +0,0 @@ -// file : xsd/cxx/option-types.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include -#include - -#include - -using namespace std; - -namespace CXX -{ - // - // cxx_version - // - - static const char* cxx_version_[] = - { - "c++98", - "c++11" - }; - - string cxx_version:: - string () const - { - return cxx_version_[v_]; - } - - istream& - operator>> (istream& is, cxx_version& v) - { - string s; - is >> s; - - if (!is.fail ()) - { - if (s == "c++98") - v = cxx_version::cxx98; - else if (s == "c++11") - v = cxx_version::cxx11; - else - is.setstate (istream::failbit); - } - - return is; - } -} diff --git a/xsd/cxx/option-types.hxx b/xsd/cxx/option-types.hxx deleted file mode 100644 index f36a6ca..0000000 --- a/xsd/cxx/option-types.hxx +++ /dev/null @@ -1,34 +0,0 @@ -// file : xsd/cxx/option-types.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef XSD_OPTION_TYPES_HXX -#define XSD_OPTION_TYPES_HXX - -#include -#include - -namespace CXX -{ - struct cxx_version - { - enum value - { - cxx98, - cxx11 - }; - - cxx_version (value v = value (0)) : v_ (v) {} - operator value () const {return v_;} - - std::string - string () const; - - private: - value v_; - }; - - std::istream& - operator>> (std::istream&, cxx_version&); -} - -#endif // XSD_OPTION_TYPES_HXX diff --git a/xsd/cxx/options.cli b/xsd/cxx/options.cli deleted file mode 100644 index 6e25949..0000000 --- a/xsd/cxx/options.cli +++ /dev/null @@ -1,550 +0,0 @@ -// file : xsd/cxx/options.cli -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include ; // std::size_t - -include ; // NarrowString, NarrowStrings - -include ; - -include ; - -namespace CXX -{ - class options: ::options = 0 - { - // Language. - // - cxx_version --std = cxx_version::cxx98 - { - "", - "Specify the C++ standard that the generated code should conform to. - Valid values are \cb{c++98} (default) and \cb{c++11}. - - The C++ standard affects various aspects of the generated code that - are discussed in more detail in various mapping-specific - documentation. Overall, when C++11 is selected, the generated - code relies on the move semantics and uses \cb{std::unique_ptr} - instead of deprecated \cb{std::auto_ptr}. - - When the C++11 mode is selected, you normally don't need to - perform any extra steps other than enable C++11 in your C++ - compiler, if required. The XSD compiler will automatically - add the necessary macro defines to the generated header files - that will switch the header-only XSD runtime library (\cb{libxsd}) - to the C++11 mode. However, if you include any of the XSD runtime - headers directly in your application (normally you just include - the generated headers), then you will need to define the - \cb{XSD_CXX11} macro for your entire project." - }; - - // Character type and encoding. - // - NarrowString --char-type = "char" - { - "", - "Generate code using the provided character instead of the - default \cb{char}. Valid values are \cb{char} and \cb{wchar_t}." - }; - - NarrowString --char-encoding - { - "", - "Specify the character encoding that should be used in the generated - code. Valid values for the \cb{char} character type are \cb{utf8} - (default), \cb{iso8859-1}, \cb{lcp} (Xerces-C++ local code page), - and \cb{custom}. If you pass \cb{custom} as the value then you will - need to include the transcoder implementation header for your - encoding at the beginning of the generated header files (see the - \cb{--hxx-prologue} option). - - For the \cb{wchar_t} character type the only valid value is \cb{auto} - and the encoding is automatically selected between UTF-16 and - UTF-32/UCS-4, depending on the \cb{wchar_t} type size." - }; - - // Output options. - // - NarrowString --output-dir - { - "", - "Write generated files to instead of the current directory." - }; - - bool --generate-inline - { - "Generate simple functions inline. This option triggers creation of - the inline file." - }; - - // Extern XML Schema. - // - bool --generate-xml-schema - { - "Generate a C++ header file as if the schema being compiled defines the - XML Schema namespace. For the C++/Tree mapping, the resulting file will - contain definitions for all XML Schema built-in types. For the - C++/Parser mapping, the resulting file will contain definitions for - all the parser skeletons and implementations corresponding to the - XML Schema built-in types. - - The schema file provided to the compiler need not exist and is only - used to derive the name of the resulting header file. Use the - \cb{--extern-xml-schema} option to include this file in the - generated files for other schemas." - }; - - NarrowString --extern-xml-schema - { - "", - "Include a header file derived from instead of generating the - XML Schema namespace mapping inline. The provided file need not - exist and is only used to derive the name of the included header - file. Use the \cb{--generate-xml-schema} option to generate this - header file." - }; - - // Namespace mapping. - // - NarrowStrings --namespace-map - { - "=", - "Map XML Schema namespace to C++ namespace . Repeat - this option to specify mapping for more than one XML Schema namespace. - For example, the following option: - - \cb{--namespace-map http://example.com/foo/bar=foo::bar} - - Will map the \cb{http://example.com/foo/bar} XML Schema namespace to - the \cb{foo::bar} C++ namespace." - }; - - NarrowStrings --namespace-regex - { - "", - "Add to the list of regular expressions used to translate XML - Schema namespace names to C++ namespace names. is a Perl-like - regular expression in the form - \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. Any character can be - used as a delimiter instead of '\cb{/}'. Escaping of the delimiter - character in \ci{pattern} or \ci{replacement} is not supported. - - All the regular expressions are pushed into a stack with the last - specified expression considered first. The first match that - succeeds is used. Regular expressions are applied to a string in - the form - - \c{\i{filename} \i{namespace}} - - For example, if you have file \cb{hello.xsd} with namespace - \cb{http://example.com/hello} and you run \cb{xsd} on this file, - then the string in question will be: - - \cb{hello.xsd. http://example.com/hello} - - For the built-in XML Schema namespace the string is: - - \cb{XMLSchema.xsd http://www.w3.org/2001/XMLSchema} - - The following three steps are performed for each regular expression - until the match is found: - - 1. The expression is applied and if the result is empty the next - expression is considered. - - 2. All '\cb{/}' are replaced with '\cb{::}'. - - 3. The result is verified to be a valid C++ scope name (e.g., - \cb{foo::bar}). If this test succeeds, the result is used as a - C++ namespace name. - - As an example, the following expression maps XML Schema namespaces - in the form \cb{http://example.com/foo/bar} to C++ namespaces in the - form \cb{foo::bar}: - - \cb{%.* http://example.com/(.+)%$1%} - - See also the REGEX AND SHELL QUOTING section below." - }; - - bool --namespace-regex-trace - { - "Trace the process of applying regular expressions specified with the - \cb{--namespace-regex} option. Use this option to find out why your - regular expressions don't do what you expected them to do." - }; - - // Reserved names. - // - NarrowStrings --reserved-name - { - "[=]", - "Add name to the list of names that should not be used as - identifiers. The name can optionally be followed by \cb{=} and the - replacement name that should be used instead. All the C++ keywords - are already in this list." - }; - - // Include options. - // - bool --include-with-brackets - { - "Use angle brackets (<>) instead of quotes (\"\") in generated - \cb{#include} directives." - }; - - NarrowString --include-prefix - { - "", - "Add to generated \cb{#include} directive paths. - - For example, if you had the following import element in your schema - - \cb{} - - and compiled this fragment with \cb{--include-prefix schemas/}, then - the include directive in the generated code would be: - - \cb{#include \"schemas/base.hxx\"}" - }; - - NarrowStrings --include-regex - { - "", - "Add to the list of regular expressions used to transform - \cb{#include} directive paths. is a Perl-like regular - expression in the form \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. - Any character can be used as a delimiter instead of '\cb{/}'. Escaping - of the delimiter character in \ci{pattern} or \ci{replacement} is not - supported. - - All the regular expressions are pushed into a stack with the last - specified expression considered first. The first match that succeeds - is used. - - As an example, the following expression transforms paths in the form - \cb{schemas/foo/bar} to paths in the form \cb{generated/foo/bar}: - - \cb{%schemas/(.+)%generated/$1%} - - See also the REGEX AND SHELL QUOTING section below." - }; - - bool --include-regex-trace - { - "Trace the process of applying regular expressions specified with the - \cb{--include-regex} option. Use this option to find out why your - regular expressions don't do what you expected them to do." - }; - - NarrowString --guard-prefix - { - "", - "Add to generated header inclusion guards. The prefix is - transformed to upper case and characters that are illegal in a - preprocessor macro name are replaced with underscores. If this - option is not specified then the directory part of the input schema - file is used as a prefix." - }; - - // File suffixes. - // - NarrowString --hxx-suffix = ".hxx" - { - "", - "Use the provided instead of the default \cb{.hxx} to - construct the name of the header file. Note that this suffix is also - used to construct names of header files corresponding to - included/imported schemas." - }; - - NarrowString --ixx-suffix = ".ixx" - { - "", - "Use the provided instead of the default \cb{.ixx} to - construct the name of the inline file." - }; - - NarrowString --cxx-suffix = ".cxx" - { - "", - "Use the provided instead of the default \cb{.cxx} to - construct the name of the source file." - }; - - NarrowString --fwd-suffix = "-fwd.hxx" - { - "", - "Use the provided instead of the default \cb{-fwd.hxx} to - construct the name of the forward declaration file." - }; - - NarrowString --hxx-regex - { - "", - "Use the provided expression to construct the name of the header file. - is a Perl-like regular expression in the form - \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. - Note that this expression is also used to construct names of header - files corresponding to included/imported schemas. See also the REGEX - AND SHELL QUOTING section below." - }; - - NarrowString --ixx-regex - { - "", - "Use the provided expression to construct the name of the inline file. - is a Perl-like regular expression in the form - \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. See also the REGEX AND - SHELL QUOTING section below." - }; - - NarrowString --cxx-regex - { - "", - "Use the provided expression to construct the name of the source file. - is a Perl-like regular expression in the form - \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. See also the REGEX AND - SHELL QUOTING section below." - }; - - NarrowString --fwd-regex - { - "", - "Use the provided expression to construct the name of the forward - declaration file. is a Perl-like regular expression in the - form \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. See also the REGEX - AND SHELL QUOTING section below." - }; - - // Prologues/epilogues. - // - NarrowStrings --hxx-prologue - { - "", - "Insert at the beginning of the header file." - }; - - NarrowStrings --ixx-prologue - { - "", - "Insert at the beginning of the inline file." - }; - - NarrowStrings --cxx-prologue - { - "", - "Insert at the beginning of the source file." - }; - - NarrowStrings --fwd-prologue - { - "", - "Insert at the beginning of the forward declaration file." - }; - - NarrowStrings --prologue - { - "", - "Insert at the beginning of each generated file for which - there is no file-specific prologue." - }; - - NarrowStrings --hxx-epilogue - { - "", - "Insert at the end of the header file." - }; - - NarrowStrings --ixx-epilogue - { - "", - "Insert at the end of the inline file." - }; - - NarrowStrings --cxx-epilogue - { - "", - "Insert at the end of the source file." - }; - - NarrowStrings --fwd-epilogue - { - "", - "Insert at the end of the forward declaration file." - }; - - NarrowStrings --epilogue - { - "", - "Insert at the end of each generated file for which there - is no file-specific epilogue." - }; - - NarrowString --hxx-prologue-file - { - "", - "Insert the content of the at the beginning of the header file." - }; - - NarrowString --ixx-prologue-file - { - "", - "Insert the content of the at the beginning of the inline file." - }; - - NarrowString --cxx-prologue-file - { - "", - "Insert the content of the at the beginning of the source file." - }; - - NarrowString --fwd-prologue-file - { - "", - "Insert the content of the at the beginning of the forward - declaration file." - }; - - NarrowString --prologue-file - { - "", - "Insert the content of the at the beginning of each generated - file for which there is no file-specific prologue file." - }; - - NarrowString --hxx-epilogue-file - { - "", - "Insert the content of the at the end of the header file." - }; - - NarrowString --ixx-epilogue-file - { - "", - "Insert the content of the at the end of the inline file." - }; - - NarrowString --cxx-epilogue-file - { - "", - "Insert the content of the at the end of the source file." - }; - - NarrowString --fwd-epilogue-file - { - "", - "Insert the content of the at the end of the forward declaration - file." - }; - - NarrowString --epilogue-file - { - "", - "Insert the content of the at the end of each generated file - for which there is no file-specific epilogue file." - }; - - // Export options. - // - NarrowString --export-symbol - { - "", - "Insert in places where DLL export/import control statements - (\cb{__declspec(dllexport/dllimport)}) are necessary." - }; - - bool --export-xml-schema - { - "Export/import types in the XML Schema namespace using the export - symbol provided with the \cb{--export-symbol} option. The - \cb{XSD_NO_EXPORT} macro can be used to omit this code during C++ - compilation, which may be useful if you would like to use the same - generated code across multiple platforms." - }; - - bool --export-maps - { - "Export polymorphism support maps from a Win32 DLL into which this - generated code is placed. This is necessary when your type hierarchy - is split across several DLLs since otherwise each DLL will have its - own set of maps. In this situation the generated code for the DLL - which contains base types and/or substitution group heads should be - compiled with this option and the generated code for all other DLLs - should be compiled with \cb{--import-maps}. This option is only valid - together with \cb{--generate-polymorphic}. The \cb{XSD_NO_EXPORT} - macro can be used to omit this code during C++ compilation, which may - be useful if you would like to use the same generated code across - multiple platforms." - }; - - bool --import-maps - { - "Import polymorphism support maps to a Win32 DLL or executable into - which this generated code is linked. See the \cb{--export-maps} - option documentation for details. This options is only valid together - with \cb{--generate-polymorphic}. The \cb{XSD_NO_EXPORT} macro can be - used to omit this code during C++ compilation, which may be useful if - you would like to use the same generated code across multiple - platforms." - }; - - // Make dependency generation. - // - bool --generate-dep - { - "Generate \cb{make} dependency information. This option triggers the - creation of the \cb{.d} file containing the dependencies of the - generated files on the main schema file as well as all the schema - files that it includes/imports, transitively. This dependency file - is then normally included into the main \cb{makefile} to implement - automatic dependency tracking. - - Note also that automatic dependency generation is not supported in - the file-per-type mode (\cb{--file-per-type}). In this case, all - the generated files are produced with a single compiler invocation - and depend on all the schemas. As a result, it is easier to establish - such a dependency manually, perhaps with the help of the - \cb{--file-list*} options." - }; - - bool --generate-dep-only - { - "Generate \cb{make} dependency information only." - }; - - bool --dep-phony - { - "Generate phony targets for included/imported schema files, causing - each to depend on nothing. Such dummy rules work around \cb{make} - errors caused by the removal of schema files without also updating - the dependency file to match." - }; - - NarrowStrings --dep-target - { - "", - "Change the target of the dependency rule. By default it contains - all the generated C++ files as well as the dependency file itself, - without any directory prefixes. If you require multiple targets, - then you can specify them as a single, space-separated argument or - you can repeat this option multiple times." - }; - - NarrowString --dep-suffix = ".d" - { - "", - "Use the provided instead of the default \cb{.d} to - construct the name of the dependency file." - }; - - NarrowString --dep-regex - { - "", - "Use the provided expression to construct the name of the dependency - file. is a Perl-like regular expression in the form - \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. See also the REGEX - AND SHELL QUOTING section below." - }; - }; -} diff --git a/xsd/cxx/parser/attribute-validation-source.cxx b/xsd/cxx/parser/attribute-validation-source.cxx deleted file mode 100644 index 76a3923..0000000 --- a/xsd/cxx/parser/attribute-validation-source.cxx +++ /dev/null @@ -1,412 +0,0 @@ -// file : xsd/cxx/parser/attribute-validation-source.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include -#include - -namespace CXX -{ - namespace Parser - { - namespace - { - struct Test: Traversal::Attribute, - Traversal::AnyAttribute, - Context - { - Test (Context& c) - : Context (c) - { - } - - virtual void - traverse (SemanticGraph::Attribute& a) - { - String const& name (a.name ()); - - if (a.qualified_p () && a.namespace_ ().name ()) - { - String const& ns (a.namespace_ ().name ()); - - os << "n == " << strlit (name) << " &&" << endl - << "ns == " << strlit (ns); - } - else - os << "n == " << strlit (name) << " && ns.empty ()"; - } - - virtual void - traverse (SemanticGraph::AnyAttribute& a) - { - String const& ns (a.definition_namespace ().name ()); - - for (SemanticGraph::AnyAttribute::NamespaceIterator - i (a.namespace_begin ()), e (a.namespace_end ()); i != e;) - { - if (*i == L"##any") - { - os << "!n.empty ()"; - } - else if (*i == L"##other") - { - if (ns) - { - // Note that here I assume that ##other does not include - // unqualified names in a schema with target namespace. - // This is not what the spec says but that seems to be - // the consensus. - // - os << "(!ns.empty () && ns != " << strlit (ns) << ")"; - } - else - os << "!ns.empty ()"; - } - else if (*i == L"##local") - { - os << "(ns.empty () && !n.empty ())"; - } - else if (*i == L"##targetNamespace") - { - os << "ns == " << strlit (ns); - } - else - { - os << "ns == " << strlit (*i); - } - - if (++i != e) - os << " ||" << endl; - } - } - }; - - // - // - struct PhaseOne: Traversal::Attribute, Context - { - PhaseOne (Context& c) - : Context (c), test_ (c) - { - } - - virtual void - traverse (Type& a) - { - String const& name (ename (a)); - String const& inst (emember (a)); - - SemanticGraph::Type& type (a.type ()); - String const& post (post_name (type)); - String const& ret (ret_type (type)); - - os << "if ("; - - test_.traverse (a); - - os << ")" - << "{" - << "if (this->" << inst << ")" - << "{" - << "this->" << inst << "->pre ();" - << "this->" << inst << "->_pre_impl ();" - << "this->" << inst << "->_characters (s);" - << "this->" << inst << "->_post_impl ();"; - - if (ret == L"void") - os << "this->" << inst << "->" << post << " ();" - << "this->" << name << " ();"; - else - { - // Don't create an lvalue in C++11 (think std::unique_ptr). - // In C++98 we do it for compatibility with older/broken - // compilers (e.g., IBM xlC that needs an lvalue to pass - // std::auto_ptr). - // - if (std == cxx_version::cxx98) - os << arg_type (type) << " tmp (this->" << inst << "->" << - post << " ());" - << "this->" << name << " (tmp);"; - else - os << "this->" << name << " (this->" << inst << "->" << - post << " ());"; - } - - os << "}"; - - if (!a.optional_p ()) - os << "static_cast< v_state_attr_* > (" << - "this->v_state_attr_stack_.top ())->" << name << " = true;"; - - os << "return true;" - << "}"; - } - - private: - Test test_; - }; - - - // - // - struct PhaseTwo: Traversal::AnyAttribute, Context - { - PhaseTwo (Context& c) - : Context (c), test_ (c) - { - } - - virtual void - traverse (Type& a) - { - os << "if ("; - - test_.traverse (a); - - os << ")" << endl - << "{" - << "this->_any_attribute (ns, n, s);" - << "return true;" - << "}"; - } - - private: - Test test_; - }; - - - // - // - struct AttributeStateInit: Traversal::Attribute, Context - { - AttributeStateInit (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& a) - { - if (!a.optional_p ()) - os << "as." << ename (a) << " = false;"; - } - }; - - - // - // - struct AttributeStateCheck: Traversal::Attribute, Context - { - AttributeStateCheck (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& a) - { - if (!a.optional_p ()) - { - String ns (a.qualified_p () ? a.namespace_ ().name () : String ()); - - os << "if (!as." << ename (a) << ")" << endl - << "this->_expected_attribute (" << endl - << strlit (ns) << ", " << strlit (a.name ()) << ");"; - } - } - }; - - // - // - struct Complex: Traversal::Complex, Context - { - Complex (Context& c) - : Context (c), - phase_one_ (c), - phase_two_ (c), - attribute_state_init_ (c), - attribute_state_check_ (c) - { - names_phase_one_ >> phase_one_; - names_phase_two_ >> phase_two_; - - names_attribute_state_init_ >> attribute_state_init_; - names_attribute_state_check_ >> attribute_state_check_; - } - - virtual void - traverse (Type& c) - { - bool has_att (has (c)); - bool has_any (has (c)); - - if (!has_att && !has_any) - return; - - bool has_req_att (false); - if (has_att) - { - RequiredAttributeTest test (has_req_att); - Traversal::Names names_test (test); - names (c, names_test); - } - - String const& name (ename (c)); - - os <<"// Attribute validation and dispatch functions for " << - name << "." << endl - <<"//" << endl; - - if (has_att) - { - // _attribute_impl_phase_one - // - os << "bool " << name << "::" << endl - << "_attribute_impl_phase_one (const " << string_type << - "& ns," << endl - << "const " << string_type << "& n," << endl - << "const " << string_type << "& s)" << endl - << "{"; - - names (c, names_phase_one_); - - // Nothing matched - call our base (extension) or return false - // if there is no base (or restriction (even from anyType)). - // - os << "return "; - - if (c.inherits_p () && - !c.inherits ().is_a ()) - { - os << "this->" << fq_name (c.inherits ().base ()) << - "::_attribute_impl_phase_one (ns, n, s);"; - } - else - os << "false;"; - - os << "}"; - } - - - if (has_any) - { - // _attribute_impl_phase_two - // - os << "bool " << name << "::" << endl - << "_attribute_impl_phase_two (const " << string_type << - "& ns," << endl - << "const " << string_type << "& n," << endl - << "const " << string_type << "& s)" - << "{"; - - names (c, names_phase_two_); - - // Nothing matched - call our base (extension) or return false - // if there is no base (or restriction (even from anyType)). - // - os << "return "; - - if (c.inherits_p () && - !c.inherits ().is_a ()) - { - os << "this->" << fq_name (c.inherits ().base ()) << - "::_attribute_impl_phase_two (ns, n, s);"; - } - else - os << "false;"; - - os << "}"; - } - - if (has_req_att) - { - // _pre_a_validate - // - os << "void " << name << "::" << endl - << "_pre_a_validate ()" - << "{" - << "this->v_state_attr_stack_.push ();" - << "v_state_attr_& as = *static_cast< v_state_attr_* > (" << - "this->v_state_attr_stack_.top ());" - << endl; - - names (c, names_attribute_state_init_); - - // Call our base (extension) last. - // - if (c.inherits_p () && - !c.inherits ().is_a ()) - { - os << "this->" << fq_name (c.inherits ().base ()) << - "::_pre_a_validate ();"; - } - - os << "}"; - - - // _post_a_validate - // - os << "void " << name << "::" << endl - << "_post_a_validate ()" - << "{"; - - // Call our base (extension) first. - // - if (c.inherits_p () && - !c.inherits ().is_a ()) - { - os << "this->" << fq_name (c.inherits ().base ()) << - "::_post_a_validate ();" - << endl; - } - - os << "v_state_attr_& as = *static_cast< v_state_attr_* > (" << - "this->v_state_attr_stack_.top ());" - << endl; - - names (c, names_attribute_state_check_); - - os << endl - << "this->v_state_attr_stack_.pop ();" - << "}"; - } - } - - private: - PhaseOne phase_one_; - Traversal::Names names_phase_one_; - - PhaseTwo phase_two_; - Traversal::Names names_phase_two_; - - AttributeStateInit attribute_state_init_; - Traversal::Names names_attribute_state_init_; - - AttributeStateCheck attribute_state_check_; - Traversal::Names names_attribute_state_check_; - }; - } - - void - generate_attribute_validation_source (Context& ctx) - { - Traversal::Schema schema; - - Sources sources; - Traversal::Names schema_names; - - Namespace ns (ctx); - Traversal::Names names; - - schema >> sources >> schema; - schema >> schema_names >> ns >> names; - - Complex complex (ctx); - - names >> complex; - - schema.dispatch (ctx.schema_root); - } - } -} diff --git a/xsd/cxx/parser/attribute-validation-source.hxx b/xsd/cxx/parser/attribute-validation-source.hxx deleted file mode 100644 index 25d7d96..0000000 --- a/xsd/cxx/parser/attribute-validation-source.hxx +++ /dev/null @@ -1,18 +0,0 @@ -// file : xsd/cxx/parser/attribute-validation-source.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_PARSER_ATTRIBUTE_VALIDATION_SOURCE_HXX -#define CXX_PARSER_ATTRIBUTE_VALIDATION_SOURCE_HXX - -#include - -namespace CXX -{ - namespace Parser - { - void - generate_attribute_validation_source (Context&); - } -} - -#endif // CXX_PARSER_ATTRIBUTE_VALIDATION_SOURCE_HXX diff --git a/xsd/cxx/parser/characters-validation-source.cxx b/xsd/cxx/parser/characters-validation-source.cxx deleted file mode 100644 index 3f3e88c..0000000 --- a/xsd/cxx/parser/characters-validation-source.cxx +++ /dev/null @@ -1,73 +0,0 @@ -// file : xsd/cxx/parser/characters-validation-source.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include -#include - -namespace CXX -{ - namespace Parser - { - namespace - { - // - // - struct Complex: Traversal::Complex, Context - { - Complex (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& c) - { - if (!c.mixed_p ()) - return; - - String const& name (ename (c)); - - os <<"// Character validation functions for " << name << "." << endl - <<"//" << endl; - - // _characters_impl - // - os << "bool " << name << "::" << endl - << "_characters_impl (const " << string_type << "& s)" - << "{" - << "this->_any_characters (s);" - << "return true;" - << "}"; - } - }; - } - - void - generate_characters_validation_source (Context& ctx) - { - //@@ Most of the time there is no mixed content type so - // we generate an empty namespace which looks ugly. Will - // need to implement smart namespace to handle this at - // some point. - // - Traversal::Schema schema; - - Sources sources; - Traversal::Names schema_names; - - Namespace ns (ctx); - Traversal::Names names; - - schema >> sources >> schema; - schema >> schema_names >> ns >> names; - - Complex complex (ctx); - - names >> complex; - - schema.dispatch (ctx.schema_root); - } - } -} diff --git a/xsd/cxx/parser/characters-validation-source.hxx b/xsd/cxx/parser/characters-validation-source.hxx deleted file mode 100644 index d0c73c4..0000000 --- a/xsd/cxx/parser/characters-validation-source.hxx +++ /dev/null @@ -1,18 +0,0 @@ -// file : xsd/cxx/parser/characters-validation-source.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_PARSER_CHARACTERS_VALIDATION_SOURCE_HXX -#define CXX_PARSER_CHARACTERS_VALIDATION_SOURCE_HXX - -#include - -namespace CXX -{ - namespace Parser - { - void - generate_characters_validation_source (Context&); - } -} - -#endif // CXX_PARSER_CHARACTERS_VALIDATION_SOURCE_HXX diff --git a/xsd/cxx/parser/driver-source.cxx b/xsd/cxx/parser/driver-source.cxx deleted file mode 100644 index 48775eb..0000000 --- a/xsd/cxx/parser/driver-source.cxx +++ /dev/null @@ -1,775 +0,0 @@ -// file : xsd/cxx/parser/driver-source.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include -#include -#include - -#include -#include - -#include -#include - -using namespace std; - -namespace CXX -{ - namespace Parser - { - namespace - { - typedef map TypeInstanceMap; - typedef set InstanceSet; - - // For base types we only want member's types, but not the - // base itself. - // - struct BaseType: Traversal::Complex, - Traversal::List, - Context - { - BaseType (Context& c, Traversal::NodeBase& def) - : Context (c), def_ (def) - { - } - - virtual void - traverse (SemanticGraph::Complex& c) - { - inherits (c); - - if (!restriction_p (c)) - names (c); - } - - virtual void - traverse (SemanticGraph::List& l) - { - def_.dispatch (l.argumented ().type ()); - } - - private: - Traversal::NodeBase& def_; - }; - - struct ParserDef: Traversal::Type, - Traversal::List, - Traversal::Complex, - - Traversal::AnyType, - Traversal::AnySimpleType, - - Traversal::Fundamental::Byte, - Traversal::Fundamental::UnsignedByte, - Traversal::Fundamental::Short, - Traversal::Fundamental::UnsignedShort, - Traversal::Fundamental::Int, - Traversal::Fundamental::UnsignedInt, - Traversal::Fundamental::Long, - Traversal::Fundamental::UnsignedLong, - Traversal::Fundamental::Integer, - Traversal::Fundamental::NonPositiveInteger, - Traversal::Fundamental::NonNegativeInteger, - Traversal::Fundamental::PositiveInteger, - Traversal::Fundamental::NegativeInteger, - - Traversal::Fundamental::Boolean, - - Traversal::Fundamental::Float, - Traversal::Fundamental::Double, - Traversal::Fundamental::Decimal, - - Traversal::Fundamental::String, - Traversal::Fundamental::NormalizedString, - Traversal::Fundamental::Token, - Traversal::Fundamental::Name, - Traversal::Fundamental::NameToken, - Traversal::Fundamental::NameTokens, - Traversal::Fundamental::NCName, - Traversal::Fundamental::Language, - - Traversal::Fundamental::QName, - - Traversal::Fundamental::Id, - Traversal::Fundamental::IdRef, - Traversal::Fundamental::IdRefs, - - Traversal::Fundamental::AnyURI, - - Traversal::Fundamental::Base64Binary, - Traversal::Fundamental::HexBinary, - - Traversal::Fundamental::Date, - Traversal::Fundamental::DateTime, - Traversal::Fundamental::Duration, - Traversal::Fundamental::Day, - Traversal::Fundamental::Month, - Traversal::Fundamental::MonthDay, - Traversal::Fundamental::Year, - Traversal::Fundamental::YearMonth, - Traversal::Fundamental::Time, - - Traversal::Fundamental::Entity, - Traversal::Fundamental::Entities, - - Context - { - ParserDef (Context& c, TypeInstanceMap& map, InstanceSet& set) - : Context (c), map_ (map), set_ (set), base_ (c, *this) - { - *this >> inherits_ >> base_ >> inherits_; - - *this >> names_; - base_ >> names_; - - names_ >> member_ >> belongs_ >> *this; - } - - virtual void - traverse (SemanticGraph::Type& t) - { - if (map_.find (&t) == map_.end ()) - { - String inst (find_instance_name (t)); - map_[&t] = inst; - - os << fq_name (t, "impl") << " " << inst << ";"; - } - } - - virtual void - traverse (SemanticGraph::List& l) - { - if (map_.find (&l) == map_.end ()) - { - String inst (find_instance_name (l)); - map_[&l] = inst; - - os << fq_name (l, "impl") << " " << inst << ";"; - - dispatch (l.argumented ().type ()); - } - } - - virtual void - traverse (SemanticGraph::Complex& c) - { - if (map_.find (&c) == map_.end ()) - { - String inst (find_instance_name (c)); - map_[&c] = inst; - - os << fq_name (c, "impl") << " " << inst << ";"; - - inherits (c); - - if (!restriction_p (c)) - names (c); - } - } - - // anyType & anySimpleType. - // - virtual void - traverse (SemanticGraph::AnyType& t) - { - fund_type (t, "any_type"); - } - - virtual void - traverse (SemanticGraph::AnySimpleType& t) - { - fund_type (t, "any_simple_type"); - } - - // Boolean. - // - virtual void - traverse (SemanticGraph::Fundamental::Boolean& t) - { - fund_type (t, "boolean"); - } - - // Integral types. - // - virtual void - traverse (SemanticGraph::Fundamental::Byte& t) - { - fund_type (t, "byte"); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedByte& t) - { - fund_type (t, "unsigned_byte"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Short& t) - { - fund_type (t, "short"); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedShort& t) - { - fund_type (t, "unsigned_short"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Int& t) - { - fund_type (t, "int"); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedInt& t) - { - fund_type (t, "unsigned_int"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Long& t) - { - fund_type (t, "long"); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedLong& t) - { - fund_type (t, "unsigned_long"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Integer& t) - { - fund_type (t, "integer"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) - { - fund_type (t, "non_positive_integer"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) - { - fund_type (t, "non_negative_integer"); - } - - virtual void - traverse (SemanticGraph::Fundamental::PositiveInteger& t) - { - fund_type (t, "positive_integer"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NegativeInteger& t) - { - fund_type (t, "negative_integer"); - } - - // Floats. - // - virtual void - traverse (SemanticGraph::Fundamental::Float& t) - { - fund_type (t, "float"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Double& t) - { - fund_type (t, "double"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Decimal& t) - { - fund_type (t, "decimal"); - } - - // Strings. - // - virtual void - traverse (SemanticGraph::Fundamental::String& t) - { - fund_type (t, "string"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NormalizedString& t) - { - fund_type (t, "normalized_string"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Token& t) - { - fund_type (t, "token"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NameToken& t) - { - fund_type (t, "nmtoken"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NameTokens& t) - { - fund_type (t, "nmtokens"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Name& t) - { - fund_type (t, "name"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NCName& t) - { - fund_type (t, "ncname"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Language& t) - { - fund_type (t, "language"); - } - - - // Qualified name. - // - virtual void - traverse (SemanticGraph::Fundamental::QName& t) - { - fund_type (t, "qname"); - } - - - // ID/IDREF. - // - virtual void - traverse (SemanticGraph::Fundamental::Id& t) - { - fund_type (t, "id"); - } - - virtual void - traverse (SemanticGraph::Fundamental::IdRef& t) - { - fund_type (t, "idref"); - } - - virtual void - traverse (SemanticGraph::Fundamental::IdRefs& t) - { - fund_type (t, "idrefs"); - } - - // URI. - // - virtual void - traverse (SemanticGraph::Fundamental::AnyURI& t) - { - fund_type (t, "uri"); - } - - // Binary. - // - virtual void - traverse (SemanticGraph::Fundamental::Base64Binary& t) - { - fund_type (t, "base64_binary"); - } - - virtual void - traverse (SemanticGraph::Fundamental::HexBinary& t) - { - fund_type (t, "hex_binary"); - } - - - // Date/time. - // - virtual void - traverse (SemanticGraph::Fundamental::Date& t) - { - fund_type (t, "date"); - } - - virtual void - traverse (SemanticGraph::Fundamental::DateTime& t) - { - fund_type (t, "date_time"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Duration& t) - { - fund_type (t, "duration"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Day& t) - { - fund_type (t, "day"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Month& t) - { - fund_type (t, "month"); - } - - virtual void - traverse (SemanticGraph::Fundamental::MonthDay& t) - { - fund_type (t, "month_day"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Year& t) - { - fund_type (t, "year"); - } - - virtual void - traverse (SemanticGraph::Fundamental::YearMonth& t) - { - fund_type (t, "year_month"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Time& t) - { - fund_type (t, "time"); - } - - // Entity. - // - virtual void - traverse (SemanticGraph::Fundamental::Entity& t) - { - fund_type (t, "entity"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Entities& t) - { - fund_type (t, "entities"); - } - - private: - virtual void - fund_type (SemanticGraph::Type& t, String const& name) - { - if (map_.find (&t) == map_.end ()) - { - String inst (find_instance_name (name)); - map_[&t] = inst; - - os << fq_name (t, "impl") << " " << inst << ";"; - } - } - - String - find_instance_name (String const& raw_name) - { - String base_name (escape (raw_name + L"_p")); - String name (base_name); - - for (size_t i (1); set_.find (name) != set_.end (); ++i) - { - std::wostringstream os; - os << i; - name = base_name + os.str (); - } - - set_.insert (name); - return name; - } - - String - find_instance_name (SemanticGraph::Type& t) - { - return find_instance_name (t.name ()); - } - - TypeInstanceMap& map_; - InstanceSet& set_; - - BaseType base_; - Traversal::Inherits inherits_; - - Traversal::Names names_; - Traversal::Member member_; - Traversal::Belongs belongs_; - }; - - struct ArgList: Traversal::Complex, - Traversal::List, - Traversal::Member, - Context - { - ArgList (Context& c, TypeInstanceMap& map) - : Context (c), map_ (map), first_ (true) - { - inherits_ >> *this; - names_ >> *this; - } - - virtual void - traverse (SemanticGraph::Complex& c) - { - inherits (c, inherits_); - - if (!restriction_p (c)) - names (c, names_); - } - - virtual void - traverse (SemanticGraph::List& l) - { - if (!first_) - os << "," << endl; - else - first_ = false; - - os << map_[&l.argumented ().type ()]; - } - - virtual void - traverse (SemanticGraph::Member& m) - { - if (skip (m)) - return; - - if (!first_) - os << "," << endl; - else - first_ = false; - - os << map_[&m.type ()]; - } - - private: - TypeInstanceMap& map_; - - Traversal::Inherits inherits_; - Traversal::Names names_; - - bool first_; - }; - - struct ParserConnect: Traversal::List, - Traversal::Complex, - Context - { - ParserConnect (Context& c, TypeInstanceMap& map) - : Context (c), map_ (map), base_ (c, *this) - { - *this >> inherits_ >> base_ >> inherits_; - - *this >> names_; - base_ >> names_; - - names_ >> member_ >> belongs_ >> *this; - } - - virtual void - traverse (SemanticGraph::List& l) - { - if (type_set_.find (&l) == type_set_.end ()) - { - os << map_[&l] << ".parsers (" << - map_[&l.argumented ().type ()] << ");" - << endl; - - type_set_.insert (&l); - } - } - - virtual void - traverse (SemanticGraph::Complex& c) - { - if (type_set_.find (&c) == type_set_.end ()) - { - if (has_members (c)) - { - os << map_[&c] << ".parsers ("; - - ArgList args (*this, map_); - args.dispatch (c); - - os << ");" - << endl; - } - - type_set_.insert (&c); - - inherits (c); - - if (!restriction_p (c)) - names (c); - } - } - - private: - bool - has_members (SemanticGraph::Complex& c) - { - using SemanticGraph::Complex; - - if (has (c)) - return true; - - if (c.inherits_p ()) - { - SemanticGraph::Type& b (c.inherits ().base ()); - - if (Complex* cb = dynamic_cast (&b)) - return has_members (*cb); - - return b.is_a (); - } - - return false; - } - - private: - TypeInstanceMap& map_; - set type_set_; - - BaseType base_; - Traversal::Inherits inherits_; - - Traversal::Names names_; - Traversal::Member member_; - Traversal::Belongs belongs_; - }; - } - - void - generate_driver_source (Context& ctx) - { - // Figure out the root element. Validator should have made sure - // it is unique. - // - SemanticGraph::Element* root (0); - { - Traversal::Schema schema; - Sources sources; - - schema >> sources >> schema; - - Traversal::Names schema_names; - Traversal::Namespace ns; - Traversal::Names ns_names; - RootElement root_element (ctx.options, root); - - schema >> schema_names >> ns >> ns_names >> root_element; - - schema.dispatch (ctx.schema_root); - } - - std::wostream& os (ctx.os); - String const& L (ctx.L); - String const& cerr (ctx.cerr_inst); - - InstanceSet set; - TypeInstanceMap map; - SemanticGraph::Type& root_type (root->type ()); - - set.insert ("doc_p"); - - os << "#include " << endl - << endl - << "int" << endl - << "main (int argc, char* argv[])" - << "{" - << "if (argc != 2)" - << "{" - << cerr << " << " << L << "\"usage: \" << argv[0] << " << - L << "\" file.xml\" << std::endl;" - << "return 1;" - << "}" - << "try" - << "{" - << "// Instantiate individual parsers." << endl - << "//" << endl; - - { - ParserDef def (ctx, map, set); - def.dispatch (root_type); - } - - os << endl - << "// Connect the parsers together." << endl - << "//" << endl; - - { - ParserConnect connect (ctx, map); - connect.dispatch (root_type); - } - - String const& root_p (map[&root_type]); - - os << "// Parse the XML document." << endl - << "//" << endl; - - if (root->namespace_().name ()) - os << ctx.xs_ns_name () << "::document doc_p (" << endl - << root_p << "," << endl - << ctx.strlit (root->namespace_().name ()) << "," << endl - << ctx.strlit (root->name ()) << ");" - << endl; - else - os << ctx.xs_ns_name () << "::document doc_p (" << root_p << ", " << - ctx.strlit (root->name ()) << ");" - << endl; - - os << root_p << ".pre ();" - << "doc_p.parse (argv[1]);"; - - String const& ret (Context::ret_type (root_type)); - String const& post (Context::post_name (root_type)); - - if (ret == L"void") - os << root_p << "." << post << " ();"; - else - { - os << Context::arg_type (root_type) << " v (" << - root_p << "." << post << " ());" - << endl; - - if (ctx.options.generate_print_impl ()) - { - PrintCall t (ctx, root->name (), "v"); - t.dispatch (root_type); - } - else - os << "// TODO" << endl - << "//" << endl; - } - - os << "}" // try - << "catch (const " << ctx.xs_ns_name () << "::exception& e)" - << "{" - << cerr << " << e << std::endl;" - << "return 1;" - << "}" - << "catch (const std::ios_base::failure&)" - << "{" - << cerr << " << argv[1] << " << - L << "\": error: io failure\" << std::endl;" - << "return 1;" - << "}" - << "}"; - } - } -} diff --git a/xsd/cxx/parser/driver-source.hxx b/xsd/cxx/parser/driver-source.hxx deleted file mode 100644 index d1c7f91..0000000 --- a/xsd/cxx/parser/driver-source.hxx +++ /dev/null @@ -1,18 +0,0 @@ -// file : xsd/cxx/parser/driver-source.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_PARSER_DRIVER_SOURCE_HXX -#define CXX_PARSER_DRIVER_SOURCE_HXX - -#include - -namespace CXX -{ - namespace Parser - { - void - generate_driver_source (Context&); - } -} - -#endif // CXX_PARSER_DRIVER_SOURCE_HXX diff --git a/xsd/cxx/parser/element-validation-source.cxx b/xsd/cxx/parser/element-validation-source.cxx deleted file mode 100644 index b34b3dd..0000000 --- a/xsd/cxx/parser/element-validation-source.cxx +++ /dev/null @@ -1,1600 +0,0 @@ -// file : xsd/cxx/parser/element-validation-source.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include - -#include -#include - -using namespace std; - -namespace CXX -{ - namespace Parser - { - namespace - { - typedef vector Particles; - - // - // - struct ParticleTest: Traversal::Compositor, - Traversal::Element, - Traversal::Any, - Context - { - ParticleTest (Context& c) - : Context (c) - { - } - - virtual void - traverse (SemanticGraph::Element& e) - { - String const& name (e.name ()); - - if (polymorphic && e.global_p ()) - os << "("; - - if (e.qualified_p () && e.namespace_ ().name ()) - { - String const& ns (e.namespace_ ().name ()); - - os << "n == " << strlit (name) << " &&" << endl - << "ns == " << strlit (ns); - } - else - os << "n == " << strlit (name) << " && ns.empty ()"; - - - // Only a globally-defined element can be a subst-group root. - // - if (polymorphic && e.global_p ()) - { - os << ") ||" << endl - << "::xsd::cxx::parser::substitution_map_instance< " << - char_type << " > ().check (" << endl - << "ns, n, " << strlit (e.namespace_ ().name ()) << - ", " << strlit (name) << ", t)"; - } - } - - virtual void - traverse (SemanticGraph::Any& a) - { - String const& ns (a.definition_namespace ().name ()); - - // Note that we need to make sure the "flush" element (both name - // and namespace are empty) does not match any compositor. - // - for (SemanticGraph::Any::NamespaceIterator i (a.namespace_begin ()), - e (a.namespace_end ()); i != e;) - { - if (*i == L"##any") - { - os << "!n.empty ()"; - } - else if (*i == L"##other") - { - if (ns) - { - // Note that here I assume that ##other does not include - // unqualified names in a schema with target namespace. - // This is not what the spec says but that seems to be - // the consensus. - // - os << "(!ns.empty () && ns != " << strlit (ns) << ")"; - } - else - os << "!ns.empty ()"; - } - else if (*i == L"##local") - { - os << "(ns.empty () && !n.empty ())"; - } - else if (*i == L"##targetNamespace") - { - os << "ns == " << strlit (ns); - } - else - { - os << "ns == " << strlit (*i); - } - - if (++i != e) - os << " ||" << endl; - } - } - - virtual void - traverse (SemanticGraph::Compositor& c) - { - // This compositor should already have been tested for - // triviality (empty). - // - Particles const& p (c.context ().get ("prefixes")); - - bool paren (p.size () != 1); - - for (Particles::const_iterator i (p.begin ()), e (p.end ()); - i != e;) - { - if (paren) - os << "("; - - dispatch (**i); - - if (paren) - os << ")"; - - if (++i != e) - os << " ||" << endl; - } - } - }; - - - // Generates particle namespace-name pair. Used to generate - // the _expected_element call. - // - struct ParticleName: Traversal::Compositor, - Traversal::Element, - Traversal::Any, - Context - { - ParticleName (Context& c) - : Context (c) - { - } - - virtual void - traverse (SemanticGraph::Element& e) - { - String ns (e.qualified_p () ? e.namespace_ ().name () : String ()); - os << strlit (ns) << ", " << strlit (e.name ()); - } - - virtual void - traverse (SemanticGraph::Any& a) - { - String const& ns (*a.namespace_begin ()); - os << strlit (ns) << ", " << L << "\"*\""; - } - - virtual void - traverse (SemanticGraph::Compositor& c) - { - Particles const& p (c.context ().get ("prefixes")); - - dispatch (**p.begin ()); - } - }; - - - // Common base for the ParticleIn{All, Choice, Sequence} treversers. - // - struct ParticleInCompositor: Context - { - protected: - ParticleInCompositor (Context& c, SemanticGraph::Complex& type) - : Context (c), type_ (type), particle_test_ (c) - { - } - - - // Generate sub-parser setup code as well as the pre/post calls. - // - void - pre_post_calls (SemanticGraph::Particle& p) - { - using SemanticGraph::Element; - using SemanticGraph::Complex; - - if (Element* e = dynamic_cast (&p)) - { - SemanticGraph::Type& type (e->type ()); - String const& fq_type (fq_name (type)); - bool poly (polymorphic && !anonymous (type)); - - String name, inst, def_parser, map; - - if (e->context ().count("name")) - { - name = ename (*e); - - if (poly) - { - def_parser = emember (*e); - map = emember_map (*e); - inst = "p"; - } - else - inst = L"this->" + emember (*e); - } - else - { - // This is the subsequent mentioning of this element in the - // content. We need to find the first one in order to get - // to the escaped names. - // - Complex::NamesIteratorPair ip (type_.find (e->name ())); - assert (ip.first != ip.second); - Element& fe (dynamic_cast(ip.first->named ())); - - name = ename (fe); - - if (poly) - { - def_parser = emember (fe); - map = emember_map (fe); - inst = "p"; - } - else - inst = L"this->" + emember (fe); - } - - if (poly) - { - // For pre-computing length. - // - String type_id (type.name ()); - - if (String type_ns = xml_ns_name (type)) - { - type_id += L' '; - type_id += type_ns; - } - - os << fq_type << "* p = 0;" - << endl - << "if (t == 0 && this->" << def_parser << " != 0)" << endl - << inst << " = this->" << def_parser << ";" - << "else" - << "{" - << string_type << " ts (" << fq_name (type) << - "::_static_type (), " << type_id.size () << "UL);" - << endl - << "if (t == 0)" << endl - << "t = &ts;" - << endl - << "if (this->" << def_parser << " != 0 && *t == ts)" << endl - << inst << " = this->" << def_parser << ";" - << "else" - << "{"; - - // Check that the types are related by inheritance. - // - os << "if (t != &ts &&" << endl - << "!::xsd::cxx::parser::validating::" << - "inheritance_map_instance< " << char_type << - " > ().check (" << endl - << "t->data (), ts))" << endl - << "throw ::xsd::cxx::parser::dynamic_type< " << char_type << - " > (*t);" - << endl - << "if (this->" << map << " != 0)" << endl - << inst << " = dynamic_cast< " << fq_type << "* > (" << endl - << "this->" << map << "->find (*t));" - << "}" - << "}"; - } - - os << "this->" << complex_base << "::context_.top ()." << - "parser_ = " << inst << ";" - << endl - << "if (" << inst << ")" << endl - << inst << "->pre ();" - << "}" - << "else" // start - << "{"; - - if (poly) - os << fq_type << "* p =" << endl - << "dynamic_cast< " << fq_type << "* > (" << endl - << "this->" << complex_base << "::context_.top ().parser_);" - << endl; - - os << "if (" << inst << ")" - << "{"; - - String const& ret (ret_type (type)); - String const& post (post_name (type)); - - if (ret == L"void") - os << inst << "->" << post << " ();" - << "this->" << name << " ();"; - else - { - // Don't create an lvalue in C++11 (think std::unique_ptr). - // In C++98 we do it for compatibility with older/broken - // compilers (e.g., IBM xlC that needs an lvalue to pass - // std::auto_ptr). - // - if (std == cxx_version::cxx98) - os << arg_type (type) << " tmp (" << inst << "->" << - post << " ());" - << "this->" << name << " (tmp);"; - else - os << "this->" << name << " (" << inst << "->" << - post << " ());"; - } - - os << "}"; - } - else - { - os << "this->_start_any_element (ns, n, t);" - << "this->" << complex_base << "::context_.top ().any_ = true;" - << "}" - << "else" // start - << "{" - << "this->" << complex_base << "::context_.top ().any_ = false;" - << "this->_end_any_element (ns, n);"; - } - } - - protected: - SemanticGraph::Complex& type_; - ParticleTest particle_test_; - }; - - - - // The 'all' compositor can only contain elements with min={0,1}, max=1. - // - struct ParticleInAll: Traversal::Element, - ParticleInCompositor - { - ParticleInAll (Context& c, SemanticGraph::Complex& type) - : ParticleInCompositor (c, type) - { - } - - virtual void - traverse (SemanticGraph::Element& e) - { - size_t state (e.context ().get ("state")); - - if (state != 0) - os << "else "; - - os << "if ("; - - particle_test_.traverse (e); - - os << ")" - << "{" - << "if (count[" << state << "UL] == 0)" - << "{" - << "if (start)" - << "{"; - - pre_post_calls (e); - - os << "count[" << state << "UL] = 1;" - << "}" - << "}" - << "else" // count != 0 - << "{" - << "assert (start);" // Assuming well-formed XML. - - // Since there is never more content after 'all', we could have - // as well thrown here. But instead we will let the code in - // start_element handle this along with other unexpected - // elements. - // - << "state = ~0UL;" - << "}" - << "}"; - } - }; - - - // - // - struct ParticleInChoice: Traversal::Particle, - Traversal::Compositor, - ParticleInCompositor - { - ParticleInChoice (Context& c, SemanticGraph::Complex& type) - : ParticleInCompositor (c, type), particle_name_ (c) - { - } - - virtual void - traverse (SemanticGraph::Particle& p) - { - using SemanticGraph::Element; - - size_t state (p.context ().get ("state")); - - size_t min (p.min ()), max (p.max ()); - - os << "case " << state << "UL:" << endl - << "{"; - - if (max != 1) // We don't need the test if max == 1. - { - os << "if ("; - - particle_test_.dispatch (p); - - os << ")" - << "{"; - } - - os << "if (start)" - << "{"; - - pre_post_calls (p); - - switch (max) - { - case 0: - { - os << "count++;"; - break; - } - case 1: - { - // We do not need to increment count because min <= max and - // we do not generate min check for min <= 1 (see below). - // - os << "state = ~0UL;"; - break; - } - default: - { - os << "if (++count == " << max << "UL)" << endl - << "state = ~0UL;"; - } - }; - - os << "}"; // start - - // We've already moved to the final state if max == 1. - // - if (max != 1) - { - os << "}" - << "else" - << "{" - << "assert (start);"; // Assuming well-formed XML - - // Check if min cardinality requirements have been met. Since - // count is always >= 1, don't generate dead code if min <= 1. - // - if (min > 1) - { - os << "if (count < " << min << "UL)" << endl - << "this->_expected_element (" << endl; - - particle_name_.dispatch (p); - - os << "," << endl - << "ns, n);"; - } - - - os << "state = ~0UL;" - << "}"; - } - - os << "break;" - << "}"; // case - } - - virtual void - traverse (SemanticGraph::Compositor& c) - { - using SemanticGraph::Compositor; - - size_t max (c.max ()); - size_t min (c.context ().get ("effective-min")); - size_t n (c.context ().get ("comp-number")); - size_t state (c.context ().get ("state")); - - String func (c.is_a () ? - "choice_" : "sequence_"); - - os << "case " << state << "UL:" << endl - << "{" - << "unsigned long s (~0UL);" - << endl; - - bool first (true); - - for (Compositor::ContainsIterator ci (c.contains_begin ()); - ci != c.contains_end (); ++ci) - { - SemanticGraph::Particle& p (ci->particle ()); - - if (p.is_a () && !c.context ().count ("comp-number")) - continue; // Empty compositor. - - if (!p.context ().count ("prefix")) - break; - - size_t state (p.context ().get ("state")); - - if (first) - first = false; - else - os << "else "; - - os << "if ("; - - particle_test_.dispatch (p); - - os << ")" << endl - << "s = " << state << "UL;"; - } - - // This compositor. - // - os << endl - << "if (s != ~0UL)" - << "{" - << "assert (start);"; // End is handled by the sub-machine. - - switch (max) - { - case 0: - { - os << "count++;"; - break; - } - case 1: - { - // We do not need to increment count because min <= max and - // we do not generate min check for min <= 1 (see below). - // - os << "state = ~0UL;"; - break; - } - default: - { - os << "if (++count == " << max << "UL)" << endl - << "state = ~0UL;"; - } - }; - - // Delegate to the sub-machine. - // - - os << endl - << "v_state_& vs = *static_cast< v_state_* > (" << - "this->v_state_stack_.top ());" - << "v_state_descr_& vd = vs.data[vs.size++];" // push - << endl - << "vd.func = &" << ename (type_) << "::" << func << n << ";" - << "vd.state = s;" - << "vd.count = 0;" - << endl - << "this->" << func << n << " (vd.state, vd.count, ns, n, t, true);" - << "}"; - - - // Not this compositor. We've elready moved to the final state - // if max == 1. - // - if (max != 1) - { - os << "else" - << "{" - << "assert (start);"; // Assuming well-formed XML - - // Check if min cardinality requirements have been met. Since - // count is always >= 1, don't generate dead code if min <= 1. - // - if (min > 1) - { - os << "if (count < " << min << "UL)" << endl - << "this->_expected_element (" << endl; - - particle_name_.dispatch (c); - - os << "," << endl - << "ns, n);"; - } - - os << "state = ~0UL;" - << "}"; - } - - os << "break;" - << "}"; // case - } - - private: - ParticleName particle_name_; - }; - - - // - // - struct ParticleInSequence: Traversal::Particle, - Traversal::Compositor, - ParticleInCompositor - { - ParticleInSequence (Context& c, - size_t state, - size_t next_state, - SemanticGraph::Complex& type) - : ParticleInCompositor (c, type), - state_ (state), particle_name_ (c) - { - // next_state == 0 indicates the terminal state (~0UL). - // - if (next_state != 0) - { - std::wostringstream ostr; - ostr << next_state; - next_state_ = ostr.str (); - } - else - next_state_ = L"~0"; - } - - virtual void - traverse (SemanticGraph::Particle& p) - { - size_t min (p.min ()), max (p.max ()); - - os << "case " << state_ << "UL:" << endl - << "{" - << "if ("; - - particle_test_.dispatch (p); - - os << ")" - << "{"; - - // This element. - // - - os << "if (start)" - << "{"; - - pre_post_calls (p); - - switch (max) - { - case 0: - { - os << "count++;"; - break; - } - case 1: - { - os << "count = 0;" - << "state = " << next_state_ << "UL;"; - break; - } - default: - { - os << "if (++count == " << max << "UL)" - << "{" - << "count = 0;" - << "state = " << next_state_ << "UL;" - << "}"; - } - }; - - os << "}" // start - << "break;" - << "}"; - - // Not this element. - // - - os << "else" - << "{" - << "assert (start);"; // Assuming well-formed XML. - - // Check if min cardinality requirements have been met. Since - // count is always >= 0, don't generate dead code if min == 0. - // - if (min != 0) - { - os << "if (count < " << min << "UL)" << endl - << "this->_expected_element (" << endl; - - particle_name_.dispatch (p); - - os << "," << endl - << "ns, n);"; - } - - os << "count = 0;" - << "state = " << next_state_ << "UL;" - << "// Fall through." << endl - << "}" // else - << "}"; // case - } - - virtual void - traverse (SemanticGraph::Compositor& c) - { - using SemanticGraph::Compositor; - - size_t max (c.max ()); - size_t min (c.context ().get ("effective-min")); - size_t n (c.context ().get ("comp-number")); - - String func (c.is_a () ? - "choice_" : "sequence_"); - - os << "case " << state_ << "UL:" << endl - << "{" - << "unsigned long s (~0UL);" - << endl; - - bool first (true); - - for (Compositor::ContainsIterator ci (c.contains_begin ()); - ci != c.contains_end (); ++ci) - { - SemanticGraph::Particle& p (ci->particle ()); - - if (p.is_a () && !c.context ().count ("comp-number")) - continue; // Empty compositor. - - if (!p.context ().count ("prefix")) - break; - - size_t state (p.context ().get ("state")); - - if (first) - first = false; - else - os << "else "; - - os << "if ("; - - particle_test_.dispatch (p); - - os << ")" << endl - << "s = " << state << "UL;"; - } - - // This element. - // - - os << endl - << "if (s != ~0UL)" - << "{" - << "assert (start);"; // End is handled by the sub-machine. - - switch (max) - { - case 0: - { - os << "count++;" - << endl; - break; - } - case 1: - { - os << "count = 0;" - << "state = " << next_state_ << "UL;" - << endl; - break; - } - default: - { - os << "if (++count == " << max << "UL)" - << "{" - << "count = 0;" - << "state = " << next_state_ << "UL;" - << "}"; - } - }; - - // Delegate to the sub-machine. - // - - os << "v_state_& vs = *static_cast< v_state_* > (" << - "this->v_state_stack_.top ());" - << "v_state_descr_& vd = vs.data[vs.size++];" // push - << endl - << "vd.func = &" << ename (type_) << "::" << func << n << ";" - << "vd.state = s;" - << "vd.count = 0;" - << endl - << "this->" << func << n << " (vd.state, vd.count, ns, n, t, true);" - << "break;" - << "}"; - - // Not this compositor. - // - - os << "else" - << "{" - << "assert (start);"; // Assuming well-formed XML - - // Check if min cardinality requirements have been met. Since - // count is always >= 0, don't generate dead code if min == 0. - // - if (min != 0) - { - os << "if (count < " << min << "UL)" << endl - << "this->_expected_element (" << endl; - - particle_name_.dispatch (c); - - os << "," << endl - << "ns, n);"; - } - - os << "count = 0;" - << "state = " << next_state_ << "UL;" - << "// Fall through." << endl - << "}" // else - << "}"; // case - } - - private: - size_t state_; - String next_state_; - - ParticleName particle_name_; - }; - - - // - // - struct ParticleFunction: Traversal::All, - Traversal::Choice, - Traversal::Sequence, - Context - { - ParticleFunction (Context& c, SemanticGraph::Complex& type) - : Context (c), type_ (type) - { - *this >> contains_particle_ >> *this; - } - - - virtual void - traverse (SemanticGraph::All& a) - { - if (!a.context().count ("comp-number")) // Empty compositor. - return; - - using SemanticGraph::Element; - using SemanticGraph::Compositor; - - - os << "void " << ename (type_) << "::" << endl - << "all_0 (unsigned long& state," << endl - << "unsigned char* count," << endl - << "const " << string_type << "& ns," << endl - << "const " << string_type << "& n," << endl - << "const " << string_type << "* t," << endl - << "bool start)" - << "{" - << "XSD_UNUSED (t);" - << endl; - - for (Compositor::ContainsIterator ci (a.contains_begin ()), - ce (a.contains_end ()); ci != ce; ++ci) - { - ParticleInAll t (*this, type_); - t.dispatch (ci->particle ()); - } - - // Handle the flush. - // - os << "else if (n.empty () && ns.empty ())" - << "{"; - - for (Compositor::ContainsIterator ci (a.contains_begin ()), - ce (a.contains_end ()); ci != ce; ++ci) - { - if (ci->min () == 0) - continue; - - Element& e (dynamic_cast (ci->particle ())); - String ns (e.qualified_p () ? e.namespace_ ().name () : String ()); - size_t state (e.context ().get ("state")); - - os << "if (count[" << state << "UL] == 0)" << endl - << "this->_expected_element (" << endl - << strlit (ns) << ", " << - strlit (e.name ()) << ");" - << endl; - } - - os << "state = ~0UL;" - << "}" - << "else" << endl - << "state = ~0UL;" - << "}"; - } - - virtual void - traverse (SemanticGraph::Choice& c) - { - if (!c.context().count ("comp-number")) // Empty compositor. - return; - - using SemanticGraph::Compositor; - - size_t n (c.context ().get ("comp-number")); - - os << "void " << ename (type_) << "::" << endl - << "choice_" << n << " (unsigned long& state," << endl - << "unsigned long& count," << endl - << "const " << string_type << "& ns," << endl - << "const " << string_type << "& n," << endl - << "const " << string_type << "* t," << endl - << "bool start)" - << "{" - << "XSD_UNUSED (count);" - << "XSD_UNUSED (ns);" - << "XSD_UNUSED (n);" - << "XSD_UNUSED (t);" - << endl - << "switch (state)" - << "{"; - - for (Compositor::ContainsIterator ci (c.contains_begin ()), - ce (c.contains_end ()); ci != ce; ++ci) - { - SemanticGraph::Particle& p (ci->particle ()); - - if (p.is_a () && !p.context().count ("comp-number")) - continue; // Empty compositor. - - ParticleInChoice t (*this, type_); - t.dispatch (p); - } - - os << "}" // switch - << "}"; - - // Generate nested compositor functions. - // - Traversal::Choice::traverse (c); - } - - virtual void - traverse (SemanticGraph::Sequence& s) - { - if (!s.context().count ("comp-number")) // Empty compositor. - return; - - using SemanticGraph::Compositor; - - size_t n (s.context ().get ("comp-number")); - - os << "void " << ename (type_) << "::" << endl - << "sequence_" << n << " (unsigned long& state," << endl - << "unsigned long& count," << endl - << "const " << string_type << "& ns," << endl - << "const " << string_type << "& n," << endl - << "const " << string_type << "* t," << endl - << "bool start)" - << "{" - << "XSD_UNUSED (t);" - << endl - << "switch (state)" - << "{"; - - size_t state (0); - - for (Compositor::ContainsIterator ci (s.contains_begin ()), - ce (s.contains_end ()); ci != ce;) - { - SemanticGraph::Particle& p (ci->particle ()); - - if (p.is_a () && !p.context().count ("comp-number")) - { - // Empty compositor. - // - ++ci; - continue; - } - - // Find the next state. - // - do - ++ci; - while (ci != ce && - ci->particle ().is_a () && - !ci->particle ().context().count ("comp-number")); - - size_t next (ci == ce ? 0 : state + 1); - - ParticleInSequence t (*this, state++, next, type_); - t.dispatch (p); - } - - os << "case ~0UL:" << endl - << "break;" - << "}" // switch - << "}"; - - // Generate nested compositor functions. - // - Traversal::Sequence::traverse (s); - } - - private: - SemanticGraph::Complex& type_; - Traversal::ContainsParticle contains_particle_; - }; - - - // - // - struct CompositorPre: Traversal::All, - Traversal::Compositor, - Context - { - CompositorPre (Context& c) - : Context (c) - { - } - - virtual void - traverse (SemanticGraph::All& a) - { - // Clear the counts and push the initial state. - // - os << "v_all_count_.push ();" - << endl; - - SemanticGraph::Compositor& c (a); - traverse (c); - } - - virtual void - traverse (SemanticGraph::Compositor&) // Choice and sequence. - { - os << "v_state_& vs = *static_cast< v_state_* > (" << - "this->v_state_stack_.top ());" - << "v_state_descr_& vd = vs.data[vs.size++];" // push - << endl - << "vd.func = 0;" - << "vd.state = 0;" - << "vd.count = 0;"; - } - }; - - - // - // - struct CompositorStartElement: Traversal::All, - Traversal::Compositor, - Context - { - CompositorStartElement (Context& c, SemanticGraph::Complex& type) - : Context (c), type_ (type), - particle_test_ (c), particle_name_ (c) - { - } - - virtual void - traverse (SemanticGraph::All&) - { - // The 'all' state machine reaches the final state only - // on an unknown element, in which case we won't get here - // again (it would be a validation error). Note that 'all' - // compositor cannot contain nested compositors so we don't - // need to re-set vd. - // - os << "all_0 (vd->state, v_all_count_.top (), ns, n, t, true);" - << endl - << "if (vd->state != ~0UL)" << endl - << "vd->count++;" - << "else" << endl - << "return false;" // Let our parent handle this. - << endl; - } - - virtual void - traverse (SemanticGraph::Compositor& c) // Choice and sequence. - { - using SemanticGraph::Compositor; - - size_t max (c.max ()); - size_t min (c.context ().get ("effective-min")); - size_t n (c.context ().get ("comp-number")); - - String func (c.is_a () ? - "choice_" : "sequence_"); - - // Invoke the current state machine. If it reaches its - // terminal state, pop it and invoke the next one until - // we reach the top, which requires special handling. - // - os << "while (vd->func != 0)" - << "{" - << "(this->*vd->func) (vd->state, vd->count, ns, n, t, true);" - << endl - << "vd = vs.data + (vs.size - 1);" // re-acquire - << endl - << "if (vd->state == ~0UL)" << endl - << "vd = vs.data + (--vs.size - 1);" // pop - << "else" << endl - << "break;" - << "}"; - - - // Check if we got to the top. This code is pretty much the - // same as the one found in ParticleInSequence. - // - os << "if (vd->func == 0)" - << "{" - << "if (vd->state != ~0UL)" - << "{" - << "unsigned long s = ~0UL;" - << endl; - - bool first (true); - - // Note that we don't need to worry about the compositor - // being empty - this case is handled by our caller. - // - for (Compositor::ContainsIterator ci (c.contains_begin ()); - ci != c.contains_end (); ++ci) - { - SemanticGraph::Particle& p (ci->particle ()); - - if (p.is_a () && !c.context ().count ("comp-number")) - continue; // Empty compositor. - - if (!p.context ().count ("prefix")) - break; - - size_t state (p.context ().get ("state")); - - if (first) - first = false; - else - os << "else "; - - os << "if ("; - - particle_test_.dispatch (p); - - os << ")" << endl - << "s = " << state << "UL;"; - } - - os << endl - << "if (s != ~0UL)" - << "{"; - - // This element is a prefix of the root compositor. - // - - switch (max) - { - case 0: - { - os << "vd->count++;"; - break; - } - case 1: - { - os << "vd->count++;" - << "vd->state = ~0UL;"; - break; - } - default: - { - os << "if (++vd->count == " << max << "UL)" << endl - << "vd->state = ~0UL;"; - } - }; - - // Delegate to the sub-machine. - // - - os << endl - << "vd = vs.data + vs.size++;" // push - << "vd->func = &" << ename (type_) << "::" << func << n << ";" - << "vd->state = s;" - << "vd->count = 0;" - << endl - << "this->" << func << n << " (vd->state, vd->count, ns, n, t, true);" - << "}"; - - // This element is not our prefix. - // - - os << "else" - << "{"; - - // Check if min cardinality requirements have been met. Since - // count is always >= 0, don't generate dead code if min == 0. - // - if (min != 0) - { - os << "if (vd->count < " << min << "UL)" << endl - << "this->_expected_element (" << endl; - - particle_name_.dispatch (c); - - os << "," << endl - << "ns, n);"; - } - - // Return false to indicate that we are not handling this element. - // - os << "return false;" - << "}" - << "}" // if (state != ~0) - << "else" << endl - << "return false;" - << "}"; // if (function == 0) - } - - private: - SemanticGraph::Complex& type_; - ParticleTest particle_test_; - ParticleName particle_name_; - }; - - - // - // - struct CompositorEndElement: Traversal::All, - Traversal::Compositor, - Context - { - CompositorEndElement (Context& c) - : Context (c) - { - } - - virtual void - traverse (SemanticGraph::All&) - { - os << "all_0 (vd.state, v_all_count_.top (), " << - "ns, n, 0, false);" - << endl; - } - - virtual void - traverse (SemanticGraph::Compositor&) // Choice and sequence. - { - os << "assert (vd.func != 0);" - << "(this->*vd.func) (vd.state, vd.count, ns, n, 0, false);" - << endl - << "if (vd.state == ~0UL)" << endl - << "vs.size--;" // pop - << endl; - } - }; - - - // - // - struct CompositorPost: Traversal::All, - Traversal::Compositor, - Context - { - CompositorPost (Context& c) - : Context (c), particle_name_ (c) - { - } - - virtual void - traverse (SemanticGraph::All& a) - { - using SemanticGraph::Element; - - os << "v_state_& vs = *static_cast< v_state_* > (" << - "this->v_state_stack_.top ());" - << "v_state_descr_& vd = vs.data[vs.size - 1];" - << endl; - - // Flush the state machine with the empty element name. This - // allows us to detect missing content. - // - os << "if (vd.count != 0)" - << "{" - << string_type << " empty;" - << "all_0 (vd.state, v_all_count_.top (), empty, empty, 0, true);" - << "}"; - - if (a.context ().get ("effective-min") != 0) - { - os << "else" << endl - << "this->_expected_element (" << endl; - - particle_name_.dispatch (a); - - os << ");"; - } - - os << endl - << "vs.size--;" // pop - << "v_all_count_.pop ();"; - } - - virtual void - traverse (SemanticGraph::Compositor& c) // Choice and sequence. - { - size_t min (c.context ().get ("effective-min")); - - os << "v_state_& vs = *static_cast< v_state_* > (" << - "this->v_state_stack_.top ());" - << "v_state_descr_* vd = vs.data + (vs.size - 1);" - << endl; - - - // Flush unfinished state machines with the empty element name. - // This allows us to detect missing content. Note that I am - // not re-setting vd since no new compositors are pushed on - // flush. - // - os << string_type << " empty;" - << "while (vd->func != 0)" - << "{" - << "(this->*vd->func) (vd->state, vd->count, empty, empty, 0, true);" - << "assert (vd->state == ~0UL);" - << "vd = vs.data + (--vs.size - 1);" // pop - << "}"; - - // Check if min cardinality requirements have been met. Since - // count is always >= 0, don't generate dead code if min == 0. - // - if (min != 0) - { - os << "if (vd->count < " << min << "UL)" << endl - << "this->_expected_element (" << endl; - - particle_name_.dispatch (c); - - os << ");"; - } - } - - private: - ParticleName particle_name_; - }; - - - // - // - struct Complex: Traversal::Complex, Context - { - Complex (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& c) - { - // Nothing to generate if we don't have any elements and wildcards. - // - if (!has (c) && - !has_particle (c)) - return; - - using SemanticGraph::Compositor; - - String const& name (ename (c)); - Compositor& comp (c.contains_compositor ().compositor ()); - - // Don't use restriction_p here since we don't want special - // treatment of anyType. - // - bool restriction ( - c.inherits_p () && - c.inherits ().is_a ()); - - os <<"// Element validation and dispatch functions for " << - name << "." << endl - <<"//" << endl; - - // _start_element_impl - // - - os << "bool " << name << "::" << endl - << "_start_element_impl (const " << string_type << "& ns," << endl - << "const " << string_type << "& n," << endl - << "const " << string_type << "* t)" - << "{" - << "XSD_UNUSED (t);" - << endl; - - os << "v_state_& vs = *static_cast< v_state_* > (" << - "this->v_state_stack_.top ());" - << "v_state_descr_* vd = vs.data + (vs.size - 1);" - << endl; - - //@@ OPT: I don't really need to call parser_base since it always - // returns false. - // - // In case of an inheritance-by-extension, call our base first. - // We don't need to generate this code for the 'all' compositor - // because it can only inherit from the empty content model. - // States of the root machine for sequence and choice: - // - // 0 - calling base - // 1 - base returned false - // ~0 - terminal state - // - if (!restriction && !comp.is_a ()) - { - os << "if (vd->func == 0 && vd->state == 0)" - << "{" - << "if (this->"; - - if (c.inherits_p ()) - os << fq_name (c.inherits ().base ()); - else - os << complex_base; - - - os << "::_start_element_impl (ns, n, t))" << endl - << "return true;" - << "else" << endl - << "vd->state = 1;" - << "}"; - } - - { - CompositorStartElement t (*this, c); - t.dispatch (comp); - } - - os << "return true;" - << "}"; - - - // _end_element_impl - // - - os << "bool " << name << "::" << endl - << "_end_element_impl (const " << string_type << "& ns," << endl - << "const " << string_type << "& n)" - << "{"; - - os << "v_state_& vs = *static_cast< v_state_* > (" << - "this->v_state_stack_.top ());" - << "v_state_descr_& vd = vs.data[vs.size - 1];" - << endl; - - //@@ OPT: I don't really need to call parser_base since it always - // returns false. - // - // In case of an inheritance-by-extension, call our base first. - // We don't need to generate this code for the 'all' compositor - // because it can only inherit from the empty content model. - // - if (!restriction && !comp.is_a ()) - { - os << "if (vd.func == 0 && vd.state == 0)" - << "{" - << "if (!"; - - if (c.inherits_p ()) - os << fq_name (c.inherits ().base ()); - else - os << complex_base; - - os << "::_end_element_impl (ns, n))" << endl - << "assert (false);" // Start and end should match. - << "return true;" - << "}"; - } - - { - CompositorEndElement t (*this); - t.dispatch (comp); - } - - os << "return true;" - << "}"; - - - // _pre_e_validate - // - os << "void " << name << "::" << endl - << "_pre_e_validate ()" - << "{" - << "this->v_state_stack_.push ();" - << "static_cast< v_state_* > (this->v_state_stack_.top ())->" << - "size = 0;" - << endl; - - { - CompositorPre t (*this); - t.dispatch (comp); - } - - // In case of an inheritance-by-extension, call our base - // _pre_e_validate. We don't need to generate this code for the - // 'all' compositor because it can only inherit from the empty - // content model. - // - if (!restriction && !comp.is_a ()) - { - // We don't need to call parser_base's implementation - // since it does nothing. - // - if (c.inherits_p ()) - { - os << endl - << fq_name (c.inherits ().base ()) << "::_pre_e_validate ();"; - } - } - - os << "}"; - - - // _post_e_validate - // - os << "void " << name << "::" << endl - << "_post_e_validate ()" - << "{"; - - // In case of an inheritance-by-extension, call our base - // _post_e_validate. We don't need to generate this code for - // the 'all' compositor because it can only inherit from - // the empty content model. - // - if (!restriction && !comp.is_a ()) - { - // We don't need to call parser_base's implementation - // since it does nothing. - // - if (c.inherits_p ()) - { - os << fq_name (c.inherits ().base ()) << "::_post_e_validate ();" - << endl; - } - } - - { - CompositorPost t (*this); - t.dispatch (c.contains_compositor ().compositor ()); - } - - os << endl - << "this->v_state_stack_.pop ();" - << "}"; - - // - // - ParticleFunction t (*this, c); - t.dispatch (c.contains_compositor ().compositor ()); - } - }; - } - - void - generate_element_validation_source (Context& ctx) - { - ctx.os << "#include " << endl - << endl; - - Traversal::Schema schema; - - Sources sources; - Traversal::Names schema_names; - - Namespace ns (ctx); - Traversal::Names names; - - schema >> sources >> schema; - schema >> schema_names >> ns >> names; - - Complex complex (ctx); - - names >> complex; - - schema.dispatch (ctx.schema_root); - } - } -} diff --git a/xsd/cxx/parser/element-validation-source.hxx b/xsd/cxx/parser/element-validation-source.hxx deleted file mode 100644 index fcdbf88..0000000 --- a/xsd/cxx/parser/element-validation-source.hxx +++ /dev/null @@ -1,18 +0,0 @@ -// file : xsd/cxx/parser/element-validation-source.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_PARSER_ELEMENT_VALIDATION_SOURCE_HXX -#define CXX_PARSER_ELEMENT_VALIDATION_SOURCE_HXX - -#include - -namespace CXX -{ - namespace Parser - { - void - generate_element_validation_source (Context&); - } -} - -#endif // CXX_PARSER_ELEMENT_VALIDATION_SOURCE_HXX diff --git a/xsd/cxx/parser/elements.cxx b/xsd/cxx/parser/elements.cxx deleted file mode 100644 index 6ab2a4b..0000000 --- a/xsd/cxx/parser/elements.cxx +++ /dev/null @@ -1,247 +0,0 @@ -// file : xsd/cxx/parser/elements.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -namespace CXX -{ - namespace Parser - { - Context:: - Context (std::wostream& o, - SemanticGraph::Schema& root, - SemanticGraph::Path const& path, - options_type const& ops, - StringLiteralMap const* map, - Regex const* he, - Regex const* ie, - Regex const* hie) - : CXX::Context (o, root, path, ops, map), - options (ops), - xml_parser (xml_parser_), - simple_base (simple_base_), - complex_base (complex_base_), - list_base (list_base_), - cout_inst (cout_inst_), - cerr_inst (cerr_inst_), - parser_map (parser_map_), - std_string_type (std_string_type_), - validation (validation_), - polymorphic (polymorphic_), - hxx_expr (he), - ixx_expr (ie), - hxx_impl_expr (hie), - xml_parser_ (ops.xml_parser ()), - validation_ ((ops.xml_parser () == "expat" || - ops.generate_validation ()) && - !ops.suppress_validation ()), - polymorphic_ (ops.generate_polymorphic ()) - { - if (char_type == L"char") - std_string_type = L"::std::string"; - else if (char_type == L"wchar_t") - std_string_type = L"::std::wstring"; - else - std_string_type = L"::std::basic_string< " + char_type + L" >"; - - String xs_ns (xs_ns_name ()); - - string_type = xs_ns + L"::ro_string"; - simple_base = xs_ns + L"::simple_content"; - complex_base = xs_ns + L"::complex_content"; - list_base = xs_ns + L"::list_base"; - - cout_inst = (char_type == L"char" ? L"std::cout" : L"std::wcout"); - cerr_inst = (char_type == L"char" ? L"std::cerr" : L"std::wcerr"); - - if (polymorphic) - parser_map_ = xs_ns + L"::parser_map"; - } - - Context:: - Context (Context& c) - : CXX::Context (c), - options (c.options), - xml_parser (c.xml_parser), - simple_base (c.simple_base), - complex_base (c.complex_base), - list_base (c.list_base), - cout_inst (c.cout_inst), - cerr_inst (c.cerr_inst), - parser_map (c.parser_map), - std_string_type (c.std_string_type), - validation (c.validation), - polymorphic (c.polymorphic), - hxx_expr (c.hxx_expr), - ixx_expr (c.ixx_expr), - hxx_impl_expr (c.hxx_impl_expr) - { - } - - Context:: - Context (Context& c, std::wostream& o) - : CXX::Context (c, o), - options (c.options), - xml_parser (c.xml_parser), - simple_base (c.simple_base), - complex_base (c.complex_base), - list_base (c.list_base), - cout_inst (c.cout_inst), - cerr_inst (c.cerr_inst), - parser_map (c.parser_map), - std_string_type (c.std_string_type), - validation (c.validation), - polymorphic (c.polymorphic), - hxx_expr (c.hxx_expr), - ixx_expr (c.ixx_expr), - hxx_impl_expr (c.hxx_impl_expr) - { - } - - Content::Value Context:: - content (SemanticGraph::Complex& c) - { - using namespace SemanticGraph; - - if (c.mixed_p ()) - return Content::mixed; - - if (c.inherits_p ()) - { - Type& base (c.inherits ().base ()); - - if (Complex* cb = dynamic_cast (&base)) - return content (*cb); - - if (base.is_a ()) - return Content::complex; - - // Everyhting else (built-in type and AnySimpleType) is simple - // content. - // - return Content::simple; - } - else - return Content::complex; - } - - bool Context:: - anonymous (SemanticGraph::Type& t) - { - return t.context ().count ("anonymous"); - } - - String const& Context:: - ret_type (SemanticGraph::Type& t) - { - return t.context ().get ("ret-type"); - } - - String const& Context:: - arg_type (SemanticGraph::Type& t) - { - return t.context ().get ("arg-type"); - } - - String const& Context:: - post_name (SemanticGraph::Type& t) - { - return t.context ().get ("post"); - } - - String const& Context:: - eparser (SemanticGraph::Member& m) - { - return m.context ().get ("parser"); - } - - String const& Context:: - emember (SemanticGraph::Member& m) - { - return m.context ().get ("member"); - } - - String const& Context:: - emember_map (SemanticGraph::Member& m) - { - return m.context ().get ("member-map"); - } - - String const& Context:: - eimpl (SemanticGraph::Type& t) - { - return t.context ().get ("impl"); - } - - // Includes - // - void TypeForward:: - traverse (SemanticGraph::Type& t) - { - os << "class " << t.context ().get (name_key_) << ";"; - } - - void Includes:: - traverse_ (SemanticGraph::Uses& u) - { - // Support for weak (forward) inclusion used in the file-per-type - // compilation model. - // - SemanticGraph::Schema& s (u.schema ()); - bool weak (u.context ().count ("weak")); - - if (weak && (type_ == header || type_ == impl_header)) - { - // Generate forward declarations. We don't really need them - // in the impl files. - // - if (type_ == header) - schema_.dispatch (s); - - return; - } - - if (type_ == source && !weak) - return; - - SemanticGraph::Path path ( - s.context ().count ("renamed") - ? s.context ().get ("renamed") - : u.path ()); - path.normalize (); - - // Try to use the portable representation of the path. If that - // fails, fall back to the native representation. - // - NarrowString path_str; - try - { - path_str = path.posix_string (); - } - catch (SemanticGraph::InvalidPath const&) - { - path_str = path.string (); - } - - String inc_path; - - switch (type_) - { - case header: - case source: - { - inc_path = ctx_.hxx_expr->replace (path_str); - break; - } - case impl_header: - { - inc_path = ctx_.hxx_impl_expr->replace (path_str); - break; - } - } - - ctx_.os << "#include " << ctx_.process_include_path (inc_path) << endl - << endl; - } - } -} diff --git a/xsd/cxx/parser/elements.hxx b/xsd/cxx/parser/elements.hxx deleted file mode 100644 index 80656c2..0000000 --- a/xsd/cxx/parser/elements.hxx +++ /dev/null @@ -1,315 +0,0 @@ -// file : xsd/cxx/parser/elements.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_PARSER_ELEMENTS_HXX -#define CXX_PARSER_ELEMENTS_HXX - -#include - -#include - -#include - -#include - -#include - -namespace CXX -{ - namespace Parser - { - struct Content - { - enum Value - { - simple, - complex, - mixed - }; - }; - - // - // - class Context: public CXX::Context - { - public: - typedef cutl::re::regexsub Regex; - - typedef Parser::options options_type; - - public: - Context (std::wostream&, - SemanticGraph::Schema&, - SemanticGraph::Path const& path, - options_type const&, - StringLiteralMap const*, - Regex const* hxx_expr, - Regex const* ixx_expr, - Regex const* hxx_impl_expr); - - protected: - Context (Context& c); - Context (Context& c, std::wostream& o); - - public: - bool - restriction_p (SemanticGraph::Complex& c) const - { - if (c.inherits_p () && - c.inherits ().is_a ()) - { - // Restriction of anyType is a special case. - // - return !c.inherits ().base ().is_a (); - } - - return false; - } - - public: - static Content::Value - content (SemanticGraph::Complex&); - - public: - static bool - anonymous (SemanticGraph::Type&); - - public: - static String const& - ret_type (SemanticGraph::Type&); - - static String const& - arg_type (SemanticGraph::Type&); - - static String const& - post_name (SemanticGraph::Type&); - - public: - static String const& - eparser (SemanticGraph::Member&); - - static String const& - emember (SemanticGraph::Member&); - - static String const& - emember_map (SemanticGraph::Member&); - - public: - static String const& - eimpl (SemanticGraph::Type&); - - public: - options_type const& options; - String& xml_parser; - String& simple_base; - String& complex_base; - String& list_base; - String& cout_inst; - String& cerr_inst; - String& parser_map; - String& std_string_type; - bool& validation; - bool& polymorphic; - - Regex const* hxx_expr; - Regex const* ixx_expr; - Regex const* hxx_impl_expr; - - private: - String xml_parser_; - String simple_base_; - String complex_base_; - String list_base_; - String cout_inst_; - String cerr_inst_; - String parser_map_; - String std_string_type_; - bool validation_; - bool polymorphic_; - }; - - // - // - struct RequiredAttributeTest: Traversal::Attribute - { - RequiredAttributeTest (bool& result) - : result_ (result) - { - } - - virtual void - traverse (Type& a) - { - if (!result_ && !a.optional_p ()) - result_ = true; - } - - private: - bool& result_; - }; - - // - // - struct ParserParamDecl: Traversal::Complex, - Traversal::List, - Traversal::Member, - Context - { - ParserParamDecl (Context& c, bool name_arg) - : Context (c), first_ (true), name_arg_ (name_arg) - { - inherits_ >> *this; - names_ >> *this; - } - - virtual void - traverse (SemanticGraph::Complex& c) - { - inherits (c, inherits_); - - if (!restriction_p (c)) - names (c, names_); - } - - virtual void - traverse (SemanticGraph::List& l) - { - if (!first_) - os << "," << endl; - else - first_ = false; - - os << fq_name (l.argumented ().type ()) << "&"; - - if (name_arg_) - os << " " << ename (l) << "_item"; - else - os << " /* " << comment (l.name ()) << " item */"; - } - - virtual void - traverse (SemanticGraph::Member& m) - { - if (skip (m)) return; - - if (!first_) - os << "," << endl; - else - first_ = false; - - os << fq_name (m.type ()) << "&"; - - if (name_arg_) - os << " " << ename (m); - else - os << " /* " << comment (m.name ()) << " */"; - } - - private: - Traversal::Inherits inherits_; - Traversal::Names names_; - - bool first_; - bool name_arg_; - }; - - - // - // - struct TypeForward: Traversal::Type, Context - { - TypeForward (Context& c, char const* name_key) - : Context (c), name_key_ (name_key) - { - } - - virtual void - traverse (SemanticGraph::Type& t); - - private: - char const* name_key_; - }; - - struct Includes: Traversal::Imports, - Traversal::Includes - { - enum Type - { - header, - source, - impl_header - }; - - Includes (Context& c, Type t) - : ctx_ (c), - type_ (t), - namespace_ (c), - type_forward_ (c, t == header ? "name" : "impl") - { - schema_ >> schema_names_ >> namespace_ >> names_ >> type_forward_; - } - - virtual void - traverse (SemanticGraph::Imports& i) - { - traverse_ (i); - } - - virtual void - traverse (SemanticGraph::Includes& i) - { - traverse_ (i); - } - - private: - void - traverse_ (SemanticGraph::Uses&); - - private: - Context& ctx_; - Type type_; - - Traversal::Schema schema_; - Traversal::Names schema_names_; - Namespace namespace_; - Traversal::Names names_; - TypeForward type_forward_; - }; - - // Find root element for the test driver. - // - struct RootElement: Traversal::Element - { - typedef Parser::options options_type; - - RootElement (options_type const& options, - SemanticGraph::Element*& element) - : options_ (options), element_ (element) - { - } - - virtual void - traverse (Type& e) - { - if (options_.root_element_first ()) - { - if (element_ == 0) - element_ = &e; - } - else if (String name = options_.root_element ()) - { - if (e.name () == name) - element_ = &e; - } - else - element_ = &e; // Cover root-element-last and no option. - } - - private: - options_type const& options_; - SemanticGraph::Element*& element_; - }; - } -} - -#endif // CXX_PARSER_ELEMENTS_HXX diff --git a/xsd/cxx/parser/generator.cxx b/xsd/cxx/parser/generator.cxx deleted file mode 100644 index 6c87117..0000000 --- a/xsd/cxx/parser/generator.cxx +++ /dev/null @@ -1,1099 +0,0 @@ -// file : xsd/cxx/parser/generator.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include -#include -#include - -#include - -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include - -#include "../../../libxsd/xsd/cxx/version.hxx" - -using std::endl; -using std::wcerr; -using std::wcout; - -using namespace XSDFrontend::SemanticGraph; - -// -// -typedef std::wifstream WideInputFileStream; -typedef std::wofstream WideOutputFileStream; -typedef std::ifstream NarrowInputFileStream; - -namespace CXX -{ - namespace - { - char const copyright_gpl[] = - "// Copyright (c) 2005-2020 Code Synthesis Tools CC.\n" - "//\n" - "// This program was generated by CodeSynthesis XSD, an XML Schema to\n" - "// C++ data binding compiler.\n" - "//\n" - "// This program is free software; you can redistribute it and/or modify\n" - "// it under the terms of the GNU General Public License version 2 as\n" - "// published by the Free Software Foundation.\n" - "//\n" - "// This program is distributed in the hope that it will be useful,\n" - "// but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - "// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" - "// GNU General Public License for more details.\n" - "//\n" - "// You should have received a copy of the GNU General Public License\n" - "// along with this program; if not, write to the Free Software\n" - "// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n" - "//\n" - "// In addition, as a special exception, Code Synthesis Tools CC gives\n" - "// permission to link this program with the Xerces-C++ library (or with\n" - "// modified versions of Xerces-C++ that use the same license as Xerces-C++),\n" - "// and distribute linked combinations including the two. You must obey\n" - "// the GNU General Public License version 2 in all respects for all of\n" - "// the code used other than Xerces-C++. If you modify this copy of the\n" - "// program, you may extend this exception to your version of the program,\n" - "// but you are not obligated to do so. If you do not wish to do so, delete\n" - "// this exception statement from your version.\n" - "//\n" - "// Furthermore, Code Synthesis Tools CC makes a special exception for\n" - "// the Free/Libre and Open Source Software (FLOSS) which is described\n" - "// in the accompanying FLOSSE file.\n" - "//\n\n"; - - char const copyright_proprietary[] = - "// Copyright (c) 2005-2020 Code Synthesis Tools CC.\n" - "//\n" - "// This program was generated by CodeSynthesis XSD, an XML Schema\n" - "// to C++ data binding compiler, in the Proprietary License mode.\n" - "// You should have received a proprietary license from Code Synthesis\n" - "// Tools CC prior to generating this code. See the license text for\n" - "// conditions.\n" - "//\n\n"; - - char const copyright_impl[] = - "// Not copyrighted - public domain.\n" - "//\n" - "// This sample parser implementation was generated by CodeSynthesis XSD,\n" - "// an XML Schema to C++ data binding compiler. You may use it in your\n" - "// programs without any restrictions.\n" - "//\n\n"; - } - - void Parser::Generator:: - usage () - { - CXX::Parser::options::print_usage (wcout); - CXX::options::print_usage (wcout); - } - - namespace - { - template - void - open (S& ifs, NarrowString const& path) - { - try - { - Path fs_path (path); - ifs.open (fs_path.string ().c_str (), - std::ios_base::in | std::ios_base::binary); - - if (!ifs.is_open ()) - { - wcerr << path.c_str () << ": error: unable to open in read mode" - << endl; - - throw Parser::Generator::Failed (); - } - } - catch (InvalidPath const&) - { - wcerr << "error: '" << path.c_str () << "' is not a valid " - << "filesystem path" << endl; - - throw Parser::Generator::Failed (); - } - } - - void - append (WideOutputFileStream& os, - NarrowString const& path, - WideInputFileStream& default_is) - { - using std::ios_base; - - if (path) - { - WideInputFileStream is; - open (is, path); - os << is.rdbuf (); - } - else if (default_is.is_open ()) - { - os << default_is.rdbuf (); - default_is.seekg (0, ios_base::beg); - } - } - - void - append (WideOutputFileStream& os, - NarrowStrings const& primary, - NarrowStrings const& def) - { - NarrowStrings const& v (primary.empty () ? def : primary); - - for (NarrowStrings::const_iterator i (v.begin ()), e (v.end ()); - i != e; ++i) - { - os << i->c_str () << endl; - } - } - } - - - size_t Parser::Generator:: - generate (Parser::options const& ops, - Schema& schema, - Path const& file_path, - bool fpt, - StringLiteralMap const& string_literal_map, - bool gen_driver, - const WarningSet& disabled_warnings, - FileList& file_list, - AutoUnlinks& unlinks) - { - using std::ios_base; - - typedef cutl::re::regexsub Regex; - - try - { - bool generate_xml_schema (ops.generate_xml_schema ()); - - // We could be compiling several schemas at once in which case - // handling of the --generate-xml-schema option gets tricky: we - // will need to rely on the presence of the --extern-xml-schema - // to tell us which (fake) schema file corresponds to XML Schema. - // - if (generate_xml_schema) - { - if (NarrowString name = ops.extern_xml_schema ()) - { - if (file_path.string () != name) - generate_xml_schema = false; - } - } - - bool impl (!generate_xml_schema && - (ops.generate_noop_impl () || - ops.generate_print_impl ())); - - bool driver (gen_driver && !generate_xml_schema && - ops.generate_test_driver ()); - - // Evaluate the graph for possibility of generating something useful. - // - { - Validator validator; - if (!validator.validate ( - ops, schema, file_path, driver, disabled_warnings)) - throw Failed (); - } - - // Process names. - // - { - NameProcessor proc; - proc.process (ops, schema, file_path, string_literal_map); - } - - bool validation ((ops.xml_parser () == "expat" || - ops.generate_validation ()) && - !ops.suppress_validation ()); - - // Compute state machine info. - // - if (validation) - { - StateProcessor proc; - proc.process (schema, file_path); - } - - // Read-in type maps. - // - TypeMap::Namespaces type_map; - { - using namespace TypeMap; - - NarrowStrings const& files (ops.type_map ()); - - for (NarrowStrings::const_iterator f (files.begin ()); - f != files.end (); ++f ) - { - NarrowInputFileStream ifs; - open (ifs, *f); - - Lexer l (ifs, *f); - TypeMap::Parser p (l, *f); - - if (!p.parse (type_map)) - throw Failed (); - } - - // Add the built-in mappings at the end. - // - - // String-based types. - // - String char_type (ops.char_type ()); - String string_type; - - if (char_type == L"char") - string_type = L"::std::string"; - else if (char_type == L"wchar_t") - string_type = L"::std::wstring"; - else - string_type = L"::std::basic_string< " + char_type + L" >"; - - String xns; - String auto_ptr; - { - Context ctx (std::wcerr, schema, file_path, ops, 0, 0, 0, 0); - xns = ctx.xs_ns_name (); - auto_ptr = ctx.auto_ptr; - } - - String buffer (auto_ptr + L"< " + xns + L"::buffer >"); - TypeMap::Namespace xsd ("http://www\\.w3\\.org/2001/XMLSchema"); - - xsd.types_push_back ("string", string_type); - xsd.types_push_back ("normalizedString", string_type); - xsd.types_push_back ("token", string_type); - xsd.types_push_back ("Name", string_type); - xsd.types_push_back ("NMTOKEN", string_type); - xsd.types_push_back ("NMTOKENS", xns + L"::string_sequence"); - xsd.types_push_back ("NCName", string_type); - - xsd.types_push_back ("ID", string_type); - xsd.types_push_back ("IDREF", string_type); - xsd.types_push_back ("IDREFS", xns + L"::string_sequence"); - - xsd.types_push_back ("language", string_type); - xsd.types_push_back ("anyURI", string_type); - xsd.types_push_back ("QName", xns + L"::qname"); - - xsd.types_push_back ("base64Binary", buffer, buffer); - xsd.types_push_back ("hexBinary", buffer, buffer); - - xsd.types_push_back ("gDay", xns + L"::gday"); - xsd.types_push_back ("gMonth", xns + L"::gmonth"); - xsd.types_push_back ("gYear", xns + L"::gyear"); - xsd.types_push_back ("gMonthDay", xns + L"::gmonth_day"); - xsd.types_push_back ("gYearMonth", xns + L"::gyear_month"); - xsd.types_push_back ("date", xns + L"::date"); - xsd.types_push_back ("time", xns + L"::time"); - xsd.types_push_back ("dateTime", xns + L"::date_time"); - xsd.types_push_back ("duration", xns + L"::duration"); - - // Fundamental C++ types. - // - xsd.types_push_back ("boolean", "bool", "bool"); - - xsd.types_push_back ("byte", "signed char", "signed char"); - xsd.types_push_back ("unsignedByte", - "unsigned char", - "unsigned char"); - - xsd.types_push_back ("short", "short", "short"); - xsd.types_push_back ("unsignedShort", - "unsigned short", - "unsigned short"); - - xsd.types_push_back ("int", "int", "int"); - xsd.types_push_back ("unsignedInt", "unsigned int", "unsigned int"); - - xsd.types_push_back ("long", "long long", "long long"); - xsd.types_push_back ("unsignedLong", - "unsigned long long", - "unsigned long long"); - - xsd.types_push_back ("integer", "long long", "long long"); - - xsd.types_push_back ("negativeInteger", "long long", "long long"); - xsd.types_push_back ("nonPositiveInteger", "long long", "long long"); - - xsd.types_push_back ("positiveInteger", - "unsigned long long", - "unsigned long long"); - xsd.types_push_back ("nonNegativeInteger", - "unsigned long long", - "unsigned long long"); - - xsd.types_push_back ("float", "float", "float"); - xsd.types_push_back ("double", "double", "double"); - xsd.types_push_back ("decimal", "double", "double"); - - type_map.push_back (xsd); - - // Everything else maps to void. - // - TypeMap::Namespace rest (".*"); - rest.types_push_back (".*", "void", "void"); - type_map.push_back (rest); - } - - // Process types. - // - { - TypeProcessor proc; - proc.process (ops, schema, gen_driver, type_map); - } - - // - // - bool inline_ (ops.generate_inline () && !generate_xml_schema); - bool source (!generate_xml_schema); - - // Generate code. - // - NarrowString name (file_path.leaf ().string ()); - NarrowString skel_suffix (ops.skel_file_suffix ()); - NarrowString impl_suffix (ops.impl_file_suffix ()); - - NarrowString hxx_suffix (ops.hxx_suffix ()); - NarrowString ixx_suffix (ops.ixx_suffix ()); - NarrowString cxx_suffix (ops.cxx_suffix ()); - - Regex hxx_expr ( - ops.hxx_regex ().empty () - ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + skel_suffix + hxx_suffix + "#" - : ops.hxx_regex ()); - - Regex ixx_expr ( - ops.ixx_regex ().empty () - ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + skel_suffix + ixx_suffix + "#" - : ops.ixx_regex ()); - - Regex cxx_expr ( - ops.cxx_regex ().empty () - ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + skel_suffix + cxx_suffix + "#" - : ops.cxx_regex ()); - - - Regex hxx_impl_expr; - Regex cxx_impl_expr; - Regex cxx_driver_expr; - - if (impl || driver) - { - hxx_impl_expr = - "#^(.+?)(\\.[^./\\\\]+)?$#$1" + impl_suffix + hxx_suffix + "#"; - - cxx_impl_expr = - "#^(.+?)(\\.[^./\\\\]+)?$#$1" + impl_suffix + cxx_suffix + "#"; - - cxx_driver_expr = - "#^(.+?)(\\.[^./\\\\]+)?$#$1-driver" + cxx_suffix + "#"; - } - - if (!hxx_expr.match (name)) - { - wcerr << "error: header expression '" << - hxx_expr.regex ().str ().c_str () << "' does not match '" << - name.c_str () << "'" << endl; - throw Failed (); - } - - if (inline_ && !ixx_expr.match (name)) - { - wcerr << "error: inline expression '" << - ixx_expr.regex ().str ().c_str () << "' does not match '" << - name.c_str () << "'" << endl; - throw Failed (); - } - - if (source && !cxx_expr.match (name)) - { - wcerr << "error: source expression '" << - cxx_expr.regex ().str ().c_str () << "' does not match '" << - name.c_str () << "'" << endl; - throw Failed (); - } - - if (impl || driver) - { - if (!hxx_impl_expr.match (name)) - { - wcerr << "error: implementation header expression '" << - hxx_impl_expr.regex ().str ().c_str () << "' does not match '" << - name.c_str () << "'" << endl; - throw Failed (); - } - - if (!cxx_impl_expr.match (name)) - { - wcerr << "error: implementation source expression '" << - cxx_impl_expr.regex ().str ().c_str () << "' does not match '" << - name.c_str () << "'" << endl; - throw Failed (); - } - - if (!cxx_driver_expr.match (name)) - { - wcerr << "error: driver source expression '" << - cxx_driver_expr.regex ().str ().c_str () << "' does not match '" << - name.c_str () << "'" << endl; - throw Failed (); - } - } - - NarrowString hxx_name (hxx_expr.replace (name)); - NarrowString ixx_name (inline_ ? ixx_expr.replace (name) : NarrowString ()); - NarrowString cxx_name (source ? cxx_expr.replace (name) : NarrowString ()); - - NarrowString hxx_impl_name; - NarrowString cxx_impl_name; - NarrowString cxx_driver_name; - - if (impl || driver) - { - hxx_impl_name = hxx_impl_expr.replace (name); - cxx_impl_name = cxx_impl_expr.replace (name); - cxx_driver_name = cxx_driver_expr.replace (name); - } - - Path hxx_path (hxx_name); - Path ixx_path (ixx_name); - Path cxx_path (cxx_name); - - Path hxx_impl_path; - Path cxx_impl_path; - Path cxx_driver_path; - - if (impl || driver) - { - hxx_impl_path = Path (hxx_impl_name); - cxx_impl_path = Path (cxx_impl_name); - cxx_driver_path = Path (cxx_driver_name); - } - - Path out_dir; - - if (NarrowString dir = ops.output_dir ()) - { - try - { - out_dir = Path (dir); - } - catch (InvalidPath const&) - { - wcerr << dir.c_str () << ": error: invalid path" << endl; - throw Failed (); - } - } - - if (fpt && !generate_xml_schema) - { - // In the file-per-type mode the schema files are always local - // unless the user added the directory so that we propagate this - // to the output files. - // - Path fpt_dir (file_path.directory ()); - - if (!fpt_dir.empty ()) - out_dir /= fpt_dir; - } - - if (!out_dir.empty ()) - { - hxx_path = out_dir / hxx_path; - ixx_path = out_dir / ixx_path; - cxx_path = out_dir / cxx_path; - - if (impl || driver) - { - hxx_impl_path = out_dir / hxx_impl_path; - cxx_impl_path = out_dir / cxx_impl_path; - cxx_driver_path = out_dir /cxx_driver_path; - } - } - - // Open the impl files first so that if open fails, the skel files - // are not deleted. - // - WideOutputFileStream hxx_impl; - WideOutputFileStream cxx_impl; - WideOutputFileStream cxx_driver; - - if (impl) - { - if (!ops.force_overwrite ()) - { - WideInputFileStream tmp ( - hxx_impl_path.string ().c_str (), ios_base::in); - - if (tmp.is_open ()) - { - wcerr << hxx_impl_path << ": error: cowardly refusing to " << - "overwrite an existing file" << endl; - throw Failed (); - } - - tmp.close (); - } - - hxx_impl.open (hxx_impl_path.string ().c_str (), ios_base::out); - - if (!hxx_impl.is_open ()) - { - wcerr << hxx_impl_path << ": error: unable to open in write mode" - << endl; - throw Failed (); - } - - unlinks.add (hxx_impl_path); - file_list.push_back (hxx_impl_path.string ()); - - if (!ops.force_overwrite ()) - { - WideInputFileStream tmp ( - cxx_impl_path.string ().c_str (), ios_base::in); - - if (tmp.is_open ()) - { - wcerr << cxx_impl_path << ": error: cowardly refusing to " << - "overwrite an existing file" << endl; - throw Failed (); - } - - tmp.close (); - } - - cxx_impl.open (cxx_impl_path.string ().c_str (), ios_base::out); - - if (!cxx_impl.is_open ()) - { - wcerr << cxx_impl_path << ": error: unable to open in write mode" - << endl; - throw Failed (); - } - - unlinks.add (cxx_impl_path); - file_list.push_back (cxx_impl_path.string ()); - } - - if (driver) - { - if (!ops.force_overwrite ()) - { - WideInputFileStream tmp ( - cxx_driver_path.string ().c_str (), ios_base::in); - - if (tmp.is_open ()) - { - wcerr << cxx_driver_path << ": error: cowardly refusing to " << - "overwrite an existing file" << endl; - throw Failed (); - } - - tmp.close (); - } - - cxx_driver.open (cxx_driver_path.string ().c_str (), ios_base::out); - - if (!cxx_driver.is_open ()) - { - wcerr << cxx_driver_path << ": error: unable to open in write " << - "mode" << endl; - throw Failed (); - } - - unlinks.add (cxx_driver_path); - file_list.push_back (cxx_driver_path.string ()); - } - - // Open the skel files. - // - WideOutputFileStream hxx (hxx_path.string ().c_str (), ios_base::out); - WideOutputFileStream ixx; - WideOutputFileStream cxx; - - if (!hxx.is_open ()) - { - wcerr << hxx_path << ": error: unable to open in write mode" << endl; - throw Failed (); - } - - unlinks.add (hxx_path); - file_list.push_back (hxx_path.string ()); - - if (inline_) - { - ixx.open (ixx_path.string ().c_str (), ios_base::out); - - if (!ixx.is_open ()) - { - wcerr << ixx_path << ": error: unable to open in write mode" << endl; - throw Failed (); - } - - unlinks.add (ixx_path); - file_list.push_back (ixx_path.string ()); - } - - - if (source) - { - cxx.open (cxx_path.string ().c_str (), ios_base::out); - - if (!cxx.is_open ()) - { - wcerr << cxx_path << ": error: unable to open in write mode" << endl; - throw Failed (); - } - - unlinks.add (cxx_path); - file_list.push_back (cxx_path.string ()); - } - - // Print copyright and license. - // - char const* copyright ( - ops.proprietary_license () ? copyright_proprietary : copyright_gpl); - - hxx << copyright; - - if (inline_) - ixx << copyright; - - if (source) - cxx << copyright; - - if (impl) - { - hxx_impl << copyright_impl; - cxx_impl << copyright_impl; - } - - if (driver) - cxx_driver << copyright_impl; - - // Prologue. - // - WideInputFileStream prologue; - { - NarrowString name (ops.prologue_file ()); - - if (name) - open (prologue, name); - } - - // Epilogue. - // - WideInputFileStream epilogue; - { - NarrowString name (ops.epilogue_file ()); - - if (name) - open (epilogue, name); - } - - // SLOC counter. - // - size_t sloc_total (0); - bool show_sloc (ops.show_sloc ()); - - typedef - compiler::ostream_filter - ind_filter; - - typedef - compiler::ostream_filter - sloc_filter; - - // - // - Regex guard_expr ("/([a-z])([A-Z])/$1_$2/"); // Split words. - - NarrowString guard_prefix (ops.guard_prefix ()); - - if (!guard_prefix) - guard_prefix = file_path.directory ().string (); - - if (guard_prefix) - guard_prefix += '_'; - - // HXX - // - { - Context ctx (hxx, - schema, - file_path, - ops, - &string_literal_map, - &hxx_expr, - &ixx_expr, - &hxx_impl_expr); - - sloc_filter sloc (hxx); - - String guard (guard_expr.replace (guard_prefix + hxx_name)); - guard = ctx.escape (guard); // Make it a C++ id. - std::transform (guard.begin (), guard.end(), guard.begin (), upcase); - - hxx << "#ifndef " << guard << endl - << "#define " << guard << endl - << endl; - - if (ctx.std >= cxx_version::cxx11) - { - hxx << "#ifndef XSD_CXX11" << endl - << "#define XSD_CXX11" << endl - << "#endif" << endl - << endl; - } - - // Copy prologue. - // - hxx << "// Begin prologue." << endl - << "//" << endl; - - append (hxx, ops.hxx_prologue (), ops.prologue ()); - append (hxx, ops.hxx_prologue_file (), prologue); - - hxx << "//" << endl - << "// End prologue." << endl - << endl; - - // Version check. - // - hxx << "#include " << endl - << endl - << "#if (XSD_INT_VERSION != " << XSD_INT_VERSION << "L)" << endl - << "#error XSD runtime version mismatch" << endl - << "#endif" << endl - << endl; - - hxx << "#include " << endl - << endl; - - // Generate. - // - { - ind_filter ind (hxx); // We don't want to indent prologues/epilogues. - - if (!generate_xml_schema) - generate_parser_forward (ctx); - - generate_parser_header (ctx, generate_xml_schema); - } - - if (inline_) - hxx << "#include " << ctx.process_include_path (ixx_name) << endl; - - hxx << "#include " << endl - << endl; - - // Copy epilogue. - // - hxx << "// Begin epilogue." << endl - << "//" << endl; - - append (hxx, ops.hxx_epilogue_file (), epilogue); - append (hxx, ops.hxx_epilogue (), ops.epilogue ()); - - hxx << "//" << endl - << "// End epilogue." << endl - << endl; - - hxx << "#endif // " << guard << endl; - - if (show_sloc) - wcerr << hxx_path << ": " << sloc.stream ().count () << endl; - - sloc_total += sloc.stream ().count (); - } - - - // IXX - // - if (inline_) - { - Context ctx (ixx, - schema, - file_path, - ops, - &string_literal_map, - &hxx_expr, - &ixx_expr, - &hxx_impl_expr); - - sloc_filter sloc (ixx); - - // Copy prologue. - // - ixx << "// Begin prologue." << endl - << "//" << endl; - - append (ixx, ops.ixx_prologue (), ops.prologue ()); - append (ixx, ops.ixx_prologue_file (), prologue); - - ixx << "//" << endl - << "// End prologue." << endl - << endl; - - // Generate. - // - { - ind_filter ind (ixx); // We don't want to indent prologues/epilogues. - generate_parser_inline (ctx); - } - - // Copy epilogue. - // - ixx << "// Begin epilogue." << endl - << "//" << endl; - - append (ixx, ops.ixx_epilogue_file (), epilogue); - append (ixx, ops.ixx_epilogue (), ops.epilogue ()); - - ixx << "//" << endl - << "// End epilogue." << endl - << endl; - - if (show_sloc) - wcerr << ixx_path << ": " << sloc.stream ().count () << endl; - - sloc_total += sloc.stream ().count (); - } - - - // CXX - // - if (source) - { - Context ctx (cxx, - schema, - file_path, - ops, - &string_literal_map, - &hxx_expr, - &ixx_expr, - &hxx_impl_expr); - - sloc_filter sloc (cxx); - - // Copy prologue. - // - cxx << "// Begin prologue." << endl - << "//" << endl; - - append (cxx, ops.cxx_prologue (), ops.prologue ()); - append (cxx, ops.cxx_prologue_file (), prologue); - - cxx << "//" << endl - << "// End prologue." << endl - << endl; - - cxx << "#include " << endl - << endl; - - cxx << "#include " << ctx.process_include_path (hxx_name) << endl - << endl; - - // Generate. - // - { - ind_filter ind (cxx); // We don't want to indent prologues/epilogues. - - if (!inline_) - generate_parser_inline (ctx); - - generate_parser_source (ctx); - - if (validation) - { - generate_element_validation_source (ctx); - generate_attribute_validation_source (ctx); - generate_characters_validation_source (ctx); - } - } - - cxx << "#include " << endl - << endl; - - // Copy epilogue. - // - cxx << "// Begin epilogue." << endl - << "//" << endl; - - append (cxx, ops.cxx_epilogue_file (), epilogue); - append (cxx, ops.cxx_epilogue (), ops.epilogue ()); - - cxx << "//" << endl - << "// End epilogue." << endl - << endl; - - if (show_sloc) - wcerr << cxx_path << ": " << sloc.stream ().count () << endl; - - sloc_total += sloc.stream ().count (); - } - - // HXX impl - // - if (impl) - { - Context ctx (hxx_impl, - schema, - file_path, - ops, - &string_literal_map, - &hxx_expr, - &ixx_expr, - &hxx_impl_expr); - - String guard (guard_expr.replace (guard_prefix + hxx_impl_name)); - guard = ctx.escape (guard); // Make it a C++ id. - std::transform (guard.begin (), guard.end(), guard.begin (), upcase); - - hxx_impl << "#ifndef " << guard << endl - << "#define " << guard << endl - << endl; - - hxx_impl << "#include " << ctx.process_include_path (hxx_name) - << endl << endl; - - { - ind_filter ind (hxx_impl); - generate_impl_header (ctx); - } - - hxx_impl << "#endif // " << guard << endl; - } - - // CXX impl - // - if (impl) - { - Context ctx (cxx_impl, - schema, - file_path, - ops, - &string_literal_map, - &hxx_expr, - &ixx_expr, - &hxx_impl_expr); - - cxx_impl << "#include " << ctx.process_include_path (hxx_impl_name) - << endl << endl; - - { - ind_filter ind (cxx_impl); - generate_impl_source (ctx); - } - } - - // CXX driver - // - if (driver) - { - Context ctx (cxx_driver, - schema, - file_path, - ops, - &string_literal_map, - &hxx_expr, - &ixx_expr, - &hxx_impl_expr); - - cxx_driver << "#include " << ctx.process_include_path (hxx_impl_name) - << endl << endl; - - { - ind_filter ind (cxx_driver); - generate_driver_source (ctx); - } - } - - return sloc_total; - } - catch (UnrepresentableCharacter const& e) - { - wcerr << "error: character at position " << e.position () << " " - << "in string '" << e.string () << "' is unrepresentable in " - << "the target encoding" << endl; - - wcerr << "info: use the --custom-literals option to provide custom " - << "string literals mapping" << endl; - - throw Failed (); - } - catch (NoNamespaceMapping const& e) - { - wcerr << e.file () << ":" << e.line () << ":" << e.column () - << ": error: unable to map XML Schema namespace '" << e.ns () - << "' to C++ namespace" << endl; - - wcerr << e.file () << ":" << e.line () << ":" << e.column () - << ": info: use the --namespace-map or --namespace-regex option " - << "to provide custom mapping" << endl; - - throw Failed (); - } - catch (InvalidNamespaceMapping const& e) - { - wcerr << "error: invalid XML to C++ namespace mapping specified: " - << "'" << e.mapping () << "': " << e.reason () << endl; - - throw Failed (); - } - catch (cutl::re::format const& e) - { - wcerr << "error: invalid regex: '" << - e.regex ().c_str () << "': " << - e.description ().c_str () << endl; - - throw Failed (); - } - catch (cutl::re::wformat const& e) - { - wcerr << "error: invalid regex: '" << - e.regex () << "': " << e.description ().c_str () << endl; - - throw Failed (); - } - } -} diff --git a/xsd/cxx/parser/generator.hxx b/xsd/cxx/parser/generator.hxx deleted file mode 100644 index 6fd984b..0000000 --- a/xsd/cxx/parser/generator.hxx +++ /dev/null @@ -1,45 +0,0 @@ -// file : xsd/cxx/parser/generator.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_PARSER_GENERATOR_HXX -#define CXX_PARSER_GENERATOR_HXX - -#include // Path -#include - -#include -#include - -#include -#include - -namespace CXX -{ - namespace Parser - { - class Generator - { - public: - static void - usage (); - - struct Failed {}; - - static size_t - generate (options const&, - XSDFrontend::SemanticGraph::Schema&, - XSDFrontend::SemanticGraph::Path const& file, - bool file_per_type, - StringLiteralMap const&, - bool gen_driver, - const WarningSet& disabled_warnings, - FileList& file_list, - AutoUnlinks& unlinks); - - private: - Generator (); - }; - } -} - -#endif // CXX_PARSER_GENERATOR_HXX diff --git a/xsd/cxx/parser/impl-header.cxx b/xsd/cxx/parser/impl-header.cxx deleted file mode 100644 index 03106ca..0000000 --- a/xsd/cxx/parser/impl-header.cxx +++ /dev/null @@ -1,232 +0,0 @@ -// file : xsd/cxx/parser/impl-header.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include -#include - -namespace CXX -{ - namespace Parser - { - namespace - { - struct Enumeration: Traversal::Enumeration, Context - { - Enumeration (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& e) - { - String const& name (eimpl (e)); - String const& ret (ret_type (e)); - SemanticGraph::Type& base (e.inherits ().base ()); - - os << "class " << type_exp << name << ": " << - "public virtual " << ename (e) << "," << endl - << " public " << fq_name (base, "impl") - << "{" - << "public:" << endl - << "virtual void" << endl - << "pre ();" - << endl - << "virtual " << ret << endl - << post_name (e) << " ();" - << "};"; - } - }; - - // - // - struct List: Traversal::List, Context - { - List (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& l) - { - String const& name (eimpl (l)); - SemanticGraph::Type& t (l.argumented ().type ()); - - String item (unclash (ename (l), "item")); - - os << "class " << type_exp << name << ": public virtual " << - ename (l) - << "{" - << "public:" << endl - << "virtual void" << endl - << "pre ();" - << endl; - - // item - // - String const& arg (arg_type (t)); - - os << "virtual void" << endl - << item; - - if (arg == L"void") - os << " ();"; - else - os << " (" << arg << ");"; - - os << endl; - - // post - // - String const& ret (ret_type (l)); - - os << "virtual " << ret << endl - << post_name (l) << " ();" - << "};"; - } - }; - - struct Union: Traversal::Union, Context - { - Union (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& u) - { - String const& name (eimpl (u)); - String const& ret (ret_type (u)); - - os << "class " << type_exp << name << ": public virtual " << - ename (u) - << "{" - << "public:" << endl - << "virtual void" << endl - << "pre ();" - << endl - << "virtual void" << endl - << "_characters (const " << string_type << "&);" - << endl - << "virtual " << ret << endl - << post_name (u) << " ();" - << "};"; - } - }; - - - // - // - struct ParserCallback: Traversal::Member, Context - { - ParserCallback (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& m) - { - if (skip (m)) - return; - - String const& arg (arg_type (m.type ())); - - os << "virtual void" << endl - << ename (m); - - if (arg == L"void") - os << " ();"; - else - os << " (" << arg << ");"; - - os << endl; - } - }; - - // - // - struct Complex: Traversal::Complex, Context - { - Complex (Context& c) - : Context (c), - parser_callback_ (c) - { - names_parser_callback_ >> parser_callback_; - } - - virtual void - traverse (Type& c) - { - String const& name (eimpl (c)); - String const& ret (ret_type (c)); - - os << "class " << type_exp << name << ": public virtual " << - ename (c); - - if (c.inherits_p ()) - os << "," << endl - << " public " << fq_name (c.inherits ().base (), "impl"); - - os << "{" - << "public:" << endl - << "virtual void" << endl - << "pre ();" - << endl; - - // In case of an inheritance-by-restriction, we don't need to - // generate parser callbacks, etc. since they are the same as in - // the base. - // - if (!restriction_p (c)) - { - names (c, names_parser_callback_); - } - - os << "virtual " << ret << endl - << post_name (c) << " ();" - << "};"; - } - - private: - // - // - ParserCallback parser_callback_; - Traversal::Names names_parser_callback_; - }; - } - - void - generate_impl_header (Context& ctx) - { - Traversal::Schema schema; - - Sources sources; - Includes includes (ctx, Includes::impl_header); - Traversal::Names schema_names; - - Namespace ns (ctx); - Traversal::Names names; - - schema >> includes; - schema >> sources >> schema; - schema >> schema_names >> ns >> names; - - List list (ctx); - Union union_ (ctx); - Complex complex (ctx); - Enumeration enumeration (ctx); - - names >> list; - names >> union_; - names >> complex; - names >> enumeration; - - schema.dispatch (ctx.schema_root); - } - } -} diff --git a/xsd/cxx/parser/impl-header.hxx b/xsd/cxx/parser/impl-header.hxx deleted file mode 100644 index f22678a..0000000 --- a/xsd/cxx/parser/impl-header.hxx +++ /dev/null @@ -1,18 +0,0 @@ -// file : xsd/cxx/parser/impl-header.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_PARSER_IMPL_HEADER_HXX -#define CXX_PARSER_IMPL_HEADER_HXX - -#include - -namespace CXX -{ - namespace Parser - { - void - generate_impl_header (Context&); - } -} - -#endif // CXX_PARSER_IMPL_HEADER_HXX diff --git a/xsd/cxx/parser/impl-source.cxx b/xsd/cxx/parser/impl-source.cxx deleted file mode 100644 index 592c956..0000000 --- a/xsd/cxx/parser/impl-source.cxx +++ /dev/null @@ -1,384 +0,0 @@ -// file : xsd/cxx/parser/impl-source.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include -#include - -#include -#include - -namespace CXX -{ - namespace Parser - { - namespace - { - struct Enumeration: Traversal::Enumeration, Context - { - Enumeration (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& e) - { - String const& name (eimpl (e)); - String const& ret (ret_type (e)); - SemanticGraph::Type& base (e.inherits ().base ()); - String const& base_ret (ret_type (base)); - - os << "// " << name << endl - << "//" << endl - << endl; - - // pre - // - os << "void " << name << "::" << endl - << "pre ()" - << "{" - << "}"; - - // post - // - os << ret << " " << name << "::" << endl - << post_name (e) << " ()" - << "{"; - - if (ret == base_ret) - { - os << (ret != L"void" ? "return " : "") << - post_name (base) << " ();"; - } - else if (ret == L"void") - { - os << arg_type (base) << " v (" << post_name (base) << " ());" - << endl; - - if (options.generate_print_impl ()) - { - PrintCall t (*this, e.name (), "v"); - t.dispatch (base); - } - else - os << "// TODO" << endl - << "//" << endl; - } - else - { - if (base_ret == L"void") - os << post_name (base) << " ();"; - else - os << arg_type (base) << " v (" << post_name (base) << " ());" - << endl - << "// TODO" << endl - << "//" << endl - << "// return ... ;" << endl; - } - - os << "}"; - } - }; - - // - // - struct List: Traversal::List, Context - { - List (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& l) - { - String const& name (eimpl (l)); - SemanticGraph::Type& type (l.argumented ().type ()); - - String item (unclash (ename (l), "item")); - - os << "// " << name << endl - << "//" << endl - << endl; - - // pre - // - os << "void " << name << "::" << endl - << "pre ()" - << "{" - << "}"; - - // item - // - String const& arg (arg_type (type)); - - os << "void " << name << "::" << endl - << item; - - if (arg == L"void") - os << " ()"; - else - os << " (" << arg << " " << item << ")"; - - os << "{"; - - if (arg != L"void") - { - if (options.generate_print_impl ()) - { - PrintCall t (*this, type.name (), item); - t.dispatch (type); - } - else - os << "// TODO" << endl - << "//" << endl; - } - - os << "}"; - - // post - // - String const& ret (ret_type (l)); - - os << ret << " " << name << "::" << endl - << post_name (l) << " ()" - << "{"; - - if (ret != L"void") - os << "// TODO" << endl - << "//" << endl - << "// return ... ;" << endl; - - os << "}"; - } - }; - - // - // - struct Union: Traversal::Union, Context - { - Union (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& u) - { - String const& name (eimpl (u)); - - os << "// " << name << endl - << "//" << endl - << endl; - - // pre - // - os << "void " << name << "::" << endl - << "pre ()" - << "{" - << "}"; - - // _characters - // - os << "void " << name << "::" << endl - << "_characters (const " << string_type << "& s)" - << "{"; - - if (options.generate_print_impl ()) - os << cout_inst << " << " << strlit (u.name () + L": ") << - " << s << std::endl;"; - else - os << "// TODO" << endl - << "//" << endl; - - os << "}"; - - // post - // - String const& ret (ret_type (u)); - - os << ret << " " << name << "::" << endl - << post_name (u) << " ()" - << "{"; - - if (ret != L"void") - os << "// TODO" << endl - << "//" << endl - << "// return ... ;" << endl; - - os << "}"; - } - }; - - // - // - struct ParserCallback: Traversal::Member, Context - { - ParserCallback (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& m) - { - if (skip (m)) - return; - - String const& name (ename (m)); - String const& arg (arg_type (m.type ())); - - os << "void " << - eimpl (dynamic_cast (m.scope ())) << - "::" << endl - << name; - - if (arg == L"void") - os << " ()"; - else - os << " (" << arg << " " << name << ")"; - - os << "{"; - - if (arg != L"void") - { - if (options.generate_print_impl ()) - { - PrintCall t (*this, m.name (), name); - t.dispatch (m.type ()); - } - else - os << "// TODO" << endl - << "//" << endl; - } - - os << "}"; - } - }; - - // - // - struct Complex: Traversal::Complex, Context - { - Complex (Context& c) - : Context (c), parser_callback_ (c) - { - names_parser_callback_ >> parser_callback_; - } - - virtual void - traverse (Type& c) - { - String const& name (eimpl (c)); - - bool restriction (restriction_p (c)); - - os << "// " << name << endl - << "//" << endl - << endl; - - // pre - // - os << "void " << name << "::" << endl - << "pre ()" - << "{" - << "}"; - - // Parser callbacks. - // - if (!restriction) - names (c, names_parser_callback_); - - // post - // - String const& ret (ret_type (c)); - - os << ret << " " << name << "::" << endl - << post_name (c) << " ()" - << "{"; - - if (c.inherits_p ()) - { - SemanticGraph::Type& base (c.inherits ().base ()); - String const& base_ret (ret_type (base)); - - if (ret == base_ret) - { - os << (ret != L"void" ? "return " : "") << - post_name (base) << " ();"; - } - else if (ret == L"void") - { - os << arg_type (base) << " v (" << post_name (base) << " ());" - << endl; - - if (options.generate_print_impl ()) - { - PrintCall t (*this, c.name (), "v"); - t.dispatch (base); - } - else - os << "// TODO" << endl - << "//" << endl; - } - else - { - if (base_ret == L"void") - os << post_name (base) << " ();"; - else - os << arg_type (base) << " v (" << post_name (base) << " ());" - << endl - << "// TODO" << endl - << "//" << endl - << "// return ... ;" << endl; - } - } - else - { - if (ret != L"void") - os << "// TODO" << endl - << "//" << endl - << "// return ... ;" << endl; - } - - os << "}"; - } - - private: - // - // - ParserCallback parser_callback_; - Traversal::Names names_parser_callback_; - }; - } - - void - generate_impl_source (Context& ctx) - { - if (ctx.options.generate_print_impl ()) - ctx.os << "#include " << endl - << endl; - - Traversal::Schema schema; - Sources sources; - Traversal::Names schema_names; - Namespace ns (ctx); - Traversal::Names names; - - schema >> sources >> schema; - schema >> schema_names >> ns >> names; - - List list (ctx); - Union union_ (ctx); - Complex complex (ctx); - Enumeration enumeration (ctx); - - names >> list; - names >> union_; - names >> complex; - names >> enumeration; - - schema.dispatch (ctx.schema_root); - } - } -} diff --git a/xsd/cxx/parser/impl-source.hxx b/xsd/cxx/parser/impl-source.hxx deleted file mode 100644 index 2fa5183..0000000 --- a/xsd/cxx/parser/impl-source.hxx +++ /dev/null @@ -1,18 +0,0 @@ -// file : xsd/cxx/parser/impl-source.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_PARSER_IMPL_SOURCE_HXX -#define CXX_PARSER_IMPL_SOURCE_HXX - -#include - -namespace CXX -{ - namespace Parser - { - void - generate_impl_source (Context&); - } -} - -#endif // CXX_PARSER_IMPL_SOURCE_HXX diff --git a/xsd/cxx/parser/name-processor.cxx b/xsd/cxx/parser/name-processor.cxx deleted file mode 100644 index a06f1e3..0000000 --- a/xsd/cxx/parser/name-processor.cxx +++ /dev/null @@ -1,1175 +0,0 @@ -// file : xsd/cxx/parser/name-processor.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include -#include -#include -#include - -#include - -#include -#include - - -using namespace std; - -namespace CXX -{ - namespace Parser - { - namespace - { - // - // - typedef set NameSet; - - class Context: public CXX::Context - { - public: - Context (Parser::options const& ops, - SemanticGraph::Schema& root, - SemanticGraph::Path const& path, - StringLiteralMap const* map) - : CXX::Context (std::wcerr, root, path, ops, map), - skel_suffix_ (ops.skel_type_suffix ()), - impl_suffix_ (ops.impl_type_suffix ()), - impl (ops.generate_noop_impl () || - ops.generate_print_impl () || - ops.generate_test_driver ()), - skel_suffix (skel_suffix_), - impl_suffix (impl_suffix_), - global_type_names (global_type_names_), - polymorphic (ops.generate_polymorphic ()) - { - } - - protected: - Context (Context& c) - : CXX::Context (c), - impl (c.impl), - skel_suffix (c.skel_suffix), - impl_suffix (c.impl_suffix), - global_type_names (c.global_type_names), - polymorphic (c.polymorphic) - { - } - - public: - String - find_name (String const& n, NameSet& set) - { - String base_name (escape (n)); - String name (base_name); - - for (size_t i (1); set.find (name) != set.end (); ++i) - { - std::wostringstream os; - os << i; - name = base_name + os.str (); - } - - set.insert (name); - return name; - } - - private: - String const skel_suffix_; - String const impl_suffix_; - - map global_type_names_; - - public: - bool const impl; - String const& skel_suffix; - String const& impl_suffix; - - map& global_type_names; - - bool polymorphic; - }; - - - // - // - struct PrimaryMember: Traversal::Member, Context - { - PrimaryMember (Context& c, NameSet& set) - : Context (c), set_ (set) - { - } - - virtual void - traverse (Type& m) - { - if (Parser::Context::skip (m)) - return; - - m.context ().set ("name", find_name (m.name (), set_)); - } - - private: - NameSet& set_; - }; - - struct DerivedMember: Traversal::Member, Context - { - DerivedMember (Context& c, NameSet& set) - : Context (c), set_ (set) - { - } - - virtual void - traverse (Type& m) - { - if (Parser::Context::skip (m)) - return; - - m.context ().set ("parser", - find_name (m.name () + L"_parser", set_)); - - String const& base (m.context ().get ("name")); - m.context ().set ("member", find_name (base + L"_parser_", set_)); - - if (polymorphic && - m.is_a () && - !m.type ().context ().count ("anonymous")) - { - m.context ().set ( - "member-map", find_name (base + L"_parser_map_", set_)); - - m.context ().set ( - "member-map-impl", - find_name (base + L"_parser_map_impl_", set_)); - } - } - - private: - NameSet& set_; - }; - - - // - // - struct MemberInRestrictionBase: Traversal::Member - { - protected: - MemberInRestrictionBase (NameSet& set, SemanticGraph::Complex& base) - : set_ (set), base_ (base) - { - } - - struct NotFound {}; - - Type& - find_member (SemanticGraph::Complex& c, Type& m) - { - using SemanticGraph::Complex; - - Complex::NamesIteratorPair r (c.find (m.name ())); - - for (; r.first != r.second; ++r.first) - { - if (r.first->named ().is_a ()) - { - Type& bm (dynamic_cast (r.first->named ())); - - if (typeid (bm) != typeid (m)) - continue; - - if (m.qualified_p ()) - { - if (bm.qualified_p () && - m.name () == bm.name () && - m.namespace_ ().name () == bm.namespace_ ().name ()) - return bm; - } - else - { - if (!bm.qualified_p () && m.name () == bm.name ()) - return bm; - } - } - } - - // If we didn't find anything, try our base. - // - if (c.inherits_p ()) - { - SemanticGraph::Type& base (c.inherits ().base ()); - - if (base.is_a ()) - return find_member (dynamic_cast (base), m); - } - - //std::wcerr << "unable to find member " << m.name () << " in " - // << c.name () << std::endl; - - throw NotFound (); - } - - protected: - NameSet& set_; - SemanticGraph::Complex& base_; - }; - - struct PrimaryMemberInRestriction: MemberInRestrictionBase, Context - { - PrimaryMemberInRestriction (Context& c, - NameSet& set, - SemanticGraph::Complex& base) - : MemberInRestrictionBase (set, base), Context (c) - { - } - - virtual void - traverse (Type& m) - { - if (Parser::Context::skip (m)) - return; - - String name; - - try - { - // Try to find corresponding member in one of our bases. - // This may fail if we use an element that substitutes - // one in our base. - // - Type& bm (find_member (base_, m)); - name = bm.context ().get ("name"); - } - catch (NotFound const&) - { - // Fall back to the standard name assignment. - // - name = find_name (m.name (), set_); - } - - m.context ().set ("name", name); - } - }; - - struct DerivedMemberInRestriction: MemberInRestrictionBase, Context - { - DerivedMemberInRestriction (Context& c, - NameSet& set, - SemanticGraph::Complex& base) - : MemberInRestrictionBase (set, base), Context (c) - { - } - - virtual void - traverse (Type& m) - { - if (Parser::Context::skip (m)) - return; - - bool poly (polymorphic && - m.is_a () && - !m.type ().context ().count ("anonymous")); - - String parser, member, member_map, member_map_impl; - - try - { - // Try to find corresponding member in one of our bases. - // This may fail if we use an element that substitutes - // one in our base. - // - Type& bm (find_member (base_, m)); - parser = bm.context ().get ("parser"); - member = bm.context ().get ("member"); - - if (poly) - { - member_map = bm.context ().get ("member-map"); - member_map_impl = bm.context ().get ("member-map-impl"); - } - } - catch (NotFound const&) - { - // Fall back to the standard name assignment. - // - String const& base (m.context ().get ("name")); - - parser = find_name (m.name () + L"_parser", set_); - member = find_name (base + L"_parser_", set_); - - if (poly) - { - member_map = find_name (base + L"_parser_map_", set_); - member_map_impl = find_name (base + L"_parser_map_impl_", set_); - } - } - - m.context ().set ("parser", parser); - m.context ().set ("member", member); - - if (poly) - { - m.context ().set ("member-map", member_map); - m.context ().set ("member-map-impl", member_map_impl); - } - } - }; - - // - // - struct Complex: Traversal::Complex, Context - { - Complex (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& c) - { - SemanticGraph::Context& cc (c.context ()); - - // Use processed name. - // - String const& name (cc.get ("name")); - - // We leave this set around to allow other mappings to use - // this information. - // - cc.set ("cxx-parser-name-processor-member-set", NameSet ()); - NameSet& member_set ( - cc.get ("cxx-parser-name-processor-member-set")); - - member_set.insert (name); - - // Add our base's members to the initial list unless we are - // inheriting by restriction in which case we need to have - // the same names as our base. - // - bool restriction (false); - - if (c.inherits_p ()) - { - // @@ What if this types name is the same as one of base's - // members? - // - SemanticGraph::Type& base (c.inherits ().base ()); - - if (base.is_a ()) - { - if (!base.context ().count ( - "cxx-parser-name-processor-member-set")) - { - dispatch (base); - } - - NameSet const& base_set ( - base.context ().get ( - "cxx-parser-name-processor-member-set")); - - member_set.insert (base_set.begin (), base_set.end ()); - - // Inheritance by restriction from anyType is a special case. - // - restriction = c.inherits ().is_a () && - !c.inherits ().base ().is_a (); - } - } - - if (restriction) - { - // First assign the "primary" names. - // - { - PrimaryMemberInRestriction member ( - *this, - member_set, - dynamic_cast ( - c.inherits ().base ())); - - Traversal::Names names (member); - - Complex::names (c, names); - } - - // Assign "derived" names. - // - { - DerivedMemberInRestriction member ( - *this, - member_set, - dynamic_cast ( - c.inherits ().base ())); - - Traversal::Names names (member); - - Complex::names (c, names); - } - } - else - { - // First assign the "primary" names. - // - { - PrimaryMember member (*this, member_set); - Traversal::Names names (member); - - Complex::names (c, names); - } - - // Assign "derived" names. - // - { - DerivedMember member (*this, member_set); - Traversal::Names names (member); - - Complex::names (c, names); - } - } - } - }; - - - // - // - struct GlobalType: Traversal::Type, Context - { - GlobalType (Context& c, NameSet& set) - : Context (c), set_ (set) - { - } - - virtual void - traverse (SemanticGraph::Type& t) - { - SemanticGraph::Context& c (t.context ()); - String const& n (t.name ()); - - String name (find_name (n + skel_suffix, set_)); - c.set ("name", name); - - // Assign the post_* name. - // - c.set ("post", find_post_name (t)); - - // Note that we do not add this name to the set so that it - // does not influence other names. - // - if (impl) - c.set ("impl", escape (n + impl_suffix)); - } - - private: - String - find_post_name (SemanticGraph::Type& t) - { - String const& n (t.name ()); - - // It is possible that our base has the same type name (just - // in a different namespaces). Avoid name clash in this case. - // - using SemanticGraph::Complex; - - Complex* c = dynamic_cast (&t); - - if (c == 0 || !c->inherits_p ()) - { - return escape (L"post_" + n); - } - else - { - NameSet set; - - // Collect all base's post_*. In some mutual inclusion cases it - // is possible that our base won't have the post name assigned - // yet. In this situation will will have to figure it out - // ourselves (we can do it since we use the "raw" type name). - // - SemanticGraph::Type* b (&c->inherits ().base ()); - - while (true) - { - if (b->context ().count ("post")) - set.insert (b->context ().get ("post")); - else - set.insert (find_post_name (*b)); - - Complex* cb (dynamic_cast (b)); - - if (cb != 0 && cb->inherits_p ()) - { - b = &cb->inherits ().base (); - continue; - } - - break; - } - - String base_name (escape (L"post_" + n)); - String post (base_name); - - for (size_t i (1); set.find (post) != set.end (); ++i) - { - std::wostringstream os; - os << i; - post = base_name + os.str (); - } - - return post; - } - } - - private: - NameSet& set_; - }; - - - struct Namespace: Traversal::Namespace, Context - { - Namespace (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& ns) - { - NameSet& type_set (global_type_names[ns.name ()]); - - GlobalType type (*this, type_set); - Traversal::Names names (type); - - Traversal::Namespace::names (ns, names); - } - }; - - - struct FundType: Traversal::AnyType, - Traversal::AnySimpleType, - - Traversal::Fundamental::Byte, - Traversal::Fundamental::UnsignedByte, - Traversal::Fundamental::Short, - Traversal::Fundamental::UnsignedShort, - Traversal::Fundamental::Int, - Traversal::Fundamental::UnsignedInt, - Traversal::Fundamental::Long, - Traversal::Fundamental::UnsignedLong, - Traversal::Fundamental::Integer, - Traversal::Fundamental::NonPositiveInteger, - Traversal::Fundamental::NonNegativeInteger, - Traversal::Fundamental::PositiveInteger, - Traversal::Fundamental::NegativeInteger, - - Traversal::Fundamental::Boolean, - - Traversal::Fundamental::Float, - Traversal::Fundamental::Double, - Traversal::Fundamental::Decimal, - - Traversal::Fundamental::String, - Traversal::Fundamental::NormalizedString, - Traversal::Fundamental::Token, - Traversal::Fundamental::Name, - Traversal::Fundamental::NameToken, - Traversal::Fundamental::NameTokens, - Traversal::Fundamental::NCName, - Traversal::Fundamental::Language, - - Traversal::Fundamental::QName, - - Traversal::Fundamental::Id, - Traversal::Fundamental::IdRef, - Traversal::Fundamental::IdRefs, - - Traversal::Fundamental::AnyURI, - - Traversal::Fundamental::Base64Binary, - Traversal::Fundamental::HexBinary, - - Traversal::Fundamental::Date, - Traversal::Fundamental::DateTime, - Traversal::Fundamental::Duration, - Traversal::Fundamental::Day, - Traversal::Fundamental::Month, - Traversal::Fundamental::MonthDay, - Traversal::Fundamental::Year, - Traversal::Fundamental::YearMonth, - Traversal::Fundamental::Time, - - Traversal::Fundamental::Entity, - Traversal::Fundamental::Entities, - - Context - { - FundType (Context& c) - : Context (c) - { - } - - // anyType & anySimpleType. - // - virtual void - traverse (SemanticGraph::AnyType& t) - { - t.context ().set ("name", make_skel_name ("any_type")); - t.context ().set ("impl", make_impl_name ("any_type")); - t.context ().set ("post", String ("post_any_type")); - } - - virtual void - traverse (SemanticGraph::AnySimpleType& t) - { - t.context ().set ("name", make_skel_name ("any_simple_type")); - t.context ().set ("impl", make_impl_name ("any_simple_type")); - t.context ().set ("post", String ("post_any_simple_type")); - } - - // Boolean. - // - virtual void - traverse (SemanticGraph::Fundamental::Boolean& t) - { - t.context ().set ("name", make_skel_name ("boolean")); - t.context ().set ("impl", make_impl_name ("boolean")); - t.context ().set ("post", String ("post_boolean")); - } - - // Integral types. - // - virtual void - traverse (SemanticGraph::Fundamental::Byte& t) - { - t.context ().set ("name", make_skel_name ("byte")); - t.context ().set ("impl", make_impl_name ("byte")); - t.context ().set ("post", String ("post_byte")); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedByte& t) - { - t.context ().set ("name", make_skel_name ("unsigned_byte")); - t.context ().set ("impl", make_impl_name ("unsigned_byte")); - t.context ().set ("post", String ("post_unsigned_byte")); - } - - virtual void - traverse (SemanticGraph::Fundamental::Short& t) - { - t.context ().set ("name", make_skel_name ("short")); - t.context ().set ("impl", make_impl_name ("short")); - t.context ().set ("post", String ("post_short")); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedShort& t) - { - t.context ().set ("name", make_skel_name ("unsigned_short")); - t.context ().set ("impl", make_impl_name ("unsigned_short")); - t.context ().set ("post", String ("post_unsigned_short")); - } - - virtual void - traverse (SemanticGraph::Fundamental::Int& t) - { - t.context ().set ("name", make_skel_name ("int")); - t.context ().set ("impl", make_impl_name ("int")); - t.context ().set ("post", String ("post_int")); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedInt& t) - { - t.context ().set ("name", make_skel_name ("unsigned_int")); - t.context ().set ("impl", make_impl_name ("unsigned_int")); - t.context ().set ("post", String ("post_unsigned_int")); - } - - virtual void - traverse (SemanticGraph::Fundamental::Long& t) - { - t.context ().set ("name", make_skel_name ("long")); - t.context ().set ("impl", make_impl_name ("long")); - t.context ().set ("post", String ("post_long")); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedLong& t) - { - t.context ().set ("name", make_skel_name ("unsigned_long")); - t.context ().set ("impl", make_impl_name ("unsigned_long")); - t.context ().set ("post", String ("post_unsigned_long")); - } - - virtual void - traverse (SemanticGraph::Fundamental::Integer& t) - { - t.context ().set ("name", make_skel_name ("integer")); - t.context ().set ("impl", make_impl_name ("integer")); - t.context ().set ("post", String ("post_integer")); - } - - virtual void - traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) - { - t.context ().set ("name", make_skel_name ("non_positive_integer")); - t.context ().set ("impl", make_impl_name ("non_positive_integer")); - t.context ().set ("post", String ("post_non_positive_integer")); - } - - virtual void - traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) - { - t.context ().set ("name", make_skel_name ("non_negative_integer")); - t.context ().set ("impl", make_impl_name ("non_negative_integer")); - t.context ().set ("post", String ("post_non_negative_integer")); - } - - virtual void - traverse (SemanticGraph::Fundamental::PositiveInteger& t) - { - t.context ().set ("name", make_skel_name ("positive_integer")); - t.context ().set ("impl", make_impl_name ("positive_integer")); - t.context ().set ("post", String ("post_positive_integer")); - } - - virtual void - traverse (SemanticGraph::Fundamental::NegativeInteger& t) - { - t.context ().set ("name", make_skel_name ("negative_integer")); - t.context ().set ("impl", make_impl_name ("negative_integer")); - t.context ().set ("post", String ("post_negative_integer")); - } - - // Floats. - // - virtual void - traverse (SemanticGraph::Fundamental::Float& t) - { - t.context ().set ("name", make_skel_name ("float")); - t.context ().set ("impl", make_impl_name ("float")); - t.context ().set ("post", String ("post_float")); - } - - virtual void - traverse (SemanticGraph::Fundamental::Double& t) - { - t.context ().set ("name", make_skel_name ("double")); - t.context ().set ("impl", make_impl_name ("double")); - t.context ().set ("post", String ("post_double")); - } - - virtual void - traverse (SemanticGraph::Fundamental::Decimal& t) - { - t.context ().set ("name", make_skel_name ("decimal")); - t.context ().set ("impl", make_impl_name ("decimal")); - t.context ().set ("post", String ("post_decimal")); - } - - // Strings. - // - virtual void - traverse (SemanticGraph::Fundamental::String& t) - { - t.context ().set ("name", make_skel_name ("string")); - t.context ().set ("impl", make_impl_name ("string")); - t.context ().set ("post", String ("post_string")); - } - - virtual void - traverse (SemanticGraph::Fundamental::NormalizedString& t) - { - t.context ().set ("name", make_skel_name ("normalized_string")); - t.context ().set ("impl", make_impl_name ("normalized_string")); - t.context ().set ("post", String ("post_normalized_string")); - } - - virtual void - traverse (SemanticGraph::Fundamental::Token& t) - { - t.context ().set ("name", make_skel_name ("token")); - t.context ().set ("impl", make_impl_name ("token")); - t.context ().set ("post", String ("post_token")); - } - - virtual void - traverse (SemanticGraph::Fundamental::NameToken& t) - { - t.context ().set ("name", make_skel_name ("nmtoken")); - t.context ().set ("impl", make_impl_name ("nmtoken")); - t.context ().set ("post", String ("post_nmtoken")); - } - - virtual void - traverse (SemanticGraph::Fundamental::NameTokens& t) - { - t.context ().set ("name", make_skel_name ("nmtokens")); - t.context ().set ("impl", make_impl_name ("nmtokens")); - t.context ().set ("post", String ("post_nmtokens")); - } - - virtual void - traverse (SemanticGraph::Fundamental::Name& t) - { - t.context ().set ("name", make_skel_name ("name")); - t.context ().set ("impl", make_impl_name ("name")); - t.context ().set ("post", String ("post_name")); - } - - virtual void - traverse (SemanticGraph::Fundamental::NCName& t) - { - t.context ().set ("name", make_skel_name ("ncname")); - t.context ().set ("impl", make_impl_name ("ncname")); - t.context ().set ("post", String ("post_ncname")); - } - - virtual void - traverse (SemanticGraph::Fundamental::Language& t) - { - t.context ().set ("name", make_skel_name ("language")); - t.context ().set ("impl", make_impl_name ("language")); - t.context ().set ("post", String ("post_language")); - } - - - // Qualified name. - // - virtual void - traverse (SemanticGraph::Fundamental::QName& t) - { - t.context ().set ("name", make_skel_name ("qname")); - t.context ().set ("impl", make_impl_name ("qname")); - t.context ().set ("post", String ("post_qname")); - } - - - // ID/IDREF. - // - virtual void - traverse (SemanticGraph::Fundamental::Id& t) - { - t.context ().set ("name", make_skel_name ("id")); - t.context ().set ("impl", make_impl_name ("id")); - t.context ().set ("post", String ("post_id")); - } - - virtual void - traverse (SemanticGraph::Fundamental::IdRef& t) - { - t.context ().set ("name", make_skel_name ("idref")); - t.context ().set ("impl", make_impl_name ("idref")); - t.context ().set ("post", String ("post_idref")); - } - - virtual void - traverse (SemanticGraph::Fundamental::IdRefs& t) - { - t.context ().set ("name", make_skel_name ("idrefs")); - t.context ().set ("impl", make_impl_name ("idrefs")); - t.context ().set ("post", String ("post_idrefs")); - } - - // URI. - // - virtual void - traverse (SemanticGraph::Fundamental::AnyURI& t) - { - t.context ().set ("name", make_skel_name ("uri")); - t.context ().set ("impl", make_impl_name ("uri")); - t.context ().set ("post", String ("post_uri")); - } - - // Binary. - // - virtual void - traverse (SemanticGraph::Fundamental::Base64Binary& t) - { - t.context ().set ("name", make_skel_name ("base64_binary")); - t.context ().set ("impl", make_impl_name ("base64_binary")); - t.context ().set ("post", String ("post_base64_binary")); - } - - virtual void - traverse (SemanticGraph::Fundamental::HexBinary& t) - { - t.context ().set ("name", make_skel_name ("hex_binary")); - t.context ().set ("impl", make_impl_name ("hex_binary")); - t.context ().set ("post", String ("post_hex_binary")); - } - - - // Date/time. - // - virtual void - traverse (SemanticGraph::Fundamental::Date& t) - { - t.context ().set ("name", make_skel_name ("date")); - t.context ().set ("impl", make_impl_name ("date")); - t.context ().set ("post", String ("post_date")); - } - - virtual void - traverse (SemanticGraph::Fundamental::DateTime& t) - { - t.context ().set ("name", make_skel_name ("date_time")); - t.context ().set ("impl", make_impl_name ("date_time")); - t.context ().set ("post", String ("post_date_time")); - } - - virtual void - traverse (SemanticGraph::Fundamental::Duration& t) - { - t.context ().set ("name", make_skel_name ("duration")); - t.context ().set ("impl", make_impl_name ("duration")); - t.context ().set ("post", String ("post_duration")); - } - - virtual void - traverse (SemanticGraph::Fundamental::Day& t) - { - t.context ().set ("name", make_skel_name ("gday")); - t.context ().set ("impl", make_impl_name ("gday")); - t.context ().set ("post", String ("post_gday")); - } - - virtual void - traverse (SemanticGraph::Fundamental::Month& t) - { - t.context ().set ("name", make_skel_name ("gmonth")); - t.context ().set ("impl", make_impl_name ("gmonth")); - t.context ().set ("post", String ("post_gmonth")); - } - - virtual void - traverse (SemanticGraph::Fundamental::MonthDay& t) - { - t.context ().set ("name", make_skel_name ("gmonth_day")); - t.context ().set ("impl", make_impl_name ("gmonth_day")); - t.context ().set ("post", String ("post_gmonth_day")); - } - - virtual void - traverse (SemanticGraph::Fundamental::Year& t) - { - t.context ().set ("name", make_skel_name ("gyear")); - t.context ().set ("impl", make_impl_name ("gyear")); - t.context ().set ("post", String ("post_gyear")); - } - - virtual void - traverse (SemanticGraph::Fundamental::YearMonth& t) - { - t.context ().set ("name", make_skel_name ("gyear_month")); - t.context ().set ("impl", make_impl_name ("gyear_month")); - t.context ().set ("post", String ("post_gyear_month")); - } - - virtual void - traverse (SemanticGraph::Fundamental::Time& t) - { - t.context ().set ("name", make_skel_name ("time")); - t.context ().set ("impl", make_impl_name ("time")); - t.context ().set ("post", String ("post_time")); - } - - // Entity. - // - virtual void - traverse (SemanticGraph::Fundamental::Entity& t) - { - t.context ().set ("name", make_skel_name ("entity")); - t.context ().set ("impl", make_impl_name ("entity")); - t.context ().set ("post", String ("post_entity")); - } - - virtual void - traverse (SemanticGraph::Fundamental::Entities& t) - { - t.context ().set ("name", make_skel_name ("entities")); - t.context ().set ("impl", make_impl_name ("entities")); - t.context ().set ("post", String ("post_entities")); - } - - private: - String - make_skel_name (String const& base) - { - return escape (base + skel_suffix); - } - - String - make_impl_name (String const& base) - { - return escape (base + impl_suffix); - } - }; - - // Go into sourced/included/imported schemas while making sure - // we don't process the same stuff more than once. - // - struct Uses: Traversal::Sources, - Traversal::Includes, - Traversal::Imports - { - virtual void - traverse (SemanticGraph::Sources& sr) - { - SemanticGraph::Schema& s (sr.schema ()); - - if (!s.context ().count ("cxx-parser-name-processor-seen")) - { - s.context ().set ("cxx-parser-name-processor-seen", true); - Traversal::Sources::traverse (sr); - } - } - - virtual void - traverse (SemanticGraph::Includes& i) - { - SemanticGraph::Schema& s (i.schema ()); - - if (!s.context ().count ("cxx-parser-name-processor-seen")) - { - s.context ().set ("cxx-parser-name-processor-seen", true); - Traversal::Includes::traverse (i); - } - } - - virtual void - traverse (SemanticGraph::Imports& i) - { - SemanticGraph::Schema& s (i.schema ()); - - if (!s.context ().count ("cxx-parser-name-processor-seen")) - { - s.context ().set ("cxx-parser-name-processor-seen", true); - Traversal::Imports::traverse (i); - } - } - }; - - // Go into implied schemas while making sure we don't process - // the same stuff more than once. - // - struct Implies: Traversal::Implies - { - virtual void - traverse (SemanticGraph::Implies& i) - { - SemanticGraph::Schema& s (i.schema ()); - - if (!s.context ().count ("cxx-parser-name-processor-seen")) - { - s.context ().set ("cxx-parser-name-processor-seen", true); - Traversal::Implies::traverse (i); - } - } - }; - - void - process_impl (options const& ops, - SemanticGraph::Schema& tu, - SemanticGraph::Path const& file, - StringLiteralMap const& map) - { - Context ctx (ops, tu, file, &map); - - if (tu.names_begin ()->named ().name () == - L"http://www.w3.org/2001/XMLSchema") - { - // XML Schema namespace. - // - Traversal::Schema schema; - - Traversal::Names schema_names; - Traversal::Namespace ns; - Traversal::Names ns_names; - FundType fund_type (ctx); - - schema >> schema_names >> ns >> ns_names >> fund_type; - - schema.dispatch (tu); - } - else - { - - // Pass one - assign names to fundamental types. - // - { - Traversal::Schema schema; - Implies implies; - Traversal::Schema xs_schema; - - schema >> implies >> xs_schema; - - Traversal::Names xs_schema_names; - Traversal::Namespace ns; - Traversal::Names ns_names; - FundType fund_type (ctx); - - xs_schema >> xs_schema_names >> ns >> ns_names >> fund_type; - - schema.dispatch (tu); - } - - // Pass two - assign names to global types. This pass cannot - // be combined with pass three because of possible recursive - // schema inclusions. Also note that we check first if this - // schema has already been processed which may happen in the - // file-per-type compilation mode. - // - if (!tu.context ().count ("cxx-parser-name-processor-seen")) - { - Traversal::Schema schema; - Uses uses; - - schema >> uses >> schema; - - Traversal::Names schema_names; - Namespace ns (ctx); - - schema >> schema_names >> ns; - - // Some twisted schemas do recusive self-inclusion. - // - tu.context ().set ("cxx-parser-name-processor-seen", true); - - schema.dispatch (tu); - } - - // Pass three - assign names inside complex types. Here we don't - // need to go into included/imported schemas. - // - { - Traversal::Schema schema; - Sources sources; - - schema >> sources >> schema; - - Traversal::Names schema_names; - Traversal::Namespace ns; - Traversal::Names ns_names; - - schema >> schema_names >> ns >> ns_names; - - Complex complex (ctx); - - ns_names >> complex; - - schema.dispatch (tu); - } - } - } - } - - void NameProcessor:: - process (options const& ops, - SemanticGraph::Schema& tu, - SemanticGraph::Path const& file, - StringLiteralMap const& map) - { - process_impl (ops, tu, file, map); - } - } -} diff --git a/xsd/cxx/parser/name-processor.hxx b/xsd/cxx/parser/name-processor.hxx deleted file mode 100644 index f7f988f..0000000 --- a/xsd/cxx/parser/name-processor.hxx +++ /dev/null @@ -1,30 +0,0 @@ -// file : xsd/cxx/parser/name-processor.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_PARSER_NAME_PROCESSOR_HXX -#define CXX_PARSER_NAME_PROCESSOR_HXX - -#include - -#include - -#include -#include - -namespace CXX -{ - namespace Parser - { - class NameProcessor - { - public: - void - process (options const&, - XSDFrontend::SemanticGraph::Schema&, - XSDFrontend::SemanticGraph::Path const& file, - StringLiteralMap const& map); - }; - } -} - -#endif // CXX_PARSER_NAME_PROCESSOR_HXX diff --git a/xsd/cxx/parser/options.cli b/xsd/cxx/parser/options.cli deleted file mode 100644 index 11312ed..0000000 --- a/xsd/cxx/parser/options.cli +++ /dev/null @@ -1,147 +0,0 @@ -// file : xsd/cxx/parser/options.cli -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include ; // std::size_t - -include ; // NarrowString, NarrowStrings - -include ; - -namespace CXX -{ - namespace Parser - { - class options: CXX::options - { - NarrowStrings --type-map - { - "", - "Read XML Schema to C++ type mapping information from . - Repeat this option to specify several type maps. Type maps are - considered in order of appearance and the first match is used. By - default all user-defined types are mapped to \cb{void}. See the - TYPE MAP section below for more information." - }; - - NarrowString --xml-parser = "xerces" - { - "", - "Use as the underlying XML parser. Valid values are - \cb{xerces} for Xerces-C++ (default) and \cb{expat} for Expat." - }; - - // Features. - // - bool --generate-validation - { - "Generate validation code. The validation code (\"perfect parser\") - ensures that instance documents conform to the schema. Validation - code is generated by default when the selected underlying XML parser - is non-validating (\cb{expat})." - }; - - bool --suppress-validation - { - "Suppress the generation of validation code. Validation is suppressed - by default when the selected underlying XML parser is validating - (\cb{xerces})." - }; - - bool --generate-polymorphic - { - "Generate polymorphism-aware code. Specify this option if you use - substitution groups or \cb{xsi:type}." - }; - - bool --generate-noop-impl - { - "Generate a sample parser implementation that does nothing (no - operation). The sample implementation can then be filled with - the application-specific code. For an input file in the form - \cb{name.xsd} this option triggers the generation of two - additional C++ files in the form: \cb{name-pimpl.hxx} (parser - implementation header file) and \cb{name-pimpl.cxx} (parser - implementation source file)." - }; - - bool --generate-print-impl - { - "Generate a sample parser implementation that prints the XML data - to \c{STDOUT}. For an input file in the form \cb{name.xsd} this - option triggers the generation of two additional C++ files in the - form: \cb{name-pimpl.hxx} (parser implementation header file) and - \cb{name-pimpl.cxx} (parser implementation source file)." - }; - - bool --generate-test-driver - { - "Generate a test driver for the sample parser implementation. For an - input file in the form \cb{name.xsd} this option triggers the - generation of an additional C++ file in the form - \cb{name-driver.cxx}." - }; - - bool --force-overwrite - { - "Force overwriting of the existing implementation and test driver - files. Use this option only if you do not mind loosing the changes - you have made in the sample implementation or test driver files." - }; - - // Root element. - // - bool --root-element-first - { - "Indicate that the first global element is the document root. This - information is used to generate the test driver for the sample - implementation." - }; - - bool --root-element-last - { - "Indicate that the last global element is the document root. This - information is used to generate the test driver for the sample - implementation." - }; - - NarrowString --root-element - { - "", - "Indicate that is the document root. This information is - used to generate the test driver for the sample implementation." - }; - - // Suffixes. - // - NarrowString --skel-type-suffix = "_pskel" - { - "", - "Use the provided instead of the default \cb{_pskel} to - construct the names of the generated parser skeletons." - }; - - NarrowString --skel-file-suffix = "-pskel" - { - "", - "Use the provided instead of the default \cb{-pskel} to - construct the names of the generated parser skeleton files." - }; - - NarrowString --impl-type-suffix = "_pimpl" - { - "", - "Use the provided instead of the default \cb{_pimpl} to - construct the names of the parser implementations for the built-in - XML Schema types as well as sample parser implementations." - }; - - NarrowString --impl-file-suffix = "-pimpl" - { - "", - "Use the provided instead of the default \cb{-pimpl} to - construct the names of the generated sample parser implementation - files." - }; - }; - } -} diff --git a/xsd/cxx/parser/parser-forward.cxx b/xsd/cxx/parser/parser-forward.cxx deleted file mode 100644 index 09a055b..0000000 --- a/xsd/cxx/parser/parser-forward.cxx +++ /dev/null @@ -1,110 +0,0 @@ -// file : xsd/cxx/parser/parser-forward.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include -#include - -namespace CXX -{ - namespace Parser - { - namespace - { - struct Enumeration: Traversal::Enumeration, Context - { - Enumeration (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& e) - { - os << "class " << ename (e) << ";"; - } - }; - - // - // - struct List: Traversal::List, Context - { - List (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& l) - { - os << "class " << ename (l) << ";"; - } - }; - - // - // - struct Union: Traversal::Union, Context - { - Union (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& u) - { - os << "class " << ename (u) << ";"; - } - }; - - // - // - struct Complex: Traversal::Complex, Context - { - Complex (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& c) - { - os << "class " << ename (c) << ";"; - } - }; - } - - void - generate_parser_forward (Context& ctx) - { - ctx.os << "// Forward declarations" << endl - << "//" << endl; - - Traversal::Schema schema; - - Sources sources; - Traversal::Names schema_names; - - Namespace ns (ctx); - Traversal::Names names; - - schema >> sources >> schema; - schema >> schema_names >> ns >> names; - - List list (ctx); - Union union_ (ctx); - Complex complex (ctx); - Enumeration enumeration (ctx); - - names >> list; - names >> union_; - names >> complex; - names >> enumeration; - - schema.dispatch (ctx.schema_root); - - ctx.os << endl; - } - } -} diff --git a/xsd/cxx/parser/parser-forward.hxx b/xsd/cxx/parser/parser-forward.hxx deleted file mode 100644 index 7796532..0000000 --- a/xsd/cxx/parser/parser-forward.hxx +++ /dev/null @@ -1,18 +0,0 @@ -// file : xsd/cxx/parser/parser-forward.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_PARSER_PARSER_FORWARD_HXX -#define CXX_PARSER_PARSER_FORWARD_HXX - -#include - -namespace CXX -{ - namespace Parser - { - void - generate_parser_forward (Context&); - } -} - -#endif // CXX_PARSER_PARSER_FORWARD_HXX diff --git a/xsd/cxx/parser/parser-header.cxx b/xsd/cxx/parser/parser-header.cxx deleted file mode 100644 index ad7767a..0000000 --- a/xsd/cxx/parser/parser-header.cxx +++ /dev/null @@ -1,1440 +0,0 @@ -// file : xsd/cxx/parser/parser-header.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include - -#include -#include - -using namespace std; - -namespace CXX -{ - namespace Parser - { - namespace - { - struct Enumeration: Traversal::Enumeration, Context - { - Enumeration (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& e) - { - String const& name (ename (e)); - SemanticGraph::Type& base (e.inherits ().base ()); - - os << "class " << type_exp << name << ": public virtual " << - fq_name (base) - << "{" - << "public:" << endl - << "// Parser callbacks. Override them in your " << - "implementation." << endl - << "//" << endl; - - os << "// virtual void" << endl - << "// pre ();" << endl - << endl; - - String const& ret (ret_type (e)); - - bool same (ret == ret_type (base)); - - os << "virtual " << ret << endl - << post_name (e) << " ()" << - (same || ret == L"void" ? ";" : " = 0;"); - - if (polymorphic) - { - os << endl - << "public:" << endl - << "static const " << char_type << "*" << endl - << "_static_type ();" - << endl - << "virtual const " << char_type << "*" << endl - << "_dynamic_type () const;"; - } - - os << "};"; - } - }; - - // - // - struct List: Traversal::List, Context - { - List (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& l) - { - String const& name (ename (l)); - SemanticGraph::Type& t (l.argumented ().type ()); - - String item (unclash (name, "item")); - - os << "class " << type_exp << name << ": public " << list_base - << "{" - << "public:" << endl - << "// Parser callbacks. Override them in your " << - "implementation." << endl - << "//" << endl; - - // pre - // - os << "// virtual void" << endl - << "// pre ();" << endl - << endl; - - // item - // - String const& arg (arg_type (t)); - - os << "virtual void" << endl - << item; - - if (arg == L"void") - os << " ();"; - else - os << " (" << arg << ");"; - - os << endl; - - // post - // - String const& ret (ret_type (l)); - - os << "virtual " << ret << endl - << post_name (l) << " ()" << (ret == L"void" ? ";" : " = 0;") - << endl; - - // - // - os << "// Parser construction API." << endl - << "//" << endl; - - // item_parser - // - os << "void" << endl - << unclash (name, "item_parser") << " (" << fq_name (t) << "&);" - << endl; - - // parsers - // - os << "void" << endl - << "parsers (" << fq_name (t) << "& /* item */);" - << endl; - - // c-tor - // - os << "// Constructor." << endl - << "//" << endl - << name << " ();" - << endl; - - - if (polymorphic) - { - os << "public:" << endl - << "static const " << char_type << "*" << endl - << "_static_type ();" - << endl - << "virtual const " << char_type << "*" << endl - << "_dynamic_type () const;" - << endl; - } - - // - // - os << "// Implementation." << endl - << "//" << endl - << "protected:" << endl; - - os << "virtual void" << endl - << "_xsd_parse_item (const " << string_type << "&);" - << endl; - - os << "protected:" << endl - << fq_name (t) << "* _xsd_" << item << "_;" - << "};"; - } - }; - - struct Union: Traversal::Union, Context - { - Union (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& u) - { - String const& name (ename (u)); - - os << "class " << type_exp << name << ": public " << simple_base - << "{" - << "public:" << endl - << "// Parser callbacks. Override them in your " << - "implementation." << endl - << "//" << endl; - - os << "// virtual void" << endl - << "// pre ();" << endl - << "//" << endl - << "// virtual void" << endl - << "// _characters (const " << string_type << "&);" << endl - << endl; - - String const& ret (ret_type (u)); - - os << "virtual " << ret << endl - << post_name (u) << " ()" << (ret == L"void" ? ";" : " = 0;"); - - if (polymorphic) - { - os << endl - << "public:" << endl - << "static const " << char_type << "*" << endl - << "_static_type ();" - << endl - << "virtual const " << char_type << "*" << endl - << "_dynamic_type () const;"; - } - - os << "};"; - } - }; - - - // - // - struct ParserCallback: Traversal::Member, Context - { - ParserCallback (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& m) - { - if (skip (m)) return; - - String const& arg (arg_type (m.type ())); - - os << "virtual void" << endl - << ename (m); - - if (arg == L"void") - os << " ();"; - else - os << " (" << arg << ");"; - - os << endl; - } - }; - - - // - // - struct ParserModifier: Traversal::Member, Context - { - ParserModifier (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& m) - { - if (skip (m)) - return; - - os << "void" << endl - << eparser (m) << " (" << fq_name (m.type ()) << "&);" - << endl; - - if (polymorphic && - m.is_a () && - !anonymous (m.type ())) - { - os << "void" << endl - << eparser (m) << " (const " << parser_map << "&);" - << endl; - } - } - }; - - // - // - struct ParserMember: Traversal::Member, Context - { - ParserMember (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& m) - { - if (skip (m)) - return; - - String type (fq_name (m.type ())); - - os << type << "* " << emember (m) << ";"; - - if (polymorphic && - m.is_a () && - !anonymous (m.type ())) - { - os << "const " << parser_map << "* " << emember_map (m) << ";" - << endl; - } - } - }; - - // - // - struct Particle: Traversal::All, - Traversal::Choice, - Traversal::Sequence, - Context - { - Particle (Context& c) - : Context (c) - { - *this >> contains_particle_ >> *this; - } - - - virtual void - traverse (SemanticGraph::All& a) - { - if (!a.context().count ("comp-number")) - return; - - size_t state_count (a.context().get ("state-count")); - - os << "void" << endl - << "all_0 (unsigned long& state," << endl - << "unsigned char* count," << endl - << "const " << string_type << "& ns," << endl - << "const " << string_type << "& n," << endl - << "const " << string_type << "* t," << endl - << "bool start);" - << endl - << "unsigned char v_all_first_[" << state_count << "UL];" - << "::xsd::cxx::parser::validating::all_stack v_all_count_;" - << endl; - } - - virtual void - traverse (SemanticGraph::Choice& c) - { - if (!c.context().count ("comp-number")) - return; - - size_t n (c.context ().get ("comp-number")); - - os << "void" << endl - << "choice_" << n << " (unsigned long& state," << endl - << "unsigned long& count," << endl - << "const " << string_type << "& ns," << endl - << "const " << string_type << "& n," << endl - << "const " << string_type << "* t," << endl - << "bool start);" - << endl; - - Traversal::Choice::traverse (c); - } - - virtual void - traverse (SemanticGraph::Sequence& s) - { - if (!s.context().count ("comp-number")) - return; - - size_t n (s.context ().get ("comp-number")); - - os << "void" << endl - << "sequence_" << n << " (unsigned long& state," << endl - << "unsigned long& count," << endl - << "const " << string_type << "& ns," << endl - << "const " << string_type << "& n," << endl - << "const " << string_type << "* t," << endl - << "bool start);" - << endl; - - Traversal::Sequence::traverse (s); - } - - private: - Traversal::ContainsParticle contains_particle_; - }; - - - // - // - struct AttributeValidationState: Traversal::Attribute, Context - { - AttributeValidationState (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& a) - { - if (!a.optional_p ()) - { - os << "bool " << ename (a) << ";"; - } - } - }; - - // - // - struct Complex: Traversal::Complex, Context - { - Complex (Context& c) - : Context (c), - parser_callback_ (c), - parser_member_ (c), - parser_modifier_ (c), - attribute_validation_state_ (c) - { - names_parser_callback_ >> parser_callback_; - names_parser_member_ >> parser_member_; - names_parser_modifier_ >> parser_modifier_; - names_attribute_validation_state_ >> attribute_validation_state_; - } - - virtual void - traverse (Type& c) - { - String const& name (ename (c)); - - // In case of an inheritance-by-restriction, we don't need to - // generate parser callbacks, etc. since they are the same as in - // the base. We only need the parsing/validation code. - // - bool restriction (restriction_p (c)); - - bool he (has (c)); - bool ha (has (c)); - - bool hae (has_particle (c)); - bool haa (has (c)); - - bool hra (false); // Has required attribute. - if (ha) - { - RequiredAttributeTest test (hra); - Traversal::Names names_test (test); - names (c, names_test); - } - - - // - // - os << "class " << type_exp << name << ": public "; - - if (c.inherits_p ()) - os << "virtual " << fq_name (c.inherits ().base ()); - else - os << complex_base; - - os << "{" - << "public:" << endl - << "// Parser callbacks. Override them in your " << - "implementation." << endl - << "//" << endl; - - os << "// virtual void" << endl - << "// pre ();" << endl - << endl; - - - if (!restriction && (ha || he)) - { - names (c, names_parser_callback_); - } - - String const& ret (ret_type (c)); - - bool same (c.inherits_p () && - ret == ret_type (c.inherits ().base ())); - - os << "virtual " << ret << endl - << post_name (c) << " ()" << - (same || ret == L"void" ? ";" : " = 0;") - << endl; - - // - // - if (!restriction && (he || ha)) - { - os << "// Parser construction API." << endl - << "//" << endl; - - names (c, names_parser_modifier_); - - os << "void" << endl - << "parsers ("; - - { - ParserParamDecl decl (*this, false); - decl.traverse (c); - } - - os << ");" - << endl; - } - - // Default c-tor. - // - if ((!restriction && (he || ha)) || - (validation && (he || hae || hra))) - { - os << "// Constructor." << endl - << "//" << endl - << name << " ();" - << endl; - } - - if (polymorphic) - { - os << "public:" << endl - << "static const " << char_type << "*" << endl - << "_static_type ();" - << endl - << "virtual const " << char_type << "*" << endl - << "_dynamic_type () const;" - << endl; - } - - // Implementation. - // - if (he || ha || (validation && (hae || haa))) - { - os << "// Implementation." << endl - << "//" << endl - << "protected:" << endl; - } - - // element - // - if (he || (validation && hae)) - { - // _start_element_impl - // - os << "virtual bool" << endl - << "_start_element_impl (const " << string_type << "&," << endl - << "const " << string_type << "&," << endl - << "const " << string_type << "*);" - << endl; - - // end_element - // - os << "virtual bool" << endl - << "_end_element_impl (const " << string_type << "&," << endl - << "const " << string_type << "&);" - << endl; - } - - // attribute - // - if (validation) - { - if (ha) - { - os << "virtual bool" << endl - << "_attribute_impl_phase_one (const " << string_type << - "&," << endl - << "const " << string_type << "&," << endl - << "const " << string_type << "&);" << endl - << endl; - } - - if (haa) - { - os << "virtual bool" << endl - << "_attribute_impl_phase_two (const " << string_type << - "&," << endl - << "const " << string_type << "&," << endl - << "const " << string_type << "&);" - << endl; - } - } - else - { - if (ha) - { - os << "virtual bool" << endl - << "_attribute_impl (const " << string_type << "&," << endl - << "const " << string_type << "&," << endl - << "const " << string_type << "&);" - << endl; - } - } - - // characters - // - if (validation && c.mixed_p ()) - { - os << "virtual bool" << endl - << "_characters_impl (const " << string_type << "&);" - << endl; - } - - if (!restriction && (he || ha)) - { - os << "protected:" << endl; - names (c, names_parser_member_); - os << endl; - } - - if (validation && (he || hae)) - { - size_t depth (c.context ().get ("depth")); - - os << "protected:" << endl; - - os << "struct v_state_descr_" - << "{" - << "void (" << fq_name (c) << "::*func) (" << endl - << "unsigned long&," << endl - << "unsigned long&," << endl - << "const " << string_type << "&," << endl - << "const " << string_type << "&," << endl - << "const " << string_type << "*," << endl - << "bool);" - << "unsigned long state;" - << "unsigned long count;" - << "};"; - - // Allocate one extra slot for the special state. - // - os << "struct v_state_" - << "{" - << "v_state_descr_ data[" << depth + 1 << "UL];" - << "unsigned long size;" - << "};"; - - os << "v_state_ v_state_first_;" - << "::xsd::cxx::parser::pod_stack v_state_stack_;" - << endl; - - os << "virtual void" << endl - << "_pre_e_validate ();" - << endl; - - os << "virtual void" << endl - << "_post_e_validate ();" - << endl; - - Particle t (*this); - t.dispatch (c.contains_compositor ().compositor ()); - } - - if (validation && hra) - { - os << "protected:" << endl; - - os << "struct v_state_attr_" - << "{"; - - names (c, names_attribute_validation_state_); - - os << "};"; - - os << "v_state_attr_ v_state_attr_first_;" - << "::xsd::cxx::parser::pod_stack v_state_attr_stack_;" - << endl; - - os << "virtual void" << endl - << "_pre_a_validate ();" - << endl; - - os << "virtual void" << endl - << "_post_a_validate ();" - << endl; - } - - os << "};"; - } - - private: - // - // - ParserCallback parser_callback_; - Traversal::Names names_parser_callback_; - - // - // - ParserMember parser_member_; - Traversal::Names names_parser_member_; - - // - // - ParserModifier parser_modifier_; - Traversal::Names names_parser_modifier_; - - // - // - AttributeValidationState attribute_validation_state_; - Traversal::Names names_attribute_validation_state_; - }; - - struct FundType : Context, - - Traversal::AnyType, - Traversal::AnySimpleType, - - Traversal::Fundamental::Byte, - Traversal::Fundamental::UnsignedByte, - Traversal::Fundamental::Short, - Traversal::Fundamental::UnsignedShort, - Traversal::Fundamental::Int, - Traversal::Fundamental::UnsignedInt, - Traversal::Fundamental::Long, - Traversal::Fundamental::UnsignedLong, - Traversal::Fundamental::Integer, - Traversal::Fundamental::NonPositiveInteger, - Traversal::Fundamental::NonNegativeInteger, - Traversal::Fundamental::PositiveInteger, - Traversal::Fundamental::NegativeInteger, - - Traversal::Fundamental::Boolean, - - Traversal::Fundamental::Float, - Traversal::Fundamental::Double, - Traversal::Fundamental::Decimal, - - Traversal::Fundamental::String, - Traversal::Fundamental::NormalizedString, - Traversal::Fundamental::Token, - Traversal::Fundamental::Name, - Traversal::Fundamental::NameToken, - Traversal::Fundamental::NameTokens, - Traversal::Fundamental::NCName, - Traversal::Fundamental::Language, - - Traversal::Fundamental::QName, - - Traversal::Fundamental::Id, - Traversal::Fundamental::IdRef, - Traversal::Fundamental::IdRefs, - - Traversal::Fundamental::AnyURI, - - Traversal::Fundamental::Base64Binary, - Traversal::Fundamental::HexBinary, - - Traversal::Fundamental::Date, - Traversal::Fundamental::DateTime, - Traversal::Fundamental::Duration, - Traversal::Fundamental::Day, - Traversal::Fundamental::Month, - Traversal::Fundamental::MonthDay, - Traversal::Fundamental::Year, - Traversal::Fundamental::YearMonth, - Traversal::Fundamental::Time, - - Traversal::Fundamental::Entity, - Traversal::Fundamental::Entities - { - FundType (Context& c) - : Context (c), xs_ns_ (xs_ns_name ()) - { - impl_ns_ = "::xsd::cxx::parser::"; - impl_ns_ += (validation ? L"validating" : L"non_validating"); - - if (char_type == L"char") - string_type_ = L"::std::string"; - else if (char_type == L"wchar_t") - string_type_ = L"::std::wstring"; - else - string_type_ = L"::std::basic_string< " + char_type + L" >"; - } - - // anyType & anySimpleType. - // - virtual void - traverse (SemanticGraph::AnyType& t) - { - gen_typedef (t, "void", "any_type_pskel", "any_type_pimpl"); - } - - virtual void - traverse (SemanticGraph::AnySimpleType& t) - { - gen_typedef (t, "void", - "any_simple_type_pskel", "any_simple_type_pimpl"); - } - - // Boolean. - // - virtual void - traverse (SemanticGraph::Fundamental::Boolean& t) - { - gen_typedef (t, "bool", "boolean_pskel", "boolean_pimpl"); - } - - // Integral types. - // - virtual void - traverse (SemanticGraph::Fundamental::Byte& t) - { - gen_typedef (t, "signed char", "byte_pskel", "byte_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedByte& t) - { - gen_typedef (t, "unsigned char", - "unsigned_byte_pskel", "unsigned_byte_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Short& t) - { - gen_typedef (t, "short", "short_pskel", "short_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedShort& t) - { - gen_typedef (t, "unsigned short", - "unsigned_short_pskel", "unsigned_short_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Int& t) - { - gen_typedef (t, "int", "int_pskel", "int_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedInt& t) - { - gen_typedef (t, "unsigned int", - "unsigned_int_pskel", "unsigned_int_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Long& t) - { - gen_typedef (t, "long long", "long_pskel", "long_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedLong& t) - { - gen_typedef (t, "unsigned long long", - "unsigned_long_pskel", "unsigned_long_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Integer& t) - { - gen_typedef (t, "long long", "integer_pskel", "integer_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NegativeInteger& t) - { - gen_typedef (t, "long long", - "negative_integer_pskel", "negative_integer_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) - { - gen_typedef (t, "long long", - "non_positive_integer_pskel", - "non_positive_integer_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::PositiveInteger& t) - { - gen_typedef (t, "unsigned long long", - "positive_integer_pskel", "positive_integer_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) - { - gen_typedef (t, "unsigned long long", - "non_negative_integer_pskel", - "non_negative_integer_pimpl"); - } - - // Floats. - // - virtual void - traverse (SemanticGraph::Fundamental::Float& t) - { - gen_typedef (t, "float", "float_pskel", "float_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Double& t) - { - gen_typedef (t, "double", "double_pskel", "double_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Decimal& t) - { - gen_typedef (t, "double", "decimal_pskel", "decimal_pimpl"); - } - - // Strings. - // - virtual void - traverse (SemanticGraph::Fundamental::String& t) - { - gen_typedef (t, string_type_, "string_pskel", "string_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NormalizedString& t) - { - gen_typedef (t, string_type_, - "normalized_string_pskel", "normalized_string_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Token& t) - { - gen_typedef (t, string_type_, "token_pskel", "token_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NameToken& t) - { - nmtoken_ = gen_typedef (t, string_type_, - "nmtoken_pskel", "nmtoken_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NameTokens& t) - { - // NMTOKENS uses NMTOKEN implementation to parse individual items. - // As a result, we don't generate NMTOKENS if we didn't generate - // NMTOKEN. Here we assume NMTOKEN is handled before NMTOKENS. - // - if(nmtoken_) - gen_typedef (t, xs_ns_ + L"::string_sequence", - "nmtokens_pskel", "nmtokens_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Name& t) - { - gen_typedef (t, string_type_, "name_pskel", "name_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NCName& t) - { - gen_typedef (t, string_type_, "ncname_pskel", "ncname_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Language& t) - { - gen_typedef (t, string_type_, "language_pskel", "language_pimpl"); - } - - // Qualified name. - // - virtual void - traverse (SemanticGraph::Fundamental::QName& t) - { - gen_typedef (t, xs_ns_ + L"::qname", "qname_pskel", "qname_pimpl"); - } - - // ID/IDREF. - // - virtual void - traverse (SemanticGraph::Fundamental::Id& t) - { - gen_typedef (t, string_type_, "id_pskel", "id_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::IdRef& t) - { - idref_ = gen_typedef (t, string_type_, "idref_pskel", "idref_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::IdRefs& t) - { - // IDREFS uses IDREF implementation to parse individual items. - // As a result, we don't generate IDREFS if we didn't generate - // IDREF. Here we assume IDREF is handled before IDREFS. - // - if (idref_) - gen_typedef (t, xs_ns_ + L"::string_sequence", - "idrefs_pskel", "idrefs_pimpl"); - } - - // URI. - // - virtual void - traverse (SemanticGraph::Fundamental::AnyURI& t) - { - gen_typedef (t, string_type_, "uri_pskel", "uri_pimpl"); - } - - // Binary. - // - virtual void - traverse (SemanticGraph::Fundamental::Base64Binary& t) - { - String buffer (auto_ptr + L"< " + xs_ns_ + L"::buffer >"); - gen_typedef (t, buffer, - "base64_binary_pskel", "base64_binary_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::HexBinary& t) - { - String buffer (auto_ptr + L"< " + xs_ns_ + L"::buffer >"); - gen_typedef (t, buffer, "hex_binary_pskel", "hex_binary_pimpl"); - } - - - // Date/time. - // - virtual void - traverse (SemanticGraph::Fundamental::Date& t) - { - gen_typedef (t, xs_ns_ + L"::date", "date_pskel", "date_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::DateTime& t) - { - gen_typedef (t, xs_ns_ + L"::date_time", - "date_time_pskel", "date_time_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Duration& t) - { - gen_typedef (t, xs_ns_ + L"::duration", - "duration_pskel", "duration_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Day& t) - { - gen_typedef (t, xs_ns_ + L"::gday", "gday_pskel", "gday_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Month& t) - { - gen_typedef (t, xs_ns_ + L"::gmonth", - "gmonth_pskel", "gmonth_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::MonthDay& t) - { - gen_typedef (t, xs_ns_ + L"::gmonth_day", - "gmonth_day_pskel", "gmonth_day_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Year& t) - { - gen_typedef (t, xs_ns_ + L"::gyear", "gyear_pskel", "gyear_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::YearMonth& t) - { - gen_typedef (t, xs_ns_ + L"::gyear_month", - "gyear_month_pskel", "gyear_month_pimpl"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Time& t) - { - gen_typedef (t, xs_ns_ + L"::time", "time_pskel", "time_pimpl"); - } - - // Entity. - // - virtual void - traverse (SemanticGraph::Fundamental::Entity&) - { - } - - virtual void - traverse (SemanticGraph::Fundamental::Entities&) - { - } - - private: - bool - gen_typedef (SemanticGraph::Type& t, - String const& type, - String const& pskel, - String const& pimpl) - { - if (ret_type (t) == type) - { - os << "typedef " << impl_ns_ << "::" << pskel << "< " << - char_type << " > " << ename (t) << ";"; - - String const& pimpl_name (t.context ().get ("impl")); - - os << "typedef " << impl_ns_ << "::" << pimpl << "< " << - char_type << " > " << pimpl_name << ";" - << endl; - - return true; - } - - return false; - } - - String xs_ns_; - String impl_ns_; - String string_type_; - - bool idref_; - bool nmtoken_; - }; - - struct FundNamespace: Namespace, Context - { - FundNamespace (Context& c) - : Namespace (c), Context (c) - { - } - - void - traverse (Type& ns) - { - pre (ns); - - String impl ("::xsd::cxx::parser::"); - impl += (validation ? L"validating" : L"non_validating"); - - String const c (char_type); - - os << "// Built-in XML Schema types mapping." << endl - << "//" << endl - << "typedef ::xsd::cxx::parser::string_sequence< " << c << - " > string_sequence;" - << "typedef ::xsd::cxx::parser::qname< " << c << " > qname;" - << "typedef ::xsd::cxx::parser::buffer buffer;" - << "typedef ::xsd::cxx::parser::time_zone time_zone;" - << "typedef ::xsd::cxx::parser::gday gday;" - << "typedef ::xsd::cxx::parser::gmonth gmonth;" - << "typedef ::xsd::cxx::parser::gyear gyear;" - << "typedef ::xsd::cxx::parser::gmonth_day gmonth_day;" - << "typedef ::xsd::cxx::parser::gyear_month gyear_month;" - << "typedef ::xsd::cxx::parser::date date;" - << "typedef ::xsd::cxx::parser::time time;" - << "typedef ::xsd::cxx::parser::date_time date_time;" - << "typedef ::xsd::cxx::parser::duration duration;" - << endl; - - os << "// Base parser skeletons." << endl - << "//" << endl - << "typedef ::xsd::cxx::parser::parser_base< " << c << - " > parser_base;" - << "typedef " << impl << "::empty_content< " << c << - " > empty_content;" - << "typedef " << impl << "::simple_content< " << c << - " > simple_content;" - << "typedef " << impl << "::complex_content< " << c << - " > complex_content;" - << "typedef " << impl << "::list_base< " << c << " > list_base;" - << endl; - - if (polymorphic) - { - os << "// Parser map interface and default implementation." << endl - << "//" << endl - << "typedef ::xsd::cxx::parser::parser_map< " << c << - " > parser_map;" - << "typedef ::xsd::cxx::parser::parser_map_impl< " << c << - " > parser_map_impl;" - << endl; - } - - os << "// Parser skeletons and implementations for the XML Schema" << endl - << "// built-in types." << endl - << "//" << endl; - - names (ns); - - os << "// Exceptions. See libxsd/xsd/cxx/parser/exceptions.hxx " << - "for details." << endl - << "//" << endl - << "typedef ::xsd::cxx::parser::exception< " << - char_type << " > exception;" - << endl - << "// Parsing diagnostics." << endl - << "//" << endl - << "typedef ::xsd::cxx::parser::severity severity;" - << "typedef ::xsd::cxx::parser::error< " << c << " > error;" - << "typedef ::xsd::cxx::parser::diagnostics< " << c << - " > diagnostics;" - << "typedef ::xsd::cxx::parser::parsing< " << c << " > parsing;" - << endl; - - os << "// Error handler. See " << - "libxsd/xsd/cxx/xml/error-handler.hxx for details." << endl - << "//" << endl - << "typedef ::xsd::cxx::xml::error_handler< " << c << - " > error_handler;" - << endl; - - os << "// Read-only string." << endl - << "//" << endl - << "typedef ::xsd::cxx::ro_string< " << c << " > ro_string;" - << endl; - - if (xml_parser == L"xerces") - { - os << "// Parsing flags. See " << - "libxsd/xsd/cxx/parser/xerces/elements.hxx" << endl - << "// for details." << endl - << "//" << endl - << "typedef ::xsd::cxx::parser::xerces::flags flags;" - << endl; - - os << "// Parsing properties. See " << - "libxsd/xsd/cxx/parser/xerces/elements.hxx" << endl - << "// for details." << endl - << "//" << endl - << "typedef ::xsd::cxx::parser::xerces::properties< " << c << - " > properties;" - << endl; - - os << "// Document type. See " << - "libxsd/xsd/cxx/parser/xerces/elements.hxx" << endl - << "// for details." << endl - << "//" << endl - << "typedef ::xsd::cxx::parser::xerces::document< " << c << - " > document;" - << endl; - - } - else if (xml_parser == L"expat") - { - os << "// Document type. See " << - "libxsd/xsd/cxx/parser/expat/elements.hxx" << endl - << "// for details." << endl - << "//" << endl - << "typedef ::xsd::cxx::parser::expat::document< " << c << - " > document;" - << endl; - } - - post (ns); - } - }; - } - - void - generate_parser_header (Context& ctx, bool generate_xml_schema) - { - String c (ctx.char_type); - - // - // - if (c == L"char") - { - ctx.os << "#ifndef XSD_USE_CHAR" << endl - << "#define XSD_USE_CHAR" << endl - << "#endif" << endl - << endl; - - ctx.os << "#ifndef XSD_CXX_PARSER_USE_CHAR" << endl - << "#define XSD_CXX_PARSER_USE_CHAR" << endl - << "#endif" << endl - << endl; - } - else if (c == L"wchar_t") - { - ctx.os << "#ifndef XSD_USE_WCHAR" << endl - << "#define XSD_USE_WCHAR" << endl - << "#endif" << endl - << endl; - - ctx.os << "#ifndef XSD_CXX_PARSER_USE_WCHAR" << endl - << "#define XSD_CXX_PARSER_USE_WCHAR" << endl - << "#endif" << endl - << endl; - } - - // - // - NarrowString extern_xml_schema; - - if (!generate_xml_schema) - extern_xml_schema = ctx.options.extern_xml_schema (); - - if (extern_xml_schema) - { - String name (ctx.hxx_expr->replace (extern_xml_schema)); - - ctx.os << "#include " << ctx.process_include_path (name) << endl - << endl; - - // Generate includes that came from the type map. - // - if (ctx.schema_root.context ().count ("includes")) - { - typedef set Includes; - - Includes const& is ( - ctx.schema_root.context ().get ("includes")); - - for (Includes::const_reverse_iterator i (is.rbegin ()); - i != is.rend (); ++i) - { - ctx.os << "#include " << *i << endl; - } - - ctx.os << endl; - } - } - else - { - if (ctx.char_type == L"char" && - ctx.xml_parser == L"xerces" && - ctx.char_encoding != L"custom") - { - ctx.os << "#include " << endl; - } - - ctx.os << "#include " << endl - << "#include " << endl - << "#include " << endl - << "#include " << endl; - - if (ctx.polymorphic) - ctx.os << "#include " << endl; - - if (ctx.validation) - ctx.os << "#include " << endl - << "#include " << endl - << "#include " << endl - << "#include " << endl; - else - ctx.os << "#include " << endl - << "#include " << endl - << "#include " << endl; - - ctx.os << "#include " << endl - << endl; - - // Generate includes that came from the type map. - // - if (ctx.schema_root.context ().count ("includes")) - { - typedef set Includes; - - Includes const& is ( - ctx.schema_root.context ().get ("includes")); - - for (Includes::const_reverse_iterator i (is.rbegin ()); - i != is.rend (); ++i) - { - ctx.os << "#include " << *i << endl; - } - - ctx.os << endl; - } - - // Generate fundamental types. - // - if (generate_xml_schema) - { - Traversal::Schema schema; - Traversal::Names names; - FundNamespace ns (ctx); - - schema >> names >> ns; - - Traversal::Names ns_names; - FundType type (ctx); - - ns >> ns_names >> type; - - schema.dispatch (ctx.schema_root); - } - else - { - Traversal::Schema schema, xsd; - Traversal::Implies implies; - Traversal::Names names; - FundNamespace ns (ctx); - - schema >> implies >> xsd >> names >> ns; - - Traversal::Names ns_names; - FundType type (ctx); - - ns >> ns_names >> type; - - schema.dispatch (ctx.schema_root); - } - } - - // Generate user type mapping. - // - if (!generate_xml_schema) - { - Traversal::Schema schema; - - Sources sources; - Includes includes (ctx, Includes::header); - Traversal::Names schema_names; - - Namespace ns (ctx); - Traversal::Names names; - - schema >> includes; - schema >> sources >> schema; - schema >> schema_names >> ns >> names; - - List list (ctx); - Union union_ (ctx); - Complex complex (ctx); - Enumeration enumeration (ctx); - - names >> list; - names >> union_; - names >> complex; - names >> enumeration; - - schema.dispatch (ctx.schema_root); - } - } - } -} diff --git a/xsd/cxx/parser/parser-header.hxx b/xsd/cxx/parser/parser-header.hxx deleted file mode 100644 index 2656fff..0000000 --- a/xsd/cxx/parser/parser-header.hxx +++ /dev/null @@ -1,18 +0,0 @@ -// file : xsd/cxx/parser/parser-header.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_PARSER_PARSER_HEADER_HXX -#define CXX_PARSER_PARSER_HEADER_HXX - -#include - -namespace CXX -{ - namespace Parser - { - void - generate_parser_header (Context&, bool generate_xml_schema); - } -} - -#endif // CXX_PARSER_PARSER_HEADER_HXX diff --git a/xsd/cxx/parser/parser-inline.cxx b/xsd/cxx/parser/parser-inline.cxx deleted file mode 100644 index fb7558e..0000000 --- a/xsd/cxx/parser/parser-inline.cxx +++ /dev/null @@ -1,399 +0,0 @@ -// file : xsd/cxx/parser/parser-inline.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include -#include - -namespace CXX -{ - namespace Parser - { - namespace - { - // - // - struct List: Traversal::List, Context - { - List (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& l) - { - String const& name (ename (l)); - SemanticGraph::Type& t (l.argumented ().type ()); - - String item (unclash (name, "item")); - - os << "// " << name << endl - << "//" << endl - << endl; - - // item_parser - // - os << inl - << "void " << name << "::" << endl - << unclash (name, "item_parser") << " (" << - fq_name (t) << "& " << item << ")" - << "{" - << "this->_xsd_" << item << "_ = &" << item << ";" - << "}"; - - // parsers - // - os << inl - << "void " << name << "::" << endl - << "parsers (" << fq_name (t) << "& " << item << ")" - << "{" - << "this->_xsd_" << item << "_ = &" << item << ";" - << "}"; - - // c-tor - // - os << inl - << name << "::" << endl - << name << " ()" << endl - << ": _xsd_" << item << "_ (0)" - << "{" - << "}"; - } - }; - - - // - // - struct ParserModifier: Traversal::Member, Context - { - ParserModifier (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& m) - { - if (skip (m)) - return; - - String const& scope (ename (m.scope ())); - String const& parser (eparser (m)); - - bool poly (polymorphic && - m.is_a () && - !anonymous (m.type ())); - - os << inl - << "void " << scope << "::" << endl - << parser << " (" << fq_name (m.type ()) << "& p)" - << "{" - << "this->" << emember (m) << " = &p;" - << "}"; - - if (poly) - { - os << inl - << "void " << scope << "::" << endl - << parser << " (const " << parser_map << "& m)" - << "{" - << "this->" << emember_map (m) << " = &m;" - << "}"; - } - } - }; - - - // - // - struct ParserMemberSet: Traversal::Member, Context - { - ParserMemberSet (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& m) - { - if (skip (m)) return; - - String const& name (ename (m)); - - os << "this->" << emember (m) << " = &" << name << ";"; - } - }; - - - // - // - struct ParserMemberInit: Traversal::Member, Context - { - ParserMemberInit (Context& c) - : Context (c), first_ (true) - { - } - - virtual void - traverse (Type& m) - { - if (skip (m)) return; - - if (first_) - first_ = false; - else - os << "," << endl << " "; - - os << emember (m) << " (0)"; - - if (polymorphic && - m.is_a () && - !anonymous (m.type ())) - { - os << "," << endl - << " " << emember_map (m) << " (0)"; - } - } - - bool - comma () const - { - return !first_; - } - - private: - bool first_; - }; - - struct ParserBaseSet: Traversal::Complex, - Traversal::List, - Context - { - ParserBaseSet (Context& c) - : Context (c), member_ (c) - { - inherits_ >> *this; - names_ >> member_; - } - - virtual void - traverse (SemanticGraph::Complex& c) - { - inherits (c, inherits_); - - if (!restriction_p (c)) - names (c, names_); - } - - virtual void - traverse (SemanticGraph::List& l) - { - String const& name (ename (l)); - String item (unclash (name, "item")); - - os << "this->_xsd_" << item << "_ = &" << name << "_item;"; - } - - private: - Traversal::Inherits inherits_; - - ParserMemberSet member_; - Traversal::Names names_; - }; - - struct Particle: Traversal::All, Context - { - Particle (Context& c) - : Context (c) - { - } - - virtual void - traverse (SemanticGraph::All& a) - { - if (!a.context().count ("comp-number")) - return; - - size_t state_count (a.context().get ("state-count")); - - os << "," << endl - << " v_all_count_ (" << state_count << "UL, v_all_first_)"; - } - }; - - // - // - struct Complex: Traversal::Complex, Context - { - Complex (Context& c) - : Context (c), - parser_modifier_ (c), - parser_base_set_ (c), - parser_member_set_ (c), - particle_ (c) - { - names_parser_modifier_ >> parser_modifier_; - inherits_parser_base_set_ >> parser_base_set_; - names_parser_member_set_ >> parser_member_set_; - } - - virtual void - traverse (Type& c) - { - bool he (has (c)); - bool ha (has (c)); - - bool hae (has_particle (c)); - - bool hra (false); // Has required attribute. - if (ha) - { - RequiredAttributeTest test (hra); - Traversal::Names names_test (test); - names (c, names_test); - } - - bool restriction (restriction_p (c)); - - if (!((!restriction && (he || ha)) || - (validation && (he || hae || hra)))) - return; - - String const& name (ename (c)); - - os << "// " << name << endl - << "//" << endl - << endl; - - if (!restriction && (he || ha)) - { - // _parser () - // - names (c, names_parser_modifier_); - - - // parsers () - // - - os << inl - << "void " << name << "::" << endl - << "parsers ("; - - { - ParserParamDecl decl (*this, true); - decl.traverse (c); - } - - os << ")" - << "{"; - - inherits (c, inherits_parser_base_set_); - names (c, names_parser_member_set_); - - os << "}"; - } - - // Default c-tor. - // - os << inl - << name << "::" << endl - << name << " ()" << endl - << ": "; - - bool comma (false); - - if (!restriction && (he || ha)) - { - ParserMemberInit member_init (*this); - Traversal::Names names_member_init (member_init); - - names (c, names_member_init); - - comma = member_init.comma (); - } - - if (validation && (he || hae)) - { - if (comma) - os << "," << endl << " "; - - os << "v_state_stack_ (sizeof (v_state_), &v_state_first_)"; - - particle_.dispatch (c.contains_compositor ().compositor ()); - - comma = true; - } - - if (validation && (hra)) - { - if (comma) - os << "," << endl << " "; - - os << "v_state_attr_stack_ (sizeof (v_state_attr_), " << - "&v_state_attr_first_)"; - } - - os << "{" - << "}"; - } - - private: - // - // - ParserModifier parser_modifier_; - Traversal::Names names_parser_modifier_; - - // - // - ParserBaseSet parser_base_set_; - Traversal::Inherits inherits_parser_base_set_; - - // - // - ParserMemberSet parser_member_set_; - Traversal::Names names_parser_member_set_; - - // - // - Particle particle_; - }; - } - - void - generate_parser_inline (Context& ctx) - { - // Emit "weak" header includes that are used in the file-per-type - // compilation model. - // - if (!ctx.options.generate_inline ()) - { - Traversal::Schema schema; - Includes includes (ctx, Includes::source); - - schema >> includes; - schema.dispatch (ctx.schema_root); - } - - Traversal::Schema schema; - - Sources sources; - Traversal::Names schema_names; - - Namespace ns (ctx); - Traversal::Names names; - - schema >> sources >> schema; - schema >> schema_names >> ns >> names; - - List list (ctx); - Complex complex (ctx); - - names >> list; - names >> complex; - - schema.dispatch (ctx.schema_root); - } - } -} diff --git a/xsd/cxx/parser/parser-inline.hxx b/xsd/cxx/parser/parser-inline.hxx deleted file mode 100644 index 7c732fc..0000000 --- a/xsd/cxx/parser/parser-inline.hxx +++ /dev/null @@ -1,18 +0,0 @@ -// file : xsd/cxx/parser/parser-inline.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_PARSER_PARSER_INLINE_HXX -#define CXX_PARSER_PARSER_INLINE_HXX - -#include - -namespace CXX -{ - namespace Parser - { - void - generate_parser_inline (Context&); - } -} - -#endif // CXX_PARSER_PARSER_INLINE_HXX diff --git a/xsd/cxx/parser/parser-source.cxx b/xsd/cxx/parser/parser-source.cxx deleted file mode 100644 index 64c0075..0000000 --- a/xsd/cxx/parser/parser-source.cxx +++ /dev/null @@ -1,957 +0,0 @@ -// file : xsd/cxx/parser/parser-source.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include -#include - -namespace CXX -{ - namespace Parser - { - namespace - { - struct Enumeration: Traversal::Enumeration, Context - { - Enumeration (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& e) - { - String const& name (ename (e)); - String const& ret (ret_type (e)); - - SemanticGraph::Type& base (e.inherits ().base ()); - - bool same (ret == ret_type (base)); - - if (same || ret == L"void" || polymorphic) - { - os << "// " << name << endl - << "//" << endl - << endl; - } - - if (same || ret == L"void") - { - os << ret << " " << name << "::" << endl - << post_name (e) << " ()" - << "{"; - - if (same) - { - if (ret == L"void") - os << post_name (base) << " ();"; - else - os << "return " << post_name (base) << " ();"; - } - - os << "}"; - } - - if (polymorphic) - { - String id (e.name ()); - - if (String ns = xml_ns_name (e)) - { - id += L' '; - id += ns; - } - - os << "const " << char_type << "* " << name << "::" << endl - << "_static_type ()" - << "{" - << "return " << strlit (id) << ";" - << "}"; - - os << "const " << char_type << "* " << name << "::" << endl - << "_dynamic_type () const" - << "{" - << "return _static_type ();" - << "}"; - - if (validation) - { - bool gen (!anonymous (e)); - - // We normally don't need to enter anonymous types into - // the inheritance map. The only exception is when an - // anonymous types is defined inside an element that - // is a member of a substitution group. - // - if (!gen) - { - // The first instance that this anonymous type classifies - // is the prototype for others if any. If this type does - // not classify anything (e.g., it is a base), then we - // don't need to do anything. - // - if (e.classifies_begin () != e.classifies_end ()) - { - SemanticGraph::Instance& i ( - e.classifies_begin ()->instance ()); - - if (SemanticGraph::Element* e = - dynamic_cast (&i)) - { - if (e->substitutes_p ()) - gen = true; - } - } - } - - if (gen) - { - os << "static" << endl - << "const ::xsd::cxx::parser::validating::inheritance_map_entry< " << - char_type << " >" << endl - << "_xsd_" << name << "_inheritance_map_entry_ (" << endl - << name << "::_static_type ()," << endl - << fq_name (base) << "::_static_type ());" - << endl; - } - } - } - } - }; - - // - // - struct List: Traversal::List, Context - { - List (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& l) - { - String const& name (ename (l)); - SemanticGraph::Type& t (l.argumented ().type ()); - - String item (unclash (name, "item")); - - os << "// " << name << endl - << "//" << endl - << endl; - - // item - // - String const& arg (arg_type (t)); - - os << "void " << name << "::" << endl - << item; - - if (arg == L"void") - os << " ()"; - else - os << " (" << arg << ")"; - - os << "{" - << "}"; - - // post - // - if (ret_type (l) == L"void") - os << "void " << name << "::" << endl - << post_name (l) << " ()" - << "{" - << "}"; - - // parse_item - // - String inst (L"_xsd_" + item + L"_"); - String const& post (post_name (t)); - - os << "void " << name << "::" << endl - << "_xsd_parse_item (const " << string_type << "& v)" - << "{" - << "if (this->" << inst << ")" - << "{" - << "this->" << inst << "->pre ();" - << "this->" << inst << "->_pre_impl ();" - << "this->" << inst << "->_characters (v);" - << "this->" << inst << "->_post_impl ();"; - - if (ret_type (t) == L"void") - os << "this->" << inst << "->" << post << " ();" - << "this->" << item << " ();"; - else - os << "this->" << item << " (this->" << inst << "->" << - post << " ());"; - - os << "}" - << "}"; - - // - // - if (polymorphic) - { - String id (l.name ()); - - if (String ns = xml_ns_name (l)) - { - id += L' '; - id += ns; - } - - os << "const " << char_type << "* " << name << "::" << endl - << "_static_type ()" - << "{" - << "return " << strlit (id) << ";" - << "}"; - - os << "const " << char_type << "* " << name << "::" << endl - << "_dynamic_type () const" - << "{" - << "return _static_type ();" - << "}"; - } - } - }; - - // - // - struct Union: Traversal::Union, Context - { - Union (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& u) - { - String const& name (ename (u)); - String const& ret (ret_type (u)); - - if (ret == L"void" || polymorphic) - { - os << "// " << name << endl - << "//" << endl - << endl; - } - - if (ret == L"void") - { - os << "void " << name << "::" << endl - << post_name (u) << " ()" - << "{" - << "}"; - } - - if (polymorphic) - { - String id (u.name ()); - - if (String ns = xml_ns_name (u)) - { - id += L' '; - id += ns; - } - - os << "const " << char_type << "* " << name << "::" << endl - << "_static_type ()" - << "{" - << "return " << strlit (id) << ";" - << "}"; - - os << "const " << char_type << "* " << name << "::" << endl - << "_dynamic_type () const" - << "{" - << "return _static_type ();" - << "}"; - } - } - }; - - // - // - struct StartElement: Traversal::Element, Context - { - StartElement (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& e) - { - if (skip (e)) - return; - - bool poly (polymorphic && !anonymous (e.type ())); - - os << "if ("; - - if (poly && e.global_p ()) - os << "("; - - if (e.qualified_p () && e.namespace_ ().name ()) - { - os << "n == " << strlit (e.name ()) << " && " << - "ns == " << strlit (e.namespace_ ().name ()); - } - else - { - os << "n == " << strlit (e.name ()) << " && ns.empty ()"; - } - - // Only a globally-defined element can be a subst-group root. - // - if (poly && e.global_p ()) - { - os << ") ||" << endl - << "::xsd::cxx::parser::substitution_map_instance< " << - char_type << " > ().check (" << endl - << "ns, n, " << strlit (e.namespace_ ().name ()) << - ", " << strlit (e.name ()) << ", t)"; - } - - os << ")" - << "{"; - - String inst; - - if (poly) - { - SemanticGraph::Type& t (e.type ()); - inst = "p"; - - // For pre-computing length. - // - String type_id (t.name ()); - - if (String type_ns = xml_ns_name (t)) - { - type_id += L' '; - type_id += type_ns; - } - - String fq_type (fq_name (t)); - String const& member (emember (e)); - String const& member_map (emember_map (e)); - - os << fq_type << "* p = 0;" - << endl - << "if (t == 0 && this->" << member << " != 0)" << endl - << inst << " = this->" << member << ";" - << "else" - << "{" - << string_type << " ts (" << fq_type << - "::_static_type (), " << type_id.size () << "UL);" - << endl - << "if (t == 0)" << endl - << "t = &ts;" - << endl - << "if (this->" << member << " != 0 && *t == ts)" << endl - << inst << " = this->" << member << ";" - << "else if (this->" << member_map << " != 0)" << endl - << inst << " = dynamic_cast< " << fq_type << - "* > (" << endl - << "this->" << member_map << "->find (*t));" - << "}"; - } - else - inst = L"this->" + emember (e); - - os << "this->" << complex_base << "::context_.top ().parser_ = " << - inst << ";" - << endl - << "if (" << inst << ")" << endl - << inst << "->pre ();" // _start_element calls _pre - << endl - << "return true;" - << "}"; - } - }; - - - // - // - struct EndElement: Traversal::Element, Context - { - EndElement (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& e) - { - if (skip (e)) - return; - - bool poly (polymorphic && !anonymous (e.type ())); - String const& name (ename (e)); - - os << "if ("; - - if (poly && e.global_p ()) - os << "("; - - if (e.qualified_p () && e.namespace_ ().name ()) - { - os << "n == " << strlit (e.name ()) << " && " << - "ns == " << strlit (e.namespace_ ().name ()); - } - else - { - os << "n == " << strlit (e.name ()) << " && ns.empty ()"; - } - - // Only a globally-defined element can be a subst-group root. - // - if (poly && e.global_p ()) - { - os << ") ||" << endl - << "::xsd::cxx::parser::substitution_map_instance< " << - char_type << " > ().check (" << endl - << "ns, n, " << strlit (e.namespace_ ().name ()) << - ", " << strlit (e.name ()) << ")"; - } - - os << ")" - << "{"; - - // _end_element calls post - // - - SemanticGraph::Type& type (e.type ()); - String const& post (post_name (type)); - String inst; - - if (poly) - { - String const& fq_type (fq_name (type)); - inst = "p"; - - os << fq_type << "* p =" << endl - << "dynamic_cast< " << fq_type << "* > (" << endl - << "this->" << complex_base << "::context_.top ().parser_);" - << endl; - } - else - inst = L"this->" + emember (e); - - os << "if (" << inst << ")"; - - if (ret_type (type) == L"void") - os << "{" - << inst << "->" << post << " ();" - << "this->" << name << " ();" - << "}"; - else - os << endl - << "this->" << name << " (" << inst << "->" << post << " ());" - << endl; - - os << "return true;" - << "}"; - } - }; - - // - // - struct Attribute: Traversal::Attribute, Context - { - Attribute (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& a) - { - String const& name (ename (a)); - String const& inst (emember (a)); - - if (a.qualified_p () && a.namespace_ ().name ()) - { - os << "if (n == " << strlit (a.name ()) << " && " << - "ns == " << strlit (a.namespace_ ().name ()) << ")" - << "{"; - } - else - { - os << "if (n == " << strlit (a.name ()) << " && ns.empty ())" - << "{"; - } - - SemanticGraph::Type& type (a.type ()); - String const& post (post_name (type)); - String const& ret (ret_type (type)); - - os << "if (this->" << inst << ")" - << "{" - << "this->" << inst << "->pre ();" - << "this->" << inst << "->_pre_impl ();" - << "this->" << inst << "->_characters (v);" - << "this->" << inst << "->_post_impl ();"; - - if (ret == L"void") - os << "this->" << inst << "->" << post << " ();" - << "this->" << name << " ();"; - else - os << "this->" << name << " (this->" << inst << "->" << - post << " ());"; - - os << "}" - << "return true;" - << "}"; - } - }; - - // - // - struct ParserCallback: Traversal::Member, Context - { - ParserCallback (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& m) - { - if (skip (m)) - return; - - String const& arg (arg_type (m.type ())); - - os << "void " << ename (m.scope ()) << "::" << endl - << ename (m); - - if (arg == L"void") - os << " ()"; - else - os << " (" << arg << ")"; - - os << "{" - << "}"; - } - }; - - // - // - struct Complex: Traversal::Complex, Context - { - Complex (Context& c) - : Context (c), - parser_callback_ (c), - start_element_ (c), - end_element_ (c), - attribute_ (c) - { - names_parser_callback_ >> parser_callback_; - names_start_element_ >> start_element_; - names_end_element_ >> end_element_; - names_attribute_ >> attribute_; - } - - virtual void - traverse (Type& c) - { - bool he (has (c)); - bool ha (has (c)); - - String const& ret (ret_type (c)); - bool same (c.inherits_p () && - ret == ret_type (c.inherits ().base ())); - - String const& name (ename (c)); - - if ((he || ha || same || ret == L"void") || polymorphic) - { - os << "// " << name << endl - << "//" << endl - << endl; - } - - if (polymorphic) - { - String id (c.name ()); - - if (String ns = xml_ns_name (c)) - { - id += L' '; - id += ns; - } - - os << "const " << char_type << "* " << name << "::" << endl - << "_static_type ()" - << "{" - << "return " << strlit (id) << ";" - << "}"; - - os << "const " << char_type << "* " << name << "::" << endl - << "_dynamic_type () const" - << "{" - << "return _static_type ();" - << "}"; - - if (c.inherits_p () && validation) - { - bool gen (!anonymous (c)); - - // We normally don't need to enter anonymous types into - // the inheritance map. The only exception is when an - // anonymous types is defined inside an element that - // is a member of a substitution group. - // - if (!gen) - { - // The first instance that this anonymous type classifies - // is the prototype for others if any. If this type does - // not classify anything (e.g., it is a base), then we - // don't need to do anything. - // - if (c.classifies_begin () != c.classifies_end ()) - { - SemanticGraph::Instance& i ( - c.classifies_begin ()->instance ()); - - if (SemanticGraph::Element* e = - dynamic_cast (&i)) - { - if (e->substitutes_p ()) - gen = true; - } - } - } - - if (gen) - { - SemanticGraph::Type& base (c.inherits ().base ()); - - os << "static" << endl - << "const ::xsd::cxx::parser::validating::inheritance_map_entry< " << - char_type << " >" << endl - << "_xsd_" << name << "_inheritance_map_entry_ (" << endl - << name << "::_static_type ()," << endl - << fq_name (base) << "::_static_type ());" - << endl; - } - } - } - - if (!(he || ha || same || ret == L"void")) - return; - - // Parser callbacks. - // - if (!restriction_p (c)) - names (c, names_parser_callback_); - - if (same || ret == L"void") - { - os << ret << " " << name << "::" << endl - << post_name (c) << " ()" - << "{"; - - if (same) - { - SemanticGraph::Type& base (c.inherits ().base ()); - - if (ret == L"void") - os << post_name (base) << " ();"; - else - os << "return " << post_name (base) << " ();"; - } - - os << "}"; - } - - // The rest is parsing/validation code which is generated in - // *-validation-source.cxx. - // - if (validation) - return; - - // Don't use restriction_p here since we don't want special - // treatment of anyType. - // - bool restriction ( - c.inherits_p () && - c.inherits ().is_a ()); - - // _start_element_impl & _end_element_impl - // - if (he) - { - os << "bool " << name << "::" << endl - << "_start_element_impl (const " << string_type << "& ns," << endl - << "const " << string_type << "& n," << endl - << "const " << string_type << "* t)" - << "{" - << "XSD_UNUSED (t);" - << endl; - - if (!restriction) - { - os << "if (this->"; - - if (c.inherits_p ()) - os << fq_name (c.inherits ().base ()); - else - os << complex_base; - - os << "::_start_element_impl (ns, n, t))" << endl - << "return true;" - << endl; - } - - names (c, names_start_element_); - - os << "return false;" - << "}"; - - - // _end_element_impl - // - os << "bool " << name << "::" << endl - << "_end_element_impl (const " << string_type << "& ns," << endl - << "const " << string_type << "& n)" - << "{"; - - if (!restriction) - { - os << "if (this->"; - - if (c.inherits_p () && !restriction) - os << fq_name (c.inherits ().base ()); - else - os << complex_base; - - os << "::_end_element_impl (ns, n))" << endl - << "return true;" - << endl; - } - - names (c, names_end_element_); - - os << "return false;" - << "}"; - } - - - if (ha) - { - // _attribute_impl - // - os << "bool " << name << "::" << endl - << "_attribute_impl (const " << string_type << "& ns," << endl - << "const " << string_type << "& n," << endl - << "const " << string_type << "& v)" - << "{"; - - if (!restriction) - { - os << "if (this->"; - - if (c.inherits_p ()) - os << fq_name (c.inherits ().base ()); - else - os << complex_base; - - os << "::_attribute_impl (ns, n, v))" << endl - << "return true;" - << endl; - } - - names (c, names_attribute_); - - os << "return false;" - << "}"; - } - } - - private: - // - // - ParserCallback parser_callback_; - Traversal::Names names_parser_callback_; - - // - // - StartElement start_element_; - Traversal::Names names_start_element_; - - // - // - EndElement end_element_; - Traversal::Names names_end_element_; - - // - // - Attribute attribute_; - Traversal::Names names_attribute_; - }; - - - // Generate substitution group map entries. - // - struct GlobalElement: Traversal::Element, Context - { - GlobalElement (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& e) - { - if (e.substitutes_p ()) - { - String name (escape (e.name ())); - Type& r (e.substitutes ().root ()); - - SemanticGraph::Type& type (e.type ()); - - os << "// Substitution map entry for " << comment (e.name ()) << "." << endl - << "//" << endl - << "static" << endl - << "const ::xsd::cxx::parser::substitution_map_entry< " << - char_type << " >" << endl - << "_xsd_" << name << "_substitution_map_entry_ (" << endl - << strlit (e.namespace_ ().name ()) << "," << endl - << strlit (e.name ()) << "," << endl - << strlit (r.namespace_ ().name ()) << "," << endl - << strlit (r.name ()) << "," << endl - << fq_name (type) << "::_static_type ());" - << endl; - } - } - }; - } - - void - generate_parser_source (Context& ctx) - { - if (ctx.polymorphic) - { - ctx.os << "#include " << endl; - - if (ctx.validation) - ctx.os << "#include " << endl - << endl; - else - ctx.os << endl; - - bool import_maps (ctx.options.import_maps ()); - bool export_maps (ctx.options.export_maps ()); - - if (import_maps || export_maps) - { - ctx.os << "#ifndef XSD_NO_EXPORT" << endl - << endl - << "namespace xsd" - << "{" - << "namespace cxx" - << "{" - << "namespace parser" - << "{" - << "#ifdef _MSC_VER" << endl; - - if (export_maps) - ctx.os << "template struct __declspec (dllexport) " << - "substitution_map_init< " << ctx.char_type << " >;"; - - if (import_maps) - ctx.os << "template struct __declspec (dllimport) " << - "substitution_map_init< " << ctx.char_type << " >;"; - - if (ctx.validation && export_maps) - ctx.os << "template struct __declspec (dllexport) " << - "inheritance_map_init< " << ctx.char_type << " >;"; - - if (ctx.validation && import_maps) - ctx.os << "template struct __declspec (dllimport) " << - "inheritance_map_init< " << ctx.char_type << " >;"; - - ctx.os << "#elif defined(__GNUC__) && __GNUC__ >= 4" << endl - << "template struct __attribute__ ((visibility(\"default\"))) " << - "substitution_map_init< " << ctx.char_type << " >;"; - - if (ctx.validation) - ctx.os << "template struct __attribute__ ((visibility(\"default\"))) " << - "inheritance_map_init< " << ctx.char_type << " >;"; - - ctx.os << "#elif defined(XSD_MAP_VISIBILITY)" << endl - << "template struct XSD_MAP_VISIBILITY " << - "substitution_map_init< " << ctx.char_type << " >;"; - - if (ctx.validation) - ctx.os << "template struct XSD_MAP_VISIBILITY " << - "inheritance_map_init< " << ctx.char_type << " >;"; - - ctx.os << "#endif" << endl - << "}" // parser - << "}" // cxx - << "}" // xsd - << "#endif // XSD_NO_EXPORT" << endl - << endl; - } - - ctx.os << "static" << endl - << "const ::xsd::cxx::parser::substitution_map_init< " << - ctx.char_type << " >" << endl - << "_xsd_substitution_map_init_;" - << endl; - - if (ctx.validation) - { - ctx.os << "static" << endl - << "const ::xsd::cxx::parser::validating::inheritance_map_init< " << - ctx.char_type << " >" << endl - << "_xsd_inheritance_map_init_;" - << endl; - } - } - - // Emit "weak" header includes that are used in the file-per-type - // compilation model. - // - if (ctx.options.generate_inline ()) - { - Traversal::Schema schema; - Includes includes (ctx, Includes::source); - - schema >> includes; - schema.dispatch (ctx.schema_root); - } - - Traversal::Schema schema; - Sources sources; - Traversal::Names schema_names; - - Namespace ns (ctx); - Traversal::Names names; - - schema >> sources >> schema; - schema >> schema_names >> ns >> names; - - List list (ctx); - Union union_ (ctx); - Complex complex (ctx); - Enumeration enumeration (ctx); - GlobalElement global_element (ctx); - - names >> list; - names >> union_; - names >> complex; - names >> enumeration; - - if (ctx.polymorphic) - names >> global_element; - - schema.dispatch (ctx.schema_root); - } - } -} diff --git a/xsd/cxx/parser/parser-source.hxx b/xsd/cxx/parser/parser-source.hxx deleted file mode 100644 index 0f8f57e..0000000 --- a/xsd/cxx/parser/parser-source.hxx +++ /dev/null @@ -1,18 +0,0 @@ -// file : xsd/cxx/parser/parser-source.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_PARSER_PARSER_SOURCE_HXX -#define CXX_PARSER_PARSER_SOURCE_HXX - -#include - -namespace CXX -{ - namespace Parser - { - void - generate_parser_source (Context&); - } -} - -#endif // CXX_PARSER_PARSER_SOURCE_HXX diff --git a/xsd/cxx/parser/print-impl-common.hxx b/xsd/cxx/parser/print-impl-common.hxx deleted file mode 100644 index 66379f0..0000000 --- a/xsd/cxx/parser/print-impl-common.hxx +++ /dev/null @@ -1,641 +0,0 @@ -// file : xsd/cxx/parser/print-impl-common.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_PARSER_PRINT_IMPL_COMMON_HXX -#define CXX_PARSER_PRINT_IMPL_COMMON_HXX - -#include -#include - -#include - -namespace CXX -{ - namespace Parser - { - struct PrintCall: Traversal::Type, - - Traversal::Fundamental::Boolean, - - Traversal::Fundamental::Byte, - Traversal::Fundamental::UnsignedByte, - Traversal::Fundamental::Short, - Traversal::Fundamental::UnsignedShort, - Traversal::Fundamental::Int, - Traversal::Fundamental::UnsignedInt, - Traversal::Fundamental::Long, - Traversal::Fundamental::UnsignedLong, - Traversal::Fundamental::Integer, - Traversal::Fundamental::NonPositiveInteger, - Traversal::Fundamental::NonNegativeInteger, - Traversal::Fundamental::PositiveInteger, - Traversal::Fundamental::NegativeInteger, - - Traversal::Fundamental::Float, - Traversal::Fundamental::Double, - Traversal::Fundamental::Decimal, - - Traversal::Fundamental::String, - Traversal::Fundamental::NormalizedString, - Traversal::Fundamental::Token, - Traversal::Fundamental::Name, - Traversal::Fundamental::NameToken, - Traversal::Fundamental::NameTokens, - Traversal::Fundamental::NCName, - Traversal::Fundamental::Language, - - Traversal::Fundamental::QName, - - Traversal::Fundamental::Id, - Traversal::Fundamental::IdRef, - Traversal::Fundamental::IdRefs, - - Traversal::Fundamental::AnyURI, - - Traversal::Fundamental::Base64Binary, - Traversal::Fundamental::HexBinary, - - Traversal::Fundamental::Date, - Traversal::Fundamental::DateTime, - Traversal::Fundamental::Duration, - Traversal::Fundamental::Day, - Traversal::Fundamental::Month, - Traversal::Fundamental::MonthDay, - Traversal::Fundamental::Year, - Traversal::Fundamental::YearMonth, - Traversal::Fundamental::Time, - - Context - { - PrintCall (Context& c, String const& tag, String const& arg) - : Context (c), tag_ (tag), arg_ (arg) - { - } - - virtual void - traverse (SemanticGraph::Type&) - { - gen_user_type (); - } - - // Boolean. - // - virtual void - traverse (SemanticGraph::Fundamental::Boolean& t) - { - if (default_type (t, "bool")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << - arg_ << " << std::endl;"; - } - else - gen_user_type (); - } - - // Integral types. - // - virtual void - traverse (SemanticGraph::Fundamental::Byte& t) - { - if (default_type (t, "signed char")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << - " << static_cast (" << arg_ << ") << std::endl;"; - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedByte& t) - { - if (default_type (t, "unsigned char")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << - " << static_cast (" << arg_ << ") << std::endl;"; - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::Short& t) - { - if (default_type (t, "short")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << - arg_ << " << std::endl;"; - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedShort& t) - { - if (default_type (t, "unsigned short")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << - arg_ << " << std::endl;"; - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::Int& t) - { - if (default_type (t, "int")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << - arg_ << " << std::endl;"; - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedInt& t) - { - if (default_type (t, "unsigned int")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << - arg_ << " << std::endl;"; - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::Long& t) - { - if (default_type (t, "long long")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << - arg_ << " << std::endl;"; - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedLong& t) - { - if (default_type (t, "unsigned long long")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << - arg_ << " << std::endl;"; - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::Integer& t) - { - if (default_type (t, "long long")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << - arg_ << " << std::endl;"; - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::NegativeInteger& t) - { - if (default_type (t, "long long")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << - arg_ << " << std::endl;"; - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) - { - if (default_type (t, "long long")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << - arg_ << " << std::endl;"; - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::PositiveInteger& t) - { - if (default_type (t, "unsigned long long")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << - arg_ << " << std::endl;"; - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) - { - if (default_type (t, "unsigned long long")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << - arg_ << " << std::endl;"; - } - else - gen_user_type (); - } - - // Floats. - // - virtual void - traverse (SemanticGraph::Fundamental::Float& t) - { - if (default_type (t, "float")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << - arg_ << " << std::endl;"; - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::Double& t) - { - if (default_type (t, "double")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << - arg_ << " << std::endl;"; - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::Decimal& t) - { - if (default_type (t, "double")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << - arg_ << " << std::endl;"; - } - else - gen_user_type (); - } - - // Strings. - // - virtual void - traverse (SemanticGraph::Fundamental::String& t) - { - gen_string (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::NormalizedString& t) - { - gen_string (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Token& t) - { - gen_string (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::NameToken& t) - { - gen_string (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Name& t) - { - gen_string (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::NCName& t) - { - gen_string (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Language& t) - { - gen_string (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Id& t) - { - gen_string (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::IdRef& t) - { - gen_string (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::AnyURI& t) - { - gen_string (t); - } - - // String sequences. - // - - virtual void - traverse (SemanticGraph::Fundamental::NameTokens& t) - { - gen_sequence (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::IdRefs& t) - { - gen_sequence (t); - } - - // QName - // - - virtual void - traverse (SemanticGraph::Fundamental::QName& t) - { - if (default_type (t, xs_ns_name () + L"::qname")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << ";" - << endl - << "if (" << arg_ << ".prefix ().empty ())" << endl - << cout_inst << " << " << arg_ << ".name ();" - << "else" << endl - << cout_inst << " << " << arg_ << ".prefix () << " << L << - "':' << " << arg_ << ".name ();" - << endl - << cout_inst << " << std::endl;"; - } - else - gen_user_type (); - } - - // Binary. - // - virtual void - traverse (SemanticGraph::Fundamental::Base64Binary& t) - { - gen_buffer (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::HexBinary& t) - { - gen_buffer (t); - } - - // Date/time. - // - virtual void - traverse (SemanticGraph::Fundamental::Date& t) - { - if (default_type (t, xs_ns_name () + L"::date")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << endl - << " << " << arg_ << ".year () << '-'" << endl - << " << " << arg_ << ".month () << '-'" << endl - << " << " << arg_ << ".day ();"; - - gen_time_zone (); - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::DateTime& t) - { - if (default_type (t, xs_ns_name () + L"::date_time")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << endl - << " << " << arg_ << ".year () << '-'" << endl - << " << " << arg_ << ".month () << '-'" << endl - << " << " << arg_ << ".day () << 'T'" << endl - << " << " << arg_ << ".hours () << ':'" << endl - << " << " << arg_ << ".minutes () << ':'" << endl - << " << " << arg_ << ".seconds ();"; - - gen_time_zone (); - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::Duration& t) - { - if (default_type (t, xs_ns_name () + L"::duration")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << ";" - << endl - << "if (" << arg_ << ".negative ())" << endl - << cout_inst << " << '-';" - << endl - << cout_inst << " << 'P'" << endl - << " << " << arg_ << ".years () << 'Y'" << endl - << " << " << arg_ << ".months () << 'M'" << endl - << " << " << arg_ << ".days () << " << L << "\"DT\"" << endl - << " << " << arg_ << ".hours () << 'H'" << endl - << " << " << arg_ << ".minutes () << 'M'" << endl - << " << " << arg_ << ".seconds () << 'S'" - << " << std::endl;"; - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::Day& t) - { - if (default_type (t, xs_ns_name () + L"::gday")) - { - os << cout_inst << " << " << strlit (tag_ + L": ---") << - " << " << arg_ << ".day ();"; - - gen_time_zone (); - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::Month& t) - { - if (default_type (t, xs_ns_name () + L"::gmonth")) - { - os << cout_inst << " << " << strlit (tag_ + L": --") << - " << " << arg_ << ".month ();"; - - gen_time_zone (); - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::MonthDay& t) - { - if (default_type (t, xs_ns_name () + L"::gmonth_day")) - { - os << cout_inst << " << " << strlit (tag_ + L": --") << endl - << " << " << arg_ << ".month () << '-'" << endl - << " << " << arg_ << ".day ();"; - - gen_time_zone (); - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::Year& t) - { - if (default_type (t, xs_ns_name () + L"::gyear")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << - arg_ << ".year ();"; - - gen_time_zone (); - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::YearMonth& t) - { - if (default_type (t, xs_ns_name () + L"::gyear_month")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << endl - << " << " << arg_ << ".year () << '-'" << endl - << " << " << arg_ << ".month ();"; - - gen_time_zone (); - } - else - gen_user_type (); - } - - virtual void - traverse (SemanticGraph::Fundamental::Time& t) - { - if (default_type (t, xs_ns_name () + L"::time")) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << endl - << " << " << arg_ << ".hours () << ':'" << endl - << " << " << arg_ << ".minutes () << ':'" << endl - << " << " << arg_ << ".seconds ();"; - - gen_time_zone (); - } - else - gen_user_type (); - } - - private: - bool - default_type (SemanticGraph::Type& t, String const& def_type) - { - return ret_type (t) == def_type; - } - - void - gen_user_type () - { - os << "// TODO" << endl - << "//" << endl; - } - - void - gen_string (SemanticGraph::Type& t) - { - if ((char_type == L"char" && default_type (t, "::std::string")) || - (char_type == L"wchar_t" && default_type (t, "::std::wstring"))) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << - arg_ << " << std::endl;"; - } - else - gen_user_type (); - } - - void - gen_sequence (SemanticGraph::Type& t) - { - String type (xs_ns_name () + L"::string_sequence"); - - if (default_type (t, type)) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << ";" - << endl; - - os << "for (" << type << "::const_iterator i (" << arg_ << - ".begin ()), e (" << arg_ << ".end ());" << endl - << "i != e;)" - << "{" - << cout_inst << " << *i++;" - << "if (i != e)" << endl - << cout_inst << " << ' ';" - << "}" - << cout_inst << " << std::endl;"; - } - else - gen_user_type (); - } - - void - gen_buffer (SemanticGraph::Type& t) - { - String type (auto_ptr + L"< " + xs_ns_name () + L"::buffer >"); - - if (default_type (t, type)) - { - os << cout_inst << " << " << strlit (tag_ + L": ") << " << " - << arg_ << "->size () << " << L << "\" bytes\" << std::endl;"; - } - else - gen_user_type (); - } - - void - gen_time_zone () - { - os << endl - << "if (" << arg_ << ".zone_present ())" - << "{" - << "if (" << arg_ << ".zone_hours () < 0)" << endl - << cout_inst << " << " << arg_ << ".zone_hours () << ':' << -" << - arg_ << ".zone_minutes ();" - << "else" << endl - << cout_inst << " << '+' << " << arg_ << ".zone_hours () << " << - "':' << " << arg_ << ".zone_minutes ();"; - - os << "}" - << cout_inst << " << std::endl;"; - } - - private: - String tag_; - String arg_; - }; - } -} - -#endif // CXX_PARSER_PRINT_IMPL_COMMON_HXX diff --git a/xsd/cxx/parser/state-processor.cxx b/xsd/cxx/parser/state-processor.cxx deleted file mode 100644 index 423d0d8..0000000 --- a/xsd/cxx/parser/state-processor.cxx +++ /dev/null @@ -1,319 +0,0 @@ -// file : xsd/cxx/parser/state-processor.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include -#include - -#include - -#include - -#include -#include - -using namespace std; - -namespace CXX -{ - namespace Parser - { - namespace - { - typedef vector Particles; - - /* - void - print (Particles const& p) - { - using std::wcerr; - using std::endl; - - wcerr << "prefixes: " << endl; - - for (Particles::const_iterator i (p.begin ()); i != p.end (); ++i) - { - if (SemanticGraph::Element* e = - dynamic_cast (*i)) - { - wcerr << e->name () << endl; - } - else - { - wcerr << "" << endl; - } - } - - wcerr << endl; - } - */ - - // - // - struct Particle: Traversal::All, - Traversal::Choice, - Traversal::Sequence - { - Particle (size_t& all, - size_t& choice, - size_t& sequence, - size_t& depth) - : all_ (all), - choice_ (choice), - sequence_ (sequence), - depth_ (depth) - { - } - - virtual void - traverse (SemanticGraph::All& a) - { - using SemanticGraph::Compositor; - - // Go over particles, collecting "prefix" particles in prefixes_, - // assigning state numbers and calculating effective minOccurs. - // If all prefixes of this compositor have minOccurs = 0, then - // the compositor itself effectively has minOccurs = 0 regardless - // of the actual value specified in the schema. - // - // Note that we don't need to care about depth since the 'all' - // compositor cannot contain any nested compositors. - // - - size_t state (0); - size_t min (0); - - for (Compositor::ContainsIterator ci (a.contains_begin ()); - ci != a.contains_end (); ++ci) - { - SemanticGraph::Particle& p (ci->particle ()); - - // The 'all' compositor can only include elements. - // - prefixes_.push_back (&p); - - if (min == 0 && ci->min () != 0) - min = 1; - - p.context ().set ("prefix", true); - p.context ().set ("state", state++); - } - - if (!prefixes_.empty ()) - { - a.context ().set ("comp-number", choice_++); - a.context ().set ("prefixes", prefixes_); - a.context ().set ("state-count", size_t (prefixes_.size ())); - - // effective-min = min * actual-min - // - if (min == 1) - min = a.min (); - - a.context ().set ("effective-min", min); - - // print (prefixes_); - } - } - - virtual void - traverse (SemanticGraph::Choice& c) - { - using SemanticGraph::Compositor; - - // Go over particles, collecting "prefix" particles in prefixes_, - // assigning state numbers and calculating effective minOccurs. - // If any prefix of this compositor have minOccurs = 0, then the - // compositor itself effectively has minOccurs = 0 regardless of - // the actual value specified in the schema. - // - - size_t state (0); - size_t min (1); - - for (Compositor::ContainsIterator ci (c.contains_begin ()); - ci != c.contains_end (); ++ci) - { - SemanticGraph::Particle& p (ci->particle ()); - - if (p.is_a () || - p.is_a ()) - { - prefixes_.push_back (&p); - - if (min == 1 && ci->min () == 0) - min = 0; - } - else - { - size_t depth (0); - Particle t (all_, choice_, sequence_, depth); - t.dispatch (p); - - if (t.prefixes_.empty ()) - continue; // Skip empty compositors. - - if (++depth > depth_) // One for this compositor. - depth_ = depth; - - prefixes_.insert (prefixes_.end (), - t.prefixes_.begin ().base (), - t.prefixes_.end ().base ()); - - if (min == 1 && - p.context ().get ("effective-min") == 0) - min = 0; - } - - p.context ().set ("prefix", true); - p.context ().set ("state", state++); - } - - if (!prefixes_.empty ()) - { - c.context ().set ("comp-number", choice_++); - c.context ().set ("prefixes", prefixes_); - - // effective-min = min * actual-min - // - if (min == 1) - min = c.min (); - - c.context ().set ("effective-min", min); - - // print (prefixes_); - } - } - - virtual void - traverse (SemanticGraph::Sequence& s) - { - using SemanticGraph::Compositor; - - // Go over particles, collecting "prefix" particles in prefixes_, - // assigning state numbers and calculating effective minOccurs. - // If all prefixes of this compositor have minOccurs = 0, then - // the compositor itself effectively has minOccurs = 0 regardless - // of the actual value specified in the schema. - // - - bool prefix (true); - size_t state (0); - size_t min (0); - - for (Compositor::ContainsIterator ci (s.contains_begin ()); - ci != s.contains_end (); ++ci) - { - SemanticGraph::Particle& p (ci->particle ()); - - if (p.is_a () || - p.is_a ()) - { - if (prefix) - { - prefixes_.push_back (&p); - - if (ci->min () != 0) - min = 1; - } - } - else - { - size_t depth (0); - Particle t (all_, choice_, sequence_, depth); - t.dispatch (p); - - if (t.prefixes_.empty ()) - continue; // Skip empty compositors. - - if (++depth > depth_) // One for this compositor. - depth_ = depth; - - if (prefix) - { - prefixes_.insert (prefixes_.end (), - t.prefixes_.begin ().base (), - t.prefixes_.end ().base ()); - - if (p.context ().get ("effective-min") != 0) - min = 1; - } - } - - p.context ().set ("state", state++); - - if (prefix) - p.context ().set ("prefix", true); - - if (prefix && min != 0) - prefix = false; - } - - if (!prefixes_.empty ()) - { - s.context ().set ("comp-number", sequence_++); - s.context ().set ("prefixes", prefixes_); - - // effective-min = min * actual-min - // - if (min == 1) - min = s.min (); - - s.context ().set ("effective-min", min); - - // print (prefixes_); - } - } - - private: - Particles prefixes_; - - size_t& all_; - size_t& choice_; - size_t& sequence_; - - size_t& depth_; - }; - - - // - // - struct Complex: Traversal::Complex - { - virtual void - traverse (Type& c) - { - if (c.contains_compositor_p ()) - { - size_t all (0), choice (0), sequence (0), depth (0); - Particle t (all, choice, sequence, depth); - t.dispatch (c.contains_compositor ().compositor ()); - - // Set the maximum stack depth for this type. Used to - // allocate fixed-size state stack. - // - c.context ().set ("depth", depth + 1); - } - } - }; - } - - void StateProcessor:: - process (SemanticGraph::Schema& tu, SemanticGraph::Path const&) - { - Traversal::Schema schema; - Sources sources; - Traversal::Names schema_names; - Traversal::Namespace ns; - Traversal::Names ns_names; - - schema >> sources >> schema; - schema >> schema_names >> ns >> ns_names; - - Complex complex_type; - - ns_names >> complex_type; - - schema.dispatch (tu); - } - } -} diff --git a/xsd/cxx/parser/state-processor.hxx b/xsd/cxx/parser/state-processor.hxx deleted file mode 100644 index e5559b4..0000000 --- a/xsd/cxx/parser/state-processor.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : xsd/cxx/parser/state-processor.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_PARSER_STATE_PROCESSOR_HXX -#define CXX_PARSER_STATE_PROCESSOR_HXX - -#include - -#include - -namespace CXX -{ - namespace Parser - { - class StateProcessor - { - public: - void - process (XSDFrontend::SemanticGraph::Schema&, - XSDFrontend::SemanticGraph::Path const& file); - }; - } -} - -#endif // CXX_PARSER_STATE_PROCESSOR_HXX diff --git a/xsd/cxx/parser/type-processor.cxx b/xsd/cxx/parser/type-processor.cxx deleted file mode 100644 index d1b2e68..0000000 --- a/xsd/cxx/parser/type-processor.cxx +++ /dev/null @@ -1,347 +0,0 @@ -// file : xsd/cxx/parser/type-processor.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include -#include - -#include -#include - -using namespace std; - -namespace CXX -{ - namespace Parser - { - namespace - { - // - // - struct Type: Traversal::Type - { - Type (SemanticGraph::Schema& schema, - TypeMap::Namespaces& type_map, - bool add_includes) - : schema_ (schema), - type_map_ (type_map), - add_includes_ (add_includes) - { - } - - virtual void - traverse (SemanticGraph::Type& type) - { - using TypeMap::Namespace; - using TypeMap::Namespaces; - - SemanticGraph::Context& tc (type.context ()); - - // There are two situations where we may try to process the - // same type more than once. The first is when the type is - // used in several element declarations in the same schema. - // The second situation only occurs when we are in the file- - // per-type mode. In this case the type was processed as part - // of another root schema. In the second case, while the ret - // and arg types are assumed to be the same, we need to re- - // match the type in order to add include directives to the - // new root schema. - // - bool set (true); - - if (tc.count ("ret-type")) - { - SemanticGraph::Schema* s ( - tc.get ("root-schema")); - - if (&schema_ == s) - return; - - set = false; - } - - SemanticGraph::Namespace& ns ( - dynamic_cast (type.scope ())); - - String ns_name (ns.name ()); - String t_name (type.name ()); - - //std::wcerr << "traversing: " << ns_name << "#" << t_name << endl; - - for (Namespaces::const_iterator n (type_map_.begin ()); - n != type_map_.end (); ++n) - { - // Check if the namespace matches. - // - bool ns_match; - - if (!n->xsd_name ().empty ()) - { - ns_match = n->xsd_name ().match (ns_name); - } - else - ns_match = ns_name.empty (); - - //std::wcerr << "considering ns expr: " << n->xsd_name () - // << " for " << ns_name - // << ": " << (ns_match ? "+" : "-") << endl; - - if (ns_match) - { - // Namespace matched. See if there is a type that matches. - // - for (Namespace::TypesIterator t (n->types_begin ()); - t != n->types_end (); ++t) - { - if (t->xsd_name ().match (t_name)) - { - if (set) - { - // Got a match. See if the namespace has the C++ - // namespace mapping. - // - String cxx_ns; - - if (n->has_cxx_name ()) - { - if (!n->xsd_name ().empty ()) - { - cxx_ns = n->xsd_name ().replace ( - ns_name, n->cxx_name (), true); - } - else - cxx_ns = n->cxx_name (); - - cxx_ns += L"::"; - } - - // Figure out ret and arg type names. - // - String ret_type (cxx_ns); - - ret_type += t->xsd_name ().replace ( - t_name, t->cxx_ret_name (), true); - - String arg_type; - - if (t->cxx_arg_name ()) - { - arg_type = cxx_ns; - arg_type += t->xsd_name ().replace ( - t_name, t->cxx_arg_name (), true); - } - else - { - if (ret_type == L"void") - arg_type = ret_type; - else - { - wchar_t last (ret_type[ret_type.size () - 1]); - - // If it is already a pointer or reference then use - // it as is. - // - if (last == L'*' || last == L'&') - arg_type = ret_type; - else - arg_type = L"const " + ret_type + L"&"; - } - } - - tc.set ("ret-type", ret_type); - tc.set ("arg-type", arg_type); - - //std::wcerr << t_name << " -> " << ret_type << endl; - } - - tc.set ("root-schema", &schema_); - - // See of we need to add any includes to the translations - // unit. - // - if (add_includes_) - { - if (n->includes_begin () != n->includes_end ()) - { - typedef std::set Includes; - - if (!schema_.context ().count ("includes")) - schema_.context ().set ("includes", Includes ()); - - Includes& is ( - schema_.context ().get ("includes")); - - for (Namespace::IncludesIterator i (n->includes_begin ()); - i != n->includes_end (); ++i) - { - is.insert (*i); - } - } - } - - return; - } - } - } - } - } - - private: - SemanticGraph::Schema& schema_; - TypeMap::Namespaces& type_map_; - bool add_includes_; - }; - - - // - // - struct GlobalType: Traversal::Type, - Traversal::List, - Traversal::Complex, - Traversal::Enumeration - { - GlobalType (SemanticGraph::Schema& schema, - TypeMap::Namespaces& type_map, - bool add_includes) - : type_ (schema, type_map, add_includes) - { - inherits_ >> type_; - names_ >> instance_ >> belongs_ >> type_; - argumented_ >> type_; - } - - virtual void - traverse (SemanticGraph::Type& t) - { - type_.traverse (t); - } - - virtual void - traverse (SemanticGraph::List& l) - { - type_.traverse (l); - Traversal::List::argumented (l, argumented_); - } - - virtual void - traverse (SemanticGraph::Complex& c) - { - type_.traverse (c); - Complex::inherits (c, inherits_); - Complex::names (c, names_); - } - - virtual void - traverse (SemanticGraph::Enumeration& e) - { - type_.traverse (e); - Complex::inherits (e, inherits_); - } - - private: - Parser::Type type_; - Traversal::Names names_; - Traversal::Instance instance_; - Traversal::Inherits inherits_; - Traversal::Belongs belongs_; - Traversal::Argumented argumented_; - }; - - void - process_impl (options const& ops, - XSDFrontend::SemanticGraph::Schema& tu, - bool gen_driver, - TypeMap::Namespaces& type_map) - { - if (tu.names_begin ()->named ().name () == - L"http://www.w3.org/2001/XMLSchema") - { - // XML Schema namespace. - // - Traversal::Schema schema; - - Traversal::Names schema_names; - Traversal::Namespace ns; - Traversal::Names ns_names; - GlobalType global_type (tu, type_map, true); - - schema >> schema_names >> ns >> ns_names >> global_type; - - schema.dispatch (tu); - } - else - { - // If --extern-xml-schema is specified, then we don't want - // includes from the XML Schema type map. - // - bool extern_xml_schema (ops.extern_xml_schema ()); - - // - // - Traversal::Schema schema; - Traversal::Schema xs_schema; - Sources sources; - Traversal::Implies implies; - - schema >> sources >> schema; - schema >> implies >> xs_schema; - - Traversal::Names schema_names; - Traversal::Namespace ns; - Traversal::Names ns_names; - GlobalType global_type (tu, type_map, true); - - schema >> schema_names >> ns >> ns_names >> global_type; - - Traversal::Names xs_schema_names; - Traversal::Namespace xs_ns; - Traversal::Names xs_ns_names; - GlobalType xs_global_type (tu, type_map, !extern_xml_schema); - - xs_schema >> xs_schema_names >> xs_ns >> xs_ns_names >> - xs_global_type; - - schema.dispatch (tu); - - // If we are generating the test driver, make sure the root - // element type is processed. - // - if (gen_driver && ops.generate_test_driver ()) - { - // Figure out the root element. Validator should have made sure - // it is unique. - // - SemanticGraph::Element* root (0); - { - Traversal::Schema schema; - Sources sources; - - schema >> sources >> schema; - - Traversal::Names schema_names; - Traversal::Namespace ns; - Traversal::Names ns_names; - RootElement root_element (ops, root); - - schema >> schema_names >> ns >> ns_names >> root_element; - - schema.dispatch (tu); - } - - global_type.dispatch (root->type ()); - } - } - } - } - - void TypeProcessor:: - process (options const& ops, - XSDFrontend::SemanticGraph::Schema& s, - bool gen_driver, - TypeMap::Namespaces& tm) - { - process_impl (ops, s, gen_driver, tm); - } - } -} diff --git a/xsd/cxx/parser/type-processor.hxx b/xsd/cxx/parser/type-processor.hxx deleted file mode 100644 index 53fd970..0000000 --- a/xsd/cxx/parser/type-processor.hxx +++ /dev/null @@ -1,31 +0,0 @@ -// file : xsd/cxx/parser/type-processor.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_PARSER_TYPE_PROCESSOR_HXX -#define CXX_PARSER_TYPE_PROCESSOR_HXX - -#include - -#include - -#include - -#include - -namespace CXX -{ - namespace Parser - { - class TypeProcessor - { - public: - void - process (options const&, - XSDFrontend::SemanticGraph::Schema&, - bool gen_driver, - TypeMap::Namespaces&); - }; - } -} - -#endif // CXX_PARSER_TYPE_PROCESSOR_HXX diff --git a/xsd/cxx/parser/validator.cxx b/xsd/cxx/parser/validator.cxx deleted file mode 100644 index 6bf5b48..0000000 --- a/xsd/cxx/parser/validator.cxx +++ /dev/null @@ -1,718 +0,0 @@ -// file : xsd/cxx/parser/validator.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include -#include - -#include - -#include -#include - -#include - -using namespace std; - -namespace CXX -{ - namespace Parser - { - namespace - { - class ValidationContext: public Context - { - public: - ValidationContext (SemanticGraph::Schema& root, - SemanticGraph::Path const& path, - Parser::options const& ops, - const WarningSet& disabled_warnings, - bool& valid_) - : Context (std::wcerr, root, path, ops, 0, 0, 0, 0), - disabled_warnings_ (disabled_warnings), - disabled_warnings_all_ (false), - valid (valid_), - subst_group_warning_issued (subst_group_warning_issued_), - subst_group_warning_issued_ (false) - { - } - - public: - bool - is_disabled (char const* w) - { - return disabled_warnings_all_ || - disabled_warnings_.find (w) != disabled_warnings_.end (); - } - - public: - String - xpath (SemanticGraph::Nameable& n) - { - if (n.is_a ()) - return L""; // There is a bug if you see this. - - assert (n.named_p ()); - - SemanticGraph::Scope& scope (n.scope ()); - - if (scope.is_a ()) - return n.name (); - - return xpath (scope) + L"/" + n.name (); - } - - protected: - ValidationContext (ValidationContext& c) - : Context (c), - disabled_warnings_ (c.disabled_warnings_), - disabled_warnings_all_ (c.disabled_warnings_all_), - valid (c.valid), - subst_group_warning_issued (c.subst_group_warning_issued) - { - } - - protected: - const WarningSet& disabled_warnings_; - bool disabled_warnings_all_; - bool& valid; - bool& subst_group_warning_issued; - bool subst_group_warning_issued_; - }; - - // - // - struct Any: Traversal::Any, ValidationContext - { - Any (ValidationContext& c) - : ValidationContext (c) - { - } - - struct Element: Traversal::Element, ValidationContext - { - Element (ValidationContext& c, SemanticGraph::Any& any) - : ValidationContext (c), - any_ (any), - ns_ (any.definition_namespace ().name ()) - { - } - - virtual void - traverse (SemanticGraph::Element& e) - { - if (skip (e)) return; - - using SemanticGraph::Any; - - bool q (e.qualified_p ()); - String ns (q ? e.namespace_ ().name () : ""); - - for (Any::NamespaceIterator i (any_.namespace_begin ()); - i != any_.namespace_end (); ++i) - { - bool failed (false); - - if (*i == L"##any") - { - failed = true; - } - else if (*i == L"##other") - { - if (ns_) - { - // Note that here I assume that ##other does not - // include names without target namespace. This - // is not what the spec says but that seems to be - // the consensus. - // - failed = q && ns != ns_; - } - else - { - // No target namespace. - // - failed = q && ns != L""; - } - } - else if (*i == L"##local") - { - failed = !q || ns == L""; - } - else if (*i == L"##targetNamespace") - { - failed = (q && ns_ == ns) || (!q && ns_ == L""); - } - else - { - failed = q && *i == ns; - } - - if (failed) - { - Any& a (any_); - - os << a.file () << ":" << a.line () << ":" << a.column () - << ": warning P001: namespace '" << *i << "' allows for " - << "element '" << e.name () << "'" << endl; - - os << a.file () << ":" << a.line () << ":" << a.column () - << ": warning P001: generated code may not associate element '" - << e.name () << "' correctly if it appears in place of " - << "this wildcard" << endl; - - os << e.file () << ":" << e.line () << ":" << e.column () - << ": info: element '" << e.name () << "' is defined " - << "here" << endl; - - os << a.file () << ":" << a.line () << ":" << a.column () - << ": info: turn on validation to ensure correct " - << "association" << endl; - } - } - } - - private: - SemanticGraph::Any& any_; - String ns_; - }; - - struct Complex: Traversal::Complex - { - Complex () - : up_ (true), down_ (true) - { - } - - virtual void - post (Type& c) - { - // Go down the inheritance hierarchy. - // - if (down_) - { - bool up = up_; - up_ = false; - - if (c.inherits_p ()) - dispatch (c.inherits ().base ()); - - up_ = up; - } - - // Go up the inheritance hierarchy. - // - if (up_) - { - bool down = down_; - down_ = false; - - for (Type::BegetsIterator i (c.begets_begin ()); - i != c.begets_end (); ++i) - { - dispatch (i->derived ()); - } - - down_ = down; - } - } - - private: - bool up_, down_; - }; - - virtual void - traverse (SemanticGraph::Any& a) - { - using SemanticGraph::Compositor; - - // Find our complex type. - // - Compositor* c (&a.contained_particle ().compositor ()); - - while(!c->contained_compositor_p ()) - c = &c->contained_particle ().compositor (); - - SemanticGraph::Complex& type ( - dynamic_cast ( - c->contained_compositor ().container ())); - - Complex complex; - Traversal::Names names; - Element element (*this, a); - - complex >> names >> element; - - complex.dispatch (type); - } - }; - - - // - // - struct Traverser: Traversal::Schema, - Traversal::Complex, - Traversal::Type, - Traversal::Element, - ValidationContext - { - Traverser (ValidationContext& c) - : ValidationContext (c), - any_ (c) - { - *this >> sources_ >> *this; - *this >> schema_names_ >> ns_ >> names_ >> *this; - - // Any - // - if (!validation && !is_disabled ("P001")) - { - *this >> contains_compositor_ >> compositor_ >> contains_particle_; - contains_particle_ >> compositor_; - contains_particle_ >> any_; - } - } - - virtual void - traverse (SemanticGraph::Complex& c) - { - using SemanticGraph::Schema; - - traverse (static_cast (c)); - - if (c.inherits_p ()) - { - SemanticGraph::Type& t (c.inherits ().base ()); - - if (t.named_p () && - types_.find ( - t.scope ().name () + L"#" + t.name ()) == types_.end ()) - { - // Don't worry about types that are in included/imported - // schemas. - // - Schema& s (dynamic_cast (t.scope ().scope ())); - - if (&s == &schema_root || sources_p (schema_root, s)) - { - valid = false; - - wcerr << c.file () << ":" << c.line () << ":" << c.column () - << ": error: type '" << xpath (c) << "' inherits from " - << "yet undefined type '" << xpath (t) << "'" << endl; - - wcerr << t.file () << ":" << t.line () << ":" << t.column () - << ": info: '" << xpath (t) << "' is defined here" - << endl; - - wcerr << c.file () << ":" << c.line () << ":" << c.column () - << ": info: inheritance from a yet-undefined type is " - << "not supported" << endl; - - wcerr << c.file () << ":" << c.line () << ":" << c.column () - << ": info: re-arrange your schema and try again" - << endl; - } - } - } - - Complex::traverse (c); - } - - virtual void - traverse (SemanticGraph::Type& t) - { - if (t.named_p ()) - { - types_.insert (t.scope ().name () + L"#" + t.name ()); - } - } - - virtual void - traverse (SemanticGraph::Element& e) - { - if (is_disabled ("P002")) - return; - - if (e.substitutes_p () && - !options.generate_polymorphic () && - !subst_group_warning_issued) - { - subst_group_warning_issued = true; - - os << e.file () << ":" << e.line () << ":" << e.column () - << ": warning P002: substitution groups are used but " - << "--generate-polymorphic was not specified" << endl; - - os << e.file () << ":" << e.line () << ":" << e.column () - << ": info: generated code may not be able to parse " - << "some conforming instances" << endl; - } - } - - // Return true if root sources s. - // - bool - sources_p (SemanticGraph::Schema& root, SemanticGraph::Schema& s) - { - using SemanticGraph::Schema; - using SemanticGraph::Sources; - - for (Schema::UsesIterator i (root.uses_begin ()); - i != root.uses_end (); ++i) - { - if (i->is_a ()) - { - if (&i->schema () == &s || sources_p (i->schema (), s)) - return true; - } - } - - return false; - } - - private: - set types_; - - Sources sources_; - - Traversal::Names schema_names_; - Traversal::Namespace ns_; - - Traversal::Names names_; - - // Any. - // - Any any_; - Traversal::Compositor compositor_; - Traversal::ContainsParticle contains_particle_; - Traversal::ContainsCompositor contains_compositor_; - }; - - - struct AnonymousType: Traversal::Schema, - Traversal::Complex, - Traversal::Element, - Traversal::Attribute, - ValidationContext - { - AnonymousType (ValidationContext& c) - : ValidationContext (c), - anonymous_error_issued_ (false) - { - *this >> sources_ >> *this; - *this >> schema_names_ >> ns_ >> names_ >> *this; - *this >> names_; - } - - bool - traverse_common (SemanticGraph::Member& m) - { - SemanticGraph::Type& t (m.type ()); - - if (!t.named_p () - && !t.is_a () - && !t.is_a ()) - { - if (!anonymous_error_issued_) - { - valid = false; - anonymous_error_issued_ = true; - - wcerr << t.file () - << ": error: anonymous types detected" - << endl; - - wcerr << t.file () - << ": info: " - << "anonymous types are not supported in this mapping" - << endl; - - wcerr << t.file () - << ": info: consider explicitly naming these types or " - << "remove the --preserve-anonymous option to " - << "automatically name them" - << endl; - - if (!options.show_anonymous ()) - wcerr << t.file () - << ": info: use --show-anonymous option to see these " - << "types" << endl; - } - - return true; - } - - return false; - } - - virtual void - traverse (SemanticGraph::Element& e) - { - if (skip (e)) return; - - if (traverse_common (e)) - { - if (options.show_anonymous ()) - { - wcerr << e.file () << ":" << e.line () << ":" << e.column () - << ": error: element '" << xpath (e) << "' " - << "is of anonymous type" << endl; - } - } - else - Traversal::Element::traverse (e); - } - - virtual void - traverse (SemanticGraph::Attribute& a) - { - if (traverse_common (a)) - { - if (options.show_anonymous ()) - { - wcerr << a.file () << ":" << a.line () << ":" << a.column () - << ": error: attribute '" << xpath (a) << "' " - << "is of anonymous type" << endl; - } - } - else - Traversal::Attribute::traverse (a); - } - - private: - bool anonymous_error_issued_; - - set types_; - - Sources sources_; - - Traversal::Names schema_names_; - Traversal::Namespace ns_; - - Traversal::Names names_; - }; - - struct GlobalElement: Traversal::Element, ValidationContext - { - GlobalElement (ValidationContext& c, SemanticGraph::Element*& element) - : ValidationContext (c), element_ (element) - { - } - - virtual void - traverse (Type& e) - { - if (!valid) - return; - - if (options.root_element_first ()) - { - if (element_ == 0) - element_ = &e; - } - else if (options.root_element_last ()) - { - element_ = &e; - } - else if (String name = options.root_element ()) - { - if (e.name () == name) - element_ = &e; - } - else - { - if (element_ == 0) - element_ = &e; - else - { - wcerr << schema_root.file () << ": error: unable to generate " - << "the test driver without a unique document root" - << endl; - - wcerr << schema_root.file () << ": info: use --root-element-* " - << "options to specify the document root" << endl; - - valid = false; - } - } - } - - private: - SemanticGraph::Element*& element_; - }; - - } - - bool Validator:: - validate (options const& ops, - SemanticGraph::Schema& root, - SemanticGraph::Path const& path, - bool gen_driver, - const WarningSet& disabled_warnings) - { - bool valid (true); - ValidationContext ctx (root, path, ops, disabled_warnings, valid); - - // - // - if (ops.char_type () != "char" && - ops.char_type () != "wchar_t" && - !ctx.is_disabled ("P003")) - { - wcerr << "warning P003: unknown base character type '" << - ops.char_type ().c_str () << "'" << endl; - } - - // - // - if (ops.xml_parser () != "xerces" && - ops.xml_parser () != "expat" && - !ctx.is_disabled ("P004")) - { - wcerr << "warning P004: unknown underlying XML parser '" << - ops.xml_parser ().c_str () << "'" << endl; - } - - // - // - if (ops.xml_parser () == "expat" && - ops.char_type () == "wchar_t") - { - wcerr << "error: using expat with wchar_t is not supported" - << endl; - - return false; - } - - // - // - if (ops.xml_parser () == "expat" && - !ops.char_encoding ().empty () && - ops.char_encoding () != "utf8") - { - wcerr << "error: using expat with character encoding other than " - << "utf8 is not supported" - << endl; - - return false; - } - - // - // - if (ops.generate_validation () && ops.suppress_validation ()) - { - wcerr << "error: mutually exclusive options specified: " - << "--generate-validation and --suppress-validation" - << endl; - - return false; - } - - // - // - if (ops.generate_noop_impl () && ops.generate_print_impl ()) - { - wcerr << "error: mutually exclusive options specified: " - << "--generate-noop-impl and --generate-print-impl" - << endl; - - return false; - } - - // - // - { - bool ref (ops.root_element_first ()); - bool rel (ops.root_element_last ()); - bool re (ops.root_element ()); - - if ((ref && rel) || (ref && re) || (rel && re)) - { - wcerr << "error: mutually exclusive options specified: " - << "--root-element-last, --root-element-first, and " - << "--root-element" - << endl; - - return false; - } - } - - // - // - bool import_maps (ops.import_maps ()); - bool export_maps (ops.export_maps ()); - - if (import_maps && export_maps) - { - wcerr << "error: --import-maps and --export-maps are " - << "mutually exclusive" << endl; - - return false; - } - - if (import_maps && !ctx.polymorphic) - { - wcerr << "error: --import-maps can only be specified together with " - << "--generate-polymorphic" << endl; - - return false; - } - - if (export_maps && !ctx.polymorphic) - { - wcerr << "error: --export-maps can only be specified together with " - << "--generate-polymorphic" << endl; - - return false; - } - - // Test for anonymout types. - // - { - AnonymousType traverser (ctx); - traverser.dispatch (root); - } - - - // Test the rest. - // - if (valid) - { - Traverser traverser (ctx); - traverser.dispatch (root); - } - - // Test that the document root is unique. - // - if (valid && gen_driver) - { - SemanticGraph::Element* element (0); - - Traversal::Schema schema; - Sources sources; - - schema >> sources >> schema; - - Traversal::Names schema_names; - Traversal::Namespace ns; - Traversal::Names ns_names; - GlobalElement global_element (ctx, element); - - schema >> schema_names >> ns >> ns_names >> global_element; - - schema.dispatch (root); - - if (valid && element == 0) - { - wcerr << root.file () << ": error: unable to generate the " - << "test driver without a global element (document root)" - << endl; - - valid = false; - } - } - - return valid; - } - } -} diff --git a/xsd/cxx/parser/validator.hxx b/xsd/cxx/parser/validator.hxx deleted file mode 100644 index 5f10526..0000000 --- a/xsd/cxx/parser/validator.hxx +++ /dev/null @@ -1,30 +0,0 @@ -// file : xsd/cxx/parser/validator.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_PARSER_VALIDATOR_HXX -#define CXX_PARSER_VALIDATOR_HXX - -#include -#include - -#include -#include - -namespace CXX -{ - namespace Parser - { - class Validator - { - public: - bool - validate (options const&, - SemanticGraph::Schema&, - SemanticGraph::Path const& tu, - bool gen_driver, - const WarningSet& disabled_warnings); - }; - } -} - -#endif // CXX_PARSER_VALIDATOR_HXX diff --git a/xsd/cxx/tree/counter.cxx b/xsd/cxx/tree/counter.cxx deleted file mode 100644 index a5bdbb3..0000000 --- a/xsd/cxx/tree/counter.cxx +++ /dev/null @@ -1,260 +0,0 @@ -// file : xsd/cxx/tree/counter.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include - -namespace CXX -{ - namespace Tree - { - namespace - { - struct Member: Traversal::Member - { - Member (size_t& complexity) - : complexity_ (complexity) - { - } - - virtual void - traverse (Type&) - { - complexity_++; - } - - size_t& complexity_; - }; - - struct Any: Traversal::Any, Traversal::AnyAttribute - { - Any (size_t& complexity) - : complexity_ (complexity) - { - } - - virtual void - traverse (SemanticGraph::Any&) - { - complexity_++; - } - - virtual void - traverse (SemanticGraph::AnyAttribute&) - { - complexity_++; - } - - size_t& complexity_; - }; - - struct TypeBase: Traversal::List, - Traversal::Union, - Traversal::Enumeration, - Traversal::Complex, - Context - { - TypeBase (Context& c, size_t& complexity) - : Context (c), complexity_ (complexity) - { - } - - virtual void - traverse (SemanticGraph::List&) - { - complexity_++; - } - - virtual void - traverse (SemanticGraph::Union&) - { - complexity_++; - } - - virtual void - traverse (SemanticGraph::Enumeration& e) - { - bool string_based (false); - { - IsStringBasedType t (string_based); - t.dispatch (e); - } - - complexity_ += (string_based ? 1 : 2); - } - - virtual void - traverse (SemanticGraph::Complex& c) - { - complexity_++; // One for the type itself. - - // Plus some for each member. - // - Any any (complexity_); - Member member (complexity_); - Traversal::Names names; - - names >> member; - - if (options.generate_wildcard ()) - names >> any; - - Complex::names (c, names); - } - - private: - size_t& complexity_; - }; - - - // - // - struct GlobalType: Traversal::Type, Context - - { - GlobalType (Context& c, Counts& counts) - : Context (c), counts_ (counts) - { - } - - virtual void - traverse (SemanticGraph::Type& t) - { - counts_.global_types++; - - size_t complexity (0); - TypeBase type (*this, complexity); - type.dispatch (t); - - counts_.complexity_total += complexity; - counts_.complexity.push_back (complexity); - } - - private: - Counts& counts_; - }; - - // - // - struct GlobalElement: Traversal::Element, - GlobalElementBase, - Context - { - GlobalElement (Context& c, Counts& counts) - : GlobalElementBase (c), - Context (c), - counts_ (counts), - last_ (0) - { - } - - ~GlobalElement () - { - if (last_ != 0) - { - last_->context ().set ("last", true); - count_last (); - } - } - - virtual void - traverse (Type& e) - { - // Check if the previous element we saw needs to be generated. - // - if (last_ != 0) - count_last (); - - last_ = &e; - - if (counts_.global_elements == 0) - e.context ().set ("first", true); - - counts_.global_elements++; - } - - private: - void - count_last () - { - if (generate_p (*last_)) - { - counts_.generated_global_elements++; - - size_t complexity (0); - - if (doc_root_p (*last_)) - { - if (options.generate_element_type ()) - { - complexity += 1; // For c-tors and d-tor. - - if (!options.suppress_parsing ()) - complexity += 1; - - if (options.generate_serialization ()) - complexity += 1; - } - else - { - if (!options.suppress_parsing ()) - complexity += 6; // 13 parsing functions. - - if (options.generate_serialization ()) - complexity += 4; // 8 serialization functions. - } - } - - if (complexity == 0) - { - // This element must be a substitution group members. For - // such elements we are only generating an entry in a map. - // We will assign it a complexity of 1 so that we don't - // end up with the total complexity that is less than the - // number of elements and types. - // - complexity = 1; - } - - counts_.complexity_total += complexity; - counts_.complexity.push_back (complexity); - } - } - - private: - Counts& counts_; - SemanticGraph::Element* last_; - }; - } - - Counts Counter:: - count (options const& ops, - SemanticGraph::Schema& tu, - SemanticGraph::Path const& path) - { - Counts counts; - Context ctx (std::wcerr, tu, path, ops, counts, false, 0, 0, 0, 0); - - Traversal::Schema schema; - Sources sources; - - schema >> sources >> schema; - - Traversal::Names schema_names; - Traversal::Namespace ns; - Traversal::Names ns_names; - GlobalType global_type (ctx, counts); - GlobalElement global_element (ctx, counts); - - schema >> schema_names >> ns >> ns_names; - - ns_names >> global_element; - ns_names >> global_type; - - schema.dispatch (tu); - - return counts; - } - } -} diff --git a/xsd/cxx/tree/counter.hxx b/xsd/cxx/tree/counter.hxx deleted file mode 100644 index 28dccf2..0000000 --- a/xsd/cxx/tree/counter.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : xsd/cxx/tree/counter.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_TREE_COUNTER_HXX -#define CXX_TREE_COUNTER_HXX - -#include -#include - -namespace CXX -{ - namespace Tree - { - class Counter - { - public: - Counts - count (options const&, - SemanticGraph::Schema&, - SemanticGraph::Path const&); - }; - } -} - -#endif // CXX_TREE_COUNTER_HXX diff --git a/xsd/cxx/tree/default-value.cxx b/xsd/cxx/tree/default-value.cxx deleted file mode 100644 index 24ec454..0000000 --- a/xsd/cxx/tree/default-value.cxx +++ /dev/null @@ -1,1273 +0,0 @@ -// file : xsd/cxx/tree/default-value.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -using std::hex; -using std::dec; - -namespace CXX -{ - namespace Tree - { - namespace - { - void - normalize (String& s) - { - size_t n (s.size ()); - - for (size_t i (0); i < n; ++i) - { - wchar_t& c (s[i]); - - if (c == 0x0D || // carriage return - c == 0x09 || // tab - c == 0x0A) - c = 0x20; - } - } - - void - collapse (String& s) - { - size_t n (s.size ()), j (0); - bool subs (false), trim (true); - - for (size_t i (0); i < n; ++i) - { - wchar_t c (s[i]); - - if (c == 0x20 || c == 0x09 || c == 0x0A) - subs = true; - else - { - if (subs) - { - subs = false; - - if (!trim) - s[j++] = 0x20; - } - - if (trim) - trim = false; - - s[j++] = c; - } - } - - s.resize (j); - } - - void - strip_zeros (String& s) - { - size_t n (s.size ()), i (0); - - if (n > 0 && (s[i] == '-' || s[i] == '+')) - i++; - - size_t j (i); - - bool strip (true); - - for (; i < n; ++i) - { - wchar_t c (s[i]); - - if (c == '0') - { - if (!strip) - s[j++] = c; - } - else - { - s[j++] = c; - - if (strip) - strip = false; - } - } - - if (strip && j < n) - s[j++] = '0'; // There was nothing except zeros so add one back. - - s.resize (j); - } - - void - make_float (String& s) - { - if (s.find ('.') == String::npos && - s.find ('e') == String::npos && - s.find ('E') == String::npos) - s += L".0"; - } - } - - // - // IsLiteralValue - // - - IsLiteralValue:: - IsLiteralValue (bool& r) - : IsFundamentalType (r) - { - *this >> inherits_ >> *this; - } - - void IsLiteralValue:: - traverse (SemanticGraph::Complex& c) - { - inherits (c); - } - - // - // LiteralValue - // - - LiteralValue:: - LiteralValue (Context& c) - : Context (c) - { - *this >> inherits_ >> *this; - } - - String LiteralValue:: - dispatch (SemanticGraph::Node& type, String const& value) - { - literal_.clear (); - value_ = value; - Traversal::NodeBase::dispatch (type); - return literal_; - } - - void LiteralValue:: - traverse (SemanticGraph::Complex& c) - { - inherits (c); - } - - // Boolean. - // - void LiteralValue:: - traverse (SemanticGraph::Fundamental::Boolean&) - { - collapse (value_); - literal_ = (value_ == L"true" || value_ == L"1") ? L"true" : L"false"; - } - - // Integral types. - // - void LiteralValue:: - traverse (SemanticGraph::Fundamental::Byte&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_; - } - - void LiteralValue:: - traverse (SemanticGraph::Fundamental::UnsignedByte&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_ + L"U"; - } - - void LiteralValue:: - traverse (SemanticGraph::Fundamental::Short&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_; - } - - void LiteralValue:: - traverse (SemanticGraph::Fundamental::UnsignedShort&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_ + L"U"; - } - - void LiteralValue:: - traverse (SemanticGraph::Fundamental::Int&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_; - } - - void LiteralValue:: - traverse (SemanticGraph::Fundamental::UnsignedInt&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_ + L"U"; - } - - void LiteralValue:: - traverse (SemanticGraph::Fundamental::Long&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_; - literal_ += L"LL"; - } - - void LiteralValue:: - traverse (SemanticGraph::Fundamental::UnsignedLong&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_; - literal_ += L"ULL"; - } - - void LiteralValue:: - traverse (SemanticGraph::Fundamental::Integer&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_ + L"LL"; - } - - void LiteralValue:: - traverse (SemanticGraph::Fundamental::NonPositiveInteger&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_ + L"LL"; - } - - void LiteralValue:: - traverse (SemanticGraph::Fundamental::NonNegativeInteger&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_ + L"ULL"; - } - - void LiteralValue:: - traverse (SemanticGraph::Fundamental::PositiveInteger&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_ + L"ULL"; - } - - void LiteralValue:: - traverse (SemanticGraph::Fundamental::NegativeInteger&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_ + L"LL"; - } - - // Floats. - // - void LiteralValue:: - traverse (SemanticGraph::Fundamental::Float& t) - { - collapse (value_); - - if (value_ == L"NaN") - { - literal_ = L"::std::numeric_limits< " + fq_name (t) + - L" >::quiet_NaN ()"; - } - else if (value_ == L"INF") - { - literal_ = L"::std::numeric_limits< " + fq_name (t) + - L" >::infinity ()"; - } - else if (value_ == L"-INF") - { - literal_ = L"- ::std::numeric_limits< " + fq_name (t) + - L" >::infinity ()"; - } - else - { - strip_zeros (value_); - make_float (value_); - literal_ = value_ + L"F"; - } - } - - void LiteralValue:: - traverse (SemanticGraph::Fundamental::Double& t) - { - collapse (value_); - - if (value_ == L"NaN") - { - literal_ = L"::std::numeric_limits< " + fq_name (t) + - L" >::quiet_NaN ()"; - } - else if (value_ == L"INF") - { - literal_ = L"::std::numeric_limits< " + fq_name (t) + - L" >::infinity ()"; - } - else if (value_ == L"-INF") - { - literal_ = L"- ::std::numeric_limits< " + fq_name (t) + - L" >::infinity ()"; - } - else - { - strip_zeros (value_); - make_float (value_); - literal_ = value_; - } - } - - void LiteralValue:: - traverse (SemanticGraph::Fundamental::Decimal&) - { - collapse (value_); - strip_zeros (value_); - make_float (value_); - literal_ = value_; - } - - // - // InitKind - // - - InitKind:: - InitKind (Kind& r) - : r_ (r) - { - *this >> inherits_ >> *this; - } - - void InitKind:: - traverse (SemanticGraph::List&) - { - r_ = function; - } - - void InitKind:: - traverse (SemanticGraph::Complex& c) - { - inherits (c); - } - - void InitKind:: - traverse (SemanticGraph::Fundamental::Base64Binary&) - { - r_ = data; - } - - void InitKind:: - traverse (SemanticGraph::Fundamental::HexBinary&) - { - r_ = data; - } - - void InitKind:: - traverse (SemanticGraph::Fundamental::NameTokens&) - { - r_ = function; - } - - void InitKind:: - traverse (SemanticGraph::Fundamental::IdRefs&) - { - r_ = function; - } - - void InitKind:: - traverse (SemanticGraph::Fundamental::Entities&) - { - r_ = function; - } - - // - // InitValue - // - - InitValue:: - InitValue (Context& c) - : Context (c), type_name_ (c), literal_value_ (c) - { - } - - void InitValue:: - dispatch (SemanticGraph::Node& type, String const& value) - { - value_ = value; - Traversal::NodeBase::dispatch (type); - } - - void InitValue:: - traverse (SemanticGraph::List& l) - { - collapse (value_); - - if (!value_) - return; - - SemanticGraph::Type& t (l.argumented ().type ()); - - String ov (value_); - size_t b (0); - - for (size_t e (ov.find (' ')); ; e = ov.find (' ', b)) - { - String v (ov, b, e != String::npos ? e - b : e); - - os << "{"; - type_name_.dispatch (t); - os << " tmp ("; - - String lit (literal_value_.dispatch (t, v)); - - if (lit) - os << lit; - else - { - value_ = v; - Traversal::NodeBase::dispatch (t); - } - - os << ");" - << "r.push_back (tmp);" - << "}"; - - if (e == String::npos) - break; - - b = e + 1; - } - - value_ = ov; - } - - void InitValue:: - traverse (SemanticGraph::Union&) - { - os << strlit (value_); - } - - void InitValue:: - traverse (SemanticGraph::Complex& c) - { - Traversal::NodeBase::dispatch (ultimate_base (c)); - } - - // anyType & anySimpleType. - // - void InitValue:: - traverse (SemanticGraph::AnyType& t) - { - os << fq_name (t) << " (" << strlit (value_) << ")"; - } - - void InitValue:: - traverse (SemanticGraph::AnySimpleType& t) - { - os << fq_name (t) << " (" << strlit (value_) << ")"; - } - - // Strings. - // - void InitValue:: - traverse (SemanticGraph::Fundamental::String&) - { - os << strlit (value_); - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::NormalizedString&) - { - normalize (value_); - os << strlit (value_); - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::Token&) - { - collapse (value_); - os << strlit (value_); - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::NameToken&) - { - collapse (value_); - os << strlit (value_); - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::NameTokens&) - { - string_sequence_type ( - dynamic_cast ( - xs_ns ().find ("NMTOKEN").first->named ())); - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::Name&) - { - collapse (value_); - os << strlit (value_); - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::NCName&) - { - collapse (value_); - os << strlit (value_); - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::Language&) - { - collapse (value_); - os << strlit (value_); - } - - // Qualified name. - // - void InitValue:: - traverse (SemanticGraph::Fundamental::QName& t) - { - size_t p (value_.rfind ('#')); - - if (p != String::npos) - { - String ns (value_, 0, p); - String qname (value_, p + 1, String::npos); - - collapse (ns); - collapse (qname); - - p = qname.find (':'); - - String name; - if (p != String::npos) - name.assign (qname, p + 1, String::npos); - else - name = qname; - - os << fq_name (t) << " (" << strlit (ns) << ", " << - strlit (name) << ")"; - } - else - { - // Unqualified name. - // - collapse (value_); - os << fq_name (t) << " (" << strlit (value_) << ")"; - } - } - - // ID/IDREF. - // - void InitValue:: - traverse (SemanticGraph::Fundamental::Id&) - { - collapse (value_); - os << strlit (value_); - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::IdRef&) - { - collapse (value_); - os << strlit (value_); - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::IdRefs&) - { - string_sequence_type ( - dynamic_cast ( - xs_ns ().find ("IDREF").first->named ())); - } - - // URI. - // - void InitValue:: - traverse (SemanticGraph::Fundamental::AnyURI&) - { - collapse (value_); - os << strlit (value_); - } - - // Binary. - // - static unsigned char - base64_decode (unsigned char c) - { - unsigned char r = 0xFF; - - if (c >= 'A' && c <= 'Z') - r = static_cast (c - 'A'); - else if (c >= 'a' && c <= 'z') - r = static_cast (c - 'a' + 26); - else if (c >= '0' && c <= '9') - r = static_cast (c - '0' + 52); - else if (c == '+') - r = 62; - else if (c == '/') - r = 63; - - return r; - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::Base64Binary& t) - { - collapse (value_); - - if (dispatch_count_++ == 0) - { - if (value_) - { - os << "unsigned char " << data_ << "[] = {"; - - // Decode. - // - size_t size (value_.size ()); - - // Remove all whitespaces. - // - { - size_t j (0); - bool subs (false); - - for (size_t i (0); i < size; ++i) - { - wchar_t c (value_[i]); - - if (c == 0x20 || c == 0x0A || c == 0x0D || c == 0x09) - subs = true; - else - { - if (subs) - subs = false; - - value_[j++] = c; - } - } - - size = j; - value_.resize (size, '\0'); - } - - // Our length should be a multiple of four. - // - size_t quad_count (size / 4); - - // Source and destination indexes. - // - size_t si (0), di (0); - - // Process all quads except the last one. - // - unsigned short v; - unsigned char b1, b2, b3, b4; - - wchar_t prev_fill (os.fill ('0')); - - for (size_t q (0); q < quad_count - 1; ++q) - { - b1 = base64_decode (value_[si++]); - b2 = base64_decode (value_[si++]); - b3 = base64_decode (value_[si++]); - b4 = base64_decode (value_[si++]); - - if (q != 0) - os << ", "; - - if (di % 9 == 0) - os << endl; - - os << hex; - - v = static_cast ((b1 << 2) | (b2 >> 4)); - os.width (2); - os << "0x" << v; - - v = static_cast ((b2 << 4) | (b3 >> 2)); - os.width (2); - os << ", 0x" << v; - - v = static_cast ((b3 << 6) | b4); - os.width (2); - os << ", 0x" << v; - - os << dec; - - di += 3; - } - - // Process the last quad. The first two octets are always there. - // - b1 = base64_decode (value_[si++]); - b2 = base64_decode (value_[si++]); - - wchar_t e3 (value_[si++]), e4 (value_[si++]); - - if (quad_count != 1) - os << ", "; - - if (di % 9 == 0) - os << endl; - - if (e4 == '=') - { - if (e3 == '=') - { - // Two pads. Last 4 bits in b2 should be zero. - // - v = static_cast ((b1 << 2) | (b2 >> 4)); - os << "0x" << hex << v << dec; - di++; - } - else - { - // One pad. Last 2 bits in b3 should be zero. - // - b3 = base64_decode (e3); - - os << hex; - - v = static_cast ((b1 << 2) | (b2 >> 4)); - os.width (2); - os << "0x" << v; - - v = static_cast ((b2 << 4) | (b3 >> 2)); - os.width (2); - os << ", 0x" << v; - - os << dec; - - di += 2; - } - } - else - { - // No pads. - // - b3 = base64_decode (e3); - b4 = base64_decode (e4); - - os << hex; - - v = static_cast ((b1 << 2) | (b2 >> 4)); - os.width (2); - os << "0x" << v; - - v = static_cast ((b2 << 4) | (b3 >> 2)); - os.width (2); - os << ", 0x" << v; - - v = static_cast ((b3 << 6) | b4); - os.width (2); - os << ", 0x" << v; - - os << dec; - - di += 3; - } - - os.fill (prev_fill); - - os << "};"; - } - } - else - { - os << fq_name (t) << " ("; - - if (value_) - os << data_ << "," << endl - << "sizeof (" << data_ << ")," << endl - << "sizeof (" << data_ << ")," << endl - << "false"; - else - os << "0"; - - - os << ")"; - } - } - - static unsigned char - hex_decode (unsigned char c) - { - unsigned char r = 0xFF; - - if (c >= '0' && c <= '9') - r = static_cast (c - '0'); - else if (c >= 'A' && c <= 'F') - r = static_cast (10 + (c - 'A')); - else if (c >= 'a' && c <= 'f') - r = static_cast (10 + (c - 'a')); - - return r; - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::HexBinary& t) - { - collapse (value_); - - if (dispatch_count_++ == 0) - { - if (value_) - { - os << "unsigned char " << data_ << "[] = {"; - - // Decode. - // - size_t n (value_.size () / 2); - wchar_t prev_fill (os.fill ('0')); - - for (size_t i (0); i < n; ++i) - { - unsigned char h (hex_decode (value_[2 * i])); - unsigned char l (hex_decode (value_[2 * i + 1])); - - if (h == 0xFF || l == 0xFF) - break; - - if (i != 0) - os << ", "; - - if (i % 9 == 0) - os << endl; - - unsigned short v = static_cast ((h << 4) | l); - os.width (2); - os << "0x" << hex << v << dec; - } - - os.fill (prev_fill); - - os << "};"; - } - } - else - { - os << fq_name (t) << " ("; - - if (value_) - os << data_ << "," << endl - << "sizeof (" << data_ << ")," << endl - << "sizeof (" << data_ << ")," << endl - << "false"; - else - os << "0"; - - - os << ")"; - } - } - - // Date/time. - // - void InitValue:: - traverse (SemanticGraph::Fundamental::Date& t) - { - // date := [-]CCYY[N]*-MM-DD[Z|(+|-)HH:MM] - // - collapse (value_); - - size_t b (0); - size_t e (value_.find ('-', value_[0] == '-' ? 5 : 4)); - String year (value_, 0, e); - - b = e + 1; - String month (value_, b, 2); - - b += 3; - String day (value_, b, 2); - - strip_zeros (year); - strip_zeros (month); - strip_zeros (day); - - os << fq_name (t) << " (" << year << ", " << month << ", " << day; - time_zone (b + 2); - os << ")"; - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::DateTime& t) - { - // date_time := [-]CCYY[N]*-MM-DDTHH:MM:SS[.S+][Z|(+|-)HH:MM] - // - collapse (value_); - - size_t b (0); - size_t e (value_.find ('-', value_[0] == '-' ? 5 : 4)); - String year (value_, 0, e); - b = e + 1; - - String month (value_, b, 2); - b += 3; - - String day (value_, b, 2); - b += 3; - - String hours (value_, b, 2); - b += 3; - - String minutes (value_, b, 2); - b += 3; - - e = b + 2; - for (; e < value_.size (); ++e) - { - wchar_t c (value_[e]); - - if (c == 'Z' || c == '+' || c == '-') - break; - } - - String seconds (value_, b, e - b); - - strip_zeros (year); - strip_zeros (month); - strip_zeros (day); - strip_zeros (hours); - strip_zeros (minutes); - strip_zeros (seconds); - make_float (seconds); - - os << fq_name (t) << " (" - << year << ", " << month << ", " << day << ", " - << hours << ", " << minutes << ", " << seconds; - time_zone (e); - os << ")"; - } - - namespace - { - size_t - find_delim (String const& s, size_t pos) - { - for (; pos < s.size (); ++pos) - { - wchar_t c (s[pos]); - - if (c == 'Y' || c == 'D' || c == 'M' || c == 'H' || - c == 'M' || c == 'S' || c == 'T') - break; - } - - return pos; - } - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::Duration& t) - { - // duration := [-]P[nY][nM][nD][TnHnMn[.n+]S] - // - collapse (value_); - - size_t b (1), e, n (value_.size ()); - - os << fq_name (t) << " ("; - - if (value_[0] == '-') - { - os << "true, "; - b++; - } - else - os << "false, "; - - e = find_delim (value_, b); - - if (e < n && value_[e] == 'Y') - { - String v (value_, b, e - b); - strip_zeros (v); - os << v << ", "; - - b = e + 1; - e = find_delim (value_, b); - } - else - os << "0, "; - - if (e < n && value_[e] == 'M') - { - String v (value_, b, e - b); - strip_zeros (v); - os << v << ", "; - - b = e + 1; - e = find_delim (value_, b); - } - else - os << "0, "; - - if (e < n && value_[e] == 'D') - { - String v (value_, b, e - b); - strip_zeros (v); - os << v << ", "; - - b = e + 1; - e = find_delim (value_, b); - } - else - os << "0, "; - - if (e < n && value_[e] == 'T') - { - b = e + 1; - e = find_delim (value_, b); - } - - if (e < n && value_[e] == 'H') - { - String v (value_, b, e - b); - strip_zeros (v); - os << v << ", "; - - b = e + 1; - e = find_delim (value_, b); - } - else - os << "0, "; - - if (e < n && value_[e] == 'M') - { - String v (value_, b, e - b); - strip_zeros (v); - os << v << ", "; - - b = e + 1; - e = find_delim (value_, b); - } - else - os << "0, "; - - if (e < n && value_[e] == 'S') - { - String v (value_, b, e - b); - strip_zeros (v); - make_float (v); - os << v; - - b = e + 1; - e = find_delim (value_, b); - } - else - os << "0.0"; - - os << ")"; - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::Day& t) - { - // gday := ---DD[Z|(+|-)HH:MM] - // - collapse (value_); - - String day (value_, 3, 2); - strip_zeros (day); - - os << fq_name (t) << " (" << day; - time_zone (5); - os << ")"; - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::Month& t) - { - // gmonth := --MM[Z|(+|-)HH:MM] - // - collapse (value_); - - String month (value_, 2, 2); - strip_zeros (month); - - os << fq_name (t) << " (" << month; - time_zone (4); - os << ")"; - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::MonthDay& t) - { - // gmonth_day := --MM-DD[Z|(+|-)HH:MM] - // - collapse (value_); - - String month (value_, 2, 2); - String day (value_, 5, 2); - - strip_zeros (month); - strip_zeros (day); - - os << fq_name (t) << " (" << month << ", " << day; - time_zone (7); - os << ")"; - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::Year& t) - { - // gyear := [-]CCYY[N]*[Z|(+|-)HH:MM] - // - collapse (value_); - - size_t pos (value_[0] == '-' ? 5 : 4); - for (; pos < value_.size (); ++pos) - { - wchar_t c (value_[pos]); - - if (c == 'Z' || c == '+' || c == '-') - break; - } - - String year (value_, 0, pos); - strip_zeros (year); - - os << fq_name (t) << " (" << year; - time_zone (pos); - os << ")"; - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::YearMonth& t) - { - // gyear_month := [-]CCYY[N]*-MM[Z|(+|-)HH:MM] - // - collapse (value_); - - size_t pos (value_.find ('-', value_[0] == '-' ? 5 : 4)); - - String year (value_, 0, pos); - String month (value_, pos + 1, 2); - - strip_zeros (year); - strip_zeros (month); - - os << fq_name (t) << " (" << year << ", " << month; - time_zone (pos + 3); - os << ")"; - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::Time& t) - { - // time := HH:MM:SS[.S+][Z|(+|-)HH:MM] - // - collapse (value_); - - String hours (value_, 0, 2); - String minutes (value_, 3, 2); - - size_t e (8); - for (; e < value_.size (); ++e) - { - wchar_t c (value_[e]); - - if (c == 'Z' || c == '+' || c == '-') - break; - } - - String seconds (value_, 6, e - 6); - - strip_zeros (hours); - strip_zeros (minutes); - strip_zeros (seconds); - make_float (seconds); - - os << fq_name (t) << " (" << hours << ", " << minutes << ", " << seconds; - time_zone (e); - os << ")"; - } - - void InitValue:: - time_zone (size_t pos) - { - // time_zone := Z|(+|-)HH:MM - // - if (pos < value_.size ()) - { - String h, m; - - if (value_[pos] == 'Z') - { - h = "0"; - m = "0"; - } - else - { - if (value_[pos] == '-') - { - h = "-"; - m = "-"; - } - - h.append (value_, pos + 1, 2); - m.append (value_, pos + 4, 2); - - strip_zeros (h); - strip_zeros (m); - } - - os << ", " << h << ", " << m; - } - } - - // Entity. - // - void InitValue:: - traverse (SemanticGraph::Fundamental::Entity&) - { - collapse (value_); - os << strlit (value_); - } - - void InitValue:: - traverse (SemanticGraph::Fundamental::Entities&) - { - string_sequence_type ( - dynamic_cast ( - xs_ns ().find ("ENTITY").first->named ())); - } - - void InitValue:: - string_sequence_type (SemanticGraph::Type& t) - { - collapse (value_); - - if (!value_) - return; - - size_t b (0); - - for (size_t e (value_.find (' ')); ; e = value_.find (' ', b)) - { - String v (value_, b, e != String::npos ? e - b : e); - - os << "{"; - type_name_.dispatch (t); - os << " tmp (" << strlit (v) << ");" - << "r.push_back (tmp);" - << "}"; - - if (e == String::npos) - break; - - b = e + 1; - } - } - } -} diff --git a/xsd/cxx/tree/default-value.hxx b/xsd/cxx/tree/default-value.hxx deleted file mode 100644 index 3937d3a..0000000 --- a/xsd/cxx/tree/default-value.hxx +++ /dev/null @@ -1,355 +0,0 @@ -// file : xsd/cxx/tree/default-value.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_TREE_DEFAULT_VALUE_HXX -#define CXX_TREE_DEFAULT_VALUE_HXX - -#include -#include - -#include - -namespace CXX -{ - namespace Tree - { - struct IsLiteralValue: IsFundamentalType, Traversal::Complex - { - IsLiteralValue (bool& r); - - virtual void - traverse (SemanticGraph::Complex&); - - private: - Traversal::Inherits inherits_; - }; - - struct LiteralValue: Traversal::Fundamental::Byte, - Traversal::Fundamental::UnsignedByte, - Traversal::Fundamental::Short, - Traversal::Fundamental::UnsignedShort, - Traversal::Fundamental::Int, - Traversal::Fundamental::UnsignedInt, - Traversal::Fundamental::Long, - Traversal::Fundamental::UnsignedLong, - Traversal::Fundamental::Integer, - Traversal::Fundamental::NonPositiveInteger, - Traversal::Fundamental::NonNegativeInteger, - Traversal::Fundamental::PositiveInteger, - Traversal::Fundamental::NegativeInteger, - - Traversal::Fundamental::Boolean, - - Traversal::Fundamental::Float, - Traversal::Fundamental::Double, - Traversal::Fundamental::Decimal, - - Traversal::Complex, - - Context - { - LiteralValue (Context&); - - String - dispatch (SemanticGraph::Node& type, String const& value); - - // Handle inheritance. - // - virtual void - traverse (SemanticGraph::Complex&); - - // Boolean. - // - virtual void - traverse (SemanticGraph::Fundamental::Boolean&); - - // Integral types. - // - virtual void - traverse (SemanticGraph::Fundamental::Byte&); - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedByte&); - - virtual void - traverse (SemanticGraph::Fundamental::Short&); - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedShort&); - - virtual void - traverse (SemanticGraph::Fundamental::Int&); - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedInt&); - - virtual void - traverse (SemanticGraph::Fundamental::Long&); - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedLong&); - - virtual void - traverse (SemanticGraph::Fundamental::Integer&); - - virtual void - traverse (SemanticGraph::Fundamental::NonPositiveInteger&); - - virtual void - traverse (SemanticGraph::Fundamental::NonNegativeInteger&); - - virtual void - traverse (SemanticGraph::Fundamental::PositiveInteger&); - - virtual void - traverse (SemanticGraph::Fundamental::NegativeInteger&); - - // Floats. - // - virtual void - traverse (SemanticGraph::Fundamental::Float&); - - virtual void - traverse (SemanticGraph::Fundamental::Double&); - - virtual void - traverse (SemanticGraph::Fundamental::Decimal&); - - private: - String value_; - String literal_; - - Traversal::Inherits inherits_; - }; - - // Some initialization (e.g., list) need a function body while others - // (e.g., *binary) require extra data. - // - struct InitKind: Traversal::List, - Traversal::Complex, - - Traversal::Fundamental::Base64Binary, - Traversal::Fundamental::HexBinary, - - Traversal::Fundamental::NameTokens, - Traversal::Fundamental::IdRefs, - Traversal::Fundamental::Entities - { - enum Kind - { - simple, - data, - function - }; - - // Should be simple initially. - // - InitKind (Kind& r); - - virtual void - traverse (SemanticGraph::List&); - - virtual void - traverse (SemanticGraph::Complex&); - - virtual void - traverse (SemanticGraph::Fundamental::Base64Binary&); - - virtual void - traverse (SemanticGraph::Fundamental::HexBinary&); - - virtual void - traverse (SemanticGraph::Fundamental::NameTokens&); - - virtual void - traverse (SemanticGraph::Fundamental::IdRefs&); - - virtual void - traverse (SemanticGraph::Fundamental::Entities&); - - private: - Kind& r_; - Traversal::Inherits inherits_; - }; - - struct InitValue: Traversal::List, - Traversal::Union, - Traversal::Complex, - - Traversal::AnyType, - Traversal::AnySimpleType, - - Traversal::Fundamental::String, - Traversal::Fundamental::NormalizedString, - Traversal::Fundamental::Token, - Traversal::Fundamental::Name, - Traversal::Fundamental::NameToken, - Traversal::Fundamental::NameTokens, - Traversal::Fundamental::NCName, - Traversal::Fundamental::Language, - - Traversal::Fundamental::QName, - - Traversal::Fundamental::Id, - Traversal::Fundamental::IdRef, - Traversal::Fundamental::IdRefs, - - Traversal::Fundamental::AnyURI, - - Traversal::Fundamental::Base64Binary, - Traversal::Fundamental::HexBinary, - - Traversal::Fundamental::Date, - Traversal::Fundamental::DateTime, - Traversal::Fundamental::Duration, - Traversal::Fundamental::Day, - Traversal::Fundamental::Month, - Traversal::Fundamental::MonthDay, - Traversal::Fundamental::Year, - Traversal::Fundamental::YearMonth, - Traversal::Fundamental::Time, - - Traversal::Fundamental::Entity, - Traversal::Fundamental::Entities, - - Context - { - InitValue (Context&); - - void - data (String const& data) - { - data_ = data; - dispatch_count_ = 0; - } - - void - dispatch (SemanticGraph::Node& type, String const& value); - - virtual void - traverse (SemanticGraph::List&); - - virtual void - traverse (SemanticGraph::Union&); - - virtual void - traverse (SemanticGraph::Complex&); - - // anyType & anySimpleType. - // - virtual void - traverse (SemanticGraph::AnyType&); - - virtual void - traverse (SemanticGraph::AnySimpleType&); - - // Strings. - // - virtual void - traverse (SemanticGraph::Fundamental::String&); - - virtual void - traverse (SemanticGraph::Fundamental::NormalizedString&); - - virtual void - traverse (SemanticGraph::Fundamental::Token&); - - virtual void - traverse (SemanticGraph::Fundamental::NameToken&); - - virtual void - traverse (SemanticGraph::Fundamental::NameTokens&); - - virtual void - traverse (SemanticGraph::Fundamental::Name&); - - virtual void - traverse (SemanticGraph::Fundamental::NCName&); - - virtual void - traverse (SemanticGraph::Fundamental::Language&); - - // Qualified name. - // - virtual void - traverse (SemanticGraph::Fundamental::QName&); - - // ID/IDREF. - // - virtual void - traverse (SemanticGraph::Fundamental::Id&); - - virtual void - traverse (SemanticGraph::Fundamental::IdRef&); - - virtual void - traverse (SemanticGraph::Fundamental::IdRefs&); - - // URI. - // - virtual void - traverse (SemanticGraph::Fundamental::AnyURI&); - - // Binary. - // - virtual void - traverse (SemanticGraph::Fundamental::Base64Binary&); - - virtual void - traverse (SemanticGraph::Fundamental::HexBinary&); - - // Date/time. - // - virtual void - traverse (SemanticGraph::Fundamental::Date&); - - virtual void - traverse (SemanticGraph::Fundamental::DateTime&); - - virtual void - traverse (SemanticGraph::Fundamental::Duration&); - - virtual void - traverse (SemanticGraph::Fundamental::Day&); - - virtual void - traverse (SemanticGraph::Fundamental::Month&); - - virtual void - traverse (SemanticGraph::Fundamental::MonthDay&); - - virtual void - traverse (SemanticGraph::Fundamental::Year&); - - virtual void - traverse (SemanticGraph::Fundamental::YearMonth&); - - virtual void - traverse (SemanticGraph::Fundamental::Time&); - - // Entity. - // - virtual void - traverse (SemanticGraph::Fundamental::Entity&); - - virtual void - traverse (SemanticGraph::Fundamental::Entities&); - - private: - void - string_sequence_type (SemanticGraph::Type& element_type); - - void - time_zone (size_t pos); - - private: - String value_; - String data_; - size_t dispatch_count_; - MemberTypeName type_name_; - LiteralValue literal_value_; - }; - } -} - -#endif // CXX_TREE_DEFAULT_VALUE_HXX diff --git a/xsd/cxx/tree/elements.cxx b/xsd/cxx/tree/elements.cxx deleted file mode 100644 index 78281cd..0000000 --- a/xsd/cxx/tree/elements.cxx +++ /dev/null @@ -1,1409 +0,0 @@ -// file : xsd/cxx/tree/elements.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -namespace CXX -{ - namespace Tree - { - // Context - // - Context:: - Context (std::wostream& o, - SemanticGraph::Schema& root, - SemanticGraph::Path const& path, - options_type const& ops, - Counts const& counts_, - bool generate_xml_schema__, - StringLiteralMap const* map, - Regex const* fe, - Regex const* he, - Regex const* ie) - : CXX::Context (o, root, path, ops, map), - options (ops), - counts (counts_), - any_type (any_type_), - any_simple_type (any_simple_type_), - element_type (element_type_), - container (container_), - flags_type (flags_type_), - qname_type (qname_type_), - xs_string_type (xs_string_type_), - properties_type (properties_type_), - error_handler_type (error_handler_type_), - list_stream_type (list_stream_type_), - namespace_infomap_type (namespace_infomap_type_), - parser_type (parser_type_), - std_ostream_type (std_ostream_type_), - ostream_type (ostream_type_), - istream_type (istream_type_), - xerces_ns (xerces_ns_), - dom_auto_ptr (dom_auto_ptr_), - dom_node_key (dom_node_key_), - as_double_type (as_double_type_), - as_decimal_type (as_decimal_type_), - generate_xml_schema (generate_xml_schema_), - doxygen (doxygen_), - polymorphic (ops.generate_polymorphic ()), - polymorphic_all (ops.polymorphic_type_all ()), - poly_plate (ops.polymorphic_plate ()), - detach (ops.generate_detach ()), - fwd_expr (fe), - hxx_expr (he), - ixx_expr (ie), - ns_scope (ns_scope_), - regex_custom_type_map (regex_custom_type_map_), - direct_custom_type_map (direct_custom_type_map_), - qname_type_ (L"::xsd::cxx::xml::qualified_name< " + char_type + L" >"), - parser_type_ (L"::xsd::cxx::xml::dom::parser< " + char_type + L" >"), - generate_xml_schema_ (generate_xml_schema__), - doxygen_ (ops.generate_doxygen ()), - ns_scope_stack (ns_scope_stack_), - cxx_uq_id_expr_ (L"^[a-zA-Z_]\\w*$"), - cxx_uq_id_expr (cxx_uq_id_expr_) - { - SemanticGraph::Namespace& xs (xs_ns ()); - SemanticGraph::Context& xsc (xs.context ()); - - // Cache some often-used names from the XML Schema namespace - // if names have already been processed. - // - if (xsc.count ("container")) - { - String xs_name (ns_name (xs)); - - any_type = fq_name (xs.find ("anyType").first->named ()); - any_simple_type = fq_name (xs.find ("anySimpleType").first->named ()); - xs_string_type = fq_name (xs.find ("string").first->named ()); - - container = xs_name + L"::" + xsc.get ("container"); - flags_type = xs_name + L"::" + xsc.get ("flags"); - - if (ops.generate_element_type ()) - element_type = xs_name + L"::" + xsc.get ("element-type"); - - properties_type = xs_name + L"::" + xsc.get ("properties"); - - if (!ops.suppress_parsing () || ops.generate_serialization ()) - { - error_handler_type = xs_name + L"::" + - xsc.get ("error-handler"); - } - - dom_auto_ptr_ = xs_name + (std >= cxx_version::cxx11 - ? L"::dom::unique_ptr" - : L"::dom::auto_ptr"); - - dom_node_key_ = xs_name + L"::dom::" + - xsc.get ("tree-node-key"); - - if (ops.generate_serialization ()) - { - as_double_type_ = xs_name + L"::" + - xsc.get ("as-double"); - - as_decimal_type_ = xs_name + L"::" + - xsc.get ("as-decimal"); - - list_stream_type = xs_name + L"::" + - xsc.get ("list-stream"); - - namespace_infomap_type = xs_name + L"::" + - xsc.get ("namespace-infomap"); - } - - // istream and ostream are templates and for now use the same - // names regardless of the naming convention. - // - if (!ops.generate_extraction ().empty ()) - istream_type = xs_name + L"::istream"; - - if (!ops.generate_insertion ().empty ()) - ostream_type = xs_name + L"::ostream"; - } - - // Xerces-C++ namespace. IntelliSense for some reason does not like - // it fully-qualified (maybe because it's a namespace alias). - // - if (ops.generate_intellisense ()) - xerces_ns = "xercesc"; - else - xerces_ns = "::xercesc"; - - // - // - if (char_type == L"char") - std_ostream_type_ = L"::std::ostream"; - else if (char_type == L"wchar_t") - std_ostream_type_ = L"::std::wostream"; - else - std_ostream_type_ = L"::std::basic_ostream< " + char_type + L" >"; - - // Custom type mapping. - // - - // Direct custom type mapping. - // - { - NarrowStrings const& v (ops.custom_type ()); - - for (NarrowStrings::const_iterator i (v.begin ()), - e (v.end ()); i != e; ++i) - { - String s (*i); - - if (s.empty ()) - throw InvalidCustomTypeMapping (s, "mapping string is empty"); - - // Split the string in two parts at the last '='. - // - size_t pos (s.rfind ('=')); - - // If no delimiter found then both type and base are empty. - // - if (pos == String::npos) - { - direct_custom_type_map[s].type.clear (); - direct_custom_type_map[s].base.clear (); - continue; - } - - String name (s, 0, pos); - String rest (s, pos + 1); - - // See if we've got the base part after '/'. - // - pos = rest.rfind ('/'); - - String type, base; - - if (pos != String::npos) - { - type.assign (rest, 0, pos); - base.assign (rest, pos + 1, String::npos); - } - else - type = rest; - - // type can be a potentially-qualified template-id. base is - // an unqualified C++ name. - // - - if (!base.empty () && !cxx_uq_id_expr.match (base)) - throw InvalidCustomTypeMapping (s, "invalid C++ identifier"); - - direct_custom_type_map[name].type = type; - direct_custom_type_map[name].base = base; - } - } - - // Regex custom type mapping. - // - { - NarrowStrings const& v (ops.custom_type_regex ()); - - for (NarrowStrings::const_iterator i (v.begin ()), - e (v.end ()); i != e; ++i) - { - String s (*i); - - if (s.empty ()) - throw InvalidCustomTypeMapping (s, "mapping string is empty"); - - wchar_t delimiter (s[0]); - - // First get pattern. - // - size_t pos (s.find (delimiter, 1)); - - if (pos == String::npos) - throw InvalidCustomTypeMapping ( - s, "missing pattern-substitution separator"); - - String pat (s, 1, pos - 1); - String rest (s, pos + 1); - - String type, base; - - // See if we've got type and base. - // - if (!rest.empty ()) - { - pos = rest.find (delimiter); - - if (pos == String::npos) - throw InvalidCustomTypeMapping ( - s, "missing pattern-substitution separator"); - - type.assign (rest, 0, pos); - rest = String (rest, pos + 1); - - if (!rest.empty ()) - { - pos = rest.find (delimiter); - - if (pos == String::npos) - throw InvalidCustomTypeMapping ( - s, "missing pattern-substitution separator"); - - base.assign (rest, 0, pos); - rest = String (rest, pos + 1); - - if (!rest.empty ()) - throw InvalidCustomTypeMapping (s, "invalid format"); - } - } - - regex_custom_type_map.push_back ( - RegexCustomTypeMapInfo (WideRegexPat (pat), type, base)); - } - } - } - - Context:: - Context (Context& c) - : CXX::Context (c), - options (c.options), - counts (c.counts), - any_type (c.any_type), - any_simple_type (c.any_simple_type), - element_type (c.element_type), - container (c.container), - flags_type (c.flags_type), - qname_type (c.qname_type), - xs_string_type (c.xs_string_type), - properties_type (c.properties_type), - error_handler_type (c.error_handler_type), - list_stream_type (c.list_stream_type), - namespace_infomap_type (c.namespace_infomap_type), - parser_type (c.parser_type), - std_ostream_type (c.std_ostream_type), - ostream_type (c.ostream_type), - istream_type (c.istream_type), - xerces_ns (c.xerces_ns), - dom_auto_ptr (c.dom_auto_ptr), - dom_node_key (c.dom_node_key), - as_double_type (c.as_double_type), - as_decimal_type (c.as_decimal_type), - generate_xml_schema (c.generate_xml_schema), - doxygen (c.doxygen), - polymorphic (c.polymorphic), - polymorphic_all (c.polymorphic_all), - poly_plate (c.poly_plate), - detach (c.detach), - fwd_expr (c.fwd_expr), - hxx_expr (c.hxx_expr), - ixx_expr (c.ixx_expr), - ns_scope (c.ns_scope), - regex_custom_type_map (c.regex_custom_type_map), - direct_custom_type_map (c.direct_custom_type_map), - ns_scope_stack (c.ns_scope_stack), - cxx_uq_id_expr (c.cxx_uq_id_expr) - { - } - - Context:: - Context (Context& c, std::wostream& o) - : CXX::Context (c, o), - options (c.options), - counts (c.counts), - any_type (c.any_type), - any_simple_type (c.any_simple_type), - element_type (c.element_type), - container (c.container), - flags_type (c.flags_type), - qname_type (c.qname_type), - xs_string_type (c.xs_string_type), - properties_type (c.properties_type), - error_handler_type (c.error_handler_type), - list_stream_type (c.list_stream_type), - namespace_infomap_type (c.namespace_infomap_type), - parser_type (c.parser_type), - std_ostream_type (c.std_ostream_type), - ostream_type (c.ostream_type), - istream_type (c.istream_type), - xerces_ns (c.xerces_ns), - dom_auto_ptr (c.dom_auto_ptr), - dom_node_key (c.dom_node_key), - as_double_type (c.as_double_type), - as_decimal_type (c.as_decimal_type), - generate_xml_schema (c.generate_xml_schema), - doxygen (c.doxygen), - polymorphic (c.polymorphic), - polymorphic_all (c.polymorphic_all), - poly_plate (c.poly_plate), - detach (c.detach), - fwd_expr (c.fwd_expr), - hxx_expr (c.hxx_expr), - ixx_expr (c.ixx_expr), - ns_scope (c.ns_scope), - regex_custom_type_map (c.regex_custom_type_map), - direct_custom_type_map (c.direct_custom_type_map), - ns_scope_stack (c.ns_scope_stack), - cxx_uq_id_expr (c.cxx_uq_id_expr) - { - } - - void Context:: - update_ns_scope () - { - ns_scope.clear (); - - bool first (true); - - for (NamespaceStack::iterator i (ns_scope_stack.begin ()); - i != ns_scope_stack.end (); - ++i) - { - // We only qualify names until the namespace level. - // - if (first) - first = false; - else - ns_scope += L"::"; - - ns_scope += *i; - } - } - - bool Context:: - custom_type (SemanticGraph::Type const& t, String& r) const - { - String const& name (t.name ()); - - // First search the direct mapping. - // - { - DirectCustomTypeMap::const_iterator i ( - direct_custom_type_map.find (name)); - - if (i != direct_custom_type_map.end ()) - { - r = i->second.type; - return true; - } - } - - - // Second search the regex mapping. - // - for (RegexCustomTypeMap::const_iterator - i (regex_custom_type_map.begin ()), - e (regex_custom_type_map.end ()); - i != e; ++i) - { - if (i->pat.match (name)) - { - // Empty type sub tells us to use the original name. - // - if (i->type_sub.empty ()) - { - r.clear (); - return true; - } - - r = i->pat.replace (name, i->type_sub); - return true; - } - } - - return false; - } - - String Context:: - custom_type (SemanticGraph::Type const& t) const - { - String r; - if (custom_type (t, r)) - { - // Empty type name tells us to use the original name. - // - if (r.empty ()) - r = ename (t); - } - - return r; - } - - bool Context:: - renamed_type (SemanticGraph::Type const& t, String& r) const - { - String const& name (t.name ()); - - // First search the direct mapping. - // - { - DirectCustomTypeMap::const_iterator i ( - direct_custom_type_map.find (name)); - - if (i != direct_custom_type_map.end ()) - { - r = i->second.base; - return true; - } - } - - - // Second search the regex mapping. - // - for (RegexCustomTypeMap::const_iterator - i (regex_custom_type_map.begin ()), - e (regex_custom_type_map.end ()); - i != e; ++i) - { - if (i->pat.match (name)) - { - if (!i->base_sub.empty ()) - { - r = i->pat.replace (name, i->base_sub); - } - else - r.clear (); - - return true; - } - } - - return false; - } - - void Context:: - write_annotation (SemanticGraph::Annotation& a) - { - String const& doc (a.documentation ()); - wchar_t const* s (doc.c_str ()); - size_t size (doc.size ()); - - // Remove leading and trailing whitespaces. - // - while (*s == wchar_t (0x20) || *s == wchar_t (0x0A) || - *s == wchar_t (0x0D) || *s == wchar_t (0x09)) - { - s++; - size--; - } - - if (size != 0) - { - wchar_t const* e (s + size - 1); - - while (e > s && - (*e == wchar_t (0x20) || *e == wchar_t (0x0A) || - *e == wchar_t (0x0D) || *e == wchar_t (0x09))) - --e; - - size = s <= e ? e - s + 1 : 0; - } - - if (size != 0) - { - os << " * "; - - // Go over the data, forcing newline after 80 chars and adding - // ' * ' after each new line. - // - wchar_t const* last_space (0); - wchar_t const* b (s); - wchar_t const* e (s); - bool after_newline (false); - bool rogue (false); - - for (; e < s + size; ++e) - { - unsigned int u (unicode_char (e)); // May advance e. - - // We are going to treat \v and \f as rogue here even though - // they can be present in C++ source code. - // - if (u > 127 || (u < 32 && u != '\t' && u != '\n')) - rogue = true; - - if (u == ' ' || u == '\t') - { - if (after_newline) - { - if (e == b) - b++; // Skip leading spaces after newline. - - continue; - } - else - last_space = e; - } - else if (after_newline) - { - os << " * "; - after_newline = false; - } - - if (u == '\n') - { - write_rogue_text (b, e - b + 1, rogue); - - b = e + 1; - last_space = 0; - after_newline = true; - rogue = false; - continue; - } - - if (e - b >= 70 && last_space != 0) - { - write_rogue_text (b, last_space - b, rogue); - os << endl; - - b = last_space + 1; - last_space = 0; - after_newline = true; - // Cannot reset rogue since we don't output the whole string. - } - } - - if (e != b) - write_rogue_text (b, e - b, rogue); - - if (!after_newline) - os << endl; - } - } - - void Context:: - write_rogue_text (wchar_t const* s, size_t size, bool rogue) - { - if (!rogue) - os.write (s, size); - else - { - for (wchar_t const* p (s); p < s + size; ++p) - { - unsigned int u (unicode_char (p)); // May advance p. - - // We are going to treat \v and \f as rogue here even though - // they can be present in C++ source code. - // - if (u > 127 || (u < 32 && u != '\t' && u != '\n')) - os.put ('?'); - else - os.put (static_cast (u)); - } - } - } - - bool Context:: - polymorphic_p (SemanticGraph::Type& t) - { - // IDREF templates cannot be polymorphic. - // - if (!t.named_p () && - (t.is_a () || - t.is_a ())) - return false; - - if (polymorphic_all) - { - bool fund (false); - IsFundamentalType test (fund); - test.dispatch (t); - return !fund; - } - else - return t.context ().get ("polymorphic"); - } - - bool Context:: - anonymous_substitutes_p (SemanticGraph::Type& t) - { - // IDREF templates cannot match. - // - if (!t.named_p () && - (t.is_a () || - t.is_a ())) - return false; - - // See which elements this type classifies. - // - for (SemanticGraph::Type::ClassifiesIterator i (t.classifies_begin ()), - e (t.classifies_end ()); i != e; ++i) - { - if (SemanticGraph::Element* e = - dynamic_cast (&i->instance ())) - { - if (e->substitutes_p ()) - return true; - } - } - - return false; - } - - // GenerateDefautCtor - // - GenerateDefaultCtor:: - GenerateDefaultCtor (Context& c, bool& generate, bool no_base) - : Context (c), generate_ (generate), no_base_ (no_base) - { - *this >> inherits_ >> *this; - *this >> names_ >> *this; - } - - void GenerateDefaultCtor:: - traverse (SemanticGraph::Complex& c) - { - // Make sure we figure out if we have any required members before - // we base our decision on the base type. - // - Complex::names (c, names_); - - if (!generate_) - Complex::inherits (c, inherits_); - } - - void GenerateDefaultCtor:: - traverse (SemanticGraph::Type&) - { - if (!no_base_) - generate_ = true; - } - - void GenerateDefaultCtor:: - traverse (SemanticGraph::Enumeration&) - { - if (!no_base_) - generate_ = true; - } - - void GenerateDefaultCtor:: - traverse (SemanticGraph::Element& e) - { - if (!skip (e) && min (e) == 1 && max (e) == 1) - generate_ = true; - } - - void GenerateDefaultCtor:: - traverse (SemanticGraph::Attribute& a) - { - if (min (a) == 1 && !a.fixed_p ()) - generate_ = true; - } - - void GenerateDefaultCtor:: - traverse (SemanticGraph::Any& a) - { - if (options.generate_wildcard () && - min (a) == 1 && max (a) == 1) - generate_ = true; - } - - - // GenerateFromBaseCtor - // - GenerateFromBaseCtor:: - GenerateFromBaseCtor (Context& c, bool& generate) - : generate_ (generate), - custom_ (false), - traverser_ (c, generate, custom_) - { - inherits_ >> traverser_; - } - - void GenerateFromBaseCtor:: - traverse (SemanticGraph::Complex& c) - { - inherits (c, inherits_); - - if (!generate_ && custom_) - { - // We have a customized type in the hierarchy. In this case we - // want to generate the c-tor unless base and ultimate-base are - // the same (see CtorArgs). - // - SemanticGraph::Type& b (c.inherits ().base ()); - generate_ = b.is_a () && - !b.is_a (); - } - } - - GenerateFromBaseCtor::Traverser:: - Traverser (Context& c, bool& generate, bool& custom) - : Context (c), generate_ (generate), custom_ (custom) - { - *this >> inherits_ >> *this; - *this >> names_ >> *this; - } - - void GenerateFromBaseCtor::Traverser:: - traverse (SemanticGraph::Type& t) - { - if (!custom_) - { - String tmp; - custom_ = custom_type (t, tmp); - } - } - - void GenerateFromBaseCtor::Traverser:: - traverse (SemanticGraph::Complex& c) - { - names (c, names_); - - if (!generate_) - inherits (c, inherits_); - - if (!generate_) - traverse (static_cast (c)); - } - - void GenerateFromBaseCtor::Traverser:: - traverse (SemanticGraph::Element& e) - { - if (!skip (e) && min (e) == 1 && max (e) == 1) - generate_ = true; - } - - void GenerateFromBaseCtor::Traverser:: - traverse (SemanticGraph::Attribute& a) - { - if (min (a) == 1 && !a.fixed_p ()) - generate_ = true; - } - - void GenerateFromBaseCtor::Traverser:: - traverse (SemanticGraph::Any& a) - { - if (options.generate_wildcard () && - min (a) == 1 && max (a) == 1) - generate_ = true; - } - - // HasComplexNonOptArgs - // - HasComplexPolyNonOptArgs:: - HasComplexPolyNonOptArgs (Context& c, - bool base, - bool& complex, - bool& poly, - bool& clash) - : Context (c), - complex_ (complex), - poly_ (poly), - clash_ (clash) - { - if (base) - *this >> inherits_ >> *this; - - *this >> names_ >> *this; - } - - void HasComplexPolyNonOptArgs:: - traverse (SemanticGraph::Complex& c) - { - // No optimizations: need to check every arg for clashes. - // - inherits (c, inherits_); - names (c, names_); - } - - void HasComplexPolyNonOptArgs:: - traverse (SemanticGraph::Element& e) - { - if (!skip (e) && min (e) == 1 && max (e) == 1) - { - bool poly (polymorphic && polymorphic_p (e.type ())); - - bool simple (true); - IsSimpleType t (simple); - t.dispatch (e.type ()); - - if (poly) - poly_ = true; - - if (!simple) - complex_ = true; - - if (poly && simple) - clash_ = false; - } - } - - // FromBaseCtorArg - // - FromBaseCtorArg:: - FromBaseCtorArg (Context& c, CtorArgType at, bool arg) - : Context (c), arg_type_ (at), arg_ (arg) - { - } - - void FromBaseCtorArg:: - traverse (SemanticGraph::Any& a) - { - if (!options.generate_wildcard ()) - return; - - if (min (a) == 1 && max (a) == 1) - { - String const& name (ename (a)); - - os << "," << endl - << "const " << xerces_ns << "::DOMElement&"; - - if (arg_) - os << " " << name; - } - } - - void FromBaseCtorArg:: - traverse (SemanticGraph::Element& e) - { - if (skip (e)) - return; - - if (min (e) == 1 && max (e) == 1) - { - String const& name (ename (e)); - - os << "," << endl; - - bool ptr (false); - - switch (arg_type_) - { - case CtorArgType::complex_auto_ptr: - { - bool simple (true); - IsSimpleType t (simple); - t.dispatch (e.type ()); - ptr = !simple; - break; - } - case CtorArgType::poly_auto_ptr: - { - ptr = polymorphic && polymorphic_p (e.type ()); - break; - } - case CtorArgType::type: - break; - } - - if (ptr) - os << auto_ptr << "< " << etype (e) << " >"; - else - os << "const " << etype (e) << "&"; - - if (arg_) - os << " " << name; - } - } - - void FromBaseCtorArg:: - traverse (SemanticGraph::Attribute& a) - { - // Note that we are not going to include attributes with - // default or required fixed values here. Instead we are - // going to default-initialize them. - // - if (min (a) == 1 && !a.fixed_p ()) - { - String const& name (ename (a)); - - os << "," << endl - << "const " << etype (a) << "&"; - - if (arg_) - os << " " << name; - } - } - - // CtorArgs - // - CtorArgs:: - CtorArgs (Context& c, CtorArgType at) - : Context (c), - arg_type_ (at), - base_arg_ (0), - first_ (true), - member_name_ (c) - { - *this >> inherits_ >> *this; - *this >> names_ >> *this; - } - - CtorArgs:: - CtorArgs (Context& c, CtorArgType at, String& base_arg) - : Context (c), - arg_type_ (at), - base_arg_ (&base_arg), - first_ (true), - member_name_ (c) - { - *this >> inherits_ >> *this; - *this >> names_ >> *this; - } - - void CtorArgs:: - traverse (SemanticGraph::Type& t) - { - os << comma () << "const "; - - member_name_.dispatch (t); - - os << "&"; - - if (base_arg_ != 0) - { - // IDREF templates don't have a name. - // - *base_arg_ = t.named_p () - ? (L"_xsd_" + ename (t) + L"_base") - : L"_xsd_base"; - - os << " " << *base_arg_; - } - } - - void CtorArgs:: - traverse (SemanticGraph::Enumeration& e) - { - os << comma () << "const "; - - member_name_.traverse (e); - - os << "&"; - - if (base_arg_ != 0) - { - *base_arg_ = L"_xsd_" + ename (e) + L"_base"; - - os << " " << *base_arg_; - } - } - - void CtorArgs:: - traverse (SemanticGraph::Any& a) - { - if (!options.generate_wildcard ()) - return; - - if (min (a) == 1 && max (a) == 1) - { - os << comma () << "const " << xerces_ns << "::DOMElement&"; - - if (base_arg_ != 0) - os << " " << ename (a); - } - } - - void CtorArgs:: - traverse (SemanticGraph::Element& e) - { - if (skip (e)) - return; - - if (min (e) == 1 && max (e) == 1) - { - bool ptr (false); - - switch (arg_type_) - { - case CtorArgType::complex_auto_ptr: - { - bool simple (true); - IsSimpleType t (simple); - t.dispatch (e.type ()); - ptr = !simple; - break; - } - case CtorArgType::poly_auto_ptr: - { - ptr = polymorphic && polymorphic_p (e.type ()); - break; - } - case CtorArgType::type: - break; - } - - if (ptr) - os << comma () << auto_ptr << "< " << etype (e) << " >"; - else - os << comma () << "const " << etype (e) << "&"; - - if (base_arg_ != 0) - os << " " << ename (e); - } - } - - void CtorArgs:: - traverse (SemanticGraph::Attribute& a) - { - // Note that we are not going to include attributes with - // default or required fixed values here. Instead we are - // going to default-initialize them. - // - if (min (a) == 1 && !a.fixed_p ()) - { - os << comma () << "const " << etype (a) << "&"; - - if (base_arg_ != 0) - os << " " << ename (a); - } - } - - String CtorArgs:: - comma () - { - bool tmp (first_); - first_ = false; - return tmp ? "" : ",\n"; - } - - - // CtorArgsWithoutBase - // - CtorArgsWithoutBase:: - CtorArgsWithoutBase (Context& c, CtorArgType at, bool arg, bool first) - : Context (c), arg_type_ (at), arg_ (arg), first_ (first) - { - *this >> inherits_ >> *this; - *this >> names_ >> *this; - } - - void CtorArgsWithoutBase:: - traverse (SemanticGraph::Any& a) - { - if (!options.generate_wildcard ()) - return; - - if (min (a) == 1 && max (a) == 1) - { - os << comma () << "const " << xerces_ns << "::DOMElement&"; - - if (arg_) - os << " " << ename (a); - } - } - - void CtorArgsWithoutBase:: - traverse (SemanticGraph::Element& e) - { - if (skip (e)) - return; - - if (min (e) == 1 && max (e) == 1) - { - bool ptr (false); - - switch (arg_type_) - { - case CtorArgType::complex_auto_ptr: - { - bool simple (true); - IsSimpleType t (simple); - t.dispatch (e.type ()); - ptr = !simple; - break; - } - case CtorArgType::poly_auto_ptr: - { - ptr = polymorphic && polymorphic_p (e.type ()); - break; - } - case CtorArgType::type: - break; - } - - if (ptr) - os << comma () << auto_ptr << "< " << etype (e) << " >"; - else - os << comma () << "const " << etype (e) << "&"; - - if (arg_) - os << " " << ename (e); - } - } - - void CtorArgsWithoutBase:: - traverse (SemanticGraph::Attribute& a) - { - // Note that we are not going to include attributes with - // default or required fixed values here. Instead we are - // going to default-initialize them. - // - if (min (a) == 1 && !a.fixed_p ()) - { - os << comma () << "const " << etype (a) << "&"; - - if (arg_) - os << " " << ename (a); - } - } - - String CtorArgsWithoutBase:: - comma () - { - bool tmp (first_); - first_ = false; - return tmp ? "" : ",\n"; - } - - // GlobalElementBase - // - bool GlobalElementBase:: - generate_p (SemanticGraph::Element& e) - { - if (e.substitutes_p () && ctx_.polymorphic) - return true; - - if (!doc_root_p (e)) - return false; - - // If we are not generating element types nor parsing/serialization - // code then we won't generate anything from it. - // - if (!ctx_.options.generate_element_type () && - ctx_.options.suppress_parsing () && - !ctx_.options.generate_serialization ()) - return false; - - return true; - } - - bool GlobalElementBase:: - doc_root_p (SemanticGraph::Element& e) - { - if (!ctx_.options.root_element_first () && - !ctx_.options.root_element_last () && - !ctx_.options.root_element_all () && - !ctx_.options.root_element_none () && - ctx_.options.root_element ().empty ()) - return true; // By default treat them all. - - if (ctx_.options.root_element_none ()) - return false; - - if (ctx_.options.root_element_all ()) - return true; - - if (ctx_.options.root_element_first () && - e.context ().count ("first") != 0) - return true; - - if (ctx_.options.root_element_last () && - e.context ().count ("last") != 0) - return true; - - NarrowStrings const& names (ctx_.options.root_element ()); - - // Hopefully nobody will specify more than a handful of names ;-). - // - for (NarrowStrings::const_iterator i (names.begin ()); - i != names.end (); ++i) - { - String name (*i); - - if (e.name () == name) - return true; - } - - return false; - } - - // Namespace - // - Namespace:: - Namespace (Context& c, - size_t first, - size_t last) - : CXX::Namespace (c, *this), - GlobalElementBase (c), - ctx_ (c), - first_ (first), - last_ (last), - count_ (0) - { - } - - void Namespace:: - traverse (Type& ns) - { - using SemanticGraph::Element; - - if (first_ > last_) - CXX::Namespace::traverse (ns); - else - { - bool opened (false); - - for (Type::NamesIterator i (ns.names_begin ()); - i != ns.names_end (); ++i) - { - SemanticGraph::Nameable& n (i->named ()); - - if (n.is_a () || - (n.is_a () && generate_p (dynamic_cast (n)))) - { - if (count_ >= first_ && count_ <= last_) - { - if (!opened) - { - opened = true; - pre (ns); - } - - edge_traverser ().dispatch (*i); - } - - ++count_; - } - } - - if (opened) - post (ns); - } - } - - void Namespace:: - enter (Type&, String const& name, bool) - { - ctx_.enter_ns_scope (name); - } - - void Namespace:: - leave () - { - ctx_.leave_ns_scope (); - } - - // Includes - // - void TypeForward:: - traverse (SemanticGraph::Type& t) - { - String const& name (ename (t)); - - if (String custom = custom_type (t)) - { - String new_name; - renamed_type (t, new_name); - - if (new_name) - os << "class " << new_name << ";"; - - if (custom == name) - os << "class " << name << ";"; - else - os << "typedef " << custom << " " << name << ";"; - } - else - os << "class " << name << ";"; - } - - void Includes:: - traverse_ (SemanticGraph::Uses& u) - { - // Support for weak (forward) inclusion used in the file-per-type - // compilation model. - // - Type t (type_); - bool weak (u.context ().count ("weak")); - SemanticGraph::Schema& s (u.schema ()); - - if (weak && t == header) - { - // Generate forward declarations. - // - if (forward_) - t = forward; - else - { - schema_.dispatch (s); - return; - } - } - - if (t == source && !weak) - { - if (u.user ().context ().count ("type-schema")) - { - // Strong include into a type schema -- this is a base class. - // We have already included its header in our header so it - // would seem we don't need to do anything here. There is one - // subtle issue, however: Our constructors include arguments - // for base members which we simply pass to the base. The base - // header has only forward declarations for its members. This - // is not a problem if we pass references to base members -- - // forward declarations are sufficient for this case. The - // problematic case is when we pass them as auto/unique_ptr. - // Because we pass them by value (which is done to support - // unique_ptr move semantics), the compiler needs to be able - // to destroy the member, presumably if an exception is thrown. - // And for that forward declarations are not enough. - // - // So what we are going to do here is include all the base - // member headers (transitively), just like the base's source - // file does. - // - // Note that we only do this for source since in the inline - // case the necessary files are already pulled via the the - // .ixx file includes. - // - Traversal::Schema schema; - schema >> *this; - schema.dispatch (s); - } - - return; - } - - SemanticGraph::Path path ( - s.context ().count ("renamed") - ? s.context ().get ("renamed") - : u.path ()); - path.normalize (); - - // Try to use the portable representation of the path. If that - // fails, fall back to the native representation. - // - NarrowString path_str; - try - { - path_str = path.posix_string (); - } - catch (SemanticGraph::InvalidPath const&) - { - path_str = path.string (); - } - - String inc_path; - - switch (t) - { - case forward: - { - inc_path = ctx_.fwd_expr->replace (path_str); - break; - } - case header: - case source: - { - inc_path = ctx_.hxx_expr->replace (path_str); - break; - } - case inline_: - { - if (weak) - { - inc_path = ctx_.hxx_expr->replace (path_str); - ctx_.os << "#include " << ctx_.process_include_path (inc_path) - << endl; - } - - inc_path = ctx_.ixx_expr->replace (path_str); - break; - } - } - - ctx_.os << "#include " << ctx_.process_include_path (inc_path) << endl - << endl; - } - } -} diff --git a/xsd/cxx/tree/elements.hxx b/xsd/cxx/tree/elements.hxx deleted file mode 100644 index 57c3075..0000000 --- a/xsd/cxx/tree/elements.hxx +++ /dev/null @@ -1,2118 +0,0 @@ -// file : xsd/cxx/tree/elements.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_TREE_ELEMENTS_HXX -#define CXX_TREE_ELEMENTS_HXX - -#include -#include -#include -#include -#include - -#include - -#include - -#include - -#include - -namespace CXX -{ - namespace Tree - { - struct Counts - { - Counts () - : global_types (0), - global_elements (0), - generated_global_elements (0), - complexity_total (0) - { - } - - size_t global_types; - size_t global_elements; - size_t generated_global_elements; - - // Complexity value for each global type and generated global - // element, in order. - // - std::vector complexity; - size_t complexity_total; - }; - - struct InvalidCustomTypeMapping - { - InvalidCustomTypeMapping (String const& mapping, - String const& reason) - : mapping_ (mapping), reason_ (reason) - { - } - - String const& - mapping () const - { - return mapping_; - } - - String const& - reason () const - { - return reason_; - } - - private: - String mapping_; - String reason_; - }; - - // A set of potentially qualified XML Schema type names. - // - struct TypeNameSet - { - template - TypeNameSet (I begin, I end) - { - for (; begin != end; ++begin) - insert (*begin); - } - - void - insert (String const& name) - { - size_t p (name.rfind ('#')); - - if (p == String::npos) - unames_.insert (name); - else - qnames_.insert (name); - } - - bool - find (SemanticGraph::Type& t) - { - if (!unames_.empty ()) - { - if (unames_.find (t.name ()) != unames_.end ()) - return true; - } - - if (!qnames_.empty ()) - { - if (qnames_.find (t.scope ().name () + L"#" + t.name ()) != - qnames_.end ()) - return true; - } - - return false; - } - - private: - typedef std::set StringSet; - - StringSet unames_; - StringSet qnames_; - }; - - // - // - class Context: public CXX::Context - { - public: - typedef cutl::re::regexsub Regex; - typedef cutl::re::wregex WideRegexPat; - - typedef Tree::options options_type; - - struct DirectCustomTypeMapInfo - { - DirectCustomTypeMapInfo (String const& t = L"", - String const& b = L"") - : type (t), base (b) - { - } - - String type; - String base; - }; - - struct RegexCustomTypeMapInfo - { - RegexCustomTypeMapInfo (WideRegexPat const& p, - String const& t, - String const& b) - : pat (p), type_sub (t), base_sub (b) - { - } - - WideRegexPat pat; - String type_sub; - String base_sub; - }; - - typedef std::vector RegexCustomTypeMap; - typedef std::map DirectCustomTypeMap; - - public: - Context (std::wostream& o, - SemanticGraph::Schema& root, - SemanticGraph::Path const& path, - options_type const& ops, - Counts const& counts_, - bool generate_xml_schema, - StringLiteralMap const*, - Regex const* fwd_expr, - Regex const* hxx_expr, - Regex const* ixx_expr); - - protected: - Context (Context& c); - Context (Context& c, std::wostream& o); - - // Custom type mapping. - // - public: - // Returns empty string if custom mapping is not required. - // - String - custom_type (SemanticGraph::Type const&) const; - - // Returns true if custom mapping is required. name is - // populated with the custom type name or empty if the - // original name should be used. - // - bool - custom_type (SemanticGraph::Type const&, String& name) const; - - // Returns true if this type has been renamed as part of the - // customization process. If the function returns true, the - // name string is populated with the new name or empty if - // the type should not be generated at all. - // - bool - renamed_type (SemanticGraph::Type const&, String& name) const; - - public: - // Performs a number of processing steps, including forcing a new - // line after 80 characters as well as "commentizing" the text by - // adding '* ' after each newline. - // - void - write_annotation (SemanticGraph::Annotation&); - - // - // - public: - static bool - ordered_p (SemanticGraph::Type const& t) - { - return t.context ().count ("ordered") && - t.context ().get ("ordered"); - } - - // Check if we are generating mixed support for this type. We only - // do it for ordered types. - // - static bool - mixed_p (SemanticGraph::Complex const& c) - { - return c.mixed_p () && ordered_p (c); - } - - bool - polymorphic_p (SemanticGraph::Type&); - - bool - anonymous_p (SemanticGraph::Type const& t) - { - return t.context ().count ("anonymous"); - } - - // Return true if this anonymous type is defined in an element - // that belongs to a substitution group. - // - bool - anonymous_substitutes_p (SemanticGraph::Type&); - - // Escaped names. - // - public: - // Accessor name. - // - static String const& - eaname (SemanticGraph::Member const& m) - { - return m.context ().get ("aname"); - } - - static String const& - eaname (SemanticGraph::Any const& a) - { - return a.context ().get ("aname"); - } - - static String const& - eaname (SemanticGraph::AnyAttribute const& a) - { - return a.context ().get ("aname"); - } - - // Modifier name. - // - static String const& - emname (SemanticGraph::Member const& m) - { - return m.context ().get ("mname"); - } - - static String const& - emname (SemanticGraph::Any const& a) - { - return a.context ().get ("mname"); - } - - static String const& - emname (SemanticGraph::AnyAttribute const& a) - { - return a.context ().get ("mname"); - } - - // Detach name. - // - static String const& - edname (SemanticGraph::Member const& m) - { - return m.context ().get ("dname"); - } - - // - // - static String const& - etype (SemanticGraph::Member const& m) - { - return m.context ().get ("type"); - } - - static String const& - etraits (SemanticGraph::Member const& m) - { - return m.context ().get ("traits"); - } - - static String const& - econtainer (SemanticGraph::Member const& m) - { - return m.context ().get ("container"); - } - - static String const& - econtainer (SemanticGraph::Any const& a) - { - return a.context ().get ("container"); - } - - static String const& - econtainer (SemanticGraph::AnyAttribute const& a) - { - return a.context ().get ("container"); - } - - static String const& - eiterator (SemanticGraph::Member const& m) - { - return m.context ().get ("iterator"); - } - - static String const& - eiterator (SemanticGraph::Any const& a) - { - return a.context ().get ("iterator"); - } - - static String const& - eiterator (SemanticGraph::AnyAttribute const& a) - { - return a.context ().get ("iterator"); - } - - static String const& - econst_iterator (SemanticGraph::Member const& m) - { - return m.context ().get ("const-iterator"); - } - - static String const& - econst_iterator (SemanticGraph::Any const& a) - { - return a.context ().get ("const-iterator"); - } - - static String const& - econst_iterator (SemanticGraph::AnyAttribute const& a) - { - return a.context ().get ("const-iterator"); - } - - static String const& - emember (SemanticGraph::Member const& m) - { - return m.context ().get ("member"); - } - - static String const& - emember (SemanticGraph::Any const& a) - { - return a.context ().get ("member"); - } - - static String const& - emember (SemanticGraph::AnyAttribute const& a) - { - return a.context ().get ("member"); - } - - static String const& - edefault_value (SemanticGraph::Member const& m) - { - return m.context ().get ("default-value"); - } - - static String const& - edefault_value_member (SemanticGraph::Member const& m) - { - return m.context ().get ("default-value-member"); - } - - // Underlying enum value type. - // - static String const& - evalue (SemanticGraph::Enumeration const& e) - { - return e.context ().get ("value"); - } - - // dom_document - // - static bool - edom_document_p (SemanticGraph::Complex const& c) - { - return c.context ().count ("dom-document"); - } - - static String const& - edom_document (SemanticGraph::Complex const& c) - { - return c.context ().get ("dom-document"); - } - - static bool - edom_document_member_p (SemanticGraph::Complex const& c) - { - return c.context ().count ("dom-document-member"); - } - - static String const& - edom_document_member (SemanticGraph::Complex const& c) - { - return c.context ().get ("dom-document-member"); - } - - // Parsing and serialization function names. - // - static String const& - eparser (SemanticGraph::Element const& e) - { - return e.context ().get ("parser"); - } - - static String const& - eserializer (SemanticGraph::Element const& e) - { - return e.context ().get ("serializer"); - } - - public: - void - enter_ns_scope (String const& name) - { - ns_scope_stack.push_back (name); - update_ns_scope (); - } - - void - leave_ns_scope () - { - ns_scope_stack.pop_back (); - update_ns_scope (); - } - - private: - void - update_ns_scope (); - - private: - // Write text that may contain characters that we will have - // to escape (indicated by the rogue flag). - // - void - write_rogue_text (wchar_t const* s, size_t size, bool rogue); - - public: - options_type const& options; - Counts const& counts; - String& any_type; - String& any_simple_type; - String& element_type; - String& container; - String& flags_type; - String& qname_type; - String& xs_string_type; - String& properties_type; - String& error_handler_type; - String& list_stream_type; - String& namespace_infomap_type; - String& parser_type; - String& std_ostream_type; - String& ostream_type; - String& istream_type; - String& xerces_ns; - String& dom_auto_ptr; - String& dom_node_key; - String& as_double_type; - String& as_decimal_type; - - bool& generate_xml_schema; - bool& doxygen; - bool polymorphic; - bool polymorphic_all; - unsigned long poly_plate; - bool detach; - - Regex const* fwd_expr; - Regex const* hxx_expr; - Regex const* ixx_expr; - - String& ns_scope; - - RegexCustomTypeMap& regex_custom_type_map; - DirectCustomTypeMap& direct_custom_type_map; - - private: - String any_type_; - String any_simple_type_; - String element_type_; - String container_; - String flags_type_; - String qname_type_; - String xs_string_type_; - String properties_type_; - String error_handler_type_; - String list_stream_type_; - String namespace_infomap_type_; - String parser_type_; - String std_ostream_type_; - String ostream_type_; - String istream_type_; - String xerces_ns_; - String dom_auto_ptr_; - String dom_node_key_; - String as_double_type_; - String as_decimal_type_; - - bool generate_xml_schema_; - bool doxygen_; - - typedef std::deque NamespaceStack; - typedef std::deque ScopeStack; - - String ns_scope_; - - NamespaceStack& ns_scope_stack; - NamespaceStack ns_scope_stack_; - - RegexCustomTypeMap regex_custom_type_map_; - DirectCustomTypeMap direct_custom_type_map_; - - private: - WideRegexPat const cxx_uq_id_expr_; - WideRegexPat const& cxx_uq_id_expr; - }; - - // Check whether this Schema type maps to a fundamental C++ type. - // - struct IsFundamentalType: Traversal::Fundamental::Byte, - Traversal::Fundamental::UnsignedByte, - Traversal::Fundamental::Short, - Traversal::Fundamental::UnsignedShort, - Traversal::Fundamental::Int, - Traversal::Fundamental::UnsignedInt, - Traversal::Fundamental::Long, - Traversal::Fundamental::UnsignedLong, - Traversal::Fundamental::Integer, - Traversal::Fundamental::NonPositiveInteger, - Traversal::Fundamental::NonNegativeInteger, - Traversal::Fundamental::PositiveInteger, - Traversal::Fundamental::NegativeInteger, - - Traversal::Fundamental::Boolean, - - Traversal::Fundamental::Float, - Traversal::Fundamental::Double, - Traversal::Fundamental::Decimal - - { - IsFundamentalType (bool& r) - : r_ (r) - { - } - - // Integral types. - // - virtual void - traverse (SemanticGraph::Fundamental::Byte&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedByte&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::Short&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedShort&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::Int&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedInt&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::Long&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedLong&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::Integer&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::NonPositiveInteger&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::NonNegativeInteger&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::PositiveInteger&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::NegativeInteger&) - { - r_ = true; - } - - // Boolean. - // - virtual void - traverse (SemanticGraph::Fundamental::Boolean&) - { - r_ = true; - } - - // Floats. - // - virtual void - traverse (SemanticGraph::Fundamental::Float&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::Double&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::Decimal&) - { - r_ = true; - } - - private: - bool& r_; - }; - - // Check whether this is a string-based type. - // - struct IsStringBasedType: Traversal::Complex, - Traversal::Union, - Traversal::Fundamental::String, - Traversal::Fundamental::NormalizedString, - Traversal::Fundamental::Token, - Traversal::Fundamental::Name, - Traversal::Fundamental::NameToken, - Traversal::Fundamental::NCName, - Traversal::Fundamental::Language - { - IsStringBasedType (bool& r) - : r_ (r) - { - *this >> inherits_ >> *this; - } - - virtual void - traverse (SemanticGraph::Complex& c) - { - inherits (c, inherits_); - } - - virtual void - traverse (SemanticGraph::Union&) - { - // Current mapping of union is string-based. - // - r_ = true; - } - - // Strings. - // - virtual void - traverse (SemanticGraph::Fundamental::String&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::NormalizedString&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::Token&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::NameToken&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::Name&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::NCName&) - { - r_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::Language&) - { - r_ = true; - } - - private: - bool& r_; - Traversal::Inherits inherits_; - }; - - - // Check whether this is a enumeration-based type. - // - struct IsEnumBasedType: Traversal::Complex - { - IsEnumBasedType (SemanticGraph::Enumeration*& e) - : enum_ (e) - { - *this >> inherits_; - - inherits_ >> *this; - inherits_ >> enum_; - } - - virtual void - traverse (SemanticGraph::Complex& c) - { - inherits (c, inherits_); - } - - private: - struct Enumeration: Traversal::Enumeration - { - Enumeration (SemanticGraph::Enumeration*& e) - : e_ (e) - { - } - - virtual void - traverse (Type& e) - { - if (e_ == 0) - e_ = &e; - } - - private: - SemanticGraph::Enumeration*& e_; - }; - - - private: - Enumeration enum_; - Traversal::Inherits inherits_; - }; - - - // - // - struct MemberTypeName : Context, - Traversal::Type, - Traversal::List, - Traversal::Union, - Traversal::Complex, - - Traversal::AnyType, - Traversal::AnySimpleType, - - Traversal::Fundamental::Byte, - Traversal::Fundamental::UnsignedByte, - Traversal::Fundamental::Short, - Traversal::Fundamental::UnsignedShort, - Traversal::Fundamental::Int, - Traversal::Fundamental::UnsignedInt, - Traversal::Fundamental::Long, - Traversal::Fundamental::UnsignedLong, - Traversal::Fundamental::Integer, - Traversal::Fundamental::NonPositiveInteger, - Traversal::Fundamental::NonNegativeInteger, - Traversal::Fundamental::PositiveInteger, - Traversal::Fundamental::NegativeInteger, - - Traversal::Fundamental::Boolean, - - Traversal::Fundamental::Float, - Traversal::Fundamental::Double, - Traversal::Fundamental::Decimal, - - Traversal::Fundamental::String, - Traversal::Fundamental::NormalizedString, - Traversal::Fundamental::Token, - Traversal::Fundamental::Name, - Traversal::Fundamental::NameToken, - Traversal::Fundamental::NameTokens, - Traversal::Fundamental::NCName, - Traversal::Fundamental::Language, - - Traversal::Fundamental::QName, - - Traversal::Fundamental::Id, - Traversal::Fundamental::IdRef, - Traversal::Fundamental::IdRefs, - - Traversal::Fundamental::AnyURI, - - Traversal::Fundamental::Base64Binary, - Traversal::Fundamental::HexBinary, - - Traversal::Fundamental::Date, - Traversal::Fundamental::DateTime, - Traversal::Fundamental::Duration, - Traversal::Fundamental::Day, - Traversal::Fundamental::Month, - Traversal::Fundamental::MonthDay, - Traversal::Fundamental::Year, - Traversal::Fundamental::YearMonth, - Traversal::Fundamental::Time, - - Traversal::Fundamental::Entity, - Traversal::Fundamental::Entities - - { - MemberTypeName (Context& c) - : Context (c) - { - } - - MemberTypeName (Context& c, std::wostream& o) - : Context (c, o) - { - } - - virtual void - traverse (SemanticGraph::Type&) - { - abort (); - } - - virtual void - traverse (SemanticGraph::List& l) - { - os << fq_name (l); - } - - virtual void - traverse (SemanticGraph::Union& u) - { - os << fq_name (u); - } - - virtual void - traverse (SemanticGraph::Complex& c) - { - os << fq_name (c); - } - - // anyType & anySimpleType. - // - virtual void - traverse (SemanticGraph::AnyType& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::AnySimpleType& t) - { - os << fq_name (t); - } - - // Integral types. - // - virtual void - traverse (SemanticGraph::Fundamental::Byte& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedByte& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Short& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedShort& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Int& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedInt& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Long& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedLong& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Integer& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::PositiveInteger& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::NegativeInteger& t) - { - os << fq_name (t); - } - - // Boolean. - // - virtual void - traverse (SemanticGraph::Fundamental::Boolean& t) - { - os << fq_name (t); - } - - // Floats. - // - virtual void - traverse (SemanticGraph::Fundamental::Float& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Double& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Decimal& t) - { - os << fq_name (t); - } - - // Strings. - // - virtual void - traverse (SemanticGraph::Fundamental::String& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::NormalizedString& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Token& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::NameToken& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::NameTokens& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Name& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::NCName& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Language& t) - { - os << fq_name (t); - } - - - // Qualified name. - // - virtual void - traverse (SemanticGraph::Fundamental::QName& t) - { - os << fq_name (t); - } - - - // ID/IDREF. - // - virtual void - traverse (SemanticGraph::Fundamental::Id& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::IdRef& t) - { - if (t.named_p ()) - { - // IDREF - // - os << fq_name (t); - } - else - { - SemanticGraph::Nameable& ncname ( - xs_ns ().find ("NCName").first->named ()); - - os << "::xsd::cxx::tree::idref< " << char_type << ", " << - fq_name (ncname) << ", " << - type_name (t.argumented ().type ()) << " >"; - } - } - - virtual void - traverse (SemanticGraph::Fundamental::IdRefs& t) - { - if (t.named_p ()) - { - // IDREFS - // - os << fq_name (t); - } - else - { - SemanticGraph::Nameable& ncname ( - xs_ns ().find ("NCName").first->named ()); - - os << "::xsd::cxx::tree::idrefs< " << char_type << ", " << - any_simple_type << ", ::xsd::cxx::tree::idref< " << - char_type << ", " << fq_name (ncname) << ", " << - type_name (t.argumented ().type ()) << " > >"; - } - } - - // URI. - // - virtual void - traverse (SemanticGraph::Fundamental::AnyURI& t) - { - os << fq_name (t); - } - - // Binary. - // - virtual void - traverse (SemanticGraph::Fundamental::Base64Binary& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::HexBinary& t) - { - os << fq_name (t); - } - - - // Date/time. - // - virtual void - traverse (SemanticGraph::Fundamental::Date& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::DateTime& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Duration& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Day& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Month& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::MonthDay& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Year& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::YearMonth& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Time& t) - { - os << fq_name (t); - } - - // Entity. - // - virtual void - traverse (SemanticGraph::Fundamental::Entity& t) - { - os << fq_name (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Entities& t) - { - os << fq_name (t); - } - - private: - // For idref/idrefs - // - String - type_name (SemanticGraph::Type& t) - { - // This type is always named. - // - std::wostringstream o; - - MemberTypeName type (*this, o); - type.dispatch (t); - - return o.str (); - } - }; - - - // - // - struct BaseTypeName : MemberTypeName - { - BaseTypeName (Context& c) - : MemberTypeName (c) - { - } - - BaseTypeName (Context& c, std::wostream& o) - : MemberTypeName (c, o) - { - } - - virtual void - fundamental_base (SemanticGraph::Type& t) - { - os << "::xsd::cxx::tree::fundamental_base< " << - fq_name (t) << ", " << char_type << ", " << - any_simple_type << " >"; - } - - // Integrals. - // - virtual void - traverse (SemanticGraph::Fundamental::Byte& t) - { - fundamental_base (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedByte& t) - { - fundamental_base (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Short& t) - { - fundamental_base (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedShort& t) - { - fundamental_base (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Int& t) - { - fundamental_base (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedInt& t) - { - fundamental_base (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Long& t) - { - fundamental_base (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedLong& t) - { - fundamental_base (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Integer& t) - { - fundamental_base (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) - { - fundamental_base (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) - { - fundamental_base (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::PositiveInteger& t) - { - fundamental_base (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::NegativeInteger& t) - { - fundamental_base (t); - } - - // Boolean. - // - virtual void - traverse (SemanticGraph::Fundamental::Boolean& t) - { - fundamental_base (t); - } - - // Floats. - // - virtual void - traverse (SemanticGraph::Fundamental::Float& t) - { - fundamental_base (t); - } - - virtual void - traverse (SemanticGraph::Fundamental::Double& t) - { - os << "::xsd::cxx::tree::fundamental_base< " << - fq_name (t) << ", " << char_type << ", " << - any_simple_type << ", " << - "::xsd::cxx::tree::schema_type::double_ >"; - } - - virtual void - traverse (SemanticGraph::Fundamental::Decimal& t) - { - os << "::xsd::cxx::tree::fundamental_base< " << - fq_name (t) << ", " << char_type << ", " << - any_simple_type << ", " << - "::xsd::cxx::tree::schema_type::decimal >"; - } - }; - - // Initial value should be true. - // - struct IsSimpleType: Traversal::Complex, - Traversal::Member, - Traversal::Any, - Traversal::AnyAttribute - { - IsSimpleType (bool& v) - : v_ (v) - { - *this >> names_ >> *this; - *this >> inherits_ >> *this; - } - - virtual void - traverse (SemanticGraph::Complex& c) - { - if (c.mixed_p ()) - v_ = false; - - if (v_) - names (c, names_); - - if (v_) - inherits (c, inherits_); - } - - virtual void - traverse (SemanticGraph::Member&) - { - v_ = false; - } - - virtual void - traverse (SemanticGraph::Any&) - { - v_ = false; - } - - virtual void - traverse (SemanticGraph::AnyAttribute&) - { - v_ = false; - } - - private: - bool& v_; - Traversal::Names names_; - Traversal::Inherits inherits_; - }; - - // Test whether we need to generate default c-tor. Note that we are not - // interested in anyAttribute since it is always mapped to a sequence. - // - struct GenerateDefaultCtor: Traversal::Complex, - Traversal::Enumeration, - Traversal::Type, - Traversal::Element, - Traversal::Attribute, - Traversal::Any, - Context - { - // generate should initially be false. - // - GenerateDefaultCtor (Context&, bool& generate, bool no_base); - - virtual void - traverse (SemanticGraph::Complex&); - - virtual void - traverse (SemanticGraph::Type&); - - virtual void - traverse (SemanticGraph::Enumeration&); - - virtual void - traverse (SemanticGraph::Element&); - - virtual void - traverse (SemanticGraph::Attribute&); - - virtual void - traverse (SemanticGraph::Any&); - - private: - bool& generate_; - bool no_base_; - - private: - Traversal::Inherits inherits_; - Traversal::Names names_; - }; - - // Test whether we need to generate from-base c-tor. - // - struct GenerateFromBaseCtor: Traversal::Complex - { - // generate should initially be false. - // - GenerateFromBaseCtor (Context& c, bool& generate); - - virtual void - traverse (SemanticGraph::Complex& c); - - private: - bool& generate_; - bool custom_; - - // Note that we are not interested in anyAttribute since it is always - // mapped to a sequence. - // - struct Traverser: Traversal::Type, - Traversal::Complex, - Traversal::Element, - Traversal::Attribute, - Traversal::Any, - Context - { - Traverser (Context& c, bool& generate, bool& custom); - - virtual void - traverse (SemanticGraph::Type&); - - virtual void - traverse (SemanticGraph::Complex&); - - virtual void - traverse (SemanticGraph::Attribute&); - - virtual void - traverse (SemanticGraph::Element&); - - virtual void - traverse (SemanticGraph::Any&); - - private: - bool& generate_; - bool& custom_; - - private: - Traversal::Inherits inherits_; - Traversal::Names names_; - } traverser_; - - Traversal::Inherits inherits_; - }; - - // Test whether the type has any non-optional element of complex - // (has attributes/elements) and polymorpjic types. - // - struct HasComplexPolyNonOptArgs: Traversal::Complex, - Traversal::Element, - Context - { - // complex and poly should initially be false. clash - // should initially be true. - // - HasComplexPolyNonOptArgs (Context& c, - bool including_base, - bool& complex, - bool& poly, - bool& clash); - - virtual void - traverse (SemanticGraph::Complex&); - - virtual void - traverse (SemanticGraph::Element&); - - private: - bool& complex_; - bool& poly_; - bool& clash_; - - Traversal::Inherits inherits_; - Traversal::Names names_; - }; - - // Contructor argument types. - // - struct CtorArgType - { - enum Value - { - type, - complex_auto_ptr, - poly_auto_ptr - }; - - CtorArgType (Value v = Value (0)) : v_ (v) {} - operator Value () const {return v_;} - - private: - Value v_; - }; - - // Immediate non-optional member. Note that AnyAttribute is always - // mapped to a sequence. - // - struct FromBaseCtorArg: Traversal::Any, - Traversal::Element, - Traversal::Attribute, - Context - { - FromBaseCtorArg (Context& c, CtorArgType, bool arg); - - virtual void - traverse (SemanticGraph::Any&); - - virtual void - traverse (SemanticGraph::Attribute&); - - virtual void - traverse (SemanticGraph::Element&); - - private: - CtorArgType arg_type_; - bool arg_; - }; - - // List of all non-optional members and a simple base. Note that - // AnyAttribute is always mapped to a sequence. - // - struct CtorArgs: Traversal::Complex, - Traversal::Enumeration, - Traversal::Type, - Traversal::Any, - Traversal::Element, - Traversal::Attribute, - Context - { - // The second version outputs the argument name and stores - // in in the base_arg string. - // - CtorArgs (Context&, CtorArgType); - CtorArgs (Context&, CtorArgType, String& base_arg); - - virtual void - traverse (SemanticGraph::Type&); - - virtual void - traverse (SemanticGraph::Enumeration&); - - virtual void - traverse (SemanticGraph::Any&); - - virtual void - traverse (SemanticGraph::Attribute&); - - virtual void - traverse (SemanticGraph::Element&); - - private: - String - comma (); - - private: - CtorArgType arg_type_; - String base_; - String* base_arg_; - bool first_; - - private: - Traversal::Inherits inherits_; - Traversal::Names names_; - - MemberTypeName member_name_; - }; - - - // Check whether we need to generate c-tor without the base argument. - // - struct GenerateWithoutBaseCtor: Traversal::List, - Traversal::Union, - Traversal::Complex, - Traversal::Enumeration, - - Traversal::AnyType, - Traversal::AnySimpleType, - - Traversal::Fundamental::String, - Traversal::Fundamental::NormalizedString, - Traversal::Fundamental::Token, - - Traversal::Fundamental::NameTokens, - Traversal::Fundamental::IdRefs, - - Traversal::Fundamental::Base64Binary, - Traversal::Fundamental::HexBinary - { - // generate should initially be false. - // - GenerateWithoutBaseCtor (bool& generate) - : generate_ (generate) - { - *this >> inherits_ >> *this; - } - - virtual void - traverse (SemanticGraph::List&) - { - generate_ = true; - } - - virtual void - traverse (SemanticGraph::Union&) - { - // No default initialization. - } - - virtual void - traverse (SemanticGraph::Complex& c) - { - Complex::inherits (c); - } - - virtual void - traverse (SemanticGraph::Enumeration&) - { - // No default initialization. - } - - virtual void - traverse (SemanticGraph::AnyType&) - { - generate_ = true; - } - - virtual void - traverse (SemanticGraph::AnySimpleType&) - { - generate_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::String&) - { - generate_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::NormalizedString&) - { - generate_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::Token&) - { - generate_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::NameTokens&) - { - generate_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::IdRefs&) - { - generate_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::Base64Binary&) - { - generate_ = true; - } - - virtual void - traverse (SemanticGraph::Fundamental::HexBinary&) - { - generate_ = true; - } - - private: - bool& generate_; - Traversal::Inherits inherits_; - }; - - - // List of all non-optional members sans simple base. Note that - // AnyAttribute is always mapped to a sequence. - // - struct CtorArgsWithoutBase: Traversal::Complex, - Traversal::Any, - Traversal::Element, - Traversal::Attribute, - Context - { - CtorArgsWithoutBase (Context& c, CtorArgType, bool arg, bool first); - - virtual void - traverse (SemanticGraph::Any&); - - virtual void - traverse (SemanticGraph::Element&); - - virtual void - traverse (SemanticGraph::Attribute&); - - private: - String - comma (); - - private: - CtorArgType arg_type_; - bool arg_; - bool first_; - - private: - Traversal::Inherits inherits_; - Traversal::Names names_; - }; - - // - // - struct GlobalElementBase - { - GlobalElementBase (Context& c) - : ctx_ (c) - { - } - - bool - generate_p (SemanticGraph::Element&); - - bool - doc_root_p (SemanticGraph::Element&); - - private: - Context& ctx_; - }; - - - // - // - struct Namespace: CXX::Namespace, - GlobalElementBase, - CXX::Namespace::ScopeTracker - { - Namespace (Context&, - size_t first = 1, - size_t last = 0); - - virtual void - traverse (Type&); - - protected: - virtual void - enter (Type&, String const& name, bool last); - - virtual void - leave (); - - protected: - Context& ctx_; - - private: - size_t first_; - size_t last_; - size_t count_; - }; - - // - // - struct DocumentedNamespace: Namespace - { - DocumentedNamespace (Context& c) - : Namespace (c) - { - } - - virtual void - enter (Type& ns, String const& name, bool last) - { - Namespace::enter (ns, name, last); - - // Only add documentation to the innermost namespace. - // - if (ctx_.doxygen && name && last) - { - ctx_.os << "/**" << endl - << " * @brief C++ namespace for the %" << - ctx_.comment (ns.name ()) << endl - << " * schema namespace." << endl - << " */" << endl; - } - } - }; - - // - // - struct TypeForward: Traversal::Type, Context - { - TypeForward (Context& c) - : Context (c) - { - } - - virtual void - traverse (SemanticGraph::Type& t); - }; - - struct Includes: Traversal::Imports, - Traversal::Includes - { - enum Type - { - forward, - header, - inline_, - source - }; - - Includes (Context& c, Type type) - : ctx_ (c), - type_ (type), - forward_ (c.options.generate_forward ()), - namespace_ (c), - type_forward_ (c) - { - schema_ >> schema_names_ >> namespace_ >> names_ >> type_forward_; - } - - virtual void - traverse (SemanticGraph::Imports& i) - { - traverse_ (i); - } - - virtual void - traverse (SemanticGraph::Includes& i) - { - traverse_ (i); - } - - private: - void - traverse_ (SemanticGraph::Uses&); - - private: - Context& ctx_; - Type type_; - bool forward_; - - Traversal::Schema schema_; - Traversal::Names schema_names_; - Namespace namespace_; - Traversal::Names names_; - TypeForward type_forward_; - }; - - // - // - struct FundIncludes: Traversal::Fundamental::Byte, - Traversal::Fundamental::UnsignedByte, - Traversal::Fundamental::Short, - Traversal::Fundamental::UnsignedShort, - Traversal::Fundamental::Int, - Traversal::Fundamental::UnsignedInt, - Traversal::Fundamental::Long, - Traversal::Fundamental::UnsignedLong, - Traversal::Fundamental::Integer, - Traversal::Fundamental::NonPositiveInteger, - Traversal::Fundamental::NonNegativeInteger, - Traversal::Fundamental::PositiveInteger, - Traversal::Fundamental::NegativeInteger, - - Traversal::Fundamental::Boolean, - - Traversal::Fundamental::Float, - Traversal::Fundamental::Double, - Traversal::Fundamental::Decimal, - Context - { - FundIncludes (Context& c, String const& prefix) - : Context (c), prefix_ (prefix), - long_ (false), unsigned_long_ (false) - { - } - - // Integral types. - // - virtual void - traverse (SemanticGraph::Fundamental::Byte& t) - { - gen_include (t, "byte.hxx"); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedByte& t) - { - gen_include (t, "unsigned-byte.hxx"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Short& t) - { - gen_include (t, "short.hxx"); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedShort& t) - { - gen_include (t, "unsigned-short.hxx"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Int& t) - { - gen_include (t, "int.hxx"); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedInt& t) - { - gen_include (t, "unsigned-int.hxx"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Long& t) - { - if (!long_) - long_ = gen_include (t, "long.hxx"); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedLong& t) - { - if (!unsigned_long_) - unsigned_long_ = gen_include (t, "unsigned-long.hxx"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Integer& t) - { - if (!long_) - long_ = gen_include (t, "long.hxx"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) - { - if (!long_) - long_ = gen_include (t, "long.hxx"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) - { - if (!unsigned_long_) - unsigned_long_ = gen_include (t, "unsigned-long.hxx"); - } - - virtual void - traverse (SemanticGraph::Fundamental::PositiveInteger& t) - { - if (!unsigned_long_) - unsigned_long_ = gen_include (t, "unsigned-long.hxx"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NegativeInteger& t) - { - if (!long_) - long_ = gen_include (t, "long.hxx"); - } - - // Boolean. - // - virtual void - traverse (SemanticGraph::Fundamental::Boolean& t) - { - gen_include (t, "boolean.hxx"); - } - - // Floats. - // - virtual void - traverse (SemanticGraph::Fundamental::Float& t) - { - gen_include (t, "float.hxx"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Double& t) - { - gen_include (t, "double.hxx"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Decimal& t) - { - gen_include (t, "decimal.hxx"); - } - - private: - bool - gen_include (SemanticGraph::Type& t, String const& file) - { - String custom; - - // XML Schema built-in type customization is only possible when - // we are generating separate header. - // - if (generate_xml_schema && custom_type (t, custom)) - { - String new_name; - renamed_type (t, new_name); - - if (!new_name) - return false; - } - - os << "#include " - << endl; - - return true; - } - - private: - String prefix_; - bool long_; - bool unsigned_long_; - }; - } -} - -#endif // CXX_TREE_ELEMENTS_HXX diff --git a/xsd/cxx/tree/fundamental-header.hxx b/xsd/cxx/tree/fundamental-header.hxx deleted file mode 100644 index e553d29..0000000 --- a/xsd/cxx/tree/fundamental-header.hxx +++ /dev/null @@ -1,1335 +0,0 @@ -// file : xsd/cxx/tree/fundamental-header.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_TREE_FUNDAMENTAL_HEADER_HXX -#define CXX_TREE_FUNDAMENTAL_HEADER_HXX - -#include -#include -#include - -#include -#include - -#include - -namespace CXX -{ - namespace Tree - { - struct FundamentalNamespace : DocumentedNamespace, - - Traversal::AnyType, - Traversal::AnySimpleType, - - Traversal::Fundamental::Byte, - Traversal::Fundamental::UnsignedByte, - Traversal::Fundamental::Short, - Traversal::Fundamental::UnsignedShort, - Traversal::Fundamental::Int, - Traversal::Fundamental::UnsignedInt, - Traversal::Fundamental::Long, - Traversal::Fundamental::UnsignedLong, - Traversal::Fundamental::Integer, - Traversal::Fundamental::NonPositiveInteger, - Traversal::Fundamental::NonNegativeInteger, - Traversal::Fundamental::PositiveInteger, - Traversal::Fundamental::NegativeInteger, - - Traversal::Fundamental::Boolean, - - Traversal::Fundamental::Float, - Traversal::Fundamental::Double, - Traversal::Fundamental::Decimal, - - Traversal::Fundamental::String, - Traversal::Fundamental::NormalizedString, - Traversal::Fundamental::Token, - Traversal::Fundamental::Name, - Traversal::Fundamental::NameToken, - Traversal::Fundamental::NameTokens, - Traversal::Fundamental::NCName, - Traversal::Fundamental::Language, - - Traversal::Fundamental::Id, - Traversal::Fundamental::IdRef, - Traversal::Fundamental::IdRefs, - - Traversal::Fundamental::AnyURI, - - Traversal::Fundamental::QName, - - Traversal::Fundamental::Base64Binary, - Traversal::Fundamental::HexBinary, - - Traversal::Fundamental::Date, - Traversal::Fundamental::DateTime, - Traversal::Fundamental::Duration, - Traversal::Fundamental::Day, - Traversal::Fundamental::Month, - Traversal::Fundamental::MonthDay, - Traversal::Fundamental::Year, - Traversal::Fundamental::YearMonth, - Traversal::Fundamental::Time, - - Traversal::Fundamental::Entity, - Traversal::Fundamental::Entities, - Context - { - FundamentalNamespace (Context& c) - : DocumentedNamespace (c), - Context (c), - export_ (c.options.export_xml_schema () && type_exp) - { - *this >> names_ >> *this; - - if (export_) - xs_ns_ = ns_name (xs_ns ()); - } - - void - gen_typedef (String const& name, - String const& type, - String const& arg1 = L"", - String const& arg2 = L"", - String const& arg3 = L"", - bool export_type = true) - { - os << "typedef " << type; - - // Use unqualified arguments since we are in the same - // namespace. - // - if (arg1) - { - os << arg1; - - if (arg2) - { - os << ", " << arg2; - - if (arg3) - os << ", " << arg3; - } - - os << " >"; - } - - os << " " << name << ";"; - - if (export_type && export_ && type.find (L'<') != String::npos) - { - String s (type); - - // Use qualified arguments. - // - if (arg1) - { - s += xs_ns_; - s += L"::"; - s += arg1; - - if (arg2) - { - s += L", "; - s += xs_ns_; - s += L"::"; - s += arg2; - - if (arg3) - { - s += L", "; - s += xs_ns_; - s += L"::"; - s += arg3; - } - } - - s += " >"; - } - - if (exports_set_.count (s) == 0) - { - exports_.push_back (s); - exports_set_.insert (s); - } - } - } - - String - built_in_type (SemanticGraph::Type& t, - String const& type, - String const& arg1 = L"", - String const& arg2 = L"", - String const& arg3 = L"") - { - String custom; - - String name (ename (t)); - - // XML Schema built-in type customization is only possible when - // we are generating separate header. - // - if (generate_xml_schema && custom_type (t, custom)) - { - if (custom.empty ()) - custom = name; - - String new_name; - renamed_type (t, new_name); - - if (new_name) - { - gen_typedef (new_name, type, arg1, arg2, arg3); - - if (doxygen) - os << endl; - } - - if (doxygen) - os << "/**" << endl - << " * @brief C++ type corresponding to the " << - comment (t.name ()) << " XML Schema" << endl - << " * built-in type." << endl - << " */" << endl; - - if (custom == name) - os << "class " << name << ";"; - else - os << "typedef " << custom << " " << name << ";"; - - if (doxygen) - os << endl; - } - else - { - // Otherwise generate simple typedef. - // - - if (doxygen) - os << "/**" << endl - << " * @brief C++ type corresponding to the " << - comment (t.name ()) << " XML Schema" << endl - << " * built-in type." << endl - << " */" << endl; - - gen_typedef (name, type, arg1, arg2, arg3); - - if (doxygen) - os << endl; - } - - return name; - } - - // anyType and anySimpleType - // - virtual void - traverse (SemanticGraph::AnyType& t) - { - os << "// anyType and anySimpleType." << endl - << "//" << endl; - - if (doxygen) - os << endl; - - type_ = built_in_type (t, "::xsd::cxx::tree::type"); - } - - virtual void - traverse (SemanticGraph::AnySimpleType& t) - { - simple_type_ = built_in_type ( - t, L"::xsd::cxx::tree::simple_type< " + char_type + L", ", type_); - - if (doxygen) - os << "/**" << endl - << " * @brief Alias for the anyType type." << endl - << " */" << endl; - - gen_typedef (xs_ns ().context().get ("container"), - "::xsd::cxx::tree::type"); - - os << endl; - - if (doxygen) - os << endl; - } - - // Integrals. - // - virtual void - traverse (SemanticGraph::Fundamental::Byte& t) - { - os << "// 8-bit" << endl - << "//" << endl; - - if (doxygen) - os << endl; - - built_in_type (t, "signed char"); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedByte& t) - { - built_in_type (t, "unsigned char"); - os << endl; - } - - virtual void - traverse (SemanticGraph::Fundamental::Short& t) - { - os << "// 16-bit" << endl - << "//" << endl; - - if (doxygen) - os << endl; - - built_in_type (t, "short"); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedShort& t) - { - built_in_type (t, "unsigned short"); - os << endl; - } - - virtual void - traverse (SemanticGraph::Fundamental::Int& t) - { - os << "// 32-bit" << endl - << "//" << endl; - - if (doxygen) - os << endl; - - built_in_type (t, "int"); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedInt& t) - { - built_in_type (t, "unsigned int"); - os << endl; - } - - virtual void - traverse (SemanticGraph::Fundamental::Long& t) - { - os << "// 64-bit" << endl - << "//" < ("buffer"), - L"::xsd::cxx::tree::buffer< " + char_type + L" >"); - - if (doxygen) - os << endl; - - built_in_type ( - t, - L"::xsd::cxx::tree::base64_binary< " + char_type + L", ", - simple_type_); - } - - virtual void - traverse (SemanticGraph::Fundamental::HexBinary& t) - { - built_in_type ( - t, - L"::xsd::cxx::tree::hex_binary< " + char_type + L", ", - simple_type_); - - os << endl; - } - - - // Date/time. - // - virtual void - traverse (SemanticGraph::Fundamental::Date& t) - { - os << "// Date/time." << endl - << "//" << endl; - - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Time zone type." << endl - << " */" << endl; - - gen_typedef (xs_ns ().context().get ("time-zone"), - "::xsd::cxx::tree::time_zone"); - - if (doxygen) - os << endl; - - built_in_type ( - t, L"::xsd::cxx::tree::date< " + char_type + L", ", simple_type_); - } - - virtual void - traverse (SemanticGraph::Fundamental::DateTime& t) - { - built_in_type ( - t, - L"::xsd::cxx::tree::date_time< " + char_type + L", ", - simple_type_); - } - - virtual void - traverse (SemanticGraph::Fundamental::Duration& t) - { - built_in_type ( - t, - L"::xsd::cxx::tree::duration< " + char_type + L", ", - simple_type_); - } - - virtual void - traverse (SemanticGraph::Fundamental::Day& t) - { - built_in_type ( - t, L"::xsd::cxx::tree::gday< " + char_type + L", ", simple_type_); - } - - virtual void - traverse (SemanticGraph::Fundamental::Month& t) - { - built_in_type ( - t, L"::xsd::cxx::tree::gmonth< " + char_type + L", ", simple_type_); - } - - virtual void - traverse (SemanticGraph::Fundamental::MonthDay& t) - { - built_in_type ( - t, - L"::xsd::cxx::tree::gmonth_day< " + char_type + L", ", - simple_type_); - } - - virtual void - traverse (SemanticGraph::Fundamental::Year& t) - { - built_in_type ( - t, L"::xsd::cxx::tree::gyear< " + char_type + L", ", simple_type_); - } - - virtual void - traverse (SemanticGraph::Fundamental::YearMonth& t) - { - built_in_type ( - t, - L"::xsd::cxx::tree::gyear_month< " + char_type + L", ", - simple_type_); - } - - virtual void - traverse (SemanticGraph::Fundamental::Time& t) - { - built_in_type ( - t, L"::xsd::cxx::tree::time< " + char_type + L", ", simple_type_); - - os << endl; - } - - // Entity. - // - virtual void - traverse (SemanticGraph::Fundamental::Entity& t) - { - os << "// Entity." << endl - << "//" << endl; - - if (doxygen) - os << endl; - - entity_ = built_in_type ( - t, L"::xsd::cxx::tree::entity< " + char_type + L", ", ncname_); - } - - virtual void - traverse (SemanticGraph::Fundamental::Entities& t) - { - built_in_type ( - t, - L"::xsd::cxx::tree::entities< " + char_type + L", ", - simple_type_, - entity_); - - os << endl; - } - - virtual void - post (SemanticGraph::Namespace& n) - { - SemanticGraph::Context& c (xs_ns ().context()); - - bool parsing (!options.suppress_parsing ()); - bool serialization (options.generate_serialization ()); - bool element_map (options.generate_element_map ()); - - { - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Content order sequence entry." << endl - << " */" << endl; - - gen_typedef (c.get ("content-order"), - "::xsd::cxx::tree::content_order"); - } - - if (options.generate_element_type ()) - { - if (doxygen) - os << "/**" << endl - << " * @brief Base class for element types." << endl - << " */" << endl; - else - os << "// Base class for element types." << endl - << "//" << endl; - - gen_typedef ( - c.get ("element-type"), - L"::xsd::cxx::tree::element_type< " + char_type + L", ", - type_); - - os << endl; - } - - if (element_map) - { - if (doxygen) - os << "/**" << endl - << " * @brief Root element map." << endl - << " */" << endl; - else - os << "// Root element map." << endl - << "//" << endl; - - gen_typedef ( - c.get ("element-map"), - L"::xsd::cxx::tree::element_map< " + char_type + L", ", - type_); - - os << endl; - } - - if (serialization) - { - os << "// Namespace information and list stream. Used in" << endl - << "// serialization functions." << endl - << "//" << endl; - - if (doxygen) - os << "/**" << endl - << " * @brief Namespace serialization information." << endl - << " */" << endl; - - gen_typedef ( - c.get ("namespace-info"), - L"::xsd::cxx::xml::dom::namespace_info< " + char_type + L" >"); - - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Namespace serialization information map." << endl - << " */" << endl; - - gen_typedef (c.get ("namespace-infomap"), - L"::xsd::cxx::xml::dom::namespace_infomap< " + - char_type + L" >"); - - if (doxygen) - os << endl - << "/**" << endl - << " * @brief List serialization stream." << endl - << " */" << endl; - - gen_typedef ( - c.get ("list-stream"), - L"::xsd::cxx::tree::list_stream< " + char_type + L" >"); - - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Serialization wrapper for the %double type." << endl - << " */" << endl; - - // Do not export as_double and as_decimal since they are already - // instantiated. - // - gen_typedef (c.get ("as-double"), - L"::xsd::cxx::tree::as_double< ", - double_, - "", - "", - false); - - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Serialization wrapper for the %decimal type." << endl - << " */" << endl; - - gen_typedef (c.get ("as-decimal"), - L"::xsd::cxx::tree::as_decimal< ", - decimal_, - "", - "", - false); - - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Simple type facet." << endl - << " */" << endl; - - gen_typedef (c.get ("facet"), "::xsd::cxx::tree::facet"); - - os << endl; - } - - //@@ Can't change names of ostream/istream since they are - // templates. - // - if (!options.generate_insertion ().empty ()) - { - if (doxygen) - os << "/**" << endl - << " * @brief Data representation output stream template." << endl - << " */" << endl; - else - os << "// Data representation output stream template." << endl - << "//" << endl; - - os << "using ::xsd::cxx::tree::ostream;" - << endl; - } - - if (!options.generate_extraction ().empty ()) - { - if (doxygen) - os << "/**" << endl - << " * @brief Data representation input stream template." << endl - << " */" << endl; - else - os << "// Data representation input stream template." << endl - << "//" << endl; - - os << "using ::xsd::cxx::tree::istream;" - << endl; - } - - os << "// Flags and properties." << endl - << "//" << endl; - - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Parsing and serialization flags." << endl - << " */" << endl; - - gen_typedef (c.get ("flags"), "::xsd::cxx::tree::flags"); - - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Parsing properties." << endl - << " */" << endl; - - gen_typedef (c.get ("properties"), - L"::xsd::cxx::tree::properties< " + char_type + L" >"); - os << endl; - - - // - // - if (parsing || serialization) - { - os << "// Parsing/serialization diagnostics." << endl - << "//" << endl; - - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Error severity." << endl - << " */" << endl; - - gen_typedef (c.get ("severity"), - "::xsd::cxx::tree::severity"); - - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Error condition." << endl - << " */" << endl; - - gen_typedef (c.get ("error"), - L"::xsd::cxx::tree::error< " + char_type + L" >"); - - if (doxygen) - os << endl - << "/**" << endl - << " * @brief List of %error conditions." << endl - << " */" << endl; - - gen_typedef (c.get ("diagnostics"), - L"::xsd::cxx::tree::diagnostics< " + char_type + L" >"); - os << endl; - } - - // - // - os << "// Exceptions." << endl - << "//" << endl; - - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Root of the C++/Tree %exception hierarchy." << endl - << " */" << endl; - - gen_typedef (c.get ("exception"), - L"::xsd::cxx::tree::exception< " + char_type + L" >"); - - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Exception indicating that the size argument exceeds" << - endl - << " * the capacity argument." << endl - << " */" << endl; - - gen_typedef (c.get ("bounds"), - L"::xsd::cxx::tree::bounds< " + char_type + L" >"); - - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Exception indicating that a duplicate ID value" << - endl - << " * was encountered in the object model." << endl - << " */" << endl; - - gen_typedef (c.get ("duplicate-id"), - L"::xsd::cxx::tree::duplicate_id< " + char_type + L" >"); - - if (parsing) - { - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Exception indicating a parsing failure." << endl - << " */" << endl; - - gen_typedef (c.get ("parsing"), - L"::xsd::cxx::tree::parsing< " + char_type + L" >"); - - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Exception indicating that an expected element" << - endl - << " * was not encountered." << endl - << " */" << endl; - - gen_typedef ( - c.get ("expected-element"), - L"::xsd::cxx::tree::expected_element< " + char_type + L" >"); - } - - if (parsing || serialization) - { - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Exception indicating that an unexpected " << - "element" << endl - << " * was encountered." << endl - << " */" << endl; - - gen_typedef ( - c.get ("unexpected-element"), - L"::xsd::cxx::tree::unexpected_element< " + char_type + L" >"); - } - - if (parsing) - { - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Exception indicating that an expected " << - "attribute" << endl - << " * was not encountered." << endl - << " */" << endl; - - gen_typedef ( - c.get ("expected-attribute"), - L"::xsd::cxx::tree::expected_attribute< " + char_type + L" >"); - - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Exception indicating that an unexpected " << - "enumerator" << endl - << " * was encountered." << endl - << " */" << endl; - - gen_typedef ( - c.get ("unexpected-enumerator"), - L"::xsd::cxx::tree::unexpected_enumerator< " + char_type + L" >"); - - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Exception indicating that the text content " << - "was" << endl - << " * expected for an element." << endl - << " */" << endl; - - gen_typedef ( - c.get ("expected-text-content"), - L"::xsd::cxx::tree::expected_text_content< " + char_type + L" >"); - - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Exception indicating that a prefix-namespace" << - endl - << " * mapping was not provided." << endl - << " */" << endl; - - gen_typedef ( - c.get ("no-prefix-mapping"), - L"::xsd::cxx::tree::no_prefix_mapping< " + char_type + L" >"); - } - - if (options.generate_polymorphic ()) - { - if (parsing || serialization) - { - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Exception indicating that the type " << - "information" << endl - << " * is not available for a type." << endl - << " */" << endl; - - gen_typedef ( - c.get ("no-type-info"), - L"::xsd::cxx::tree::no_type_info< " + char_type + L" >"); - } - - if (parsing) - { - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Exception indicating that the types are not" << - endl - << " * related by inheritance." << endl - << " */" << endl; - - gen_typedef ( - c.get ("not-derived"), - L"::xsd::cxx::tree::not_derived< " + char_type + L" >"); - } - } - - if (element_map) - { - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Exception indicating that parsing or " << - "serialization" << endl - << " * information is not available for an element." << endl - << " */" << endl; - - gen_typedef ( - c.get ("no-element-info"), - L"::xsd::cxx::tree::no_element_info< " + char_type + L" >"); - } - - if (serialization) - { - if (doxygen) - os << endl - << "/**" << endl - << " * @brief Exception indicating a serialization " << - "failure." << endl - << " */" << endl; - - gen_typedef ( - c.get ("serialization"), - L"::xsd::cxx::tree::serialization< " + char_type + L" >"); - } - - os << endl; - - if (parsing || serialization) - { - if (doxygen) - os << "/**" << endl - << " * @brief Error handler callback interface." << endl - << " */" << endl; - else - os << "// Error handler callback interface." << endl - << "//" << endl; - - gen_typedef ( - c.get ("error-handler"), - L"::xsd::cxx::xml::error_handler< " + char_type + L" >"); - - os << endl; - } - - if (parsing || serialization) - { - if (doxygen) - os << "/**" << endl - << " * @brief DOM interaction." << endl - << " */" << endl; - else - os << "// DOM interaction." << endl - << "//" << endl; - - os << "namespace dom" - << "{"; - - // @@ Disregarding current naming convention by using the - // fixed name (even in C++11, template alias is not yet - // widely supported). - // - if (doxygen) - os << "/**" << endl - << " * @brief Automatic pointer for DOMDocument." << endl - << " */" << endl; - else - os << "// Automatic pointer for DOMDocument." << endl - << "//" << endl; - - if (std >= cxx_version::cxx11) - os << "using ::xsd::cxx::xml::dom::unique_ptr;"; - else - os << "using ::xsd::cxx::xml::dom::auto_ptr;"; - - os << endl; - - if (parsing) - { - if (!generate_xml_schema) - { - String g (L"XSD_CXX_TREE_TREE_NODE_KEY" + ns_name (n)); - - std::transform (g.begin (), g.end(), g.begin (), upcase); - g = escape (g); // Make it a C++ id. - - os << "#ifndef " << g << endl - << "#define " << g << endl; - } - - if (doxygen) - os << "/**" << endl - << " * @brief DOM user data key for back pointers to " << - "tree nodes." << endl - << " */" << endl; - else - os << "// DOM user data key for back pointers to tree nodes." << endl - << "//" << endl; - - os << "const XMLCh* const " << c.get ("tree-node-key") << - " = ::xsd::cxx::tree::user_data_keys::node;"; - - if (!generate_xml_schema) - os << "#endif" << endl; - } - - os << "}"; // namespace dom - } - - if (element_map) - { - if (doxygen) - os << "//@cond" << endl - << endl; - - if (!generate_xml_schema) - { - String g (L"XSD_CXX_TREE_ELEMENT_MAP_INIT" + ns_name (n)); - - std::transform (g.begin (), g.end(), g.begin (), upcase); - g = escape (g); // Make it a C++ id. - - os << "#ifndef " << g << endl - << "#define " << g << endl; - } - - os << "static" << endl - << "const ::xsd::cxx::tree::element_map_init< " << - char_type << ", " << type_ << " >" << endl - << "_xsd_element_map_init;"; - - if (!generate_xml_schema) - os << "#endif" << endl; - - if (doxygen) - os << endl - << "//@endcond" << endl; - } - - Namespace::post (n); - - // Generate exports. - // - if (export_) - { - StringSet ns_set; - - for (StringList::const_iterator i (exports_.begin ()); - i != exports_.end (); ++i) - { - String const& e (*i); - - // 12 is to skip ::xsd::cxx:: - // - ns_set.insert (String (e, 12, e.rfind (':', e.find ('<')) - 13)); - } - - os << "#ifndef XSD_NO_EXPORT" << endl - << endl - << "namespace xsd" - << "{" - << "namespace cxx" - << "{"; - - for (StringSet::const_iterator i (ns_set.begin ()); - i != ns_set.end (); ++i) - { - String const& ns (*i); - String prefix (L"::xsd::cxx::" + ns); - - size_t n (1); - for (size_t b (0), e (ns.find (':')); ; n++) - { - os << "namespace " << String (ns, b, e) - << "{"; - - if (e == String::npos) - break; - - b = e + 2; - e = ns.find (':', b); - } - - for (StringList::const_iterator i (exports_.begin ()); - i != exports_.end (); ++i) - { - String const& e (*i); - String ens (e, 12, e.rfind (':', e.find ('<')) - 13); - - if (ns == ens) - { - String type (e, e.rfind (':', e.find ('<')) + 1); - os << "template class " << type_exp << type << ";"; - } - } - - while (n--) - os << "}"; - } - - os << "}" // cxx - << "}" // xsd - << "#endif // XSD_NO_EXPORT" << endl - << endl; - } - } - - private: - typedef std::set StringSet; - typedef std::vector StringList; - - bool export_; - StringList exports_; - StringSet exports_set_; - String xs_ns_; - - Traversal::Names names_; - - String type_; - String simple_type_; - String string_; - String norm_string_; - String token_; - String nmtoken_; - String name_; - String ncname_; - String idref_; - String uri_; - String entity_; - - String double_; - String decimal_; - }; - } -} - -#endif // CXX_TREE_FUNDAMENTAL_HEADER_HXX diff --git a/xsd/cxx/tree/generator.cxx b/xsd/cxx/tree/generator.cxx deleted file mode 100644 index edf5523..0000000 --- a/xsd/cxx/tree/generator.cxx +++ /dev/null @@ -1,1227 +0,0 @@ -// file : xsd/cxx/tree/generator.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include - -#include - -#include "../../../libxsd/xsd/cxx/version.hxx" - -using namespace std; -using namespace cutl; -using namespace XSDFrontend::SemanticGraph; - -// -// -typedef std::wifstream WideInputFileStream; -typedef std::wofstream WideOutputFileStream; - -namespace CXX -{ - namespace - { - char const copyright_gpl[] = - "// Copyright (c) 2005-2020 Code Synthesis Tools CC.\n" - "//\n" - "// This program was generated by CodeSynthesis XSD, an XML Schema to\n" - "// C++ data binding compiler.\n" - "//\n" - "// This program is free software; you can redistribute it and/or modify\n" - "// it under the terms of the GNU General Public License version 2 as\n" - "// published by the Free Software Foundation.\n" - "//\n" - "// This program is distributed in the hope that it will be useful,\n" - "// but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - "// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" - "// GNU General Public License for more details.\n" - "//\n" - "// You should have received a copy of the GNU General Public License\n" - "// along with this program; if not, write to the Free Software\n" - "// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n" - "//\n" - "// In addition, as a special exception, Code Synthesis Tools CC gives\n" - "// permission to link this program with the Xerces-C++ library (or with\n" - "// modified versions of Xerces-C++ that use the same license as Xerces-C++),\n" - "// and distribute linked combinations including the two. You must obey\n" - "// the GNU General Public License version 2 in all respects for all of\n" - "// the code used other than Xerces-C++. If you modify this copy of the\n" - "// program, you may extend this exception to your version of the program,\n" - "// but you are not obligated to do so. If you do not wish to do so, delete\n" - "// this exception statement from your version.\n" - "//\n" - "// Furthermore, Code Synthesis Tools CC makes a special exception for\n" - "// the Free/Libre and Open Source Software (FLOSS) which is described\n" - "// in the accompanying FLOSSE file.\n" - "//\n\n"; - - char const copyright_proprietary[] = - "// Copyright (c) 2005-2020 Code Synthesis Tools CC.\n" - "//\n" - "// This program was generated by CodeSynthesis XSD, an XML Schema\n" - "// to C++ data binding compiler, in the Proprietary License mode.\n" - "// You should have received a proprietary license from Code Synthesis\n" - "// Tools CC prior to generating this code. See the license text for\n" - "// conditions.\n" - "//\n\n"; - } - - void Tree::Generator:: - usage () - { - CXX::Tree::options::print_usage (wcout); - CXX::options::print_usage (wcout); - } - - namespace - { - void - open (WideInputFileStream& ifs, NarrowString const& path) - { - try - { - Path fs_path (path); - ifs.open (fs_path.string ().c_str (), - std::ios_base::in | std::ios_base::binary); - - if (!ifs.is_open ()) - { - wcerr << path.c_str () << ": error: unable to open in read mode" - << endl; - - throw Tree::Generator::Failed (); - } - } - catch (InvalidPath const&) - { - wcerr << "error: '" << path.c_str () << "' is not a valid " - << "filesystem path" << endl; - - throw Tree::Generator::Failed (); - } - } - - void - append (WideOutputFileStream& os, - NarrowString const& path, - WideInputFileStream& default_is) - { - using std::ios_base; - - if (path) - { - WideInputFileStream is; - open (is, path); - os << is.rdbuf (); - } - else if (default_is.is_open ()) - { - os << default_is.rdbuf (); - default_is.seekg (0, ios_base::beg); - } - } - - void - append (WideOutputFileStream& os, - NarrowStrings const& primary, - NarrowStrings const& def) - { - NarrowStrings const& v (primary.empty () ? def : primary); - - for (NarrowStrings::const_iterator i (v.begin ()), e (v.end ()); - i != e; ++i) - { - os << i->c_str () << endl; - } - } - } - - - size_t Tree::Generator:: - generate (Tree::options const& ops, - Schema& schema, - Path const& file_path, - bool fpt, - StringLiteralMap const& string_literal_map, - const WarningSet& disabled_warnings, - FileList& file_list, - AutoUnlinks& unlinks) - { - using cutl::shared_ptr; - typedef cutl::re::regexsub Regex; - - typedef vector Paths; - typedef vector > WideOutputFileStreams; - - try - { - // Do option validation. - // - if (ops.parts () < 1) - { - wcerr << "error: invalid value for option --parts: " << - ops.parts () << endl; - throw Failed (); - } - - // Get counts. - // - Counts counts; - { - Counter counter; - counts = counter.count (ops, schema, file_path); - - /* - wcerr << "global type count: " << counts.global_types << endl; - wcerr << "global element count: " << counts.global_elements << endl; - wcerr << "generated global element count: " << - counts.generated_global_elements << endl; - - wcerr << "total complexity: " << counts.complexity_total << endl; - wcerr << "complexity vector size: " << counts.complexity.size () - << endl; - */ - } - - // Evaluate the graph for possibility of generating something useful. - // - { - Validator validator; - if (!validator.validate ( - ops, schema, file_path, disabled_warnings, counts)) - throw Failed (); - } - - bool gen_cxx (!ops.generate_dep_only ()); - - // Process ordered types. - // - if (gen_cxx) - { - OrderProcessor proc; - if (!proc.process (ops, schema, file_path)) - throw Failed (); - } - - // Process names. - // - if (gen_cxx) - { - NameProcessor proc; - if (!proc.process (ops, schema, file_path, string_literal_map)) - throw Failed (); - } - - // Process polymorphic types. - // - if (gen_cxx && - ops.generate_polymorphic () && - !ops.polymorphic_type_all ()) - { - PolymorphismProcessor proc; - if (!proc.process (ops, schema, file_path, disabled_warnings)) - throw Failed (); - } - - // Parts. - // - size_t parts (ops.parts ()); - size_t units (counts.global_types + counts.generated_global_elements); - size_t units_per_part (units / parts); - - if (parts != 1 && units_per_part < 1) - { - wcerr << "error: too many parts specified: " << parts << endl; - throw Failed (); - } - - size_t complexity_per_part (counts.complexity_total / parts); - - - NarrowString parts_suffix (ops.parts_suffix ()); - - // - // - bool generate_xml_schema (ops.generate_xml_schema ()); - - // We could be compiling several schemas at once in which case - // handling of the --generate-xml-schema option gets tricky: we - // will need to rely on the presence of the --extern-xml-schema - // to tell us which (fake) schema file corresponds to XML Schema. - // - if (generate_xml_schema) - { - if (NarrowString name = ops.extern_xml_schema ()) - { - if (file_path.string () != name) - generate_xml_schema = false; - } - } - - bool header (true); - bool inline_ (ops.generate_inline () && !generate_xml_schema); - bool forward (ops.generate_forward () && !generate_xml_schema); - bool source (!generate_xml_schema); - bool gen_dep ((ops.generate_dep () || ops.generate_dep_only ()) && - !generate_xml_schema); - - if (ops.generate_dep_only () && generate_xml_schema) - { - wcerr << "error: no dependency information can be generated for " - "XML Schema header" << endl; - throw Failed (); - } - - if (gen_dep && fpt) - { - wcerr << "error: dependency generation not support in the " << - "file-per-type mode" << endl; - throw Failed (); - } - - // Generate code. - // - NarrowString name (file_path.leaf ().string ()); - - NarrowString hxx_suffix (ops.hxx_suffix ()); - NarrowString ixx_suffix (ops.ixx_suffix ()); - NarrowString cxx_suffix (ops.cxx_suffix ()); - NarrowString fwd_suffix (ops.fwd_suffix ()); - NarrowString dep_suffix (ops.dep_suffix ()); - - Regex hxx_expr (ops.hxx_regex ().empty () - ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + hxx_suffix + "#" - : ops.hxx_regex ()); - - Regex ixx_expr (ops.ixx_regex ().empty () - ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + ixx_suffix + "#" - : ops.ixx_regex ()); - - Regex cxx_expr (ops.cxx_regex ().empty () - ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + cxx_suffix + "#" - : ops.cxx_regex ()); - - Regex fwd_expr (ops.fwd_regex ().empty () - ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + fwd_suffix + "#" - : ops.fwd_regex ()); - - Regex dep_expr (ops.dep_regex ().empty () - ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + dep_suffix + "#" - : ops.dep_regex ()); - - if (header && !hxx_expr.match (name)) - { - wcerr << "error: header expression '" << - hxx_expr.regex ().str ().c_str () << "' does not match '" << - name.c_str () << "'" << endl; - throw Failed (); - } - - if (inline_ && !ixx_expr.match (name)) - { - wcerr << "error: inline expression '" << - ixx_expr.regex ().str ().c_str () << "' does not match '" << - name.c_str () << "'" << endl; - throw Failed (); - } - - if (source && parts == 1 && !cxx_expr.match (name)) - { - wcerr << "error: source expression '" << - cxx_expr.regex ().str ().c_str () << "' does not match '" << - name.c_str () << "'" << endl; - throw Failed (); - } - - if (forward && !fwd_expr.match (name)) - { - wcerr << "error: forward expression '" << - fwd_expr.regex ().str ().c_str () << "' does not match '" << - name.c_str () << "'" << endl; - throw Failed (); - } - - if (gen_dep && !dep_expr.match (name)) - { - wcerr << "error: dependency expression '" << - dep_expr.regex ().str ().c_str () << "' does not match '" << - name.c_str () << "'" << endl; - throw Failed (); - } - - NarrowString hxx_name (header ? hxx_expr.replace (name) : NarrowString ()); - NarrowString ixx_name (inline_ ? ixx_expr.replace (name) : NarrowString ()); - NarrowString fwd_name (forward ? fwd_expr.replace (name) : NarrowString ()); - NarrowString dep_name (gen_dep ? dep_expr.replace (name) : NarrowString ()); - - Path hxx_path (hxx_name); - Path ixx_path (ixx_name); - Path fwd_path (fwd_name); - Path dep_path (dep_name); - Paths cxx_paths; - - if (source) - { - if (parts > 1) - { - for (size_t i (0); i < parts; ++i) - { - std::ostringstream os; - os << i; - - Regex expr ( - "#^(.+?)(\\.[^./\\\\]+)?$#$1" + parts_suffix + os.str () + "$2#"); - - NarrowString part_name (expr.replace (name)); - - if (!cxx_expr.match (part_name)) - { - wcerr << "error: source expression '" << - cxx_expr.regex ().str ().c_str () << "' does not match '" << - part_name.c_str () << "'" << endl; - throw Failed (); - } - - cxx_paths.push_back (Path (cxx_expr.replace (part_name))); - } - } - else - cxx_paths.push_back (Path (cxx_expr.replace (name))); - } - - Path out_dir; - - if (NarrowString dir = ops.output_dir ()) - { - try - { - out_dir = Path (dir); - } - catch (InvalidPath const&) - { - wcerr << dir.c_str () << ": error: invalid path" << endl; - throw Failed (); - } - } - - if (fpt && !generate_xml_schema) - { - // In the file-per-type mode the schema files are always local - // unless the user added the directory so that we propagate this - // to the output files. - // - Path fpt_dir (file_path.directory ()); - - if (!fpt_dir.empty ()) - out_dir /= fpt_dir; - } - - if (!out_dir.empty ()) - { - hxx_path = out_dir / hxx_path; - ixx_path = out_dir / ixx_path; - fwd_path = out_dir / fwd_path; - dep_path = out_dir / dep_path; - - for (Paths::iterator i (cxx_paths.begin ()); - i != cxx_paths.end (); ++i) - *i = out_dir / *i; - } - - // - // - WideOutputFileStream hxx; - WideOutputFileStream ixx; - WideOutputFileStream fwd; - WideOutputFileStream dep; - WideOutputFileStreams cxx; - - // DEP - // - if (gen_dep) - { - dep.open (dep_path.string ().c_str (), ios_base::out); - - if (!dep.is_open ()) - { - wcerr << dep_path << ": error: unable to open in write mode" << endl; - throw Failed (); - } - - unlinks.add (dep_path); - file_list.push_back (dep_path.string ()); - } - - // FWD - // - if (gen_cxx && forward) - { - fwd.open (fwd_path.string ().c_str (), ios_base::out); - - if (!fwd.is_open ()) - { - wcerr << fwd_path << ": error: unable to open in write mode" << endl; - throw Failed (); - } - - unlinks.add (fwd_path); - file_list.push_back (fwd_path.string ()); - } - - // HXX - // - if (gen_cxx && header) - { - hxx.open (hxx_path.string ().c_str (), ios_base::out); - - if (!hxx.is_open ()) - { - wcerr << hxx_path << ": error: unable to open in write mode" << endl; - throw Failed (); - } - - unlinks.add (hxx_path); - file_list.push_back (hxx_path.string ()); - } - - // IXX - // - if (gen_cxx && inline_) - { - ixx.open (ixx_path.string ().c_str (), ios_base::out); - - if (!ixx.is_open ()) - { - wcerr << ixx_path << ": error: unable to open in write mode" << endl; - throw Failed (); - } - - unlinks.add (ixx_path); - file_list.push_back (ixx_path.string ()); - } - - // CXX - // - if (gen_cxx && source) - { - for (Paths::iterator i (cxx_paths.begin ()); - i != cxx_paths.end (); ++i) - { - shared_ptr s ( - new (shared) WideOutputFileStream ( - i->string ().c_str (), ios_base::out)); - - if (!s->is_open ()) - { - wcerr << *i << ": error: unable to open in write mode" << endl; - throw Failed (); - } - - unlinks.add (*i); - file_list.push_back (i->string ()); - cxx.push_back (s); - } - } - - // Print copyright and license. - // - char const* copyright ( - ops.proprietary_license () ? copyright_proprietary : copyright_gpl); - - if (gen_cxx && header) - hxx << copyright; - - if (gen_cxx && forward) - fwd << copyright; - - if (ops.generate_doxygen ()) - { - // Use native path format. - // - hxx << "/**" << endl - << " * @file" << endl - << " * @brief Generated from " << name.c_str () << "." << endl - << " */" << endl - << endl; - - } - - if (gen_cxx && inline_) - ixx << copyright; - - if (gen_cxx && source) - { - for (WideOutputFileStreams::iterator i (cxx.begin ()); - i != cxx.end (); ++i) - **i << copyright; - } - - - // Prologue. - // - WideInputFileStream prologue; - { - NarrowString name (ops.prologue_file ()); - - if (name) - open (prologue, name); - } - - // Epilogue. - // - WideInputFileStream epilogue; - { - NarrowString name (ops.epilogue_file ()); - - if (name) - open (epilogue, name); - } - - // SLOC counter. - // - size_t sloc_total (0); - bool show_sloc (ops.show_sloc ()); - - typedef - compiler::ostream_filter - ind_filter; - - typedef - compiler::ostream_filter - sloc_filter; - - // - // - Regex guard_expr ("/([a-z])([A-Z])/$1_$2/"); // Split words. - NarrowString guard_prefix (ops.guard_prefix ()); - - if (!guard_prefix) - guard_prefix = file_path.directory ().string (); - - if (guard_prefix) - guard_prefix += '_'; - - // DEP - // - if (gen_dep) - { - NarrowString target; - NarrowStrings const& ts (ops.dep_target ()); - - if (!ts.empty ()) - { - for (NarrowStrings::const_iterator i (ts.begin ()); - i != ts.end (); ++i) - target += (target.empty () ? "" : " \\\n") + *i; - } - else - { - target = hxx_path.string (); - - if (forward) - target += " \\\n" + fwd_path.string (); - - if (inline_) - target += " \\\n" + ixx_path.string (); - - for (Paths::iterator i (cxx_paths.begin ()); - i != cxx_paths.end (); ++i) - target += " \\\n" + i->string (); - - target += " \\\n" + dep_path.string (); - } - - dep << target.c_str () << ':'; - - XSDFrontend::Generators::Dependencies gen; - Paths prq (gen.generate (schema, file_path)); - - for (Paths::iterator i (prq.begin ()); i != prq.end (); ++i) - dep << " \\" << endl - << " " << *i; - - dep << endl; - - // If requested, generate phony rules for included/imported schemas - // but not the main file which is the first in the list. - // - if (ops.dep_phony () && prq.size () > 1) - { - for (Paths::iterator i (prq.begin () + 1); i != prq.end (); ++i) - dep << endl - << *i << ':' << endl; - } - } - - // FWD - // - if (gen_cxx && forward) - { - Context ctx (fwd, - schema, - file_path, - ops, - counts, - generate_xml_schema, - &string_literal_map, - &fwd_expr, - &hxx_expr, - &ixx_expr); - - sloc_filter sloc (fwd); - - // Guard - // - String guard (guard_expr.replace (guard_prefix + fwd_name)); - guard = ctx.escape (guard); // make a c++ id - std::transform (guard.begin (), guard.end(), guard.begin (), upcase); - - fwd << "#ifndef " << guard << endl - << "#define " << guard << endl - << endl; - - if (ctx.std >= cxx_version::cxx11) - { - fwd << "#ifndef XSD_CXX11" << endl - << "#define XSD_CXX11" << endl - << "#endif" << endl - << endl; - } - - if (ctx.char_type == L"char") - { - fwd << "#ifndef XSD_USE_CHAR" << endl - << "#define XSD_USE_CHAR" << endl - << "#endif" << endl - << endl; - - fwd << "#ifndef XSD_CXX_TREE_USE_CHAR" << endl - << "#define XSD_CXX_TREE_USE_CHAR" << endl - << "#endif" << endl - << endl; - } - else if (ctx.char_type == L"wchar_t") - { - fwd << "#ifndef XSD_USE_WCHAR" << endl - << "#define XSD_USE_WCHAR" << endl - << "#endif" << endl - << endl; - - fwd << "#ifndef XSD_CXX_TREE_USE_WCHAR" << endl - << "#define XSD_CXX_TREE_USE_WCHAR" << endl - << "#endif" << endl - << endl; - } - - // Copy prologue. - // - fwd << "// Begin prologue." << endl - << "//" << endl; - - append (fwd, ops.fwd_prologue (), ops.prologue ()); - append (fwd, ops.fwd_prologue_file (), prologue); - - fwd << "//" << endl - << "// End prologue." << endl - << endl; - - // Version check. - // - fwd << "#include " << endl - << endl - << "#if (XSD_INT_VERSION != " << XSD_INT_VERSION << "L)" << endl - << "#error XSD runtime version mismatch" << endl - << "#endif" << endl - << endl; - - fwd << "#include " << endl - << endl; - - // Generate. - // - { - ind_filter ind (fwd); // We don't want to indent prologues/epilogues. - generate_forward (ctx); - } - - fwd << "#include " << endl - << endl; - - // Copy epilogue. - // - fwd << "// Begin epilogue." << endl - << "//" << endl; - - append (fwd, ops.fwd_epilogue_file (), epilogue); - append (fwd, ops.fwd_epilogue (), ops.epilogue ()); - - fwd << "//" << endl - << "// End epilogue." << endl - << endl; - - fwd << "#endif // " << guard << endl; - - if (show_sloc) - wcerr << fwd_path << ": " << sloc.stream ().count () << endl; - - sloc_total += sloc.stream ().count (); - } - - // HXX - // - if (gen_cxx && header) - { - Context ctx (hxx, - schema, - file_path, - ops, - counts, - generate_xml_schema, - &string_literal_map, - &fwd_expr, - &hxx_expr, - &ixx_expr); - - sloc_filter sloc (hxx); - - // Guard - // - String guard (guard_expr.replace (guard_prefix + hxx_name)); - guard = ctx.escape (guard); // make a c++ id - std::transform (guard.begin (), guard.end(), guard.begin (), upcase); - - hxx << "#ifndef " << guard << endl - << "#define " << guard << endl - << endl; - - if (!forward) - { - if (ctx.std >= cxx_version::cxx11) - { - hxx << "#ifndef XSD_CXX11" << endl - << "#define XSD_CXX11" << endl - << "#endif" << endl - << endl; - } - - if (ctx.char_type == L"char") - { - hxx << "#ifndef XSD_USE_CHAR" << endl - << "#define XSD_USE_CHAR" << endl - << "#endif" << endl - << endl; - - hxx << "#ifndef XSD_CXX_TREE_USE_CHAR" << endl - << "#define XSD_CXX_TREE_USE_CHAR" << endl - << "#endif" << endl - << endl; - } - else if (ctx.char_type == L"wchar_t") - { - hxx << "#ifndef XSD_USE_WCHAR" << endl - << "#define XSD_USE_WCHAR" << endl - << "#endif" << endl - << endl; - - hxx << "#ifndef XSD_CXX_TREE_USE_WCHAR" << endl - << "#define XSD_CXX_TREE_USE_WCHAR" << endl - << "#endif" << endl - << endl; - } - } - else if (!generate_xml_schema) - { - // Generate it before the prologue so that we get the above - // defines. - // - hxx << "#include " << ctx.process_include_path (fwd_name) - << endl << endl; - } - - // Copy prologue. - // - hxx << "// Begin prologue." << endl - << "//" << endl; - - append (hxx, ops.hxx_prologue (), ops.prologue ()); - append (hxx, ops.hxx_prologue_file (), prologue); - - hxx << "//" << endl - << "// End prologue." << endl - << endl; - - // Version check. - // - hxx << "#include " << endl - << endl - << "#if (XSD_INT_VERSION != " << XSD_INT_VERSION << "L)" << endl - << "#error XSD runtime version mismatch" << endl - << "#endif" << endl - << endl; - - hxx << "#include " << endl - << endl; - - // Generate. - // - { - ind_filter ind (hxx); // We don't want to indent prologues/epilogues. - - if (!generate_xml_schema && !forward) - generate_forward (ctx); - - generate_tree_header (ctx); - - if (!generate_xml_schema) - { - if (ops.generate_ostream ()) - generate_stream_header (ctx); - - if (!ops.generate_element_type () && !ops.suppress_parsing ()) - generate_parser_header (ctx); - - if (ops.generate_serialization ()) - generate_serialization_header (ctx); - - if (!ops.generate_insertion ().empty ()) - generate_stream_insertion_header (ctx); - } - } - - if (inline_) - { - hxx << "#ifndef XSD_DONT_INCLUDE_INLINE" << endl - << "#include " << ctx.process_include_path (ixx_name) << endl - << "#endif // XSD_DONT_INCLUDE_INLINE" << endl - << endl; - } - - hxx << "#include " << endl - << endl; - - // Copy epilogue. - // - hxx << "// Begin epilogue." << endl - << "//" << endl; - - append (hxx, ops.hxx_epilogue_file (), epilogue); - append (hxx, ops.hxx_epilogue (), ops.epilogue ()); - - hxx << "//" << endl - << "// End epilogue." << endl - << endl; - - hxx << "#endif // " << guard << endl; - - if (show_sloc) - wcerr << hxx_path << ": " << sloc.stream ().count () << endl; - - sloc_total += sloc.stream ().count (); - } - - - // IXX - // - if (gen_cxx && inline_) - { - Context ctx (ixx, - schema, - file_path, - ops, - counts, - generate_xml_schema, - &string_literal_map, - &fwd_expr, - &hxx_expr, - &ixx_expr); - - sloc_filter sloc (ixx); - - // Guard - // - String guard (guard_expr.replace (guard_prefix + ixx_name)); - guard = ctx.escape (guard); // make a c++ id - std::transform (guard.begin (), guard.end(), guard.begin (), upcase); - - ixx << "#ifndef " << guard.c_str () << endl - << "#define " << guard.c_str () << endl - << endl; - - // Copy prologue. - // - ixx << "// Begin prologue." << endl - << "//" << endl; - - append (ixx, ops.ixx_prologue (), ops.prologue ()); - append (ixx, ops.ixx_prologue_file (), prologue); - - ixx << "//" << endl - << "// End prologue." << endl - << endl; - - // Generate. - // - { - ind_filter ind (ixx); // We don't want to indent prologues/epilogues. - generate_tree_inline (ctx, 1, 0); - } - - // Copy epilogue. - // - ixx << "// Begin epilogue." << endl - << "//" << endl; - - append (ixx, ops.ixx_epilogue_file (), epilogue); - append (ixx, ops.ixx_epilogue (), ops.epilogue ()); - - ixx << "//" << endl - << "// End epilogue." << endl - << endl; - - ixx << "#endif // " << guard.c_str () << endl; - - if (show_sloc) - wcerr << ixx_path << ": " << sloc.stream ().count () << endl; - - sloc_total += sloc.stream ().count (); - } - - // CXX - // - if (gen_cxx && source) - { - size_t first_unit (0); // First unit in the current part. - - for (size_t part (0); part < parts; ++part) - { - // Figure out the range of units for this part. - // - size_t last_unit (first_unit); - - if (units != 0) - { - size_t complexity (counts.complexity[last_unit]); - - while (complexity < complexity_per_part) - { - // Make sure there will be at least one unit for each part left. - // - if ((last_unit + 1) >= units || - (units - (last_unit + 1) - 1) < (parts - part - 1)) - break; - - // Check if the increase in complexity should be kept in this - // part or moved to the next. - // - size_t new_complexity ( - complexity + counts.complexity[last_unit + 1]); - - if (new_complexity > complexity_per_part) - { - if ((new_complexity - complexity_per_part) > - (counts.complexity[last_unit + 1] / 2)) - break; - } - - last_unit++; - complexity = new_complexity; - } - - if (part + 1 == parts) - { - // Last part. - // - last_unit = units - 1; - } - } - - // - // - size_t first (first_unit); - size_t last (last_unit); - - first_unit = last_unit + 1; - - //wcerr << "[" << first << ", " << last << "]: " << complexity - // << endl; - - WideOutputFileStream& os (*cxx[part]); - - Context ctx (os, - schema, - file_path, - ops, - counts, - generate_xml_schema, - &string_literal_map, - &fwd_expr, - &hxx_expr, - &ixx_expr); - - sloc_filter sloc (os); - - // Copy prologue. - // - os << "// Begin prologue." << endl - << "//" << endl; - - append (os, ops.cxx_prologue (), ops.prologue ()); - append (os, ops.cxx_prologue_file (), prologue); - - os << "//" << endl - << "// End prologue." << endl - << endl; - - os << "#include " << endl - << endl; - - os << "#include " << ctx.process_include_path (hxx_name) << endl - << endl; - - // Generate. - // - { - // We don't want to indent prologues/epilogues. - // - ind_filter ind (os); - - if (!inline_) - generate_tree_inline (ctx, first, last); - - generate_tree_source (ctx, first, last); - - if (ops.generate_ostream ()) - generate_stream_source (ctx, first, last); - - if (!ops.generate_element_type () && !ops.suppress_parsing ()) - generate_parser_source (ctx, first, last); - - if (ops.generate_serialization ()) - generate_serialization_source (ctx, first, last); - - if (!ops.generate_extraction ().empty ()) - generate_stream_extraction_source (ctx); - - if (!ops.generate_insertion ().empty ()) - generate_stream_insertion_source (ctx); - } - - os << "#include " << endl - << endl; - - // Copy epilogue. - // - os << "// Begin epilogue." << endl - << "//" << endl; - - append (os, ops.cxx_epilogue_file (), epilogue); - append (os, ops.cxx_epilogue (), ops.epilogue ()); - - os << "//" << endl - << "// End epilogue." << endl - << endl; - - if (show_sloc) - wcerr << cxx_paths[part] << ": " << sloc.stream ().count () - << endl; - - sloc_total += sloc.stream ().count (); - } - } - - return sloc_total; - } - catch (UnrepresentableCharacter const& e) - { - wcerr << "error: character at position " << e.position () << " " - << "in string '" << e.string () << "' is unrepresentable in " - << "the target encoding" << endl; - - wcerr << "info: use the --custom-literals option to provide custom " - << "string literals mapping" << endl; - - throw Failed (); - } - catch (NoNamespaceMapping const& e) - { - wcerr << e.file () << ":" << e.line () << ":" << e.column () - << ": error: unable to map XML Schema namespace '" << e.ns () - << "' to C++ namespace" << endl; - - wcerr << e.file () << ":" << e.line () << ":" << e.column () - << ": info: use the --namespace-map or --namespace-regex option " - << "to provide custom mapping" << endl; - - throw Failed (); - } - catch (InvalidNamespaceMapping const& e) - { - wcerr << "error: invalid XML to C++ namespace mapping specified: " - << "'" << e.mapping () << "': " << e.reason () << endl; - - throw Failed (); - } - catch (InvalidCustomTypeMapping const& e) - { - wcerr << "error: invalid custom type mapping specified: " - << "'" << e.mapping () << "': " << e.reason () << endl; - - throw Failed (); - } - catch (cutl::re::format const& e) - { - wcerr << "error: invalid regex: '" << - e.regex ().c_str () << "': " << - e.description ().c_str () << endl; - - throw Failed (); - } - catch (cutl::re::wformat const& e) - { - wcerr << "error: invalid regex: '" << - e.regex () << "': " << e.description ().c_str () << endl; - - throw Failed (); - } - } -} diff --git a/xsd/cxx/tree/generator.hxx b/xsd/cxx/tree/generator.hxx deleted file mode 100644 index e3da0c3..0000000 --- a/xsd/cxx/tree/generator.hxx +++ /dev/null @@ -1,44 +0,0 @@ -// file : xsd/cxx/tree/generator.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_TREE_GENERATOR_HXX -#define CXX_TREE_GENERATOR_HXX - -#include // Path -#include - -#include -#include - -#include -#include - -namespace CXX -{ - namespace Tree - { - class Generator - { - public: - static void - usage (); - - struct Failed {}; - - static size_t - generate (options const&, - XSDFrontend::SemanticGraph::Schema&, - XSDFrontend::SemanticGraph::Path const& file, - bool file_per_type, - StringLiteralMap const&, - const WarningSet& disabled_warnings, - FileList& file_list, - AutoUnlinks& unlinks); - - private: - Generator (); - }; - } -} - -#endif // CXX_TREE_GENERATOR_HXX diff --git a/xsd/cxx/tree/name-processor.cxx b/xsd/cxx/tree/name-processor.cxx deleted file mode 100644 index 51f058c..0000000 --- a/xsd/cxx/tree/name-processor.cxx +++ /dev/null @@ -1,2399 +0,0 @@ -// file : xsd/cxx/tree/name-processor.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include -#include -#include -#include -#include - -#include - -#include -#include - -using namespace std; - -namespace CXX -{ - namespace Tree - { - namespace - { - // - // - typedef set NameSet; - - class Context: public Tree::Context - { - public: - struct Failed {}; - - Context (Tree::options const& ops, - Counts const& counts, - bool generate_xml_schema, - SemanticGraph::Schema& root, - SemanticGraph::Path const& path, - StringLiteralMap const& map) - : Tree::Context (std::wcerr, - root, - path, - ops, - counts, - generate_xml_schema, - &map, - 0, - 0, - 0), - global_type_names (global_type_names_), - global_element_names (global_element_names_), - detach (ops.generate_detach ()), - type_regex (type_regex_), - accessor_regex (accessor_regex_), - one_accessor_regex (one_accessor_regex_), - opt_accessor_regex (opt_accessor_regex_), - seq_accessor_regex (seq_accessor_regex_), - modifier_regex (modifier_regex_), - one_modifier_regex (one_modifier_regex_), - opt_modifier_regex (opt_modifier_regex_), - seq_modifier_regex (seq_modifier_regex_), - parser_regex (parser_regex_), - serializer_regex (serializer_regex_), - const_regex (const_regex_), - enumerator_regex (enumerator_regex_), - element_type_regex (element_type_regex_) - { - NarrowString tn (options.type_naming ()); - NarrowString fn (options.function_naming ()); - - // Type name regex. - // - { - // Predefined rules. The most frequently used come last: global - // names, two components (,type), three components - // (,const,iterator), and one component (value in enum). - // - if (tn == "knr") - { - type_regex.push_back ("/(?:[^ ]* )?([^,]+),([^,]+),([^,]+),([^,]+)/$1_$2_$3_$4/"); - type_regex.push_back ("/(?:[^ ]* )?([^,]+),([^,]+),([^,]+)/$1_$2_$3/"); - type_regex.push_back ("/(?:[^ ]* )?([^,]+),([^,]+)/$1_$2/"); - type_regex.push_back ("/(?:[^ ]* )?([^,]+)/$1/"); - - /* - type_regex.push_back ("/([^,]+)/$1/"); - type_regex.push_back ("/([^,]+),([^,]+),([^,]+),([^,]+)/$1_$2_$3_$4/"); - type_regex.push_back ("/([^,]+),([^,]+),([^,]+)/$1_$2_$3/"); - type_regex.push_back ("/([^,]+),([^,]+)/$1_$2/"); - type_regex.push_back ("/[^ ]* (.+)/$1/"); - */ - } - else - { - // Upper camel case or Java. - // - type_regex.push_back ("/(?:[^ ]* )?([^,]+),([^,]+),([^,]+),([^,]+)/\\u$1\\u$2\\u$3\\u$4/"); - type_regex.push_back ("/(?:[^ ]* )?([^,]+),([^,]+),([^,]+)/\\u$1\\u$2\\u$3/"); - type_regex.push_back ("/(?:[^ ]* )?([^,]+),([^,]+)/\\u$1\\u$2/"); - type_regex.push_back ("/(?:[^ ]* )?([^,]+)/\\u$1/"); - - /* - type_regex.push_back ("/([^,]+)/\\u$1/"); - type_regex.push_back ("/([^,]+),([^,]+),([^,]+),([^,]+)/\\u$1\\u$2\\u$3\\u$4/"); - type_regex.push_back ("/([^,]+),([^,]+),([^,]+)/\\u$1\\u$2\\u$3/"); - type_regex.push_back ("/([^,]+),([^,]+)/\\u$1\\u$2/"); - type_regex.push_back ("/[^ ]* (.+)/\\u$1/"); - */ - - } - - compile_regex (options.type_regex (), type_regex, "type"); - } - - // Accessor name regex. - // - { - // Predefined rules. The most frequently used come last: one - // component, three components (,default,value) and two - // component (dom,document). - // - if (fn == "knr") - { - accessor_regex.push_back ("/([^,]+),([^,]+)/$1_$2/"); - accessor_regex.push_back ("/([^,]+),([^,]+),([^,]+)/$1_$2_$3/"); - accessor_regex.push_back ("/([^,]+)/$1/"); - } - else if (fn == "lcc") - { - accessor_regex.push_back ("/([^,]+),([^,]+)/\\l$1\\u$2/"); - accessor_regex.push_back ("/([^,]+),([^,]+),([^,]+)/\\l$1\\u$2\\u$3/"); - accessor_regex.push_back ("/([^,]+)/\\l$1/"); - } - else - { - // Java: add get. - // - accessor_regex.push_back ("/([^,]+),([^,]+)/get\\u$1\\u$2/"); - accessor_regex.push_back ("/([^,]+),([^,]+),([^,]+)/get\\u$1\\u$2\\u$3/"); - accessor_regex.push_back ("/([^,]+)/get\\u$1/"); - } - - compile_regex (options.accessor_regex (), - accessor_regex, - "accessor"); - - compile_regex (options.one_accessor_regex (), - one_accessor_regex, - "one accessor"); - - compile_regex (options.opt_accessor_regex (), - opt_accessor_regex, - "optional accessor"); - - compile_regex (options.seq_accessor_regex (), - seq_accessor_regex, - "sequence accessor"); - } - - // Modifier name regex. - // - { - if (fn == "knr") - { - // any,attribute - // - modifier_regex.push_back ("/([^,]+),([^,]+)/$1_$2/"); - } - else if (fn == "lcc") - { - modifier_regex.push_back ("/([^,]+),([^,]+)/\\l$1\\u$2/"); - modifier_regex.push_back ("/([^,]+)/\\l$1/"); - } - else - { - // Java: add set. - // - modifier_regex.push_back ("/([^,]+),([^,]+)/set\\u$1\\u$2/"); - modifier_regex.push_back ("/([^,]+)/set\\u$1/"); - modifier_regex.push_back ("/detach,([^,]+)/detach\\u$1/"); - } - - compile_regex (options.modifier_regex (), - modifier_regex, - "modifier"); - - compile_regex (options.one_modifier_regex (), - one_modifier_regex, - "one modifier"); - - compile_regex (options.opt_modifier_regex (), - opt_modifier_regex, - "optional modifier"); - - compile_regex (options.seq_modifier_regex (), - seq_modifier_regex, - "sequence modifier"); - } - - // Parser name regex. - // - { - if (fn == "lcc") - { - parser_regex.push_back ("/(.+)/\\l$1/"); - } - else if (fn == "java") - { - // Java: add parse. - // - parser_regex.push_back ("/(.+)/parse\\u$1/"); - } - - compile_regex (options.parser_regex (), parser_regex, "parser"); - } - - // Serializer name regex. - // - { - if (fn == "lcc") - { - serializer_regex.push_back ("/(.+)/\\l$1/"); - } - else if (fn == "java") - { - // Java: add serialize. - // - serializer_regex.push_back ("/(.+)/serialize\\u$1/"); - } - - compile_regex (options.serializer_regex (), - serializer_regex, - "serializer"); - } - - // Const regex. - // - { - if (fn == "knr") - { - const_regex.push_back ("/([^,]+),([^,]+),([^,]+)/$1_$2_$3/"); - const_regex.push_back ("/([^,]+),([^,]+)/$1_$2/"); - } - else if (fn == "lcc") - { - const_regex.push_back ("/([^,]+),([^,]+),([^,]+)/\\l$1_\\u$2_\\u$3/"); - const_regex.push_back ("/([^,]+),([^,]+)/\\l$1\\u$2/"); - } - else - { - // Java: all uppercase. - // - const_regex.push_back ("/([^,]+),([^,]+),([^,]+)/\\U$1_$2_$3/"); - const_regex.push_back ("/([^,]+),([^,]+)/\\U$1_$2/"); - } - - compile_regex (options.const_regex (), const_regex, "const"); - } - - // Enumerator name regex. - // - { - // By default map an empty enumerator to the 'empty' word. - // - enumerator_regex.push_back ("/^$/empty/"); - - compile_regex (options.enumerator_regex (), - enumerator_regex, - "enumerator"); - } - - // Element type regex. - // - compile_regex (options.element_type_regex (), - element_type_regex, - "element_type"); - } - - protected: - Context (Context& c) - : Tree::Context (c), - global_type_names (c.global_type_names), - global_element_names (c.global_element_names), - detach (c.detach), - type_regex (c.type_regex), - accessor_regex (c.accessor_regex), - one_accessor_regex (c.one_accessor_regex), - opt_accessor_regex (c.opt_accessor_regex), - seq_accessor_regex (c.seq_accessor_regex), - modifier_regex (c.modifier_regex), - one_modifier_regex (c.one_modifier_regex), - opt_modifier_regex (c.opt_modifier_regex), - seq_modifier_regex (c.seq_modifier_regex), - parser_regex (c.parser_regex), - serializer_regex (c.serializer_regex), - const_regex (c.const_regex), - enumerator_regex (c.enumerator_regex), - element_type_regex (c.element_type_regex) - { - } - - public: - typedef cutl::re::wregexsub Regex; - typedef cutl::re::wformat RegexFormat; - - struct RegexVector: vector - { - void - push_back (String const& r) - { - vector::push_back (Regex (r)); - } - }; - - String - process_regex (String const& name, - RegexVector const& rv, - String const& id) - { - bool trace (options.name_regex_trace ()); - - if (trace) - os << id << " name: '" << name << "'" << endl; - - for (RegexVector::const_reverse_iterator i (rv.rbegin ()); - i != rv.rend (); ++i) - { - if (trace) - os << "try: '" << i->regex () << "' : "; - - if (i->match (name)) - { - String r (i->replace (name)); - - if (trace) - os << "'" << r << "' : +" << endl; - - return r; - } - - if (trace) - os << '-' << endl; - } - - return name; - } - - String - process_regex (String const& name, - RegexVector const& primary, - RegexVector const& backup, - String const& id) - { - bool trace (options.name_regex_trace ()); - - if (trace) - os << id << " name: '" << name << "'" << endl; - - for (RegexVector::const_reverse_iterator i (primary.rbegin ()); - i != primary.rend (); ++i) - { - if (trace) - os << "try: '" << i->regex () << "' : "; - - if (i->match (name)) - { - String r (i->replace (name)); - - if (trace) - os << "'" << r << "' : +" << endl; - - return r; - } - - if (trace) - os << '-' << endl; - } - - for (RegexVector::const_reverse_iterator i (backup.rbegin ()); - i != backup.rend (); ++i) - { - if (trace) - os << "try: '" << i->regex () << "' : "; - - if (i->match (name)) - { - String r (i->replace (name)); - - if (trace) - os << "'" << r << "' : +" << endl; - - return r; - } - - if (trace) - os << '-' << endl; - } - - return name; - } - - String - process_regex (String const& ns, - String const& name, - RegexVector const& rv, - String const& id) - { - String s (ns + L' ' + name); - bool trace (options.name_regex_trace ()); - - if (trace) - os << id << " name: '" << s << "'" << endl; - - for (RegexVector::const_reverse_iterator i (rv.rbegin ()); - i != rv.rend (); ++i) - { - if (trace) - os << "try: '" << i->regex () << "' : "; - - if (i->match (s)) - { - String r (i->replace (s)); - - if (trace) - os << "'" << r << "' : +" << endl; - - return r; - } - - if (trace) - os << '-' << endl; - } - - return name; - } - - String - process_regex (String const& ns, - String const& name, - RegexVector const& primary, - RegexVector const& backup, - String const& id) - { - String s (ns + L' ' + name); - bool trace (options.name_regex_trace ()); - - if (trace) - os << id << " name: '" << s << "'" << endl; - - for (RegexVector::const_reverse_iterator i (primary.rbegin ()); - i != primary.rend (); ++i) - { - if (trace) - os << "try: '" << i->regex () << "' : "; - - if (i->match (s)) - { - String r (i->replace (s)); - - if (trace) - os << "'" << r << "' : +" << endl; - - return r; - } - - if (trace) - os << '-' << endl; - } - - for (RegexVector::const_reverse_iterator i (backup.rbegin ()); - i != backup.rend (); ++i) - { - if (trace) - os << "try: '" << i->regex () << "' : "; - - if (i->match (s)) - { - String r (i->replace (s)); - - if (trace) - os << "'" << r << "' : +" << endl; - - return r; - } - - if (trace) - os << '-' << endl; - } - - return name; - } - - public: - String - find_name (String const& base_name, - NameSet& set, - bool insert = true) - { - String name (base_name); - - for (size_t i (1); set.find (name) != set.end (); ++i) - { - std::wostringstream os; - os << i; - name = base_name + os.str (); - } - - if (insert) - set.insert (name); - - return name; - } - - private: - void - compile_regex (NarrowStrings const& sv, - RegexVector& rv, - String const& id) - { - for (NarrowStrings::const_iterator i (sv.begin ()); i != sv.end (); - ++i) - { - try - { - rv.push_back (*i); - } - catch (RegexFormat const& e) - { - os << "error: invalid " << id << " name regex: '" << - e.regex () << "': " << e.description ().c_str () << endl; - - throw Failed (); - } - } - } - - private: - map global_type_names_; - map global_element_names_; - - RegexVector type_regex_; - RegexVector accessor_regex_; - RegexVector one_accessor_regex_; - RegexVector opt_accessor_regex_; - RegexVector seq_accessor_regex_; - RegexVector modifier_regex_; - RegexVector one_modifier_regex_; - RegexVector opt_modifier_regex_; - RegexVector seq_modifier_regex_; - RegexVector parser_regex_; - RegexVector serializer_regex_; - RegexVector const_regex_; - RegexVector enumerator_regex_; - RegexVector element_type_regex_; - - public: - map& global_type_names; - map& global_element_names; - - bool detach; - - RegexVector& type_regex; - RegexVector& accessor_regex; - RegexVector& one_accessor_regex; - RegexVector& opt_accessor_regex; - RegexVector& seq_accessor_regex; - RegexVector& modifier_regex; - RegexVector& one_modifier_regex; - RegexVector& opt_modifier_regex; - RegexVector& seq_modifier_regex; - RegexVector& parser_regex; - RegexVector& serializer_regex; - RegexVector& const_regex; - RegexVector& enumerator_regex; - RegexVector& element_type_regex; - }; - - // - // - struct Enumerator: Traversal::Enumerator, Context - { - Enumerator (Context& c, NameSet& set) - : Context (c), set_ (set) - { - } - - virtual void - traverse (Type& e) - { - // Process the name with enumerator name regex. - // - String name ( - process_regex (e.name (), enumerator_regex, L"enumerator")); - - // Escape and unclash. - // - name = find_name (escape (name), set_); - e.context ().set ("name", name); - } - - private: - NameSet& set_; - }; - - // - // - struct Enumeration: Traversal::Enumeration, Context - { - Enumeration (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& e) - { - // Use processed name. - // - String name (e.context ().get ("name")); - - // If renamed name is empty then we are not generating - // anything for this type and name processing is not - // required. - // - if (renamed_type (e, name) && !name) - return; - - NameSet enum_set; - enum_set.insert (name); - - Enumerator enumerator (*this, enum_set); - Traversal::Names names (enumerator); - - Traversal::Enumeration::names (e, names); - - // Assign name to the value type. First process the name - // with type name regex. - // - String value_name ( - escape (process_regex ("value", type_regex, L"type"))); - e.context ().set ("value", find_name (value_name, enum_set)); - } - }; - - // - // - struct PrimaryMember: Traversal::Member, Context - { - PrimaryMember (Context& c, NameSet& name_set, NameSet& stem_set) - : Context (c), name_set_ (name_set), stem_set_ (stem_set) - { - } - - virtual void - traverse (Type& m) - { - if (Tree::Context::skip (m)) - return; - - String stem (find_name (m.name (), stem_set_)); - - m.context ().set ("stem", stem); - m.context ().set ("name", - find_name (escape (stem), name_set_, false)); - } - - private: - NameSet& name_set_; - NameSet& stem_set_; - }; - - // - // - struct DerivedMember: Traversal::Member, Context - { - DerivedMember (Context& c, NameSet& name_set) - : Context (c), name_set_ (name_set) - { - } - - virtual void - traverse (Type& m) - { - if (Tree::Context::skip (m)) - return; - - SemanticGraph::Complex& c ( - dynamic_cast (m.scope ())); - - size_t max (Tree::Context::max (m)); - size_t min (Tree::Context::min (m)); - - String const& s (m.context ().get ("stem")); - String const& b (m.context ().get ("name")); - - bool def_attr (m.default_p () && - m.is_a ()); - - // Accessors/modifiers. Note that we postpone inserting - // the names into the name_set to avoid over-escaping. - // - String an, mn; - - if (max != 1) - { - an = find_name ( - escape (process_regex (s, - seq_accessor_regex, - accessor_regex, - L"sequence accessor")), - name_set_, - false); - - mn = find_name ( - escape (process_regex (s, - seq_modifier_regex, - modifier_regex, - L"sequence modifier")), - name_set_, - false); - } - else if (min == 0 && !def_attr) - { - an = find_name ( - escape (process_regex (s, - opt_accessor_regex, - accessor_regex, - L"optional accessor")), - name_set_, - false); - - mn = find_name ( - escape (process_regex (s, - opt_modifier_regex, - modifier_regex, - L"optional modifier")), - name_set_, - false); - } - else - { - an = find_name ( - escape (process_regex (s, - one_accessor_regex, - accessor_regex, - L"one accessor")), - name_set_, - false); - - mn = find_name ( - escape (process_regex (s, - one_modifier_regex, - modifier_regex, - L"one modifier")), - name_set_, - false); - } - - m.context ().set ("aname", an); - m.context ().set ("mname", mn); - - name_set_.insert (b); - - if (an != b) - name_set_.insert (an); - - if (mn != b && mn != an) - name_set_.insert (mn); - - // Detach. - // - if (detach && max == 1 && (min == 1 || def_attr)) - { - String dn (find_name ( - escape (process_regex (L"detach," + s, - one_modifier_regex, - modifier_regex, - L"one modifier")), - name_set_)); - - m.context ().set ("dname", dn); - } - - // Types. - // - m.context ().set ( - "type", - find_name ( - escape (process_regex (s + L",type", type_regex, L"type")), - name_set_)); - - m.context ().set ( - "traits", - find_name ( - escape (process_regex (s + L",traits", type_regex, L"type")), - name_set_)); - - if (max != 1) - { - m.context ().set ( - "container", - find_name ( - escape (process_regex (s + L",sequence", type_regex, L"type")), - name_set_)); - - m.context ().set ( - "iterator", - find_name ( - escape (process_regex (s + L",iterator", type_regex, L"type")), - name_set_)); - - m.context ().set ( - "const-iterator", - find_name ( - escape ( - process_regex (s + L",const,iterator", type_regex, L"type")), - name_set_)); - } - else if (min == 0 && !def_attr) - { - m.context ().set ( - "container", - find_name ( - escape (process_regex (s + L",optional", type_regex, L"type")), - name_set_)); - } - - // Data member. - // - m.context ().set ("member", find_name (b + L"_", name_set_)); - - // Default value. - // - if (m.default_p ()) - { - bool simple (true); - - if (m.is_a ()) - { - IsSimpleType test (simple); - test.dispatch (m.type ()); - } - - if (simple) - { - String an ( - escape ( - process_regex ( - s + L",default,value", accessor_regex, L"accessor"))); - - m.context ().set ("default-value", find_name (an, name_set_)); - - bool lit (false); - { - IsLiteralValue test (lit); - test.dispatch (m.type ()); - } - - if (!lit) - { - m.context ().set ( - "default-value-member", - find_name (b + L"_default_value_", name_set_)); - } - } - } - - // Element id. - // - if (m.is_a () && ordered_p (c)) - { - String id ( - escape ( - process_regex ( - s + L",id", const_regex, L"const"))); - - m.context ().set ("ordered-id-name", find_name (id, name_set_)); - } - } - - private: - NameSet& name_set_; - }; - - - // - // - struct Any: Traversal::Any, Traversal::AnyAttribute, Context - { - Any (Context& c, - NameSet& name_set, - NameSet& stem_set, - bool& has_wildcard) - : Context (c), - name_set_ (name_set), - stem_set_ (stem_set), - has_wildcard_ (has_wildcard) - { - } - - virtual void - traverse (SemanticGraph::Any& a) - { - SemanticGraph::Complex& c ( - dynamic_cast (a.scope ())); - - size_t max (Tree::Context::max (a)); - size_t min (Tree::Context::min (a)); - - String s (find_name (L"any", stem_set_)); - - String b (find_name (escape (s), name_set_, false)); - a.context ().set ("name", b); - - // Accessors/modifiers. Note that we postpone inserting the - // names into the name_set to avoid over-escaping. - // - String an, mn; - - if (max != 1) - { - an = find_name ( - escape (process_regex (s, - seq_accessor_regex, - accessor_regex, - L"sequence accessor")), - name_set_, - false); - - mn = find_name ( - escape (process_regex (s, - seq_modifier_regex, - modifier_regex, - L"sequence modifier")), - name_set_, - false); - } - else if (min == 0) - { - an = find_name ( - escape (process_regex (s, - opt_accessor_regex, - accessor_regex, - L"optional accessor")), - name_set_, - false); - - mn = find_name ( - escape (process_regex (s, - opt_modifier_regex, - modifier_regex, - L"optional modifier")), - name_set_, - false); - } - else - { - an = find_name ( - escape (process_regex (s, - one_accessor_regex, - accessor_regex, - L"one accessor")), - name_set_, - false); - - mn = find_name ( - escape (process_regex (s, - one_modifier_regex, - modifier_regex, - L"one modifier")), - name_set_, - false); - } - - a.context ().set ("aname", an); - a.context ().set ("mname", mn); - - name_set_.insert (b); - - if (an != b) - name_set_.insert (an); - - if (mn != b && mn != an) - name_set_.insert (mn); - - // Types - // - if (max != 1) - { - a.context ().set ( - "container", - find_name ( - escape (process_regex (s + L",sequence", type_regex, L"type")), - name_set_)); - - a.context ().set ( - "iterator", - find_name ( - escape (process_regex (s + L",iterator", type_regex, L"type")), - name_set_)); - - a.context ().set ( - "const-iterator", - find_name ( - escape ( - process_regex (s + L",const,iterator", type_regex, L"type")), - name_set_)); - } - else if (min == 0) - { - a.context ().set ( - "container", - find_name ( - escape (process_regex (s + L",optional", type_regex, L"type")), - name_set_)); - } - - // Data member. - // - a.context ().set ("member", find_name (b + L"_", name_set_)); - - // Wildcard id. - // - if (ordered_p (c)) - { - String id ( - escape ( - process_regex ( - s + L",id", const_regex, L"const"))); - - a.context ().set ("ordered-id-name", find_name (id, name_set_)); - } - - if (!has_wildcard_) - has_wildcard_ = true; - } - - virtual void - traverse (SemanticGraph::AnyAttribute& a) - { - String s (find_name (L"any,attribute", stem_set_)); - - String b (find_name (escape (s), name_set_, false)); - a.context ().set ("name", b); - - // Accessors/modifiers. Note that we postpone inserting the - // names into the name_set to avoid over-escaping. - // - String an ( - find_name ( - escape (process_regex (s, accessor_regex, L"accessor")), - name_set_, - false)); - - String mn ( - find_name ( - escape (process_regex (s, modifier_regex, L"modifier")), - name_set_, - false)); - - a.context ().set ("aname", an); - a.context ().set ("mname", mn); - - name_set_.insert (b); - - if (an != b) - name_set_.insert (an); - - if (mn != b && mn != an) - name_set_.insert (mn); - - // Types - // - a.context ().set ( - "container", - find_name ( - escape (process_regex (s + L",set", type_regex, L"type")), - name_set_)); - - a.context ().set ( - "iterator", - find_name ( - escape (process_regex (s + L",iterator", type_regex, L"type")), - name_set_)); - - a.context ().set ( - "const-iterator", - find_name ( - escape ( - process_regex (s + L",const,iterator", type_regex, L"type")), - name_set_)); - - // Data member. - // - a.context ().set ("member", find_name (b + L"_", name_set_)); - - if (!has_wildcard_) - has_wildcard_ = true; - } - - private: - NameSet& name_set_; - NameSet& stem_set_; - bool& has_wildcard_; - }; - - // - // - struct Complex: Traversal::Complex, Context - { - Complex (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& c) - { - SemanticGraph::Context& ctx (c.context ()); - - // We leave this set around to allow other mappings to use - // this information. - // - ctx.set ("cxx-tree-name-processor-stem-set", NameSet ()); - ctx.set ("cxx-tree-name-processor-member-set", NameSet ()); - - // Use processed name. - // - String name (ctx.get ("name")); - - // If renamed name is empty then we are not generating - // anything for this type and name processing is not - // required. - // - if (renamed_type (c, name) && !name) - return; - - NameSet& stem_set ( - ctx.get ("cxx-tree-name-processor-stem-set")); - - NameSet& member_set ( - ctx.get ("cxx-tree-name-processor-member-set")); - - stem_set.insert (c.name ()); - member_set.insert (name); - - // Add our base's stems and members to the initial list. - // - if (c.inherits_p ()) - { - // @@ What if this types name is the same as one of base's - // members? - // - SemanticGraph::Type& base (c.inherits ().base ()); - - if (base.is_a () && - !base.is_a ()) - { - if (!base.context ().count ( - "cxx-tree-name-processor-member-set")) - { - dispatch (base); - } - - NameSet const& base_stem_set ( - base.context ().get ( - "cxx-tree-name-processor-stem-set")); - - stem_set.insert (base_stem_set.begin (), base_stem_set.end ()); - - NameSet const& base_member_set ( - base.context ().get ( - "cxx-tree-name-processor-member-set")); - - member_set.insert (base_member_set.begin (), - base_member_set.end ()); - } - } - - // First assign the "primary" names. - // - { - PrimaryMember member (*this, member_set, stem_set); - Traversal::Names names (member); - - Complex::names (c, names); - } - - // Derived names for members. - // - { - DerivedMember member (*this, member_set); - Traversal::Names names (member); - - Complex::names (c, names); - } - - // Names for the mixed content. - // - if (mixed_p (c)) - { - // Check if we already have the mixed content down inheritance - // hierarchy. - // - using SemanticGraph::Complex; - - for (Complex* p (&c); p->inherits_p ();) - { - if (Complex* b = dynamic_cast ( - &p->inherits ().base ())) - { - if (mixed_p (*b)) - { - SemanticGraph::Context& bctx (b->context ()); - ctx.set ("mixed-type", bctx.get ("mixed-type")); - ctx.set ("mixed-const-iterator", - bctx.get ("mixed-const-iterator")); - ctx.set ("mixed-ordered-id-name", - bctx.get ("mixed-ordered-id-name")); - ctx.set ("mixed-aname", bctx.get ("mixed-aname")); - ctx.set ("mixed-member", bctx.get ("mixed-member")); - ctx.set ("mixed-in-base", true); - break; - } - - p = b; - } - else - break; - } - - // If not, set up the names. - // - if (!ctx.count ("mixed-in-base")) - { - String s (find_name (L"text,content", stem_set)); - String n (find_name (escape (s), member_set, false)); - - String an (find_name ( - escape (process_regex (s, - seq_accessor_regex, - accessor_regex, - L"sequence accessor")), - member_set, - false)); - - String mn (find_name ( - escape (process_regex (s, - seq_modifier_regex, - modifier_regex, - L"sequence modifier")), - member_set, - false)); - - ctx.set ("mixed-aname", an); - ctx.set ("mixed-mname", mn); - - member_set.insert (name); - - if (an != n) - member_set.insert (an); - - if (mn != n && mn != an) - member_set.insert (mn); - - // Types. - // - ctx.set ( - "mixed-type", - find_name ( - escape (process_regex (s + L",type", type_regex, L"type")), - member_set)); - - ctx.set ( - "mixed-container", - find_name ( - escape (process_regex (s + L",sequence", type_regex, L"type")), - member_set)); - - ctx.set ( - "mixed-iterator", - find_name ( - escape (process_regex (s + L",iterator", type_regex, L"type")), - member_set)); - - ctx.set ( - "mixed-const-iterator", - find_name ( - escape ( - process_regex (s + L",const,iterator", type_regex, L"type")), - member_set)); - - // Text content id. - // - ctx.set ( - "mixed-ordered-id-name", - find_name ( - escape ( - process_regex (s + L",id", const_regex, L"const")), - member_set)); - - // Data member. - // - ctx.set ("mixed-member", find_name (n + L"_", member_set)); - } - } - - // Names for wildcards. - // - if (options.generate_wildcard ()) - { - bool has_wildcard (false); - Any any (*this, member_set, stem_set, has_wildcard); - Traversal::Names names (any); - Complex::names (c, names); - - // Assign names for dom_document. - // - if (has_wildcard) - { - // Check if we already have dom_document down inheritance - // hierarchy. - // - for (SemanticGraph::Complex* p (&c); p->inherits_p ();) - { - if (SemanticGraph::Complex* base = - dynamic_cast ( - &p->inherits ().base ())) - { - if (base->context ().count ("dom-document")) - { - c.context ().set ( - "dom-document", - base->context ().get ("dom-document")); - break; - } - - p = base; - } - else - break; - } - - // If not, set up the names. - // - if (!c.context ().count ("dom-document")) - { - String stem (find_name (L"dom,document", stem_set)); - - String an ( - escape ( - process_regex (stem, accessor_regex, L"accessor"))); - - c.context ().set ("dom-document", find_name (an, member_set)); - - c.context ().set ( - "dom-document-member", - find_name (escape (stem + L"_"), member_set)); - } - } - } - - // Names for the order container. - // - if (ordered_p (c)) - { - // Check if we already have the order container down - // inheritance hierarchy. - // - using SemanticGraph::Complex; - - for (Complex* p (&c); p->inherits_p ();) - { - if (Complex* b = dynamic_cast ( - &p->inherits ().base ())) - { - if (ordered_p (*b)) - { - SemanticGraph::Context& bctx (b->context ()); - ctx.set ("order-type", bctx.get ("order-type")); - ctx.set ("order-const-iterator", - bctx.get ("order-const-iterator")); - ctx.set ("order-aname", bctx.get ("order-aname")); - ctx.set ("order-member", bctx.get ("order-member")); - ctx.set ("order-in-base", true); - break; - } - - p = b; - } - else - break; - } - - // If not, set up the names. - // - if (!ctx.count ("order-in-base")) - { - String s (find_name (L"content,order", stem_set)); - String n (find_name (escape (s), member_set, false)); - - String an (find_name ( - escape (process_regex (s, - seq_accessor_regex, - accessor_regex, - L"sequence accessor")), - member_set, - false)); - - String mn (find_name ( - escape (process_regex (s, - seq_modifier_regex, - modifier_regex, - L"sequence modifier")), - member_set, - false)); - - ctx.set ("order-aname", an); - ctx.set ("order-mname", mn); - - member_set.insert (name); - - if (an != n) - member_set.insert (an); - - if (mn != n && mn != an) - member_set.insert (mn); - - // Types. - // - ctx.set ( - "order-type", - find_name ( - escape (process_regex (s + L",type", type_regex, L"type")), - member_set)); - - ctx.set ( - "order-container", - find_name ( - escape (process_regex (s + L",sequence", type_regex, L"type")), - member_set)); - - ctx.set ( - "order-iterator", - find_name ( - escape (process_regex (s + L",iterator", type_regex, L"type")), - member_set)); - - ctx.set ( - "order-const-iterator", - find_name ( - escape ( - process_regex (s + L",const,iterator", type_regex, L"type")), - member_set)); - - // Data member. - // - ctx.set ("order-member", find_name (n + L"_", member_set)); - } - } - } - }; - - - // - // - struct GlobalType: Traversal::Type, Context - { - GlobalType (Context& c, NameSet& set) - : Context (c), set_ (set) - { - } - - virtual void - traverse (SemanticGraph::Type& t) - { - // Process the name with type name regex. - // - String name (process_regex ( - namespace_ (t).name (), - t.name (), - type_regex, - L"type")); - - // Escape and unclash. - // - name = find_name (escape (name), set_); - t.context ().set ("name", name); - - // Also add renamed name if any. - // - if (renamed_type (t, name) && name) - set_.insert (name); - } - - private: - NameSet& set_; - }; - - - // - // - struct GlobalElement: Traversal::Element, - GlobalElementBase, - Context - { - GlobalElement (Context& c, - NameSet const& type_set, - NameSet& element_set) - : GlobalElementBase (c), - Context (c), - type_set_ (type_set), - element_set_ (element_set) - { - } - - virtual void - traverse (Type& e) - { - // First we need to figure out if we need to process this - // global element. - // - if (!generate_p (e)) - return; - - if (options.generate_element_type ()) - { - SemanticGraph::Context& ec (e.context ()); - - String name; - - if (doc_root_p (e)) - { - name = find_name ( - escape ( - process_regex ( - namespace_ (e).name (), - e.name (), - element_type_regex, - type_regex, - L"element type"))); - - // Assign inner names. - // - NameSet set; - set.insert (name); - - ec.set ( - "type", - Context::find_name ( - escape (process_regex (L"value,type", type_regex, L"type")), - set)); - - ec.set ( - "traits", - Context::find_name ( - escape (process_regex (L"value,traits", type_regex, L"type")), - set)); - - String an (Context::find_name ( - escape (process_regex ("value", - one_accessor_regex, - accessor_regex, - L"one accessor")), - set, - false)); - - String mn (Context::find_name ( - escape (process_regex ("value", - one_modifier_regex, - modifier_regex, - L"one modifier")), - set, - false)); - - ec.set ("aname", an); - ec.set ("mname", mn); - - set.insert (an); - - if (an != mn) - set.insert (mn); - - // Detach. - // - if (detach) - { - String dn (Context::find_name ( - escape (process_regex (L"detach,value", - one_modifier_regex, - modifier_regex, - L"one modifier")), - set)); - - ec.set ("dname", dn); - } - - // Assign name() and namespace_() names. - // - ec.set ( - "element-name", - Context::find_name ( - escape ( - process_regex ("name", accessor_regex, L"modifier")), - set)); - - ec.set ( - "element-ns", - Context::find_name ( - escape ( - process_regex ("namespace", accessor_regex, L"modifier")), - set)); - - // Data members. - // - ec.set ("member", Context::find_name ("value_", set)); - ec.set ("element-name-member", - Context::find_name ("name_", set)); - ec.set ("element-ns-member", - Context::find_name ("namespace__", set)); - } - else - name = find_name (escape (e.name ())); - - ec.set ("name", name); - element_set_.insert (name); - } - else - { - // Make sure the name is unique among global elements and - // does not collide with a global type name. - // - String base (find_name (escape (e.name ()))); - e.context ().set ("name", base); - - String n (e.name ()); - - // Assign the parsing function name. - // - String p; - - if (!options.suppress_parsing () && doc_root_p (e)) - { - p = find_name ( - escape ( - process_regex (n, parser_regex, L"parsing function"))); - - e.context ().set ("parser", p); - } - - // Assign the serialization function name. - // - String s; - - if (options.generate_serialization () && doc_root_p (e)) - { - s = find_name ( - escape ( - process_regex ( - n, serializer_regex, L"serialization function"))); - - e.context ().set ("serializer", s); - } - - // Add the names to the set only after processing parsing and - // serialization function names so that we do not over-escape - // them. - // - element_set_.insert (base); - - if (p && p != base) - element_set_.insert (p); - - if (s && s != base && s != p) - element_set_.insert (s); - } - } - - private: - String - find_name (String const& name) - { - String r (name); - - // If we are conflicting with a type name let's first try to - // simply append an underscore and only resort to ugly names - // like name1, etc., if this fails. - // - if (type_set_.find (r) != type_set_.end ()) - r += L"_"; - - for (size_t i (1); - element_set_.find (r) != element_set_.end () || - type_set_.find (r) != type_set_.end (); ++i) - { - std::wostringstream os; - os << i; - r = name + os.str (); - } - - return r; - } - - private: - NameSet const& type_set_; - NameSet& element_set_; - }; - - struct NamespacePassOne: Traversal::Namespace, Context - { - NamespacePassOne (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& ns) - { - NameSet& type_set (global_type_names[ns.name ()]); - - GlobalType type (*this, type_set); - Traversal::Names names (type); - - Traversal::Namespace::names (ns, names); - Traversal::Namespace::names (ns); - } - }; - - - struct NamespacePassThree: Traversal::Namespace, Context - { - NamespacePassThree (Context& c) - : Context (c) - { - } - - virtual void - traverse (Type& ns) - { - String const& name (ns.name ()); - - NameSet const& type_set (global_type_names[name]); - NameSet& element_set (global_element_names[name]); - - GlobalElement element (*this, type_set, element_set); - Traversal::Names names (element); - - Traversal::Namespace::names (ns, names); - } - }; - - - struct FundamentalNamespace: Traversal::Namespace, - - Traversal::AnyType, - Traversal::AnySimpleType, - - Traversal::Fundamental::Byte, - Traversal::Fundamental::UnsignedByte, - Traversal::Fundamental::Short, - Traversal::Fundamental::UnsignedShort, - Traversal::Fundamental::Int, - Traversal::Fundamental::UnsignedInt, - Traversal::Fundamental::Long, - Traversal::Fundamental::UnsignedLong, - Traversal::Fundamental::Integer, - Traversal::Fundamental::NonPositiveInteger, - Traversal::Fundamental::NonNegativeInteger, - Traversal::Fundamental::PositiveInteger, - Traversal::Fundamental::NegativeInteger, - - Traversal::Fundamental::Boolean, - - Traversal::Fundamental::Float, - Traversal::Fundamental::Double, - Traversal::Fundamental::Decimal, - - Traversal::Fundamental::String, - Traversal::Fundamental::NormalizedString, - Traversal::Fundamental::Token, - Traversal::Fundamental::Name, - Traversal::Fundamental::NameToken, - Traversal::Fundamental::NameTokens, - Traversal::Fundamental::NCName, - Traversal::Fundamental::Language, - - Traversal::Fundamental::Id, - Traversal::Fundamental::IdRef, - Traversal::Fundamental::IdRefs, - - Traversal::Fundamental::AnyURI, - - Traversal::Fundamental::QName, - - Traversal::Fundamental::Base64Binary, - Traversal::Fundamental::HexBinary, - - Traversal::Fundamental::Date, - Traversal::Fundamental::DateTime, - Traversal::Fundamental::Duration, - Traversal::Fundamental::Day, - Traversal::Fundamental::Month, - Traversal::Fundamental::MonthDay, - Traversal::Fundamental::Year, - Traversal::Fundamental::YearMonth, - Traversal::Fundamental::Time, - - Traversal::Fundamental::Entity, - Traversal::Fundamental::Entities, - - Context - { - FundamentalNamespace (Context& c) - : Context (c) - { - *this >> names_ >> *this; - } - - void - process_name (SemanticGraph::Type& t, String const& name) - { - String r ( - process_regex ( - namespace_ (t).name (), name, type_regex, L"type")); - - t.context ().set ("name", escape (r)); - } - - void - process_name (SemanticGraph::Namespace& n, - String const& name, - char const* key) - { - String r (process_regex (name, type_regex, L"type")); - n.context ().set (key, escape (r)); - } - - // anyType and anySimpleType - // - virtual void - traverse (SemanticGraph::AnyType& t) - { - process_name (t, "type"); - } - - virtual void - traverse (SemanticGraph::AnySimpleType& t) - { - process_name (t, "simple,type"); - } - - // Integrals. - // - virtual void - traverse (SemanticGraph::Fundamental::Byte& t) - { - process_name (t, "byte"); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedByte& t) - { - process_name (t, "unsigned,byte"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Short& t) - { - process_name (t, "short"); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedShort& t) - { - process_name (t, "unsigned,short"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Int& t) - { - process_name (t, "int"); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedInt& t) - { - process_name (t, "unsigned,int"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Long& t) - { - process_name (t, "long"); - } - - virtual void - traverse (SemanticGraph::Fundamental::UnsignedLong& t) - { - process_name (t, "unsigned,long"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Integer& t) - { - process_name (t, "integer"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) - { - process_name (t, "non,positive,integer"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) - { - process_name (t, "non,negative,integer"); - } - - virtual void - traverse (SemanticGraph::Fundamental::PositiveInteger& t) - { - process_name (t, "positive,integer"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NegativeInteger& t) - { - process_name (t, "negative,integer"); - } - - // Boolean. - // - virtual void - traverse (SemanticGraph::Fundamental::Boolean& t) - { - process_name (t, "boolean"); - } - - // Floats. - // - virtual void - traverse (SemanticGraph::Fundamental::Float& t) - { - process_name (t, "float"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Double& t) - { - process_name (t, "double"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Decimal& t) - { - process_name (t, "decimal"); - } - - // Strings. - // - virtual void - traverse (SemanticGraph::Fundamental::String& t) - { - process_name (t, "string"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NormalizedString& t) - { - process_name (t, "normalized,string"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Token& t) - { - process_name (t, "token"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NameToken& t) - { - process_name (t, "nmtoken"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NameTokens& t) - { - process_name (t, "nmtokens"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Name& t) - { - process_name (t, "name"); - } - - virtual void - traverse (SemanticGraph::Fundamental::NCName& t) - { - process_name (t, "ncname"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Language& t) - { - process_name (t, "language"); - } - - // ID/IDREF. - // - virtual void - traverse (SemanticGraph::Fundamental::Id& t) - { - process_name (t, "id"); - } - - virtual void - traverse (SemanticGraph::Fundamental::IdRef& t) - { - process_name (t, "idref"); - } - - virtual void - traverse (SemanticGraph::Fundamental::IdRefs& t) - { - process_name (t, "idrefs"); - } - - - // URI. - // - virtual void - traverse (SemanticGraph::Fundamental::AnyURI& t) - { - process_name (t, "uri"); - } - - // Qualified name. - // - virtual void - traverse (SemanticGraph::Fundamental::QName& t) - { - process_name (t, "qname"); - } - - // Binary. - // - virtual void - traverse (SemanticGraph::Fundamental::Base64Binary& t) - { - process_name (t, "base64,binary"); - } - - virtual void - traverse (SemanticGraph::Fundamental::HexBinary& t) - { - process_name (t, "hex,binary"); - } - - - // Date/time. - // - virtual void - traverse (SemanticGraph::Fundamental::Date& t) - { - process_name (t, "date"); - } - - virtual void - traverse (SemanticGraph::Fundamental::DateTime& t) - { - process_name (t, "date,time"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Duration& t) - { - process_name (t, "duration"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Day& t) - { - process_name (t, "gday"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Month& t) - { - process_name (t, "gmonth"); - } - - virtual void - traverse (SemanticGraph::Fundamental::MonthDay& t) - { - process_name (t, "gmonth,day"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Year& t) - { - process_name (t, "gyear"); - } - - virtual void - traverse (SemanticGraph::Fundamental::YearMonth& t) - { - process_name (t, "gyear,month"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Time& t) - { - process_name (t, "time"); - } - - // Entity. - // - virtual void - traverse (SemanticGraph::Fundamental::Entity& t) - { - process_name (t, "entity"); - } - - virtual void - traverse (SemanticGraph::Fundamental::Entities& t) - { - process_name (t, "entities"); - } - - virtual void - post (SemanticGraph::Namespace& n) - { - // Assign names to extra stuff in the XML Schema namespace. - // - process_name (n, "container", "container"); - process_name (n, "buffer", "buffer"); - process_name (n, "time,zone", "time-zone"); - - process_name (n, "content,order", "content-order"); - - if (options.generate_element_type ()) - process_name (n, "element,type", "element-type"); - - if (options.generate_element_map ()) - process_name (n, "element,map", "element-map"); - - if (options.generate_serialization ()) - { - process_name (n, "namespace,info", "namespace-info"); - process_name (n, "namespace,infomap", "namespace-infomap"); - process_name (n, "list,stream", "list-stream"); - process_name (n, "as,double", "as-double"); - process_name (n, "as,decimal", "as-decimal"); - process_name (n, "facet", "facet"); - } - - if (!options.generate_insertion ().empty ()) - { - process_name (n, "ostream", "ostream"); - } - - if (!options.generate_extraction ().empty ()) - { - process_name (n, "istream", "istream"); - } - - process_name (n, "flags", "flags"); - process_name (n, "properties", "properties"); - - NarrowString fn (options.function_naming ()); - - if (fn == "knr") - n.context ().set ("tree-node-key", String ("tree_node_key")); - else - n.context ().set ("tree-node-key", String ("treeNodeKey")); - - process_name (n, "exception", "exception"); - process_name (n, "parsing", "parsing"); - process_name (n, "expected,element", "expected-element"); - process_name (n, "unexpected,element", "unexpected-element"); - process_name (n, "expected,attribute", "expected-attribute"); - process_name (n, "unexpected,enumerator", "unexpected-enumerator"); - process_name (n, "expected,text,content", "expected-text-content"); - process_name (n, "no,type,info", "no-type-info"); - process_name (n, "no,element,info", "no-element-info"); - process_name (n, "not,derived", "not-derived"); - process_name (n, "duplicate,id", "duplicate-id"); - process_name (n, "serialization", "serialization"); - process_name (n, "no,namespace,mapping", "no-namespace-mapping"); - process_name (n, "no,prefix,mapping", "no-prefix-mapping"); - process_name (n, "xsi,already,in,use", "xsi-already-in-use"); - process_name (n, "bounds", "bounds"); - - process_name (n, "severity", "severity"); - process_name (n, "error", "error"); - process_name (n, "diagnostics", "diagnostics"); - - if (!options.suppress_parsing () || - options.generate_serialization ()) - { - process_name (n, "error,handler", "error-handler"); - } - - Namespace::post (n); - } - - private: - Traversal::Names names_; - }; - - - // Go into sourced/included/imported schemas while making sure - // we don't process the same stuff more than once. - // - struct UsesPassOne: Traversal::Uses - { - virtual void - traverse (Type& u) - { - SemanticGraph::Schema& s (u.schema ()); - - if (!s.context ().count ("cxx-tree-name-processor-pass-1")) - { - s.context ().set ("cxx-tree-name-processor-pass-1", true); - Traversal::Uses::traverse (u); - } - } - }; - - struct UsesPassThree: Traversal::Uses - { - virtual void - traverse (Type& u) - { - SemanticGraph::Schema& s (u.schema ()); - - if (!s.context ().count ("cxx-tree-name-processor-pass-3")) - { - s.context ().set ("cxx-tree-name-processor-pass-3", true); - Traversal::Uses::traverse (u); - } - } - }; - - // Go into implied schemas while making sure we don't process - // the same stuff more than once. - // - struct Implies: Traversal::Implies - { - virtual void - traverse (SemanticGraph::Implies& i) - { - SemanticGraph::Schema& s (i.schema ()); - - if (!s.context ().count ("cxx-tree-name-processor-seen")) - { - s.context ().set ("cxx-tree-name-processor-seen", true); - Traversal::Implies::traverse (i); - } - } - }; - - bool - process_impl (options const& ops, - SemanticGraph::Schema& tu, - SemanticGraph::Path const& file, - StringLiteralMap const& map) - { - try - { - Counts counts; - Context ctx (ops, counts, false, tu, file, map); - - if (tu.names_begin ()->named ().name () == - L"http://www.w3.org/2001/XMLSchema") - { - // XML Schema namespace. - // - Traversal::Schema xs_schema; - Traversal::Names xs_schema_names; - FundamentalNamespace xs_ns (ctx); - - xs_schema >> xs_schema_names >> xs_ns; - - xs_schema.dispatch (tu); - } - else - { - - // Pass one - assign names to global types. This pass cannot - // be combined with pass two because of possible recursive - // schema inclusions. Also note that we check first if this - // schema has already been processed which may happen in the - // file-per-type compilation mode. - // - if (!tu.context ().count ("cxx-tree-name-processor-pass-1")) - { - Traversal::Schema schema; - Traversal::Schema xs_schema; - UsesPassOne uses; - Implies implies; - - schema >> uses >> schema; - schema >> implies >> xs_schema; - - Traversal::Names schema_names; - Traversal::Names xs_schema_names; - NamespacePassOne ns (ctx); - FundamentalNamespace xs_ns (ctx); - - schema >> schema_names >> ns; - xs_schema >> xs_schema_names >> xs_ns; - - // Some twisted schemas do recusive self-inclusion. - // - tu.context ().set ("cxx-tree-name-processor-pass-1", true); - - schema.dispatch (tu); - } - - // Pass two - assign names inside complex types. Here - // we don't need to go into included/imported schemas. - // - { - Traversal::Schema schema; - Sources sources; - - schema >> sources >> schema; - - Traversal::Names schema_names; - Traversal::Namespace ns; - Traversal::Names ns_names; - - schema >> schema_names >> ns >> ns_names; - - Complex complex (ctx); - Traversal::Enumeration enumeration; // Avoid fallback on complex. - - ns_names >> complex; - ns_names >> enumeration; - - schema.dispatch (tu); - } - - // Pass three - assign names to global elements as well as - // inside enums. Also note that we check first if this schema - // has already been processed which may happen in the file-per- - // type compilation mode. - // - if (!tu.context ().count ("cxx-tree-name-processor-pass-3")) - { - Traversal::Schema schema; - UsesPassThree uses; - - schema >> uses >> schema; - - Traversal::Names schema_names; - NamespacePassThree ns (ctx); - Traversal::Namespace ns_enum; - - schema >> schema_names; - - schema_names >> ns; - schema_names >> ns_enum; - - Traversal::Names ns_names; - Enumeration enumeration (ctx); - - ns_enum >> ns_names >> enumeration; - - // Some twisted schemas do recusive self-inclusion. - // - tu.context ().set ("cxx-tree-name-processor-pass-3", true); - - schema.dispatch (tu); - } - } - } - catch (Context::Failed const&) - { - // Diagnostics has already been issued. - // - return false; - } - - return true; - } - } - - bool NameProcessor:: - process (options const& ops, - SemanticGraph::Schema& tu, - SemanticGraph::Path const& file, - StringLiteralMap const& map) - { - return process_impl (ops, tu, file, map); - } - } -} diff --git a/xsd/cxx/tree/name-processor.hxx b/xsd/cxx/tree/name-processor.hxx deleted file mode 100644 index 62b3af4..0000000 --- a/xsd/cxx/tree/name-processor.hxx +++ /dev/null @@ -1,28 +0,0 @@ -// file : xsd/cxx/tree/name-processor.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_TREE_NAME_PROCESSOR_HXX -#define CXX_TREE_NAME_PROCESSOR_HXX - -#include - -#include -#include - -namespace CXX -{ - namespace Tree - { - class NameProcessor - { - public: - bool - process (options const&, - XSDFrontend::SemanticGraph::Schema&, - XSDFrontend::SemanticGraph::Path const& file, - StringLiteralMap const&); - }; - } -} - -#endif // CXX_TREE_NAME_PROCESSOR_HXX diff --git a/xsd/cxx/tree/options.cli b/xsd/cxx/tree/options.cli deleted file mode 100644 index 08c9be3..0000000 --- a/xsd/cxx/tree/options.cli +++ /dev/null @@ -1,479 +0,0 @@ -// file : xsd/cxx/tree/options.cli -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include ; // std::size_t - -include ; // NarrowString, NarrowStrings - -include ; - -namespace CXX -{ - namespace Tree - { - class options: CXX::options - { - // Polymorphism. - // - bool --generate-polymorphic - { - "Generate polymorphism-aware code. Specify this option if you use - substitution groups or \cb{xsi:type}. Use the \cb{--polymorphic-type} - or \cb{--polymorphic-type-all} option to specify which type - hierarchies are polymorphic." - }; - - NarrowStrings --polymorphic-type - { - "", - "Indicate that is a root of a polymorphic type hierarchy. The - compiler can often automatically determine which types are - polymorphic based on the substitution group declarations. However, - you may need to use this option if you are not using substitution - groups or if substitution groups are defined in another schema. You - need to specify this option when compiling every schema file that - references . The argument is an XML Schema type name - that can be optionally qualified with a namespace in the - \c{\i{namespace}\b{#}\i{name}} form." - }; - - bool --polymorphic-type-all - { - "Indicate that all types should be treated as polymorphic." - }; - - unsigned long --polymorphic-plate = 0 - { - "", - "Specify the polymorphic map plate the generated code should register - on. This functionality is primarily useful to segregate multiple - schemas that define the same polymorphic types." - }; - - // Ordered content. - // - NarrowStrings --ordered-type - { - "", - "Indicate that element order in is significant. An example - would be a complex type with unbounded choice as a content model - where the element order in XML has application-specific semantics. - For ordered types the compiler generates a special container data - member and a corresponding set of accessors and modifiers that are - used to capture the order of elements and, for mixed content, of - text. - - The argument is an XML Schema type name that can be optionally - qualified with a namespace in the \c{\i{namespace}\b{#}\i{name}} form. - Note also that you will need to specify this option when compiling - every schema file that has other ordered types derived from this - type." - }; - - bool --ordered-type-derived - { - "Automatically treat types derived from ordered bases as also - ordered. This is primarily useful if you would like to be able - to iterate over the complete content using the content order - container." - }; - - bool --ordered-type-mixed - { - "Automatically treat complex types with mixed content as ordered." - }; - - bool --ordered-type-all - { - "Indicate that element order in all types is significant." - }; - - NarrowString --order-container - { - "", - "Specify a custom class template that should be used as a container - for the content order in ordered types instead of the default - \cb{std::vector}. See \cb{--ordered-type} for more information on - ordered type. This option is primarily useful if you need to - perform more complex lookups in the content order container, for - example by element id. In this case, a container like Boost - multi-index may be more convenient. Note that if using a custom - container, you will also most likely need to include the relevant - headers using the \cb{--hxx-prologue*} options." - }; - - // Features. - // - bool --generate-serialization - { - "Generate serialization functions. Serialization functions convert - the object model back to XML." - }; - - bool --generate-ostream - { - "Generate ostream insertion operators (\cb{operator<<}) for generated - types. This allows one to easily print a fragment or the whole object - model for debugging or logging." - }; - - bool --generate-doxygen - { - "Generate documentation comments suitable for extraction by the - Doxygen documentation system. Documentation from annotations is - added to the comments if present in the schema." - }; - - bool --generate-comparison - { - "Generate comparison operators (\cb{operator==} and \cb{operator!=}) - for complex types. Comparison is performed member-wise." - }; - - bool --generate-default-ctor - { - "Generate default constructors even for types that have required - members. Required members of an instance constructed using such a - constructor are not initialized and accessing them results in - undefined behavior." - }; - - bool --generate-from-base-ctor - { - "Generate constructors that expect an instance of a base type - followed by all required members." - }; - - bool --suppress-assignment - { - "Suppress the generation of copy assignment operators for complex - types. If this option is specified, the copy assignment operators - for such types are declared private and left unimplemented." - }; - - bool --generate-detach - { - "Generate detach functions for required elements and attributes. - Detach functions for optional and sequence cardinalities are - provided by the respective containers. These functions, for - example, allow you to move sub-trees in the object model either - within the same tree or between different trees." - }; - - bool --generate-wildcard - { - "Generate accessors and modifiers as well as parsing and serialization - code for XML Schema wildcards (\cb{any} and \cb{anyAttribute}). XML - content matched by wildcards is presented as DOM fragments. Note - that you need to initialize the Xerces-C++ runtime if you are using - this option." - }; - - bool --generate-any-type - { - "Extract and store content of the XML Schema \cb{anyType} type as a - DOM fragment. Note that you need to initialize the Xerces-C++ runtime - if you are using this option." - }; - - NarrowStrings --generate-insertion - { - "", - "Generate data representation stream insertion operators for the - output stream type. Repeat this option to specify more than one - stream type. The ACE CDR stream (\cb{ACE_OutputCDR}) and RPC XDR - are recognized by the compiler and the necessary \cb{#include} - directives are automatically generated. For custom stream types use - the \cb{--hxx-prologue*} options to provide the necessary - declarations." - }; - - NarrowStrings --generate-extraction - { - "", - "Generate data representation stream extraction constructors for the - input stream type. Repeat this option to specify more than one - stream type. The ACE CDR stream (\cb{ACE_InputCDR}) and RPC XDR are - recognized by the compiler and the necessary \cb{#include} directives - are automatically generated. For custom stream types use the - \cb{--hxx-prologue*} options to provide the necessary declarations." - }; - - bool --generate-forward - { - "Generate a separate header file with forward declarations for the - types being generated." - }; - - bool --suppress-parsing - { - "Suppress the generation of the parsing functions and constructors. - Use this option to reduce the generated code size when parsing from - XML is not needed." - }; - - bool --generate-element-type - { - "Generate types instead of parsing and serialization functions for - root elements. This is primarily useful to distinguish object models - with the same root type but with different root elements." - }; - - bool --generate-element-map - { - "Generate a root element map that allows uniform parsing and - serialization of multiple root elements. This option is only valid - together with \cb{--generate-element-type}." - }; - - bool --generate-intellisense - { - "Generate workarounds for IntelliSense bugs in Visual Studio 2005 - (8.0). When this option is used, the resulting code is slightly - more verbose. IntelliSense in Visual Studio 2008 (9.0) and later - does not require these workarounds. Support for IntelliSense in - Visual Studio 2003 (7.1) is improved with this option but is - still incomplete." - }; - - bool --omit-default-attributes - { - "Omit attributes with default and fixed values from serialized XML - documents." - }; - - // Naming. - // - NarrowString --type-naming = "knr" - { - " + + + + + +
+
+ +
+ +
+
C++/Parser Mapping
+
Getting Started Guide
+ +

Copyright © @copyright@.

+ +

Permission is granted to copy, distribute and/or modify this + document under the terms of the + GNU Free + Documentation License, version 1.2; with no Invariant Sections, + no Front-Cover Texts and no Back-Cover Texts. +

+ +

This document is available in the following formats: + XHTML, + PDF, and + PostScript.

+ +
+ +

Table of Contents

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Preface + + + +
About This Document
More Information
+
1Introduction + + + +
1.1Mapping Overview
1.2Benefits
+
2Hello World Example + + + + + +
2.1Writing XML Document and Schema
2.2Translating Schema to C++
2.3Implementing Application Logic
2.4Compiling and Running
+
3Parser Skeletons + + + + + +
3.1Implementing the Gender Parser
3.2Implementing the Person Parser
3.3Implementing the People Parser
3.4Connecting the Parsers Together
+
4Type Maps + + + + +
4.1Object Model
4.2Type Map File Format
4.3Parser Implementations
+
5Mapping Configuration + + + + + + +
5.1C++ Standard
5.2Character Type and Encoding
5.3Underlying XML Parser
5.4XML Schema Validation
5.5Support for Polymorphism
+
6Built-In XML Schema Type Parsers + + + + + + + + + + + + + + +
6.1QName Parser
6.2NMTOKENS and IDREFS Parsers
6.3base64Binary and hexBinary Parsers
6.4Time Zone Representation
6.5date Parser
6.6dateTime Parser
6.7duration Parser
6.8gDay Parser
6.9gMonth Parser
6.10gMonthDay Parser
6.11gYear Parser
6.12gYearMonth Parser
6.13time Parser
+
7Document Parser and Error Handling + + + + +
7.1Xerces-C++ Document Parser
7.2Expat Document Parser
7.3Error Handling
+
Appendix A — Supported XML Schema Constructs
+
+ +

Preface

+ +

About This Document

+ +

The goal of this document is to provide you with an understanding of + the C++/Parser programming model and allow you to efficiently evaluate + XSD against your project's technical requirements. As such, this + document is intended for C++ developers and software architects + who are looking for an XML processing solution. Prior experience + with XML and C++ is required to understand this document. Basic + understanding of XML Schema is advantageous but not expected + or required. +

+ + +

More Information

+ +

Beyond this guide, you may also find the following sources of + information useful:

+ +
    +
  • XSD + Compiler Command Line Manual
  • + +
  • The cxx/parser/ directory in the + xsd-examples package + contains a collection of examples and a README file with an overview + of each example.
  • + +
  • The README file in the + xsd-examples package + explains how to build the examples.
  • + +
  • The xsd-users + mailing list is the place to ask technical questions about XSD and the C++/Parser mapping. + Furthermore, the archives + may already have answers to some of your questions.
  • + +
+ + + +

1 Introduction

+ +

Welcome to CodeSynthesis XSD and the C++/Parser mapping. XSD is a + cross-platform W3C XML Schema to C++ data binding compiler. C++/Parser + is a W3C XML Schema to C++ mapping that represents an XML vocabulary + as a set of parser skeletons which you can implement to perform XML + processing as required by your application logic. +

+ +

1.1 Mapping Overview

+ +

The C++/Parser mapping provides event-driven, stream-oriented + XML parsing, XML Schema validation, and C++ data binding. It was + specifically designed and optimized for high performance and + small footprint. Based on the static analysis of the schemas, XSD + generates compact, highly-optimized hierarchical state machines + that combine data extraction, validation, and even dispatching + in a single step. As a result, the generated code is typically + 2-10 times faster than general-purpose validating XML parsers + while maintaining the lowest static and dynamic memory footprints. +

+ +

To speed up application development, the C++/Parser mapping + can be instructed to generate sample parser implementations + and a test driver which can then be filled with the application + logic code. The mapping also provides a wide range of + mechanisms for controlling and customizing the generated code.

+ +

The next chapter shows how to create a simple application that uses + the C++/Parser mapping to parse, validate, and extract data from a + simple XML document. The following chapters show how to + use the C++/Parser mapping in more detail.

+ +

1.2 Benefits

+ +

Traditional XML access APIs such as Document Object Model (DOM) + or Simple API for XML (SAX) have a number of drawbacks that + make them less suitable for creating robust and maintainable + XML processing applications. These drawbacks include: +

+ +
    +
  • Generic representation of XML in terms of elements, attributes, + and text forces an application developer to write a substantial + amount of bridging code that identifies and transforms pieces + of information encoded in XML to a representation more suitable + for consumption by the application logic.
  • + +
  • String-based flow control defers error detection to runtime. + It also reduces code readability and maintainability.
  • + +
  • Lack of type safety because the data is represented + as text.
  • + +
  • Resulting applications are hard to debug, change, and + maintain.
  • +
+ +

In contrast, statically-typed, vocabulary-specific parser + skeletons produced by the C++/Parser mapping allow you to + operate in your domain terms instead of the generic elements, + attributes, and text. Static typing helps catch errors at + compile-time rather than at run-time. Automatic code generation + frees you for more interesting tasks (such as doing something + useful with the information stored in the XML documents) and + minimizes the effort needed to adapt your applications to + changes in the document structure. To summarize, the C++/Parser + mapping has the following key advantages over generic XML + access APIs:

+ +
    +
  • Ease of use. The generated code hides all the complexity + associated with recreating the document structure, maintaining the + dispatch state, and converting the data from the text representation + to data types suitable for manipulation by the application logic. + Parser skeletons also provide a convenient mechanism for building + custom in-memory representations.
  • + +
  • Natural representation. The generated parser skeletons + implement parser callbacks as virtual functions with names + corresponding to elements and attributes in XML. As a result, + you process the XML data using your domain vocabulary instead + of generic elements, attributes, and text. +
  • + +
  • Concise code. With a separate parser skeleton for each + XML Schema type, the application implementation is + simpler and thus easier to read and understand.
  • + +
  • Safety. The XML data is delivered to parser callbacks as + statically typed objects. The parser callbacks themselves are virtual + functions. This helps catch programming errors at compile-time + rather than at runtime.
  • + +
  • Maintainability. Automatic code generation minimizes the + effort needed to adapt the application to changes in the + document structure. With static typing, the C++ compiler + can pin-point the places in the application code that need to be + changed.
  • + +
  • Efficiency. The generated parser skeletons combine + data extraction, validation, and even dispatching in a single + step. This makes them much more efficient than traditional + architectures with separate stages for validation and data + extraction/dispatch.
  • +
+ + + + +

2 Hello World Example

+ +

In this chapter we will examine how to parse a very simple XML + document using the XSD-generated C++/Parser skeletons. + The code presented in this chapter is based on the hello + example which can be found in the cxx/parser/ directory in + the xsd-examples + package.

+ +

2.1 Writing XML Document and Schema

+ +

First, we need to get an idea about the structure + of the XML documents we are going to process. Our + hello.xml, for example, could look like this:

+ +
+<?xml version="1.0"?>
+<hello>
+
+  <greeting>Hello</greeting>
+
+  <name>sun</name>
+  <name>moon</name>
+  <name>world</name>
+
+</hello>
+  
+ +

Then we can write a description of the above XML in the + XML Schema language and save it into hello.xsd:

+ +
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+  <xs:complexType name="hello">
+    <xs:sequence>
+      <xs:element name="greeting" type="xs:string"/>
+      <xs:element name="name" type="xs:string" maxOccurs="unbounded"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="hello" type="hello"/>
+
+</xs:schema>
+  
+ +

Even if you are not familiar with XML Schema, it + should be easy to connect declarations in hello.xsd + to elements in hello.xml. The hello type + is defined as a sequence of the nested greeting and + name elements. Note that the term sequence in XML + Schema means that elements should appear in a particular order + as opposed to appearing multiple times. The name + element has its maxOccurs property set to + unbounded which means it can appear multiple times + in an XML document. Finally, the globally-defined hello + element prescribes the root element for our vocabulary. For an + easily-approachable introduction to XML Schema refer to + XML Schema Part 0: + Primer.

+ +

The above schema is a specification of our XML vocabulary; it tells + everybody what valid documents of our XML-based language should look + like. The next step is to compile this schema to generate + the object model and parsing functions.

+ +

2.2 Translating Schema to C++

+ +

Now we are ready to translate our hello.xsd to C++ parser + skeletons. To do this we invoke the XSD compiler from a terminal + (UNIX) or a command prompt (Windows): +

+ +
+$ xsd cxx-parser --std c++11 --xml-parser expat hello.xsd
+  
+ +

The --xml-parser option indicates that we want to + use Expat as the underlying XML parser (see Section + 5.3, "Underlying XML Parser"). The XSD compiler produces two + C++ files: hello-pskel.hxx and hello-pskel.cxx. + The following code fragment is taken from hello-pskel.hxx; + it should give you an idea about what gets generated: +

+ +
+class hello_pskel
+{
+public:
+  // Parser callbacks. Override them in your implementation.
+  //
+  virtual void
+  pre ();
+
+  virtual void
+  greeting (const std::string&);
+
+  virtual void
+  name (const std::string&);
+
+  virtual void
+  post_hello ();
+
+  // Parser construction API.
+  //
+  void
+  greeting_parser (xml_schema::string_pskel&);
+
+  void
+  name_parser (xml_schema::string_pskel&);
+
+  void
+  parsers (xml_schema::string_pskel& /* greeting */,
+           xml_schema::string_pskel& /* name */);
+
+private:
+  ...
+};
+  
+ +

The first four member functions shown above are called parser + callbacks. You would normally override them in your implementation + of the parser to do something useful. Let's go through all of + them one by one.

+ +

The pre() function is an initialization callback. It is + called when a new element of type hello is about + to be parsed. You would normally use this function to allocate a new + instance of the resulting type or clear accumulators that are used + to gather information during parsing. The default implementation + of this function does nothing.

+ +

The post_hello() function is a finalization callback. Its + name is constructed by adding the parser skeleton name to the + post_ prefix. The finalization callback is called when + parsing of the element is complete and the result, if any, should + be returned. Note that in our case the return type of + post_hello() is void which means there + is nothing to return. More on parser return types later. +

+ +

You may be wondering why the finalization callback is called + post_hello() instead of post() just + like pre(). The reason for this is that + finalization callbacks can have different return types and + result in function signature clashes across inheritance + hierarchies. To prevent this the signatures of finalization + callbacks are made unique by adding the type name to their names.

+ +

The greeting() and name() functions are + called when the greeting and name elements + have been parsed, respectively. Their arguments are of type + std::string and contain the data extracted from XML.

+ +

The last three functions are for connecting parsers to each other. + For example, there is a predefined parser for built-in XML Schema type + string in the XSD runtime. We will be using + it to parse the contents of greeting and + name elements, as shown in the next section.

+ +

2.3 Implementing Application Logic

+ +

At this point we have all the parts we need to do something useful + with the information stored in our XML document. The first step is + to implement the parser: +

+ +
+#include <iostream>
+#include "hello-pskel.hxx"
+
+class hello_pimpl: public hello_pskel
+{
+public:
+  virtual void
+  greeting (const std::string& g)
+  {
+    greeting_ = g;
+  }
+
+  virtual void
+  name (const std::string& n)
+  {
+    std::cout << greeting_ << ", " << n << "!" << std::endl;
+  }
+
+private:
+  std::string greeting_;
+};
+  
+ +

We left both pre() and post_hello() with the + default implementations; we don't have anything to initialize or + return. The rest is pretty straightforward: we store the greeting + in a member variable and later, when parsing names, use it to + say hello.

+ +

An observant reader my ask what happens if the name + element comes before greeting? Don't we need to + make sure greeting_ was initialized and report + an error otherwise? The answer is no, we don't have to do + any of this. The hello_pskel parser skeleton + performs validation of XML according to the schema from which + it was generated. As a result, it will check the order + of the greeting and name elements + and report an error if it is violated.

+ +

Now it is time to put this parser implementation to work:

+ +
+using namespace std;
+
+int
+main (int argc, char* argv[])
+{
+  try
+  {
+    // Construct the parser.
+    //
+    xml_schema::string_pimpl string_p;
+    hello_pimpl hello_p;
+
+    hello_p.greeting_parser (string_p);
+    hello_p.name_parser (string_p);
+
+    // Parse the XML instance.
+    //
+    xml_schema::document doc_p (hello_p, "hello");
+
+    hello_p.pre ();
+    doc_p.parse (argv[1]);
+    hello_p.post_hello ();
+  }
+  catch (const xml_schema::exception& e)
+  {
+    cerr << e << endl;
+    return 1;
+  }
+}
+  
+ +

The first part of this code snippet instantiates individual parsers + and assembles them into a complete vocabulary parser. + xml_schema::string_pimpl is an implementation of a parser + for built-in XML Schema type string. It is provided by + the XSD runtime along with parsers for other built-in types (for + more information on the built-in parsers see Chapter 6, + "Built-In XML Schema Type Parsers"). We use string_pimpl + to parse the greeting and name elements as + indicated by the calls to greeting_parser() and + name_parser(). +

+ +

Then we instantiate a document parser (doc_p). The + first argument to its constructor is the parser for + the root element (hello_p in our case). The + second argument is the root element name. +

+ +

The final piece is the calls to pre(), parse(), + and post_hello(). The call to parse() + perform the actual XML parsing while the calls to pre() and + post_hello() make sure that the parser for the root + element can perform proper initialization and cleanup.

+ +

While our parser implementation and test driver are pretty small and + easy to write by hand, for bigger XML vocabularies it can be a + substantial effort. To help with this task XSD can automatically + generate sample parser implementations and a test driver from your + schemas. You can request the generation of a sample implementation with + empty function bodies by specifying the --generate-noop-impl + option. Or you can generate a sample implementation that prints the + data store in XML by using the --generate-print-impl + option. To request the generation of a test driver you can use the + --generate-test-driver option. For more information + on these options refer to the + XSD + Compiler Command Line Manual. The 'generated' example + in the xsd-examples package + shows the sample implementation generation feature in action.

+ + +

2.4 Compiling and Running

+ +

After saving all the parts from the previous section in + driver.cxx, we are ready to compile our first + application and run it on the test XML document. On a UNIX + system this can be done with the following commands: +

+ +
+$ c++ -std=c++11 -I.../libxsd -c driver.cxx hello-pskel.cxx
+$ c++ -std=c++11 -o driver driver.o hello-pskel.o -lexpat
+$ ./driver hello.xml
+Hello, sun!
+Hello, moon!
+Hello, world!
+  
+ +

Here .../libxsd represents the path to the + libxsd package root + directory. We can also test the error handling. To test XML + well-formedness checking, we can try to parse + hello-pskel.hxx:

+ +
+$ ./driver hello-pskel.hxx
+hello-pskel.hxx:1:0: not well-formed (invalid token)
+  
+ +

We can also try to parse a valid XML but not from our + vocabulary, for example hello.xsd:

+ +
+$ ./driver hello.xsd
+hello.xsd:2:0: expected element 'hello' instead of
+'http://www.w3.org/2001/XMLSchema#schema'
+  
+ + + + + +

3 Parser Skeletons

+ +

As we have seen in the previous chapter, the XSD compiler generates + a parser skeleton class for each type defined in XML Schema. In + this chapter we will take a closer look at different functions + that comprise a parser skeleton as well as the way to connect + our implementations of these parser skeletons to create a complete + parser.

+ +

In this and subsequent chapters we will use the following schema + that describes a collection of person records. We save it in + people.xsd:

+ +
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+  <xs:simpleType name="gender">
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="male"/>
+      <xs:enumeration value="female"/>
+    </xs:restriction>
+  </xs:simpleType>
+
+  <xs:complexType name="person">
+    <xs:sequence>
+      <xs:element name="first-name" type="xs:string"/>
+      <xs:element name="last-name" type="xs:string"/>
+      <xs:element name="gender" type="gender"/>
+      <xs:element name="age" type="xs:short"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:complexType name="people">
+    <xs:sequence>
+      <xs:element name="person" type="person" maxOccurs="unbounded"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="people" type="people"/>
+
+</xs:schema>
+  
+ +

A sample XML instance to go along with this schema is saved + in people.xml:

+ +
+<?xml version="1.0"?>
+<people>
+  <person>
+    <first-name>John</first-name>
+    <last-name>Doe</last-name>
+    <gender>male</gender>
+    <age>32</age>
+  </person>
+  <person>
+    <first-name>Jane</first-name>
+    <last-name>Doe</last-name>
+    <gender>female</gender>
+    <age>28</age>
+  </person>
+</people>
+  
+ +

Compiling people.xsd with the XSD compiler results + in three parser skeletons being generated: gender_pskel, + person_pskel, and people_pskel. We are going + to examine and implement each of them in the subsequent sections.

+ +

3.1 Implementing the Gender Parser

+ +

The generated gender_pskel parser skeleton looks like + this:

+ +
+class gender_pskel: public virtual xml_schema::string_pskel
+{
+public:
+  // Parser callbacks. Override them in your implementation.
+  //
+  virtual void
+  pre ();
+
+  virtual void
+  post_gender ();
+};
+  
+ +

Notice that gender_pskel inherits from + xml_schema::string_skel which is a parser skeleton + for built-in XML Schema type string and is + predefined in the XSD runtime library. This is an example + of the general rule that parser skeletons follow: if a type + in XML Schema inherits from another then there will be an + equivalent inheritance between the corresponding parser + skeleton classes.

+ +

The pre() and post_gender() callbacks + should look familiar from the previous chapter. Let's now + implement the parser. Our implementation will simply print + the gender to cout:

+ + +
+class gender_pimpl: public gender_pskel,
+                    public xml_schema::string_pimpl
+{
+public:
+  virtual void
+  post_gender ()
+  {
+    std::string s = post_string ();
+    cout << "gender: " << s << endl;
+  }
+};
+  
+ +

While the code is quite short, there is a lot going on. First, + notice that we are inheriting from gender_pskel and + from xml_schema::string_pimpl. We've encountered + xml_schema::string_pimpl already; it is an + implementation of the xml_schema::string_pskel parser + skeleton for built-in XML Schema type string.

+ +

This is another common theme in the C++/Parser programming model: + reusing implementations of the base parsers in the derived ones with + the C++ mixin idiom. In our case, string_pimpl will + do all the dirty work of extracting the data and we can just get + it at the end with the call to post_string().

+ +

In case you are curious, here is what + xml_schema::string_pskel and + xml_schema::string_pimpl look like:

+ +
+namespace xml_schema
+{
+  class string_pskel: public simple_content
+  {
+  public:
+    virtual std::string
+    post_string () = 0;
+  };
+
+  class string_pimpl: public virtual string_pskel
+  {
+  public:
+    virtual void
+    _pre ();
+
+    virtual void
+    _characters (const xml_schema::ro_string&);
+
+    virtual std::string
+    post_string ();
+
+  protected:
+    std::string str_;
+  };
+}
+  
+ +

There are three new pieces in this code that we haven't seen yet. + They are the simple_content class as well as + the _pre() and _characters() functions. + The simple_content class is defined in the XSD + runtime and is a base class for all parser skeletons that conform + to the simple content model in XML Schema. Types with the + simple content model cannot have nested elements—only text + and attributes. There is also the complex_content + class which corresponds to the complex content mode (types with + nested elements, for example, person from + people.xsd).

+ +

The _pre() function is a parser callback. Remember we + talked about the pre() and post_*() callbacks + in the previous chapter? There are actually two more callbacks + with similar roles: _pre() and _post (). + As a result, each parser skeleton has four special callbacks:

+ +
+  virtual void
+  pre ();
+
+  virtual void
+  _pre ();
+
+  virtual void
+  _post ();
+
+  virtual void
+  post_name ();
+  
+ +

pre() and _pre() are initialization + callbacks. They get called in that order before a new instance of the type + is about to be parsed. The difference between pre() and + _pre() is conventional: pre() can + be completely overridden by a derived parser. The derived + parser can also override _pre() but has to always call + the original version. This allows you to partition initialization + into customizable and required parts.

+ +

Similarly, _post() and post_name() are + finalization callbacks with exactly the same semantics: + post_name() can be completely overridden by the derived + parser while the original _post() should always be called. +

+ +

The final bit we need to discuss in this section is the + _characters() function. As you might have guessed, it + is also a callback. A low-level one that delivers raw character content + for the type being parsed. You will seldom need to use this callback + directly. Using implementations for the built-in parsers provided by + the XSD runtime is usually a simpler and more convenient + alternative.

+ +

At this point you might be wondering why some post_*() + callbacks, for example post_string(), return some data + while others, for example post_gender(), have + void as a return type. This is a valid concern + and it will be addressed in the next chapter.

+ +

3.2 Implementing the Person Parser

+ +

The generated person_pskel parser skeleton looks like + this:

+ +
+class person_pskel: public xml_schema::complex_content
+{
+public:
+  // Parser callbacks. Override them in your implementation.
+  //
+  virtual void
+  pre ();
+
+  virtual void
+  first_name (const std::string&);
+
+  virtual void
+  last_name (const std::string&);
+
+  virtual void
+  gender ();
+
+  virtual void
+  age (short);
+
+  virtual void
+  post_person ();
+
+  // Parser construction API.
+  //
+  void
+  first_name_parser (xml_schema::string_pskel&);
+
+  void
+  last_name_parser (xml_schema::string_pskel&);
+
+  void
+  gender_parser (gender_pskel&);
+
+  void
+  age_parser (xml_schema::short_pskel&);
+
+  void
+  parsers (xml_schema::string_pskel& /* first-name */,
+           xml_schema::string_pskel& /* last-name */,
+           gender_pskel&             /* gender */,
+           xml_schema::short_pskel&  /* age */);
+};
+  
+ + +

As you can see, we have a parser callback for each of the nested + elements found in the person XML Schema type. + The implementation of this parser is straightforward:

+ +
+class person_pimpl: public person_pskel
+{
+public:
+  virtual void
+  first_name (const std::string& n)
+  {
+    cout << "first: " << f << endl;
+  }
+
+  virtual void
+  last_name (const std::string& l)
+  {
+    cout << "last: " << l << endl;
+  }
+
+  virtual void
+  age (short a)
+  {
+    cout << "age: " << a << endl;
+  }
+};
+  
+ +

Notice that we didn't override the gender() callback + because all the printing is done by gender_pimpl.

+ + +

3.3 Implementing the People Parser

+ +

The generated people_pskel parser skeleton looks like + this:

+ +
+class people_pskel: public xml_schema::complex_content
+{
+public:
+  // Parser callbacks. Override them in your implementation.
+  //
+  virtual void
+  pre ();
+
+  virtual void
+  person ();
+
+  virtual void
+  post_people ();
+
+  // Parser construction API.
+  //
+  void
+  person_parser (person_pskel&);
+
+  void
+  parsers (person_pskel& /* person */);
+};
+  
+ +

The person() callback will be called after parsing each + person element. While person_pimpl does + all the printing, one useful thing we can do in this callback is to + print an extra newline after each person record so that our + output is more readable:

+ +
+class people_pimpl: public people_pskel
+{
+public:
+  virtual void
+  person ()
+  {
+    cout << endl;
+  }
+};
+  
+ +

Now it is time to put everything together.

+ + +

3.4 Connecting the Parsers Together

+ +

At this point we have all the individual parsers implemented + and can proceed to assemble them into a complete parser + for our XML vocabulary. The first step is to instantiate + all the individual parsers that we will need:

+ +
+xml_schema::short_pimpl short_p;
+xml_schema::string_pimpl string_p;
+
+gender_pimpl gender_p;
+person_pimpl person_p;
+people_pimpl people_p;
+  
+ +

Notice that our schema uses two built-in XML Schema types: + string for the first-name and + last-name elements as well as short + for age. We will use predefined parsers that + come with the XSD runtime to handle these types. The next + step is to connect all the individual parsers. We do this + with the help of functions defined in the parser + skeletons and marked with the "Parser Construction API" + comment. One way to do it is to connect each individual + parser by calling the *_parser() functions:

+ +
+person_p.first_name_parser (string_p);
+person_p.last_name_parser (string_p);
+person_p.gender_parser (gender_p);
+person_p.age_parser (short_p);
+
+people_p.person_parser (person_p);
+  
+ +

You might be wondering what happens if you do not provide + a parser by not calling one of the *_parser() functions. + In that case the corresponding XML content will be skipped, + including validation. This is an efficient way to ignore parts + of the document that you are not interested in.

+ + +

An alternative, shorter, way to connect the parsers is by using + the parsers() functions which connects all the parsers + for a given type at once:

+ +
+person_p.parsers (string_p, string_p, gender_p, short_p);
+people_p.parsers (person_p);
+  
+ +

The following figure illustrates the resulting connections. Notice + the correspondence between return types of the post_*() + functions and argument types of element callbacks that are connected + by the arrows.

+ + +
+ +

The last step is the construction of the document parser and + invocation of the complete parser on our sample XML instance:

+ +
+xml_schema::document doc_p (people_p, "people");
+
+people_p.pre ();
+doc_p.parse ("people.xml");
+people_p.post_people ();
+  
+ +

Let's consider xml_schema::document in + more detail. While the exact definition of this class + varies depending on the underlying parser selected, + here is the common part:

+ +
+namespace xml_schema
+{
+  class document
+  {
+  public:
+    document (xml_schema::parser_base&,
+              const std::string& root_element_name,
+              bool polymorphic = false);
+
+    document (xml_schema::parser_base&,
+              const std::string& root_element_namespace,
+              const std::string& root_element_name,
+              bool polymorphic = false);
+
+    void
+    parse (const std::string& file);
+
+    void
+    parse (std::istream&);
+
+    ...
+
+  };
+}
+  
+ +

xml_schema::document is a root parser for + the vocabulary. The first argument to its constructors is the + parser for the type of the root element (people_impl + in our case). Because a type parser is only concerned with + the element's content and not with the element's name, we need + to specify the root element's name somewhere. That's + what is passed as the second and third arguments to the + document's constructors.

+ +

There are also two overloaded parse() functions + defined in the document class (there are actually + more but the others are specific to the underlying XML parser). + The first version parses a local file identified by a name. The + second version reads the data from an input stream. For more + information on the xml_schema::document class + refer to Chapter 7, "Document Parser and Error + Handling".

+ +

Let's now consider a step-by-step list of actions that happen + as we parse through people.xml. The content of + people.xml is repeated below for convenience.

+ +
+<?xml version="1.0"?>
+<people>
+  <person>
+    <first-name>John</first-name>
+    <last-name>Doe</last-name>
+    <gender>male</gender>
+    <age>32</age>
+  </person>
+  <person>
+    <first-name>Jane</first-name>
+    <last-name>Doe</last-name>
+    <gender>female</gender>
+    <age>28</age>
+  </person>
+</people>
+  
+ + +
    +
  1. people_p.pre() is called from + main(). We did not provide any implementation + for this callback so this call is a no-op.
  2. + +
  3. doc_p.parse("people.xml") is called from + main(). The parser opens the file and starts + parsing its content.
  4. + +
  5. The parser encounters the root element. doc_p + verifies that the root element is correct and calls + _pre() on people_p which is also + a no-op. Parsing is now delegated to people_p.
  6. + +
  7. The parser encounters the person element. + people_p determines that person_p + is responsible for parsing this element. pre() + and _pre() callbacks are called on person_p. + Parsing is now delegated to person_p.
  8. + +
  9. The parser encounters the first-name element. + person_p determines that string_p + is responsible for parsing this element. pre() + and _pre() callbacks are called on string_p. + Parsing is now delegated to string_p.
  10. + +
  11. The parser encounters character content consisting of + "John". The _characters() callback is + called on string_p.
  12. + +
  13. The parser encounters the end of first-name + element. The _post() and post_string() + callbacks are called on string_p. The + first_name() callback is called on person_p + with the return value of post_string(). The + first_name() implementation prints + "first: John" to cout. + Parsing is now returned to person_p.
  14. + +
  15. Steps analogous to 5-7 are performed for the last-name, + gender, and age elements.
  16. + +
  17. The parser encounters the end of person + element. The _post() and post_person() + callbacks are called on person_p. The + person() callback is called on people_p. + The person() implementation prints a new line + to cout. Parsing is now returned to + people_p.
  18. + +
  19. Steps 4-9 are performed for the second person + element.
  20. + +
  21. The parser encounters the end of people + element. The _post() callback is called on + people_p. The doc_p.parse("people.xml") + call returns to main().
  22. + +
  23. people_p.post_people() is called from + main() which is a no-op.
  24. + +
+ + + + + +

4 Type Maps

+ +

There are many useful things you can do inside parser callbacks as they + are right now. There are, however, times when you want to propagate + some information from one parser to another or to the caller of the + parser. One common task that would greatly benefit from such a + possibility is building a tree-like in-memory object model of the + data stored in XML. During execution, each individual sub-parser + would create a sub-tree and return it to its parent parser + which can then incorporate this sub-tree into the whole tree.

+ +

In this chapter we will discuss the mechanisms offered by the + C++/Parser mapping for returning information from individual + parsers and see how to use them to build an object model + of our people vocabulary.

+ +

4.1 Object Model

+ +

An object model for our person record example could + look like this (saved in the people.hxx file):

+ +
+#include <string>
+#include <vector>
+
+enum gender
+{
+  male,
+  female
+};
+
+class person
+{
+public:
+  person (const std::string& first,
+          const std::string& last,
+          ::gender gender,
+          short age)
+    : first_ (first), last_ (last),
+      gender_ (gender), age_ (age)
+  {
+  }
+
+  const std::string&
+  first () const
+  {
+    return first_;
+  }
+
+  const std::string&
+  last () const
+  {
+    return last_;
+  }
+
+  ::gender
+  gender () const
+  {
+    return gender_;
+  }
+
+  short
+  age () const
+  {
+    return age_;
+  }
+
+private:
+  std::string first_;
+  std::string last_;
+  ::gender gender_;
+  short age_;
+};
+
+typedef std::vector<person> people;
+  
+ +

While it is clear which parser is responsible for which part of + the object model, it is not exactly clear how, for + example, gender_pimpl will deliver gender + to person_pimpl. You might have noticed that + string_pimpl manages to deliver its value to the + first_name() callback of person_pimpl. Let's + see how we can utilize the same mechanism to propagate our + own data.

+ +

There is a way to tell the XSD compiler that you want to + exchange data between parsers. More precisely, for each + type defined in XML Schema, you can tell the compiler two things. + First, the return type of the post_*() callback + in the parser skeleton generated for this type. And, second, + the argument type for callbacks corresponding to elements and + attributes of this type. For example, for XML Schema type + gender we can specify the return type for + post_gender() in the gender_pskel + skeleton and the argument type for the gender() callback + in the person_pskel skeleton. As you might have guessed, + the generated code will then pass the return value from the + post_*() callback as an argument to the element or + attribute callback.

+ +

The way to tell the XSD compiler about these XML Schema to + C++ mappings is with type map files. Here is a simple type + map for the gender type from the previous paragraph:

+ +
+include "people.hxx";
+gender ::gender ::gender;
+  
+ +

The first line indicates that the generated code must include + people.hxx in order to get the definition for the + gender type. The second line specifies that both + argument and return types for the gender + XML Schema type should be the ::gender C++ enum + (we use fully-qualified C++ names to avoid name clashes). + The next section will describe the type map format in detail. + We save this type map in people.map and + then translate our schemas with the --type-map + option to let the XSD compiler know about our type map:

+ +
+$ xsd cxx-parser --std c++11 --type-map people.map people.xsd
+  
+ +

If we now look at the generated people-pskel.hxx, + we will see the following changes in the gender_pskel and + person_pskel skeletons:

+ +
+#include "people.hxx"
+
+class gender_pskel: public virtual xml_schema::string_pskel
+{
+  virtual ::gender
+  post_gender () = 0;
+
+  ...
+};
+
+class person_pskel: public xml_schema::complex_content
+{
+  virtual void
+  gender (::gender);
+
+  ...
+};
+  
+ +

Notice that #include "people.hxx" was added to + the generated header file from the type map to provide the + definition for the gender enum.

+ +

4.2 Type Map File Format

+ +

Type map files are used to define a mapping between XML Schema + and C++ types. The compiler uses this information + to determine return types of post_*() + callbacks in parser skeletons corresponding to XML Schema + types as well as argument types for callbacks corresponding + to elements and attributes of these types.

+ +

The compiler has a set of predefined mapping rules that map + the built-in XML Schema types to suitable C++ types (discussed + below) and all other types to void. + By providing your own type maps you can override these predefined + rules. The format of the type map file is presented below: +

+ +
+namespace <schema-namespace> [<cxx-namespace>]
+{
+  (include <file-name>;)*
+  ([type] <schema-type> <cxx-ret-type> [<cxx-arg-type>];)*
+}
+  
+ +

Both <schema-namespace> and + <schema-type> are regex patterns while + <cxx-namespace>, + <cxx-ret-type>, and + <cxx-arg-type> are regex pattern + substitutions. All names can be optionally enclosed in + " ", for example, to include white-spaces.

+ +

<schema-namespace> determines XML + Schema namespace. Optional <cxx-namespace> + is prefixed to every C++ type name in this namespace declaration. + <cxx-ret-type> is a C++ type name that is + used as a return type for the post_*() callback. + Optional <cxx-arg-type> is an argument + type for callbacks corresponding to elements and attributes + of this type. If <cxx-arg-type> is not + specified, it defaults to <cxx-ret-type> + if <cxx-ret-type> ends with * or + & (that is, it is a pointer or a reference) and + const <cxx-ret-type>& + otherwise. + <file-name> is a file name either in the + " " or < > format + and is added with the #include directive to + the generated code.

+ +

The # character starts a comment that ends + with a new line or end of file. To specify a name that contains + # enclose it in " ". + For example:

+ +
+namespace http://www.example.com/xmlns/my my
+{
+  include "my.hxx";
+
+  # Pass apples by value.
+  #
+  apple apple;
+
+  # Pass oranges as pointers.
+  #
+  orange orange_t*;
+}
+  
+ +

In the example above, for the + http://www.example.com/xmlns/my#orange + XML Schema type, the my::orange_t* C++ type will + be used as both return and argument types.

+ +

Several namespace declarations can be specified in a single + file. The namespace declaration can also be completely + omitted to map types in a schema without a namespace. For + instance:

+ +
+include "my.hxx";
+apple apple;
+
+namespace http://www.example.com/xmlns/my
+{
+  orange "const orange_t*";
+}
+  
+ +

The compiler has a number of predefined mapping rules for + the built-in XML Schema types which can be presented as the + following map files. The string-based XML Schema types are + mapped to either std::string or + std::wstring depending on the character type + selected (see Section 5.2, "Character Type and + Encoding" for more information). The binary XML Schema + types are mapped to either std::unique_ptr<xml_schema::buffer> + or std::auto_ptr<xml_schema::buffer> + depending on the C++ standard selected (C++11 or C++98, + respectively; refer to the --std XSD compiler + command line option for details).

+ +
+namespace http://www.w3.org/2001/XMLSchema
+{
+  boolean bool bool;
+
+  byte "signed char" "signed char";
+  unsignedByte "unsigned char" "unsigned char";
+
+  short short short;
+  unsignedShort "unsigned short" "unsigned short";
+
+  int int int;
+  unsignedInt "unsigned int" "unsigned int";
+
+  long "long long" "long long";
+  unsignedLong "unsigned long long" "unsigned long long";
+
+  integer "long long" "long long";
+
+  negativeInteger "long long" "long long";
+  nonPositiveInteger "long long" "long long";
+
+  positiveInteger "unsigned long long" "unsigned long long";
+  nonNegativeInteger "unsigned long long" "unsigned long long";
+
+  float float float;
+  double double double;
+  decimal double double;
+
+  string std::string;
+  normalizedString std::string;
+  token std::string;
+  Name std::string;
+  NMTOKEN std::string;
+  NCName std::string;
+  ID std::string;
+  IDREF std::string;
+  language std::string;
+  anyURI std::string;
+
+  NMTOKENS xml_schema::string_sequence;
+  IDREFS xml_schema::string_sequence;
+
+  QName xml_schema::qname;
+
+  base64Binary std::[auto|unique]_ptr<xml_schema::buffer>
+               std::[auto|unique]_ptr<xml_schema::buffer>;
+  hexBinary std::[auto|unique]_ptr<xml_schema::buffer>
+            std::[auto|unique]_ptr<xml_schema::buffer>;
+
+  date xml_schema::date;
+  dateTime xml_schema::date_time;
+  duration xml_schema::duration;
+  gDay xml_schema::gday;
+  gMonth xml_schema::gmonth;
+  gMonthDay xml_schema::gmonth_day;
+  gYear xml_schema::gyear;
+  gYearMonth xml_schema::gyear_month;
+  time xml_schema::time;
+}
+  
+ +

For more information about the mapping of the built-in XML Schema types + to C++ types refer to Chapter 6, "Built-In XML Schema Type + Parsers". The last predefined rule maps anything that wasn't + mapped by previous rules to void:

+ +
+namespace .*
+{
+  .* void void;
+}
+  
+ + +

When you provide your own type maps with the + --type-map option, they are evaluated first. This + allows you to selectively override any of the predefined rules. + Note also that if you change the mapping + of a built-in XML Schema type then it becomes your responsibility + to provide the corresponding parser skeleton and implementation + in the xml_schema namespace. You can include the + custom definitions into the generated header file using the + --hxx-prologue-* options.

+ +

4.3 Parser Implementations

+ +

With the knowledge from the previous section, we can proceed + with creating a type map that maps types in the people.xsd + schema to our object model classes in + people.hxx. In fact, we already have the beginning + of our type map file in people.map. Let's extend + it with the rest of the types:

+ +
+include "people.hxx";
+
+gender ::gender ::gender;
+person ::person;
+people ::people;
+  
+ +

There are a few things to note about this type map. We did not + provide the argument types for person and + people because the default constant reference is + exactly what we need. We also did not provide any mappings + for built-in XML Schema types string and + short because they are handled by the predefined + rules and we are happy with the result. Note also that + all C++ types are fully qualified. This is done to avoid + potential name conflicts in the generated code. Now we can + recompile our schema and move on to implementing the parsers:

+ +
+$ xsd cxx-parser --std c++11 --xml-parser expat --type-map people.map \
+      people.xsd
+  
+ +

Here is the implementation of our three parsers in full. One + way to save typing when implementing your own parsers is + to open the generated code and copy the signatures of parser + callbacks into your code. Or you could always auto generate the + sample implementations and fill them with your code.

+ + +
+#include "people-pskel.hxx"
+
+class gender_pimpl: public gender_pskel,
+                    public xml_schema::string_pimpl
+{
+public:
+  virtual ::gender
+  post_gender ()
+  {
+    return post_string () == "male" ? male : female;
+  }
+};
+
+class person_pimpl: public person_pskel
+{
+public:
+  virtual void
+  first_name (const std::string& f)
+  {
+    first_ = f;
+  }
+
+  virtual void
+  last_name (const std::string& l)
+  {
+    last_ = l;
+  }
+
+  virtual void
+  gender (::gender g)
+  {
+    gender_ = g;
+  }
+
+  virtual void
+  age (short a)
+  {
+    age_ = a;
+  }
+
+  virtual ::person
+  post_person ()
+  {
+    return ::person (first_, last_, gender_, age_);
+  }
+
+private:
+  std::string first_;
+  std::string last_;
+  ::gender gender_;
+  short age_;
+};
+
+class people_pimpl: public people_pskel
+{
+public:
+  virtual void
+  person (const ::person& p)
+  {
+    people_.push_back (p);
+  }
+
+  virtual ::people
+  post_people ()
+  {
+    ::people r;
+    r.swap (people_);
+    return r;
+  }
+
+private:
+  ::people people_;
+};
+  
+ +

This code fragment should look familiar by now. Just note that + all the post_*() callbacks now have return types instead + of void. Here is the implementation of the test + driver for this example:

+ +
+#include <iostream>
+
+using namespace std;
+
+int
+main (int argc, char* argv[])
+{
+  // Construct the parser.
+  //
+  xml_schema::short_pimpl short_p;
+  xml_schema::string_pimpl string_p;
+
+  gender_pimpl gender_p;
+  person_pimpl person_p;
+  people_pimpl people_p;
+
+  person_p.parsers (string_p, string_p, gender_p, short_p);
+  people_p.parsers (person_p);
+
+  // Parse the document to obtain the object model.
+  //
+  xml_schema::document doc_p (people_p, "people");
+
+  people_p.pre ();
+  doc_p.parse (argv[1]);
+  people ppl = people_p.post_people ();
+
+  // Print the object model.
+  //
+  for (people::iterator i (ppl.begin ()); i != ppl.end (); ++i)
+  {
+    cout << "first:  " << i->first () << endl
+         << "last:   " << i->last () << endl
+         << "gender: " << (i->gender () == male ? "male" : "female") << endl
+         << "age:    " << i->age () << endl
+         << endl;
+  }
+}
+  
+ +

The parser creation and assembly part is exactly the same as in + the previous chapter. The parsing part is a bit different: + post_people() now has a return value which is the + complete object model. We store it in the + ppl variable. The last bit of the code simply iterates + over the people vector and prints the information + for each person. We save the last two code fragments to + driver.cxx and proceed to compile and test + our new application:

+ + +
+$ c++ -std=c++11 -I.../libxsd -c driver.cxx people-pskel.cxx
+$ c++ -std=c++11 -o driver driver.o people-pskel.o -lexpat
+$ ./driver people.xml
+first:  John
+last:   Doe
+gender: male
+age:    32
+
+first:  Jane
+last:   Doe
+gender: female
+age:    28
+  
+ + + + + +

5 Mapping Configuration

+ +

The C++/Parser mapping has a number of configuration parameters that + determine the overall properties and behavior of the generated code. + Configuration parameters are specified with the XSD command line + options and include the C++ standard, the character type that is used + by the generated code, the underlying XML parser, whether the XML Schema + validation is performed in the generated code, and support for XML Schema + polymorphism. This chapter describes these configuration + parameters in more detail. For more ways to configure the generated + code refer to the + XSD + Compiler Command Line Manual. +

+ +

5.1 C++ Standard

+ +

The C++/Parser mapping provides support for ISO/IEC C++ 2011 (C++11) + and ISO/IEC C++ 1998/2003 (C++98). To select the C++ standard for the + generated code we use the --std XSD compiler command + line option. While the majority of the examples in this guide use + C++11, the document explains the C++11/98 usage difference and so + they can easily be converted to C++98.

+ +

5.2 Character Type and Encoding

+ +

The C++/Parser mapping has built-in support for two character types: + char and wchar_t. You can select the + character type with the --char-type command line + option. The default character type is char. The + string-based built-in XML Schema types are returned as either + std::string or std::wstring depending + on the character type selected.

+ +

Another aspect of the mapping that depends on the character type + is character encoding. For the char character type + the default encoding is UTF-8. Other supported encodings are + ISO-8859-1, Xerces-C++ Local Code Page (LPC), as well as + custom encodings. You can select which encoding should be used + in the object model with the --char-encoding command + line option.

+ +

For the wchar_t character type the encoding is + automatically selected between UTF-16 and UTF-32/UCS-4 depending + on the size of the wchar_t type. On some platforms + (for example, Windows with Visual C++ and AIX with IBM XL C++) + wchar_t is 2 bytes long. For these platforms the + encoding is UTF-16. On other platforms wchar_t is 4 bytes + long and UTF-32/UCS-4 is used.

+ +

Note also that the character encoding that is used in the object model + is independent of the encodings used in input and output XML. In fact, + all three (object mode, input XML, and output XML) can have different + encodings.

+ +

5.3 Underlying XML Parser

+ +

The C++/Parser mapping can be used with either Xerces-C++ or Expat + as the underlying XML parser. You can select the XML parser with + the --xml-parser command line option. Valid values + for this option are xerces and expat. + The default XML parser is Xerces-C++.

+ +

The generated code is identical for both parsers except for the + xml_schema::document class in which some of the + parse() functions are parser-specific as described + in Chapter 7, "Document Parser and Error Handling".

+ + +

5.4 XML Schema Validation

+ +

The C++/Parser mapping provides support for validating a + commonly-used subset of W3C XML Schema in the generated code. + For the list of supported XML Schema constructs refer to + Appendix A, "Supported XML Schema Constructs".

+ +

By default validation in the generated code is disabled if + the underlying XML parser is validating (Xerces-C++) and + enabled otherwise (Expat). See Section 5.3, + "Underlying XML Parser" for more information about + the underlying XML parser. You can override the default + behavior with the --generate-validation + and --suppress-validation command line options.

+ + +

5.5 Support for Polymorphism

+ +

By default the XSD compiler generates non-polymorphic code. If your + vocabulary uses XML Schema polymorphism in the form of xsi:type + and/or substitution groups, then you will need to compile your schemas + with the --generate-polymorphic option to produce + polymorphism-aware code as well as pass true as the last + argument to the xml_schema::document's constructors.

+ +

When using the polymorphism-aware generated code, you can specify + several parsers for a single element by passing a parser map + instead of an individual parser to the parser connection function + for the element. One of the parsers will then be looked up and used + depending on the xsi:type attribute value or an element + name from a substitution group. Consider the following schema as an + example:

+ +
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+  <xs:complexType name="person">
+    <xs:sequence>
+      <xs:element name="name" type="xs:string"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <!-- substitution group root -->
+  <xs:element name="person" type="person"/>
+
+  <xs:complexType name="superman">
+    <xs:complexContent>
+      <xs:extension base="person">
+        <xs:attribute name="can-fly" type="xs:boolean"/>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+
+  <xs:element name="superman"
+              type="superman"
+              substitutionGroup="person"/>
+
+  <xs:complexType name="batman">
+    <xs:complexContent>
+      <xs:extension base="superman">
+        <xs:attribute name="wing-span" type="xs:unsignedInt"/>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+
+  <xs:element name="batman"
+              type="batman"
+              substitutionGroup="superman"/>
+
+  <xs:complexType name="supermen">
+    <xs:sequence>
+      <xs:element ref="person" maxOccurs="unbounded"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="supermen" type="supermen"/>
+
+</xs:schema>
+  
+ +

Conforming XML documents can use the superman + and batman types in place of the person + type either by specifying the type with the xsi:type + attributes or by using the elements from the substitution + group, for instance:

+ + +
+<supermen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+  <person>
+    <name>John Doe</name>
+  </person>
+
+  <superman can-fly="false">
+    <name>James "007" Bond</name>
+  </superman>
+
+  <superman can-fly="true" wing-span="10" xsi:type="batman">
+    <name>Bruce Wayne</name>
+  </superman>
+
+</supermen>
+  
+ +

To print the data stored in such XML documents we can implement + the parsers as follows:

+ +
+class person_pimpl: public virtual person_pskel
+{
+public:
+  virtual void
+  pre ()
+  {
+    cout << "starting to parse person" << endl;
+  }
+
+  virtual void
+  name (const std::string& v)
+  {
+    cout << "name: " << v << endl;
+  }
+
+  virtual void
+  post_person ()
+  {
+    cout << "finished parsing person" << endl;
+  }
+};
+
+class superman_pimpl: public virtual superman_pskel,
+                      public person_pimpl
+{
+public:
+  virtual void
+  pre ()
+  {
+    cout << "starting to parse superman" << endl;
+  }
+
+  virtual void
+  can_fly (bool v)
+  {
+    cout << "can-fly: " << v << endl;
+  }
+
+  virtual void
+  post_person ()
+  {
+    post_superman ();
+  }
+
+  virtual void
+  post_superman ()
+  {
+    cout << "finished parsing superman" << endl
+  }
+};
+
+class batman_pimpl: public virtual batman_pskel,
+                    public superman_pimpl
+{
+public:
+  virtual void
+  pre ()
+  {
+    cout << "starting to parse batman" << endl;
+  }
+
+  virtual void
+  wing_span (unsigned int v)
+  {
+    cout << "wing-span: " << v << endl;
+  }
+
+  virtual void
+  post_superman ()
+  {
+    post_batman ();
+  }
+
+  virtual void
+  post_batman ()
+  {
+    cout << "finished parsing batman" << endl;
+  }
+};
+  
+ +

Note that because the derived type parsers (superman_pskel + and batman_pskel) are called via the person_pskel + interface, we have to override the post_person() + virtual function in superman_pimpl to call + post_superman() and the post_superman() + virtual function in batman_pimpl to call + post_batman().

+ +

The following code fragment shows how to connect the parsers together. + Notice that for the person element in the supermen_p + parser we specify a parser map instead of a specific parser and we pass + true as the last argument to the document parser constructor + to indicate that we are parsing potentially-polymorphic XML documents:

+ +
+int
+main (int argc, char* argv[])
+{
+  // Construct the parser.
+  //
+  xml_schema::string_pimpl string_p;
+  xml_schema::boolean_pimpl boolean_p;
+  xml_schema::unsigned_int_pimpl unsigned_int_p;
+
+  person_pimpl person_p;
+  superman_pimpl superman_p;
+  batman_pimpl batman_p;
+
+  xml_schema::parser_map_impl person_map;
+  supermen_pimpl supermen_p;
+
+  person_p.parsers (string_p);
+  superman_p.parsers (string_p, boolean_p);
+  batman_p.parsers (string_p, boolean_p, unsigned_int_p);
+
+  // Here we are specifying a parser map which containes several
+  // parsers that can be used to parse the person element.
+  //
+  person_map.insert (person_p);
+  person_map.insert (superman_p);
+  person_map.insert (batman_p);
+
+  supermen_p.person_parser (person_map);
+
+  // Parse the XML document. The last argument to the document's
+  // constructor indicates that we are parsing polymorphic XML
+  // documents.
+  //
+  xml_schema::document doc_p (supermen_p, "supermen", true);
+
+  supermen_p.pre ();
+  doc_p.parse (argv[1]);
+  supermen_p.post_supermen ();
+}
+  
+ +

When polymorphism-aware code is generated, each element's + *_parser() function is overloaded to also accept + an object of the xml_schema::parser_map type. + For example, the supermen_pskel class from the + above example looks like this:

+ +
+class supermen_pskel: public xml_schema::parser_complex_content
+{
+public:
+
+  ...
+
+  // Parser construction API.
+  //
+  void
+  parsers (person_pskel&);
+
+  // Individual element parsers.
+  //
+  void
+  person_parser (person_pskel&);
+
+  void
+  person_parser (const xml_schema::parser_map&);
+
+  ...
+};
+  
+ +

Note that you can specify both the individual (static) parser and + the parser map. The individual parser will be used when the static + element type and the dynamic type of the object being parsed are + the same. This is the case, for example, when there is no + xsi:type attribute and the element hasn't been + substituted. Because the individual parser for an element is + cached and no map lookup is necessary, it makes sense to specify + both the individual parser and the parser map when most of the + objects being parsed are of the static type and optimal + performance is important. The following code fragment shows + how to change the above example to set both the individual + parser and the parser map:

+ +
+int
+main (int argc, char* argv[])
+{
+  ...
+
+  person_map.insert (superman_p);
+  person_map.insert (batman_p);
+
+  supermen_p.person_parser (person_p);
+  supermen_p.person_parser (person_map);
+
+  ...
+}
+  
+ + +

The xml_schema::parser_map interface and the + xml_schema::parser_map_impl default implementation + are presented below:

+ +
+namespace xml_schema
+{
+  class parser_map
+  {
+  public:
+    virtual parser_base*
+    find (const ro_string* type) const = 0;
+  };
+
+  class parser_map_impl: public parser_map
+  {
+  public:
+    void
+    insert (parser_base&);
+
+    virtual parser_base*
+    find (const ro_string* type) const;
+
+  private:
+    parser_map_impl (const parser_map_impl&);
+
+    parser_map_impl&
+    operator= (const parser_map_impl&);
+
+    ...
+  };
+}
+  
+ +

The type argument in the find() virtual + function is the type name and namespace from the xsi:type attribute + (the namespace prefix is resolved to the actual XML namespace) + or the type of an element from the substitution group in the form + "<name> <namespace>" with the space and the + namespace part absent if the type does not have a namespace. + You can obtain a parser's dynamic type in the same format + using the _dynamic_type() function. The static + type can be obtained by calling the static _static_type() + function, for example person_pskel::_static_type(). + Both functions return a C string (const char* or + const wchar_t*, depending on the character type + used) which is valid for as long as the application is running. + The following example shows how we can implement our own parser + map using std::map:

+ + +
+#include <map>
+#include <string>
+
+class parser_map: public xml_schema::parser_map
+{
+public:
+ void
+ insert (xml_schema::parser_base& p)
+ {
+   map_[p._dynamic_type ()] = &p;
+ }
+
+ virtual xml_schema::parser_base*
+ find (const xml_schema::ro_string* type) const
+ {
+   map::const_iterator i = map_.find (type);
+   return i != map_.end () ? i->second : 0;
+ }
+
+private:
+  typedef std::map<std::string, xml_schema::parser_base*> map;
+  map map_;
+};
+  
+ +

Most of code presented in this section is taken from the + polymorphism example which can be found in the + cxx/parser/ directory in the + xsd-examples package. + Handling of xsi:type and substitution groups when used on + root elements requires a number of special actions as shown in + the polyroot example.

+ + + + + +

6 Built-In XML Schema Type Parsers

+ +

The XSD runtime provides parser implementations for all built-in + XML Schema types as summarized in the following table. Declarations + for these types are automatically included into each generated + header file. As a result you don't need to include any headers + to gain access to these parser implementations. Note that some + parsers return either std::string or + std::wstring depending on the character type selected.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
XML Schema typeParser implementation in the xml_schema namespaceParser return type
anyType and anySimpleType types
anyTypeany_type_pimplvoid
anySimpleTypeany_simple_type_pimplvoid
fixed-length integral types
bytebyte_pimplsigned char
unsignedByteunsigned_byte_pimplunsigned char
shortshort_pimplshort
unsignedShortunsigned_short_pimplunsigned short
intint_pimplint
unsignedIntunsigned_int_pimplunsigned int
longlong_pimpllong long
unsignedLongunsigned_long_pimplunsigned long long
arbitrary-length integral types
integerinteger_pimpllong long
nonPositiveIntegernon_positive_integer_pimpllong long
nonNegativeIntegernon_negative_integer_pimplunsigned long long
positiveIntegerpositive_integer_pimplunsigned long long
negativeIntegernegative_integer_pimpllong long
boolean types
booleanboolean_pimplbool
fixed-precision floating-point types
floatfloat_pimplfloat
doubledouble_pimpldouble
arbitrary-precision floating-point types
decimaldecimal_pimpldouble
string-based types
stringstring_pimplstd::string or std::wstring
normalizedStringnormalized_string_pimplstd::string or std::wstring
tokentoken_pimplstd::string or std::wstring
Namename_pimplstd::string or std::wstring
NMTOKENnmtoken_pimplstd::string or std::wstring
NCNamencname_pimplstd::string or std::wstring
languagelanguage_pimplstd::string or std::wstring
qualified name
QNameqname_pimplxml_schema::qname
Section 6.1, + "QName Parser"
ID/IDREF types
IDid_pimplstd::string or std::wstring
IDREFidref_pimplstd::string or std::wstring
list types
NMTOKENSnmtokens_pimplxml_schema::string_sequence
Section + 6.2, "NMTOKENS and IDREFS Parsers"
IDREFSidrefs_pimplxml_schema::string_sequence
Section + 6.2, "NMTOKENS and IDREFS Parsers"
URI types
anyURIuri_pimplstd::string or std::wstring
binary types
base64Binarybase64_binary_pimplstd::[auto|unique]_ptr< xml_schema::buffer>
+ Section 6.3, "base64Binary and + hexBinary Parsers"
hexBinaryhex_binary_pimplstd::[auto|unique]_ptr< xml_schema::buffer>
+ Section 6.3, "base64Binary and + hexBinary Parsers"
date/time types
datedate_pimplxml_schema::date
Section 6.5, + "date Parser"
dateTimedate_time_pimplxml_schema::date_time
Section 6.6, + "dateTime Parser"
durationduration_pimplxml_schema::duration
Section 6.7, + "duration Parser"
gDaygday_pimplxml_schema::gday
Section 6.8, + "gDay Parser"
gMonthgmonth_pimplxml_schema::gmonth
Section 6.9, + "gMonth Parser"
gMonthDaygmonth_day_pimplxml_schema::gmonth_day
Section 6.10, + "gMonthDay Parser"
gYeargyear_pimplxml_schema::gyear
Section 6.11, + "gYear Parser"
gYearMonthgyear_month_pimplxml_schema::gyear_month
Section + 6.12, "gYearMonth Parser"
timetime_pimplxml_schema::time
Section 6.13, + "time Parser"
+ +

6.1 QName Parser

+ +

The return type of the qname_pimpl parser implementation + is xml_schema::qname which represents an XML qualified + name. Its interface is presented below. + Note that the std::string type in the interface becomes + std::wstring if the selected character type is + wchar_t.

+ +
+namespace xml_schema
+{
+  class qname
+  {
+  public:
+    explicit
+    qname (const std::string& name);
+    qname (const std::string& prefix, const std::string& name);
+
+    const std::string&
+    prefix () const;
+
+    void
+    prefix (const std::string&);
+
+    const std::string&
+    name () const;
+
+    void
+    name (const std::string&);
+  };
+
+  bool
+  operator== (const qname&, const qname&);
+
+  bool
+  operator!= (const qname&, const qname&);
+}
+  
+ + +

6.2 NMTOKENS and IDREFS Parsers

+ +

The return type of the nmtokens_pimpl and + idrefs_pimpl parser implementations is + xml_schema::string_sequence which represents a + sequence of strings. Its interface is presented below. + Note that the std::string type in the interface becomes + std::wstring if the selected character type is + wchar_t.

+ +
+namespace xml_schema
+{
+  class string_sequence: public std::vector<std::string>
+  {
+  public:
+    string_sequence ();
+
+    explicit
+    string_sequence (std::vector<std::string>::size_type n,
+                     const std::string& x = std::string ());
+
+    template <typename I>
+    string_sequence (const I& begin, const I& end);
+  };
+
+  bool
+  operator== (const string_sequence&, const string_sequence&);
+
+  bool
+  operator!= (const string_sequence&, const string_sequence&);
+}
+  
+ + +

6.3 base64Binary and hexBinary Parsers

+ +

The return type of the base64_binary_pimpl and + hex_binary_pimpl parser implementations is either + std::unique_ptr<xml_schema::buffer> (C++11) or + std::auto_ptr<xml_schema::buffer> (C++98), + depending on the C++ standard selected (--std XSD + compiler option). The xml_schema::buffer type + represents a binary buffer and its interface is presented below.

+ +
+namespace xml_schema
+{
+  class buffer
+  {
+  public:
+    typedef std::size_t size_t;
+
+    class bounds {}; // Out of bounds exception.
+
+  public:
+    explicit
+    buffer (size_t size = 0);
+    buffer (size_t size, size_t capacity);
+    buffer (const void* data, size_t size);
+    buffer (const void* data, size_t size, size_t capacity);
+    buffer (void* data,
+            size_t size,
+            size_t capacity,
+            bool assume_ownership);
+
+  public:
+    buffer (const buffer&);
+
+    buffer&
+    operator= (const buffer&);
+
+    void
+    swap (buffer&);
+
+  public:
+    size_t
+    capacity () const;
+
+    bool
+    capacity (size_t);
+
+  public:
+    size_t
+    size () const;
+
+    bool
+    size (size_t);
+
+  public:
+    const char*
+    data () const;
+
+    char*
+    data ();
+
+    const char*
+    begin () const;
+
+    char*
+    begin ();
+
+    const char*
+    end () const;
+
+    char*
+    end ();
+  };
+
+  bool
+  operator== (const buffer&, const buffer&);
+
+  bool
+  operator!= (const buffer&, const buffer&);
+}
+  
+ +

If the assume_ownership argument to the constructor + is true, the instance assumes the ownership of the + memory block pointed to by the data argument and will + eventually release it by calling operator delete(). The + capacity() and size() modifier functions + return true if the underlying buffer has moved. +

+ +

The bounds exception is thrown if the constructor + arguments violate the (size <= capacity) + constraint.

+ + +

6.4 Time Zone Representation

+ +

The date, dateTime, gDay, + gMonth, gMonthDay, gYear, + gYearMonth, and time XML Schema built-in + types all include an optional time zone component. The following + xml_schema::time_zone base class is used to represent + this information:

+ +
+namespace xml_schema
+{
+  class time_zone
+  {
+  public:
+    time_zone ();
+    time_zone (short hours, short minutes);
+
+    bool
+    zone_present () const;
+
+    void
+    zone_reset ();
+
+    short
+    zone_hours () const;
+
+    void
+    zone_hours (short);
+
+    short
+    zone_minutes () const;
+
+    void
+    zone_minutes (short);
+  };
+
+  bool
+  operator== (const time_zone&, const time_zone&);
+
+  bool
+  operator!= (const time_zone&, const time_zone&);
+}
+  
+ +

The zone_present() accessor function returns true + if the time zone is specified. The zone_reset() modifier + function resets the time zone object to the not specified + state. If the time zone offset is negative then both hours and + minutes components are represented as negative integers.

+ + +

6.5 date Parser

+ +

The return type of the date_pimpl parser implementation + is xml_schema::date which represents a year, a day, and a month + with an optional time zone. Its interface is presented below. + For more information on the base xml_schema::time_zone + class refer to Section 6.4, "Time Zone + Representation".

+ +
+namespace xml_schema
+{
+  class date
+  {
+  public:
+    date (int year, unsigned short month, unsigned short day);
+    date (int year, unsigned short month, unsigned short day,
+          short zone_hours, short zone_minutes);
+
+    int
+    year () const;
+
+    void
+    year (int);
+
+    unsigned short
+    month () const;
+
+    void
+    month (unsigned short);
+
+    unsigned short
+    day () const;
+
+    void
+    day (unsigned short);
+  };
+
+  bool
+  operator== (const date&, const date&);
+
+  bool
+  operator!= (const date&, const date&);
+}
+  
+ +

6.6 dateTime Parser

+ +

The return type of the date_time_pimpl parser implementation + is xml_schema::date_time which represents a year, a month, a day, + hours, minutes, and seconds with an optional time zone. Its interface + is presented below. + For more information on the base xml_schema::time_zone + class refer to Section 6.4, "Time Zone + Representation".

+ +
+namespace xml_schema
+{
+  class date_time
+  {
+  public:
+    date_time (int year, unsigned short month, unsigned short day,
+               unsigned short hours, unsigned short minutes,
+               double seconds);
+
+    date_time (int year, unsigned short month, unsigned short day,
+               unsigned short hours, unsigned short minutes,
+               double seconds, short zone_hours, short zone_minutes);
+
+    int
+    year () const;
+
+    void
+    year (int);
+
+    unsigned short
+    month () const;
+
+    void
+    month (unsigned short);
+
+    unsigned short
+    day () const;
+
+    void
+    day (unsigned short);
+
+    unsigned short
+    hours () const;
+
+    void
+    hours (unsigned short);
+
+    unsigned short
+    minutes () const;
+
+    void
+    minutes (unsigned short);
+
+    double
+    seconds () const;
+
+    void
+    seconds (double);
+  };
+
+  bool
+  operator== (const date_time&, const date_time&);
+
+  bool
+  operator!= (const date_time&, const date_time&);
+}
+  
+ +

6.7 duration Parser

+ +

The return type of the duration_pimpl parser implementation + is xml_schema::duration which represents a potentially + negative duration in the form of years, months, days, hours, minutes, + and seconds. Its interface is presented below.

+ +
+namespace xml_schema
+{
+  class duration
+  {
+  public:
+    duration (bool negative,
+              unsigned int years, unsigned int months, unsigned int days,
+              unsigned int hours, unsigned int minutes, double seconds);
+
+    bool
+    negative () const;
+
+    void
+    negative (bool);
+
+    unsigned int
+    years () const;
+
+    void
+    years (unsigned int);
+
+    unsigned int
+    months () const;
+
+    void
+    months (unsigned int);
+
+    unsigned int
+    days () const;
+
+    void
+    days (unsigned int);
+
+    unsigned int
+    hours () const;
+
+    void
+    hours (unsigned int);
+
+    unsigned int
+    minutes () const;
+
+    void
+    minutes (unsigned int);
+
+    double
+    seconds () const;
+
+    void
+    seconds (double);
+  };
+
+  bool
+  operator== (const duration&, const duration&);
+
+  bool
+  operator!= (const duration&, const duration&);
+}
+  
+ + +

6.8 gDay Parser

+ +

The return type of the gday_pimpl parser implementation + is xml_schema::gday which represents a day of the month with + an optional time zone. Its interface is presented below. + For more information on the base xml_schema::time_zone + class refer to Section 6.4, "Time Zone + Representation".

+ +
+namespace xml_schema
+{
+  class gday
+  {
+  public:
+    explicit
+    gday (unsigned short day);
+    gday (unsigned short day, short zone_hours, short zone_minutes);
+
+    unsigned short
+    day () const;
+
+    void
+    day (unsigned short);
+  };
+
+  bool
+  operator== (const gday&, const gday&);
+
+  bool
+  operator!= (const gday&, const gday&);
+}
+  
+ +

6.9 gMonth Parser

+ +

The return type of the gmonth_pimpl parser implementation + is xml_schema::gmonth which represents a month of the year + with an optional time zone. Its interface is presented below. + For more information on the base xml_schema::time_zone + class refer to Section 6.4, "Time Zone + Representation".

+ +
+namespace xml_schema
+{
+  class gmonth
+  {
+  public:
+    explicit
+    gmonth (unsigned short month);
+    gmonth (unsigned short month, short zone_hours, short zone_minutes);
+
+    unsigned short
+    month () const;
+
+    void
+    month (unsigned short);
+  };
+
+  bool
+  operator== (const gmonth&, const gmonth&);
+
+  bool
+  operator!= (const gmonth&, const gmonth&);
+}
+  
+ +

6.10 gMonthDay Parser

+ +

The return type of the gmonth_day_pimpl parser implementation + is xml_schema::gmonth_day which represents a day and a month + of the year with an optional time zone. Its interface is presented below. + For more information on the base xml_schema::time_zone + class refer to Section 6.4, "Time Zone + Representation".

+ +
+namespace xml_schema
+{
+  class gmonth_day
+  {
+  public:
+    gmonth_day (unsigned short month, unsigned short day);
+    gmonth_day (unsigned short month, unsigned short day,
+                short zone_hours, short zone_minutes);
+
+    unsigned short
+    month () const;
+
+    void
+    month (unsigned short);
+
+    unsigned short
+    day () const;
+
+    void
+    day (unsigned short);
+  };
+
+  bool
+  operator== (const gmonth_day&, const gmonth_day&);
+
+  bool
+  operator!= (const gmonth_day&, const gmonth_day&);
+}
+  
+ +

6.11 gYear Parser

+ +

The return type of the gyear_pimpl parser implementation + is xml_schema::gyear which represents a year with + an optional time zone. Its interface is presented below. + For more information on the base xml_schema::time_zone + class refer to Section 6.4, "Time Zone + Representation".

+ +
+namespace xml_schema
+{
+  class gyear
+  {
+  public:
+    explicit
+    gyear (int year);
+    gyear (int year, short zone_hours, short zone_minutes);
+
+    int
+    year () const;
+
+    void
+    year (int);
+  };
+
+  bool
+  operator== (const gyear&, const gyear&);
+
+  bool
+  operator!= (const gyear&, const gyear&);
+}
+  
+ +

6.12 gYearMonth Parser

+ +

The return type of the gyear_month_pimpl parser implementation + is xml_schema::gyear_month which represents a year and a month + with an optional time zone. Its interface is presented below. + For more information on the base xml_schema::time_zone + class refer to Section 6.4, "Time Zone + Representation".

+ +
+namespace xml_schema
+{
+  class gyear_month
+  {
+  public:
+    gyear_month (int year, unsigned short month);
+    gyear_month (int year, unsigned short month,
+                 short zone_hours, short zone_minutes);
+
+    int
+    year () const;
+
+    void
+    year (int);
+
+    unsigned short
+    month () const;
+
+    void
+    month (unsigned short);
+  };
+
+  bool
+  operator== (const gyear_month&, const gyear_month&);
+
+  bool
+  operator!= (const gyear_month&, const gyear_month&);
+}
+  
+ + +

6.13 time Parser

+ +

The return type of the time_pimpl parser implementation + is xml_schema::time which represents hours, minutes, + and seconds with an optional time zone. Its interface is presented below. + For more information on the base xml_schema::time_zone + class refer to Section 6.4, "Time Zone + Representation".

+ +
+namespace xml_schema
+{
+  class time
+  {
+  public:
+    time (unsigned short hours, unsigned short minutes, double seconds);
+    time (unsigned short hours, unsigned short minutes, double seconds,
+          short zone_hours, short zone_minutes);
+
+    unsigned short
+    hours () const;
+
+    void
+    hours (unsigned short);
+
+    unsigned short
+    minutes () const;
+
+    void
+    minutes (unsigned short);
+
+    double
+    seconds () const;
+
+    void
+    seconds (double);
+  };
+
+  bool
+  operator== (const time&, const time&);
+
+  bool
+  operator!= (const time&, const time&);
+}
+  
+ + + + + +

7 Document Parser and Error Handling

+ +

In this chapter we will discuss the xml_schema::document + type as well as the error handling mechanisms provided by the mapping + in more detail. As mentioned in Section 3.4, + "Connecting the Parsers Together", the interface of + xml_schema::document depends on the underlying XML + parser selected (Section 5.3, "Underlying XML + Parser"). The following sections describe the + document type interface for Xerces-C++ and + Expat as underlying parsers.

+ +

7.1 Xerces-C++ Document Parser

+ +

When Xerces-C++ is used as the underlying XML parser, the + document type has the following interface. Note that + if the character type is wchar_t, then the string type + in the interface becomes std::wstring + (see Section 5.2, "Character Type and Encoding").

+ +
+namespace xml_schema
+{
+  class parser_base;
+  class error_handler;
+
+  class flags
+  {
+  public:
+    // Do not validate XML documents with the Xerces-C++ validator.
+    //
+    static const unsigned long dont_validate;
+
+    // Do not initialize the Xerces-C++ runtime.
+    //
+    static const unsigned long dont_initialize;
+
+    // Disable handling of subsequent imports for the same namespace
+    // in Xerces-C++ 3.1.0 and later.
+    //
+    static const unsigned long no_multiple_imports;
+  };
+
+  class properties
+  {
+  public:
+    // Add a location for a schema with a target namespace.
+    //
+    void
+    schema_location (const std::string& namespace_,
+                     const std::string& location);
+
+    // Add a location for a schema without a target namespace.
+    //
+    void
+    no_namespace_schema_location (const std::string& location);
+  };
+
+  class document
+  {
+  public:
+    document (parser_base& root,
+              const std::string& root_element_name,
+	      bool polymorphic = false);
+
+    document (parser_base& root,
+              const std::string& root_element_namespace,
+              const std::string& root_element_name,
+	      bool polymorphic = false);
+
+  public:
+    // Parse URI or a local file.
+    //
+    void
+    parse (const std::string& uri,
+           flags = 0,
+           const properties& = properties ());
+
+    // Parse URI or a local file with a user-provided error_handler
+    // object.
+    //
+    void
+    parse (const std::string& uri,
+           error_handler&,
+           flags = 0,
+           const properties& = properties ());
+
+    // Parse URI or a local file with a user-provided ErrorHandler
+    // object. Note that you must initialize the Xerces-C++ runtime
+    // before calling this function.
+    //
+    void
+    parse (const std::string& uri,
+           xercesc::ErrorHandler&,
+           flags = 0,
+           const properties& = properties ());
+
+    // Parse URI or a local file using a user-provided SAX2XMLReader
+    // object. Note that you must initialize the Xerces-C++ runtime
+    // before calling this function.
+    //
+    void
+    parse (const std::string& uri,
+           xercesc::SAX2XMLReader&,
+           flags = 0,
+           const properties& = properties ());
+
+  public:
+    // Parse std::istream.
+    //
+    void
+    parse (std::istream&,
+           flags = 0,
+           const properties& = properties ());
+
+    // Parse std::istream with a user-provided error_handler object.
+    //
+    void
+    parse (std::istream&,
+           error_handler&,
+           flags = 0,
+           const properties& = properties ());
+
+    // Parse std::istream with a user-provided ErrorHandler object.
+    // Note that you must initialize the Xerces-C++ runtime before
+    // calling this function.
+    //
+    void
+    parse (std::istream&,
+           xercesc::ErrorHandler&,
+           flags = 0,
+           const properties& = properties ());
+
+    // Parse std::istream using a user-provided SAX2XMLReader object.
+    // Note that you must initialize the Xerces-C++ runtime before
+    // calling this function.
+    //
+    void
+    parse (std::istream&,
+           xercesc::SAX2XMLReader&,
+           flags = 0,
+           const properties& = properties ());
+
+  public:
+    // Parse std::istream with a system id.
+    //
+    void
+    parse (std::istream&,
+           const std::string& system_id,
+           flags = 0,
+           const properties& = properties ());
+
+    // Parse std::istream with a system id and a user-provided
+    // error_handler object.
+    //
+    void
+    parse (std::istream&,
+           const std::string& system_id,
+           error_handler&,
+           flags = 0,
+           const properties& = properties ());
+
+    // Parse std::istream with a system id and a user-provided
+    // ErrorHandler object. Note that you must initialize the
+    // Xerces-C++ runtime before calling this function.
+    //
+    void
+    parse (std::istream&,
+           const std::string& system_id,
+           xercesc::ErrorHandler&,
+           flags = 0,
+           const properties& = properties ());
+
+    // Parse std::istream with a system id using a user-provided
+    // SAX2XMLReader object. Note that you must initialize the
+    // Xerces-C++ runtime before calling this function.
+    //
+    void
+    parse (std::istream&,
+           const std::string& system_id,
+           xercesc::SAX2XMLReader&,
+           flags = 0,
+           const properties& = properties ());
+
+  public:
+    // Parse std::istream with system and public ids.
+    //
+    void
+    parse (std::istream&,
+           const std::string& system_id,
+           const std::string& public_id,
+           flags = 0,
+           const properties& = properties ());
+
+    // Parse std::istream with system and public ids and a user-provided
+    // error_handler object.
+    //
+    void
+    parse (std::istream&,
+           const std::string& system_id,
+           const std::string& public_id,
+           error_handler&,
+           flags = 0,
+           const properties& = properties ());
+
+    // Parse std::istream with system and public ids and a user-provided
+    // ErrorHandler object. Note that you must initialize the Xerces-C++
+    // runtime before calling this function.
+    //
+    void
+    parse (std::istream&,
+           const std::string& system_id,
+           const std::string& public_id,
+           xercesc::ErrorHandler&,
+           flags = 0,
+           const properties& = properties ());
+
+    // Parse std::istream with system and public ids using a user-
+    // provided SAX2XMLReader object. Note that you must initialize
+    // the Xerces-C++ runtime before calling this function.
+    //
+    void
+    parse (std::istream&,
+           const std::string& system_id,
+           const std::string& public_id,
+           xercesc::SAX2XMLReader&,
+           flags = 0,
+           const properties& = properties ());
+
+  public:
+    // Parse InputSource. Note that you must initialize the Xerces-C++
+    // runtime before calling this function.
+    //
+    void
+    parse (const xercesc::InputSource&,
+           flags = 0,
+           const properties& = properties ());
+
+    // Parse InputSource with a user-provided error_handler object.
+    // Note that you must initialize the Xerces-C++ runtime before
+    // calling this function.
+    //
+    void
+    parse (const xercesc::InputSource&,
+           error_handler&,
+           flags = 0,
+           const properties& = properties ());
+
+    // Parse InputSource with a user-provided ErrorHandler object.
+    // Note that you must initialize the Xerces-C++ runtime before
+    // calling this function.
+    //
+    void
+    parse (const xercesc::InputSource&,
+           xercesc::ErrorHandler&,
+           flags = 0,
+           const properties& = properties ());
+
+    // Parse InputSource using a user-provided SAX2XMLReader object.
+    // Note that you must initialize the Xerces-C++ runtime before
+    // calling this function.
+    //
+    void
+    parse (const xercesc::InputSource&,
+           xercesc::SAX2XMLReader&,
+           flags = 0,
+           const properties& = properties ());
+  };
+}
+  
+ +

The document class is a root parser for + the vocabulary. The first argument to its constructors is the + parser for the type of the root element. The parser_base + class is the base type for all parser skeletons. The second and + third arguments to the document's constructors are + the root element's name and namespace. The last argument, + polymorphic, specifies whether the XML documents + being parsed use polymorphism. For more information on support + for XML Schema polymorphism in the C++/Parser mapping refer + to Section 5.5, "Support for Polymorphism".

+ +

The rest of the document interface consists of overloaded + parse() functions. The last two arguments in each of these + functions are flags and properties. The + flags argument allows you to modify the default behavior + of the parsing functions. The properties argument allows + you to override the schema location attributes specified in XML + documents. Note that the schema location paths are relative to an + XML document unless they are complete URIs. For example if you want + to use a local schema file then you will need to use a URI in the + form file:///absolute/path/to/your/schema.

+ +

A number of overloaded parse() functions have the + system_id and public_id arguments. The + system id is a system identifier of the resources being + parsed (for example, URI or a full file path). The public id is a + public identifier of the resource (for example, an + application-specific name or a relative file path). The system id + is used to resolve relative paths (for example, schema paths). In + diagnostics messages the public id is used if it is available. + Otherwise the system id is used.

+ +

The error handling mechanisms employed by the document + parser are described in Section 7.3, "Error + Handling".

+ +

7.2 Expat Document Parser

+ +

When Expat is used as the underlying XML parser, the + document type has the following interface. Note that + if the character type is wchar_t, then the string type + in the interface becomes std::wstring + (see Section 5.2, "Character Type and Encoding").

+ +
+namespace xml_schema
+{
+  class parser_base;
+  class error_handler;
+
+  class document
+  {
+  public:
+    document (parser_base&,
+              const std::string& root_element_name,
+              bool polymorphic = false);
+
+    document (parser_base&,
+              const std::string& root_element_namespace,
+              const std::string& root_element_name,
+              bool polymorphic = false);
+
+  public:
+    // Parse a local file. The file is accessed with std::ifstream
+    // in binary mode. The std::ios_base::failure exception is used
+    // to report io errors (badbit and failbit).
+    void
+    parse (const std::string& file);
+
+    // Parse a local file with a user-provided error_handler
+    // object. The file is accessed with std::ifstream in binary
+    // mode. The std::ios_base::failure exception is used to report
+    // io errors (badbit and failbit).
+    //
+    void
+    parse (const std::string& file, error_handler&);
+
+  public:
+    // Parse std::istream.
+    //
+    void
+    parse (std::istream&);
+
+    // Parse std::istream with a user-provided error_handler object.
+    //
+    void
+    parse (std::istream&, error_handler&);
+
+    // Parse std::istream with a system id.
+    //
+    void
+    parse (std::istream&, const std::string& system_id);
+
+    // Parse std::istream with a system id and a user-provided
+    // error_handler object.
+    //
+    void
+    parse (std::istream&,
+           const std::string& system_id,
+           error_handler&);
+
+    // Parse std::istream with system and public ids.
+    //
+    void
+    parse (std::istream&,
+           const std::string& system_id,
+           const std::string& public_id);
+
+    // Parse std::istream with system and public ids and a user-provided
+    // error_handler object.
+    //
+    void
+    parse (std::istream&,
+           const std::string& system_id,
+           const std::string& public_id,
+           error_handler&);
+
+  public:
+    // Parse a chunk of input. You can call these functions multiple
+    // times with the last call having the last argument true.
+    //
+    void
+    parse (const void* data, std::size_t size, bool last);
+
+    void
+    parse (const void* data, std::size_t size, bool last,
+           error_handler&);
+
+    void
+    parse (const void* data, std::size_t size, bool last,
+           const std::string& system_id);
+
+    void
+    parse (const void* data, std::size_t size, bool last,
+           const std::string& system_id,
+           error_handler&);
+
+    void
+    parse (const void* data, std::size_t size, bool last,
+           const std::string& system_id,
+           const std::string& public_id);
+
+    void
+    parse (const void* data, std::size_t size, bool last,
+           const std::string& system_id,
+           const std::string& public_id,
+           error_handler&);
+
+  public:
+    // Low-level Expat-specific parsing API.
+    //
+    void
+    parse_begin (XML_Parser);
+
+    void
+    parse_begin (XML_Parser, const std::string& public_id);
+
+    void
+    parse_begin (XML_Parser, error_handler&);
+
+    void
+    parse_begin (XML_Parser,
+                 const std::string& public_id,
+                 error_handler&);
+    void
+    parse_end ();
+  };
+}
+  
+ +

The document class is a root parser for + the vocabulary. The first argument to its constructors is the + parser for the type of the root element. The parser_base + class is the base type for all parser skeletons. The second and + third arguments to the document's constructors are + the root element's name and namespace. The last argument, + polymorphic, specifies whether the XML documents + being parsed use polymorphism. For more information on support + for XML Schema polymorphism in the C++/Parser mapping refer + to Section 5.5, "Support for Polymorphism".

+ +

A number of overloaded parse() functions have the + system_id and public_id arguments. The + system id is a system identifier of the resources being + parsed (for example, URI or a full file path). The public id is a + public identifier of the resource (for example, an + application-specific name or a relative file path). The system id + is used to resolve relative paths. In diagnostics messages the + public id is used if it is available. Otherwise the system id + is used.

+ +

The parse_begin() and parse_end() functions + present a low-level, Expat-specific parsing API for maximum control. + A typical use-case would look like this (pseudo-code):

+ +
+xxx_pimpl root_p;
+document doc_p (root_p, "root");
+
+root_p.pre ();
+doc_p.parse_begin (xml_parser, "file.xml");
+
+while (more_data_to_parse)
+{
+  // Call XML_Parse or XML_ParseBuffer.
+
+  if (status == XML_STATUS_ERROR)
+    break;
+}
+
+// Call parse_end even in case of an error to translate
+// XML and Schema errors to exceptions or error_handler
+// calls.
+//
+doc.parse_end ();
+result_type result (root_p.post_xxx ());
+  
+ +

Note that if your vocabulary uses XML namespaces, the + XML_ParserCreateNS() functions should be used to create + the XML parser. Space (XML_Char (' ')) should be used + as a separator (the second argument to XML_ParserCreateNS()). +

+ +

The error handling mechanisms employed by the document + parser are described in Section 7.3, "Error + Handling".

+ + +

7.3 Error Handling

+ +

There are three categories of errors that can result from running + a parser on an XML document: System, XML, and Application. + The System category contains memory allocation and file/stream + operation errors. The XML category covers XML parsing and + well-formedness checking as well as XML Schema validation errors. + Finally, the Application category is for application logic errors + that you may want to propagate from parser implementations to the + caller of the parser. +

+ +

The System errors are mapped to the standard exceptions. The + out of memory condition is indicated by throwing an instance + of std::bad_alloc. The stream operation errors + are reported either by throwing an instance of + std::ios_base::failure if exceptions are enabled + or by setting the stream state.

+ +

Note that if you are parsing std::istream on + which exceptions are not enabled, then you will need to + check the stream state before calling the post() + callback, as shown in the following example:

+ +
+int
+main (int argc, char* argv[])
+{
+  ...
+
+  std::ifstream ifs (argv[1]);
+
+  if (ifs.fail ())
+  {
+    cerr << argv[1] << ": unable to open" << endl;
+    return 1;
+  }
+
+  root_p.pre ();
+  doc_p.parse (ifs);
+
+  if (ifs.fail ())
+  {
+    cerr << argv[1] << ": io failure" << endl;
+    return 1;
+  }
+
+  result_type result (root_p.post_xxx ());
+}
+  
+ +

The above example can be rewritten to use exceptions + as shown below:

+ +
+int
+main (int argc, char* argv[])
+{
+  try
+  {
+    ...
+
+    std::ifstream ifs;
+    ifs.exceptions (std::ifstream::badbit | std::ifstream::failbit);
+    ifs.open (argv[1]);
+
+    root_p.pre ();
+    doc_p.parse (ifs);
+    result_type result (root_p.post_xxx ());
+  }
+  catch (const std::ifstream::failure&)
+  {
+    cerr << argv[1] << ": unable to open or io failure" << endl;
+    return 1;
+  }
+}
+  
+ + +

For reporting application errors from parsing callbacks, you + can throw any exceptions of your choice. They are propagated to + the caller of the parser without any alterations.

+ +

The XML errors can be reported either by throwing the + xml_schema::parsing exception or by a callback + to the xml_schema::error_handler object (and + xercesc::ErrorHandler object in case of Xerces-C++).

+ +

The xml_schema::parsing exception contains + a list of warnings and errors that were accumulated during + parsing. Note that this exception is thrown only if there + was an error. This makes it impossible to obtain warnings + from an otherwise successful parsing using this mechanism. + The following listing shows the definition of + xml_schema::parsing exception. Note that if the + character type is wchar_t, then the string type + and output stream type in the definition become + std::wstring and std::wostream, + respectively (see Section 5.2, "Character Type + and Encoding").

+ +
+namespace xml_schema
+{
+  class exception: public std::exception
+  {
+  protected:
+    virtual void
+    print (std::ostream&) const = 0;
+  };
+
+  inline std::ostream&
+  operator<< (std::ostream& os, const exception& e)
+  {
+    e.print (os);
+    return os;
+  }
+
+
+  class severity
+  {
+  public:
+    enum value
+    {
+      warning,
+      error
+    };
+  };
+
+
+  class error
+  {
+  public:
+    error (xml_schema::severity,
+           const std::string& id,
+           unsigned long line,
+           unsigned long column,
+           const std::string& message);
+
+    xml_schema::severity
+    severity () const;
+
+    const std::string&
+    id () const;
+
+    unsigned long
+    line () const;
+
+    unsigned long
+    column () const;
+
+    const std::string&
+    message () const;
+  };
+
+  std::ostream&
+  operator<< (std::ostream&, const error&);
+
+
+  class diagnostics: public std::vector<error>
+  {
+  };
+
+  std::ostream&
+  operator<< (std::ostream&, const diagnostics&);
+
+
+  class parsing: public exception
+  {
+  public:
+    parsing ();
+    parsing (const xml_schema::diagnostics&);
+
+    const xml_schema::diagnostics&
+    diagnostics () const;
+
+    virtual const char*
+    what () const throw ();
+
+  protected:
+    virtual void
+    print (std::ostream&) const;
+  };
+}
+  
+ +

The following example shows how we can catch and print this + exception. The code will print diagnostics messages one per line + in case of an error.

+ +
+int
+main (int argc, char* argv[])
+{
+  try
+  {
+    // Parse.
+  }
+  catch (const xml_schema::parsing& e)
+  {
+    cerr << e << endl;
+    return 1;
+  }
+}
+  
+ +

With the error_handler approach the diagnostics + messages are delivered as parsing progresses. The following + listing presents the definition of the error_handler + interface. Note that if the character type is wchar_t, + then the string type in the interface becomes std::wstring + (see Section 5.2, "Character Type and Encoding").

+ +
+namespace xml_schema
+{
+  class error_handler
+  {
+  public:
+    class severity
+    {
+    public:
+      enum value
+      {
+        warning,
+        error,
+        fatal
+      };
+    };
+
+    virtual bool
+    handle (const std::string& id,
+            unsigned long line,
+            unsigned long column,
+            severity,
+            const std::string& message) = 0;
+  };
+}
+  
+ +

The return value of the handle() function indicates whether + parsing should continue if possible. The error with the fatal severity + level terminates the parsing process regardless of the returned value. + At the end of the parsing process with an error that was reported via + the error_handler object, an empty + xml_schema::parsing exception is thrown to indicate + the failure to the caller. You can alter this behavior by throwing + your own exception from the handle() function.

+ + + + + +

Appendix A — Supported XML Schema Constructs

+ +

The C++/Parser mapping supports validation of the following W3C XML + Schema constructs in the generated code.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ConstructNotes
Structure
element
attribute
any
anyAttribute
all
sequence
choice
complex type, empty content
complex type, mixed content
complex type, simple content extension
complex type, simple content restrictionSimple type facets are not validated.
complex type, complex content extension
complex type, complex content restriction
list
Datatypes
byte
unsignedByte
short
unsignedShort
int
unsignedInt
long
unsignedLong
integer
nonPositiveInteger
nonNegativeInteger
positiveInteger
negativeInteger
boolean
float
double
decimal
string
normalizedString
token
Name
NMTOKEN
NCName
language
anyURI
IDIdentity constraint is not enforced.
IDREFIdentity constraint is not enforced.
NMTOKENS
IDREFSIdentity constraint is not enforced.
QName
base64Binary
hexBinary
date
dateTime
duration
gDay
gMonth
gMonthDay
gYear
gYearMonth
time
+ + +
+
+ + + diff --git a/xsd/doc/cxx/tree/guide/.gitignore b/xsd/doc/cxx/tree/guide/.gitignore new file mode 100644 index 0000000..17828e9 --- /dev/null +++ b/xsd/doc/cxx/tree/guide/.gitignore @@ -0,0 +1,2 @@ +index.xhtml +guide.html2ps diff --git a/xsd/doc/cxx/tree/guide/guide.html2ps.in b/xsd/doc/cxx/tree/guide/guide.html2ps.in new file mode 100644 index 0000000..461ffde --- /dev/null +++ b/xsd/doc/cxx/tree/guide/guide.html2ps.in @@ -0,0 +1,65 @@ +@@html2ps { + option { + toc: hb; + colour: 1; + hyphenate: 1; + titlepage: 1; + } + + datefmt: "%B %Y"; + + titlepage { + content: " +
+

C++/Tree Mapping

+

Getting Started Guide

+

 

+

 

+

 

+

 

+

 

+

 

+
+

Copyright © @copyright@.

+ +

Permission is granted to copy, distribute and/or modify this + document under the terms of the + GNU Free + Documentation License, version 1.2; with no Invariant Sections, + no Front-Cover Texts and no Back-Cover Texts. +

+ +

This document is available in the following formats: + XHTML, + PDF, and + PostScript.

"; + } + + toc { + indent: 2em; + } + + header { + odd-right: $H; + even-left: $H; + } + + footer { + odd-left: $D; + odd-center: $T; + odd-right: $N; + + even-left: $N; + even-center: $T; + even-right: $D; + } +} + +body { + font-size: 12pt; + text-align: justify; +} + +pre { + font-size: 10pt; +} diff --git a/xsd/doc/cxx/tree/guide/index.xhtml.in b/xsd/doc/cxx/tree/guide/index.xhtml.in new file mode 100644 index 0000000..b704e50 --- /dev/null +++ b/xsd/doc/cxx/tree/guide/index.xhtml.in @@ -0,0 +1,2738 @@ + + + + + + C++/Tree Mapping Getting Started Guide + + + + + + + + + + + + + +
+
+ +
+ +
+
C++/Tree Mapping
+
Getting Started Guide
+ +

Copyright © @copyright@.

+ +

Permission is granted to copy, distribute and/or modify this + document under the terms of the + GNU Free + Documentation License, version 1.2; with no Invariant Sections, + no Front-Cover Texts and no Back-Cover Texts. +

+ +

This document is available in the following formats: + XHTML, + PDF, and + PostScript.

+ +
+ +

Table of Contents

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Preface + + + +
About This Document
More Information
+
1Introduction + + + +
1.1Mapping Overview
1.2Benefits
+
2Hello World Example + + + + + + + + +
2.1Writing XML Document and Schema
2.2Translating Schema to C++
2.3Implementing Application Logic
2.4Compiling and Running
2.5Adding Serialization
2.6Selecting Naming Convention
2.7Generating Documentation
+
3Overall Mapping Configuration + + + + + + +
3.1C++ Standard
3.2Character Type and Encoding
3.3Support for Polymorphism
3.4Namespace Mapping
3.5Thread Safety
+
4Working with Object Models + + + + + + +
4.1Attribute and Element Cardinalities
4.2Accessing the Object Model
4.3Modifying the Object Model
4.4Creating the Object Model from Scratch
4.5Mapping for the Built-in XML Schema Types
+
5Parsing + + + +
5.1XML Schema Validation and Searching
5.2Error Handling
+
6Serialization + + + +
6.1Namespace and Schema Information
6.2Error Handling
+
+
+ +

Preface

+ +

About This Document

+ +

The goal of this document is to provide you with an understanding of + the C++/Tree programming model and allow you to efficiently evaluate + XSD against your project's technical requirements. As such, this + document is intended for C++ developers and software architects + who are looking for an XML processing solution. For a more in-depth + description of the C++/Tree mapping refer to the + C++/Tree + Mapping User Manual.

+ +

Prior experience with XML and C++ is required to understand this + document. Basic understanding of XML Schema is advantageous but + not expected or required. +

+ + +

More Information

+ +

Beyond this guide, you may also find the following sources of + information useful:

+ + + + + +

1 Introduction

+ +

Welcome to CodeSynthesis XSD and the C++/Tree mapping. XSD is a + cross-platform W3C XML Schema to C++ data binding compiler. C++/Tree + is a W3C XML Schema to C++ mapping that represents the data stored + in XML as a statically-typed, vocabulary-specific object model. +

+ +

1.1 Mapping Overview

+ +

Based on a formal description of an XML vocabulary (schema), the + C++/Tree mapping produces a tree-like data structure suitable for + in-memory processing. The core of the mapping consists of C++ + classes that constitute the object model and are derived from + types defined in XML Schema as well as XML parsing and + serialization code.

+ +

Besides the core features, C++/Tree provide a number of additional + mapping elements that can be useful in some applications. These + include serialization and extraction to/from formats others than + XML, such as unstructured text (useful for debugging) and binary + representations such as XDR and CDR for high-speed data processing + as well as automatic documentation generation. The C++/Tree mapping + also provides a wide range of mechanisms for controlling and + customizing the generated code.

+ +

A typical application that uses C++/Tree for XML processing usually + performs the following three steps: it first reads (parses) an XML + document to an in-memory object model, it then performs some useful + computations on that object model which may involve modification + of the model, and finally it may write (serialize) the modified + object model back to XML.

+ +

The next chapter presents a simple application that performs these + three steps. The following chapters show how to use the C++/Tree + mapping in more detail.

+ +

1.2 Benefits

+ +

Traditional XML access APIs such as Document Object Model (DOM) + or Simple API for XML (SAX) have a number of drawbacks that + make them less suitable for creating robust and maintainable + XML processing applications. These drawbacks include: +

+ +
    +
  • Generic representation of XML in terms of elements, attributes, + and text forces an application developer to write a substantial + amount of bridging code that identifies and transforms pieces + of information encoded in XML to a representation more suitable + for consumption by the application logic.
  • + +
  • String-based flow control defers error detection to runtime. + It also reduces code readability and maintainability.
  • + +
  • Lack of type safety because the data is represented as text.
  • + +
  • Resulting applications are hard to debug, change, and + maintain.
  • +
+ +

In contrast, statically-typed, vocabulary-specific object model + produced by the C++/Tree mapping allows you to operate in your + domain terms instead of the generic elements, attributes, and + text. Static typing helps catch errors at compile-time rather + than at run-time. Automatic code generation frees you for more + interesting tasks (such as doing something useful with the + information stored in the XML documents) and minimizes the + effort needed to adapt your applications to changes in the + document structure. To summarize, the C++/Tree object model has + the following key advantages over generic XML access APIs:

+ +
    +
  • Ease of use. The generated code hides all the complexity + associated with parsing and serializing XML. This includes navigating + the structure and converting between the text representation and + data types suitable for manipulation by the application + logic.
  • + +
  • Natural representation. The object representation allows + you to access the XML data using your domain vocabulary instead + of generic elements, attributes, and text.
  • + +
  • Concise code. With the object representation the + application implementation is simpler and thus easier + to read and understand.
  • + +
  • Safety. The generated object model is statically + typed and uses functions instead of strings to access the + information. This helps catch programming errors at compile-time + rather than at runtime.
  • + +
  • Maintainability. Automatic code generation minimizes the + effort needed to adapt the application to changes in the + document structure. With static typing, the C++ compiler + can pin-point the places in the client code that need to be + changed.
  • + +
  • Compatibility. Sequences of elements are represented in + the object model as containers conforming to the standard C++ + sequence requirements. This makes it possible to use standard + C++ algorithms on the object representation and frees you from + learning yet another container interface, as is the case with + DOM.
  • + +
  • Efficiency. If the application makes repetitive use + of the data extracted from XML, then the C++/Tree object model + is more efficient because the navigation is performed using + function calls rather than string comparisons and the XML + data is extracted only once. Furthermore, the runtime memory + usage is reduced due to more efficient data storage + (for instance, storing numeric data as integers instead of + strings) as well as the static knowledge of cardinality + constraints.
  • +
+ + + + + +

2 Hello World Example

+ +

In this chapter we will examine how to parse, access, modify, and + serialize a very simple XML document using the XSD-generated + C++/Tree object model. The code presented in this chapter is + based on the hello example which can be found in + the cxx/tree/ directory in the + xsd-examples package.

+ +

2.1 Writing XML Document and Schema

+ +

First, we need to get an idea about the structure + of the XML documents we are going to process. Our + hello.xml, for example, could look like this:

+ +
+<?xml version="1.0"?>
+<hello>
+
+  <greeting>Hello</greeting>
+
+  <name>sun</name>
+  <name>moon</name>
+  <name>world</name>
+
+</hello>
+  
+ +

Then we can write a description of the above XML in the + XML Schema language and save it into hello.xsd:

+ +
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+  <xs:complexType name="hello_t">
+    <xs:sequence>
+      <xs:element name="greeting" type="xs:string"/>
+      <xs:element name="name" type="xs:string" maxOccurs="unbounded"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="hello" type="hello_t"/>
+
+</xs:schema>
+  
+ +

Even if you are not familiar with XML Schema, it + should be easy to connect declarations in hello.xsd + to elements in hello.xml. The hello_t type + is defined as a sequence of the nested greeting and + name elements. Note that the term sequence in XML + Schema means that elements should appear in a particular order + as opposed to appearing multiple times. The name + element has its maxOccurs property set to + unbounded which means it can appear multiple times + in an XML document. Finally, the globally-defined hello + element prescribes the root element for our vocabulary. For an + easily-approachable introduction to XML Schema refer to + XML Schema Part 0: + Primer.

+ +

The above schema is a specification of our XML vocabulary; it tells + everybody what valid documents of our XML-based language should look + like. We can also update our hello.xml to include the + information about the schema so that XML parsers can validate + our document:

+ +
+<?xml version="1.0"?>
+<hello xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:noNamespaceSchemaLocation="hello.xsd">
+
+  <greeting>Hello</greeting>
+
+  <name>sun</name>
+  <name>moon</name>
+  <name>world</name>
+
+</hello>
+      
+ + +

The next step is to compile the schema to generate the object + model and parsing functions.

+ +

2.2 Translating Schema to C++

+ +

Now we are ready to translate our hello.xsd to C++. + To do this we invoke the XSD compiler from a terminal (UNIX) or + a command prompt (Windows): +

+ +
+$ xsd cxx-tree --std c++11 hello.xsd
+  
+ +

The XSD compiler produces two C++ files: hello.hxx and + hello.cxx. The following code fragment is taken from + hello.hxx; it should give you an idea about what gets + generated: +

+ +
+class hello_t
+{
+public:
+  // greeting
+  //
+  typedef xml_schema::string greeting_type;
+
+  const greeting_type&
+  greeting () const;
+
+  greeting_type&
+  greeting ();
+
+  void
+  greeting (const greeting_type& x);
+
+  // name
+  //
+  typedef xml_schema::string name_type;
+  typedef xsd::sequence<name_type> name_sequence;
+  typedef name_sequence::iterator name_iterator;
+  typedef name_sequence::const_iterator name_const_iterator;
+
+  const name_sequence&
+  name () const;
+
+  name_sequence&
+  name ();
+
+  void
+  name (const name_sequence& s);
+
+  // Constructor.
+  //
+  hello_t (const greeting_type&);
+
+  ...
+
+};
+
+std::unique_ptr<hello_t>
+hello (const std::string& uri);
+
+std::unique_ptr<hello_t>
+hello (std::istream&);
+  
+ +

The hello_t C++ class corresponds to the + hello_t XML Schema type. For each element + in this type a set of C++ type definitions as well as + accessor and modifier functions are generated inside the + hello_t class. Note that the type definitions + and member functions for the greeting and + name elements are different because of the + cardinality differences between these two elements + (greeting is a required single element and + name is a sequence of elements).

+ +

The xml_schema::string type used in the type + definitions is a C++ class provided by the XSD runtime + that corresponds to built-in XML Schema type + string. The xml_schema::string + is based on std::string and can be used as + such. Similarly, the sequence class template + that is used in the name_sequence type + definition is based on and has the same interface as + std::vector. The mapping between the built-in + XML Schema types and C++ types is described in more detail in + Section 4.5, "Mapping for the Built-in XML Schema + Types". The hello_t class also includes a + constructor with an initializer for the required + greeting element as its argument.

+ +

The hello overloaded global functions correspond + to the hello global element in XML Schema. A + global element in XML Schema is a valid document root. + By default XSD generated a set of parsing functions for each + global element defined in XML Schema (this can be overridden + with the --root-element-* options). Parsing + functions return a dynamically allocated object model as an + automatic pointer. The actual pointer used depends on the + C++ standard selected. For C++11 it is std::unique_ptr + as shown above. For C++98 it is std::auto_ptr. + For example, if we modify our XSD compiler invocation to + select C++98:

+ +
+$ xsd cxx-tree hello.xsd
+  
+ +

Then the parsing function signatures will become:

+ +
+std::auto_ptr<hello_t>
+hello (const std::string& uri);
+
+std::auto_ptr<hello_t>
+hello (std::istream&);
+  
+ +

For more information on parsing functions see Chapter 5, + "Parsing".

+ +

2.3 Implementing Application Logic

+ +

At this point we have all the parts we need to do something useful + with the information stored in our XML document: +

+ +
+#include <iostream>
+#include "hello.hxx"
+
+using namespace std;
+
+int
+main (int argc, char* argv[])
+{
+  try
+  {
+    unique_ptr<hello_t> h (hello (argv[1]));
+
+    for (hello_t::name_const_iterator i (h->name ().begin ());
+         i != h->name ().end ();
+         ++i)
+    {
+      cerr << h->greeting () << ", " << *i << "!" << endl;
+    }
+  }
+  catch (const xml_schema::exception& e)
+  {
+    cerr << e << endl;
+    return 1;
+  }
+}
+  
+ +

The first part of our application calls one of the parsing + functions to parser an XML file specified in the command line. + We then use the returned object model to iterate over names + and print a greeting line for each of them. Finally, we + catch and print the xml_schema::exception + exception in case something goes wrong. This exception + is the root of the exception hierarchy used by the + XSD-generated code. +

+ + +

2.4 Compiling and Running

+ +

After saving our application from the previous section in + driver.cxx, we are ready to compile our first + program and run it on the test XML document. On a UNIX + system this can be done with the following commands: +

+ +
+$ c++ -std=c++11 -I.../libxsd -c driver.cxx hello.cxx
+$ c++ -std=c++11 -o driver driver.o hello.o -lxerces-c
+$ ./driver hello.xml
+Hello, sun!
+Hello, moon!
+Hello, world!
+  
+ +

Here .../libxsd represents the path to the + libxsd package root + directory. Note also that we are required to link our + application with the Xerces-C++ library because the generated + code uses it as the underlying XML parser.

+ +

2.5 Adding Serialization

+ +

While parsing and accessing the XML data may be everything + you need, there are applications that require creating new + or modifying existing XML documents. By default XSD does + not produce serialization code. We will need to request + it with the --generate-serialization options:

+ +
+$ xsd cxx-tree --std c++11 --generate-serialization hello.xsd
+  
+ +

If we now examine the generated hello.hxx file, + we will find a set of overloaded serialization functions, + including the following version:

+ +
+void
+hello (std::ostream&,
+       const hello_t&,
+       const xml_schema::namespace_infomap& =
+         xml_schema::namespace_infomap ());
+
+  
+ +

Just like with parsing functions, XSD generates serialization + functions for each global element unless instructed otherwise + with one of the --root-element-* options. For more + information on serialization functions see Chapter 6, + "Serialization".

+ +

We first examine an application that modifies an existing + object model and serializes it back to XML:

+ +
+#include <iostream>
+#include "hello.hxx"
+
+using namespace std;
+
+int
+main (int argc, char* argv[])
+{
+  try
+  {
+    unique_ptr<hello_t> h (hello (argv[1]));
+
+    // Change the greeting phrase.
+    //
+    h->greeting ("Hi");
+
+    // Add another entry to the name sequence.
+    //
+    h->name ().push_back ("mars");
+
+    // Serialize the modified object model to XML.
+    //
+    xml_schema::namespace_infomap map;
+    map[""].name = "";
+    map[""].schema = "hello.xsd";
+
+    hello (cout, *h, map);
+  }
+  catch (const xml_schema::exception& e)
+  {
+    cerr << e << endl;
+    return 1;
+  }
+}
+  
+ +

First, our application parses an XML document and obtains its + object model as in the previous example. Then it changes the + greeting string and adds another entry to the list of names. + Finally, it serializes the object model back to XML by calling + the serialization function.

+ +

The first argument we pass to the serialization function is + cout which results in the XML being written to + the standard output for us to inspect. We could have also + written the result to a file or memory buffer by creating an + instance of std::ofstream or std::ostringstream + and passing it instead of cout. The second argument is the + object model we want to serialize. The final argument is an optional + namespace information map for our vocabulary. It captures information + such as namespaces, namespace prefixes to which they should be mapped, + and schemas associated with these namespaces. If we don't provide + this argument then generic namespace prefixes (p1, + p2, etc.) will be automatically assigned to XML namespaces + and no schema information will be added to the resulting document + (see Chapter 6, "Serialization" for details). + In our case, the prefix (map key) and namespace name are empty + because our vocabulary does not use XML namespaces.

+ +

If we now compile and run this application we will see the + output as shown in the following listing:

+ +
+<?xml version="1.0"?>
+<hello xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:noNamespaceSchemaLocation="hello.xsd">
+
+  <greeting>Hi</greeting>
+
+  <name>sun</name>
+  <name>moon</name>
+  <name>world</name>
+  <name>mars</name>
+
+</hello>
+  
+ +

We can also create and serialize an object model from scratch + as shown in the following example:

+ +
+#include <iostream>
+#include <fstream>
+#include "hello.hxx"
+
+using namespace std;
+
+int
+main (int argc, char* argv[])
+{
+  try
+  {
+    hello_t h ("Hi");
+
+    hello_t::name_sequence& ns (h.name ());
+
+    ns.push_back ("Jane");
+    ns.push_back ("John");
+
+    // Serialize the object model to XML.
+    //
+    xml_schema::namespace_infomap map;
+    map[""].name = "";
+    map[""].schema = "hello.xsd";
+
+    std::ofstream ofs (argv[1]);
+    hello (ofs, h, map);
+  }
+  catch (const xml_schema::exception& e)
+  {
+    cerr << e << endl;
+    return 1;
+  }
+}
+  
+ +

In this example we used the generated constructor to create + an instance of type hello_t. To reduce typing, + we obtained a reference to the name sequence which we then + used to add a few names. The serialization part is identical + to the previous example except this time we are writing to + a file. If we compile and run this program, it produces the + following XML file:

+ +
+<?xml version="1.0"?>
+<hello xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:noNamespaceSchemaLocation="hello.xsd">
+
+  <greeting>Hi</greeting>
+
+  <name>Jane</name>
+  <name>John</name>
+
+</hello>
+  
+ +

2.6 Selecting Naming Convention

+ +

By default XSD uses the so-called K&R (Kernighan and Ritchie) + identifier naming convention in the generated code. In this + convention both type and function names are in lower case and + words are separated by underscores. If your application code or + schemas use a different notation, you may want to change the + naming convention used in the generated code for consistency. + XSD supports a set of widely-used naming conventions + that you can select with the --type-naming and + --function-naming options. You can also further + refine one of the predefined conventions or create a completely + custom naming scheme by using the --*-regex options.

+ +

As an example, let's assume that our "Hello World" application + uses the so-called upper-camel-case naming convention for types + (that is, each word in a type name is capitalized) and the K&R + convention for function names. Since K&R is the default + convention for both type and function names, we only need to + change the type naming scheme:

+ +
+$ xsd cxx-tree --std c++11 --type-naming ucc hello.xsd
+  
+ +

The ucc argument to the --type-naming + options stands for upper-camel-case. If we now examine the + generated hello.hxx, we will see the following + changes compared to the declarations shown in the previous + sections:

+ +
+class Hello_t
+{
+public:
+  // greeting
+  //
+  typedef xml_schema::String GreetingType;
+
+  const GreetingType&
+  greeting () const;
+
+  GreetingType&
+  greeting ();
+
+  void
+  greeting (const GreetingType& x);
+
+  // name
+  //
+  typedef xml_schema::String NameType;
+  typedef xsd::sequence<NameType> NameSequence;
+  typedef NameSequence::iterator NameIterator;
+  typedef NameSequence::const_iterator NameConstIterator;
+
+  const NameSequence&
+  name () const;
+
+  NameSequence&
+  name ();
+
+  void
+  name (const NameSequence& s);
+
+  // Constructor.
+  //
+  Hello_t (const GreetingType&);
+
+  ...
+
+};
+
+std::unique_ptr<Hello_t>
+hello (const std::string& uri);
+
+std::unique_ptr<Hello_t>
+hello (std::istream&);
+  
+ +

Notice that the type names in the xml_schema namespace, + for example xml_schema::String, now also use the + upper-camel-case naming convention. The only thing that we may + be unhappy about in the above code is the _t + suffix in Hello_t. If we are not in a position + to change the schema, we can touch-up the ucc + convention with a custom translation rule using the + --type-regex option:

+ +
+$ xsd cxx-tree --std c++11 --type-naming ucc \
+      --type-regex '/ (.+)_t/\u$1/' hello.xsd
+  
+ +

This results in the following changes to the generated code:

+ +
+class Hello
+{
+public:
+  // greeting
+  //
+  typedef xml_schema::String GreetingType;
+
+  const GreetingType&
+  greeting () const;
+
+  GreetingType&
+  greeting ();
+
+  void
+  greeting (const GreetingType& x);
+
+  // name
+  //
+  typedef xml_schema::String NameType;
+  typedef xsd::sequence<NameType> NameSequence;
+  typedef NameSequence::iterator NameIterator;
+  typedef NameSequence::const_iterator NameConstIterator;
+
+  const NameSequence&
+  name () const;
+
+  NameSequence&
+  name ();
+
+  void
+  name (const NameSequence& s);
+
+  // Constructor.
+  //
+  Hello (const GreetingType&);
+
+  ...
+
+};
+
+std::unique_ptr<Hello>
+hello (const std::string& uri);
+
+std::unique_ptr<Hello>
+hello (std::istream&);
+  
+ +

For more detailed information on the --type-naming, + --function-naming, --type-regex, and + other --*-regex options refer to the NAMING + CONVENTION section in the XSD + Compiler Command Line Manual.

+ +

2.7 Generating Documentation

+ +

While our object model is quite simple, real-world vocabularies + can be quite complex with hundreds of types, elements, and + attributes. For such vocabularies figuring out which types + provide which member functions by studying the generated + source code or schemas can be a daunting task. To provide + application developers with a more accessible way of + understanding the generated object models, the XSD compiler + can be instructed to produce source code with documentation + comments in the Doxygen format. Then the source code can be + processed with the Doxygen + documentation system to extract this information and produce + documentation in various formats. +

+ +

In this section we will see how to generate documentation + for our "Hello World" vocabulary. To showcase the full power + of the XSD documentation facilities, we will first document + our schema. The XSD compiler will then transfer + this information from the schema to the generated code and + then to the object model documentation. Note that the + documentation in the schema is not required for XSD to + generate useful documentation. Below you will find + our hello.xsd with added documentation:

+ +
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+  <xs:complexType name="hello_t">
+
+    <xs:annotation>
+      <xs:documentation>
+        The hello_t type consists of a greeting phrase and a
+        collection of names to which this greeting applies.
+      </xs:documentation>
+    </xs:annotation>
+
+    <xs:sequence>
+
+      <xs:element name="greeting" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>
+            The greeting element contains the greeting phrase
+            for this hello object.
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+
+      <xs:element name="name" type="xs:string" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>
+            The name elements contains names to be greeted.
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="hello" type="hello_t">
+    <xs:annotation>
+      <xs:documentation>
+        The hello element is a root of the Hello XML vocabulary.
+        Every conforming document should start with this element.
+      </xs:documentation>
+    </xs:annotation>
+  </xs:element>
+
+</xs:schema>
+  
+ +

The first step in obtaining the documentation is to recompile + our schema with the --generate-doxygen option:

+ +
+$ xsd cxx-tree --std c++11 --generate-serialization --generate-doxygen \
+      hello.xsd
+  
+ +

Now the generated hello.hxx file contains comments + in the Doxygen format. The next step is to process this file + with the Doxygen documentation system. If your project does + not use Doxygen then you first need to create a configuration + file for your project:

+ +
+$ doxygen -g hello.doxygen
+  
+ +

You only need to perform this step once. Now we can generate + the documentation by executing the following command in the + directory with the generated source code:

+ +
+$ doxygen hello.doxygen
+  
+ +

While the generated documentation can be useful as is, we can + go one step further and link (using the Doxygen tags mechanism) + the documentation for our object model with the documentation + for the XSD runtime library which defines C++ classes for the + built-in XML Schema types. This way we can seamlessly browse + between documentation for the hello_t class which + is generated by the XSD compiler and the xml_schema::string + class which is defined in the XSD runtime library. The Doxygen + configuration file for the XSD runtime is provided with the XSD + distribution.

+ +

You can view the result of the steps described in this section + on the Hello + Example Documentation page.

+ + + + +

3 Overall Mapping Configuration

+ +

The C++/Tree mapping has a number of configuration parameters that + determine the overall properties and behavior of the generated code. + Configuration parameters are specified with the XSD command line + options. This chapter describes configuration aspects that are most + commonly encountered by application developers. These include: the + C++ standard, the character type that is used by the generated code, + handling of vocabularies that use XML Schema polymorphism, XML Schema + to C++ namespace mapping, and thread safety. For more ways to configure + the generated code refer to the + XSD + Compiler Command Line Manual. +

+ +

3.1 C++ Standard

+ +

The C++/Tree mapping provides support for ISO/IEC C++ 2011 (C++11) + and ISO/IEC C++ 1998/2003 (C++98). To select the C++ standard for the + generated code we use the --std XSD compiler command + line option. While the majority of the examples in this guide use + C++11, the document explains the C++11/98 usage difference and so + they can easily be converted to C++98.

+ +

3.2 Character Type and Encoding

+ +

The C++/Tree mapping has built-in support for two character types: + char and wchar_t. You can select the + character type with the --char-type command line + option. The default character type is char. The + character type affects all string and string-based types that + are used in the mapping. These include the string-based built-in + XML Schema types, exception types, stream types, etc.

+ +

Another aspect of the mapping that depends on the character type + is character encoding. For the char character type + the default encoding is UTF-8. Other supported encodings are + ISO-8859-1, Xerces-C++ Local Code Page (LPC), as well as + custom encodings. You can select which encoding should be used + in the object model with the --char-encoding command + line option.

+ +

For the wchar_t character type the encoding is + automatically selected between UTF-16 and UTF-32/UCS-4 depending + on the size of the wchar_t type. On some platforms + (for example, Windows with Visual C++ and AIX with IBM XL C++) + wchar_t is 2 bytes long. For these platforms the + encoding is UTF-16. On other platforms wchar_t is 4 bytes + long and UTF-32/UCS-4 is used.

+ +

Note also that the character encoding that is used in the object model + is independent of the encodings used in input and output XML. In fact, + all three (object mode, input XML, and output XML) can have different + encodings.

+ +

3.3 Support for Polymorphism

+ +

By default XSD generates non-polymorphic code. If your vocabulary + uses XML Schema polymorphism in the form of xsi:type + and/or substitution groups, then you will need to compile + your schemas with the --generate-polymorphic option + to produce polymorphism-aware code. For more information on + working with polymorphic object models, refer to + Section 2.11, + "Mapping for xsi:type and Substitution Groups" in + the C++/Tree Mapping User Manual.

+ +

3.4 Namespace Mapping

+ +

XSD maps XML namespaces specified in the targetNamespace + attribute in XML Schema to one or more nested C++ namespaces. By + default, a namespace URI is mapped to a sequence of C++ namespace + names by removing the protocol and host parts and splitting the + rest into a sequence of names with '/' as the name + separator.

+ +

The default mapping of namespace URIs to C++ namespaces + can be altered using the --namespace-map and + --namespace-regex compiler options. For example, + to map namespace URI https://www.codesynthesis.com/my to + C++ namespace cs::my, we can use the following option:

+ +
+--namespace-map https://www.codesynthesis.com/my=cs::my
+  
+ +

A vocabulary without a namespace is mapped to the global scope. This + also can be altered with the above options by using an empty name + for the XML namespace:

+ +
+--namespace-map =cs
+  
+ +

3.5 Thread Safety

+ +

XSD-generated code is thread-safe in the sense that you can + use different instantiations of the object model in several + threads concurrently. This is possible due to the generated + code not relying on any writable global variables. If you need + to share the same object between several threads then you will + need to provide some form of synchronization. One approach would + be to use the generated code customization mechanisms to embed + synchronization primitives into the generated C++ classes. For more + information on generated code customization refer to the + C++/Tree + Mapping Customization Guide.

+ +

If you also would like to call parsing and/or serialization + functions from several threads potentially concurrently, then + you will need to make sure the Xerces-C++ runtime is initialized + and terminated only once. The easiest way to do this is to + initialize/terminate Xerces-C++ from main() when + there are no threads yet/anymore:

+ +
+#include <xercesc/util/PlatformUtils.hpp>
+
+int
+main ()
+{
+  xercesc::XMLPlatformUtils::Initialize ();
+
+  {
+    // Start/terminate threads and parse/serialize here.
+  }
+
+  xercesc::XMLPlatformUtils::Terminate ();
+}
+  
+ +

Because you initialize the Xerces-C++ runtime yourself you should + also pass the xml_schema::flags::dont_initialize flag + to parsing and serialization functions. See Chapter 5, + "Parsing" and Chapter 6, "Serialization" for + more information.

+ + + + + +

4 Working with Object Models

+ +

As we have seen in the previous chapters, the XSD compiler generates + a C++ class for each type defined in XML Schema. Together these classes + constitute an object model for an XML vocabulary. In this chapter we + will take a closer look at different elements that comprise an + object model class as well as how to create, access, and modify + object models.

+ +

In this and subsequent chapters we will use the following schema + that describes a collection of person records. We save it in + people.xsd:

+ +
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+  <xs:simpleType name="gender_t">
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="male"/>
+      <xs:enumeration value="female"/>
+    </xs:restriction>
+  </xs:simpleType>
+
+  <xs:complexType name="person_t">
+    <xs:sequence>
+      <xs:element name="first-name" type="xs:string"/>
+      <xs:element name="middle-name" type="xs:string" minOccurs="0"/>
+      <xs:element name="last-name" type="xs:string"/>
+      <xs:element name="gender" type="gender_t"/>
+      <xs:element name="age" type="xs:short"/>
+    </xs:sequence>
+    <xs:attribute name="id" type="xs:unsignedInt" use="required"/>
+  </xs:complexType>
+
+  <xs:complexType name="people_t">
+    <xs:sequence>
+      <xs:element name="person" type="person_t" maxOccurs="unbounded"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="people" type="people_t"/>
+
+</xs:schema>
+  
+ +

A sample XML instance to go along with this schema is saved + in people.xml:

+ +
+<?xml version="1.0"?>
+<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="people.xsd">
+
+  <person id="1">
+    <first-name>John</first-name>
+    <last-name>Doe</last-name>
+    <gender>male</gender>
+    <age>32</age>
+  </person>
+
+  <person id="2">
+    <first-name>Jane</first-name>
+    <middle-name>Mary</middle-name>
+    <last-name>Doe</last-name>
+    <gender>female</gender>
+    <age>28</age>
+  </person>
+
+</people>
+  
+ +

Compiling people.xsd with the XSD compiler results + in three generated C++ classes: gender_t, + person_t, and people_t. + The gender_t class is modelled after the C++ + enum type. Its definition is presented below:

+ +
+class gender_t: public xml_schema::string
+{
+public:
+  enum value
+  {
+    male,
+    female
+  };
+
+  gender_t (value);
+  gender_t (const xml_schema::string&);
+
+  gender_t&
+  operator= (value);
+
+  operator value () const;
+};
+  
+ +

The following listing shows how we can use this type:

+ +
+gender_t m (gender_t::male);
+gender_t f ("female");
+
+if (m == "female" || f == gender_t::male)
+{
+  ...
+}
+
+switch (m)
+{
+case gender_t::male:
+  {
+    ...
+  }
+case gender_t::female:
+  {
+    ...
+  }
+}
+  
+ +

The other two classes will be examined in detail in the subsequent + sections.

+ +

4.1 Attribute and Element Cardinalities

+ +

As we have seen in the previous chapters, XSD generates a different + set of type definitions and member functions for elements with + different cardinalities. The C++/Tree mapping divides all the possible + element and attribute cardinalities into three cardinality classes: + one, optional, and sequence.

+ +

The one cardinality class covers all elements that should + occur exactly once as well as required attributes. In our + example, the first-name, last-name, + gender, and age elements as well as + the id attribute belong to this cardinality class. + The following code fragment shows type definitions as well as the + accessor and modifier functions that are generated for the + gender element in the person_t class:

+ +
+class person_t
+{
+  // gender
+  //
+  typedef gender_t gender_type;
+
+  const gender_type&
+  gender () const;
+
+  gender_type&
+  gender ();
+
+  void
+  gender (const gender_type&);
+};
+  
+ +

The gender_type type is an alias for the element's type. + The first two accessor functions return read-only (constant) and + read-write references to the element's value, respectively. The + modifier function sets the new value for the element.

+ +

The optional cardinality class covers all elements that + can occur zero or one time as well as optional attributes. In our + example, the middle-name element belongs to this + cardinality class. The following code fragment shows the type + definitions as well as the accessor and modifier functions that + are generated for this element in the person_t class:

+ +
+class person_t
+{
+  // middle-name
+  //
+  typedef xml_schema::string middle_name_type;
+  typedef xsd::optional<middle_name_type> middle_name_optional;
+
+  const middle_name_optional&
+  middle_name () const;
+
+  middle_name_optional&
+  middle_name ();
+
+  void
+  middle_name (const middle_name_type&);
+
+  void
+  middle_name (const middle_name_optional&);
+};
+  
+ +

As with the gender element, middle_name_type + is an alias for the element's type. The middle_name_optional + type is a container for the element's optional value. It can be queried + for the presence of the value using the present() function. + The value itself can be retrieved using the get() + accessor and set using the set() modifier. The container + can be reverted to the value not present state with the call to the + reset() function. The following example shows how we + can use this container:

+ +
+person_t::middle_name_optional n ("John");
+
+if (n.present ())
+{
+  cout << n.get () << endl;
+}
+
+n.set ("Jane");
+n.reset ();
+  
+ + +

Unlike the one cardinality class, the accessor functions + for the optional class return read-only (constant) and + read-write references to the container instead of the element's + value directly. The modifier functions set the new value for the + element.

+ +

Finally, the sequence cardinality class covers all elements + that can occur more than once. In our example, the + person element in the people_t type + belongs to this cardinality class. The following code fragment shows + the type definitions as well as the accessor and modifier functions + that are generated for this element in the people_t + class:

+ +
+class people_t
+{
+  // person
+  //
+  typedef person_t person_type;
+  typedef xsd::sequence<person_type> person_sequence;
+  typedef person_sequence::iterator person_iterator;
+  typedef person_sequence::const_iterator person_const_iterator;
+
+  const person_sequence&
+  person () const;
+
+  person_sequence&
+  person ();
+
+  void
+  person (const person_sequence&);
+};
+  
+ +

Identical to the other cardinality classes, person_type + is an alias for the element's type. The person_sequence + type is a sequence container for the element's values. It is based + on and has the same interface as std::vector and + therefore can be used in similar ways. The person_iterator + and person_const_iterator types are read-only + (constant) and read-write iterators for the person_sequence + container.

+ +

Similar to the optional cardinality class, the + accessor functions for the sequence class return + read-only (constant) and read-write references to the sequence + container. The modifier functions copies the entries from + the passed sequence.

+ +

C++/Tree is a "flattening" mapping in a sense that many levels of + nested compositors (choice and sequence), + all potentially with their own cardinalities, are in the end mapped + to a flat set of elements with one of the three cardinality classes + discussed above. While this results in a simple and easy to use API + for most types, in certain cases, the order of elements in the actual + XML documents is not preserved once parsed into the object model. To + overcome this limitation we can mark certain schema types, for which + content order is not sufficiently preserved, as ordered. For more + information on this functionality refer to + Section + 2.8.4, "Element Order" in the C++/Tree Mapping User Manual.

+ +

For complex schemas with many levels of nested compositors + (choice and sequence) it can also + be hard to deduce the cardinality class of a particular element. + The generated Doxygen documentation can greatly help with + this task. For each element and attribute the documentation + clearly identifies its cardinality class. Alternatively, you + can study the generated header files to find out the cardinality + class of a particular attribute or element.

+ +

In the next sections we will examine how to access and modify + information stored in an object model using accessor and modifier + functions described in this section.

+ +

4.2 Accessing the Object Model

+ +

In this section we will learn how to get to the information + stored in the object model for our person records vocabulary. + The following application accesses and prints the contents + of the people.xml file:

+ +
+#include <iostream>
+#include "people.hxx"
+
+using namespace std;
+
+int
+main ()
+{
+  unique_ptr<people_t> ppl (people ("people.xml"));
+
+  // Iterate over individual person records.
+  //
+  people_t::person_sequence& ps (ppl->person ());
+
+  for (people_t::person_iterator i (ps.begin ()); i != ps.end (); ++i)
+  {
+    person_t& p (*i);
+
+    // Print names: first-name and last-name are required elements,
+    // middle-name is optional.
+    //
+    cout << "name:   " << p.first_name () << " ";
+
+    if (p.middle_name ().present ())
+      cout << p.middle_name ().get () << " ";
+
+    cout << p.last_name () << endl;
+
+    // Print gender, age, and id which are all required.
+    //
+    cout << "gender: " << p.gender () << endl
+         << "age:    " << p.age () << endl
+         << "id:     " << p.id () << endl
+         << endl;
+  }
+}
+  
+ +

This code shows common patterns of accessing elements and attributes + with different cardinality classes. For the sequence element + (person in people_t) we first obtain a + reference to the container and then iterate over individual + records. The values of elements and attributes with the + one cardinality class (first-name, + last-name, gender, age, + and id) can be obtained directly by calling the + corresponding accessor functions. For the optional element + middle-name we first check if the value is present + and only then call get() to retrieve it.

+ +

Note that when we want to reduce typing by creating a variable + representing a fragment of the object model that we are currently + working with (ps and p above), we obtain + a reference to that fragment instead of making a potentially + expensive copy. This is generally a good rule to follow when + creating high-performance applications.

+ +

If we run the above application on our sample + people.xml, the output looks as follows:

+ +
+name:   John Doe
+gender: male
+age:    32
+id:     1
+
+name:   Jane Mary Doe
+gender: female
+age:    28
+id:     2
+  
+ + +

4.3 Modifying the Object Model

+ +

In this section we will learn how to modify the information + stored in the object model for our person records vocabulary. + The following application changes the contents of the + people.xml file:

+ +
+#include <iostream>
+#include "people.hxx"
+
+using namespace std;
+
+int
+main ()
+{
+  unique_ptr<people_t> ppl (people ("people.xml"));
+
+  // Iterate over individual person records and increment
+  // the age.
+  //
+  people_t::person_sequence& ps (ppl->person ());
+
+  for (people_t::person_iterator i (ps.begin ()); i != ps.end (); ++i)
+  {
+    // Alternative way: i->age ()++;
+    //
+    i->age (i->age () + 1);
+  }
+
+  // Add middle-name to the first record and remove it from
+  // the second.
+  //
+  person_t& john (ps[0]);
+  person_t& jane (ps[1]);
+
+  john.middle_name ("Mary");
+  jane.middle_name ().reset ();
+
+  // Add another John record.
+  //
+  ps.push_back (john);
+
+  // Serialize the modified object model to XML.
+  //
+  xml_schema::namespace_infomap map;
+  map[""].name = "";
+  map[""].schema = "people.xsd";
+
+  people (cout, *ppl, map);
+}
+  
+ +

The first modification the above application performs is iterating + over person records and incrementing the age value. This code + fragment shows how to modify the value of a required attribute + or element. The next modification shows how to set a new value + for the optional middle-name element as well + as clear its value. Finally the example adds a copy of the + John Doe record to the person element sequence.

+ +

Note that in this case using references for the ps, + john, and jane variables is no longer + a performance improvement but a requirement for the application + to function correctly. If we hadn't used references, all our changes + would have been made on copies without affecting the object model.

+ +

If we run the above application on our sample people.xml, + the output looks as follows:

+ +
+<?xml version="1.0"?>
+<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="people.xsd">
+
+  <person id="1">
+    <first-name>John</first-name>
+    <middle-name>Mary</middle-name>
+    <last-name>Doe</last-name>
+    <gender>male</gender>
+    <age>33</age>
+  </person>
+
+  <person id="2">
+    <first-name>Jane</first-name>
+    <last-name>Doe</last-name>
+    <gender>female</gender>
+    <age>29</age>
+  </person>
+
+  <person id="1">
+    <first-name>John</first-name>
+    <middle-name>Mary</middle-name>
+    <last-name>Doe</last-name>
+    <gender>male</gender>
+    <age>33</age>
+  </person>
+
+</people>
+  
+ + +

4.4 Creating the Object Model from Scratch

+ +

In this section we will learn how to create a new object model + for our person records vocabulary. The following application + recreates the content of the original people.xml + file:

+ +
+#include <iostream>
+#include "people.hxx"
+
+using namespace std;
+
+int
+main ()
+{
+  people_t ppl;
+  people_t::person_sequence& ps (ppl.person ());
+
+  // Add the John Doe record.
+  //
+  ps.push_back (
+    person_t ("John",         // first-name
+              "Doe",          // last-name
+              gender_t::male, // gender
+              32,             // age
+              1));
+
+  // Add the Jane Doe record.
+  //
+  ps.push_back (
+    person_t ("Jane",           // first-name
+              "Doe",            // last-name
+              gender_t::female, // gender
+              28,               // age
+              2));              // id
+
+  // Add middle name to the Jane Doe record.
+  //
+  person_t& jane (ps.back ());
+  jane.middle_name ("Mary");
+
+  // Serialize the object model to XML.
+  //
+  xml_schema::namespace_infomap map;
+  map[""].name = "";
+  map[""].schema = "people.xsd";
+
+  people (cout, ppl, map);
+}
+  
+ +

The only new part in the above application is the calls + to the people_t and person_t + constructors. As a general rule, for each C++ class + XSD generates a constructor with initializers + for each element and attribute belonging to the one + cardinality class. For our vocabulary, the following + constructors are generated:

+ +
+class person_t
+{
+  person_t (const first_name_type&,
+            const last_name_type&,
+            const gender_type&,
+            const age_type&,
+            const id_type&);
+};
+
+class people_t
+{
+  people_t ();
+};
+  
+ +

Note also that we set the middle-name element + on the Jane Doe record by obtaining a reference to that record + in the object model and setting the middle-name + value on it. This is a general rule that should be followed + in order to obtain the best performance: if possible, + direct modifications to the object model should be preferred + to modifications on temporaries with subsequent copying. The + following code fragment shows a semantically equivalent but + slightly slower version:

+ +
+// Add the Jane Doe record.
+//
+person_t jane ("Jane",           // first-name
+               "Doe",            // last-name
+               gender_t::female, // gender
+               28,               // age
+               2);               // id
+
+jane.middle_name ("Mary");
+
+ps.push_back (jane);
+  
+ +

We can also go one step further to reduce copying and improve + the performance of our application by using the non-copying + push_back() function which assumes ownership + of the passed objects:

+ +
+// Add the Jane Doe record. C++11 version
+//
+unique_ptr<person_t> jane_p (
+  new person_t ("Jane",           // first-name
+                "Doe",            // last-name
+                gender_t::female, // gender
+                28,               // age
+                2));              // id
+ps.push_back (std::move (jane_p)); // assumes ownership
+
+// Add the John Doe record. C++98 version.
+//
+auto_ptr<person_t> john_p (
+  new person_t ("John",           // first-name
+                "Doe",            // last-name
+                gender_t::male,   // gender
+                32,               // age
+                1));
+ps.push_back (john_p); // assumes ownership
+  
+ +

For more information on the non-copying modifier functions refer to + Section + 2.8, "Mapping for Local Elements and Attributes" in the C++/Tree Mapping + User Manual. The above application produces the following output:

+ +
+<?xml version="1.0" ?>
+<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="people.xsd">
+
+  <person id="1">
+    <first-name>John</first-name>
+    <last-name>Doe</last-name>
+    <gender>male</gender>
+    <age>32</age>
+  </person>
+
+  <person id="2">
+    <first-name>Jane</first-name>
+    <middle-name>Mary</middle-name>
+    <last-name>Doe</last-name>
+    <gender>female</gender>
+    <age>28</age>
+  </person>
+
+</people>
+  
+ +

4.5 Mapping for the Built-in XML Schema Types

+ +

Our person record vocabulary uses several built-in XML Schema + types: string, short, and + unsignedInt. Until now we haven't talked about + the mapping of built-in XML Schema types to C++ types and how + to work with them. This section provides an overview + of the built-in types. For more detailed information refer + to Section + 2.5, "Mapping for Built-in Data Types" in the C++/Tree Mapping + User Manual.

+ +

In XML Schema, built-in types are defined in the XML Schema namespace. + By default, the C++/Tree mapping maps this namespace to C++ + namespace xml_schema (this mapping can be altered + with the --namespace-map option). The following table + summarizes the mapping of XML Schema built-in types to C++ types:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
XML Schema typeAlias in the xml_schema namespaceC++ type
fixed-length integral types
bytebytesigned char
unsignedByteunsigned_byteunsigned char
shortshort_short
unsignedShortunsigned_shortunsigned short
intint_int
unsignedIntunsigned_intunsigned int
longlong_long long
unsignedLongunsigned_longunsigned long long
arbitrary-length integral types
integerintegerlong long
nonPositiveIntegernon_positive_integerlong long
nonNegativeIntegernon_negative_integerunsigned long long
positiveIntegerpositive_integerunsigned long long
negativeIntegernegative_integerlong long
boolean types
booleanbooleanbool
fixed-precision floating-point types
floatfloat_float
doubledouble_double
arbitrary-precision floating-point types
decimaldecimaldouble
string types
stringstringtype derived from std::basic_string
normalizedStringnormalized_stringtype derived from string
tokentokentype derived from normalized_string
Namenametype derived from token
NMTOKENnmtokentype derived from token
NMTOKENSnmtokenstype derived from sequence<nmtoken>
NCNamencnametype derived from name
languagelanguagetype derived from token
qualified name
QNameqnamexml_schema::qname
ID/IDREF types
IDidtype derived from ncname
IDREFidreftype derived from ncname
IDREFSidrefstype derived from sequence<idref>
URI types
anyURIuritype derived from std::basic_string
binary types
base64Binarybase64_binaryxml_schema::base64_binary
hexBinaryhex_binaryxml_schema::hex_binary
date/time types
datedatexml_schema::date
dateTimedate_timexml_schema::date_time
durationdurationxml_schema::duration
gDaygdayxml_schema::gday
gMonthgmonthxml_schema::gmonth
gMonthDaygmonth_dayxml_schema::gmonth_day
gYeargyearxml_schema::gyear
gYearMonthgyear_monthxml_schema::gyear_month
timetimexml_schema::time
entity types
ENTITYentitytype derived from name
ENTITIESentitiestype derived from sequence<entity>
+ +

As you can see from the table above a number of built-in + XML Schema types are mapped to fundamental C++ types such + as int or bool. All string-based + XML Schema types are mapped to C++ types that are derived + from either std::string or + std::wstring, depending on the character + type selected. For access and modification purposes these + types can be treated as std::string. A number + of built-in types, such as qname, the binary + types, and the date/time types do not have suitable + fundamental or standard C++ types to map to. As a result, + these types are implemented from scratch in the XSD runtime. + For more information on their interfaces refer to + Section + 2.5, "Mapping for Built-in Data Types" in the C++/Tree Mapping + User Manual.

+ + + + + +

5 Parsing

+ +

We have already seen how to parse XML to an object model in this guide + before. In this chapter we will discuss the parsing topic in more + detail.

+ +

By default, the C++/Tree mapping provides a total of 14 overloaded + parsing functions. They differ in the input methods used to + read XML as well as the error reporting mechanisms. It is also possible + to generate types for root elements instead of parsing and serialization + functions. This may be useful if your XML vocabulary has multiple + root elements. For more information on element types refer to + Section + 2.9, "Mapping for Global Elements" in the C++/Tree Mapping User + Manual.

+ + +

In this section we will discuss the most commonly used versions of + the parsing functions. For a comprehensive description of parsing + refer to Chapter + 3, "Parsing" in the C++/Tree Mapping User Manual. For the people + global element from our person record vocabulary, we will concentrate + on the following three parsing functions:

+ +
+std::[unique|auto]_ptr<people_t>
+people (const std::string& uri,
+	xml_schema::flags f = 0,
+	const xml_schema::properties& p = xml_schema::properties ());
+
+std::[unique|auto]_ptr<people_t>
+people (std::istream& is,
+        xml_schema::flags f = 0,
+        const xml_schema::properties& p = xml_schema::properties ());
+
+std::[unique|auto]_ptr<people_t>
+people (std::istream& is,
+        const std::string& resource_id,
+        xml_schema::flags f = 0,
+        const xml_schema::properties& p = ::xml_schema::properties ());
+  
+ +

The first function parses a local file or a URI. We have already + used this parsing function in the previous chapters. The second + and third functions read XML from a standard input stream. The + last function also requires a resource id. This id is used to + identify the XML document being parser in diagnostics messages + as well as to resolve relative paths to other documents (for example, + schemas) that might be referenced from the XML document.

+ +

The last two arguments to all three parsing functions are parsing + flags and properties. The flags argument provides a number of ways + to fine-tune the parsing process. The properties argument allows + to pass additional information to the parsing functions. We will + use these two arguments in Section 5.1, "XML Schema + Validation and Searching" below. All three functions return + the object model as either std::unique_ptr (C++11) or + std::auto_ptr (C++98), depending on the C++ standard + selected (--std XSD compiler option). The following + example shows how we can use the above parsing functions:

+ +
+using std::unique_ptr;
+
+// Parse a local file or URI.
+//
+unique_ptr<people_t> p1 (people ("people.xml"));
+unique_ptr<people_t> p2 (people ("http://example.com/people.xml"));
+
+// Parse a local file via ifstream.
+//
+std::ifstream ifs ("people.xml");
+unique_ptr<people_t> p3 (people (ifs, "people.xml"));
+
+// Parse an XML string.
+//
+std::string str ("..."); // XML in a string.
+std::istringstream iss (str);
+unique_ptr<people_t> p4 (people (iss));
+  
+ + +

5.1 XML Schema Validation and Searching

+ +

The C++/Tree mapping relies on the underlying Xerces-C++ XML + parser for full XML document validation. The XML Schema + validation is enabled by default and can be disabled by + passing the xml_schema::flags::dont_validate + flag to the parsing functions, for example:

+ +
+unique_ptr<people_t> p (
+  people ("people.xml", xml_schema::flags::dont_validate));
+  
+ +

Even when XML Schema validation is disabled, the generated + code still performs a number of checks to prevent + construction of an inconsistent object model (for example, an + object model with missing required attributes or elements).

+ +

When XML Schema validation is enabled, the XML parser needs + to locate a schema to validate against. There are several + methods to provide the schema location information to the + parser. The easiest and most commonly used method is to + specify schema locations in the XML document itself + with the schemaLocation or + noNamespaceSchemaLocation attributes, for example:

+ +
+<?xml version="1.0" ?>
+<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="people.xsd"
+        xsi:schemaLocation="http://www.w3.org/XML/1998/namespace xml.xsd">
+  
+ +

As you might have noticed, we used this method in all the sample XML + documents presented in this guide up until now. Note that the + schema locations specified with these two attributes are relative + to the document's path unless they are absolute URIs (that is + start with http://, file://, etc.). + In particular, if you specify just file names as your schema + locations, as we did above, then the schemas should reside in + the same directory as the XML document itself.

+ +

Another method of providing the schema location information + is via the xml_schema::properties argument, as + shown in the following example:

+ +
+xml_schema::properties props;
+props.no_namespace_schema_location ("people.xsd");
+props.schema_location ("http://www.w3.org/XML/1998/namespace", "xml.xsd");
+
+unique_ptr<people_t> p (people ("people.xml", 0, props));
+  
+ +

The schema locations provided with this method overrides + those specified in the XML document. As with the previous + method, the schema locations specified this way are + relative to the document's path unless they are absolute URIs. + In particular, if you want to use local schemas that are + not related to the document being parsed, then you will + need to use the file:// URI. The following + example shows how to use schemas that reside in the current + working directory:

+ +
+#include <unistd.h> // getcwd
+#include <limits.h> // PATH_MAX
+
+char cwd[PATH_MAX];
+if (getcwd (cwd, PATH_MAX) == 0)
+{
+  // Buffer too small?
+}
+
+xml_schema::properties props;
+
+props.no_namespace_schema_location (
+  "file:///" + std::string (cwd) + "/people.xsd");
+
+props.schema_location (
+  "http://www.w3.org/XML/1998/namespace",
+  "file:///" + std::string (cwd) + "/xml.xsd");
+
+unique_ptr<people_t> p (people ("people.xml", 0, props));
+  
+ +

A third method is the most useful if you are planning to parse + several XML documents of the same vocabulary. In that case + it may be beneficial to pre-parse and cache the schemas in + the XML parser which can then be used to parse all documents + without re-parsing the schemas. For more information on + this method refer to the caching example in the + cxx/tree/ directory in the + xsd-examples package. + It is also possible to convert the schemas into a pre-compiled + binary representation and embed this representation directly into + the application executable. With this approach your application can + perform XML Schema validation without depending on any external + schema files. For more information on how to achieve this refer to + the embedded example in the cxx/tree/ + directory in the xsd-examples + package.

+ +

When the XML parser cannot locate a schema for the + XML document, the validation fails and XML document + elements and attributes for which schema definitions could + not be located are reported in the diagnostics. For + example, if we remove the noNamespaceSchemaLocation + attribute in people.xml from the previous chapter, + then we will get the following diagnostics if we try to parse + this file with validation enabled:

+ +
+people.xml:2:63 error: no declaration found for element 'people'
+people.xml:4:18 error: no declaration found for element 'person'
+people.xml:4:18 error: attribute 'id' is not declared for element 'person'
+people.xml:5:17 error: no declaration found for element 'first-name'
+people.xml:6:18 error: no declaration found for element 'middle-name'
+people.xml:7:16 error: no declaration found for element 'last-name'
+people.xml:8:13 error: no declaration found for element 'gender'
+people.xml:9:10 error: no declaration found for element 'age'
+  
+ +

5.2 Error Handling

+ +

The parsing functions offer a number of ways to handle error conditions + with the C++ exceptions being the most commonly used mechanism. All + C++/Tree exceptions derive from common base xml_schema::exception + which in turn derives from std::exception. The easiest + way to uniformly handle all possible C++/Tree exceptions and print + detailed information about the error is to catch and print + xml_schema::exception, as shown in the following + example:

+ +
+try
+{
+  unique_ptr<people_t> p (people ("people.xml"));
+}
+catch (const xml_schema::exception& e)
+{
+  cerr << e << endl;
+}
+  
+ +

Each individual C++/Tree exception also allows you to obtain + error details programmatically. For example, the + xml_schema::parsing exception is thrown when + the XML parsing and validation in the underlying XML parser + fails. It encapsulates various diagnostics information + such as the file name, line and column numbers, as well as the + error or warning message for each entry. For more information + about this and other exceptions that can be thrown during + parsing, refer to + Section + 3.3, "Error Handling" in the C++/Tree Mapping + User Manual.

+ +

Note that if you are parsing std::istream on which + exceptions are not enabled, then you will need to check the + stream state after the call to the parsing function in order + to detect any possible stream failures, for example:

+ +
+std::ifstream ifs ("people.xml");
+
+if (ifs.fail ())
+{
+  cerr << "people.xml: unable to open" << endl;
+  return 1;
+}
+
+unique_ptr<people_t> p (people (ifs, "people.xml"));
+
+if (ifs.fail ())
+{
+  cerr << "people.xml: read error" << endl;
+  return 1;
+}
+  
+ +

The above example can be rewritten to use exceptions as + shown below:

+ +
+try
+{
+  std::ifstream ifs;
+  ifs.exceptions (std::ifstream::badbit | std::ifstream::failbit);
+  ifs.open ("people.xml");
+
+  unique_ptr<people_t> p (people (ifs, "people.xml"));
+}
+catch (const std::ifstream::failure&)
+{
+  cerr << "people.xml: unable to open or read error" << endl;
+  return 1;
+}
+  
+ + + + + +

6 Serialization

+ +

We have already seen how to serialize an object model back to XML + in this guide before. In this chapter we will discuss the + serialization topic in more detail.

+ +

By default, the C++/Tree mapping provides a total of 8 overloaded + serialization functions. They differ in the output methods used to write + XML as well as the error reporting mechanisms. It is also possible to + generate types for root elements instead of parsing and serialization + functions. This may be useful if your XML vocabulary has multiple + root elements. For more information on element types refer to + Section + 2.9, "Mapping for Global Elements" in the C++/Tree Mapping User + Manual.

+ + +

In this section we will discuss the most commonly + used version of serialization functions. For a comprehensive description + of serialization refer to + Chapter + 4, "Serialization" in the C++/Tree Mapping User Manual. For the + people global element from our person record vocabulary, + we will concentrate on the following serialization function:

+ +
+void
+people (std::ostream& os,
+        const people_t& x,
+        const xml_schema::namespace_infomap& map =
+          xml_schema::namespace_infomap (),
+        const std::string& encoding = "UTF-8",
+        xml_schema::flags f = 0);
+  
+ +

This function serializes the object model passed as the second + argument to the standard output stream passed as the first + argument. The third argument is a namespace information map + which we will discuss in more detail in the next section. + The fourth argument is a character encoding that the resulting + XML document should be in. Possible valid values for this + argument are "US-ASCII", "ISO8859-1", "UTF-8", "UTF-16BE", + "UTF-16LE", "UCS-4BE", and "UCS-4LE". Finally, the flags + argument allows fine-tuning of the serialization process. + The following example shows how we can use the above serialization + function:

+ +
+people_t& p = ...
+
+xml_schema::namespace_infomap map;
+map[""].schema = "people.xsd";
+
+// Serialize to stdout.
+//
+people (std::cout, p, map);
+
+// Serialize to a file.
+//
+std::ofstream ofs ("people.xml");
+people (ofs, p, map);
+
+// Serialize to a string.
+//
+std::ostringstream oss;
+people (oss, p, map);
+std::string xml (oss.str ());
+  
+ + +

6.1 Namespace and Schema Information

+ +

While XML serialization can be done just from the object + model alone, it is often desirable to assign meaningful + prefixes to XML namespaces used in the vocabulary as + well as to provide the schema location information. + This is accomplished by passing the namespace information + map to the serialization function. The key in this map is + a namespace prefix that should be assigned to an XML namespace + specified in the name variable of the + map value. You can also assign an optional schema location for + this namespace in the schema variable. Based + on each key-value entry in this map, the serialization + function adds two attributes to the resulting XML document: + the namespace-prefix mapping attribute and schema location + attribute. The empty prefix indicates that the namespace + should be mapped without a prefix. For example, the following + map:

+ +
+xml_schema::namespace_infomap map;
+
+map[""].name = "http://www.example.com/example";
+map[""].schema = "example.xsd";
+
+map["x"].name = "http://www.w3.org/XML/1998/namespace";
+map["x"].schema = "xml.xsd";
+  
+ +

Results in the following XML document:

+ +
+<?xml version="1.0" ?>
+<example
+  xmlns="http://www.example.com/example"
+  xmlns:x="http://www.w3.org/XML/1998/namespace"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.example.com/example example.xsd
+                      http://www.w3.org/XML/1998/namespace xml.xsd">
+  
+ +

The empty namespace indicates that the vocabulary has no target + namespace. For example, the following map results in only the + noNamespaceSchemaLocation attribute being added:

+ +
+xml_schema::namespace_infomap map;
+
+map[""].name = "";
+map[""].schema = "example.xsd";
+  
+ +

6.2 Error Handling

+ +

Similar to the parsing functions, the serialization functions offer a + number of ways to handle error conditions with the C++ exceptions being + the most commonly used mechanisms. As with parsing, the easiest way to + uniformly handle all possible serialization exceptions and print + detailed information about the error is to catch and print + xml_schema::exception:

+ +
+try
+{
+  people_t& p = ...
+
+  xml_schema::namespace_infomap map;
+  map[""].schema = "people.xsd";
+
+  people (std::cout, p, map));
+}
+catch (const xml_schema::exception& e)
+{
+  cerr << e << endl;
+}
+  
+ +

The most commonly encountered serialization exception is + xml_schema::serialization. It is thrown + when the XML serialization in the underlying XML writer + fails. It encapsulates various diagnostics information + such as the file name, line and column numbers, as well as the + error or warning message for each entry. For more information + about this and other exceptions that can be thrown during + serialization, refer to + Section + 4.4, "Error Handling" in the C++/Tree Mapping + User Manual.

+ +

Note that if you are serializing to std::ostream on + which exceptions are not enabled, then you will need to check the + stream state after the call to the serialization function in order + to detect any possible stream failures, for example:

+ +
+std::ofstream ofs ("people.xml");
+
+if (ofs.fail ())
+{
+  cerr << "people.xml: unable to open" << endl;
+  return 1;
+}
+
+people (ofs, p, map));
+
+if (ofs.fail ())
+{
+  cerr << "people.xml: write error" << endl;
+  return 1;
+}
+  
+ +

The above example can be rewritten to use exceptions as + shown below:

+ +
+try
+{
+  std::ofstream ofs;
+  ofs.exceptions (std::ofstream::badbit | std::ofstream::failbit);
+  ofs.open ("people.xml");
+
+  people (ofs, p, map));
+}
+catch (const std::ofstream::failure&)
+{
+  cerr << "people.xml: unable to open or write error" << endl;
+  return 1;
+}
+  
+ +
+
+ + + diff --git a/xsd/doc/cxx/tree/manual/.gitignore b/xsd/doc/cxx/tree/manual/.gitignore new file mode 100644 index 0000000..39e8d48 --- /dev/null +++ b/xsd/doc/cxx/tree/manual/.gitignore @@ -0,0 +1,2 @@ +index.xhtml +manual.html2ps diff --git a/xsd/doc/cxx/tree/manual/index.xhtml.in b/xsd/doc/cxx/tree/manual/index.xhtml.in new file mode 100644 index 0000000..5a7240a --- /dev/null +++ b/xsd/doc/cxx/tree/manual/index.xhtml.in @@ -0,0 +1,6826 @@ + + + + + + C++/Tree Mapping User Manual + + + + + + + + + + + + + + +
+
+ +
+ +
+
C++/Tree Mapping User Manual
+ +

Copyright © @copyright@.

+ +

Permission is granted to copy, distribute and/or modify this + document under the terms of the + GNU Free + Documentation License, version 1.2; with no Invariant Sections, + no Front-Cover Texts and no Back-Cover Texts. +

+ +

This document is available in the following formats: + XHTML, + PDF, and + PostScript.

+
+ +

Table of Contents

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Preface + + + +
About This Document
More Information
+
1Introduction
2C++/Tree Mapping + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
2.1Preliminary Information + + + + + + +
2.1.1C++ Standard
2.1.2Identifiers
2.1.3Character Type and Encoding
2.1.4XML Schema Namespace
2.1.5Anonymous Types
+
2.2Error Handling + + +
2.2.1xml_schema::duplicate_id
+
2.3Mapping for import and include + + + + +
2.3.1Import
2.3.2Inclusion with Target Namespace
2.3.3Inclusion without Target Namespace
+
2.4Mapping for Namespaces
2.5Mapping for Built-in Data Types + + + + + + + + + + + + + + + + + +
2.5.1Inheritance from Built-in Data Types
2.5.2Mapping for anyType
2.5.3Mapping for anySimpleType
2.5.4Mapping for QName
2.5.5Mapping for IDREF
2.5.6Mapping for base64Binary and hexBinary
2.5.7Time Zone Representation
2.5.8Mapping for date
2.5.9Mapping for dateTime
2.5.10Mapping for duration
2.5.11Mapping for gDay
2.5.12Mapping for gMonth
2.5.13Mapping for gMonthDay
2.5.14Mapping for gYear
2.5.15Mapping for gYearMonth
2.5.16Mapping for time
+
2.6Mapping for Simple Types + + + + + +
2.6.1Mapping for Derivation by Restriction
2.6.2Mapping for Enumerations
2.6.3Mapping for Derivation by List
2.6.4Mapping for Derivation by Union
+
2.7Mapping for Complex Types + + + +
2.7.1Mapping for Derivation by Extension
2.7.2Mapping for Derivation by Restriction
+
2.8Mapping for Local Elements and Attributes + + + + + +
2.8.1Mapping for Members with the One Cardinality Class
2.8.2Mapping for Members with the Optional Cardinality Class
2.8.3Mapping for Members with the Sequence Cardinality Class
2.8.4Element Order
+
2.9Mapping for Global Elements + + + +
2.9.1Element Types
2.9.2Element Map
+
2.10Mapping for Global Attributes
2.11Mapping for xsi:type and Substitution Groups
2.12Mapping for any and anyAttribute + + + + + + +
2.12.1Mapping for any with the One Cardinality Class
2.12.2Mapping for any with the Optional Cardinality Class
2.12.3Mapping for any with the Sequence Cardinality Class
2.12.4Element Wildcard Order
2.12.5Mapping for anyAttribute
+
2.13Mapping for Mixed Content Models
+
3Parsing + + + + + + + + + + + + + + + + + + + + + + +
3.1Initializing the Xerces-C++ Runtime
3.2Flags and Properties
3.3Error Handling + + + + + + + + + + +
3.3.1xml_schema::parsing
3.3.2xml_schema::expected_element
3.3.3xml_schema::unexpected_element
3.3.4xml_schema::expected_attribute
3.3.5xml_schema::unexpected_enumerator
3.3.6xml_schema::expected_text_content
3.3.7xml_schema::no_type_info
3.3.8xml_schema::not_derived
3.3.9xml_schema::not_prefix_mapping
+
3.4Reading from a Local File or URI
3.5Reading from std::istream
3.6Reading from xercesc::InputSource
3.7Reading from DOM
+
4Serialization + + + + + + + + + + + + + + + + + + + + + + +
4.1Initializing the Xerces-C++ Runtime
4.2Namespace Infomap and Character Encoding
4.3Flags
4.4Error Handling + + + + +
4.4.1xml_schema::serialization
4.4.2xml_schema::unexpected_element
4.4.3xml_schema::no_type_info
+
4.5Serializing to std::ostream
4.6Serializing to xercesc::XMLFormatTarget
4.7Serializing to DOM
+
5Additional Functionality + + + + + + + +
5.1DOM Association
5.2Binary Serialization
+
Appendix A — Default and Fixed Values
+
+ +

Preface

+ +

About This Document

+ +

This document describes the mapping of W3C XML Schema + to the C++ programming language as implemented by + CodeSynthesis + XSD - an XML Schema to C++ data binding compiler. The mapping + represents information stored in XML instance documents as a + statically-typed, tree-like in-memory data structure and is + called C++/Tree. +

+ +

Revision 4.1.0
+ This revision of the manual describes the C++/Tree + mapping as implemented by CodeSynthesis XSD version 4.1.0. +

+ +

This document is available in the following formats: + XHTML, + PDF, and + PostScript.

+ +

More Information

+ +

Beyond this manual, you may also find the following sources of + information useful:

+ + + + +

1 Introduction

+ +

C++/Tree is a W3C XML Schema to C++ mapping that represents the + data stored in XML as a statically-typed, vocabulary-specific + object model. Based on a formal description of an XML vocabulary + (schema), the C++/Tree mapping produces a tree-like data structure + suitable for in-memory processing as well as XML parsing and + serialization code.

+ +

A typical application that processes XML documents usually + performs the following three steps: it first reads (parses) an XML + instance document to an object model, it then performs + some useful computations on that model which may involve + modification of the model, and finally it may write (serialize) + the modified object model back to XML. +

+ +

The C++/Tree mapping consists of C++ types that represent the + given vocabulary (Chapter 2, "C++/Tree Mapping"), + a set of parsing functions that convert XML documents to + a tree-like in-memory data structure (Chapter 3, + "Parsing"), and a set of serialization functions that convert + the object model back to XML (Chapter 4, + "Serialization"). Furthermore, the mapping provides a number + of additional features, such as DOM association and binary + serialization, that can be useful in some applications + (Chapter 5, "Additional Functionality"). +

+ + + + + +

2 C++/Tree Mapping

+ +

2.1 Preliminary Information

+ +

2.1.1 C++ Standard

+ +

The C++/Tree mapping provides support for ISO/IEC C++ 2011 (C++11) + and ISO/IEC C++ 1998/2003 (C++98). To select the C++ standard for the + generated code we use the --std XSD compiler command + line option. While the majority of the examples in this guide use + C++11, the document explains the C++11/98 usage difference and so + they can easily be converted to C++98.

+ +

2.1.2 Identifiers

+ +

XML Schema names may happen to be reserved C++ keywords or contain + characters that are illegal in C++ identifiers. To avoid C++ compilation + problems, such names are changed (escaped) when mapped to C++. If an + XML Schema name is a C++ keyword, the "_" suffix is added to it. All + character of an XML Schema name that are not allowed in C++ identifiers + are replaced with "_". +

+ +

For example, XML Schema name try will be mapped to + C++ identifier try_. Similarly, XML Schema name + strange.na-me will be mapped to C++ identifier + strange_na_me. +

+ +

Furthermore, conflicts between type names and function names in the + same scope are resolved using name escaping. Such conflicts include + both a global element (which is mapped to a set of parsing and/or + serialization functions or element types, see Section + 2.9, "Mapping for Global Elements") and a global type sharing the + same name as well as a local element or attribute inside a type having + the same name as the type itself.

+ +

For example, if we had a global type catalog + and a global element with the same name then the type would be + mapped to a C++ class with name catalog while the + parsing functions corresponding to the global element would have + their names escaped as catalog_. +

+ +

By default the mapping uses the so-called K&R (Kernighan and + Ritchie) identifier naming convention which is also used throughout + this manual. In this convention both type and function names are in + lower case and words are separated by underscores. If your application + code or schemas use a different notation, you may want to change the + naming convention used by the mapping for consistency. + The compiler supports a set of widely-used naming conventions + that you can select with the --type-naming and + --function-naming options. You can also further + refine one of the predefined conventions or create a completely + custom naming scheme by using the --*-regex options. + For more detailed information on these options refer to the NAMING + CONVENTION section in the XSD + Compiler Command Line Manual.

+ +

2.1.3 Character Type and Encoding

+ +

The code that implements the mapping, depending on the + --char-type option, is generated using either + char or wchar_t as the character + type. In this document code samples use symbol C + to refer to the character type you have selected when translating + your schemas, for example std::basic_string<C>. +

+ +

Another aspect of the mapping that depends on the character type + is character encoding. For the char character type + the default encoding is UTF-8. Other supported encodings are + ISO-8859-1, Xerces-C++ Local Code Page (LPC), as well as + custom encodings and can be selected with the + --char-encoding command line option.

+ +

For the wchar_t character type the encoding is + automatically selected between UTF-16 and UTF-32/UCS-4 depending + on the size of the wchar_t type. On some platforms + (for example, Windows with Visual C++ and AIX with IBM XL C++) + wchar_t is 2 bytes long. For these platforms the + encoding is UTF-16. On other platforms wchar_t is 4 bytes + long and UTF-32/UCS-4 is used.

+ +

2.1.4 XML Schema Namespace

+ +

The mapping relies on some predefined types, classes, and functions + that are logically defined in the XML Schema namespace reserved for + the XML Schema language (http://www.w3.org/2001/XMLSchema). + By default, this namespace is mapped to C++ namespace + xml_schema. It is automatically accessible + from a C++ compilation unit that includes a header file generated + from an XML Schema definition. +

+ +

Note that, if desired, the default mapping of this namespace can be + changed as described in Section 2.4, "Mapping for + Namespaces". +

+ + +

2.1.5 Anonymous Types

+ +

For the purpose of code generation, anonymous types defined in + XML Schema are automatically assigned names that are derived + from enclosing attributes and elements. Otherwise, such types + follows standard mapping rules for simple and complex type + definitions (see Section 2.6, "Mapping for Simple Types" + and Section 2.7, "Mapping for Complex Types"). + For example, in the following schema fragment: +

+ +
+<element name="object">
+  <complexType>
+    ...
+  </complexType>
+</element>
+  
+ +

The anonymous type defined inside element object will + be given name object. The compiler has a number of + options that control the process of anonymous type naming. For more + information refer to the XSD + Compiler Command Line Manual.

+ + +

2.2 Error Handling

+ +

The mapping uses the C++ exception handling mechanism as a primary way + of reporting error conditions. All exceptions that are specified in + this mapping derive from xml_schema::exception which + itself is derived from std::exception: +

+ +
+struct exception: virtual std::exception
+{
+  friend
+  std::basic_ostream<C>&
+  operator<< (std::basic_ostream<C>& os, const exception& e)
+  {
+    e.print (os);
+    return os;
+  }
+
+protected:
+  virtual void
+  print (std::basic_ostream<C>&) const = 0;
+};
+  
+ +

The exception hierarchy supports "virtual" operator<< + which allows you to obtain diagnostics corresponding to the thrown + exception using the base exception interface. For example:

+ +
+try
+{
+  ...
+}
+catch (const xml_schema::exception& e)
+{
+  cerr << e << endl;
+}
+  
+ +

The following sub-sections describe exceptions thrown by the + types that constitute the object model. + Section 3.3, "Error Handling" of + Chapter 3, "Parsing" describes exceptions + and error handling mechanisms specific to the parsing functions. + Section 4.4, "Error Handling" of + Chapter 4, "Serialization" describes exceptions + and error handling mechanisms specific to the serialization functions. +

+ + +

2.2.1 xml_schema::duplicate_id

+ +
+struct duplicate_id: virtual exception
+{
+  duplicate_id (const std::basic_string<C>& id);
+
+  const std::basic_string<C>&
+  id () const;
+
+  virtual const char*
+  what () const throw ();
+};
+  
+ +

The xml_schema::duplicate_id is thrown when + a conflicting instance of xml_schema::id (see + Section 2.5, "Mapping for Built-in Data Types") + is added to a tree. The offending ID value can be obtained using + the id function. +

+ +

2.3 Mapping for import and include

+ +

2.3.1 Import

+ +

The XML Schema import element is mapped to the C++ + Preprocessor #include directive. The value of + the schemaLocation attribute is used to derive + the name of the header file that appears in the #include + directive. For instance: +

+ +
+<import namespace="https://www.codesynthesis.com/test"
+        schemaLocation="test.xsd"/>
+  
+ +

is mapped to:

+ +
+#include "test.hxx"
+  
+ +

Note that you will need to compile imported schemas separately + in order to produce corresponding header files.

+ +

2.3.2 Inclusion with Target Namespace

+ +

The XML Schema include element which refers to a schema + with a target namespace or appears in a schema without a target namespace + follows the same mapping rules as the import element, + see Section 2.3.1, "Import". +

+ +

2.3.3 Inclusion without Target Namespace

+ +

For the XML Schema include element which refers to a schema + without a target namespace and appears in a schema with a target + namespace (such inclusion sometimes called "chameleon inclusion"), + declarations and definitions from the included schema are generated + in-line in the namespace of the including schema as if they were + declared and defined there verbatim. For example, consider the + following two schemas: +

+ +
+<-- common.xsd -->
+<schema>
+  <complexType name="type">
+  ...
+  </complexType>
+</schema>
+
+<-- test.xsd -->
+<schema targetNamespace="https://www.codesynthesis.com/test">
+  <include schemaLocation="common.xsd"/>
+</schema>
+  
+ +

The fragment of interest from the generated header file for + text.xsd would look like this:

+ +
+// test.hxx
+namespace test
+{
+  class type
+  {
+    ...
+  };
+}
+  
+ +

2.4 Mapping for Namespaces

+ +

An XML Schema namespace is mapped to one or more nested C++ + namespaces. XML Schema namespaces are identified by URIs. + By default, a namespace URI is mapped to a sequence of + C++ namespace names by removing the protocol and host parts + and splitting the rest into a sequence of names with '/' + as the name separator. For instance: +

+ +
+<schema targetNamespace="https://www.codesynthesis.com/system/test">
+  ...
+</schema>
+  
+ +

is mapped to:

+ +
+namespace system
+{
+  namespace test
+  {
+    ...
+  }
+}
+  
+ +

The default mapping of namespace URIs to C++ namespace names can be + altered using the --namespace-map and + --namespace-regex options. See the + XSD + Compiler Command Line Manual for more information. +

+ +

2.5 Mapping for Built-in Data Types

+ +

The mapping of XML Schema built-in data types to C++ types is + summarized in the table below.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
XML Schema typeAlias in the xml_schema namespaceC++ type
anyType and anySimpleType types
anyTypetypeSection 2.5.2, "Mapping for anyType"
anySimpleTypesimple_typeSection 2.5.3, "Mapping for anySimpleType"
fixed-length integral types
bytebytesigned char
unsignedByteunsigned_byteunsigned char
shortshort_short
unsignedShortunsigned_shortunsigned short
intint_int
unsignedIntunsigned_intunsigned int
longlong_long long
unsignedLongunsigned_longunsigned long long
arbitrary-length integral types
integerintegerlong long
nonPositiveIntegernon_positive_integerlong long
nonNegativeIntegernon_negative_integerunsigned long long
positiveIntegerpositive_integerunsigned long long
negativeIntegernegative_integerlong long
boolean types
booleanbooleanbool
fixed-precision floating-point types
floatfloat_float
doubledouble_double
arbitrary-precision floating-point types
decimaldecimaldouble
string types
stringstringtype derived from std::basic_string
normalizedStringnormalized_stringtype derived from string
tokentokentype derived from normalized_string
Namenametype derived from token
NMTOKENnmtokentype derived from token
NMTOKENSnmtokenstype derived from sequence<nmtoken>
NCNamencnametype derived from name
languagelanguagetype derived from token
qualified name
QNameqnameSection 2.5.4, "Mapping for QName"
ID/IDREF types
IDidtype derived from ncname
IDREFidrefSection 2.5.5, "Mapping for IDREF"
IDREFSidrefstype derived from sequence<idref>
URI types
anyURIuritype derived from std::basic_string
binary types
base64Binarybase64_binarySection 2.5.6, "Mapping for + base64Binary and hexBinary"
hexBinaryhex_binary
date/time types
datedateSection 2.5.8, "Mapping for + date"
dateTimedate_timeSection 2.5.9, "Mapping for + dateTime"
durationdurationSection 2.5.10, "Mapping for + duration"
gDaygdaySection 2.5.11, "Mapping for + gDay"
gMonthgmonthSection 2.5.12, "Mapping for + gMonth"
gMonthDaygmonth_daySection 2.5.13, "Mapping for + gMonthDay"
gYeargyearSection 2.5.14, "Mapping for + gYear"
gYearMonthgyear_monthSection 2.5.15, "Mapping for + gYearMonth"
timetimeSection 2.5.16, "Mapping for + time"
entity types
ENTITYentitytype derived from name
ENTITIESentitiestype derived from sequence<entity>
+ +

All XML Schema built-in types are mapped to C++ classes that are + derived from the xml_schema::simple_type class except + where the mapping is to a fundamental C++ type.

+ +

The sequence class template is defined in an + implementation-specific namespace. It conforms to the + sequence interface as defined by the ISO/ANSI Standard for + C++ (ISO/IEC 14882:1998, Section 23.1.1, "Sequences"). + Practically, this means that you can treat such a sequence + as if it was std::vector. One notable extension + to the standard interface that is available only for + sequences of non-fundamental C++ types is the addition of + the overloaded push_back and insert + member functions which instead of the constant reference + to the element type accept automatic pointer (std::unique_ptr + or std::auto_ptr, depending on the C++ standard + selected) to the element type. These functions assume ownership + of the pointed to object and reset the passed automatic pointer. +

+ +

2.5.1 Inheritance from Built-in Data Types

+ +

In cases where the mapping calls for an inheritance from a built-in + type which is mapped to a fundamental C++ type, a proxy type is + used instead of the fundamental C++ type (C++ does not allow + inheritance from fundamental types). For instance:

+ +
+<simpleType name="my_int">
+  <restriction base="int"/>
+</simpleType>
+  
+ +

is mapped to:

+ +
+class my_int: public fundamental_base<int>
+{
+  ...
+};
+  
+ +

The fundamental_base class template provides a close + emulation (though not exact) of a fundamental C++ type. + It is defined in an implementation-specific namespace and has the + following interface:

+ +
+template <typename X>
+class fundamental_base: public simple_type
+{
+public:
+  fundamental_base ();
+  fundamental_base (X)
+  fundamental_base (const fundamental_base&)
+
+public:
+  fundamental_base&
+  operator= (const X&);
+
+public:
+  operator const X & () const;
+  operator X& ();
+
+  template <typename Y>
+  operator Y () const;
+
+  template <typename Y>
+  operator Y ();
+};
+  
+ +

2.5.2 Mapping for anyType

+ +

The XML Schema anyType built-in data type is mapped to the + xml_schema::type C++ class:

+ +
+class type
+{
+public:
+  virtual
+  ~type ();
+
+  type ();
+  type (const type&);
+
+  type&
+  operator= (const type&);
+
+  virtual type*
+  _clone () const;
+
+  // anyType DOM content.
+  //
+public:
+  typedef element_optional dom_content_optional;
+
+  const dom_content_optional&
+  dom_content () const;
+
+  dom_content_optional&
+  dom_content ();
+
+  void
+  dom_content (const xercesc::DOMElement&);
+
+  void
+  dom_content (xercesc::DOMElement*);
+
+  void
+  dom_content (const dom_content_optional&);
+
+  const xercesc::DOMDocument&
+  dom_content_document () const;
+
+  xercesc::DOMDocument&
+  dom_content_document ();
+
+  bool
+  null_content () const;
+
+  // DOM association.
+  //
+public:
+  const xercesc::DOMNode*
+  _node () const;
+
+  xercesc::DOMNode*
+  _node ();
+};
+  
+ +

When xml_schema::type is used to create an instance + (as opposed to being a base of a derived type), it represents + the XML Schema anyType type. anyType + allows any attributes and any content in any order. In the + C++/Tree mapping this content can be represented as a DOM + fragment, similar to XML Schema wildcards (Section + 2.12, "Mapping for any and + anyAttribute").

+ +

To enable automatic extraction of anyType content + during parsing, the --generate-any-type option must be + specified. Because the DOM API is used to access such content, the + Xerces-C++ runtime should be initialized by the application prior to + parsing and should remain initialized for the lifetime of objects + with the DOM content. For more information on the Xerces-C++ runtime + initialization see Section 3.1, "Initializing the + Xerces-C++ Runtime".

+ +

The DOM content is stored as the optional DOM element container + and the DOM content accessors and modifiers presented above are + identical to those generated for an optional element wildcard. + Refer to Section 2.12.2, "Mapping for any + with the Optional Cardinality Class" for details on their + semantics.

+ +

The dom_content_document() function returns the + DOM document used to store the raw XML content corresponding + to the anyType instance. It is equivalent to the + dom_document() function generated for types + with wildcards.

+ +

The null_content() accessor is an optimization function + that allows us to check for the lack of content without actually + creating its empty representation, that is, empty DOM document for + anyType or empty string for anySimpleType + (see the following section for details on anySimpleType).

+ +

For more information on DOM association refer to + Section 5.1, "DOM Association".

+ +

2.5.3 Mapping for anySimpleType

+ +

The XML Schema anySimpleType built-in data type is mapped + to the xml_schema::simple_type C++ class:

+ +
+class simple_type: public type
+{
+public:
+  simple_type ();
+  simple_type (const C*);
+  simple_type (const std::basic_string<C>&);
+
+  simple_type (const simple_type&);
+
+  simple_type&
+  operator= (const simple_type&);
+
+  virtual simple_type*
+  _clone () const;
+
+  // anySimpleType text content.
+  //
+public:
+  const std::basic_string<C>&
+  text_content () const;
+
+  std::basic_string<C>&
+  text_content ();
+
+  void
+  text_content (const std::basic_string<C>&);
+};
+  
+ +

When xml_schema::simple_type is used to create an instance + (as opposed to being a base of a derived type), it represents + the XML Schema anySimpleType type. anySimpleType + allows any simple content. In the C++/Tree mapping this content can + be represented as a string and accessed or modified with the + text_content() functions shown above.

+ +

2.5.4 Mapping for QName

+ +

The XML Schema QName built-in data type is mapped to the + xml_schema::qname C++ class:

+ +
+class qname: public simple_type
+{
+public:
+  qname (const ncname&);
+  qname (const uri&, const ncname&);
+  qname (const qname&);
+
+public:
+  qname&
+  operator= (const qname&);
+
+public:
+  virtual qname*
+  _clone () const;
+
+public:
+  bool
+  qualified () const;
+
+  const uri&
+  namespace_ () const;
+
+  const ncname&
+  name () const;
+};
+  
+ +

The qualified accessor function can be used to determine + if the name is qualified.

+ +

2.5.5 Mapping for IDREF

+ +

The XML Schema IDREF built-in data type is mapped to the + xml_schema::idref C++ class. This class implements the + smart pointer C++ idiom:

+ +
+class idref: public ncname
+{
+public:
+  idref (const C* s);
+  idref (const C* s, std::size_t n);
+  idref (std::size_t n, C c);
+  idref (const std::basic_string<C>&);
+  idref (const std::basic_string<C>&,
+         std::size_t pos,
+         std::size_t n = npos);
+
+public:
+  idref (const idref&);
+
+public:
+  virtual idref*
+  _clone () const;
+
+public:
+  idref&
+  operator= (C c);
+
+  idref&
+  operator= (const C* s);
+
+  idref&
+  operator= (const std::basic_string<C>&)
+
+  idref&
+  operator= (const idref&);
+
+public:
+  const type*
+  operator-> () const;
+
+  type*
+  operator-> ();
+
+  const type&
+  operator* () const;
+
+  type&
+  operator* ();
+
+  const type*
+  get () const;
+
+  type*
+  get ();
+
+  // Conversion to bool.
+  //
+public:
+  typedef void (idref::*bool_convertible)();
+  operator bool_convertible () const;
+};
+  
+ +

The object, idref instance refers to, is the immediate + container of the matching id instance. For example, + with the following instance document and schema: +

+ + +
+<!-- test.xml -->
+<root>
+  <object id="obj-1" text="hello"/>
+  <reference>obj-1</reference>
+</root>
+
+<!-- test.xsd -->
+<schema>
+  <complexType name="object_type">
+    <attribute name="id" type="ID"/>
+    <attribute name="text" type="string"/>
+  </complexType>
+
+  <complexType name="root_type">
+    <sequence>
+      <element name="object" type="object_type"/>
+      <element name="reference" type="IDREF"/>
+    </sequence>
+  </complexType>
+
+  <element name="root" type="root_type"/>
+</schema>
+  
+ +

The ref instance in the code below will refer to + an object of type object_type:

+ +
+root_type& root = ...;
+xml_schema::idref& ref (root.reference ());
+object_type& obj (dynamic_cast<object_type&> (*ref));
+cout << obj.text () << endl;
+  
+ +

The smart pointer interface of the idref class always + returns a pointer or reference to xml_schema::type. + This means that you will need to manually cast such pointer or + reference to its real (dynamic) type before you can use it (unless + all you need is the base interface provided by + xml_schema::type). As a special extension to the XML + Schema language, the mapping supports static typing of idref + references by employing the refType extension attribute. + The following example illustrates this mechanism: +

+ +
+<!-- test.xsd -->
+<schema
+  xmlns:xse="https://www.codesynthesis.com/xmlns/xml-schema-extension">
+
+  ...
+
+      <element name="reference" type="IDREF" xse:refType="object_type"/>
+
+  ...
+
+</schema>
+  
+ +

With this modification we do not need to do manual casting anymore: +

+ +
+root_type& root = ...;
+root_type::reference_type& ref (root.reference ());
+object_type& obj (*ref);
+cout << ref->text () << endl;
+  
+ + +

2.5.6 Mapping for base64Binary and + hexBinary

+ +

The XML Schema base64Binary and hexBinary + built-in data types are mapped to the + xml_schema::base64_binary and + xml_schema::hex_binary C++ classes, respectively. The + base64_binary and hex_binary classes + support a simple buffer abstraction by inheriting from the + xml_schema::buffer class: +

+ +
+class bounds: public virtual exception
+{
+public:
+  virtual const char*
+  what () const throw ();
+};
+
+class buffer
+{
+public:
+  typedef std::size_t size_t;
+
+public:
+  buffer (size_t size = 0);
+  buffer (size_t size, size_t capacity);
+  buffer (const void* data, size_t size);
+  buffer (const void* data, size_t size, size_t capacity);
+  buffer (void* data,
+          size_t size,
+          size_t capacity,
+          bool assume_ownership);
+
+public:
+  buffer (const buffer&);
+
+  buffer&
+  operator= (const buffer&);
+
+  void
+  swap (buffer&);
+
+public:
+  size_t
+  capacity () const;
+
+  bool
+  capacity (size_t);
+
+public:
+  size_t
+  size () const;
+
+  bool
+  size (size_t);
+
+public:
+  const char*
+  data () const;
+
+  char*
+  data ();
+
+  const char*
+  begin () const;
+
+  char*
+  begin ();
+
+  const char*
+  end () const;
+
+  char*
+  end ();
+};
+  
+ +

The last overloaded constructor reuses an existing data buffer instead + of making a copy. If the assume_ownership argument is + true, the instance assumes ownership of the + memory block pointed to by the data argument and will + eventually release it by calling operator delete. The + capacity and size modifier functions return + true if the underlying buffer has moved. +

+ +

The bounds exception is thrown if the constructor + arguments violate the (size <= capacity) + constraint.

+ +

The base64_binary and hex_binary classes + support the buffer interface and perform automatic + decoding/encoding from/to the Base64 and Hex formats, respectively: +

+ +
+class base64_binary: public simple_type, public buffer
+{
+public:
+  base64_binary (size_t size = 0);
+  base64_binary (size_t size, size_t capacity);
+  base64_binary (const void* data, size_t size);
+  base64_binary (const void* data, size_t size, size_t capacity);
+  base64_binary (void* data,
+                 size_t size,
+                 size_t capacity,
+                 bool assume_ownership);
+
+public:
+  base64_binary (const base64_binary&);
+
+  base64_binary&
+  operator= (const base64_binary&);
+
+  virtual base64_binary*
+  _clone () const;
+
+public:
+  std::basic_string<C>
+  encode () const;
+};
+  
+ +
+class hex_binary: public simple_type, public buffer
+{
+public:
+  hex_binary (size_t size = 0);
+  hex_binary (size_t size, size_t capacity);
+  hex_binary (const void* data, size_t size);
+  hex_binary (const void* data, size_t size, size_t capacity);
+  hex_binary (void* data,
+              size_t size,
+              size_t capacity,
+              bool assume_ownership);
+
+public:
+  hex_binary (const hex_binary&);
+
+  hex_binary&
+  operator= (const hex_binary&);
+
+  virtual hex_binary*
+  _clone () const;
+
+public:
+  std::basic_string<C>
+  encode () const;
+};
+  
+ + +

2.5.7 Time Zone Representation

+ +

The date, dateTime, gDay, + gMonth, gMonthDay, gYear, + gYearMonth, and time XML Schema built-in + types all include an optional time zone component. The following + xml_schema::time_zone base class is used to represent + this information:

+ +
+class time_zone
+{
+public:
+  time_zone ();
+  time_zone (short hours, short minutes);
+
+  bool
+  zone_present () const;
+
+  void
+  zone_reset ();
+
+  short
+  zone_hours () const;
+
+  void
+  zone_hours (short);
+
+  short
+  zone_minutes () const;
+
+  void
+  zone_minutes (short);
+};
+
+bool
+operator== (const time_zone&, const time_zone&);
+
+bool
+operator!= (const time_zone&, const time_zone&);
+  
+ +

The zone_present() accessor function returns true + if the time zone is specified. The zone_reset() modifier + function resets the time zone object to the not specified + state. If the time zone offset is negative then both hours and + minutes components are represented as negative integers.

+ + +

2.5.8 Mapping for date

+ +

The XML Schema date built-in data type is mapped to the + xml_schema::date C++ class which represents a year, a day, + and a month with an optional time zone. Its interface is presented + below. For more information on the base xml_schema::time_zone + class refer to Section 2.5.7, "Time Zone + Representation".

+ +
+class date: public simple_type, public time_zone
+{
+public:
+  date (int year, unsigned short month, unsigned short day);
+  date (int year, unsigned short month, unsigned short day,
+        short zone_hours, short zone_minutes);
+
+public:
+  date (const date&);
+
+  date&
+  operator= (const date&);
+
+  virtual date*
+  _clone () const;
+
+public:
+  int
+  year () const;
+
+  void
+  year (int);
+
+  unsigned short
+  month () const;
+
+  void
+  month (unsigned short);
+
+  unsigned short
+  day () const;
+
+  void
+  day (unsigned short);
+};
+
+bool
+operator== (const date&, const date&);
+
+bool
+operator!= (const date&, const date&);
+  
+ +

2.5.9 Mapping for dateTime

+ +

The XML Schema dateTime built-in data type is mapped to the + xml_schema::date_time C++ class which represents a year, a month, + a day, hours, minutes, and seconds with an optional time zone. Its interface + is presented below. For more information on the base + xml_schema::time_zone class refer to Section + 2.5.7, "Time Zone Representation".

+ +
+class date_time: public simple_type, public time_zone
+{
+public:
+  date_time (int year, unsigned short month, unsigned short day,
+             unsigned short hours, unsigned short minutes,
+             double seconds);
+
+  date_time (int year, unsigned short month, unsigned short day,
+             unsigned short hours, unsigned short minutes,
+             double seconds, short zone_hours, short zone_minutes);
+public:
+  date_time (const date_time&);
+
+  date_time&
+  operator= (const date_time&);
+
+  virtual date_time*
+  _clone () const;
+
+public:
+  int
+  year () const;
+
+  void
+  year (int);
+
+  unsigned short
+  month () const;
+
+  void
+  month (unsigned short);
+
+  unsigned short
+  day () const;
+
+  void
+  day (unsigned short);
+
+  unsigned short
+  hours () const;
+
+  void
+  hours (unsigned short);
+
+  unsigned short
+  minutes () const;
+
+  void
+  minutes (unsigned short);
+
+  double
+  seconds () const;
+
+  void
+  seconds (double);
+};
+
+bool
+operator== (const date_time&, const date_time&);
+
+bool
+operator!= (const date_time&, const date_time&);
+  
+ + +

2.5.10 Mapping for duration

+ +

The XML Schema duration built-in data type is mapped to the + xml_schema::duration C++ class which represents a potentially + negative duration in the form of years, months, days, hours, minutes, + and seconds. Its interface is presented below.

+ +
+class duration: public simple_type
+{
+public:
+  duration (bool negative,
+            unsigned int years, unsigned int months, unsigned int days,
+            unsigned int hours, unsigned int minutes, double seconds);
+public:
+  duration (const duration&);
+
+  duration&
+  operator= (const duration&);
+
+  virtual duration*
+  _clone () const;
+
+public:
+  bool
+  negative () const;
+
+  void
+  negative (bool);
+
+  unsigned int
+  years () const;
+
+  void
+  years (unsigned int);
+
+  unsigned int
+  months () const;
+
+  void
+  months (unsigned int);
+
+  unsigned int
+  days () const;
+
+  void
+  days (unsigned int);
+
+  unsigned int
+  hours () const;
+
+  void
+  hours (unsigned int);
+
+  unsigned int
+  minutes () const;
+
+  void
+  minutes (unsigned int);
+
+  double
+  seconds () const;
+
+  void
+  seconds (double);
+};
+
+bool
+operator== (const duration&, const duration&);
+
+bool
+operator!= (const duration&, const duration&);
+  
+ + +

2.5.11 Mapping for gDay

+ +

The XML Schema gDay built-in data type is mapped to the + xml_schema::gday C++ class which represents a day of the + month with an optional time zone. Its interface is presented below. + For more information on the base xml_schema::time_zone + class refer to Section 2.5.7, "Time Zone + Representation".

+ +
+class gday: public simple_type, public time_zone
+{
+public:
+  explicit
+  gday (unsigned short day);
+  gday (unsigned short day, short zone_hours, short zone_minutes);
+
+public:
+  gday (const gday&);
+
+  gday&
+  operator= (const gday&);
+
+  virtual gday*
+  _clone () const;
+
+public:
+  unsigned short
+  day () const;
+
+  void
+  day (unsigned short);
+};
+
+bool
+operator== (const gday&, const gday&);
+
+bool
+operator!= (const gday&, const gday&);
+  
+ + +

2.5.12 Mapping for gMonth

+ +

The XML Schema gMonth built-in data type is mapped to the + xml_schema::gmonth C++ class which represents a month of the + year with an optional time zone. Its interface is presented below. + For more information on the base xml_schema::time_zone + class refer to Section 2.5.7, "Time Zone + Representation".

+ +
+class gmonth: public simple_type, public time_zone
+{
+public:
+  explicit
+  gmonth (unsigned short month);
+  gmonth (unsigned short month,
+          short zone_hours, short zone_minutes);
+
+public:
+  gmonth (const gmonth&);
+
+  gmonth&
+  operator= (const gmonth&);
+
+  virtual gmonth*
+  _clone () const;
+
+public:
+  unsigned short
+  month () const;
+
+  void
+  month (unsigned short);
+};
+
+bool
+operator== (const gmonth&, const gmonth&);
+
+bool
+operator!= (const gmonth&, const gmonth&);
+  
+ + +

2.5.13 Mapping for gMonthDay

+ +

The XML Schema gMonthDay built-in data type is mapped to the + xml_schema::gmonth_day C++ class which represents a day and + a month of the year with an optional time zone. Its interface is presented + below. For more information on the base xml_schema::time_zone + class refer to Section 2.5.7, "Time Zone + Representation".

+ +
+class gmonth_day: public simple_type, public time_zone
+{
+public:
+  gmonth_day (unsigned short month, unsigned short day);
+  gmonth_day (unsigned short month, unsigned short day,
+              short zone_hours, short zone_minutes);
+
+public:
+  gmonth_day (const gmonth_day&);
+
+  gmonth_day&
+  operator= (const gmonth_day&);
+
+  virtual gmonth_day*
+  _clone () const;
+
+public:
+  unsigned short
+  month () const;
+
+  void
+  month (unsigned short);
+
+  unsigned short
+  day () const;
+
+  void
+  day (unsigned short);
+};
+
+bool
+operator== (const gmonth_day&, const gmonth_day&);
+
+bool
+operator!= (const gmonth_day&, const gmonth_day&);
+  
+ + +

2.5.14 Mapping for gYear

+ +

The XML Schema gYear built-in data type is mapped to the + xml_schema::gyear C++ class which represents a year with + an optional time zone. Its interface is presented below. For more + information on the base xml_schema::time_zone class refer + to Section 2.5.7, "Time Zone Representation".

+ +
+class gyear: public simple_type, public time_zone
+{
+public:
+  explicit
+  gyear (int year);
+  gyear (int year, short zone_hours, short zone_minutes);
+
+public:
+  gyear (const gyear&);
+
+  gyear&
+  operator= (const gyear&);
+
+  virtual gyear*
+  _clone () const;
+
+public:
+  int
+  year () const;
+
+  void
+  year (int);
+};
+
+bool
+operator== (const gyear&, const gyear&);
+
+bool
+operator!= (const gyear&, const gyear&);
+  
+ + +

2.5.15 Mapping for gYearMonth

+ +

The XML Schema gYearMonth built-in data type is mapped to + the xml_schema::gyear_month C++ class which represents + a year and a month with an optional time zone. Its interface is presented + below. For more information on the base xml_schema::time_zone + class refer to Section 2.5.7, "Time Zone + Representation".

+ +
+class gyear_month: public simple_type, public time_zone
+{
+public:
+  gyear_month (int year, unsigned short month);
+  gyear_month (int year, unsigned short month,
+               short zone_hours, short zone_minutes);
+public:
+  gyear_month (const gyear_month&);
+
+  gyear_month&
+  operator= (const gyear_month&);
+
+  virtual gyear_month*
+  _clone () const;
+
+public:
+  int
+  year () const;
+
+  void
+  year (int);
+
+  unsigned short
+  month () const;
+
+  void
+  month (unsigned short);
+};
+
+bool
+operator== (const gyear_month&, const gyear_month&);
+
+bool
+operator!= (const gyear_month&, const gyear_month&);
+  
+ + +

2.5.16 Mapping for time

+ +

The XML Schema time built-in data type is mapped to + the xml_schema::time C++ class which represents hours, + minutes, and seconds with an optional time zone. Its interface is + presented below. For more information on the base + xml_schema::time_zone class refer to + Section 2.5.7, "Time Zone Representation".

+ +
+class time: public simple_type, public time_zone
+{
+public:
+  time (unsigned short hours, unsigned short minutes, double seconds);
+  time (unsigned short hours, unsigned short minutes, double seconds,
+        short zone_hours, short zone_minutes);
+
+public:
+  time (const time&);
+
+  time&
+  operator= (const time&);
+
+  virtual time*
+  _clone () const;
+
+public:
+  unsigned short
+  hours () const;
+
+  void
+  hours (unsigned short);
+
+  unsigned short
+  minutes () const;
+
+  void
+  minutes (unsigned short);
+
+  double
+  seconds () const;
+
+  void
+  seconds (double);
+};
+
+bool
+operator== (const time&, const time&);
+
+bool
+operator!= (const time&, const time&);
+  
+ + + + +

2.6 Mapping for Simple Types

+ +

An XML Schema simple type is mapped to a C++ class with the same + name as the simple type. The class defines a public copy constructor, + a public copy assignment operator, and a public virtual + _clone function. The _clone function is + declared const, does not take any arguments, and returns + a pointer to a complete copy of the instance allocated in the free + store. The _clone function shall be used to make copies + when static type and dynamic type of the instance may differ (see + Section 2.11, "Mapping for xsi:type + and Substitution Groups"). For instance:

+ +
+<simpleType name="object">
+  ...
+</simpleType>
+  
+ +

is mapped to:

+ +
+class object: ...
+{
+public:
+  object (const object&);
+
+public:
+  object&
+  operator= (const object&);
+
+public:
+  virtual object*
+  _clone () const;
+
+  ...
+
+};
+  
+ +

The base class specification and the rest of the class definition + depend on the type of derivation used to define the simple type.

+ + +

2.6.1 Mapping for Derivation by Restriction

+ +

XML Schema derivation by restriction is mapped to C++ public + inheritance. The base type of the restriction becomes the base + type for the resulting C++ class. In addition to the members described + in Section 2.6, "Mapping for Simple Types", the + resulting C++ class defines a public constructor with the base type + as its single argument. For instance:

+ +
+<simpleType name="object">
+  <restriction base="base">
+    ...
+  </restriction>
+</simpleType>
+  
+ +

is mapped to:

+ +
+class object: public base
+{
+public:
+  object (const base&);
+  object (const object&);
+
+public:
+  object&
+  operator= (const object&);
+
+public:
+  virtual object*
+  _clone () const;
+};
+  
+ + +

2.6.2 Mapping for Enumerations

+ +

XML Schema restriction by enumeration is mapped to a C++ class + with semantics similar to C++ enum. Each XML Schema + enumeration element is mapped to a C++ enumerator with the + name derived from the value attribute and defined + in the class scope. In addition to the members + described in Section 2.6, "Mapping for Simple Types", + the resulting C++ class defines a public constructor that can be called + with one of the enumerators as its single argument, a public constructor + that can be called with enumeration's base value as its single + argument, a public assignment operator that can be used to assign the + value of one of the enumerators, and a public implicit conversion + operator to the underlying C++ enum type.

+ +

Furthermore, for string-based enumeration types, the resulting C++ + class defines a public constructor with a single argument of type + const C* and a public constructor with a single + argument of type const std::basic_string<C>&. + For instance:

+ +
+<simpleType name="color">
+  <restriction base="string">
+    <enumeration value="red"/>
+    <enumeration value="green"/>
+    <enumeration value="blue"/>
+  </restriction>
+</simpleType>
+  
+ +

is mapped to:

+ +
+class color: public xml_schema::string
+{
+public:
+  enum value
+  {
+    red,
+    green,
+    blue
+  };
+
+public:
+  color (value);
+  color (const C*);
+  color (const std::basic_string<C>&);
+  color (const xml_schema::string&);
+  color (const color&);
+
+public:
+  color&
+  operator= (value);
+
+  color&
+  operator= (const color&);
+
+public:
+  virtual color*
+  _clone () const;
+
+public:
+  operator value () const;
+};
+  
+ +

2.6.3 Mapping for Derivation by List

+ +

XML Schema derivation by list is mapped to C++ public + inheritance from xml_schema::simple_type + (Section 2.5.3, "Mapping for + anySimpleType") and a suitable sequence type. + The list item type becomes the element type of the sequence. + In addition to the members described in Section 2.6, + "Mapping for Simple Types", the resulting C++ class defines + a public default constructor, a public constructor + with the first argument of type size_type and + the second argument of list item type that creates + a list object with the specified number of copies of the specified + element value, and a public constructor with the two arguments + of an input iterator type that creates a list object from an + iterator range. For instance: +

+ +
+<simpleType name="int_list">
+  <list itemType="int"/>
+</simpleType>
+  
+ +

is mapped to:

+ +
+class int_list: public simple_type,
+                public sequence<int>
+{
+public:
+  int_list ();
+  int_list (size_type n, int x);
+
+  template <typename I>
+  int_list (const I& begin, const I& end);
+  int_list (const int_list&);
+
+public:
+  int_list&
+  operator= (const int_list&);
+
+public:
+  virtual int_list*
+  _clone () const;
+};
+  
+ +

The sequence class template is defined in an + implementation-specific namespace. It conforms to the + sequence interface as defined by the ISO/ANSI Standard for + C++ (ISO/IEC 14882:1998, Section 23.1.1, "Sequences"). + Practically, this means that you can treat such a sequence + as if it was std::vector. One notable extension + to the standard interface that is available only for + sequences of non-fundamental C++ types is the addition of + the overloaded push_back and insert + member functions which instead of the constant reference + to the element type accept automatic pointer (std::unique_ptr + or std::auto_ptr, depending on the C++ standard + selected) to the element type. These functions assume ownership + of the pointed to object and reset the passed automatic pointer. +

+ +

2.6.4 Mapping for Derivation by Union

+ +

XML Schema derivation by union is mapped to C++ public + inheritance from xml_schema::simple_type + (Section 2.5.3, "Mapping for + anySimpleType") and std::basic_string<C>. + In addition to the members described in Section 2.6, + "Mapping for Simple Types", the resulting C++ class defines a + public constructor with a single argument of type const C* + and a public constructor with a single argument of type + const std::basic_string<C>&. For instance: +

+ +
+<simpleType name="int_string_union">
+  <xsd:union memberTypes="xsd:int xsd:string"/>
+</simpleType>
+  
+ +

is mapped to:

+ +
+class int_string_union: public simple_type,
+                        public std::basic_string<C>
+{
+public:
+  int_string_union (const C*);
+  int_string_union (const std::basic_string<C>&);
+  int_string_union (const int_string_union&);
+
+public:
+  int_string_union&
+  operator= (const int_string_union&);
+
+public:
+  virtual int_string_union*
+  _clone () const;
+};
+  
+ +

2.7 Mapping for Complex Types

+ +

An XML Schema complex type is mapped to a C++ class with the same + name as the complex type. The class defines a public copy constructor, + a public copy assignment operator, and a public virtual + _clone function. The _clone function is + declared const, does not take any arguments, and returns + a pointer to a complete copy of the instance allocated in the free + store. The _clone function shall be used to make copies + when static type and dynamic type of the instance may differ (see + Section 2.11, "Mapping for xsi:type + and Substitution Groups").

+ +

Additionally, the resulting C++ class + defines two public constructors that take an initializer for each + member of the complex type and all its base types that belongs to + the One cardinality class (see Section 2.8, "Mapping + for Local Elements and Attributes"). In the first constructor, + the arguments are passed as constant references and the newly created + instance is initialized with copies of the passed objects. In the + second constructor, arguments that are complex types (that is, + they themselves contain elements or attributes) are passed as + either std::unique_ptr (C++11) or std::auto_ptr + (C++98), depending on the C++ standard selected. In this case the newly + created instance is directly initialized with and assumes ownership + of the pointed to objects and the std::[unique|auto]_ptr + arguments are reset to 0. For instance:

+ +
+<complexType name="complex">
+  <sequence>
+    <element name="a" type="int"/>
+    <element name="b" type="string"/>
+  </sequence>
+</complexType>
+
+<complexType name="object">
+  <sequence>
+    <element name="s-one" type="boolean"/>
+    <element name="c-one" type="complex"/>
+    <element name="optional" type="int" minOccurs="0"/>
+    <element name="sequence" type="string" maxOccurs="unbounded"/>
+  </sequence>
+</complexType>
+  
+ +

is mapped to:

+ +
+class complex: public xml_schema::type
+{
+public:
+  object (const int& a, const xml_schema::string& b);
+  object (const complex&);
+
+public:
+  object&
+  operator= (const complex&);
+
+public:
+  virtual complex*
+  _clone () const;
+
+  ...
+
+};
+
+class object: public xml_schema::type
+{
+public:
+  object (const bool& s_one, const complex& c_one);
+  object (const bool& s_one, std::[unique|auto]_ptr<complex> c_one);
+  object (const object&);
+
+public:
+  object&
+  operator= (const object&);
+
+public:
+  virtual object*
+  _clone () const;
+
+  ...
+
+};
+  
+ +

Notice that the generated complex class does not + have the second (std::[unique|auto]_ptr) version of the + constructor since all its required members are of simple types.

+ +

If an XML Schema complex type has an ultimate base which is an XML + Schema simple type then the resulting C++ class also defines a public + constructor that takes an initializer for the base type as well as + for each member of the complex type and all its base types that + belongs to the One cardinality class. For instance:

+ +
+<complexType name="object">
+  <simpleContent>
+    <extension base="date">
+      <attribute name="lang" type="language" use="required"/>
+    </extension>
+  </simpleContent>
+</complexType>
+  
+ +

is mapped to:

+ +
+class object: public xml_schema::string
+{
+public:
+  object (const xml_schema::language& lang);
+
+  object (const xml_schema::date& base,
+          const xml_schema::language& lang);
+
+  ...
+
+};
+  
+ +

Furthermore, for string-based XML Schema complex types, the resulting C++ + class also defines two public constructors with the first arguments + of type const C* and std::basic_string<C>&, + respectively, followed by arguments for each member of the complex + type and all its base types that belongs to the One cardinality + class. For enumeration-based complex types the resulting C++ + class also defines a public constructor with the first arguments + of the underlying enum type followed by arguments for each member + of the complex type and all its base types that belongs to the One + cardinality class. For instance:

+ +
+<simpleType name="color">
+  <restriction base="string">
+    <enumeration value="red"/>
+    <enumeration value="green"/>
+    <enumeration value="blue"/>
+  </restriction>
+</simpleType>
+
+<complexType name="object">
+  <simpleContent>
+    <extension base="color">
+      <attribute name="lang" type="language" use="required"/>
+    </extension>
+  </simpleContent>
+</complexType>
+  
+ +

is mapped to:

+ +
+class color: public xml_schema::string
+{
+public:
+  enum value
+  {
+    red,
+    green,
+    blue
+  };
+
+public:
+  color (value);
+  color (const C*);
+  color (const std::basic_string<C>&);
+
+  ...
+
+};
+
+class object: color
+{
+public:
+  object (const color& base,
+          const xml_schema::language& lang);
+
+  object (const color::value& base,
+          const xml_schema::language& lang);
+
+  object (const C* base,
+          const xml_schema::language& lang);
+
+  object (const std::basic_string<C>& base,
+          const xml_schema::language& lang);
+
+  ...
+
+};
+  
+ +

Additional constructors can be requested with the + --generate-default-ctor and + --generate-from-base-ctor options. See the + XSD + Compiler Command Line Manual for details.

+ +

If an XML Schema complex type is not explicitly derived from any type, + the resulting C++ class is derived from xml_schema::type. + In cases where an XML Schema complex type is defined using derivation + by extension or restriction, the resulting C++ base class specification + depends on the type of derivation and is described in the subsequent + sections. +

+ +

The mapping for elements and attributes that are defined in a complex + type is described in Section 2.8, "Mapping for Local + Elements and Attributes". +

+ +

2.7.1 Mapping for Derivation by Extension

+ +

XML Schema derivation by extension is mapped to C++ public + inheritance. The base type of the extension becomes the base + type for the resulting C++ class. +

+ +

2.7.2 Mapping for Derivation by Restriction

+ +

XML Schema derivation by restriction is mapped to C++ public + inheritance. The base type of the restriction becomes the base + type for the resulting C++ class. XML Schema elements and + attributes defined within restriction do not result in any + definitions in the resulting C++ class. Instead, corresponding + (unrestricted) definitions are inherited from the base class. + In the future versions of this mapping, such elements and + attributes may result in redefinitions of accessors and + modifiers to reflect their restricted semantics. +

+ + + +

2.8 Mapping for Local Elements and Attributes

+ +

XML Schema element and attribute definitions are called local + if they appear within a complex type definition, an element group + definition, or an attribute group definitions. +

+ +

Local XML Schema element and attribute definitions have the same + C++ mapping. Therefore, in this section, local elements and + attributes are collectively called members. +

+ +

While there are many different member cardinality combinations + (determined by the use attribute for attributes and + the minOccurs and maxOccurs attributes + for elements), the mapping divides all possible cardinality + combinations into three cardinality classes: +

+ +
+
one
+
attributes: use == "required"
+
attributes: use == "optional" and has default or fixed value
+
elements: minOccurs == "1" and maxOccurs == "1"
+ +
optional
+
attributes: use == "optional" and doesn't have default or fixed value
+
elements: minOccurs == "0" and maxOccurs == "1"
+ +
sequence
+
elements: maxOccurs > "1"
+
+ +

An optional attribute with a default or fixed value acquires this value + if the attribute hasn't been specified in an instance document (see + Appendix A, "Default and Fixed Values"). This + mapping places such optional attributes to the One cardinality + class.

+ +

A member is mapped to a set of public type definitions + (typedefs) and a set of public accessor and modifier + functions. Type definitions have names derived from the member's + name. The accessor and modifier functions have the same name as the + member. For example: +

+ +
+<complexType name="object">
+  <sequence>
+    <element name="member" type="string"/>
+  </sequence>
+</complexType>
+  
+ +

is mapped to:

+ +
+class object: public xml_schema::type
+{
+public:
+  typedef xml_schema::string member_type;
+
+  const member_type&
+  member () const;
+
+  ...
+
+};
+  
+ +

In addition, if a member has a default or fixed value, a static + accessor function is generated that returns this value. For + example:

+ +
+<complexType name="object">
+  <attribute name="data" type="string" default="test"/>
+</complexType>
+  
+ +

is mapped to:

+ +
+class object: public xml_schema::type
+{
+public:
+  typedef xml_schema::string data_type;
+
+  const data_type&
+  data () const;
+
+  static const data_type&
+  data_default_value ();
+
+  ...
+
+};
+  
+ +

Names and semantics of type definitions for the member as well + as signatures of the accessor and modifier functions depend on + the member's cardinality class and are described in the following + sub-sections. +

+ + +

2.8.1 Mapping for Members with the One Cardinality Class

+ +

For the One cardinality class, the type definitions consist of + an alias for the member's type with the name created by appending + the _type suffix to the member's name. +

+ +

The accessor functions come in constant and non-constant versions. + The constant accessor function returns a constant reference to the + member and can be used for read-only access. The non-constant + version returns an unrestricted reference to the member and can + be used for read-write access. +

+ +

The first modifier function expects an argument of type reference to + constant of the member's type. It makes a deep copy of its argument. + Except for member's types that are mapped to fundamental C++ types, + the second modifier function is provided that expects an argument + of type automatic pointer (std::unique_ptr or + std::auto_ptr, depending on the C++ standard selected) + to the member's type. It assumes ownership of the pointed to object + and resets the passed automatic pointer. For instance:

+ +
+<complexType name="object">
+  <sequence>
+    <element name="member" type="string"/>
+  </sequence>
+</complexType>
+  
+ +

is mapped to:

+ +
+class object: public xml_schema::type
+{
+public:
+  // Type definitions.
+  //
+  typedef xml_schema::string member_type;
+
+  // Accessors.
+  //
+  const member_type&
+  member () const;
+
+  member_type&
+  member ();
+
+  // Modifiers.
+  //
+  void
+  member (const member_type&);
+
+  void
+  member (std::[unique|auto]_ptr<member_type>);
+  ...
+
+};
+  
+ +

In addition, if requested by specifying the --generate-detach + option and only for members of non-fundamental C++ types, the mapping + provides a detach function that returns an automatic pointer to the + member's type, for example:

+ +
+class object: public xml_schema::type
+{
+public:
+  ...
+
+  std::[unique|auto]_ptr<member_type>
+  detach_member ();
+  ...
+
+};
+  
+ +

This function detaches the value from the tree leaving the member + value uninitialized. Accessing such an uninitialized value prior to + re-initializing it results in undefined behavior.

+ +

The following code shows how one could use this mapping:

+ +
+void
+f (object& o)
+{
+  using xml_schema::string;
+
+  string s (o.member ());                // get
+  object::member_type& sr (o.member ()); // get
+
+  o.member ("hello");           // set, deep copy
+  o.member () = "hello";        // set, deep copy
+
+  // C++11 version.
+  //
+  std::unique_ptr<string> p (new string ("hello"));
+  o.member (std::move (p));     // set, assumes ownership
+  p = o.detach_member ();       // detach, member is uninitialized
+  o.member (std::move (p));     // re-attach
+
+  // C++98 version.
+  //
+  std::auto_ptr<string> p (new string ("hello"));
+  o.member (p);                 // set, assumes ownership
+  p = o.detach_member ();       // detach, member is uninitialized
+  o.member (p);                 // re-attach
+}
+  
+ + +

2.8.2 Mapping for Members with the Optional Cardinality Class

+ +

For the Optional cardinality class, the type definitions consist of + an alias for the member's type with the name created by appending + the _type suffix to the member's name and an alias for + the container type with the name created by appending the + _optional suffix to the member's name. +

+ +

Unlike accessor functions for the One cardinality class, accessor + functions for the Optional cardinality class return references to + corresponding containers rather than directly to members. The + accessor functions come in constant and non-constant versions. + The constant accessor function returns a constant reference to + the container and can be used for read-only access. The non-constant + version returns an unrestricted reference to the container + and can be used for read-write access. +

+ +

The modifier functions are overloaded for the member's + type and the container type. The first modifier function + expects an argument of type reference to constant of the + member's type. It makes a deep copy of its argument. + Except for member's types that are mapped to fundamental C++ types, + the second modifier function is provided that expects an argument + of type automatic pointer (std::unique_ptr or + std::auto_ptr, depending on the C++ standard selected) + to the member's type. It assumes ownership of the pointed to object + and resets the passed automatic pointer. The last modifier function + expects an argument of type reference to constant of the container + type. It makes a deep copy of its argument. For instance: +

+ +
+<complexType name="object">
+  <sequence>
+    <element name="member" type="string" minOccurs="0"/>
+  </sequence>
+</complexType>
+  
+ +

is mapped to:

+ +
+class object: public xml_schema::type
+{
+public:
+  // Type definitions.
+  //
+  typedef xml_schema::string member_type;
+  typedef optional<member_type> member_optional;
+
+  // Accessors.
+  //
+  const member_optional&
+  member () const;
+
+  member_optional&
+  member ();
+
+  // Modifiers.
+  //
+  void
+  member (const member_type&);
+
+  void
+  member (std::[unique|auto]_ptr<member_type>);
+
+  void
+  member (const member_optional&);
+
+  ...
+
+};
+  
+ + +

The optional class template is defined in an + implementation-specific namespace and has the following + interface. The [unique|auto]_ptr-based constructor + and modifier function are only available if the template + argument is not a fundamental C++ type. +

+ +
+template <typename X>
+class optional
+{
+public:
+  optional ();
+
+  // Makes a deep copy.
+  //
+  explicit
+  optional (const X&);
+
+  // Assumes ownership.
+  //
+  explicit
+  optional (std::[unique|auto]_ptr<X>);
+
+  optional (const optional&);
+
+public:
+  optional&
+  operator= (const X&);
+
+  optional&
+  operator= (const optional&);
+
+  // Pointer-like interface.
+  //
+public:
+  const X*
+  operator-> () const;
+
+  X*
+  operator-> ();
+
+  const X&
+  operator* () const;
+
+  X&
+  operator* ();
+
+  typedef void (optional::*bool_convertible) ();
+  operator bool_convertible () const;
+
+  // Get/set interface.
+  //
+public:
+  bool
+  present () const;
+
+  const X&
+  get () const;
+
+  X&
+  get ();
+
+  // Makes a deep copy.
+  //
+  void
+  set (const X&);
+
+  // Assumes ownership.
+  //
+  void
+  set (std::[unique|auto]_ptr<X>);
+
+  // Detach and return the contained value.
+  //
+  std::[unique|auto]_ptr<X>
+  detach ();
+
+  void
+  reset ();
+};
+
+template <typename X>
+bool
+operator== (const optional<X>&, const optional<X>&);
+
+template <typename X>
+bool
+operator!= (const optional<X>&, const optional<X>&);
+
+template <typename X>
+bool
+operator< (const optional<X>&, const optional<X>&);
+
+template <typename X>
+bool
+operator> (const optional<X>&, const optional<X>&);
+
+template <typename X>
+bool
+operator<= (const optional<X>&, const optional<X>&);
+
+template <typename X>
+bool
+operator>= (const optional<X>&, const optional<X>&);
+  
+ + +

The following code shows how one could use this mapping:

+ +
+void
+f (object& o)
+{
+  using xml_schema::string;
+
+  if (o.member ().present ())       // test
+  {
+    string& s (o.member ().get ()); // get
+    o.member ("hello");             // set, deep copy
+    o.member ().set ("hello");      // set, deep copy
+    o.member ().reset ();           // reset
+  }
+
+  // Same as above but using pointer notation:
+  //
+  if (o.member ())                  // test
+  {
+    string& s (*o.member ());       // get
+    o.member ("hello");             // set, deep copy
+    *o.member () = "hello";         // set, deep copy
+    o.member ().reset ();           // reset
+  }
+
+  // C++11 version.
+  //
+  std::unique_ptr<string> p (new string ("hello"));
+  o.member (std::move (p));         // set, assumes ownership
+
+  p.reset (new string ("hello"));
+  o.member ().set (std::move (p));  // set, assumes ownership
+
+  p = o.member ().detach ();        // detach, member is reset
+  o.member ().set (std::move (p));  // re-attach
+
+  // C++98 version.
+  //
+  std::auto_ptr<string> p (new string ("hello"));
+  o.member (p);                     // set, assumes ownership
+
+  p = new string ("hello");
+  o.member ().set (p);              // set, assumes ownership
+
+  p = o.member ().detach ();        // detach, member is reset
+  o.member ().set (p);              // re-attach
+}
+  
+ + +

2.8.3 Mapping for Members with the Sequence Cardinality Class

+ +

For the Sequence cardinality class, the type definitions consist of an + alias for the member's type with the name created by appending + the _type suffix to the member's name, an alias of + the container type with the name created by appending the + _sequence suffix to the member's name, an alias of + the iterator type with the name created by appending the + _iterator suffix to the member's name, and an alias + of the constant iterator type with the name created by appending the + _const_iterator suffix to the member's name. +

+ +

The accessor functions come in constant and non-constant versions. + The constant accessor function returns a constant reference to the + container and can be used for read-only access. The non-constant + version returns an unrestricted reference to the container and can + be used for read-write access. +

+ +

The modifier function expects an argument of type reference to + constant of the container type. The modifier function + makes a deep copy of its argument. For instance: +

+ + +
+<complexType name="object">
+  <sequence>
+    <element name="member" type="string" minOccurs="unbounded"/>
+  </sequence>
+</complexType>
+  
+ +

is mapped to:

+ +
+class object: public xml_schema::type
+{
+public:
+  // Type definitions.
+  //
+  typedef xml_schema::string member_type;
+  typedef sequence<member_type> member_sequence;
+  typedef member_sequence::iterator member_iterator;
+  typedef member_sequence::const_iterator member_const_iterator;
+
+  // Accessors.
+  //
+  const member_sequence&
+  member () const;
+
+  member_sequence&
+  member ();
+
+  // Modifier.
+  //
+  void
+  member (const member_sequence&);
+
+  ...
+
+};
+  
+ +

The sequence class template is defined in an + implementation-specific namespace. It conforms to the + sequence interface as defined by the ISO/ANSI Standard for + C++ (ISO/IEC 14882:1998, Section 23.1.1, "Sequences"). + Practically, this means that you can treat such a sequence + as if it was std::vector. Two notable extensions + to the standard interface that are available only for + sequences of non-fundamental C++ types are the addition of + the overloaded push_back and insert + as well as the detach_back and detach + member functions. The additional push_back and + insert functions accept an automatic pointer + (std::unique_ptr or std::auto_ptr, + depending on the C++ standard selected) to the + element type instead of the constant reference. They assume + ownership of the pointed to object and reset the passed + automatic pointer. The detach_back and + detach functions detach the element + value from the sequence container and, by default, remove + the element from the sequence. These additional functions + have the following signatures:

+ +
+template <typename X>
+class sequence
+{
+public:
+  ...
+
+  void
+  push_back (std::[unique|auto]_ptr<X>)
+
+  iterator
+  insert (iterator position, std::[unique|auto]_ptr<X>)
+
+  std::[unique|auto]_ptr<X>
+  detach_back (bool pop = true);
+
+  iterator
+  detach (iterator position,
+          std::[unique|auto]_ptr<X>& result,
+          bool erase = true)
+
+  ...
+}
+  
+ +

The following code shows how one could use this mapping:

+ +
+void
+f (object& o)
+{
+  using xml_schema::string;
+
+  object::member_sequence& s (o.member ());
+
+  // Iteration.
+  //
+  for (object::member_iterator i (s.begin ()); i != s.end (); ++i)
+  {
+    string& value (*i);
+  }
+
+  // Modification.
+  //
+  s.push_back ("hello");  // deep copy
+
+  // C++11 version.
+  //
+  std::unique_ptr<string> p (new string ("hello"));
+  s.push_back (std::move (p)); // assumes ownership
+  p = s.detach_back ();        // detach and pop
+  s.push_back (std::move (p)); // re-append
+
+  // C++98 version.
+  //
+  std::auto_ptr<string> p (new string ("hello"));
+  s.push_back (p);        // assumes ownership
+  p = s.detach_back ();   // detach and pop
+  s.push_back (p);        // re-append
+
+  // Setting a new container.
+  //
+  object::member_sequence n;
+  n.push_back ("one");
+  n.push_back ("two");
+  o.member (n);           // deep copy
+}
+  
+ +

2.8.4 Element Order

+ +

C++/Tree is a "flattening" mapping in a sense that many levels of + nested compositors (choice and sequence), + all potentially with their own cardinalities, are in the end mapped + to a flat set of elements with one of the three cardinality classes + discussed in the previous sections. While this results in a simple + and easy to use API for most types, in certain cases, the order of + elements in the actual XML documents is not preserved once parsed + into the object model. And sometimes such order has + application-specific significance. As an example, consider a schema + that defines a batch of bank transactions:

+ +
+<complexType name="withdraw">
+  <sequence>
+    <element name="account" type="unsignedInt"/>
+    <element name="amount" type="unsignedInt"/>
+  </sequence>
+</complexType>
+
+<complexType name="deposit">
+  <sequence>
+    <element name="account" type="unsignedInt"/>
+    <element name="amount" type="unsignedInt"/>
+  </sequence>
+</complexType>
+
+<complexType name="batch">
+  <choice minOccurs="0" maxOccurs="unbounded">
+    <element name="withdraw" type="withdraw"/>
+    <element name="deposit" type="deposit"/>
+  </choice>
+</complexType>
+  
+ +

The batch can contain any number of transactions in any order + but the order of transactions in each actual batch is significant. + For instance, consider what could happen if we reorder the + transactions and apply all the withdrawals before deposits.

+ +

For the batch schema type defined above the default + C++/Tree mapping will produce a C++ class that contains a pair of + sequence containers, one for each of the two elements. While this + will capture the content (transactions), the order of this content + as it appears in XML will be lost. Also, if we try to serialize the + batch we just loaded back to XML, all the withdrawal transactions + will appear before deposits.

+ +

To overcome this limitation of a flattening mapping, C++/Tree + allows us to mark certain XML Schema types, for which content + order is important, as ordered.

+ +

There are several command line options that control which + schema types are treated as ordered. To make an individual + type ordered, we use the --ordered-type option, + for example:

+ +
+--ordered-type batch
+  
+ +

To automatically treat all the types that are derived from an ordered + type also ordered, we use the --ordered-type-derived + option. This is primarily useful if you would like to iterate + over the complete hierarchy's content using the content order + sequence (discussed below).

+ +

Ordered types are also useful for handling mixed content. To + automatically mark all the types with mixed content as ordered + we use the --ordered-type-mixed option. For more + information on handling mixed content see Section + 2.13, "Mapping for Mixed Content Models".

+ +

Finally, we can mark all the types in the schema we are + compiling with the --ordered-type-all option. + You should only resort to this option if all the types in + your schema truly suffer from the loss of content + order since, as we will discuss shortly, ordered types + require extra effort to access and, especially, modify. + See the + XSD + Compiler Command Line Manual for more information on + these options.

+ +

Once a type is marked ordered, C++/Tree alters its mapping + in several ways. Firstly, for each local element, element + wildcard (Section 2.12.4, "Element Wildcard + Order"), and mixed content text (Section + 2.13, "Mapping for Mixed Content Models") in this type, a + content id constant is generated. Secondly, an addition sequence + is added to the class that captures the content order. Here + is how the mapping of our batch class changes + once we make it ordered:

+ +
+class batch: public xml_schema::type
+{
+public:
+  // withdraw
+  //
+  typedef withdraw withdraw_type;
+  typedef sequence<withdraw_type> withdraw_sequence;
+  typedef withdraw_sequence::iterator withdraw_iterator;
+  typedef withdraw_sequence::const_iterator withdraw_const_iterator;
+
+  static const std::size_t withdraw_id = 1;
+
+  const withdraw_sequence&
+  withdraw () const;
+
+  withdraw_sequence&
+  withdraw ();
+
+  void
+  withdraw (const withdraw_sequence&);
+
+  // deposit
+  //
+  typedef deposit deposit_type;
+  typedef sequence<deposit_type> deposit_sequence;
+  typedef deposit_sequence::iterator deposit_iterator;
+  typedef deposit_sequence::const_iterator deposit_const_iterator;
+
+  static const std::size_t deposit_id = 2;
+
+  const deposit_sequence&
+  deposit () const;
+
+  deposit_sequence&
+  deposit ();
+
+  void
+  deposit (const deposit_sequence&);
+
+  // content_order
+  //
+  typedef xml_schema::content_order content_order_type;
+  typedef std::vector<content_order_type> content_order_sequence;
+  typedef content_order_sequence::iterator content_order_iterator;
+  typedef content_order_sequence::const_iterator content_order_const_iterator;
+
+  const content_order_sequence&
+  content_order () const;
+
+  content_order_sequence&
+  content_order ();
+
+  void
+  content_order (const content_order_sequence&);
+
+  ...
+};
+  
+ +

Notice the withdraw_id and deposit_id + content ids as well as the extra content_order + sequence that does not correspond to any element in the + schema definition. The other changes to the mapping for ordered + types has to do with XML parsing and serialization code. During + parsing the content order is captured in the content_order + sequence while during serialization this sequence is used to + determine the order in which content is serialized. The + content_order sequence is also copied during + copy construction and assigned during copy assignment. It is also + taken into account during comparison.

+ +

The entry type of the content_order sequence is the + xml_schema::content_order type that has the following + interface:

+ +
+namespace xml_schema
+{
+  struct content_order
+  {
+    content_order (std::size_t id, std::size_t index = 0);
+
+    std::size_t id;
+    std::size_t index;
+  };
+
+  bool
+  operator== (const content_order&, const content_order&);
+
+  bool
+  operator!= (const content_order&, const content_order&);
+
+  bool
+  operator< (const content_order&, const content_order&);
+}
+  
+ +

The content_order sequence describes the order of + content (elements, including wildcards, as well as mixed content + text). Each entry in this sequence consists of the content id + (for example, withdraw_id or deposit_id + in our case) as well as, for elements of the sequence cardinality + class, an index into the corresponding sequence container (the + index is unused for the one and optional cardinality classes). + For example, in our case, if the content id is withdraw_id, + then the index will point into the withdraw element + sequence.

+ +

With all this information we can now examine how to iterate over + transaction in the batch in content order:

+ +
+batch& b = ...
+
+for (batch::content_order_const_iterator i (b.content_order ().begin ());
+     i != b.content_order ().end ();
+     ++i)
+{
+  switch (i->id)
+  {
+  case batch::withdraw_id:
+    {
+      const withdraw& t (b.withdraw ()[i->index]);
+      cerr << t.account () << " withdraw " << t.amount () << endl;
+      break;
+    }
+  case batch::deposit_id:
+    {
+      const deposit& t (b.deposit ()[i->index]);
+      cerr << t.account () << " deposit " << t.amount () << endl;
+      break;
+    }
+  default:
+    {
+      assert (false); // Unknown content id.
+    }
+  }
+}
+  
+ +

If we serialized our batch back to XML, we would also see that the + order of transactions in the output is exactly the same as in the + input rather than all the withdrawals first followed by all the + deposits.

+ +

The most complex aspect of working with ordered types is + modifications. Now we not only need to change the content, + but also remember to update the order information corresponding + to this change. As a first example, we add a deposit transaction + to the batch:

+ +
+using xml_schema::content_order;
+
+batch::deposit_sequence& d (b.deposit ());
+batch::withdraw_sequence& w (b.withdraw ());
+batch::content_order_sequence& co (b.content_order ());
+
+d.push_back (deposit (123456789, 100000));
+co.push_back (content_order (batch::deposit_id, d.size () - 1));
+  
+ +

In the above example we first added the content (deposit + transaction) and then updated the content order information + by adding an entry with deposit_id content + id and the index of the just added deposit transaction.

+ +

Removing the last transaction can be easy if we know which + transaction (deposit or withdrawal) is last:

+ +
+d.pop_back ();
+co.pop_back ();
+  
+ +

If, however, we do not know which transaction is last, then + things get a bit more complicated:

+ +
+switch (co.back ().id)
+{
+case batch::withdraw_id:
+  {
+    d.pop_back ();
+    break;
+  }
+case batch::deposit_id:
+  {
+    w.pop_back ();
+    break;
+  }
+}
+
+co.pop_back ();
+  
+ +

The following example shows how to add a transaction at the + beginning of the batch:

+ +
+w.push_back (withdraw (123456789, 100000));
+co.insert (co.begin (),
+           content_order (batch::withdraw_id, w.size () - 1));
+  
+ +

Note also that when we merely modify the content of one + of the elements in place, we do not need to update its + order since it doesn't change. For example, here is how + we can change the amount in the first withdrawal:

+ +
+w[0].amount (10000);
+  
+ +

For the complete working code shown in this section refer to the + order/element example in the + cxx/tree/ directory in the + xsd-examples + package.

+ +

If both the base and derived types are ordered, then the + content order sequence is only added to the base and the content + ids are unique within the whole hierarchy. In this case + the content order sequence for the derived type contains + ordering information for both base and derived content.

+ +

In some applications we may need to perform more complex + content processing. For example, in our case, we may need + to remove all the withdrawal transactions. The default + container, std::vector, is not particularly + suitable for such operations. What may be required by + some applications is a multi-index container that not + only allows us to iterate in content order similar to + std::vector but also search by the content + id as well as the content id and index pair.

+ +

While C++/Tree does not provide this functionality by + default, it allows us to specify a custom container + type for content order with the --order-container + command line option. The only requirement from the + generated code side for such a container is to provide + the vector-like push_back(), + size(), and const iteration interfaces.

+ +

As an example, here is how we can use the Boost Multi-Index + container for content order. First we create the + content-order-container.hxx header with the + following definition:

+ +
+#ifndef CONTENT_ORDER_CONTAINER
+#define CONTENT_ORDER_CONTAINER
+
+#include <cstddef> // std::size_t
+
+#include <boost/multi_index_container.hpp>
+#include <boost/multi_index/member.hpp>
+#include <boost/multi_index/identity.hpp>
+#include <boost/multi_index/ordered_index.hpp>
+#include <boost/multi_index/random_access_index.hpp>
+
+struct by_id {};
+struct by_id_index {};
+
+template <typename T>
+using content_order_container =
+  boost::multi_index::multi_index_container<
+    T,
+    boost::multi_index::indexed_by<
+      boost::multi_index::random_access<>,
+      boost::multi_index::ordered_unique<
+        boost::multi_index::tag<by_id_index>,
+        boost::multi_index::identity<T>
+      >,
+      boost::multi_index::ordered_non_unique<
+        boost::multi_index::tag<by_id>,
+        boost::multi_index::member<T, std::size_t, &T::id>
+      >
+    >
+  >;
+
+#endif
+  
+ +

Next we add the following two XSD compiler options to include + this header into every generated header file and to use the + custom container type (see the XSD compiler command line manual + for more information on shell quoting for the first option):

+ +
+--hxx-prologue '#include "content-order-container.hxx"'
+--order-container content_order_container
+  
+ +

With these changes we can now use the multi-index functionality, + for example, to search for a specific content id:

+ +
+typedef batch::content_order_sequence::index<by_id>::type id_set;
+typedef id_set::iterator id_iterator;
+
+const id_set& ids (b.content_order ().get<by_id> ());
+
+std::pair<id_iterator, id_iterator> r (
+  ids.equal_range (std::size_t (batch::deposit_id));
+
+for (id_iterator i (r.first); i != r.second; ++i)
+{
+  const deposit& t (b.deposit ()[i->index]);
+  cerr << t.account () << " deposit " << t.amount () << endl;
+}
+  
+ +

2.9 Mapping for Global Elements

+ +

An XML Schema element definition is called global if it appears + directly under the schema element. + A global element is a valid root of an instance document. By + default, a global element is mapped to a set of overloaded + parsing and, optionally, serialization functions with the + same name as the element. It is also possible to generate types + for root elements instead of parsing and serialization functions. + This is primarily useful to distinguish object models with the + same root type but with different root elements. See + Section 2.9.1, "Element Types" for details. + It is also possible to request the generation of an element map + which allows uniform parsing and serialization of multiple root + elements. See Section 2.9.2, "Element Map" + for details. +

+ +

The parsing functions read XML instance documents and return + corresponding object models as an automatic pointer + (std::unique_ptr or std::auto_ptr, + depending on the C++ standard selected). Their signatures + have the following pattern (type denotes + element's type and name denotes element's + name): +

+ +
+std::[unique|auto]_ptr<type>
+name (....);
+  
+ +

The process of parsing, including the exact signatures of the parsing + functions, is the subject of Chapter 3, "Parsing". +

+ +

The serialization functions write object models back to XML instance + documents. Their signatures have the following pattern: +

+ +
+void
+name (<stream type>&, const type&, ....);
+  
+ +

The process of serialization, including the exact signatures of the + serialization functions, is the subject of Chapter 4, + "Serialization". +

+ + +

2.9.1 Element Types

+ +

The generation of element types is requested with the + --generate-element-type option. With this option + each global element is mapped to a C++ class with the + same name as the element. Such a class is derived from + xml_schema::element_type and contains the same set + of type definitions, constructors, and member function as would a + type containing a single element with the One cardinality class + named "value". In addition, the element type also + contains a set of member functions for accessing the element + name and namespace as well as its value in a uniform manner. + For example:

+ +
+<complexType name="type">
+  <sequence>
+    ...
+  </sequence>
+</complexType>
+
+<element name="root" type="type"/>
+  
+ +

is mapped to:

+ +
+class type
+{
+  ...
+};
+
+class root: public xml_schema::element_type
+{
+public:
+  // Element value.
+  //
+  typedef type value_type;
+
+  const value_type&
+  value () const;
+
+  value_type&
+  value ();
+
+  void
+  value (const value_type&);
+
+  void
+  value (std::[unique|auto]_ptr<value_type>);
+
+  // Constructors.
+  //
+  root (const value_type&);
+
+  root (std::[unique|auto]_ptr<value_type>);
+
+  root (const xercesc::DOMElement&, xml_schema::flags = 0);
+
+  root (const root&, xml_schema::flags = 0);
+
+  virtual root*
+  _clone (xml_schema::flags = 0) const;
+
+  // Element name and namespace.
+  //
+  static const std::string&
+  name ();
+
+  static const std::string&
+  namespace_ ();
+
+  virtual const std::string&
+  _name () const;
+
+  virtual const std::string&
+  _namespace () const;
+
+  // Element value as xml_schema::type.
+  //
+  virtual const xml_schema::type*
+  _value () const;
+
+  virtual xml_schema::type*
+  _value ();
+};
+
+void
+operator<< (xercesc::DOMElement&, const root&);
+  
+ +

The xml_schema::element_type class is a common + base type for all element types and is defined as follows:

+ +
+namespace xml_schema
+{
+  class element_type
+  {
+  public:
+    virtual
+    ~element_type ();
+
+    virtual element_type*
+    _clone (flags f = 0) const = 0;
+
+    virtual const std::basic_string<C>&
+    _name () const = 0;
+
+    virtual const std::basic_string<C>&
+    _namespace () const = 0;
+
+    virtual xml_schema::type*
+    _value () = 0;
+
+    virtual const xml_schema::type*
+    _value () const = 0;
+  };
+}
+  
+ +

The _value() member function returns a pointer to + the element value or 0 if the element is of a fundamental C++ + type and therefore is not derived from xml_schema::type. +

+ +

Unlike parsing and serialization functions, element types + are only capable of parsing and serializing from/to a + DOMElement object. This means that the application + will need to perform its own XML-to-DOM parsing and DOM-to-XML + serialization. The following section describes a mechanism + provided by the mapping to uniformly parse and serialize + multiple root elements.

+ + +

2.9.2 Element Map

+ +

When element types are generated for root elements it is also + possible to request the generation of an element map with the + --generate-element-map option. The element map + allows uniform parsing and serialization of multiple root + elements via the common xml_schema::element_type + base type. The xml_schema::element_map class is + defined as follows:

+ +
+namespace xml_schema
+{
+  class element_map
+  {
+  public:
+    static std::[unique|auto]_ptr<xml_schema::element_type>
+    parse (const xercesc::DOMElement&, flags = 0);
+
+    static void
+    serialize (xercesc::DOMElement&, const element_type&);
+  };
+}
+  
+ +

The parse() function creates the corresponding + element type object based on the element name and namespace + and returns it as an automatic pointer (std::unique_ptr + or std::auto_ptr, depending on the C++ standard + selected) to xml_schema::element_type. + The serialize() function serializes the passed element + object to DOMElement. Note that in case of + serialize(), the DOMElement object + should have the correct name and namespace. If no element type is + available for an element, both functions throw the + xml_schema::no_element_info exception:

+ +
+struct no_element_info: virtual exception
+{
+  no_element_info (const std::basic_string<C>& element_name,
+                   const std::basic_string<C>& element_namespace);
+
+  const std::basic_string<C>&
+  element_name () const;
+
+  const std::basic_string<C>&
+  element_namespace () const;
+
+  virtual const char*
+  what () const throw ();
+};
+  
+ +

The application can discover the actual type of the element + object returned by parse() either using + dynamic_cast or by comparing element names and + namespaces. The following code fragments illustrate how the + element map can be used:

+ +
+// Parsing.
+//
+DOMElement& e = ... // Parse XML to DOM.
+
+unique_ptr<xml_schema::element_type> r (
+  xml_schema::element_map::parse (e));
+
+if (root1 r1 = dynamic_cast<root1*> (r.get ()))
+{
+  ...
+}
+else if (r->_name == root2::name () &&
+         r->_namespace () == root2::namespace_ ())
+{
+  root2& r2 (static_cast<root2&> (*r));
+
+  ...
+}
+  
+ +
+// Serialization.
+//
+xml_schema::element_type& r = ...
+
+string name (r._name ());
+string ns (r._namespace ());
+
+DOMDocument& doc = ... // Create a new DOMDocument with name and ns.
+DOMElement& e (*doc->getDocumentElement ());
+
+xml_schema::element_map::serialize (e, r);
+
+// Serialize DOMDocument to XML.
+  
+ + + +

2.10 Mapping for Global Attributes

+ +

An XML Schema attribute definition is called global if it appears + directly under the schema element. A global + attribute does not have any mapping. +

+ + + +

2.11 Mapping for xsi:type and Substitution + Groups

+ +

The mapping provides optional support for the XML Schema polymorphism + features (xsi:type and substitution groups) which can + be requested with the --generate-polymorphic option. + When used, the dynamic type of a member may be different from + its static type. Consider the following schema definition and + instance document: +

+ +
+<!-- test.xsd -->
+<schema>
+  <complexType name="base">
+    <attribute name="text" type="string"/>
+  </complexType>
+
+  <complexType name="derived">
+    <complexContent>
+      <extension base="base">
+        <attribute name="extra-text" type="string"/>
+      </extension>
+    </complexContent>
+  </complexType>
+
+  <complexType name="root_type">
+    <sequence>
+      <element name="item" type="base" maxOccurs="unbounded"/>
+    </sequence>
+  </complexType>
+
+  <element name="root" type="root_type"/>
+</schema>
+
+<!-- test.xml -->
+<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <item text="hello"/>
+  <item text="hello" extra-text="world" xsi:type="derived"/>
+</root>
+  
+ +

In the resulting object model, the container for + the root::item member will have two elements: + the first element's type will be base while + the second element's (dynamic) type will be + derived. This can be discovered using the + dynamic_cast operator as shown in the following + example: +

+ +
+void
+f (root& r)
+{
+  for (root::item_const_iterator i (r.item ().begin ());
+       i != r.item ().end ()
+       ++i)
+  {
+    if (derived* d = dynamic_cast<derived*> (&(*i)))
+    {
+      // derived
+    }
+    else
+    {
+      // base
+    }
+  }
+}
+  
+ +

The _clone virtual function should be used instead of + copy constructors to make copies of members that might use + polymorphism: +

+ +
+void
+f (root& r)
+{
+  for (root::item_const_iterator i (r.item ().begin ());
+       i != r.item ().end ()
+       ++i)
+  {
+    std::unique_ptr<base> c (i->_clone ());
+  }
+}
+  
+ +

The mapping can often automatically determine which types are + polymorphic based on the substitution group declarations. However, + if your XML vocabulary is not using substitution groups or if + substitution groups are defined in a separate schema, then you will + need to use the --polymorphic-type option to specify + which types are polymorphic. When using this option you only need + to specify the root of a polymorphic type hierarchy and the mapping + will assume that all the derived types are also polymorphic. + Also note that you need to specify this option when compiling every + schema file that references the polymorphic type. Consider the following + two schemas as an example:

+ +
+<!-- base.xsd -->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+  <xs:complexType name="base">
+    <xs:sequence>
+      <xs:element name="b" type="xs:int"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <!-- substitution group root -->
+  <xs:element name="base" type="base"/>
+
+</xs:schema>
+  
+ +
+<!-- derived.xsd -->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+  <include schemaLocation="base.xsd"/>
+
+  <xs:complexType name="derived">
+    <xs:complexContent>
+      <xs:extension base="base">
+        <xs:sequence>
+          <xs:element name="d" type="xs:string"/>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+
+  <xs:element name="derived" type="derived" substitutionGroup="base"/>
+
+</xs:schema>
+  
+ +

In this example we need to specify "--polymorphic-type base" + when compiling both schemas because the substitution group is declared + in a schema other than the one defining type base.

+ +

You can also indicate that all types should be treated as polymorphic + with the --polymorphic-type-all. However, this may result + in slower generated code with a greater footprint.

+ + + + + +

2.12 Mapping for any and anyAttribute

+ +

For the XML Schema any and anyAttribute + wildcards an optional mapping can be requested with the + --generate-wildcard option. The mapping represents + the content matched by wildcards as DOM fragments. Because the + DOM API is used to access such content, the Xerces-C++ runtime + should be initialized by the application prior to parsing and + should remain initialized for the lifetime of objects with + the wildcard content. For more information on the Xerces-C++ + runtime initialization see Section 3.1, + "Initializing the Xerces-C++ Runtime". +

+ +

The mapping for any is similar to the mapping for + local elements (see Section 2.8, "Mapping for Local + Elements and Attributes") except that the type used in the + wildcard mapping is xercesc::DOMElement. As with local + elements, the mapping divides all possible cardinality combinations + into three cardinality classes: one, optional, and + sequence. +

+ +

The mapping for anyAttribute represents the attributes + matched by this wildcard as a set of xercesc::DOMAttr + objects with a key being the attribute's name and namespace.

+ +

Similar to local elements and attributes, the any and + anyAttribute wildcards are mapped to a set of public type + definitions (typedefs) and a set of public accessor and modifier + functions. Type definitions have names derived from "any" + for the any wildcard and "any_attribute" + for the anyAttribute wildcard. The accessor and modifier + functions are named "any" for the any wildcard + and "any_attribute" for the anyAttribute + wildcard. Subsequent wildcards in the same type have escaped names + such as "any1" or "any_attribute1". +

+ +

Because Xerces-C++ DOM nodes always belong to a DOMDocument, + each type with a wildcard has an associated DOMDocument + object. The reference to this object can be obtained using the accessor + function called dom_document. The access to the document + object from the application code may be necessary to create or modify + the wildcard content. For example: +

+ +
+<complexType name="object">
+  <sequence>
+    <any namespace="##other"/>
+  </sequence>
+  <anyAttribute namespace="##other"/>
+</complexType>
+  
+ +

is mapped to:

+ +
+class object: public xml_schema::type
+{
+public:
+  // any
+  //
+  const xercesc::DOMElement&
+  any () const;
+
+  void
+  any (const xercesc::DOMElement&);
+
+  ...
+
+  // any_attribute
+  //
+  typedef attribute_set any_attribute_set;
+  typedef any_attribute_set::iterator any_attribute_iterator;
+  typedef any_attribute_set::const_iterator any_attribute_const_iterator;
+
+  const any_attribute_set&
+  any_attribute () const;
+
+  any_attribute_set&
+  any_attribute ();
+
+  ...
+
+  // DOMDocument object for wildcard content.
+  //
+  const xercesc::DOMDocument&
+  dom_document () const;
+
+  xercesc::DOMDocument&
+  dom_document ();
+
+  ...
+};
+  
+ + +

Names and semantics of type definitions for the wildcards as well + as signatures of the accessor and modifier functions depend on the + wildcard type as well as the cardinality class for the any + wildcard. They are described in the following sub-sections. +

+ + +

2.12.1 Mapping for any with the One Cardinality Class

+ +

For any with the One cardinality class, + there are no type definitions. The accessor functions come in + constant and non-constant versions. The constant accessor function + returns a constant reference to xercesc::DOMElement and + can be used for read-only access. The non-constant version returns + an unrestricted reference to xercesc::DOMElement and can + be used for read-write access. +

+ +

The first modifier function expects an argument of type reference + to constant xercesc::DOMElement and makes a deep copy + of its argument. The second modifier function expects an argument of + type pointer to xercesc::DOMElement. This modifier + function assumes ownership of its argument and expects the element + object to be created using the DOM document associated with this + instance. For example: +

+ +
+<complexType name="object">
+  <sequence>
+    <any namespace="##other"/>
+  </sequence>
+</complexType>
+  
+ +

is mapped to:

+ +
+class object: public xml_schema::type
+{
+public:
+  // Accessors.
+  //
+  const xercesc::DOMElement&
+  any () const;
+
+  xercesc::DOMElement&
+  any ();
+
+  // Modifiers.
+  //
+  void
+  any (const xercesc::DOMElement&);
+
+  void
+  any (xercesc::DOMElement*);
+
+  ...
+
+};
+  
+ + +

The following code shows how one could use this mapping:

+ +
+void
+f (object& o, const xercesc::DOMElement& e)
+{
+  using namespace xercesc;
+
+  DOMElement& e1 (o.any ());             // get
+  o.any (e)                              // set, deep copy
+  DOMDocument& doc (o.dom_document ());
+  o.any (doc.createElement (...));       // set, assumes ownership
+}
+  
+ +

2.12.2 Mapping for any with the Optional Cardinality Class

+ +

For any with the Optional cardinality class, the type + definitions consist of an alias for the container type with name + any_optional (or any1_optional, etc., for + subsequent wildcards in the type definition). +

+ +

Unlike accessor functions for the One cardinality class, accessor + functions for the Optional cardinality class return references to + corresponding containers rather than directly to DOMElement. + The accessor functions come in constant and non-constant versions. + The constant accessor function returns a constant reference to + the container and can be used for read-only access. The non-constant + version returns an unrestricted reference to the container + and can be used for read-write access. +

+ +

The modifier functions are overloaded for xercesc::DOMElement + and the container type. The first modifier function expects an argument of + type reference to constant xercesc::DOMElement and + makes a deep copy of its argument. The second modifier function + expects an argument of type pointer to xercesc::DOMElement. + This modifier function assumes ownership of its argument and expects + the element object to be created using the DOM document associated + with this instance. The third modifier function expects an argument + of type reference to constant of the container type and makes a + deep copy of its argument. For instance: +

+ +
+<complexType name="object">
+  <sequence>
+    <any namespace="##other" minOccurs="0"/>
+  </sequence>
+</complexType>
+  
+ +

is mapped to:

+ +
+class object: public xml_schema::type
+{
+public:
+  // Type definitions.
+  //
+  typedef element_optional any_optional;
+
+  // Accessors.
+  //
+  const any_optional&
+  any () const;
+
+  any_optional&
+  any ();
+
+  // Modifiers.
+  //
+  void
+  any (const xercesc::DOMElement&);
+
+  void
+  any (xercesc::DOMElement*);
+
+  void
+  any (const any_optional&);
+
+  ...
+
+};
+  
+ + +

The element_optional container is a + specialization of the optional class template described + in Section 2.8.2, "Mapping for Members with the Optional + Cardinality Class". Its interface is presented below: +

+ +
+class element_optional
+{
+public:
+  explicit
+  element_optional (xercesc::DOMDocument&);
+
+  // Makes a deep copy.
+  //
+  element_optional (const xercesc::DOMElement&, xercesc::DOMDocument&);
+
+  // Assumes ownership.
+  //
+  element_optional (xercesc::DOMElement*, xercesc::DOMDocument&);
+
+  element_optional (const element_optional&, xercesc::DOMDocument&);
+
+public:
+  element_optional&
+  operator= (const xercesc::DOMElement&);
+
+  element_optional&
+  operator= (const element_optional&);
+
+  // Pointer-like interface.
+  //
+public:
+  const xercesc::DOMElement*
+  operator-> () const;
+
+  xercesc::DOMElement*
+  operator-> ();
+
+  const xercesc::DOMElement&
+  operator* () const;
+
+  xercesc::DOMElement&
+  operator* ();
+
+  typedef void (element_optional::*bool_convertible) ();
+  operator bool_convertible () const;
+
+  // Get/set interface.
+  //
+public:
+  bool
+  present () const;
+
+  const xercesc::DOMElement&
+  get () const;
+
+  xercesc::DOMElement&
+  get ();
+
+  // Makes a deep copy.
+  //
+  void
+  set (const xercesc::DOMElement&);
+
+  // Assumes ownership.
+  //
+  void
+  set (xercesc::DOMElement*);
+
+  void
+  reset ();
+};
+
+bool
+operator== (const element_optional&, const element_optional&);
+
+bool
+operator!= (const element_optional&, const element_optional&);
+  
+ + +

The following code shows how one could use this mapping:

+ +
+void
+f (object& o, const xercesc::DOMElement& e)
+{
+  using namespace xercesc;
+
+  DOMDocument& doc (o.dom_document ());
+
+  if (o.any ().present ())                  // test
+  {
+    DOMElement& e1 (o.any ().get ());       // get
+    o.any ().set (e);                       // set, deep copy
+    o.any ().set (doc.createElement (...)); // set, assumes ownership
+    o.any ().reset ();                      // reset
+  }
+
+  // Same as above but using pointer notation:
+  //
+  if (o.member ())                          // test
+  {
+    DOMElement& e1 (*o.any ());             // get
+    o.any (e);                              // set, deep copy
+    o.any (doc.createElement (...));        // set, assumes ownership
+    o.any ().reset ();                      // reset
+  }
+}
+  
+ + + +

2.12.3 Mapping for any with the Sequence Cardinality Class

+ +

For any with the Sequence cardinality class, the type + definitions consist of an alias of the container type with name + any_sequence (or any1_sequence, etc., for + subsequent wildcards in the type definition), an alias of the iterator + type with name any_iterator (or any1_iterator, + etc., for subsequent wildcards in the type definition), and an alias + of the constant iterator type with name any_const_iterator + (or any1_const_iterator, etc., for subsequent wildcards + in the type definition). +

+ +

The accessor functions come in constant and non-constant versions. + The constant accessor function returns a constant reference to the + container and can be used for read-only access. The non-constant + version returns an unrestricted reference to the container and can + be used for read-write access. +

+ +

The modifier function expects an argument of type reference to + constant of the container type. The modifier function makes + a deep copy of its argument. For instance: +

+ + +
+<complexType name="object">
+  <sequence>
+    <any namespace="##other" minOccurs="unbounded"/>
+  </sequence>
+</complexType>
+  
+ +

is mapped to:

+ +
+class object: public xml_schema::type
+{
+public:
+  // Type definitions.
+  //
+  typedef element_sequence any_sequence;
+  typedef any_sequence::iterator any_iterator;
+  typedef any_sequence::const_iterator any_const_iterator;
+
+  // Accessors.
+  //
+  const any_sequence&
+  any () const;
+
+  any_sequence&
+  any ();
+
+  // Modifier.
+  //
+  void
+  any (const any_sequence&);
+
+  ...
+
+};
+  
+ +

The element_sequence container is a + specialization of the sequence class template described + in Section 2.8.3, "Mapping for Members with the + Sequence Cardinality Class". Its interface is similar to + the sequence interface as defined by the ISO/ANSI Standard for + C++ (ISO/IEC 14882:1998, Section 23.1.1, "Sequences") and is + presented below: +

+ +
+class element_sequence
+{
+public:
+  typedef xercesc::DOMElement        value_type;
+  typedef xercesc::DOMElement*       pointer;
+  typedef const xercesc::DOMElement* const_pointer;
+  typedef xercesc::DOMElement&       reference;
+  typedef const xercesc::DOMElement& const_reference;
+
+  typedef <implementation-defined>   iterator;
+  typedef <implementation-defined>   const_iterator;
+  typedef <implementation-defined>   reverse_iterator;
+  typedef <implementation-defined>   const_reverse_iterator;
+
+  typedef <implementation-defined>   size_type;
+  typedef <implementation-defined>   difference_type;
+  typedef <implementation-defined>   allocator_type;
+
+public:
+  explicit
+  element_sequence (xercesc::DOMDocument&);
+
+  // DOMElement cannot be default-constructed.
+  //
+  // explicit
+  // element_sequence (size_type n);
+
+  element_sequence (size_type n,
+                    const xercesc::DOMElement&,
+                    xercesc::DOMDocument&);
+
+  template <typename I>
+  element_sequence (const I& begin,
+                    const I& end,
+                    xercesc::DOMDocument&);
+
+  element_sequence (const element_sequence&, xercesc::DOMDocument&);
+
+  element_sequence&
+  operator= (const element_sequence&);
+
+public:
+  void
+  assign (size_type n, const xercesc::DOMElement&);
+
+  template <typename I>
+  void
+  assign (const I& begin, const I& end);
+
+public:
+  // This version of resize can only be used to shrink the
+  // sequence because DOMElement cannot be default-constructed.
+  //
+  void
+  resize (size_type);
+
+  void
+  resize (size_type, const xercesc::DOMElement&);
+
+public:
+  size_type
+  size () const;
+
+  size_type
+  max_size () const;
+
+  size_type
+  capacity () const;
+
+  bool
+  empty () const;
+
+  void
+  reserve (size_type);
+
+  void
+  clear ();
+
+public:
+  const_iterator
+  begin () const;
+
+  const_iterator
+  end () const;
+
+  iterator
+  begin ();
+
+  iterator
+  end ();
+
+  const_reverse_iterator
+  rbegin () const;
+
+  const_reverse_iterator
+  rend () const
+
+    reverse_iterator
+  rbegin ();
+
+  reverse_iterator
+  rend ();
+
+public:
+  xercesc::DOMElement&
+  operator[] (size_type);
+
+  const xercesc::DOMElement&
+  operator[] (size_type) const;
+
+  xercesc::DOMElement&
+  at (size_type);
+
+  const xercesc::DOMElement&
+  at (size_type) const;
+
+  xercesc::DOMElement&
+  front ();
+
+  const xercesc::DOMElement&
+  front () const;
+
+  xercesc::DOMElement&
+  back ();
+
+  const xercesc::DOMElement&
+  back () const;
+
+public:
+  // Makes a deep copy.
+  //
+  void
+  push_back (const xercesc::DOMElement&);
+
+  // Assumes ownership.
+  //
+  void
+  push_back (xercesc::DOMElement*);
+
+  void
+  pop_back ();
+
+  // Makes a deep copy.
+  //
+  iterator
+  insert (iterator position, const xercesc::DOMElement&);
+
+  // Assumes ownership.
+  //
+  iterator
+  insert (iterator position, xercesc::DOMElement*);
+
+  void
+  insert (iterator position, size_type n, const xercesc::DOMElement&);
+
+  template <typename I>
+  void
+  insert (iterator position, const I& begin, const I& end);
+
+  iterator
+  erase (iterator position);
+
+  iterator
+  erase (iterator begin, iterator end);
+
+public:
+  // Note that the DOMDocument object of the two sequences being
+  // swapped should be the same.
+  //
+  void
+  swap (sequence& x);
+};
+
+inline bool
+operator== (const element_sequence&, const element_sequence&);
+
+inline bool
+operator!= (const element_sequence&, const element_sequence&);
+  
+ + +

The following code shows how one could use this mapping:

+ +
+void
+f (object& o, const xercesc::DOMElement& e)
+{
+  using namespace xercesc;
+
+  object::any_sequence& s (o.any ());
+
+  // Iteration.
+  //
+  for (object::any_iterator i (s.begin ()); i != s.end (); ++i)
+  {
+    DOMElement& e (*i);
+  }
+
+  // Modification.
+  //
+  s.push_back (e);                       // deep copy
+  DOMDocument& doc (o.dom_document ());
+  s.push_back (doc.createElement (...)); // assumes ownership
+}
+  
+ +

2.12.4 Element Wildcard Order

+ +

Similar to elements, element wildcards in ordered types + (Section 2.8.4, "Element Order") are assigned + content ids and are included in the content order sequence. + Continuing with the bank transactions example started in Section + 2.8.4, we can extend the batch by allowing custom transactions:

+ +
+<complexType name="batch">
+  <choice minOccurs="0" maxOccurs="unbounded">
+    <element name="withdraw" type="withdraw"/>
+    <element name="deposit" type="deposit"/>
+    <any namespace="##other" processContents="lax"/>
+  </choice>
+</complexType>
+  
+ +

This will lead to the following changes in the generated + batch C++ class:

+ +
+class batch: public xml_schema::type
+{
+public:
+  ...
+
+  // any
+  //
+  typedef element_sequence any_sequence;
+  typedef any_sequence::iterator any_iterator;
+  typedef any_sequence::const_iterator any_const_iterator;
+
+  static const std::size_t any_id = 3UL;
+
+  const any_sequence&
+  any () const;
+
+  any_sequence&
+  any ();
+
+  void
+  any (const any_sequence&);
+
+  ...
+};
+  
+ +

With this change we also need to update the iteration code to handle + the new content id:

+ +
+for (batch::content_order_const_iterator i (b.content_order ().begin ());
+     i != b.content_order ().end ();
+     ++i)
+{
+  switch (i->id)
+  {
+    ...
+
+  case batch::any_id:
+    {
+      const DOMElement& e (b.any ()[i->index]);
+      ...
+      break;
+    }
+
+    ...
+  }
+}
+  
+ +

For the complete working code that shows the use of wildcards in + ordered types refer to the order/element example in + the cxx/tree/ directory in the + xsd-examples + package.

+ +

2.12.5 Mapping for anyAttribute

+ +

For anyAttribute the type definitions consist of an alias + of the container type with name any_attribute_set + (or any1_attribute_set, etc., for subsequent wildcards + in the type definition), an alias of the iterator type with name + any_attribute_iterator (or any1_attribute_iterator, + etc., for subsequent wildcards in the type definition), and an alias + of the constant iterator type with name any_attribute_const_iterator + (or any1_attribute_const_iterator, etc., for subsequent + wildcards in the type definition). +

+ +

The accessor functions come in constant and non-constant versions. + The constant accessor function returns a constant reference to the + container and can be used for read-only access. The non-constant + version returns an unrestricted reference to the container and can + be used for read-write access. +

+ +

The modifier function expects an argument of type reference to + constant of the container type. The modifier function makes + a deep copy of its argument. For instance: +

+ + +
+<complexType name="object">
+  <sequence>
+    ...
+  </sequence>
+  <anyAttribute namespace="##other"/>
+</complexType>
+  
+ +

is mapped to:

+ +
+class object: public xml_schema::type
+{
+public:
+  // Type definitions.
+  //
+  typedef attribute_set any_attribute_set;
+  typedef any_attribute_set::iterator any_attribute_iterator;
+  typedef any_attribute_set::const_iterator any_attribute_const_iterator;
+
+  // Accessors.
+  //
+  const any_attribute_set&
+  any_attribute () const;
+
+  any_attribute_set&
+  any_attribute ();
+
+  // Modifier.
+  //
+  void
+  any_attribute (const any_attribute_set&);
+
+  ...
+
+};
+  
+ +

The attribute_set class is an associative container + similar to the std::set class template as defined by + the ISO/ANSI Standard for C++ (ISO/IEC 14882:1998, Section 23.3.3, + "Class template set") with the key being the attribute's name + and namespace. Unlike std::set, attribute_set + allows searching using names and namespaces instead of + xercesc::DOMAttr objects. It is defined in an + implementation-specific namespace and its interface is presented + below: +

+ +
+class attribute_set
+{
+public:
+  typedef xercesc::DOMAttr         key_type;
+  typedef xercesc::DOMAttr         value_type;
+  typedef xercesc::DOMAttr*        pointer;
+  typedef const xercesc::DOMAttr*  const_pointer;
+  typedef xercesc::DOMAttr&        reference;
+  typedef const xercesc::DOMAttr&  const_reference;
+
+  typedef <implementation-defined> iterator;
+  typedef <implementation-defined> const_iterator;
+  typedef <implementation-defined> reverse_iterator;
+  typedef <implementation-defined> const_reverse_iterator;
+
+  typedef <implementation-defined> size_type;
+  typedef <implementation-defined> difference_type;
+  typedef <implementation-defined> allocator_type;
+
+public:
+  attribute_set (xercesc::DOMDocument&);
+
+  template <typename I>
+  attribute_set (const I& begin, const I& end, xercesc::DOMDocument&);
+
+  attribute_set (const attribute_set&, xercesc::DOMDocument&);
+
+  attribute_set&
+  operator= (const attribute_set&);
+
+public:
+  const_iterator
+  begin () const;
+
+  const_iterator
+  end () const;
+
+  iterator
+  begin ();
+
+  iterator
+  end ();
+
+  const_reverse_iterator
+  rbegin () const;
+
+  const_reverse_iterator
+  rend () const;
+
+  reverse_iterator
+  rbegin ();
+
+  reverse_iterator
+  rend ();
+
+public:
+  size_type
+  size () const;
+
+  size_type
+  max_size () const;
+
+  bool
+  empty () const;
+
+  void
+  clear ();
+
+public:
+  // Makes a deep copy.
+  //
+  std::pair<iterator, bool>
+  insert (const xercesc::DOMAttr&);
+
+  // Assumes ownership.
+  //
+  std::pair<iterator, bool>
+  insert (xercesc::DOMAttr*);
+
+  // Makes a deep copy.
+  //
+  iterator
+  insert (iterator position, const xercesc::DOMAttr&);
+
+  // Assumes ownership.
+  //
+  iterator
+  insert (iterator position, xercesc::DOMAttr*);
+
+  template <typename I>
+  void
+  insert (const I& begin, const I& end);
+
+public:
+  void
+  erase (iterator position);
+
+  size_type
+  erase (const std::basic_string<C>& name);
+
+  size_type
+  erase (const std::basic_string<C>& namespace_,
+         const std::basic_string<C>& name);
+
+  size_type
+  erase (const XMLCh* name);
+
+  size_type
+  erase (const XMLCh* namespace_, const XMLCh* name);
+
+  void
+  erase (iterator begin, iterator end);
+
+public:
+  size_type
+  count (const std::basic_string<C>& name) const;
+
+  size_type
+  count (const std::basic_string<C>& namespace_,
+         const std::basic_string<C>& name) const;
+
+  size_type
+  count (const XMLCh* name) const;
+
+  size_type
+  count (const XMLCh* namespace_, const XMLCh* name) const;
+
+  iterator
+  find (const std::basic_string<C>& name);
+
+  iterator
+  find (const std::basic_string<C>& namespace_,
+        const std::basic_string<C>& name);
+
+  iterator
+  find (const XMLCh* name);
+
+  iterator
+  find (const XMLCh* namespace_, const XMLCh* name);
+
+  const_iterator
+  find (const std::basic_string<C>& name) const;
+
+  const_iterator
+  find (const std::basic_string<C>& namespace_,
+        const std::basic_string<C>& name) const;
+
+  const_iterator
+  find (const XMLCh* name) const;
+
+  const_iterator
+  find (const XMLCh* namespace_, const XMLCh* name) const;
+
+public:
+  // Note that the DOMDocument object of the two sets being
+  // swapped should be the same.
+  //
+  void
+  swap (attribute_set&);
+};
+
+bool
+operator== (const attribute_set&, const attribute_set&);
+
+bool
+operator!= (const attribute_set&, const attribute_set&);
+  
+ +

The following code shows how one could use this mapping:

+ +
+void
+f (object& o, const xercesc::DOMAttr& a)
+{
+  using namespace xercesc;
+
+  object::any_attribute_set& s (o.any_attribute ());
+
+  // Iteration.
+  //
+  for (object::any_attribute_iterator i (s.begin ()); i != s.end (); ++i)
+  {
+    DOMAttr& a (*i);
+  }
+
+  // Modification.
+  //
+  s.insert (a);                         // deep copy
+  DOMDocument& doc (o.dom_document ());
+  s.insert (doc.createAttribute (...)); // assumes ownership
+
+  // Searching.
+  //
+  object::any_attribute_iterator i (s.find ("name"));
+  i = s.find ("http://www.w3.org/XML/1998/namespace", "lang");
+}
+  
+ + + +

2.13 Mapping for Mixed Content Models

+ +

For XML Schema types with mixed content models C++/Tree provides + mapping support only if the type is marked as ordered + (Section 2.8.4, "Element Order"). Use the + --ordered-type-mixed XSD compiler option to + automatically mark all types with mixed content as ordered.

+ +

For an ordered type with mixed content, C++/Tree adds an extra + text content sequence that is used to store the text fragments. + This text content sequence is also assigned the content id and + its entries are included in the content order sequence, just + like elements. As a result, it is possible to capture the order + between elements and text fragments.

+ +

As an example, consider the following schema that describes text + with embedded links:

+ +
+<complexType name="anchor">
+  <simpleContent>
+    <extension base="string">
+      <attribute name="href" type="anyURI" use="required"/>
+    </extension>
+  </simpleContent>
+</complexType>
+
+<complexType name="text" mixed="true">
+  <sequence>
+    <element name="a" type="anchor" minOccurs="0" maxOccurs="unbounded"/>
+  </sequence>
+</complexType>
+  
+ +

The generated text C++ class will provide the following + API (assuming it is marked as ordered):

+ +
+class text: public xml_schema::type
+{
+public:
+  // a
+  //
+  typedef anchor a_type;
+  typedef sequence<a_type> a_sequence;
+  typedef a_sequence::iterator a_iterator;
+  typedef a_sequence::const_iterator a_const_iterator;
+
+  static const std::size_t a_id = 1UL;
+
+  const a_sequence&
+  a () const;
+
+  a_sequence&
+  a ();
+
+  void
+  a (const a_sequence&);
+
+  // text_content
+  //
+  typedef xml_schema::string text_content_type;
+  typedef sequence<text_content_type> text_content_sequence;
+  typedef text_content_sequence::iterator text_content_iterator;
+  typedef text_content_sequence::const_iterator text_content_const_iterator;
+
+  static const std::size_t text_content_id = 2UL;
+
+  const text_content_sequence&
+  text_content () const;
+
+  text_content_sequence&
+  text_content ();
+
+  void
+  text_content (const text_content_sequence&);
+
+  // content_order
+  //
+  typedef xml_schema::content_order content_order_type;
+  typedef std::vector<content_order_type> content_order_sequence;
+  typedef content_order_sequence::iterator content_order_iterator;
+  typedef content_order_sequence::const_iterator content_order_const_iterator;
+
+  const content_order_sequence&
+  content_order () const;
+
+  content_order_sequence&
+  content_order ();
+
+  void
+  content_order (const content_order_sequence&);
+
+  ...
+};
+  
+ +

Given this interface we can iterate over both link elements + and text in content order. The following code fragment converts + our format to plain text with references.

+ +
+const text& t = ...
+
+for (text::content_order_const_iterator i (t.content_order ().begin ());
+     i != t.content_order ().end ();
+     ++i)
+{
+  switch (i->id)
+  {
+  case text::a_id:
+    {
+      const anchor& a (t.a ()[i->index]);
+      cerr << a << "[" << a.href () << "]";
+      break;
+    }
+  case text::text_content_id:
+    {
+      const xml_schema::string& s (t.text_content ()[i->index]);
+      cerr << s;
+      break;
+    }
+  default:
+    {
+      assert (false); // Unknown content id.
+    }
+  }
+}
+  
+ +

For the complete working code that shows the use of mixed content + in ordered types refer to the order/mixed example in + the cxx/tree/ directory in the + xsd-examples + package.

+ + + + +

3 Parsing

+ +

This chapter covers various aspects of parsing XML instance + documents in order to obtain corresponding tree-like object + model. +

+ +

Each global XML Schema element in the form:

+ +
+<element name="name" type="type"/>
+  
+ +

is mapped to 14 overloaded C++ functions in the form:

+ +
+// Read from a URI or a local file.
+//
+
+std::[unique|auto]_ptr<type>
+name (const std::basic_string<C>& uri,
+      xml_schema::flags = 0,
+      const xml_schema::properties& = xml_schema::properties ());
+
+std::[unique|auto]_ptr<type>
+name (const std::basic_string<C>& uri,
+      xml_schema::error_handler&,
+      xml_schema::flags = 0,
+      const xml_schema::properties& = xml_schema::properties ());
+
+std::[unique|auto]_ptr<type>
+name (const std::basic_string<C>& uri,
+      xercesc::DOMErrorHandler&,
+      xml_schema::flags = 0,
+      const xml_schema::properties& = xml_schema::properties ());
+
+
+// Read from std::istream.
+//
+
+std::[unique|auto]_ptr<type>
+name (std::istream&,
+      xml_schema::flags = 0,
+      const xml_schema::properties& = xml_schema::properties ());
+
+std::[unique|auto]_ptr<type>
+name (std::istream&,
+      xml_schema::error_handler&,
+      xml_schema::flags = 0,
+      const xml_schema::properties& = xml_schema::properties ());
+
+std::[unique|auto]_ptr<type>
+name (std::istream&,
+      xercesc::DOMErrorHandler&,
+      xml_schema::flags = 0,
+      const xml_schema::properties& = xml_schema::properties ());
+
+
+std::[unique|auto]_ptr<type>
+name (std::istream&,
+      const std::basic_string<C>& id,
+      xml_schema::flags = 0,
+      const xml_schema::properties& = xml_schema::properties ());
+
+std::[unique|auto]_ptr<type>
+name (std::istream&,
+      const std::basic_string<C>& id,
+      xml_schema::error_handler&,
+      xml_schema::flags = 0,
+      const xml_schema::properties& = xml_schema::properties ());
+
+std::[unique|auto]_ptr<type>
+name (std::istream&,
+      const std::basic_string<C>& id,
+      xercesc::DOMErrorHandler&,
+      xml_schema::flags = 0,
+      const xml_schema::properties& = xml_schema::properties ());
+
+
+// Read from InputSource.
+//
+
+std::[unique|auto]_ptr<type>
+name (xercesc::InputSource&,
+      xml_schema::flags = 0,
+      const xml_schema::properties& = xml_schema::properties ());
+
+std::[unique|auto]_ptr<type>
+name (xercesc::InputSource&,
+      xml_schema::error_handler&,
+      xml_schema::flags = 0,
+      const xml_schema::properties& = xml_schema::properties ());
+
+std::[unique|auto]_ptr<type>
+name (xercesc::InputSource&,
+      xercesc::DOMErrorHandler&,
+      xml_schema::flags = 0,
+      const xml_schema::properties& = xml_schema::properties ());
+
+
+// Read from DOM.
+//
+
+std::[unique|auto]_ptr<type>
+name (const xercesc::DOMDocument&,
+      xml_schema::flags = 0,
+      const xml_schema::properties& = xml_schema::properties ());
+
+std::[unique|auto]_ptr<type>
+name (xml_schema::dom::[unique|auto]_ptr<xercesc::DOMDocument>,
+      xml_schema::flags = 0,
+      const xml_schema::properties& = xml_schema::properties ());
+  
+ +

You can choose between reading an XML instance from a local file, + URI, std::istream, xercesc::InputSource, + or a pre-parsed DOM instance in the form of + xercesc::DOMDocument. All the parsing functions + return a dynamically allocated object model as either + std::unique_ptr or std::auto_ptr, + depending on the C++ standard selected. Each of these parsing + functions is discussed in more detail in the following sections. +

+ +

3.1 Initializing the Xerces-C++ Runtime

+ +

Some parsing functions expect you to initialize the Xerces-C++ + runtime while others initialize and terminate it as part of their + work. The general rule is as follows: if a function has any arguments + or return a value that is an instance of a Xerces-C++ type, then + this function expects you to initialize the Xerces-C++ runtime. + Otherwise, the function initializes and terminates the runtime for + you. Note that it is legal to have nested calls to the Xerces-C++ + initialize and terminate functions as long as the calls are balanced. +

+ +

You can instruct parsing functions that initialize and terminate + the runtime not to do so by passing the + xml_schema::flags::dont_initialize flag (see + Section 3.2, "Flags and Properties"). +

+ + +

3.2 Flags and Properties

+ +

Parsing flags and properties are the last two arguments of every + parsing function. They allow you to fine-tune the process of + instance validation and parsing. Both arguments are optional. +

+ + +

The following flags are recognized by the parsing functions:

+ +
+
xml_schema::flags::keep_dom
+
Keep association between DOM nodes and the resulting + object model nodes. For more information about DOM association + refer to Section 5.1, "DOM Association".
+ +
xml_schema::flags::own_dom
+
Assume ownership of the DOM document passed. This flag only + makes sense together with the keep_dom flag in + the call to the parsing function with the + xml_schema::dom::[unique|auto]_ptr<DOMDocument> + argument.
+ +
xml_schema::flags::dont_validate
+
Do not validate instance documents against schemas.
+ +
xml_schema::flags::dont_initialize
+
Do not initialize the Xerces-C++ runtime.
+
+ +

You can pass several flags by combining them using the bit-wise OR + operator. For example:

+ +
+using xml_schema::flags;
+
+std::unique_ptr<type> r (
+  name ("test.xml", flags::keep_dom | flags::dont_validate));
+  
+ +

By default, validation of instance documents is turned on even + though parsers generated by XSD do not assume instance + documents are valid. They include a number of checks that prevent + construction of inconsistent object models. This, + however, does not mean that an instance document that was + successfully parsed by the XSD-generated parsers is + valid per the corresponding schema. If an instance document is not + "valid enough" for the generated parsers to construct consistent + object model, one of the exceptions defined in + xml_schema namespace is thrown (see + Section 3.3, "Error Handling"). +

+ +

For more information on the Xerces-C++ runtime initialization + refer to Section 3.1, "Initializing the Xerces-C++ + Runtime". +

+ +

The xml_schema::properties class allows you to + programmatically specify schema locations to be used instead + of those specified with the xsi::schemaLocation + and xsi::noNamespaceSchemaLocation attributes + in instance documents. The interface of the properties + class is presented below: +

+ +
+class properties
+{
+public:
+  void
+  schema_location (const std::basic_string<C>& namespace_,
+                   const std::basic_string<C>& location);
+  void
+  no_namespace_schema_location (const std::basic_string<C>& location);
+};
+  
+ +

Note that all locations are relative to an instance document unless + they are URIs. For example, if you want to use a local file as your + schema, then you will need to pass + file:///absolute/path/to/your/schema as the location + argument. +

+ +

3.3 Error Handling

+ +

As discussed in Section 2.2, "Error Handling", + the mapping uses the C++ exception handling mechanism as its primary + way of reporting error conditions. However, to handle recoverable + parsing and validation errors and warnings, a callback interface maybe + preferred by the application.

+ +

To better understand error handling and reporting strategies employed + by the parsing functions, it is useful to know that the + transformation of an XML instance document to a statically-typed + tree happens in two stages. The first stage, performed by Xerces-C++, + consists of parsing an XML document into a DOM instance. For short, + we will call this stage the XML-DOM stage. Validation, if not disabled, + happens during this stage. The second stage, + performed by the generated parsers, consist of parsing the DOM + instance into the statically-typed tree. We will call this stage + the DOM-Tree stage. Additional checks are performed during this + stage in order to prevent construction of inconsistent tree which + could otherwise happen when validation is disabled, for example.

+ +

All parsing functions except the one that operates on a DOM instance + come in overloaded triples. The first function in such a triple + reports error conditions exclusively by throwing exceptions. It + accumulates all the parsing and validation errors of the XML-DOM + stage and throws them in a single instance of the + xml_schema::parsing exception (described below). + The second and the third functions in the triple use callback + interfaces to report parsing and validation errors and warnings. + The two callback interfaces are xml_schema::error_handler + and xercesc::DOMErrorHandler. For more information + on the xercesc::DOMErrorHandler interface refer to + the Xerces-C++ documentation. The xml_schema::error_handler + interface is presented below: +

+ +
+class error_handler
+{
+public:
+  struct severity
+  {
+    enum value
+    {
+      warning,
+      error,
+      fatal
+    };
+  };
+
+  virtual bool
+  handle (const std::basic_string<C>& id,
+          unsigned long line,
+          unsigned long column,
+          severity,
+          const std::basic_string<C>& message) = 0;
+
+  virtual
+  ~error_handler ();
+};
+  
+ +

The id argument of the error_handler::handle + function identifies the resource being parsed (e.g., a file name or + URI). +

+ +

By returning true from the handle function + you instruct the parser to recover and continue parsing. Returning + false results in termination of the parsing process. + An error with the fatal severity level results in + termination of the parsing process no matter what is returned from + the handle function. It is safe to throw an exception + from the handle function. +

+ +

The DOM-Tree stage reports error conditions exclusively by throwing + exceptions. Individual exceptions thrown by the parsing functions + are described in the following sub-sections. +

+ + +

3.3.1 xml_schema::parsing

+ +
+struct severity
+{
+  enum value
+  {
+    warning,
+    error
+  };
+
+  severity (value);
+  operator value () const;
+};
+
+struct error
+{
+  error (severity,
+         const std::basic_string<C>& id,
+         unsigned long line,
+         unsigned long column,
+         const std::basic_string<C>& message);
+
+  severity
+  severity () const;
+
+  const std::basic_string<C>&
+  id () const;
+
+  unsigned long
+  line () const;
+
+  unsigned long
+  column () const;
+
+  const std::basic_string<C>&
+  message () const;
+};
+
+std::basic_ostream<C>&
+operator<< (std::basic_ostream<C>&, const error&);
+
+struct diagnostics: std::vector<error>
+{
+};
+
+std::basic_ostream<C>&
+operator<< (std::basic_ostream<C>&, const diagnostics&);
+
+struct parsing: virtual exception
+{
+  parsing ();
+  parsing (const diagnostics&);
+
+  const diagnostics&
+  diagnostics () const;
+
+  virtual const char*
+  what () const throw ();
+};
+  
+ +

The xml_schema::parsing exception is thrown if there + were parsing or validation errors reported during the XML-DOM stage. + If no callback interface was provided to the parsing function, the + exception contains a list of errors and warnings accessible using + the diagnostics function. The usual conditions when + this exception is thrown include malformed XML instances and, if + validation is turned on, invalid instance documents. +

+ +

3.3.2 xml_schema::expected_element

+ +
+struct expected_element: virtual exception
+{
+  expected_element (const std::basic_string<C>& name,
+                    const std::basic_string<C>& namespace_);
+
+
+  const std::basic_string<C>&
+  name () const;
+
+  const std::basic_string<C>&
+  namespace_ () const;
+
+
+  virtual const char*
+  what () const throw ();
+};
+  
+ +

The xml_schema::expected_element exception is thrown + when an expected element is not encountered by the DOM-Tree stage. + The name and namespace of the expected element can be obtained using + the name and namespace_ functions respectively. +

+ + +

3.3.3 xml_schema::unexpected_element

+ +
+struct unexpected_element: virtual exception
+{
+  unexpected_element (const std::basic_string<C>& encountered_name,
+                      const std::basic_string<C>& encountered_namespace,
+                      const std::basic_string<C>& expected_name,
+                      const std::basic_string<C>& expected_namespace)
+
+
+  const std::basic_string<C>&
+  encountered_name () const;
+
+  const std::basic_string<C>&
+  encountered_namespace () const;
+
+
+  const std::basic_string<C>&
+  expected_name () const;
+
+  const std::basic_string<C>&
+  expected_namespace () const;
+
+
+  virtual const char*
+  what () const throw ();
+};
+  
+ +

The xml_schema::unexpected_element exception is thrown + when an unexpected element is encountered by the DOM-Tree stage. + The name and namespace of the encountered element can be obtained + using the encountered_name and + encountered_namespace functions respectively. If an + element was expected instead of the encountered one, its name + and namespace can be obtained using the expected_name and + expected_namespace functions respectively. Otherwise + these functions return empty strings. +

+ +

3.3.4 xml_schema::expected_attribute

+ +
+struct expected_attribute: virtual exception
+{
+  expected_attribute (const std::basic_string<C>& name,
+                      const std::basic_string<C>& namespace_);
+
+
+  const std::basic_string<C>&
+  name () const;
+
+  const std::basic_string<C>&
+  namespace_ () const;
+
+
+  virtual const char*
+  what () const throw ();
+};
+  
+ +

The xml_schema::expected_attribute exception is thrown + when an expected attribute is not encountered by the DOM-Tree stage. + The name and namespace of the expected attribute can be obtained using + the name and namespace_ functions respectively. +

+ + +

3.3.5 xml_schema::unexpected_enumerator

+ +
+struct unexpected_enumerator: virtual exception
+{
+  unexpected_enumerator (const std::basic_string<C>& enumerator);
+
+  const std::basic_string<C>&
+  enumerator () const;
+
+  virtual const char*
+  what () const throw ();
+};
+  
+ +

The xml_schema::unexpected_enumerator exception is thrown + when an unexpected enumerator is encountered by the DOM-Tree stage. + The enumerator can be obtained using the enumerator + functions. +

+ +

3.3.6 xml_schema::expected_text_content

+ +
+struct expected_text_content: virtual exception
+{
+  virtual const char*
+  what () const throw ();
+};
+  
+ +

The xml_schema::expected_text_content exception is thrown + when a content other than text is encountered and the text content was + expected by the DOM-Tree stage. +

+ +

3.3.7 xml_schema::no_type_info

+ +
+struct no_type_info: virtual exception
+{
+  no_type_info (const std::basic_string<C>& type_name,
+                const std::basic_string<C>& type_namespace);
+
+  const std::basic_string<C>&
+  type_name () const;
+
+  const std::basic_string<C>&
+  type_namespace () const;
+
+  virtual const char*
+  what () const throw ();
+};
+  
+ +

The xml_schema::no_type_info exception is thrown + when there is no type information associated with a type specified + by the xsi:type attribute. This exception is thrown + by the DOM-Tree stage. The name and namespace of the type in question + can be obtained using the type_name and + type_namespace functions respectively. Usually, catching + this exception means that you haven't linked the code generated + from the schema defining the type in question with your application + or this schema has been compiled without the + --generate-polymorphic option. +

+ + +

3.3.8 xml_schema::not_derived

+ +
+struct not_derived: virtual exception
+{
+  not_derived (const std::basic_string<C>& base_type_name,
+               const std::basic_string<C>& base_type_namespace,
+               const std::basic_string<C>& derived_type_name,
+               const std::basic_string<C>& derived_type_namespace);
+
+  const std::basic_string<C>&
+  base_type_name () const;
+
+  const std::basic_string<C>&
+  base_type_namespace () const;
+
+
+  const std::basic_string<C>&
+  derived_type_name () const;
+
+  const std::basic_string<C>&
+  derived_type_namespace () const;
+
+  virtual const char*
+  what () const throw ();
+};
+  
+ +

The xml_schema::not_derived exception is thrown + when a type specified by the xsi:type attribute is + not derived from the expected base type. This exception is thrown + by the DOM-Tree stage. The name and namespace of the expected + base type can be obtained using the base_type_name and + base_type_namespace functions respectively. The name + and namespace of the offending type can be obtained using the + derived_type_name and + derived_type_namespace functions respectively. +

+ +

3.3.9 xml_schema::no_prefix_mapping

+ +
+struct no_prefix_mapping: virtual exception
+{
+  no_prefix_mapping (const std::basic_string<C>& prefix);
+
+  const std::basic_string<C>&
+  prefix () const;
+
+  virtual const char*
+  what () const throw ();
+};
+  
+ +

The xml_schema::no_prefix_mapping exception is thrown + during the DOM-Tree stage if a namespace prefix is encountered for + which a prefix-namespace mapping hasn't been provided. The namespace + prefix in question can be obtained using the prefix + function. +

+ +

3.4 Reading from a Local File or URI

+ +

Using a local file or URI is the simplest way to parse an XML instance. + For example:

+ +
+using std::unique_ptr;
+
+unique_ptr<type> r1 (name ("test.xml"));
+unique_ptr<type> r2 (name ("https://www.codesynthesis.com/test.xml"));
+  
+ +

Or, in the C++98 mode:

+ +
+using std::auto_ptr;
+
+auto_ptr<type> r1 (name ("test.xml"));
+auto_ptr<type> r2 (name ("https://www.codesynthesis.com/test.xml"));
+  
+ +

3.5 Reading from std::istream

+ +

When using an std::istream instance, you may also + pass an optional resource id. This id is used to identify the + resource (for example in error messages) as well as to resolve + relative paths. For instance:

+ +
+using std::unique_ptr;
+
+{
+  std::ifstream ifs ("test.xml");
+  unique_ptr<type> r (name (ifs, "test.xml"));
+}
+
+{
+  std::string str ("..."); // Some XML fragment.
+  std::istringstream iss (str);
+  unique_ptr<type> r (name (iss));
+}
+  
+ +

3.6 Reading from xercesc::InputSource

+ +

Reading from a xercesc::InputSource instance + is similar to the std::istream case except + the resource id is maintained by the InputSource + object. For instance:

+ +
+xercesc::StdInInputSource is;
+std::unique_ptr<type> r (name (is));
+  
+ +

3.7 Reading from DOM

+ +

Reading from a xercesc::DOMDocument instance allows + you to setup a custom XML-DOM stage. Things like DOM + parser reuse, schema pre-parsing, and schema caching can be achieved + with this approach. For more information on how to obtain DOM + representation from an XML instance refer to the Xerces-C++ + documentation. In addition, the + C++/Tree Mapping + FAQ shows how to parse an XML instance to a Xerces-C++ + DOM document using the XSD runtime utilities. +

+ +

The last parsing function is useful when you would like to perform + your own XML-to-DOM parsing and associate the resulting DOM document + with the object model nodes. The automatic DOMDocument + pointer is reset and the resulting object model assumes ownership + of the DOM document passed. For example:

+ +
+// C++11 version.
+//
+xml_schema::dom::unique_ptr<xercesc::DOMDocument> doc = ...
+
+std::unique_ptr<type> r (
+  name (std::move (doc),
+        xml_schema::flags::keep_dom | xml_schema::flags::own_dom));
+
+// At this point doc is reset to 0.
+
+// C++98 version.
+//
+xml_schema::dom::auto_ptr<xercesc::DOMDocument> doc = ...
+
+std::auto_ptr<type> r (
+  name (doc, xml_schema::flags::keep_dom | xml_schema::flags::own_dom));
+
+// At this point doc is reset to 0.
+  
+ +

4 Serialization

+ +

This chapter covers various aspects of serializing a + tree-like object model to DOM or XML. + In this regard, serialization is complimentary to the reverse + process of parsing a DOM or XML instance into an object model + which is discussed in Chapter 3, + "Parsing". Note that the generation of the serialization code + is optional and should be explicitly requested with the + --generate-serialization option. See the + XSD + Compiler Command Line Manual for more information. +

+ +

Each global XML Schema element in the form: +

+ + +
+<xsd:element name="name" type="type"/>
+  
+ +

is mapped to 8 overloaded C++ functions in the form:

+ +
+// Serialize to std::ostream.
+//
+void
+name (std::ostream&,
+      const type&,
+      const xml_schema::namespace_fomap& =
+        xml_schema::namespace_infomap (),
+      const std::basic_string<C>& encoding = "UTF-8",
+      xml_schema::flags = 0);
+
+void
+name (std::ostream&,
+      const type&,
+      xml_schema::error_handler&,
+      const xml_schema::namespace_infomap& =
+        xml_schema::namespace_infomap (),
+      const std::basic_string<C>& encoding = "UTF-8",
+      xml_schema::flags = 0);
+
+void
+name (std::ostream&,
+      const type&,
+      xercesc::DOMErrorHandler&,
+      const xml_schema::namespace_infomap& =
+        xml_schema::namespace_infomap (),
+      const std::basic_string<C>& encoding = "UTF-8",
+      xml_schema::flags = 0);
+
+
+// Serialize to XMLFormatTarget.
+//
+void
+name (xercesc::XMLFormatTarget&,
+      const type&,
+      const xml_schema::namespace_infomap& =
+        xml_schema::namespace_infomap (),
+      const std::basic_string<C>& encoding = "UTF-8",
+      xml_schema::flags = 0);
+
+void
+name (xercesc::XMLFormatTarget&,
+      const type&,
+      xml_schema::error_handler&,
+      const xml_schema::namespace_infomap& =
+        xml_schema::namespace_infomap (),
+      const std::basic_string<C>& encoding = "UTF-8",
+      xml_schema::flags = 0);
+
+void
+name (xercesc::XMLFormatTarget&,
+      const type&,
+      xercesc::DOMErrorHandler&,
+      const xml_schema::namespace_infomap& =
+        xml_schema::namespace_infomap (),
+      const std::basic_string<C>& encoding = "UTF-8",
+      xml_schema::flags = 0);
+
+
+// Serialize to DOM.
+//
+xml_schema::dom::[unique|auto]_ptr<xercesc::DOMDocument>
+name (const type&,
+      const xml_schema::namespace_infomap&
+        xml_schema::namespace_infomap (),
+      xml_schema::flags = 0);
+
+void
+name (xercesc::DOMDocument&,
+      const type&,
+      xml_schema::flags = 0);
+  
+ +

You can choose between writing XML to std::ostream or + xercesc::XMLFormatTarget and creating a DOM instance + in the form of xercesc::DOMDocument. Serialization + to ostream or XMLFormatTarget requires a + considerably less work while serialization to DOM provides + for greater flexibility. Each of these serialization functions + is discussed in more detail in the following sections. +

+ + +

4.1 Initializing the Xerces-C++ Runtime

+ +

Some serialization functions expect you to initialize the Xerces-C++ + runtime while others initialize and terminate it as part of their + work. The general rule is as follows: if a function has any arguments + or return a value that is an instance of a Xerces-C++ type, then + this function expects you to initialize the Xerces-C++ runtime. + Otherwise, the function initializes and terminates the runtime for + you. Note that it is legal to have nested calls to the Xerces-C++ + initialize and terminate functions as long as the calls are balanced. +

+ +

You can instruct serialization functions that initialize and terminate + the runtime not to do so by passing the + xml_schema::flags::dont_initialize flag (see + Section 4.3, "Flags"). +

+ +

4.2 Namespace Infomap and Character Encoding

+ +

When a document being serialized uses XML namespaces, custom + prefix-namespace associations can to be established. If custom + prefix-namespace mapping is not provided then generic prefixes + (p1, p2, etc) are automatically assigned + to namespaces as needed. Also, if + you would like the resulting instance document to contain the + schemaLocation or noNamespaceSchemaLocation + attributes, you will need to provide namespace-schema associations. + The xml_schema::namespace_infomap class is used + to capture this information:

+ +
+struct namespace_info
+{
+  namespace_info ();
+  namespace_info (const std::basic_string<C>& name,
+                  const std::basic_string<C>& schema);
+
+  std::basic_string<C> name;
+  std::basic_string<C> schema;
+};
+
+// Map of namespace prefix to namespace_info.
+//
+struct namespace_infomap: public std::map<std::basic_string<C>,
+                                          namespace_info>
+{
+};
+  
+ +

Consider the following associations as an example:

+ +
+xml_schema::namespace_infomap map;
+
+map["t"].name = "https://www.codesynthesis.com/test";
+map["t"].schema = "test.xsd";
+  
+ +

This map, if passed to one of the serialization functions, + could result in the following XML fragment:

+ +
+<?xml version="1.0" ?>
+<t:name xmlns:t="https://www.codesynthesis.com/test"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="https://www.codesynthesis.com/test test.xsd">
+  
+ +

As you can see, the serialization function automatically added namespace + mapping for the xsi prefix. You can change this by + providing your own prefix:

+ +
+xml_schema::namespace_infomap map;
+
+map["xsn"].name = "http://www.w3.org/2001/XMLSchema-instance";
+
+map["t"].name = "https://www.codesynthesis.com/test";
+map["t"].schema = "test.xsd";
+  
+ +

This could result in the following XML fragment:

+ +
+<?xml version="1.0" ?>
+<t:name xmlns:t="https://www.codesynthesis.com/test"
+        xmlns:xsn="http://www.w3.org/2001/XMLSchema-instance"
+        xsn:schemaLocation="https://www.codesynthesis.com/test test.xsd">
+  
+ +

To specify the location of a schema without a namespace you can use + an empty prefix as in the example below:

+ +
+xml_schema::namespace_infomap map;
+
+map[""].schema = "test.xsd";
+  
+ +

This would result in the following XML fragment:

+ +
+<?xml version="1.0" ?>
+<name xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xsi:noNamespaceSchemaLocation="test.xsd">
+  
+ +

To make a particular namespace default you can use an empty + prefix, for example:

+ +
+xml_schema::namespace_infomap map;
+
+map[""].name = "https://www.codesynthesis.com/test";
+map[""].schema = "test.xsd";
+  
+ +

This could result in the following XML fragment:

+ +
+<?xml version="1.0" ?>
+<name xmlns="https://www.codesynthesis.com/test"
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xsi:schemaLocation="https://www.codesynthesis.com/test test.xsd">
+  
+ + +

Another bit of information that you can pass to the serialization + functions is the character encoding method that you would like to use. + Common values for this argument are "US-ASCII", + "ISO8859-1", "UTF-8", + "UTF-16BE", "UTF-16LE", + "UCS-4BE", and "UCS-4LE". The default + encoding is "UTF-8". For more information on + encoding methods see the + "Character + Encoding" article from Wikipedia. +

+ +

4.3 Flags

+ +

Serialization flags are the last argument of every serialization + function. They allow you to fine-tune the process of serialization. + The flags argument is optional. +

+ + +

The following flags are recognized by the serialization + functions:

+ +
+
xml_schema::flags::dont_initialize
+
Do not initialize the Xerces-C++ runtime.
+ +
xml_schema::flags::dont_pretty_print
+
Do not add extra spaces or new lines that make the resulting XML + slightly bigger but easier to read.
+ +
xml_schema::flags::no_xml_declaration
+
Do not write XML declaration (<?xml ... ?>).
+
+ +

You can pass several flags by combining them using the bit-wise OR + operator. For example:

+ +
+std::unique_ptr<type> r = ...
+std::ofstream ofs ("test.xml");
+xml_schema::namespace_infomap map;
+name (ofs,
+      *r,
+      map,
+      "UTF-8",
+      xml_schema::flags::no_xml_declaration |
+      xml_schema::flags::dont_pretty_print);
+  
+ +

For more information on the Xerces-C++ runtime initialization + refer to Section 4.1, "Initializing the Xerces-C++ + Runtime". +

+ +

4.4 Error Handling

+ +

As with the parsing functions (see Section 3.3, + "Error Handling"), to better understand error handling and + reporting strategies employed by the serialization functions, it + is useful to know that the transformation of a statically-typed + tree to an XML instance document happens in two stages. The first + stage, performed by the generated code, consist of building a DOM + instance from the statically-typed tree . For short, we will call + this stage the Tree-DOM stage. The second stage, performed by + Xerces-C++, consists of serializing the DOM instance into the XML + document. We will call this stage the DOM-XML stage. +

+ +

All serialization functions except the two that serialize into + a DOM instance come in overloaded triples. The first function + in such a triple reports error conditions exclusively by throwing + exceptions. It accumulates all the serialization errors of the + DOM-XML stage and throws them in a single instance of the + xml_schema::serialization exception (described below). + The second and the third functions in the triple use callback + interfaces to report serialization errors and warnings. The two + callback interfaces are xml_schema::error_handler and + xercesc::DOMErrorHandler. The + xml_schema::error_handler interface is described in + Section 3.3, "Error Handling". For more information + on the xercesc::DOMErrorHandler interface refer to the + Xerces-C++ documentation. +

+ +

The Tree-DOM stage reports error conditions exclusively by throwing + exceptions. Individual exceptions thrown by the serialization functions + are described in the following sub-sections. +

+ +

4.4.1 xml_schema::serialization

+ +
+struct serialization: virtual exception
+{
+  serialization ();
+  serialization (const diagnostics&);
+
+  const diagnostics&
+  diagnostics () const;
+
+  virtual const char*
+  what () const throw ();
+};
+  
+ +

The xml_schema::diagnostics class is described in + Section 3.3.1, "xml_schema::parsing". + The xml_schema::serialization exception is thrown if + there were serialization errors reported during the DOM-XML stage. + If no callback interface was provided to the serialization function, + the exception contains a list of errors and warnings accessible using + the diagnostics function. +

+ + +

4.4.2 xml_schema::unexpected_element

+ +

The xml_schema::unexpected_element exception is + described in Section 3.3.3, + "xml_schema::unexpected_element". It is thrown + by the serialization functions during the Tree-DOM stage if the + root element name of the provided DOM instance does not match with + the name of the element this serialization function is for. +

+ +

4.4.3 xml_schema::no_type_info

+ +

The xml_schema::no_type_info exception is + described in Section 3.3.7, + "xml_schema::no_type_info". It is thrown + by the serialization functions during the Tree-DOM stage when there + is no type information associated with a dynamic type of an + element. Usually, catching this exception means that you haven't + linked the code generated from the schema defining the type in + question with your application or this schema has been compiled + without the --generate-polymorphic option. +

+ +

4.5 Serializing to std::ostream

+ +

In order to serialize to std::ostream you will need + an object model, an output stream and, optionally, a namespace + infomap. For instance:

+ +
+// Obtain the object model.
+//
+std::unique_ptr<type> r = ...
+
+// Prepare namespace mapping and schema location information.
+//
+xml_schema::namespace_infomap map;
+
+map["t"].name = "https://www.codesynthesis.com/test";
+map["t"].schema = "test.xsd";
+
+// Write it out.
+//
+name (std::cout, *r, map);
+  
+ +

Note that the output stream is treated as a binary stream. This + becomes important when you use a character encoding that is wider + than 8-bit char, for instance UTF-16 or UCS-4. For + example, things will most likely break if you try to serialize + to std::ostringstream with UTF-16 or UCS-4 as an + encoding. This is due to the special value, + '\0', that will most likely occur as part of such + serialization and it won't have the special meaning assumed by + std::ostringstream. +

+ + +

4.6 Serializing to xercesc::XMLFormatTarget

+ +

Serializing to an xercesc::XMLFormatTarget instance + is similar the std::ostream case. For instance: +

+ +
+using std::unique_ptr;
+
+// Obtain the object model.
+//
+unique_ptr<type> r = ...
+
+// Prepare namespace mapping and schema location information.
+//
+xml_schema::namespace_infomap map;
+
+map["t"].name = "https://www.codesynthesis.com/test";
+map["t"].schema = "test.xsd";
+
+using namespace xercesc;
+
+XMLPlatformUtils::Initialize ();
+
+{
+  // Choose a target.
+  //
+  unique_ptr<XMLFormatTarget> ft;
+
+  if (argc != 2)
+  {
+    ft = unique_ptr<XMLFormatTarget> (new StdOutFormatTarget ());
+  }
+  else
+  {
+    ft = unique_ptr<XMLFormatTarget> (
+      new LocalFileFormatTarget (argv[1]));
+  }
+
+  // Write it out.
+  //
+  name (*ft, *r, map);
+}
+
+XMLPlatformUtils::Terminate ();
+  
+ +

Note that we had to initialize the Xerces-C++ runtime before we + could call this serialization function.

+ +

4.7 Serializing to DOM

+ +

The mapping provides two overloaded functions that implement + serialization to a DOM instance. The first creates a DOM instance + for you and the second serializes to an existing DOM instance. + While serializing to a new DOM instance is similar to serializing + to std::ostream or xercesc::XMLFormatTarget, + serializing to an existing DOM instance requires quite a bit of work + from your side. You will need to set all the custom namespace mapping + attributes as well as the schemaLocation and/or + noNamespaceSchemaLocation attributes. The following + listing should give you an idea about what needs to be done: +

+ +
+// Obtain the object model.
+//
+std::unique_ptr<type> r = ...
+
+using namespace xercesc;
+
+XMLPlatformUtils::Initialize ();
+
+{
+  // Create a DOM instance. Set custom namespace mapping and schema
+  // location attributes.
+  //
+  DOMDocument& doc = ...
+
+  // Serialize to DOM.
+  //
+  name (doc, *r);
+
+  // Serialize the DOM document to XML.
+  //
+  ...
+}
+
+XMLPlatformUtils::Terminate ();
+  
+ +

For more information on how to create and serialize a DOM instance + refer to the Xerces-C++ documentation. In addition, the + C++/Tree Mapping + FAQ shows how to implement these operations using the XSD + runtime utilities. +

+ +

5 Additional Functionality

+ +

The C++/Tree mapping provides a number of optional features + that can be useful in certain situations. They are described + in the following sections.

+ +

5.1 DOM Association

+ +

Normally, after parsing is complete, the DOM document which + was used to extract the data is discarded. However, the parsing + functions can be instructed to preserve the DOM document + and create an association between the DOM nodes and object model + nodes. When there is an association between the DOM and + object model nodes, you can obtain the corresponding DOM element + or attribute node from an object model node as well as perform + the reverse transition: obtain the corresponding object model + from a DOM element or attribute node.

+ +

Maintaining DOM association is normally useful when the application + needs access to XML constructs that are not preserved in the + object model, for example, XML comments. + Another useful aspect of DOM association is the ability of the + application to navigate the document tree using the generic DOM + interface (for example, with the help of an XPath processor) + and then move back to the statically-typed object model. Note + also that while you can change the underlying DOM document, + these changes are not reflected in the object model and will + be ignored during serialization. If you need to not only access + but also modify some aspects of XML that are not preserved in + the object model, then type customization with custom parsing + constructors and serialization operators should be used instead.

+ +

To request DOM association you will need to pass the + xml_schema::flags::keep_dom flag to one of the + parsing functions (see Section 3.2, + "Flags and Properties" for more information). In this case the + DOM document is retained and will be released when the object model + is deleted. Note that since DOM nodes "out-live" the parsing function + call, you need to initialize the Xerces-C++ runtime before calling + one of the parsing functions with the keep_dom flag and + terminate it after the object model is destroyed (see + Section 3.1, "Initializing the Xerces-C++ Runtime").

+ +

If the keep_dom flag is passed + as the second argument to the copy constructor and the copy + being made is of a complete tree, then the DOM association + is also maintained in the copy by cloning the underlying + DOM document and reestablishing the associations. For example:

+ +
+using namespace xercesc;
+
+XMLPlatformUtils::Initialize ();
+
+{
+  // Parse XML to object model.
+  //
+  std::unique_ptr<type> r (root (
+    "root.xml",
+     xml_schema::flags::keep_dom |
+     xml_schema::flags::dont_initialize));
+
+   // Copy without DOM association.
+   //
+   type copy1 (*r);
+
+   // Copy with DOM association.
+   //
+   type copy2 (*r, xml_schema::flags::keep_dom);
+}
+
+XMLPlatformUtils::Terminate ();
+  
+ + +

To obtain the corresponding DOM node from an object model node + you will need to call the _node accessor function + which returns a pointer to DOMNode. You can then query + this DOM node's type and cast it to either DOMAttr* + or DOMElement*. To obtain the corresponding object + model node from a DOM node, the DOM user data API is used. The + xml_schema::dom::tree_node_key variable contains + the key for object model nodes. The following schema and code + fragment show how to navigate from DOM to object model nodes + and in the opposite direction:

+ +
+<complexType name="object">
+  <sequence>
+    <element name="a" type="string"/>
+  </sequence>
+</complexType>
+
+<element name="root" type="object"/>
+  
+ +
+using namespace xercesc;
+
+XMLPlatformUtils::Initialize ();
+
+{
+  // Parse XML to object model.
+  //
+  std::unique_ptr<type> r (root (
+    "root.xml",
+     xml_schema::flags::keep_dom |
+     xml_schema::flags::dont_initialize));
+
+  DOMNode* n = r->_node ();
+  assert (n->getNodeType () == DOMNode::ELEMENT_NODE);
+  DOMElement* re = static_cast<DOMElement*> (n);
+
+  // Get the 'a' element. Note that it is not necessarily the
+  // first child node of 'root' since there could be whitespace
+  // nodes before it.
+  //
+  DOMElement* ae;
+
+  for (n = re->getFirstChild (); n != 0; n = n->getNextSibling ())
+  {
+    if (n->getNodeType () == DOMNode::ELEMENT_NODE)
+    {
+      ae = static_cast<DOMElement*> (n);
+      break;
+    }
+  }
+
+  // Get from the 'a' DOM element to xml_schema::string object model
+  // node.
+  //
+  xml_schema::type& t (
+    *reinterpret_cast<xml_schema::type*> (
+       ae->getUserData (xml_schema::dom::tree_node_key)));
+
+  xml_schema::string& a (dynamic_cast<xml_schema::string&> (t));
+}
+
+XMLPlatformUtils::Terminate ();
+  
+ +

The 'mixed' example which can be found in the XSD distribution + shows how to handle the mixed content using DOM association.

+ +

5.2 Binary Serialization

+ +

Besides reading from and writing to XML, the C++/Tree mapping + also allows you to save the object model to and load it from a + number of predefined as well as custom data representation + formats. The predefined binary formats are CDR (Common Data + Representation) and XDR (eXternal Data Representation). A + custom format can easily be supported by providing + insertion and extraction operators for basic types.

+ +

Binary serialization saves only the data without any meta + information or markup. As a result, saving to and loading + from a binary representation can be an order of magnitude + faster than parsing and serializing the same data in XML. + Furthermore, the resulting representation is normally several + times smaller than the equivalent XML representation. These + properties make binary serialization ideal for internal data + exchange and storage. A typical application that uses this + facility stores the data and communicates within the + system using a binary format and reads/writes the data + in XML when communicating with the outside world.

+ +

In order to request the generation of insertion operators and + extraction constructors for a specific predefined or custom + data representation stream, you will need to use the + --generate-insertion and --generate-extraction + compiler options. See the + XSD + Compiler Command Line Manual for more information.

+ +

Once the insertion operators and extraction constructors are + generated, you can use the xml_schema::istream + and xml_schema::ostream wrapper stream templates + to save the object model to and load it from a specific format. + The following code fragment shows how to do this using ACE + (Adaptive Communication Environment) CDR streams as an example:

+ +
+<complexType name="object">
+  <sequence>
+    <element name="a" type="string"/>
+    <element name="b" type="int"/>
+  </sequence>
+</complexType>
+
+<element name="root" type="object"/>
+  
+ +
+// Parse XML to object model.
+//
+std::unique_ptr<type> r (root ("root.xml"));
+
+// Save to a CDR stream.
+//
+ACE_OutputCDR ace_ocdr;
+xml_schema::ostream<ACE_OutputCDR> ocdr (ace_ocdr);
+
+ocdr << *r;
+
+// Load from a CDR stream.
+//
+ACE_InputCDR ace_icdr (buf, size);
+xml_schema::istream<ACE_InputCDR> icdr (ace_icdr);
+
+std::unique_ptr<object> copy (new object (icdr));
+
+// Serialize to XML.
+//
+root (std::cout, *copy);
+  
+ +

The XSD distribution contains a number of examples that + show how to save the object model to and load it from + CDR, XDR, and a custom format.

+ + + + +

Appendix A — Default and Fixed Values

+ +

The following table summarizes the effect of default and fixed + values (specified with the default and fixed + attributes, respectively) on attribute and element values. The + default and fixed attributes are mutually + exclusive. It is also worthwhile to note that the fixed value semantics + is a superset of the default value semantics. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
defaultfixed
elementnot presentoptionalrequiredoptionalrequired
not presentinvalid instancenot presentinvalid instance
emptydefault value is usedfixed value is used
valuevalue is usedvalue is used provided it's the same as fixed
attributenot presentoptionalrequiredoptionalrequired
default value is usedinvalid schemafixed value is usedinvalid instance
emptyempty value is usedempty value is used provided it's the same as fixed
valuevalue is usedvalue is used provided it's the same as fixed
+ +
+
+ + + + diff --git a/xsd/doc/cxx/tree/manual/manual.html2ps.in b/xsd/doc/cxx/tree/manual/manual.html2ps.in new file mode 100644 index 0000000..5629122 --- /dev/null +++ b/xsd/doc/cxx/tree/manual/manual.html2ps.in @@ -0,0 +1,66 @@ +@@html2ps { + option { + toc: hb; + colour: 1; + hyphenate: 1; + titlepage: 1; + } + + datefmt: "%B %Y"; + + titlepage { + content: " +
+

C++/Tree Mapping User Manual

+

 

+

 

+

 

+

 

+

 

+

 

+

 

+
+

Revision $[revision]     $D

+

Copyright © @copyright@.

+ +

Permission is granted to copy, distribute and/or modify this + document under the terms of the + GNU Free + Documentation License, version 1.2; with no Invariant Sections, + no Front-Cover Texts and no Back-Cover Texts. +

+ +

This document is available in the following formats: + XHTML, + PDF, and + PostScript.

"; + } + + toc { + indent: 2em; + } + + header { + odd-right: $H; + even-left: $H; + } + + footer { + odd-left: $D; + odd-center: $T, v$[revision]; + odd-right: $N; + + even-left: $N; + even-center: $T, v$[revision]; + even-right: $D; + } +} + +body { + font-size: 12pt; + text-align: justify; +} + +pre { + font-size: 10pt; +} diff --git a/xsd/doc/default.css b/xsd/doc/default.css new file mode 100644 index 0000000..bb3805b --- /dev/null +++ b/xsd/doc/default.css @@ -0,0 +1,319 @@ +html { + margin : 0; + padding : 0; + background : white; +} + +body { + font-family : "Lucida Grande", Verdana, "Bitstream Vera Sans", sans-serif; + font-weight : normal; + font-size : 13px; + line-height : 19px; + + color : black; + + margin : 0 2em 0 2em; + padding : 0; +} + + +body { + min-width: 40em; +} + +#container { + max-width : 46em; + margin : 0 auto; + padding : 0 1em 0 1em; +} + + + +/* + * Footer + * + */ +#footer { + color : #3a84a7; + + padding : 1em 0 0.5em 0; + + font-size : 10px; + line-height : 15px; + + text-align: center; +} + +#footer a:link, #footer a:visited { + + color:#1d6699; + text-decoration: underline; +} + +#footer a { + margin-left: 0.7em; + margin-right: 0.7em; +} + +#footer p { + padding: 0; + margin: 0.3em 0 0 0; +} + +/* Distribution terms. */ +#footer #terms { + text-align: justify; + + font-size : 110%; + font-family : monospace; + + padding : 1em 0 0.5em 0; +} + + +/* + * Content + * + */ + +#content { + padding : 0em 0.1em 0 1.3em; + margin : 1.4em 0 0 0; +} + +#content p, +#content ol, +#content ul, +#content dl { + text-align: justify; +} + +#content h1 { + margin-left: -0.89em; +} + +a:link { + color:#0536d2; +} + + +/* + * Headings + * + */ + +h1, h2, h3, h4, h5, h6 { + font-weight : 500; +} + +h1 { font-size : 155%; } +h2 { font-size : 130%; } +h3 { font-size : 125%; } +h4 { font-size : 110%; } +h5 { font-size : 106%; } +h6 { font-size : 100%; } + +h1 { margin : 1.8em 0 0.8em 0;} +h2 { margin-top : 1.4em;} +h3 { margin-top : 1em;} + +p.indent { + margin-left : 1.5em; +} + + +/* + * Fix for IE 5.5 table font problem + * + */ + +table { + font-size : 13px; +} + + +/* + * table of content + * + */ + +ul.toc li { + padding : .4em 0em 0em 0em; +} + + +/* Toc links don't need to show when they are visited. */ +.toc a:visited { + color:#0536d2; +} + + +/* + * lists + * + */ + + +/* list of links */ +ul.menu { + list-style-type : none; +} + +ul.menu li { + padding-top : 0.3em; + padding-bottom : 0.3em; +} + + + +/* @@ I should probably use child selector here */ +/* list with multiline list-elements */ +ul.multiline li, ol.multiline li, dl.multiline dd { + padding-top : 0.16em; + padding-bottom : 0.16em; + + font-size : 11px; + line-height : 15px; +} + + + +/* C++ code snippet */ +pre.cxx { + margin-top : 0em; + margin-bottom : 2em; + + margin-left : 1em; +} + + + +/* make code snippet */ +pre.make { + margin-top : 0em; + margin-bottom : 2em; + + margin-left : 1em; +} + + + +/* terminal output */ +pre.term { + margin-top : 0em; + margin-bottom : 2em; + + margin-left : 1em; +} + + +/* Images */ +div.center { + text-align: center; +} + +/* Document info. */ +#docinfo { + margin-top: 4em; + border-top: 1px dashed #000000; + font-size: 70%; +} + + +/* Footnote */ + +#footnote { + margin-top : 2.5em; +} + +#footnote hr, hr.footnote { + margin-left: 0; + margin-bottom: 0.6em; + width: 8em; + border-top: 1px solid #000000; + border-right: none; + border-bottom: none; + border-left: none; + +} + +#footnote ol { + margin-left: 0; + padding-left: 1.45em; +} + +#footnote li { + text-align : left; + font-size : 11px; + line-height : 15px; + + padding : .4em 0 .4em 0; +} + + +/* Normal table with borders, etc. */ + +table.std { + margin: 2em 0 2em 0; + + border-collapse : collapse; + border : 1px solid; + border-color : #000000; + + font-size : 11px; + line-height : 14px; +} + +table.std th, table.std td { + border : 1px solid; + padding : 0.6em 0.8em 0.6em 0.8em; +} + +table.std th { + background : #cde8f6; +} + +table.std td { + text-align: left; +} + + +/* + * "item | description" table. + * + */ + +table.description { + border-style : none; + border-collapse : separate; + border-spacing : 0; + + font-size : 13px; + + margin : 0.6em 0 0.6em 0; + padding : 0 0 0 0; +} + +table.description tr { + padding : 0 0 0 0; + margin : 0 0 0 0; +} + +table.description * td, table.description * th { + border-style : none; + margin : 0 0 0 0; + vertical-align : top; +} + +table.description * th { + font-weight : normal; + padding : 0.4em 1em 0.4em 0; + text-align : left; + white-space : nowrap; + background : none; +} + +table.description * td { + padding : 0.4em 0 0.4em 1em; + text-align : justify; +} diff --git a/xsd/doc/xsd-epilogue.1 b/xsd/doc/xsd-epilogue.1 new file mode 100644 index 0000000..192880c --- /dev/null +++ b/xsd/doc/xsd-epilogue.1 @@ -0,0 +1,566 @@ +\" +\" NAMING CONVENTION +\" + +.SH NAMING CONVENTION +The compiler can be instructed to use a particular naming convention in +the generated code. A number of widely-used conventions can be selected +using the +.B --type-naming +and +.B --function-naming +options. A custom naming convention can be achieved using the +.BR --type-regex , +.BR --accessor-regex , +.BR --one-accessor-regex , +.BR --opt-accessor-regex , +.BR --seq-accessor-regex , +.BR --modifier-regex , +.BR --one-modifier-regex , +.BR --opt-modifier-regex , +.BR --seq-modifier-regex , +.BR --parser-regex , +.BR --serializer-regex , +.BR --const-regex , +.BR --enumerator-regex , +and +.B --element-type-regex +options. + +The +.B --type-naming +option specifies the convention that should be used for naming C++ types. +Possible values for this option are +.B knr +(default), +.BR ucc , +and +.BR java . +The +.B knr +value (stands for K&R) signifies the standard, lower-case naming convention +with the underscore used as a word delimiter, for example: foo, foo_bar. +The +.B ucc +(stands for upper-camel-case) and +.B java +values a synonyms for the same naming convention where the first letter +of each word in the name is capitalized, for example: Foo, FooBar. + +Similarly, the +.B --function-naming +option specifies the convention that should be used for naming C++ functions. +Possible values for this option are +.B knr +(default), +.BR lcc , +and +.BR java . +The +.B knr +value (stands for K&R) signifies the standard, lower-case naming convention +with the underscore used as a word delimiter, for example: foo(), foo_bar(). +The +.B lcc +value (stands for lower-camel-case) signifies a naming convention where the +first letter of each word except the first is capitalized, for example: foo(), +fooBar(). The +.B java +naming convention is similar to the lower-camel-case one except that accessor +functions are prefixed with get, modifier functions are prefixed with set, +parsing functions are prefixed with parse, and serialization functions are +prefixed with serialize, for example: getFoo(), setFooBar(), parseRoot(), +serializeRoot(). + +Note that the naming conventions specified with the +.B --type-naming +and +.B --function-naming +options perform only limited transformations on the +names that come from the schema in the form of type, attribute, and element +names. In other words, to get consistent results, your schemas should follow +a similar naming convention as the one you would like to have in the generated +code. Alternatively, you can use the +.B --*-regex +options (discussed below) to perform further transformations on the names +that come from the schema. + +The +.BR --type-regex , +.BR --accessor-regex , +.BR --one-accessor-regex , +.BR --opt-accessor-regex , +.BR --seq-accessor-regex , +.BR --modifier-regex , +.BR --one-modifier-regex , +.BR --opt-modifier-regex , +.BR --seq-modifier-regex , +.BR --parser-regex , +.BR --serializer-regex , +.BR --const-regex , +.BR --enumerator-regex , +and +.B --element-type-regex +options allow you to specify extra regular expressions for each name +category in addition to the predefined set that is added depending on +the +.B --type-naming +and +.B --function-naming +options. Expressions that are provided with the +.B --*-regex +options are evaluated prior to any predefined expressions. This allows +you to selectively override some or all of the predefined transformations. +When debugging your own expressions, it is often useful to see which +expressions match which names. The +.B --name-regex-trace +option allows you to trace the process of applying +regular expressions to names. + +The value for the +.B --*-regex +options should be a perl-like regular expression in the form +.BI / pattern / replacement /\fR. +Any character can be used as a delimiter instead of +.BR / . +Escaping of the delimiter character in +.I pattern +or +.I replacement +is not supported. All the regular expressions for each category are pushed +into a category-specific stack with the last specified expression +considered first. The first match that succeeds is used. For the +.B --one-accessor-regex +(accessors with cardinality one), +.B --opt-accessor-regex +(accessors with cardinality optional), and +.B --seq-accessor-regex +(accessors with cardinality sequence) categories the +.B --accessor-regex +expressions are used as a fallback. For the +.BR --one-modifier-regex , +.BR --opt-modifier-regex , +and +.B --seq-modifier-regex +categories the +.B --modifier-regex +expressions are used as a fallback. For the +.B --element-type-regex +category the +.B --type-regex +expressions are used as a fallback. + +The type name expressions +.RB ( --type-regex ) +are evaluated on the name string that has the following format: + +[\fInamespace \fR]\fIname\fR[\fB,\fIname\fR][\fB,\fIname\fR][\fB,\fIname\fR] + +The element type name expressions +.RB ( --element-type-regex ), +effective only when the +.B --generate-element-type +option is specified, are evaluated on the name string that has the following +format: + +.I namespace name + +In the type name format the +.I namespace +part followed by a space is only present for global type names. For global +types and elements defined in schemas without a target namespace, the +.I namespace +part is empty but the space is still present. In the type name format after +the initial +.I name +component, up to three additional +.I name +components can be present, separated by commas. For example: + +.B http://example.com/hello type + +.B foo + +.B foo,iterator + +.B foo,const,iterator + +The following set of predefined regular expressions is used to transform +type names when the upper-camel-case naming convention is selected: + +.B /(?:[^ ]* )?([^,]+)/\\\\u$1/ + +.B /(?:[^ ]* )?([^,]+),([^,]+)/\\\\u$1\\\\u$2/ + +.B /(?:[^ ]* )?([^,]+),([^,]+),([^,]+)/\\\\u$1\\\\u$2\\\\u$3/ + +.B /(?:[^ ]* )?([^,]+),([^,]+),([^,]+),([^,]+)/\\\\u$1\\\\u$2\\\\u$3\\\\u$4/ + +The accessor and modifier expressions +.RB ( --*accessor-regex +and +.BR --*modifier-regex ) +are evaluated on the name string that has the following format: + +\fIname\fR[\fB,\fIname\fR][\fB,\fIname\fR] + +After the initial +.I name +component, up to two additional +.I name +components can be present, separated by commas. For example: + +.B foo + +.B dom,document + +.B foo,default,value + +The following set of predefined regular expressions is used to transform +accessor names when the +.B java +naming convention is selected: + +.B /([^,]+)/get\\\\u$1/ + +.B /([^,]+),([^,]+)/get\\\\u$1\\\\u$2/ + +.B /([^,]+),([^,]+),([^,]+)/get\\\\u$1\\\\u$2\\\\u$3/ + +For the parser, serializer, and enumerator categories, the corresponding +regular expressions are evaluated on local names of elements and on +enumeration values, respectively. For example, the following predefined +regular expression is used to transform parsing function names when the +.B java +naming convention is selected: + +.B /(.+)/parse\\\\u$1/ + +The const category is used to create C++ constant names for the +element/wildcard/text content ids in ordered types. + +See also the REGEX AND SHELL QUOTING section below. + +\" +\" TYPE MAP +\" +.SH TYPE MAP +Type map files are used in C++/Parser to define a mapping between XML +Schema and C++ types. The compiler uses this information to determine +the return types of +.B post_* +functions in parser skeletons corresponding to XML Schema types +as well as argument types for callbacks corresponding to elements +and attributes of these types. + +The compiler has a set of predefined mapping rules that map built-in +XML Schema types to suitable C++ types (discussed below) and all +other types to +.BR void . +By providing your own type maps you can override these predefined rules. +The format of the type map file is presented below: + +.RS +.B namespace +.I schema-namespace +[ +.I cxx-namespace +] +.br +.B { +.br + ( +.B include +.IB file-name ; +)* +.br + ([ +.B type +] +.I schema-type cxx-ret-type +[ +.I cxx-arg-type +.RB ] ; +)* +.br +.B } +.br +.RE + +Both +.I schema-namespace +and +.I schema-type +are regex patterns while +.IR cxx-namespace , +.IR cxx-ret-type , +and +.I cxx-arg-type +are regex pattern substitutions. All names can be optionally enclosed +in \fR" "\fR, for example, to include white-spaces. + +.I schema-namespace +determines XML Schema namespace. Optional +.I cxx-namespace +is prefixed to every C++ type name in this namespace declaration. +.I cxx-ret-type +is a C++ type name that is used as a return type for the +.B post_* +functions. Optional +.I cxx-arg-type +is an argument type for callback functions corresponding to elements and +attributes of this type. If +.I cxx-arg-type +is not specified, it defaults to +.I cxx-ret-type +if +.I cxx-ret-type +ends with +.B * +or +.B & +(that is, it is a pointer or a reference) and +.B const +\fIcxx-ret-type\fB&\fR otherwise. +.I file-name +is a file name either in the \fR" "\fR or < > format and is added with the +.B #include +directive to the generated code. + +The \fB#\fR character starts a comment that ends with a new line or end of +file. To specify a name that contains \fB#\fR enclose it in \fR" "\fR. For +example: + +.RS +namespace http://www.example.com/xmlns/my my +.br +{ +.br + include "my.hxx"; +.br + + # Pass apples by value. + # + apple apple; +.br + + # Pass oranges as pointers. + # + orange orange_t*; +.br +} +.br +.RE + +In the example above, for the +.B http://www.example.com/xmlns/my#orange +XML Schema type, the +.B my::orange_t* +C++ type will be used as both return and argument types. + +Several namespace declarations can be specified in a single file. +The namespace declaration can also be completely omitted to map +types in a schema without a namespace. For instance: + +.RS +include "my.hxx"; +.br +apple apple; +.br + +namespace http://www.example.com/xmlns/my +.br +{ +.br + orange "const orange_t*"; +.br +} +.br +.RE + + +The compiler has a number of predefined mapping rules that can be +presented as the following map files. The string-based XML Schema +built-in types are mapped to either +.B std::string +or +.B std::wstring +depending on the character type selected with the +.B --char-type +option +.RB ( char +by default). + +.RS +namespace http://www.w3.org/2001/XMLSchema +.br +{ +.br + boolean bool bool; +.br + + byte "signed char" "signed char"; +.br + unsignedByte "unsigned char" "unsigned char"; +.br + + short short short; +.br + unsignedShort "unsigned short" "unsigned short"; +.br + + int int int; +.br + unsignedInt "unsigned int" "unsigned int"; +.br + + long "long long" "long long"; +.br + unsignedLong "unsigned long long" "unsigned long long"; +.br + + integer "long long" "long long"; +.br + + negativeInteger "long long" "long long"; +.br + nonPositiveInteger "long long" "long long"; +.br + + positiveInteger "unsigned long long" "unsigned long long"; +.br + nonNegativeInteger "unsigned long long" "unsigned long long"; +.br + + float float float; +.br + double double double; +.br + decimal double double; +.br + + string std::string; +.br + normalizedString std::string; +.br + token std::string; +.br + Name std::string; +.br + NMTOKEN std::string; +.br + NCName std::string; +.br + ID std::string; +.br + IDREF std::string; +.br + language std::string; +.br + anyURI std::string; +.br + + NMTOKENS xml_schema::string_sequence; +.br + IDREFS xml_schema::string_sequence; +.br + + QName xml_schema::qname; +.br + + base64Binary std::auto_ptr +.br + std::auto_ptr; +.br + hexBinary std::auto_ptr +.br + std::auto_ptr; +.br + + date xml_schema::date; +.br + dateTime xml_schema::date_time; +.br + duration xml_schema::duration; +.br + gDay xml_schema::gday; +.br + gMonth xml_schema::gmonth; +.br + gMonthDay xml_schema::gmonth_day; +.br + gYear xml_schema::gyear; +.br + gYearMonth xml_schema::gyear_month; +.br + time xml_schema::time; +.br +} +.br +.RE + + +The last predefined rule maps anything that wasn't mapped by previous +rules to +.BR void : + +.RS +namespace .* +.br +{ +.br + .* void void; +.br +} +.br +.RE + +When you provide your own type maps with the +.B --type-map +option, they are evaluated first. This allows you to selectively override +predefined rules. + +.\" +.\" REGEX AND SHELL QUOTING +.\" +.SH REGEX AND SHELL QUOTING +When entering a regular expression argument in the shell command line +it is often necessary to use quoting (enclosing the argument in " " +or ' ') in order to prevent the shell from interpreting certain +characters, for example, spaces as argument separators and $ as +variable expansions. + +Unfortunately it is hard to achieve this in a manner that is portable +across POSIX shells, such as those found on GNU/Linux and UNIX, and +Windows shell. For example, if you use " " for quoting you will get +a wrong result with POSIX shells if your expression contains $. The +standard way of dealing with this on POSIX systems is to use ' ' +instead. Unfortunately, Windows shell does not remove ' ' from +arguments when they are passed to applications. As a result you may +have to use ' ' for POSIX and " " for Windows ($ is not treated as +a special character on Windows). + +Alternatively, you can save regular expression options into a file, +one option per line, and use this file with the +.B --options-file +option. With this approach you don't need to worry about shell quoting. + +.\" +.\" DIAGNOSTICS +.\" +.SH DIAGNOSTICS +If the input file is not a valid W3C XML Schema definition, +.B xsd +will issue diagnostic messages to +.B STDERR +and exit with non-zero exit code. +.SH BUGS +Send bug reports to the xsd-users@codesynthesis.com mailing list. +.SH COPYRIGHT +Copyright (c) $copyright$. + +Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, +version 1.2; with no Invariant Sections, no Front-Cover Texts and +no Back-Cover Texts. Copy of the license can be obtained from +https://www.codesynthesis.com/licenses/fdl-1.2.txt diff --git a/xsd/doc/xsd-epilogue.xhtml b/xsd/doc/xsd-epilogue.xhtml new file mode 100644 index 0000000..aef0418 --- /dev/null +++ b/xsd/doc/xsd-epilogue.xhtml @@ -0,0 +1,422 @@ +

NAMING CONVENTION

+ +

The compiler can be instructed to use a particular naming + convention in the generated code. A number of widely-used + conventions can be selected using the --type-naming + and --function-naming options. A custom + naming convention can be achieved using the + --type-regex, + --accessor-regex, + --one-accessor-regex, + --opt-accessor-regex, + --seq-accessor-regex, + --modifier-regex, + --one-modifier-regex, + --opt-modifier-regex, + --seq-modifier-regex, + --parser-regex, + --serializer-regex, + --const-regex, + --enumerator-regex, and + --element-type-regex options. +

+ +

The --type-naming option specifies the + convention that should be used for naming C++ types. Possible + values for this option are knr (default), + ucc, and java. The + knr value (stands for K&R) signifies + the standard, lower-case naming convention with the underscore + used as a word delimiter, for example: foo, + foo_bar. The ucc (stands + for upper-camel-case) and + java values a synonyms for the same + naming convention where the first letter of each word in the + name is capitalized, for example: Foo, + FooBar.

+ +

Similarly, the --function-naming option + specifies the convention that should be used for naming C++ + functions. Possible values for this option are knr + (default), lcc, and java. The + knr value (stands for K&R) signifies + the standard, lower-case naming convention with the underscore + used as a word delimiter, for example: foo(), + foo_bar(). The lcc value + (stands for lower-camel-case) signifies a naming convention + where the first letter of each word except the first is + capitalized, for example: foo(), fooBar(). + The java naming convention is similar to + the lower-camel-case one except that accessor functions are prefixed + with get, modifier functions are prefixed + with set, parsing functions are prefixed + with parse, and serialization functions are + prefixed with serialize, for example: + getFoo(), setFooBar(), + parseRoot(), serializeRoot().

+ +

Note that the naming conventions specified with the + --type-naming and + --function-naming options perform only limited + transformations on the names that come from the schema in the + form of type, attribute, and element names. In other words, to + get consistent results, your schemas should follow a similar + naming convention as the one you would like to have in the + generated code. Alternatively, you can use the + --*-regex options (discussed below) + to perform further transformations on the names that come from + the schema.

+ +

The + --type-regex, + --accessor-regex, + --one-accessor-regex, + --opt-accessor-regex, + --seq-accessor-regex, + --modifier-regex, + --one-modifier-regex, + --opt-modifier-regex, + --seq-modifier-regex, + --parser-regex, + --serializer-regex, + --const-regex, + --enumerator-regex, and + --element-type-regex options allow you to + specify extra regular expressions for each name category in + addition to the predefined set that is added depending on + the --type-naming and + --function-naming options. Expressions + that are provided with the --*-regex + options are evaluated prior to any predefined expressions. + This allows you to selectively override some or all of the + predefined transformations. When debugging your own expressions, + it is often useful to see which expressions match which names. + The --name-regex-trace option allows you + to trace the process of applying regular expressions to + names.

+ +

The value for the --*-regex options should be + a perl-like regular expression in the form + /pattern/replacement/. + Any character can be used as a delimiter instead of /. + Escaping of the delimiter character in pattern or + replacement is not supported. + All the regular expressions for each category are pushed into a + category-specific stack with the last specified expression + considered first. The first match that succeeds is used. For the + --one-accessor-regex (accessors with cardinality one), + --opt-accessor-regex (accessors with cardinality optional), and + --seq-accessor-regex (accessors with cardinality sequence) + categories the --accessor-regex expressions are + used as a fallback. For the + --one-modifier-regex, + --opt-modifier-regex, and + --seq-modifier-regex + categories the --modifier-regex expressions are + used as a fallback. For the --element-type-regex + category the --type-regex expressions are + used as a fallback.

+ +

The type name expressions (--type-regex) + are evaluated on the name string that has the following + format:

+ +

[namespace ]name[,name][,name][,name]

+ +

The element type name expressions + (--element-type-regex), effective only when + the --generate-element-type option is specified, + are evaluated on the name string that has the following + format:

+ +

namespace name

+ +

In the type name format the namespace part + followed by a space is only present for global type names. For + global types and elements defined in schemas without a target + namespace, the namespace part is empty but + the space is still present. In the type name format after the + initial name component, up to three additional + name components can be present, separated + by commas. For example:

+ +

http://example.com/hello type

+

foo

+

foo,iterator

+

foo,const,iterator

+ +

The following set of predefined regular expressions is used to + transform type names when the upper-camel-case naming convention + is selected:

+ +

/(?:[^ ]* )?([^,]+)/\u$1/

+

/(?:[^ ]* )?([^,]+),([^,]+)/\u$1\u$2/

+

/(?:[^ ]* )?([^,]+),([^,]+),([^,]+)/\u$1\u$2\u$3/

+

/(?:[^ ]* )?([^,]+),([^,]+),([^,]+),([^,]+)/\u$1\u$2\u$3\u$4/

+ +

The accessor and modifier expressions + (--*accessor-regex and + --*modifier-regex) are evaluated on the name string + that has the following format:

+ +

name[,name][,name]

+ +

After the initial name component, up to two + additional name components can be present, + separated by commas. For example:

+ +

foo

+

dom,document

+

foo,default,value

+ +

The following set of predefined regular expressions is used to + transform accessor names when the java naming + convention is selected:

+ +

/([^,]+)/get\u$1/

+

/([^,]+),([^,]+)/get\u$1\u$2/

+

/([^,]+),([^,]+),([^,]+)/get\u$1\u$2\u$3/

+ +

For the parser, serializer, and enumerator categories, the + corresponding regular expressions are evaluated on local names of + elements and on enumeration values, respectively. For example, the + following predefined regular expression is used to transform parsing + function names when the java naming convention + is selected:

+ +

/(.+)/parse\u$1/

+ +

The const category is used to create C++ constant names for the + element/wildcard/text content ids in ordered types.

+ +

See also the REGEX AND SHELL QUOTING section below.

+ +

TYPE MAP

+ +

Type map files are used in C++/Parser to define a mapping between + XML Schema and C++ types. The compiler uses this information + to determine the return types of post_* + functions in parser skeletons corresponding to XML Schema + types as well as argument types for callbacks corresponding + to elements and attributes of these types.

+ +

The compiler has a set of predefined mapping rules that map + built-in XML Schema types to suitable C++ types (discussed + below) and all other types to void. + By providing your own type maps you can override these predefined + rules. The format of the type map file is presented below: +

+ +
+namespace <schema-namespace> [<cxx-namespace>]
+{
+  (include <file-name>;)*
+  ([type] <schema-type> <cxx-ret-type> [<cxx-arg-type>];)*
+}
+  
+ +

Both <schema-namespace> and + <schema-type> are regex patterns while + <cxx-namespace>, + <cxx-ret-type>, and + <cxx-arg-type> are regex pattern + substitutions. All names can be optionally enclosed in + " ", for example, to include white-spaces.

+ +

<schema-namespace> determines XML + Schema namespace. Optional <cxx-namespace> + is prefixed to every C++ type name in this namespace declaration. + <cxx-ret-type> is a C++ type name that is + used as a return type for the post_* functions. + Optional <cxx-arg-type> is an argument + type for callback functions corresponding to elements and attributes + of this type. If + <cxx-arg-type> is not specified, it defaults + to <cxx-ret-type> if <cxx-ret-type> + ends with * or & (that is, + it is a pointer or a reference) and + const <cxx-ret-type>& + otherwise. + <file-name> is a file name either in the + " " or < > format + and is added with the #include directive to + the generated code.

+ +

The # character starts a comment that ends + with a new line or end of file. To specify a name that contains + # enclose it in " ". + For example:

+ +
+namespace http://www.example.com/xmlns/my my
+{
+  include "my.hxx";
+
+  # Pass apples by value.
+  #
+  apple apple;
+
+  # Pass oranges as pointers.
+  #
+  orange orange_t*;
+}
+  
+ +

In the example above, for the + http://www.example.com/xmlns/my#orange + XML Schema type, the my::orange_t* C++ type will + be used as both return and argument types.

+ +

Several namespace declarations can be specified in a single + file. The namespace declaration can also be completely + omitted to map types in a schema without a namespace. For + instance:

+ +
+include "my.hxx";
+apple apple;
+
+namespace http://www.example.com/xmlns/my
+{
+  orange "const orange_t*";
+}
+  
+ +

The compiler has a number of predefined mapping rules that can be + presented as the following map files. The string-based XML Schema + built-in types are mapped to either std::string + or std::wstring depending on the character type + selected with the --char-type option + (char by default).

+ +
+namespace http://www.w3.org/2001/XMLSchema
+{
+  boolean bool bool;
+
+  byte "signed char" "signed char";
+  unsignedByte "unsigned char" "unsigned char";
+
+  short short short;
+  unsignedShort "unsigned short" "unsigned short";
+
+  int int int;
+  unsignedInt "unsigned int" "unsigned int";
+
+  long "long long" "long long";
+  unsignedLong "unsigned long long" "unsigned long long";
+
+  integer "long long" "long long";
+
+  negativeInteger "long long" "long long";
+  nonPositiveInteger "long long" "long long";
+
+  positiveInteger "unsigned long long" "unsigned long long";
+  nonNegativeInteger "unsigned long long" "unsigned long long";
+
+  float float float;
+  double double double;
+  decimal double double;
+
+  string std::string;
+  normalizedString std::string;
+  token std::string;
+  Name std::string;
+  NMTOKEN std::string;
+  NCName std::string;
+  ID std::string;
+  IDREF std::string;
+  language std::string;
+  anyURI std::string;
+
+  NMTOKENS xml_schema::string_sequence;
+  IDREFS xml_schema::string_sequence;
+
+  QName xml_schema::qname;
+
+  base64Binary std::auto_ptr<xml_schema::buffer>
+               std::auto_ptr<xml_schema::buffer>;
+  hexBinary std::auto_ptr<xml_schema::buffer>
+            std::auto_ptr<xml_schema::buffer>;
+
+  date xml_schema::date;
+  dateTime xml_schema::date_time;
+  duration xml_schema::duration;
+  gDay xml_schema::gday;
+  gMonth xml_schema::gmonth;
+  gMonthDay xml_schema::gmonth_day;
+  gYear xml_schema::gyear;
+  gYearMonth xml_schema::gyear_month;
+  time xml_schema::time;
+}
+  
+ +

The last predefined rule maps anything that wasn't mapped by + previous rules to void:

+ +
+namespace .*
+{
+  .* void void;
+}
+  
+ + +

When you provide your own type maps with the + --type-map option, they are evaluated first. + This allows you to selectively override predefined rules.

+ +

REGEX AND SHELL QUOTING

+ +

When entering a regular expression argument in the shell + command line it is often necessary to use quoting (enclosing + the argument in " " or + ' ') in order to prevent the shell + from interpreting certain characters, for example, spaces as + argument separators and $ as variable + expansions.

+ +

Unfortunately it is hard to achieve this in a manner that is + portable across POSIX shells, such as those found on + GNU/Linux and UNIX, and Windows shell. For example, if you + use " " for quoting you will get a + wrong result with POSIX shells if your expression contains + $. The standard way of dealing with this + on POSIX systems is to use ' ' instead. + Unfortunately, Windows shell does not remove ' ' + from arguments when they are passed to applications. As a result you + may have to use ' ' for POSIX and + " " for Windows ($ is + not treated as a special character on Windows).

+ +

Alternatively, you can save regular expression options into + a file, one option per line, and use this file with the + --options-file option. With this approach + you don't need to worry about shell quoting.

+ +

DIAGNOSTICS

+ +

If the input file is not a valid W3C XML Schema definition, + xsd will issue diagnostic messages to STDERR + and exit with non-zero exit code.

+ +

BUGS

+ +

Send bug reports to the + xsd-users@codesynthesis.com mailing list.

+ +
+ +
+ + diff --git a/xsd/doc/xsd-parser-header.1 b/xsd/doc/xsd-parser-header.1 new file mode 100644 index 0000000..e0cf84e --- /dev/null +++ b/xsd/doc/xsd-parser-header.1 @@ -0,0 +1,4 @@ +\" +\" C++/Parser +\" +.SS cxx-parser command options diff --git a/xsd/doc/xsd-parser-header.xhtml b/xsd/doc/xsd-parser-header.xhtml new file mode 100644 index 0000000..94fa2c1 --- /dev/null +++ b/xsd/doc/xsd-parser-header.xhtml @@ -0,0 +1 @@ +

CXX-PARSER COMMAND OPTIONS

diff --git a/xsd/doc/xsd-prologue.1 b/xsd/doc/xsd-prologue.1 new file mode 100644 index 0000000..33f039e --- /dev/null +++ b/xsd/doc/xsd-prologue.1 @@ -0,0 +1,119 @@ +.\" Process this file with +.\" groff -man -Tascii xsd.1 +.\" +.TH XSD 1 "$date$" "$project$ $version$" +.SH NAME +xsd \- W3C XML Schema to C++ Compiler +.\" +.\" +.\" +.\"-------------------------------------------------------------------- +.SH SYNOPSIS +.\"-------------------------------------------------------------------- +.B xsd +.I command +.B [ +.I options +.B ] +.I file +.B [ +.I file +.B ...] +.in +.B xsd help +.B [ +.I command +.B ] +.in +.B xsd version +.\" +.\" +.\" +.\"-------------------------------------------------------------------- +.SH DESCRIPTION +.\"-------------------------------------------------------------------- +.B xsd +generates vocabulary-specific, statically-typed C++ mapping from W3C XML +Schema definitions. Particular mapping to produce is selected by a +.IR command . +Each mapping has a number of mapping-specific +.I options +that should appear, if any, after the +.IR command . +Input files should be W3C XML Schema definitions. The exact set of the +generated files depends on the selected mapping and options. +.\" +.\" +.\" +.\"-------------------------------------------------------------------- +.SH COMMANDS +.\"-------------------------------------------------------------------- +.IP \fBcxx-tree\fR +Generate the C++/Tree mapping. For each input file in the form +.B name.xsd +the following C++ files are generated: +.B name.hxx +(header file), +.B name.ixx +(inline file, generated only if the +.B --generate-inline +option is specified), +.B name.cxx +(source file), and +.B name-fwd.hxx +(forward declaration file, generated only if the +.B --generate-forward +option is specified). + +.IP \fBcxx-parser\fR +Generate the C++/Parser mapping. For each input file in the form +.B name.xsd +the following C++ files are generated: +.B name-pskel.hxx +(parser skeleton header file), +.B name-pskel.ixx +(parser skeleton inline file, generated only if the +.B --generate-inline +option is specified), and +.B name-pskel.cxx +(parser skeleton source file). If the +.B --generate-noop-impl +or +.B --generate-print-impl +option is specified, the following additional sample implementation files +are generated: +.B name-pimpl.hxx +(parser implementation header file) and +.B name-pimpl.cxx +(parser implementation source file). If the +.B --generate-test-driver +option is specified, the additional +.B name-driver.cxx +test driver file is generated. + +.IP \fBhelp\fR +Print usage information and exit. Use +.PP +.RS +.RS 3 +.B xsd help +.I command +.RE +.PP +for command-specific help. +.RE +.IP \fBversion\fR +Print version and exit. +.\"-------------------------------------------------------------------- +.SH OPTIONS +.\"-------------------------------------------------------------------- +Command-specific +.IR options , +if any, should appear after the corresponding +.IR command . + +.\" +.\" Common options. +.\" +.SS common options +. diff --git a/xsd/doc/xsd-prologue.xhtml b/xsd/doc/xsd-prologue.xhtml new file mode 100644 index 0000000..e52e1fc --- /dev/null +++ b/xsd/doc/xsd-prologue.xhtml @@ -0,0 +1,123 @@ + + + + + + $project$ $version$ Compiler Command Line Manual + + + + + + + + + + + + +
+
+ +

NAME

+ +

xsd - W3C XML Schema to C++ Compiler

+ +

SYNOPSIS

+ +
+
xsd command [options] file [file ...]
+
xsd help [command]
+
xsd version
+
+ +

DESCRIPTION

+ +

xsd generates vocabulary-specific, statically-typed + C++ mapping from W3C XML Schema definitions. Particular mapping to + produce is selected by a command. Each mapping has + a number of mapping-specific options that should + appear, if any, after the command. Input files should + be W3C XML Schema definitions. The exact set of the generated files depends + on the selected mapping and options.

+ +

COMMANDS

+ +
+
cxx-tree
+
Generate the C++/Tree mapping. For each input file in the form + name.xsd the following C++ files are generated: + name.hxx (header file), + name.ixx (inline file, generated only if the + --generate-inline option is specified), + name.cxx (source file), and + name-fwd.hxx (forward declaration file, generated + only if the --generate-forward option is + specified).
+ +
cxx-parser
+
Generate the C++/Parser mapping. For each input file in the form + name.xsd the following C++ files are generated: + name-pskel.hxx (parser skeleton header file), + name-pskel.ixx (parser skeleton inline file, + generated only if the --generate-inline + option is specified), and + name-pskel.cxx (parser skeleton source file). + If the --generate-noop-impl or + --generate-print-impl option is specified, + the following additional sample implementation files are generated: + name-pimpl.hxx (parser implementation header + file) and + name-pimpl.cxx (parser implementation source + file). If the --generate-test-driver option + is specified, the additional name-driver.cxx + test driver file is generated.
+ +
help
+
Print usage information and exit. Use +

xsd help command

+ for command-specific help. +
+ +
version
+
Print version and exit.
+
+ +

OPTIONS

+ +

Command-specific options, if any, should appear + after the corresponding command.

+ +

COMMON OPTIONS

diff --git a/xsd/doc/xsd-tree-header.1 b/xsd/doc/xsd-tree-header.1 new file mode 100644 index 0000000..b9146a7 --- /dev/null +++ b/xsd/doc/xsd-tree-header.1 @@ -0,0 +1,4 @@ +.\" +.\" C++/Tree options. +.\" +.SS cxx-tree command options diff --git a/xsd/doc/xsd-tree-header.xhtml b/xsd/doc/xsd-tree-header.xhtml new file mode 100644 index 0000000..73f9c99 --- /dev/null +++ b/xsd/doc/xsd-tree-header.xhtml @@ -0,0 +1 @@ +

CXX-TREE COMMAND OPTIONS

diff --git a/xsd/elements.hxx b/xsd/elements.hxx deleted file mode 100644 index 4d63f6a..0000000 --- a/xsd/elements.hxx +++ /dev/null @@ -1,125 +0,0 @@ -// file : xsd/elements.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef ELEMENTS_HXX -#define ELEMENTS_HXX - -#include -#include - -#include - -namespace SemanticGraph = XSDFrontend::SemanticGraph; -namespace Traversal = XSDFrontend::Traversal; - -// Anonymous feedback via belongs edge. -// -struct AnonymousBase : Traversal::Element, Traversal::Attribute -{ - AnonymousBase (Traversal::NodeDispatcher& d1) - : complex_ (&d1, 0) - { - edge_traverser (belongs_); - belongs_.node_traverser (complex_); - } - - AnonymousBase (Traversal::NodeDispatcher& d1, Traversal::NodeDispatcher& d2) - : complex_ (&d1, &d2) - { - edge_traverser (belongs_); - belongs_.node_traverser (complex_); - } - - // Hooks. - // -public: - virtual void - member_pre (SemanticGraph::Member&) - { - } - - virtual void - member_post (SemanticGraph::Member&) - { - } - - /* - virtual void - type_pre (SemanticGraph::Type& t) - { - } - - virtual void - type_post (SemanticGraph::Type& t) - { - } - */ - -public: - - virtual void - traverse (SemanticGraph::Element& e) - { - SemanticGraph::Type& t (e.type ()); - - if (!t.named_p () && !t.context ().count ("seen")) - { - t.context ().set ("seen", true); - - member_pre (e); - - Element::belongs (e, belongs_); - - member_post (e); - - t.context ().remove ("seen"); - } - } - - virtual void - traverse (SemanticGraph::Attribute& a) - { - SemanticGraph::Type& t (a.type ()); - - if (!t.named_p () && !t.context ().count ("seen")) - { - t.context ().set ("seen", true); - - member_pre (a); - - Attribute::belongs (a, belongs_); - - member_post (a); - - t.context ().remove ("seen"); - } - } - -private: - struct Complex : Traversal::Complex - { - Complex (Traversal::NodeDispatcher* d1, Traversal::NodeDispatcher* d2) - : d1_ (d1), d2_ (d2) - { - } - - virtual void - traverse (SemanticGraph::Complex& c) - { - if (d1_) - d1_->dispatch (c); - - if (d2_) - d2_->dispatch (c); - } - - private: - Traversal::NodeDispatcher* d1_; - Traversal::NodeDispatcher* d2_; - - } complex_; - - Traversal::Belongs belongs_; -}; - -#endif // ELEMENTS_HXX diff --git a/xsd/makefile b/xsd/makefile deleted file mode 100644 index 55a99ef..0000000 --- a/xsd/makefile +++ /dev/null @@ -1,190 +0,0 @@ -# file : xsd/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make - -cxx_tun := xsd.cxx - -cxx_tun += cxx/elements.cxx \ - cxx/literal-map.cxx \ - cxx/option-types.cxx - -cxx_tun += cxx/parser/elements.cxx \ - cxx/parser/validator.cxx \ - cxx/parser/name-processor.cxx \ - cxx/parser/type-processor.cxx \ - cxx/parser/state-processor.cxx \ - cxx/parser/generator.cxx \ - cxx/parser/parser-header.cxx \ - cxx/parser/parser-inline.cxx \ - cxx/parser/parser-source.cxx \ - cxx/parser/parser-forward.cxx \ - cxx/parser/impl-header.cxx \ - cxx/parser/impl-source.cxx \ - cxx/parser/driver-source.cxx \ - cxx/parser/element-validation-source.cxx \ - cxx/parser/attribute-validation-source.cxx \ - cxx/parser/characters-validation-source.cxx - -cxx_tun += cxx/tree/elements.cxx \ - cxx/tree/validator.cxx \ - cxx/tree/counter.cxx \ - cxx/tree/name-processor.cxx \ - cxx/tree/order-processor.cxx \ - cxx/tree/polymorphism-processor.cxx \ - cxx/tree/default-value.cxx \ - cxx/tree/generator.cxx \ - cxx/tree/tree-forward.cxx \ - cxx/tree/tree-header.cxx \ - cxx/tree/tree-inline.cxx \ - cxx/tree/tree-source.cxx \ - cxx/tree/parser-header.cxx \ - cxx/tree/parser-source.cxx \ - cxx/tree/stream-header.cxx \ - cxx/tree/stream-source.cxx \ - cxx/tree/serialization-header.cxx \ - cxx/tree/serialization-source.cxx \ - cxx/tree/stream-insertion-header.cxx \ - cxx/tree/stream-insertion-source.cxx \ - cxx/tree/stream-extraction-source.cxx - - -# Type map. -# -cxx_tun += type-map/lexer.cxx \ - type-map/parser.cxx - -# Processing. -# -cxx_tun += processing/cardinality/processor.cxx \ - processing/inheritance/processor.cxx - -# Options file. -# -cli_tun := options.cli \ - cxx/options.cli \ - cxx/tree/options.cli \ - cxx/parser/options.cli - -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(cli_tun:.cli=.o)) -cxx_od := $(cxx_obj:.o=.o.d) - -xsd := $(out_base)/xsd -install := $(out_base)/.install -dist := $(out_base)/.dist -dist-win := $(out_base)/.dist-win -clean := $(out_base)/.clean - -# Import. -# -$(call import,\ - $(scf_root)/import/cli/stub.make,\ - cli: cli,cli-rules: cli_rules) - -$(call import,\ - $(scf_root)/import/libcutl/stub.make,\ - l: cutl.l,cpp-options: cutl.l.cpp-options) - -$(call import,\ - $(scf_root)/import/libxsd-frontend/stub.make,\ - l: xsd_fe.l,cpp-options: xsd_fe.l.cpp-options) - -$(call import,\ - $(scf_root)/import/libxerces-c/stub.make,\ - l: xerces_c.l,cpp-options: xerces_c.l.cpp-options) - -# Build. -# -$(xsd): $(cxx_obj) $(xsd_fe.l) $(cutl.l) $(xerces_c.l) - -$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base) -$(cxx_obj) $(cxx_od): \ - $(xsd_fe.l.cpp-options) \ - $(cutl.l.cpp-options) \ - $(xerces_c.l.cpp-options) - -genf := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx) $(cli_tun:.cli=.cxx) -gen := $(addprefix $(out_base)/,$(genf)) - -# Don't depend on installed executable since it may not exist. -# -ifneq ($(cli),cli) -$(gen): $(cli) -endif -$(gen): cli := $(cli) -$(gen): cli_options += \ --I $(src_base) \ ---generate-specifier \ ---ostream-type ::std::wostream \ ---exclude-base \ ---suppress-undocumented \ ---generate-file-scanner \ ---include-with-brackets \ ---option-length 28 \ ---cxx-prologue '\#include ' - -#--include-prefix xsd -#--guard-prefix XSD - -$(addprefix $(out_base)/cxx/options,.hxx .ixx .cxx): $(src_base)/options.cli -$(addprefix $(out_base)/cxx/options,.hxx .ixx .cxx): cli_options += \ ---include-prefix cxx --guard-prefix CXX - -$(addprefix $(out_base)/cxx/tree/options,.hxx .ixx .cxx): \ -$(src_base)/options.cli $(src_base)/cxx/options.cli -$(addprefix $(out_base)/cxx/tree/options,.hxx .ixx .cxx): cli_options += \ ---include-prefix cxx/tree --guard-prefix CXX_TREE - -$(addprefix $(out_base)/cxx/parser/options,.hxx .ixx .cxx): \ -$(src_base)/options.cli $(src_base)/cxx/options.cli -$(addprefix $(out_base)/cxx/parser/options,.hxx .ixx .cxx): cli_options += \ ---include-prefix cxx/parser --guard-prefix CXX_PARSER - -$(call include-dep,$(cxx_od),$(cxx_obj),$(gen)) - -# Alias for default target. -# -$(out_base)/: $(xsd) - -# Install -# -$(install): $(xsd) - $(call install-exec,$<,$(install_bin_dir)/xsd) - -# Dist. -# -$(dist): $(xsd) - $(call install-exec,$<,$(dist_prefix)/bin/xsd) - -$(dist-win): $(xsd) - $(call install-exec,$<,$(dist_prefix)/bin/xsd.exe) - -# Clean. -# -$(clean): \ - $(xsd).o.clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) - -ifneq ($(xsd_clean_gen),n) -$(clean): $(addprefix $(out_base)/,$(cli_tun:.cli=.cxx.cli.clean)) -endif - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(xsd): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := xsd $(genf) -$(clean): $(out_base)/.gitignore.clean - -$(call include,$(bld_root)/git/gitignore.make) -endif - -# How to. -# -$(call include,$(cli_rules)) -$(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) diff --git a/xsd/manifest b/xsd/manifest new file mode 100644 index 0000000..db9720b --- /dev/null +++ b/xsd/manifest @@ -0,0 +1,23 @@ +: 1 +name: xsd +version: 4.2.0-b.1.z +summary: XML Schema to C++ data binding compiler +license: other: GPL-2.0-only with Xerces-C++ linking exception and FLOSS exception +topics: C++, XML, XML Schema, XML parser, source code generation +description-file: README +changes-file: NEWS +url: https://www.codesynthesis.com/projects/xsd/ +doc-url: https://www.codesynthesis.com/projects/xsd/ +src-url: https://git.codesynthesis.com/cgit/xsd/xsd/tree/xsd/ +email: xsd-users@codesynthesis.com ; Mailing list +build-warning-email: builds@codesynthesis.com +requires: c++11 +depends: * build2 >= 0.13.0 +depends: * bpkg >= 0.13.0 +# @@ Should probably become conditional dependency. +requires: ? cli ; Only required if changing .cli files. +depends: libxsd-frontend ^2.1.0- +depends: libcutl ^1.11.0- +depends: libxerces-c ^3.0.0 +tests: xsd-tests == $ +examples: xsd-examples == $ diff --git a/xsd/options-parser.hxx b/xsd/options-parser.hxx deleted file mode 100644 index 52125cb..0000000 --- a/xsd/options-parser.hxx +++ /dev/null @@ -1,29 +0,0 @@ -// file : xsd/options-parser.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef OPTIONS_PARSER_HXX -#define OPTIONS_PARSER_HXX - -#include -#include - -namespace cli -{ - template <> - struct parser - { - static void - parse (NarrowString& x, bool& xs, scanner& s) - { - xs = true; - const char* o (s.next ()); - - if (s.more ()) - x = s.next (); - else - throw missing_value (o); - } - }; -} - -#endif // OPTIONS_PARSER_HXX diff --git a/xsd/options.cli b/xsd/options.cli deleted file mode 100644 index ac129cf..0000000 --- a/xsd/options.cli +++ /dev/null @@ -1,312 +0,0 @@ -// file : xsd/options.cli -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include ; // std::size_t - -include ; // NarrowString, NarrowStrings - -class help_options -{ - // These are all documented elsewhere. - // - bool --help; - bool --version; - bool --proprietary-license; -}; - -class options = 0 -{ - NarrowStrings --disable-warning - { - "", - "Disable printing warning with id . If \cb{all} is specified for - the warning id then all warnings are disabled." - }; - - // The following option is "fake" in that it is actually handled by - // argv_file_scanner. We have it here to get the documentation. - // - std::string --options-file - { - "", - "Read additional options from . Each option should appearing on a - separate line optionally followed by space and an option value. Empty - lines and lines starting with \cb{#} are ignored. Option values can - be enclosed in double (\cb{\"}) or single (\cb{'}) quotes to preserve - leading and trailing whitespaces as well as to specify empty values. - If the value itself contains trailing or leading quotes, enclose it - with an extra pair of quotes, for example \cb{'\"x\"'}. Non-leading - and non-trailing quotes are interpreted as being part of the option - value. - - The semantics of providing options in a file is equivalent to providing - the same set of options in the same order on the command line at the - point where the \cb{--options-file} option is specified except that - the shell escaping and quoting is not required. You can repeat this - option to specify more than one options file." - }; - - // SLOC/license options. - // - bool --show-sloc - { - "Show the number of generated physical source lines of code (SLOC)." - }; - - std::size_t --sloc-limit - { - "", - "Check that the number of generated physical source lines of code (SLOC) - does not exceed ." - }; - - bool --proprietary-license - { - "Indicate that the generated code is licensed under a proprietary - license instead of the GPL." - }; - - NarrowString --custom-literals - { - "", - "Load custom XML string to C++ literal mappings from . This - mechanism can be useful if you are using a custom character encoding - and some of the strings in your schemas, for example element/attribute - names or enumeration values, contain non-ASCII characters. In this - case you will need to provide a custom mapping to C++ literals for - such strings. The format of this file is specified in the - \cb{custom-literals.xsd} XML Schema file that can be found in the - documentation directory." - }; - - // Anonymous type morphing. - // - bool --preserve-anonymous - { - "Preserve anonymous types. By default anonymous types are automatically - named with names derived from the enclosing elements/attributes. Because - mappings implemented by this compiler require all types to be named, - this option is only useful if you want to make sure your schemas don't - have anonymous types." - }; - - bool --show-anonymous - { - "Show elements and attributes that are of anonymous types. This option - only makes sense together with the \cb{--preserve-anonymous} option." - }; - - NarrowStrings --anonymous-regex - { - "", - "Add to the list of regular expressions used to derive names for - anonymous types from the enclosing attributes/elements. is a - Perl-like regular expression in the form - \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. - Any character can be used as a delimiter instead of '\cb{/}'. Escaping of - the delimiter character in \ci{pattern} or \ci{replacement} is not - supported. - - All the regular expressions are pushed into a stack with the last - specified expression considered first. The first match that succeeds is - used. Regular expressions are applied to a string in the form - - \c{\i{filename} \i{namespace} \i{xpath}} - - For instance: - - \cb{hello.xsd http://example.com/hello element} - - \cb{hello.xsd http://example.com/hello type/element} - - As an example, the following expression makes all the derived names - start with capital letters. This could be useful when your naming - convention requires type names to start with capital letters: - - \cb{%.* .* (.+/)*(.+)%\\u$2%} - - See also the REGEX AND SHELL QUOTING section below." - }; - - bool --anonymous-regex-trace - { - "Trace the process of applying regular expressions specified with the - \cb{--anonymous-regex} option. Use this option to find out why your - regular expressions don't do what you expected them to do." - }; - - bool --morph-anonymous; // Deprecated and therefore undocumented. - - // Location options. - // - NarrowStrings --location-map - { - "
    =", - "Map the original schema location
      that is specified in the XML - Schema include or import elements to new schema location . Repeat - this option to map more than one schema location. For example, the - following option maps the \cb{http://example.com/foo.xsd} URL to the - \cb{foo.xsd} local file. - - \cb{--location-map http://example.com/foo.xsd=foo.xsd}" - }; - - NarrowStrings --location-regex - { - "", - "Add to the list of regular expressions used to map schema - locations that are specified in the XML Schema include or import - elements. is a Perl-like regular expression in the form - \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. Any character can - be used as a delimiter instead of '\cb{/}'. Escaping of the delimiter - character in \ci{pattern} or \ci{replacement} is not supported. All - the regular expressions are pushed into a stack with the last specified - expression considered first. The first match that succeeds is used. - - For example, the following expression maps URL locations in the form - \cb{http://example.com/foo/bar.xsd} to local files in the form - \cb{bar.xsd}: - - \cb{%http://.+/(.+)%$1%} - - See also the REGEX AND SHELL QUOTING section below." - }; - - bool --location-regex-trace - { - "Trace the process of applying regular expressions specified with the - \cb{--location-regex} option. Use this option to find out why your - regular expressions don't do what you expected them to do." - }; - - // File-per-type option. - // - bool --file-per-type - { - "Generate a separate set of C++ files for each type defined in XML - Schema. Note that in this mode you only need to compile the root - schema(s) and the code will be generated for all included and - imported schemas. This compilation mode is primarily useful when - some of your schemas cannot be compiled separately or have cyclic - dependencies which involve type inheritance. Other options related - to this mode are: \cb{--type-file-regex}, \cb{--schema-file-regex}, - \cb{--fat-type-file}, and \cb{--file-list}." - }; - - NarrowStrings --type-file-regex - { - "", - "Add to the list of regular expressions used to translate type - names to file names when the \cb{--file-per-type} option is specified. - is a Perl-like regular expression in the form - \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. Any character can be - used as a delimiter instead of '\cb{/}'. Escaping of the delimiter - character in \ci{pattern} or \ci{replacement} is not supported. All - the regular expressions are pushed into a stack with the last specified - expression considered first. The first match that succeeds is used. - Regular expressions are applied to a string in the form - - \c{\i{namespace} \i{type-name}} - - For example, the following expression maps type \cb{foo} that is - defined in the \cb{http://example.com/bar} namespace to file name - \cb{bar-foo}: - - \cb{%http://example.com/(.+) (.+)%$1-$2%} - - See also the REGEX AND SHELL QUOTING section below." - }; - - bool --type-file-regex-trace - { - "Trace the process of applying regular expressions specified with the - \cb{--type-file-regex} option. Use this option to find out why your - regular expressions don't do what you expected them to do." - }; - - NarrowStrings --schema-file-regex - { - "", - "Add to the list of regular expressions used to translate schema - file names when the \cb{--file-per-type} option is specified. is - a Perl-like regular expression in the form - \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. Any character can be used - as a delimiter instead of '\cb{/}'. Escaping of the delimiter character in - \ci{pattern} or \ci{replacement} is not supported. All the regular - expressions are pushed into a stack with the last specified expression - considered first. The first match that succeeds is used. Regular - Expressions are applied to the absolute filesystem path of a schema file - and the result, including the directory part, if any, is used to derive - the \cb{#include} directive paths as well as the generated C++ file - paths. This option, along with \cb{--type-file-regex} are primarily - useful to place the generated files into subdirectories or to resolve - file name conflicts. - - For example, the following expression maps schema files in the - \cb{foo/1.0.0/} subdirectory to the files in the \cb{foo/} subdirectory. - As a result, the \cb{#include} directive paths for such schemas will be - in the \cb{foo/schema.hxx} form and the generated C++ files will be - placed into the \cb{foo/} subdirectory: - - \cb{%.*/foo/1.0.0/(.+)%foo/$1%} - - See also the REGEX AND SHELL QUOTING section below." - }; - - bool --schema-file-regex-trace - { - "Trace the process of applying regular expressions specified with the - \cb{--schema-file-regex} option. Use this option to find out why your - regular expressions don't do what you expected them to do." - }; - - bool --fat-type-file - { - "Generate code corresponding to global elements into type files instead - of schema files when the \cb{--type-file-regex} option is specified. - This option is primarily useful when trying to minimize the amount of - object code that is linked to an executable by packaging compiled - generated code into a static (archive) library." - }; - - // File list options. - // - NarrowString --file-list - { - "", - "Write a list of generated C++ files to . This option is primarily - useful in the file-per-type compilation mode (\cb{--file-per-type}) to - create a list of generated C++ files, for example, as a makefile - fragment." - }; - - NarrowString --file-list-prologue - { - "", - "Insert at the beginning of the file list. As a convenience, all - occurrences of the \cb{\\n} character sequence in are replaced - with new lines. This option can, for example, be used to assign the - generated file list to a makefile variable." - }; - - NarrowString --file-list-epilogue - { - "", - "Insert at the end of the file list. As a convenience, all - occurrences of the \cb{\\n} character sequence in are replaced - with new lines." - }; - - NarrowString --file-list-delim = "\n" - { - "", - "Delimit file names written to the file list with instead of new - lines. As a convenience, all occurrences of the \cb{\\n} character - sequence in are replaced with new lines." - }; - - // Undocumented. - // - bool --disable-multi-import; - bool --disable-full-check; -}; diff --git a/xsd/processing/cardinality/processor.cxx b/xsd/processing/cardinality/processor.cxx deleted file mode 100644 index 2a5292e..0000000 --- a/xsd/processing/cardinality/processor.cxx +++ /dev/null @@ -1,407 +0,0 @@ -// file : processing/cardinality/processor.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include -#include - -#include - -#include - -using namespace std; - -namespace Processing -{ - namespace SemanticGraph = XSDFrontend::SemanticGraph; - namespace Traversal = XSDFrontend::Traversal; - - namespace Cardinality - { - namespace - { - // - // - struct ElementInfo - { - ElementInfo () - : min (0), max (0), e_ (0) - { - } - - ElementInfo (SemanticGraph::Element& e) - : min (1), max (1), e_ (&e) - { - } - - ElementInfo (SemanticGraph::Element& e, size_t min_, size_t max_) - : min (min_), max (max_), e_ (&e) - { - } - - SemanticGraph::Element& - element () - { - assert (e_ != 0); - return *e_; - } - - public: - size_t min, max; - - private: - SemanticGraph::Element* e_; - }; - - typedef map ElementInfoMap; - - // - // - struct AnyInfo - { - AnyInfo () - : min (0), max (0), a_ (0) - { - } - - AnyInfo (SemanticGraph::Any& a) - : min (1), max (1), a_ (&a) - { - } - - AnyInfo (SemanticGraph::Any& a, size_t min_, size_t max_) - : min (min_), max (max_), a_ (&a) - { - } - - SemanticGraph::Any& - any () - { - assert (a_ != 0); - return *a_; - } - - public: - size_t min, max; - - private: - SemanticGraph::Any* a_; - }; - - typedef map AnyInfoMap; - - // - // - struct Particle: Traversal::All, - Traversal::Choice, - Traversal::Sequence, - Traversal::Element, - Traversal::Any - { - virtual void - traverse (SemanticGraph::All& a) - { - traverse_sequence (a); - } - - virtual void - traverse (SemanticGraph::Choice& c) - { - using SemanticGraph::Compositor; - - // Go over all particles we contain and add them to the map. - // - for (Compositor::ContainsIterator ci (c.contains_begin ()); - ci != c.contains_end (); ++ci) - { - Particle t; - t.dispatch (ci->particle ()); - - // Handle elements. - // - if (ci == c.contains_begin ()) - el_map = t.el_map; // First arm. - else - { - // For elements that are in the map but not in this - // arm of choice, we need to set min to 0 while for - // those that are we need to choose minimum between - // the two for min and maximum for max. - // - for (ElementInfoMap::iterator i (el_map.begin ()); - i != el_map.end (); ++i) - { - String const& name (i->first); - ElementInfo& ei (i->second); - - ElementInfoMap::iterator j (t.el_map.find (name)); - - if (j == t.el_map.end ()) - ei.min = 0; - else - { - ei.min = j->second.min < ei.min ? j->second.min : ei.min; - - // Unbounded is encoded as 0. - // - if (j->second.max == 0 || ei.max == 0) - ei.max = 0; - else - ei.max = j->second.max > ei.max ? j->second.max : ei.max; - } - } - - // Now elements that are in this arm of choice but are - // not in the map, we need to add to the map and set their - // min to 0. - // - for (ElementInfoMap::iterator i (t.el_map.begin ()); - i != t.el_map.end (); ++i) - { - String const& name (i->first); - ElementInfo& ei (i->second); - - ElementInfoMap::iterator j (el_map.find (name)); - - if (j == el_map.end ()) - el_map[name] = ElementInfo (ei.element (), 0, ei.max); - } - } - - // Handle wildcards. Since each wildcard is treated as unique, - // we need to copy them from each arm of choice and set min to - // 0. - // - for (AnyInfoMap::iterator i (t.any_map.begin ()); - i != t.any_map.end (); ++i) - { - String const& name (i->first); - AnyInfo& ai (i->second); - - assert (any_map.find (name) == any_map.end ()); - - any_map[name] = AnyInfo (ai.any (), 0, ai.max); - } - } - - // Choice's min and max. - // - size_t cmin (c.min ()), cmax (c.max ()); - - // Iterate over elements and wildcards in the maps and multiply - // their cardinality by cmin and cmax. - // - for (ElementInfoMap::iterator i (el_map.begin ()); - i != el_map.end (); ++i) - { - i->second.min *= cmin; - i->second.max *= cmax; - } - - for (AnyInfoMap::iterator i (any_map.begin ()); - i != any_map.end (); ++i) - { - i->second.min *= cmin; // Not really necessary since min == 0. - i->second.max *= cmax; - } - } - - virtual void - traverse (SemanticGraph::Sequence& s) - { - traverse_sequence (s); - } - - void - traverse_sequence (SemanticGraph::Compositor& c) - { - using SemanticGraph::Compositor; - - // Sequence's min and max. - // - size_t smin (c.min ()), smax (c.max ()); - - // Go over all particles we contain and add them to the map. - // - for (Compositor::ContainsIterator ci (c.contains_begin ()); - ci != c.contains_end (); ++ci) - { - Particle t; - t.dispatch (ci->particle ()); - - // Handle elements. - // - for (ElementInfoMap::iterator i (t.el_map.begin ()); - i != t.el_map.end (); ++i) - { - String const& name (i->first); - ElementInfo& ei (i->second); - size_t min (ei.min * smin); - size_t max (ei.max * smax); - ElementInfoMap::iterator j (el_map.find (name)); - - if (j != el_map.end ()) - { - // Add i's cardinality to j - // - j->second.min += min; - j->second.max = (j->second.max == 0 || max == 0) ? - 0 : (j->second.max + max); - } - else - el_map[name] = ElementInfo (ei.element (), min, max); - } - - // Handle wildcards. - // - for (AnyInfoMap::iterator i (t.any_map.begin ()); - i != t.any_map.end (); ++i) - { - String const& name (i->first); - AnyInfo& ai (i->second); - size_t min (ai.min * smin); - size_t max (ai.max * smax); - - assert (any_map.find (name) == any_map.end ()); - - any_map[name] = AnyInfo (ai.any (), min, max); - } - } - } - - virtual void - traverse (SemanticGraph::Element& e) - { - SemanticGraph::ContainsParticle& cp (e.contained_particle ()); - - String name (e.qualified_p () - ? e.namespace_ ().name () + L" " + e.name () - : e.name ()); - - el_map[name] = ElementInfo (e, cp.min (), cp.max ()); - } - - virtual void - traverse (SemanticGraph::Any& a) - { - SemanticGraph::ContainsParticle& cp (a.contained_particle ()); - - any_map[a.name ()] = AnyInfo (a, cp.min (), cp.max ()); - } - - public: - AnyInfoMap any_map; - ElementInfoMap el_map; - }; - - - // - // - struct Complex: Traversal::Complex - { - virtual void - traverse (Type& c) - { - if (c.contains_compositor_p ()) - { - Particle t; - t.dispatch (c.contains_compositor ().compositor ()); - - for (ElementInfoMap::iterator i (t.el_map.begin ()); - i != t.el_map.end (); ++i) - { - ElementInfo& ei (i->second); - SemanticGraph::Context& ctx (ei.element ().context ()); - - ctx.set ("min", ei.min); - ctx.set ("max", ei.max); - } - - for (AnyInfoMap::iterator i (t.any_map.begin ()); - i != t.any_map.end (); ++i) - { - AnyInfo& ai (i->second); - SemanticGraph::Context& ctx (ai.any ().context ()); - - ctx.set ("min", ai.min); - ctx.set ("max", ai.max); - } - } - - // Traverse attributes and anonymous types (via elements). - // - Complex::names (c); - } - }; - - - // - // - struct Attribute: Traversal::Attribute - { - virtual void - traverse (Type& a) - { - SemanticGraph::Context& ctx (a.context ()); - - ctx.set ("min", size_t (a.optional_p () ? 0 : 1)); - ctx.set ("max", size_t (1)); - } - }; - - // Go into implied/included/imported schemas while making sure - // we don't process the same stuff more than once. - // - struct Uses: Traversal::Uses - { - virtual void - traverse (Type& u) - { - SemanticGraph::Schema& s (u.schema ()); - - if (!s.context ().count ("processing-cardinality-seen")) - { - s.context ().set ("processing-cardinality-seen", true); - Traversal::Uses::traverse (u); - } - } - }; - } - - void Processor:: - process (SemanticGraph::Schema& tu, SemanticGraph::Path const&) - { - Traversal::Schema schema; - Uses uses; - - schema >> uses >> schema; - - Traversal::Names schema_names; - Traversal::Namespace ns; - Traversal::Names ns_names; - - schema >> schema_names >> ns >> ns_names; - - Complex complex_type; - AnonymousBase anonymous (complex_type); - - ns_names >> complex_type; - ns_names >> anonymous; - - Attribute attribute; - Traversal::Names names; - - complex_type >> names; - - names >> attribute; - names >> anonymous; - - // Some twisted schemas do recusive inclusions. - // - tu.context ().set ("processing-cardinality-seen", true); - - schema.dispatch (tu); - } - } -} diff --git a/xsd/processing/cardinality/processor.hxx b/xsd/processing/cardinality/processor.hxx deleted file mode 100644 index f09155e..0000000 --- a/xsd/processing/cardinality/processor.hxx +++ /dev/null @@ -1,28 +0,0 @@ -// file : processing/cardinality/processor.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef PROCESSING_CARDINALITY_PROCESSOR_HXX -#define PROCESSING_CARDINALITY_PROCESSOR_HXX - -#include // Path -#include - -#include - -namespace Processing -{ - namespace Cardinality - { - class Processor - { - public: - struct Failed {}; - - void - process (XSDFrontend::SemanticGraph::Schema&, - XSDFrontend::SemanticGraph::Path const& file); - }; - } -} - -#endif // PROCESSING_CARDINALITY_PROCESSOR_HXX diff --git a/xsd/processing/inheritance/processor.cxx b/xsd/processing/inheritance/processor.cxx deleted file mode 100644 index 9269852..0000000 --- a/xsd/processing/inheritance/processor.cxx +++ /dev/null @@ -1,492 +0,0 @@ -// file : processing/inheritance/processor.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include -#include - -#include - -#include - -#include -#include - -using namespace std; - -namespace Processing -{ - namespace SemanticGraph = XSDFrontend::SemanticGraph; - namespace Traversal = XSDFrontend::Traversal; - - namespace Inheritance - { - namespace - { - struct Dep - { - Dep (SemanticGraph::Type& t, - SemanticGraph::Member* m = 0, - String const& xpath = L"") - : type (t), member (m), member_xpath (xpath) - { - } - - SemanticGraph::Type& type; - SemanticGraph::Member* member; // Member if type is anonymous. - String member_xpath; - }; - - inline bool - operator< (Dep const& a, Dep const& b) - { - return &a.type < &b.type; - } - - typedef set DepSet; - typedef set TypeSet; - - String - xpath (SemanticGraph::Nameable& n) - { - if (dynamic_cast (&n) != 0) - return L""; // There is a bug if you see this. - - if (n.named_p ()) - { - SemanticGraph::Scope& scope (n.scope ()); - - if (dynamic_cast (&scope) != 0) - return n.name (); - - return xpath (scope) + L"/" + n.name (); - } - else - { - return L"(anonymous type for " + - n.context ().get ("instance-name") + L")"; - } - } - - - // Calculate the list of dependencies for this complex - // type. - // - struct ComplexType: Traversal::Complex, - Traversal::Member - { - ComplexType (DepSet& dep_set) - : dep_set_ (dep_set), last_ (0) - { - *this >> names_ >> *this; - } - - virtual void - traverse (SemanticGraph::Complex& c) - { - using SemanticGraph::Complex; - - if (c.inherits_p ()) - dep_set_.insert (Dep (c.inherits ().base (), last_, last_xpath_)); - - types_seen_.insert (&c); - - // Go after anonymous types. - // - names (c); - } - - virtual void - traverse (SemanticGraph::Member& m) - { - SemanticGraph::Type& t (m.type ()); - - if (!t.named_p () && types_seen_.find (&t) == types_seen_.end ()) - { - SemanticGraph::Context& ctx (t.context ()); - - last_xpath_ = xpath (m); - - String prev_xpath; - - if (ctx.count ("instance-name")) - prev_xpath = ctx.get ("instance-name"); - - ctx.set ("instance-name", last_xpath_); - - last_ = &m; - dispatch (t); - - if (prev_xpath) - ctx.set ("instance-name", prev_xpath); - else - ctx.remove ("instance-name"); - } - } - - private: - DepSet& dep_set_; - TypeSet types_seen_; - - SemanticGraph::Member* last_; - String last_xpath_; - - Traversal::Names names_; - }; - - - // - // - template - struct NodeArgs - { - NodeArgs (N& node, A arg) - : node_ (node), arg_ (arg) - { - } - - operator N& () const - { - return node_; - } - - template - void - add_edge_left (E& e) - { - node_.add_edge_left (e, arg_); - } - - template - void - add_edge_right (E& e) - { - node_.add_edge_right (e, arg_); - } - - private: - N& node_; - A arg_; - }; - - - // - // - struct Global: Traversal::Type, - Traversal::Complex, - Traversal::Element - { - Global (SemanticGraph::Schema& root, - SemanticGraph::Schema& schema, - bool& failed) - : root_ (root), schema_ (schema), failed_ (failed) - { - } - - virtual void - traverse (SemanticGraph::Type& t) - { - if (t.named_p ()) - types_seen_.insert (&t); - } - - virtual void - traverse (SemanticGraph::Complex& c) - { - check_dep (c, c); - types_seen_.insert (&c); - }; - - virtual void - traverse (SemanticGraph::Element& e) - { - SemanticGraph::Type& t (e.type ()); - - if (!t.named_p ()) - { - t.context ().set ("instance-name", xpath (e)); - check_dep (e, t); - t.context ().remove ("instance-name"); - } - }; - - private: - void - check_dep (SemanticGraph::Nameable& global, - SemanticGraph::Type& type) - { - using SemanticGraph::Type; - using SemanticGraph::Scope; - using SemanticGraph::Names; - using SemanticGraph::Schema; - - DepSet prereqs; - - // Calculate our prerequisistes. - // - { - ComplexType complex (prereqs); - complex.dispatch (type); - } - - for (DepSet::const_iterator i (prereqs.begin ()); - i != prereqs.end (); ++i) - { - Dep const& dep (*i); - Type& t (dep.type); - - // Ignore IDREF templates. - // - if (!t.named_p () && - (t.is_a () || - t.is_a ())) - continue; - - // We won't be able to generate compilable code in case of a - // dependency on ourselves (e.g., a member element with - // anonymous type that inherits from us). - // - if (&t == &type) - { - assert (dep.member != 0); - - SemanticGraph::Member& m (*dep.member); - - wcerr << t.file () << ":" << t.line () << ":" << t.column () - << " error: nested anonymous type for '" - << dep.member_xpath << "' cyclicly inherits from '" - << t.name () << "'" << endl; - - wcerr << t.file () << ":" << t.line () << ":" << t.column () - << " error: unable to generate valid code for such " - << "cyclic inheritance" << endl; - - wcerr << m.file () << ":" << m.line () << ":" << m.column () - << " info: '" << m.name () << "' element is declared here" - << endl; - - wcerr << t.file () << ":" << t.line () << ":" << t.column () - << ": info: consider explicitly naming this type " - << "or remove the --preserve-anonymous option" - << endl; - - failed_ = true; - continue; - } - - if (types_seen_.find (&t) == types_seen_.end ()) - { - Scope& scope (t.scope ()); - Schema& schema (dynamic_cast (scope.scope ())); - - // Don't worry about types that are in included/imported - // schemas. - // - if (&schema != &schema_ && !sources_p (schema_, schema)) - continue; - - if (t.context ().count ("seen")) - { - wcerr << t.file () << ":" << t.line () << ":" << t.column () - << " error: nested anonymous type in '" << t.name () - << "' or '" << type.name () << "' inherits from one of " - << "these types and makes them mutually dependant" - << endl; - - wcerr << t.file () << ":" << t.line () << ":" << t.column () - << " error: unable to generate valid code for such " - << "cyclic dependency" << endl; - - wcerr << type.file () << ":" << type.line () << ":" - << type.column () << " info: '" << type.name () - << "' type is defined here" - << endl; - - wcerr << t.file () << ":" << t.line () << ":" << t.column () - << ": info: consider explicitly naming the anonymous " - << "type or remove the --preserve-anonymous option" - << endl; - - failed_ = true; - continue; - } - - //wcerr << "type '" << t.name () << "' needs to be moved " << - // "before " << (global.is_a () ? "type" : "element") << - // " '" << global.name () << "'" << endl; - - - // Delete current Names edge. - // - String name (t.name ()); - { - Names& n (t.named ()); - root_.delete_edge (scope, t, n); - } - - // Insert a new Names edge before global. - // - { - // t.scope () and global.scope () can be different in - // case of the chameleon inclusion. - // - Scope& scope (global.scope ()); - - // Convert to the insert-after call. - // - Scope::NamesIterator i (scope.find (global.named ())); - - if (i == scope.names_begin ()) - i = scope.names_end (); - else - --i; - - NodeArgs na (scope, i); - root_.new_edge (na, t, name); - } - - // Recursively process the moved type. - // - global.context ().set ("seen", true); - dispatch (t); - global.context ().remove ("seen"); - } - } - } - - private: - // Return true if root sources s. - // - bool - sources_p (SemanticGraph::Schema& root, SemanticGraph::Schema& s) - { - using SemanticGraph::Schema; - using SemanticGraph::Sources; - - for (Schema::UsesIterator i (root.uses_begin ()); - i != root.uses_end (); ++i) - { - if (i->is_a ()) - { - if (&i->schema () == &s || sources_p (i->schema (), s)) - return true; - } - } - - return false; - } - - private: - SemanticGraph::Schema& root_; - SemanticGraph::Schema& schema_; - TypeSet types_seen_; - bool& failed_; - }; - - - // Sources traverser that goes into each schema only once. - // - struct Sources: Traversal::Sources - { - virtual void - traverse (SemanticGraph::Sources& s) - { - if (schemas_.insert (&s.schema ()).second) - Traversal::Sources::traverse (s); - } - - private: - set schemas_; - }; - - // Go into included/imported schemas while making sure we don't - // process the same stuff more than once. - // - struct Uses: Traversal::Includes, Traversal::Imports - { - Uses (SemanticGraph::Schema& root, bool& failed) - : root_ (root), failed_ (failed) - { - } - - virtual void - traverse (SemanticGraph::Includes& i) - { - traverse (i.schema ()); - } - - virtual void - traverse (SemanticGraph::Imports& i) - { - traverse (i.schema ()); - } - - private: - void - traverse (SemanticGraph::Schema& s) - { - if (!s.context ().count ("processing-inheritance-seen")) - { - Traversal::Schema schema; - Sources sources; - - schema >> sources >> schema; - schema >> *this; - - Traversal::Names schema_names; - Traversal::Namespace ns; - Traversal::Names ns_names; - - schema >> schema_names >> ns >> ns_names; - - Global global (root_, s, failed_); - - ns_names >> global; - - s.context ().set ("processing-inheritance-seen", true); - schema.dispatch (s); - } - } - - private: - SemanticGraph::Schema& root_; - bool& failed_; - }; - } - - void Processor:: - process (SemanticGraph::Schema& tu, SemanticGraph::Path const&) - { - bool failed (false); - - // We need to process include/imported schemas since other - // parts of the process, for example, name processors can - // rely on the order of types in the schema. - // - Traversal::Schema schema; - Sources sources; - Uses uses (tu, failed); - - schema >> sources >> schema; - schema >> uses; - - Traversal::Names schema_names; - Traversal::Namespace ns; - Traversal::Names ns_names; - - schema >> schema_names >> ns >> ns_names; - - Global global (tu, tu, failed); - - ns_names >> global; - - // Some twisted schemas do recusive self-inclusion. - // - tu.context ().set ("processing-inheritance-seen", true); - - schema.dispatch (tu); - - if (failed) - throw Failed (); - } - } -} diff --git a/xsd/processing/inheritance/processor.hxx b/xsd/processing/inheritance/processor.hxx deleted file mode 100644 index f0a881f..0000000 --- a/xsd/processing/inheritance/processor.hxx +++ /dev/null @@ -1,28 +0,0 @@ -// file : processing/inheritance/processor.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef PROCESSING_INHERITANCE_PROCESSOR_HXX -#define PROCESSING_INHERITANCE_PROCESSOR_HXX - -#include // Path -#include - -#include - -namespace Processing -{ - namespace Inheritance - { - class Processor - { - public: - struct Failed {}; - - void - process (XSDFrontend::SemanticGraph::Schema&, - XSDFrontend::SemanticGraph::Path const& file); - }; - } -} - -#endif // PROCESSING_INHERITANCE_PROCESSOR_HXX diff --git a/xsd/type-map/lexer.cxx b/xsd/type-map/lexer.cxx deleted file mode 100644 index 26600c5..0000000 --- a/xsd/type-map/lexer.cxx +++ /dev/null @@ -1,131 +0,0 @@ -// file : xsd/type-map/lexer.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include - -using std::wcerr; -using std::endl; - -namespace TypeMap -{ - Lexer::Lexer (std::istream& is, String const& path) - : locale_ ("C"), is_ (is), path_ (path), line_ (1), comment_ (false) - { - is_.exceptions (std::ios_base::badbit); - } - - Lexer::Token Lexer:: - next () - { - if (held_lexeme_) - { - Token t (Token::punct, held_lexeme_, line_); - held_lexeme_.clear (); - return t; - } - - typedef std::char_traits Traits; - typedef Traits::char_type CharType; - typedef Traits::int_type IntType; - - IntType i; - CharType c ('\0'); - NarrowString lexeme; - - // Skip all whitespaces including comments. - // - while (!is_.eof ()) - { - i = is_.get (); - - if (i == Traits::eof ()) - break; - - c = Traits::to_char_type (i); - - if (comment_) - { - if (c == '\n') - comment_ = false; - } - else - { - if (!(std::isspace (c, locale_) || c == '#')) - break; - - if (c == '#') - comment_ = true; - } - - if (c == '\n') - ++line_; - } - - if (is_.eof ()) - return Token (Token::eos, L"", line_); - - bool quote (c == '"'); - - if (!quote) - lexeme += c; - - if (c != ';' && c != '{' && c != '}') - { - // Accumulate non-whitespace character sequence. - // - - while (!is_.eof ()) - { - i = is_.get (); - - if (i == Traits::eof ()) - break; - - c = Traits::to_char_type (i); - - if (!quote && c == '#') - { - comment_ = true; - break; - } - - if (std::isspace (c, locale_)) - { - if (c == '\n') - ++line_; - - if (!quote) - break; - } - - if (!quote && (c == ';' || c == '{' || c == '}')) - { - held_lexeme_ += c; - break; - } - - if (quote && c == '"') - break; - - lexeme += c; - } - - if (quote && c != '"') - { - wcerr << path_ << ":" << line_ << ": error: closing '\"' expected" - << endl; - - throw Failed (); - } - } - - if (!quote && (lexeme == ";" || lexeme == "{" || lexeme == "}")) - { - return Token (Token::punct, lexeme, line_); - } - else - return Token (Token::token, lexeme, line_); - } -} diff --git a/xsd/type-map/lexer.hxx b/xsd/type-map/lexer.hxx deleted file mode 100644 index ab16eb1..0000000 --- a/xsd/type-map/lexer.hxx +++ /dev/null @@ -1,74 +0,0 @@ -// file : xsd/type-map/lexer.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef XSD_TYPE_MAP_LEXER_HXX -#define XSD_TYPE_MAP_LEXER_HXX - -#include -#include - -#include - -namespace TypeMap -{ - class Lexer - { - public: - class Token - { - public: - enum Type - { - token, - punct, - eos - }; - - Token (Type type, String const& lexeme, size_t line) - : type_ (type), lexeme_ (lexeme), line_ (line) - { - } - - Type - type () const - { - return type_; - } - - String const& - lexeme () const - { - return lexeme_; - } - - size_t - line () const - { - return line_; - } - - private: - Type type_; - String lexeme_; - size_t line_; - }; - - Lexer (std::istream&, String const& path); - - struct Failed {}; - - Token - next (); - - private: - std::locale locale_; - std::istream& is_; - String path_; - size_t line_; - String held_lexeme_; - bool comment_; - }; - -} - -#endif // XSD_TYPE_MAP_LEXER_HXX diff --git a/xsd/type-map/parser.cxx b/xsd/type-map/parser.cxx deleted file mode 100644 index 39389f7..0000000 --- a/xsd/type-map/parser.cxx +++ /dev/null @@ -1,279 +0,0 @@ -// file : xsd/type-map/parser.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include - -#include - -using std::endl; - -namespace TypeMap -{ - typedef Lexer::Token Token; - typedef cutl::re::wformat Format; - - Parser::Parser (Lexer& lex, String const& path) - : lex_ (lex), path_ (path), e (std::wcerr) - { - } - - bool Parser:: - parse (Namespaces& ns) - { - try - { - Namespace* global = 0; - - for (Token t (lex_.next ()); t.type () != Token::eos; t = lex_.next ()) - { - String l (t.lexeme ()); - - if (l == L"namespace") - { - global = 0; - - if (!namespace_ (ns)) - return false; - } - else if (l == L"include") - { - if (global == 0) - { - ns.push_back (Namespace (Pattern ())); - global = &(*ns.rbegin ()); - } - - if (!include (*global)) - return false; - } - else if (l == L"type" || t.type () == Token::token) - { - // Type mapping can have 'type' specifier omitted. - // - if (l == L"type") - t = lex_.next (); - - if (global == 0) - { - ns.push_back (Namespace (Pattern ())); - global = &(*ns.rbegin ()); - } - - if (!type (t, *global)) - return false; - } - else - { - e << path_ << ":" << t.line () << ": unexpected '" << l << "'" - << endl; - - return false; - } - } - } - catch (Lexer::Failed const&) - { - return false; - } - - return true; - } - - bool Parser:: - namespace_ (Namespaces& ns) - { - // First get XML namespace. - // - Token t (lex_.next ()); - - Pattern xsd_name; - - try - { - xsd_name = t.lexeme (); - } - catch (Format const& ex) - { - e << path_ << ":" << t.line () << ": invalid namespace pattern: " - << ex.description ().c_str () << endl; - return false; - } - - if (t.type () != Token::token) - { - e << path_ << ":" << t.line () << ": expected XML namespace " - << "instead of '" << xsd_name << "'" << endl; - return false; - } - - - // See if we've got optional C++ mapping. - // - t = lex_.next (); - - bool has_cxx_name (false); - String cxx_name; - - if (t.type () != Token::token) - { - if (t.lexeme () != L"{") - { - e << path_ << ":" << t.line () << ": expected C++ namespace or '{' " - << "instead of '" << t.lexeme () << "'" << endl; - return false; - } - } - else - { - has_cxx_name = true; - cxx_name = t.lexeme (); - } - - // Swallow '{' if needed. - // - if (has_cxx_name) - { - t = lex_.next (); - - if (t.type () != Token::punct || t.lexeme () != L"{") - { - e << path_ << ":" << t.line () << ": expected '{' instead of '" - << t.lexeme () << "'" << endl; - return false; - } - } - - Namespace n (xsd_name, has_cxx_name, cxx_name); - - // Parse namespace body. - // - for (t = lex_.next ();; t = lex_.next ()) - { - String l (t.lexeme ()); - - if (l == L"include") - { - if (!include (n)) - return false; - } - else if (l == L"type" || t.type () == Token::token) - { - // Type mapping can have 'type' specifier omitted. - // - if (l == L"type") - t = lex_.next (); - - if (!type (t, n)) - return false; - } - else if (t.type () == Token::punct && l == L"}") - { - break; - } - else - { - e << path_ << ":" << t.line () << ": unexpected '" << l << "'" - << endl; - return false; - } - } - - if (cxx_name || n.types_begin () != n.types_end () || - n.includes_begin () != n.includes_end ()) - { - ns.push_back (n); - } - - return true; - } - - bool Parser:: - include (Namespace& n) - { - Token t (lex_.next ()); - - String path (t.lexeme ()); - - if (t.type () != Token::token) - { - e << path_ << ":" << t.line () << ": expected include path " - << "instead of '" << path << "'" << endl; - return false; - } - - if (path && path[0] == L'<') - n.includes_push_back (path); - else - n.includes_push_back (L'"' + path + L'"'); - - t = lex_.next (); - - if (t.type () != Token::punct || t.lexeme () != L";") - { - e << path_ << ":" << t.line () << ": expected ';' after '" - << path << "'" << endl; - return false; - } - - return true; - } - - bool Parser:: - type (Token t, Namespace& n) - { - Pattern xsd_name; - - try - { - xsd_name = t.lexeme (); - } - catch (Format const& ex) - { - e << path_ << ":" << t.line () << ": invalid namespace pattern: " - << ex.description ().c_str () << endl; - return false; - } - - if (t.type () != Token::token) - { - e << path_ << ":" << t.line () << ": expected XML Schema type name " - << "instead of '" << xsd_name << "'" << endl; - return false; - } - - t = lex_.next (); - String cxx_ret_name (t.lexeme ()); - - if (t.type () != Token::token) - { - e << path_ << ":" << t.line () << ": expected C++ type name " - << "instead of '" << cxx_ret_name << "'" << endl; - return false; - } - - t = lex_.next (); - - String cxx_arg_name; - - // See if we've got optional argument type. - // - if (t.type () == Token::token) - { - cxx_arg_name = t.lexeme (); - t = lex_.next (); - } - - if (t.type () != Token::punct || t.lexeme () != L";") - { - e << path_ << ":" << t.line () << ": expected ';' after '" - << cxx_arg_name << "'" << endl; - return false; - } - - n.types_push_back (xsd_name, cxx_ret_name, cxx_arg_name); - - return true; - } -} diff --git a/xsd/type-map/parser.hxx b/xsd/type-map/parser.hxx deleted file mode 100644 index eceb255..0000000 --- a/xsd/type-map/parser.hxx +++ /dev/null @@ -1,41 +0,0 @@ -// file : xsd/type-map/parser.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef XSD_TYPE_MAP_PARSER_HXX -#define XSD_TYPE_MAP_PARSER_HXX - -#include - -#include -#include - -namespace TypeMap -{ - class Parser - { - public: - Parser (Lexer&, String const& path); - - // Merge parsed namespaces. - // - bool - parse (Namespaces&); - - private: - bool - namespace_ (Namespaces&); - - bool - include (Namespace&); - - bool - type (Lexer::Token, Namespace&); - - private: - Lexer& lex_; - String path_; - std::wostream& e; - }; -} - -#endif // XSD_TYPE_MAP_PARSER_HXX diff --git a/xsd/type-map/type-map.hxx b/xsd/type-map/type-map.hxx deleted file mode 100644 index 374591e..0000000 --- a/xsd/type-map/type-map.hxx +++ /dev/null @@ -1,178 +0,0 @@ -// file : xsd/type-map/type-map.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef XSD_TYPE_MAP_TYPE_MAP_HXX -#define XSD_TYPE_MAP_TYPE_MAP_HXX - -#include - -#include - -#include - -namespace TypeMap -{ - typedef cutl::re::wregex Pattern; - - class Type - { - public: - Type (String const& xsd_name, - String const& cxx_ret_name, - String const& cxx_arg_name) - : xsd_name_ (xsd_name), - cxx_ret_name_ (cxx_ret_name), - cxx_arg_name_ (cxx_arg_name) - { - } - - Type (Pattern const& xsd_name, - String const& cxx_ret_name, - String const& cxx_arg_name) - : xsd_name_ (xsd_name), - cxx_ret_name_ (cxx_ret_name), - cxx_arg_name_ (cxx_arg_name) - { - } - - Pattern const& - xsd_name () const - { - return xsd_name_; - } - - String const& - cxx_ret_name () const - { - return cxx_ret_name_; - } - - String const& - cxx_arg_name () const - { - return cxx_arg_name_; - } - - private: - Pattern xsd_name_; - String cxx_ret_name_; - String cxx_arg_name_; - }; - - class Namespace - { - public: - Namespace (String const& xsd_name) - : xsd_name_ (xsd_name), has_cxx_name_ (false) - { - } - - Namespace (Pattern const& xsd_name) - : xsd_name_ (xsd_name), has_cxx_name_ (false) - { - } - - Namespace (Pattern const& xsd_name, String const& cxx_name) - : xsd_name_ (xsd_name), has_cxx_name_ (true), cxx_name_ (cxx_name) - { - } - - Namespace (Pattern const& xsd_name, - bool has_cxx_name, - String const& cxx_name) - : xsd_name_ (xsd_name), - has_cxx_name_ (has_cxx_name), - cxx_name_ (cxx_name) - { - } - - // - // - typedef std::vector Includes; - typedef Includes::const_iterator IncludesIterator; - - IncludesIterator - includes_begin () const - { - return includes_.begin (); - } - - IncludesIterator - includes_end () const - { - return includes_.end (); - } - - void - includes_push_back (String const& i) - { - includes_.push_back (i); - } - - // - // - typedef std::vector Types; - typedef Types::const_iterator TypesIterator; - - TypesIterator - types_begin () const - { - return types_.begin (); - } - - TypesIterator - types_end () const - { - return types_.end (); - } - - void - types_push_back (String const& xsd_type, - String const& cxx_ret_type, - String const& cxx_arg_type = L"") - { - types_.push_back (Type (xsd_type, cxx_ret_type, cxx_arg_type)); - } - - void - types_push_back (Pattern const& xsd_type, - String const& cxx_ret_type, - String const& cxx_arg_type = L"") - { - types_.push_back (Type (xsd_type, cxx_ret_type, cxx_arg_type)); - } - - // - // - Pattern const& - xsd_name () const - { - return xsd_name_; - } - - // - // - bool - has_cxx_name () const - { - return has_cxx_name_; - } - - String const& - cxx_name () const - { - return cxx_name_; - } - - private: - Includes includes_; - Types types_; - Pattern xsd_name_; - bool has_cxx_name_; - String cxx_name_; - }; - - typedef std::vector Namespaces; -} - -#endif // XSD_TYPE_MAP_TYPE_MAP_HXX diff --git a/xsd/types.hxx b/xsd/types.hxx deleted file mode 100644 index 51af830..0000000 --- a/xsd/types.hxx +++ /dev/null @@ -1,19 +0,0 @@ -// file : xsd/types.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef TYPES_HXX -#define TYPES_HXX - -#include -#include // std::size_t - -#include - -using std::size_t; - -using XSDFrontend::String; -using XSDFrontend::NarrowString; - -typedef std::vector NarrowStrings; - -#endif // TYPES_HXX diff --git a/xsd/xsd.cxx b/xsd/xsd.cxx deleted file mode 100644 index bcf7307..0000000 --- a/xsd/xsd.cxx +++ /dev/null @@ -1,1126 +0,0 @@ -// file : xsd/xsd.cxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include -#include -#include // std::auto_ptr -#include // std::size_t -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include - -#include "../libxsd/xsd/cxx/version.hxx" - -namespace SemanticGraph = XSDFrontend::SemanticGraph; -namespace Transformations = XSDFrontend::Transformations; - -using namespace std; - -// -// -struct LocationTranslator: XSDFrontend::LocationTranslator -{ - struct Failed {}; - - LocationTranslator (NarrowStrings const& map, - NarrowStrings const& regex, - bool trace); - - virtual NarrowString - translate (NarrowString const&); - -private: - typedef map Map; - - typedef cutl::re::regexsub Regex; - typedef cutl::re::format RegexFormat; - typedef vector RegexVector; - - typedef map Cache; - - Map map_; - RegexVector regex_; - Cache cache_; - bool trace_; -}; - -// -// -struct AnonymousNameTranslator: Transformations::AnonymousNameTranslator -{ - struct Failed {}; - - AnonymousNameTranslator (NarrowStrings const& regex, bool trace); - - virtual String - translate (String const& file, - String const& ns, - String const& name, - String const& xpath); - -private: - typedef cutl::re::wregexsub Regex; - typedef cutl::re::wformat RegexFormat; - typedef vector RegexVector; - - RegexVector regex_; - bool trace_; - -}; - -// -// -struct SchemaPerTypeTranslator: Transformations::SchemaPerTypeTranslator -{ - struct Failed {}; - - SchemaPerTypeTranslator (NarrowStrings const& type_regex, - bool type_trace, - NarrowStrings const& schema_regex, - bool schema_trace); - - virtual String - translate_type (String const& ns, String const& name); - - virtual NarrowString - translate_schema (NarrowString const& file); - -private: - typedef cutl::re::wregexsub TypeRegex; - typedef cutl::re::wformat TypeRegexFormat; - typedef vector TypeRegexVector; - - TypeRegexVector type_regex_; - bool type_trace_; - - typedef cutl::re::regexsub SchemaRegex; - typedef cutl::re::format SchemaRegexFormat; - typedef vector SchemaRegexVector; - - SchemaRegexVector schema_regex_; - bool schema_trace_; -}; - -// -// -struct XercesInitializer -{ - XercesInitializer () - { - xercesc::XMLPlatformUtils::Initialize (); - } - - ~XercesInitializer () - { - xercesc::XMLPlatformUtils::Terminate (); - } -}; - -// Expand the \n escape sequence. -// -void -expand_nl (NarrowString& s); - -int -main (int argc, char* argv[]) -{ - wostream& e (wcerr); - - try - { - cli::argv_file_scanner args (argc, argv, "--options-file"); - help_options help_ops (args, cli::unknown_mode::stop); - - NarrowString cmd; - if (args.more ()) - cmd = args.next (); - - if (help_ops.version () || cmd == "version") - { - wostream& o (wcout); - - o << "CodeSynthesis XSD XML Schema to C++ compiler " << - XSD_STR_VERSION << endl - << "Copyright (c) 2005-2020 Code Synthesis Tools CC." << endl; - - if (!help_ops.proprietary_license () && cmd == "version") - { - // Parse the options after the command to detect trailing - // --proprietary-license. - // - help_ops = help_options (args, cli::unknown_mode::stop); - } - - if (help_ops.proprietary_license ()) - { - o << "The compiler was invoked in the Proprietary License mode. You " - << "should have\nreceived a proprietary license from Code Synthesis " - << "Tools CC that entitles\nyou to use it in this mode." << endl; - } - else - { - o << "This is free software; see the source for copying conditions. " - << "There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS " - << "FOR A PARTICULAR PURPOSE." << endl; - } - - return 0; - } - - if (help_ops.help () || cmd == "help") - { - wostream& o (wcout); - - if (cmd == "help" && args.more ()) - { - NarrowString arg (args.next ()); - - if (arg == "cxx-tree") - { - o << "Usage: " << argv[0] << " cxx-tree [options] file [file ...]" - << endl - << "Options:" << endl; - - CXX::Tree::Generator::usage (); - } - else if (arg == "cxx-parser") - { - o << "Usage: " << argv[0] << " cxx-parser [options] file [file ...]" - << endl - << "Options:" << endl; - - CXX::Parser::Generator::usage (); - } - else - { - o << "error: unknown command '" << arg.c_str () << "'" << endl - << "info: try '" << argv[0] << " help' for the list of commands" - << endl; - - return 1; - } - - // Add frontend options at the end. - // - options::print_usage (o); - } - else - { - o << "Usage: " << argv[0] << " ..." << endl - << "Commands:" << endl; - - o << " help Print usage information and exit. Use\n" - << " 'help ' for command-specific options." - << endl; - - o << " version Print version and exit." - << endl; - - o << " cxx-tree Generate the C++/Tree mapping." - << endl; - - o << " cxx-parser Generate the C++/Parser mapping." - << endl; - } - - return 0; - } - - if (cmd.empty ()) - { - e << "error: no command specified" << endl - << "info: try '" << argv[0] << " help' for usage information" << endl; - - return 1; - } - - if (cmd != "cxx-tree" && cmd != "cxx-parser") - { - e << "error: unknown command '" << cmd.c_str () << "'" << endl - << "info: try '" << argv[0] << " help' for the list of commands" - << endl; - - return 1; - } - - // We need to parse command line options before we can get to - // the arguments. - // - auto_ptr tree_ops ( - cmd == "cxx-tree" ? new CXX::Tree::options (args) : 0); - - auto_ptr parser_ops ( - cmd == "cxx-parser" ? new CXX::Parser::options (args) : 0); - - CXX::options& common_ops ( - cmd == "cxx-tree" - ? static_cast (*tree_ops) - : static_cast (*parser_ops)); - - // Disabled warnings. - // - WarningSet disabled_w; - { - NarrowStrings const& w (common_ops.disable_warning ()); - - for (NarrowStrings::const_iterator i (w.begin ()); i != w.end (); ++i) - disabled_w.insert (*i); - } - - bool disabled_w_all (disabled_w.find ("all") != disabled_w.end ()); - - if (common_ops.morph_anonymous () && - !disabled_w_all && - disabled_w.find ("D001") == disabled_w.end ()) - { - e << "warning D001: the --morph-anonymous option is on by default and " - << "no longer required" - << endl; - } - - // Collect all the files to compile in a vector. - // - NarrowStrings files; - - while (args.more ()) - files.push_back (args.next ()); - - if (files.empty ()) - { - e << "error: no input file specified" << endl; - return 1; - } - - bool fpt (common_ops.file_per_type ()); - - if (cmd == "cxx-tree" || cmd == "cxx-parser") - { - bool gen (common_ops.generate_xml_schema ()); - bool use (common_ops.extern_xml_schema ()); - - // Things get complicated when we are compiling several schemas at - // once (non-file-per-type mode) and use the --generate-xml-schema/ - // --extern-xml-schema options. The only way we can figure out which - // file corresponds to XML Schema is if the --extern-xml-schema option - // is also present. So we are going to require it for this case, - // especially since it generally makes sense. - // - if (!fpt) - { - if (files.size () > 1 && gen && !use) - { - e << "error: --extern-xml-schema is required when compiling more " - << "than one schema and --generate-xml-schema is specified" - << endl; - - return 1; - } - - if (files.size () == 1 && gen && use) - { - e << "error: --generate-xml-schema and --extern-xml-schema are " - << "mutually exclusive when compiling a single schema" << endl; - - return 1; - } - } - else - { - // The --file-per-type and --generate-xml-schema options are - // incompatible. It also makes sense to use --file-per-type - // and --extern-xml-schema. - // - if (gen) - { - e << "error: --file-per-type and --generate-xml-schema are " - << "incompatible" << endl - << "info: use --generate-xml-schema in a separate invocation " - << "of the compiler" << endl; - - return 1; - } - - if (!use && - !disabled_w_all && disabled_w.find ("D002") == disabled_w.end ()) - { - e << "warning D002: --extern-xml-schema is recommended when " - << "--file-per-type is specified to reduce generated code size" - << endl; - } - } - } - - // - // - FileList file_list; - AutoUnlinks unlinks; - size_t sloc (0); - - LocationTranslator loc_translator ( - common_ops.location_map (), - common_ops.location_regex (), - common_ops.location_regex_trace ()); - - AnonymousNameTranslator anon_translator ( - common_ops.anonymous_regex (), - common_ops.anonymous_regex_trace ()); - - // Load custom string literals, if any. - // - CXX::StringLiteralMap string_literal_map; - - if (NarrowString file = common_ops.custom_literals ()) - { - XercesInitializer xerces_init; - - if (!CXX::read_literal_map (file, string_literal_map)) - { - // Diagnostics has already been issued. - // - return 1; - } - } - - if (!fpt) - { - // File-per-schema compilation mode. - // - - for (size_t i (0); i < files.size (); ++i) - { - // Parse schema. - // - SemanticGraph::Path tu; - - try - { - tu = SemanticGraph::Path (files[i]); - } - catch (SemanticGraph::InvalidPath const&) - { - e << "error: '" << files[i].c_str () << "' is not a valid " - << "filesystem path" << endl; - - return 1; - } - - XSDFrontend::Parser parser ( - cmd != "cxx-tree", - !common_ops.disable_multi_import (), - !common_ops.disable_full_check (), - loc_translator, - disabled_w); - - auto_ptr schema; - - if (cmd == "cxx-tree" || cmd == "cxx-parser") - { - // See if we are generating code for the XML Schema namespace. - // We could be compiling several schemas at once in which case - // handling of the --generate-xml-schema option gets tricky: we - // will need to rely on the presence of the --extern-xml-schema - // to tell us which (fake) schema file corresponds to XML Schema. - // - bool gen_xml_schema (common_ops.generate_xml_schema ()); - - if (gen_xml_schema) - { - if (NarrowString name = common_ops.extern_xml_schema ()) - { - if (tu.string () != name) - gen_xml_schema = false; - } - } - - if (gen_xml_schema) - schema = parser.xml_schema (tu); - else - schema = parser.parse (tu); - } - else - schema = parser.parse (tu); - - // Morph anonymous types. - // - if (!common_ops.preserve_anonymous ()) - { - try - { - Transformations::Anonymous trans (anon_translator); - trans.transform (*schema, tu, true); - } - catch (Transformations::Anonymous::Failed const&) - { - return 1; // Diagnostic has already been issued. - } - } - - // Synthesize enumerations from unions. - // - if (cmd == "cxx-tree") - { - Transformations::EnumSynthesis trans; - trans.transform (*schema, tu); - } - - // Simplify the schema graph. - // - if (cmd == "cxx-parser") - { - Transformations::Simplifier trans; - trans.transform (*schema, tu); - } - - // Try to rearrange definitions so that there is no forward - // inheritance. - // - try - { - Processing::Inheritance::Processor proc; - proc.process (*schema, tu); - } - catch (Processing::Inheritance::Processor::Failed const&) - { - return 1; // Diagnostic has already been issued. - } - - // Normalize and annotate complex content restrictions. - // - if (cmd == "cxx-parser") - { - try - { - Transformations::Restriction trans; - trans.transform (*schema, tu); - } - catch (Transformations::Restriction::Failed const&) - { - return 1; // Diagnostic has already been issued. - } - } - - // Calculate cardinality. - // - { - Processing::Cardinality::Processor proc; - proc.process (*schema, tu); - } - - // Generate mapping. - // - if (cmd == "cxx-tree") - { - try - { - sloc += CXX::Tree::Generator::generate ( - *tree_ops, - *schema, - tu, - false, - string_literal_map, - disabled_w, - file_list, - unlinks); - } - catch (CXX::Tree::Generator::Failed const&) - { - // Diagnostic has already been issued. - // - return 1; - } - } - else if (cmd == "cxx-parser") - { - try - { - sloc += CXX::Parser::Generator::generate ( - *parser_ops, - *schema, - tu, - false, - string_literal_map, - true, - disabled_w, - file_list, - unlinks); - } - catch (CXX::Parser::Generator::Failed const&) - { - // Diagnostic has already been issued. - // - return 1; - } - } - } - } - else - { - // File-per-type compilation mode. - // - SemanticGraph::Paths paths; - - for (size_t i (0); i < files.size (); ++i) - { - try - { - paths.push_back (SemanticGraph::Path (files[i])); - } - catch (SemanticGraph::InvalidPath const&) - { - e << "error: '" << files[i].c_str () << "' is not a valid " - << "filesystem path" << endl; - - return 1; - } - } - - if (cmd == "cxx-parser" && - paths.size () > 1 && - parser_ops->generate_test_driver ()) - { - e << "info: generating test driver for the first schema only: '" << - paths[0] << "'" << endl; - } - - XSDFrontend::Parser parser ( - cmd != "cxx-tree", - !common_ops.disable_multi_import (), - !common_ops.disable_full_check (), - loc_translator, - disabled_w); - - auto_ptr schema (parser.parse (paths)); - - // Morph anonymous types. - // - if (!common_ops.preserve_anonymous ()) - { - try - { - Transformations::Anonymous trans (anon_translator); - trans.transform (*schema, SemanticGraph::Path (), false); - } - catch (Transformations::Anonymous::Failed const&) - { - return 1; // Diagnostic has already been issued. - } - } - - // Synthesize enumerations from unions. - // - if (cmd == "cxx-tree") - { - Transformations::EnumSynthesis trans; - trans.transform (*schema, SemanticGraph::Path ()); - } - - // Simplify the schema graph. - // - if (cmd == "cxx-parser") - { - Transformations::Simplifier trans; - trans.transform (*schema, SemanticGraph::Path ()); - } - - // Normalize and annotate complex content restrictions. - // - if (cmd == "cxx-parser") - { - try - { - Transformations::Restriction trans; - trans.transform (*schema, SemanticGraph::Path ()); - } - catch (Transformations::Restriction::Failed const&) - { - return 1; // Diagnostic has already been issued. - } - } - - // Calculate cardinality. - // - { - Processing::Cardinality::Processor proc; - proc.process (*schema, SemanticGraph::Path ()); - } - - // Rearrange the graph so that each type is in a seperate - // schema file. - // - typedef vector Schemas; - - SchemaPerTypeTranslator type_translator ( - common_ops.type_file_regex (), - common_ops.type_file_regex_trace (), - common_ops.schema_file_regex (), - common_ops.schema_file_regex_trace ()); - - Transformations::SchemaPerType trans ( - type_translator, - common_ops.fat_type_file ()); - - Schemas schemas (trans.transform (*schema)); - - // Generate code. - // - for (Schemas::iterator b (schemas.begin ()), i (b), e (schemas.end ()); - i != e; ++i) - { - SemanticGraph::Schema& s (**i); - SemanticGraph::Path path ( - s.context ().count ("renamed") - ? s.context ().get ("renamed") - : s.used_begin ()->path ()); - - if (cmd == "cxx-tree") - { - try - { - sloc += CXX::Tree::Generator::generate ( - *tree_ops, - s, - path, - true, - string_literal_map, - disabled_w, - file_list, - unlinks); - } - catch (CXX::Tree::Generator::Failed const&) - { - // Diagnostic has already been issued. - // - return 1; - } - } - else if (cmd == "cxx-parser") - { - try - { - // Only generate driver for the first schema. - // - sloc += CXX::Parser::Generator::generate ( - *parser_ops, - s, - path, - true, - string_literal_map, - i == b, - disabled_w, - file_list, - unlinks); - } - catch (CXX::Parser::Generator::Failed const&) - { - // Diagnostic has already been issued. - // - return 1; - } - } - } - } - - // See if we need to produce the file list. - // - if (NarrowString fl = common_ops.file_list ()) - { - typedef std::ofstream OutputFileStream; - - try - { - OutputFileStream ofs; - SemanticGraph::Path path (fl); - - ofs.open (path.string ().c_str (), ios_base::out); - - if (!ofs.is_open ()) - { - wcerr << path << ": error: unable to open in write mode" << endl; - return 1; - } - - NarrowString d (common_ops.file_list_delim ()); - expand_nl (d); - - if (NarrowString p = common_ops.file_list_prologue ()) - { - expand_nl (p); - ofs << p; - } - - for (FileList::iterator i (file_list.begin ()), e (file_list.end ()); - i != e;) - { - ofs << *i; - - if (++i != e) - ofs << d; - } - - if (NarrowString e = common_ops.file_list_epilogue ()) - { - expand_nl (e); - ofs << e; - } - } - catch (SemanticGraph::InvalidPath const&) - { - wcerr << "error: '" << fl.c_str () << "' is not a valid " - << "filesystem path" << endl; - return 1; - } - } - - if (common_ops.show_sloc ()) - e << "total: " << sloc << endl; - - if (size_t sloc_limit = common_ops.sloc_limit ()) - { - if (sloc_limit < sloc) - { - e << "error: SLOC limit of " << sloc_limit - << " lines has been exceeded" << endl; - - return 1; - } - } - - unlinks.cancel (); - - return 0; - } - catch (LocationTranslator::Failed const&) - { - // Diagnostic has already been issued. - } - catch (AnonymousNameTranslator::Failed const&) - { - // Diagnostic has already been issued. - } - catch (SchemaPerTypeTranslator::Failed const&) - { - // Diagnostic has already been issued. - } - catch (Transformations::SchemaPerType::Failed const&) - { - // Diagnostic has already been issued. - } - catch (XSDFrontend::InvalidSchema const&) - { - // Diagnostic has already been issued. - } - catch (cli::exception const& ex) - { - wcerr << ex << endl; - wcerr << "try '" << argv[0] << " help' for usage information" << endl; - } - - return 1; -} - -// LocationTranslator -// - -LocationTranslator:: -LocationTranslator (NarrowStrings const& map, - NarrowStrings const& regex, - bool trace) - : trace_ (trace) -{ - // Map. - // - for (NarrowStrings::const_iterator i (map.begin ()); i != map.end (); ++i) - { - // Split the string in two parts at the last '='. - // - size_t pos (i->rfind ('=')); - - if (pos == NarrowString::npos) - { - wcerr << "error: invalid location map: '" << i->c_str () << - "': delimiter ('=') not found" << endl; - - throw Failed (); - } - - map_[NarrowString (*i, 0, pos)] = NarrowString (*i, pos + 1); - } - - // Regex. - // - for (NarrowStrings::const_iterator i (regex.begin ()); i != regex.end (); ++i) - { - try - { - regex_.push_back (Regex (*i)); - } - catch (RegexFormat const& e) - { - wcerr << "error: invalid location regex: '" << - e.regex ().c_str () << "': " << - e.description ().c_str () << endl; - - throw Failed (); - } - } -} - -NarrowString LocationTranslator:: -translate (NarrowString const& l) -{ - // First check the cache. - // - Cache::const_iterator ci (cache_.find (l)); - - if (ci != cache_.end ()) - return ci->second; - - // Then check the direct map. - // - Map::const_iterator mi (map_.find (l)); - - if (mi != map_.end ()) - { - cache_[l] = mi->second; - return mi->second; - } - - // Finally try regex. - // - if (trace_) - wcerr << "location: '" << l.c_str () << "'" << endl; - - for (RegexVector::reverse_iterator i (regex_.rbegin ()); - i != regex_.rend (); ++i) - { - if (trace_) - wcerr << "try: '" << i->regex ().str ().c_str () << "' : "; - - if (i->match (l)) - { - NarrowString r (i->replace (l)); - - if (trace_) - wcerr << "'" << r.c_str () << "' : +" << endl; - - cache_[l] = r; - return r; - } - - if (trace_) - wcerr << '-' << endl; - } - - // No match - return the original location. - // - cache_[l] = l; - return l; -} - -// AnonymousNameTranslator -// - -AnonymousNameTranslator:: -AnonymousNameTranslator (NarrowStrings const& regex, bool trace) - : trace_ (trace) -{ - for (NarrowStrings::const_iterator i (regex.begin ()); i != regex.end (); ++i) - { - try - { - regex_.push_back (Regex (String (*i))); - } - catch (RegexFormat const& e) - { - wcerr << "error: invalid anonymous type regex: '" << - e.regex () << "': " << e.description ().c_str () << endl; - - throw Failed (); - } - } -} - -String AnonymousNameTranslator:: -translate (String const& file, - String const& ns, - String const& name, - String const& xpath) -{ - String s (file + L' ' + ns + L' ' + xpath); - - if (trace_) - wcerr << "anonymous type: '" << s << "'" << endl; - - for (RegexVector::reverse_iterator i (regex_.rbegin ()); - i != regex_.rend (); ++i) - { - if (trace_) - wcerr << "try: '" << i->regex () << "' : "; - - if (i->match (s)) - { - String r (i->replace (s)); - - if (trace_) - wcerr << "'" << r << "' : +" << endl; - - return r; - } - - if (trace_) - wcerr << '-' << endl; - } - - // No match - return the name. - // - return name; -} - -// SchemaPerTypeTranslator -// - -SchemaPerTypeTranslator:: -SchemaPerTypeTranslator (NarrowStrings const& type_regex, - bool type_trace, - NarrowStrings const& schema_regex, - bool schema_trace) - : type_trace_ (type_trace), schema_trace_ (schema_trace) -{ - for (NarrowStrings::const_iterator i (type_regex.begin ()); - i != type_regex.end (); ++i) - { - try - { - type_regex_.push_back (TypeRegex (String (*i))); - } - catch (TypeRegexFormat const& e) - { - wcerr << "error: invalid type file regex: '" << - e.regex () << "': " << e.description ().c_str () << endl; - - throw Failed (); - } - } - - for (NarrowStrings::const_iterator i (schema_regex.begin ()); - i != schema_regex.end (); ++i) - { - try - { - schema_regex_.push_back (SchemaRegex (*i)); - } - catch (SchemaRegexFormat const& e) - { - wcerr << "error: invalid type file regex: '" << - e.regex ().c_str () << "': " << e.description ().c_str () << endl; - - throw Failed (); - } - } -} - -String SchemaPerTypeTranslator:: -translate_type (String const& ns, String const& name) -{ - String s (ns + L' ' + name); - - if (type_trace_) - wcerr << "type: '" << s << "'" << endl; - - for (TypeRegexVector::reverse_iterator i (type_regex_.rbegin ()); - i != type_regex_.rend (); ++i) - { - if (type_trace_) - wcerr << "try: '" << i->regex () << "' : "; - - if (i->match (s)) - { - String r (i->replace (s)); - - if (type_trace_) - wcerr << "'" << r << "' : +" << endl; - - return r; - } - - if (type_trace_) - wcerr << '-' << endl; - } - - // No match - return empty string. - // - return L""; -} - -NarrowString SchemaPerTypeTranslator:: -translate_schema (NarrowString const& file) -{ - if (schema_trace_) - wcerr << "schema: '" << file.c_str () << "'" << endl; - - for (SchemaRegexVector::reverse_iterator i (schema_regex_.rbegin ()); - i != schema_regex_.rend (); ++i) - { - if (schema_trace_) - wcerr << "try: '" << i->regex ().str ().c_str () << "' : "; - - if (i->match (file)) - { - NarrowString r (i->replace (file)); - - if (schema_trace_) - wcerr << "'" << r.c_str () << "' : +" << endl; - - return r; - } - - if (schema_trace_) - wcerr << '-' << endl; - } - - // No match - return empty string. - // - return ""; -} - -// -// -void -expand_nl (NarrowString& s) -{ - for (size_t i (0); i < s.size ();) - { - if (s[i] == '\\' && (i + 1) < s.size () && s[i + 1] == 'n') - { - NarrowString tmp (s, 0, i); - tmp += '\n'; - tmp.append (s.c_str () + i + 2); - s = tmp; - } - else - ++i; - } -} diff --git a/xsd/xsd.hxx b/xsd/xsd.hxx deleted file mode 100644 index f1bbd5f..0000000 --- a/xsd/xsd.hxx +++ /dev/null @@ -1,24 +0,0 @@ -// file : xsd/xsd.hxx -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef XSD_HXX -#define XSD_HXX - -#include -#include -#include // std::remove - -#include -#include - -#include // Path - -#include - -typedef std::set WarningSet; -typedef std::vector FileList; - -typedef cutl::fs::auto_remove AutoUnlink; -typedef cutl::fs::auto_removes AutoUnlinks; - -#endif // XSD_HXX diff --git a/xsd/xsd/.gitignore b/xsd/xsd/.gitignore new file mode 100644 index 0000000..2d9360c --- /dev/null +++ b/xsd/xsd/.gitignore @@ -0,0 +1,3 @@ +xsd +options.?xx +version.hxx diff --git a/xsd/xsd/buildfile b/xsd/xsd/buildfile new file mode 100644 index 0000000..49fbf2c --- /dev/null +++ b/xsd/xsd/buildfile @@ -0,0 +1,68 @@ +# file : xsd/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd-frontend%lib{xsd-frontend} +import libs += libcutl%lib{cutl} +import libs += libxerces-c%lib{xerces-c} + +options_topics = options cxx/options cxx/parser/options cxx/tree/options + +./: exe{xsd}: {hxx ixx txx cxx}{** -{$options_topics} -version} \ + {hxx ixx cxx}{$options_topics} \ + {hxx}{version} \ + $libs + +# Target metadata, see also --build2-metadata in xsd.cxx. +# +exe{xsd}: +{ + export.metadata = 1 xsd + xsd.name = [string] xsd + xsd.version = $version + xsd.checksum = $version +} + +hxx{version}: in{version} $src_root/manifest + +# Build options. +# +# Pass the copyright notice extracted from the LICENSE file. +# +obj{xsd cxx/parser/generator cxx/tree/generator}: \ + cxx.poptions += -DXSD_COPYRIGHT=\"$copyright\" + +# Generated options parser. +# +if $cli.configured +{ + cli.cxx{options}: cli{options} + cxx/cli.cxx{options}: cxx/cli{options} + cxx/parser/cli.cxx{options}: cxx/parser/cli{options} + cxx/tree/cli.cxx{options}: cxx/tree/cli{options} + + cli.options += --std c++11 -I $src_root --generate-specifier \ +--ostream-type ::std::wostream --exclude-base --suppress-undocumented \ +--generate-file-scanner --include-with-brackets --option-length 28 \ +--cxx-prologue '#include ' + + cli.cxx{options}: cli.options += --include-prefix xsd --guard-prefix XSD + + cxx/cli.cxx{options}: cli.options += --include-prefix xsd/cxx \ + --guard-prefix XSD_CXX + + cxx/parser/cli.cxx{options}: cli.options += --include-prefix xsd/cxx/parser \ + --guard-prefix XSD_CXX_PARSER + + cxx/tree/cli.cxx{options}: cli.options += --include-prefix xsd/cxx/tree \ + --guard-prefix XSD_CXX_TREE + + # Include the generated cli files into the distribution and don't remove + # them when cleaning in src (so that clean results in a state identical to + # distributed). + # + cli.cxx{*}: + { + dist = true + clean = ($src_root != $out_root) + } +} diff --git a/xsd/xsd/cxx/elements.cxx b/xsd/xsd/cxx/elements.cxx new file mode 100644 index 0000000..e914f9d --- /dev/null +++ b/xsd/xsd/cxx/elements.cxx @@ -0,0 +1,1322 @@ +// file : xsd/cxx/elements.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include // std::toupper +#include +#include +#include +#include +#include + +using std::wcerr; +using std::endl; + +namespace CXX +{ + // + // + wchar_t + upcase (wchar_t c) + { + return std::toupper (c); + } + + namespace + { + wchar_t const* keywords[] = { + L"NULL", + L"and", + L"asm", + L"auto", + L"bitand", + L"bitor", + L"bool", + L"break", + L"case", + L"catch", + L"char", + L"class", + L"compl", + L"const", + L"const_cast", + L"continue", + L"default", + L"delete", + L"do", + L"double", + L"dynamic_cast", + L"else", + L"end_eq", + L"enum", + L"explicit", + L"export", + L"extern", + L"false", + L"float", + L"for", + L"friend", + L"goto", + L"if", + L"inline", + L"int", + L"long", + L"mutable", + L"namespace", + L"new", + L"not", + L"not_eq", + L"operator", + L"or", + L"or_eq", + L"private", + L"protected", + L"public", + L"register", + L"reinterpret_cast", + L"return", + L"short", + L"signed", + L"sizeof", + L"static", + L"static_cast", + L"struct", + L"switch", + L"template", + L"this", + L"throw", + L"true", + L"try", + L"typedef", + L"typeid", + L"typename", + L"union", + L"unsigned", + L"using", + L"virtual", + L"void", + L"volatile", + L"wchar_t", + L"while", + L"xor", + L"xor_eq" + }; + } + + // Context + // + + Context:: + Context (std::wostream& o, + SemanticGraph::Schema& root, + SemanticGraph::Path const& path, + options_type const& ops, + StringLiteralMap const* string_literal_map_) + : os (o), + schema_root (root), + schema_path (schema_path_), + options (ops), + std (ops.std ()), + char_type (char_type_), + char_encoding (char_encoding_), + L (L_), + string_type (string_type_), + auto_ptr (auto_ptr_), + string_literal_map (string_literal_map_), + type_exp (type_exp_), + inst_exp (inst_exp_), + inl (inl_), + ns_mapping_cache (ns_mapping_cache_), + schema_path_ (path), + xs_ns_ (0), + char_type_ (ops.char_type ()), + char_encoding_ (ops.char_encoding ()), + L_ (char_type == L"wchar_t" ? L"L" : L""), + inl_ (ops.generate_inline () ? L"inline\n" : L""), + cxx_id_expr_ (L"^(::)?([a-zA-Z_]\\w*)(::[a-zA-Z_]\\w*)*$"), + cxx_id_expr (cxx_id_expr_), + urn_mapping_ (L"#^urn.*:([a-zA-Z_].*)$#$1#"), + urn_mapping (urn_mapping_), + nsr_mapping (nsr_mapping_), + nsm_mapping (nsm_mapping_), + include_mapping (include_mapping_), + reserved_name_map (reserved_name_map_), + keyword_set (keyword_set_) + { + // Export symbol. + // + { + String es (ops.export_symbol ()); + type_exp_ = es ? es + L" " : es; + inst_exp_ = es ? es + L"\n" : es; + } + + // Resolve and cache XML Schema namespace. + // + { + SemanticGraph::Nameable* n; + + if (schema_root.names_begin ()->name () == + L"http://www.w3.org/2001/XMLSchema") + { + // schema_root is the XML Schema itself. + // + n = &schema_root.names_begin ()->named (); + } + else + { + // Otherwise, the first used schema is implied XML Schema. + // + SemanticGraph::Uses& u = *schema_root.uses_begin (); + assert (u.is_a ()); + n = &u.schema ().names_begin ()->named (); + } + + xs_ns_ = dynamic_cast (n); + } + + // String type. + // + if (char_type == L"char") + string_type_ = L"::std::string"; + else if (char_type == L"wchar_t") + string_type_ = L"::std::wstring"; + else + string_type_ = L"::std::basic_string< " + char_type + L" >"; + + // Automatic pointer type. + // + auto_ptr_ = std >= cxx_version::cxx11 + ? "::std::unique_ptr" + : "::std::auto_ptr"; + + // Default encoding. + // + if (!char_encoding) + { + if (char_type == L"char") + char_encoding = L"utf8"; + else + char_encoding = L"auto"; + } + + // Default mapping. + // + nsr_mapping_.push_back ( + Regex (L"#^.* (.*?/)??" L"(([a-zA-Z_]\\w*)(/[a-zA-Z_]\\w*)*)/?$#$2#")); + nsr_mapping_.push_back ( + Regex (L"#^.* http://www\\.w3\\.org/2001/XMLSchema$#xml_schema#")); + + // Custom regex mapping. + // + for (NarrowStrings::const_iterator i (ops.namespace_regex ().begin ()), + e (ops.namespace_regex ().end ()); i != e; ++i) + { + nsr_mapping_.push_back (Regex (String (*i))); + } + + // Custom direct mapping. + // + for (NarrowStrings::const_iterator i (ops.namespace_map ().begin ()), + e (ops.namespace_map ().end ()); i != e; ++i) + { + String s (*i); + + // Split the string in two parts at the last '='. + // + size_t pos (s.rfind ('=')); + + if (pos == String::npos) + throw InvalidNamespaceMapping (s, "delimiter ('=') not found"); + + // Empty xml_ns designates the no-namespace case. + // + String xml_ns (s, 0, pos); + String cxx_ns (s, pos + 1); + + if (!cxx_ns.empty () && !cxx_id_expr.match (cxx_ns)) + throw InvalidNamespaceMapping (s, "invalid C++ identifier"); + + nsm_mapping_[xml_ns] = cxx_ns; + } + + // Include path regex + // + for (NarrowStrings::const_iterator i (ops.include_regex ().begin ()), + e (ops.include_regex ().end ()); i != e; ++i) + { + include_mapping_.push_back (Regex (String (*i))); + } + + // Reserved names. + // + for (NarrowStrings::const_iterator i (ops.reserved_name ().begin ()), + e (ops.reserved_name ().end ()); i != e; ++i) + { + String s (*i); + + // Split the string in two parts at '='. + // + size_t pos (s.find ('=')); + + if (pos == String::npos) + reserved_name_map_[s] = L""; + else + reserved_name_map_[String (s, 0, pos)] = String (s, pos + 1); + } + + // Populate the keyword set. + // + for (size_t i (0); i < sizeof (keywords) / sizeof (char*); ++i) + keyword_set_.insert (keywords[i]); + } + + String Context:: + ns_name (SemanticGraph::Namespace& ns) + { + using SemanticGraph::Schema; + using SemanticGraph::Includes; + using SemanticGraph::Imports; + using SemanticGraph::Implies; + using SemanticGraph::Sources; + + String tmp; + MapMapping::const_iterator i (nsm_mapping.find (ns.name ())); + + if (i != nsm_mapping.end ()) + { + tmp = i->second; + } + else + { + SemanticGraph::Path path; + Schema& schema (dynamic_cast (ns.scope ())); + + if (schema.used_p ()) + { + // Here we need to detect a special multi-schema compilation + // case where the root schemas are imported into a special + // schema that doesn't have a namespace. + // + SemanticGraph::Uses& u (*schema.used_begin ()); + SemanticGraph::Schema& s (u.user ()); + + if (s.names_begin () != s.names_end ()) + path = u.path (); + } + else + path = schema_path; + + String pair; + + if (!path.empty ()) + { + path.normalize (); + + // Try to use the portable representation of the path. If that + // fails, fall back to the native representation. + // + try + { + pair = path.posix_string (); + } + catch (SemanticGraph::InvalidPath const&) + { + pair = path.string (); + } + } + + pair += L' ' + ns.name (); + + // Check cache first + // + MappingCache::const_iterator i (ns_mapping_cache.find (pair)); + + if (i != ns_mapping_cache.end ()) + { + tmp = i->second; + } + else + { + bool trace (options.namespace_regex_trace ()); + + if (trace) + wcerr << "namespace: '" << pair << "'" << endl; + + bool found (false); + Regex colon (L"#/#::#"); + + for (RegexMapping::const_reverse_iterator e (nsr_mapping.rbegin ()); + e != nsr_mapping.rend (); ++e) + { + if (trace) + wcerr << "try: '" << e->regex () << "' : "; + + if (e->match (pair)) + { + tmp = e->replace (pair); + tmp = colon.replace (tmp); // replace `/' with `::' + + // Check the result. + // + found = cxx_id_expr.match (tmp); + + if (trace) + wcerr << "'" << tmp << "' : "; + } + + if (trace) + wcerr << (found ? '+' : '-') << endl; + + if (found) + break; + } + + if (!found) + { + String const& n (ns.name ()); + + // Check if the name is valid by itself. + // + if (n.empty ()) + { + // Empty name denotes a no-namespace case. + // + tmp = n; + } + else + { + tmp = colon.replace (n); // replace `/' with `::' + + if (!cxx_id_expr.match (tmp)) + { + // See if this is a urn-style namespace. + // + if (urn_mapping.match (n)) + { + Regex filter (L"#[.:-]#_#"); + tmp = urn_mapping.replace (n); + tmp = filter.replace (tmp); + + if (!cxx_id_expr.match (tmp)) + throw NoNamespaceMapping ( + ns.file (), ns.line (), ns.column (), ns.name ()); + } + else + throw NoNamespaceMapping ( + ns.file (), ns.line (), ns.column (), ns.name ()); + } + } + } + + // Add the mapping to the cache. + // + ns_mapping_cache[pair] = tmp; + } + } + + + // Parse resulting namespace string and id() each name. + // + String r; + String::size_type b (0), e; + + do + { + e = tmp.find (L"::", b); + + String name (tmp, b, e == tmp.npos ? e : e - b); + + if (!name.empty ()) + r += L"::" + escape (name); + + b = e; + + if (b == tmp.npos) + break; + + b += 2; + + } while (true); + + return r; + } + + SemanticGraph::Namespace& Context:: + xs_ns () + { + return *xs_ns_; + } + + String Context:: + xs_ns_name () + { + return ns_name (*xs_ns_); + } + + SemanticGraph::Namespace& Context:: + namespace_ (SemanticGraph::Nameable& n) + { + // The basic idea goes like this: go up Names edges until you + // reach Namespace. There are, however, anonymous types which + // need special handling. In the case of an anonymous type we + // will go up the first Belongs edge (because the first edge + // is where the type was defined. + // + + if (n.named_p ()) + { + SemanticGraph::Scope& s (n.scope ()); + + SemanticGraph::Namespace* ns ( + dynamic_cast (&n)); + + return ns ? *ns : namespace_ (s); + } + else + { + SemanticGraph::Type& t (dynamic_cast (n)); + + SemanticGraph::Belongs& b (*t.classifies_begin ()); + + return namespace_ (b.instance ()); + } + } + + String Context:: + xml_ns_name (SemanticGraph::Nameable& n) + { + return namespace_ (n).name (); + } + + String Context:: + fq_name (SemanticGraph::Nameable& n, char const* name_key) + { + using namespace SemanticGraph; + + String r; + + if (dynamic_cast (&n)) + { + return L""; // Map to global namespace. + } + else if (SemanticGraph::Namespace* ns = + dynamic_cast (&n)) + { + r = ns_name (*ns); + } + else + { + r = fq_name (n.scope ()); + r += L"::"; + r += n.context ().get (name_key); + } + + return r; + } + + SemanticGraph::Type& Context:: + ultimate_base (SemanticGraph::Complex& c) + { + using namespace SemanticGraph; + + Type* b (&c.inherits ().base ()); + + while (true) + { + Complex* cb (dynamic_cast (b)); + + if (cb != 0 && cb->inherits_p ()) + { + b = &cb->inherits ().base (); + continue; + } + + break; + } + + return *b; + } + + String Context:: + escape (String const& name) + { + String r; + size_t n (name.size ()); + + // In most common cases we will have that many chars. + // + r.reserve (n); + + for (size_t i (0); i < n; ++i) + { + bool first (i == 0); + + unsigned int u (unicode_char (name, i)); // May advance i. + + if (first) + { + if (!((u >= 'a' && u <= 'z') || + (u >= 'A' && u <= 'Z') || + u == '_')) + r = (u >= '0' && u <= '9') ? L"cxx_" : L"cxx"; + } + + if (!((u >= 'a' && u <= 'z') || + (u >= 'A' && u <= 'Z') || + (u >= '0' && u <= '9') || + u == '_')) + r.push_back ('_'); + else + r.push_back (static_cast (u)); + } + + if (r.empty ()) + r = L"cxx"; + + // Custom reserved words. + // + ReservedNameMap::const_iterator i (reserved_name_map.find (r)); + + if (i != reserved_name_map.end ()) + { + if (i->second) + return i->second; + else + r += L'_'; + } + + // Keywords + // + if (keyword_set.find (r) != keyword_set.end ()) + { + r += L'_'; + + // Re-run custom words. + // + i = reserved_name_map.find (r); + + if (i != reserved_name_map.end ()) + { + if (i->second) + return i->second; + else + r += L'_'; + } + } + + return r; + } + + // String escaping. + // + + String + charlit (unsigned int u) + { + String r ("\\x"); + bool lead (true); + + for (int i (7); i >= 0; --i) + { + unsigned int x ((u >> (i * 4)) & 0x0F); + + if (lead) + { + if (x == 0) + continue; + + lead = false; + } + + r += x < 10 ? ('0' + x) : ('A' + x - 10); + } + + return r; + } + + String + strlit_ascii (String const& str) + { + String r; + size_t n (str.size ()); + + // In most common cases we will have that many chars. + // + r.reserve (n + 2); + + r += '"'; + + bool escape (false); + + for (size_t i (0); i < n; ++i) + { + unsigned int u (Context::unicode_char (str, i)); // May advance i. + + // [128 - ] - unrepresentable + // 127 - \x7F + // [32 - 126] - as is + // [0 - 31] - \X or \xXX + // + + if (u < 32 || u == 127) + { + switch (u) + { + case L'\n': + { + r += L"\\n"; + break; + } + case L'\t': + { + r += L"\\t"; + break; + } + case L'\v': + { + r += L"\\v"; + break; + } + case L'\b': + { + r += L"\\b"; + break; + } + case L'\r': + { + r += L"\\r"; + break; + } + case L'\f': + { + r += L"\\f"; + break; + } + case L'\a': + { + r += L"\\a"; + break; + } + default: + { + r += charlit (u); + escape = true; + break; + } + } + } + else if (u < 127) + { + if (escape) + { + // Close and open the string so there are no clashes. + // + r += '"'; + r += '"'; + + escape = false; + } + + switch (u) + { + case L'"': + { + r += L"\\\""; + break; + } + case L'\\': + { + r += L"\\\\"; + break; + } + default: + { + r += static_cast (u); + break; + } + } + } + else + { + // Unrepresentable character. + // + throw UnrepresentableCharacter (str, i + 1); + } + } + + r += '"'; + + return r; + } + + const unsigned int utf8_first_char_mask[5] = + { + 0x00, 0x00, 0xC0, 0xE0, 0xF0 + }; + + String + strlit_utf8 (String const& str) + { + String r; + size_t n (str.size ()); + + // In most common cases we will have that many chars. + // + r.reserve (n + 2); + + r += '"'; + + bool escape (false); + + for (size_t i (0); i < n; ++i) + { + unsigned int u (Context::unicode_char (str, i)); // May advance i. + + // [128 - ] - UTF-8 + // 127 - \x7F + // [32 - 126] - as is + // [0 - 31] - \X or \xXX + // + + if (u < 32 || u == 127) + { + switch (u) + { + case L'\n': + { + r += L"\\n"; + break; + } + case L'\t': + { + r += L"\\t"; + break; + } + case L'\v': + { + r += L"\\v"; + break; + } + case L'\b': + { + r += L"\\b"; + break; + } + case L'\r': + { + r += L"\\r"; + break; + } + case L'\f': + { + r += L"\\f"; + break; + } + case L'\a': + { + r += L"\\a"; + break; + } + default: + { + r += charlit (u); + escape = true; + break; + } + } + } + else if (u < 127) + { + if (escape) + { + // Close and open the string so there are no clashes. + // + r += '"'; + r += '"'; + + escape = false; + } + + switch (u) + { + case L'"': + { + r += L"\\\""; + break; + } + case L'\\': + { + r += L"\\\\"; + break; + } + default: + { + r += static_cast (u); + break; + } + } + } + else + { + unsigned int count (0); + unsigned int tmp[4]; + + if (u < 0x800) + count = 2; + else if (u < 0x10000) + count = 3; + else if (u < 0x110000) + count = 4; + + switch (count) + { + case 4: + { + tmp[3] = (u | 0x80UL) & 0xBFUL; + u >>= 6; + } + // Fall through. + case 3: + { + tmp[2] = (u | 0x80UL) & 0xBFUL; + u >>= 6; + } + // Fall through. + case 2: + { + tmp[1] = (u | 0x80UL) & 0xBFUL; + u >>= 6; + } + // Fall through. + case 1: + { + tmp[0] = u | utf8_first_char_mask[count]; + break; + } + default: + assert (false); + } + + for (unsigned int j (0); j < count; ++j) + r += charlit (tmp[j]); + + escape = true; + } + } + + r += '"'; + + return r; + } + + String + strlit_iso8859_1 (String const& str) + { + String r; + size_t n (str.size ()); + + // In most common cases we will have that many chars. + // + r.reserve (n + 2); + + r += '"'; + + bool escape (false); + + for (size_t i (0); i < n; ++i) + { + unsigned int u (Context::unicode_char (str, i)); // May advance i. + + // [256 - ] - unrepresentable + // [127 - 255] - \xXX + // [32 - 126] - as is + // [0 - 31] - \X or \xXX + // + + if (u < 32) + { + switch (u) + { + case L'\n': + { + r += L"\\n"; + break; + } + case L'\t': + { + r += L"\\t"; + break; + } + case L'\v': + { + r += L"\\v"; + break; + } + case L'\b': + { + r += L"\\b"; + break; + } + case L'\r': + { + r += L"\\r"; + break; + } + case L'\f': + { + r += L"\\f"; + break; + } + case L'\a': + { + r += L"\\a"; + break; + } + default: + { + r += charlit (u); + escape = true; + break; + } + } + } + else if (u < 127) + { + if (escape) + { + // Close and open the string so there are no clashes. + // + r += '"'; + r += '"'; + + escape = false; + } + + switch (u) + { + case L'"': + { + r += L"\\\""; + break; + } + case L'\\': + { + r += L"\\\\"; + break; + } + default: + { + r += static_cast (u); + break; + } + } + } + else if (u < 256) + { + r += charlit (u); + escape = true; + } + else + { + // Unrepresentable character. + // + throw UnrepresentableCharacter (str, i + 1); + } + } + + r += '"'; + + return r; + } + + String + strlit_utf32 (String const& str) + { + String r; + size_t n (str.size ()); + + // In most common cases we will have that many chars. + // + r.reserve (n + 3); + + r += L"L\""; + + bool escape (false); + + for (size_t i (0); i < n; ++i) + { + unsigned int u (Context::unicode_char (str, i)); // May advance i. + + // [128 - ] - \xUUUUUUUU + // 127 - \x7F + // [32 - 126] - as is + // [0 - 31] - \X or \xXX + // + + if (u < 32 || u == 127) + { + switch (u) + { + case L'\n': + { + r += L"\\n"; + break; + } + case L'\t': + { + r += L"\\t"; + break; + } + case L'\v': + { + r += L"\\v"; + break; + } + case L'\b': + { + r += L"\\b"; + break; + } + case L'\r': + { + r += L"\\r"; + break; + } + case L'\f': + { + r += L"\\f"; + break; + } + case L'\a': + { + r += L"\\a"; + break; + } + default: + { + r += charlit (u); + escape = true; + break; + } + } + } + else if (u < 127) + { + if (escape) + { + // Close and open the string so there are no clashes. C++11 + // requires a space between " and L. + // + r += L"\" L\""; + escape = false; + } + + switch (u) + { + case L'"': + { + r += L"\\\""; + break; + } + case L'\\': + { + r += L"\\\\"; + break; + } + default: + { + r += static_cast (u); + break; + } + } + } + else + { + r += charlit (u); + escape = true; + } + } + + r += '"'; + + return r; + } + + String Context:: + strlit (String const& str) + { + // First see if we have a custom mapping. + // + assert (string_literal_map != 0); + StringLiteralMap::const_iterator i (string_literal_map->find (str)); + + if (i != string_literal_map->end ()) + return i->second; + + if (char_type == L"char") + { + if (char_encoding == L"utf8") + return strlit_utf8 (str); + else if (char_encoding == L"iso8859-1") + return strlit_iso8859_1 (str); + else + { + // For LCP, custom, and other unknown encodings, use ASCII. + // + return strlit_ascii (str); + } + } + else + return strlit_utf32 (str); + } + + String Context:: + comment (String const& str) + { + String r; + + wchar_t const* s (str.c_str ()); + size_t size (str.size ()); + + // In most common cases we will have that many chars. + // + r.reserve (size); + + for (wchar_t const* p (s); p < s + size; ++p) + { + unsigned int u (unicode_char (p)); // May advance p. + + // We are going to treat \v, \f and \n as unrepresentable + // here even though they can be present in C++ source code. + // + if (u > 127 || (u < 32 && u != '\t')) + r += L'?'; + else + r += static_cast (u); + } + + return r; + } + + String Context:: + process_include_path (String const& name) const + { + String path (String (options.include_prefix ()) + name); + bool trace (options.include_regex_trace ()); + + if (trace) + wcerr << "include: '" << path << "'" << endl; + + String r; + bool found (false); + + for (RegexMapping::const_reverse_iterator e (include_mapping.rbegin ()); + e != include_mapping.rend (); ++e) + { + if (trace) + wcerr << "try: '" << e->regex () << "' : "; + + if (e->match (path)) + { + r = e->replace (path); + found = true; + + if (trace) + wcerr << "'" << r << "' : "; + } + + if (trace) + wcerr << (found ? '+' : '-') << endl; + + if (found) + break; + } + + if (!found) + r = path; + + if (!r.empty () && r[0] != L'"' && r[0] != L'<') + { + wchar_t op (options.include_with_brackets () ? L'<' : L'"'); + wchar_t cl (options.include_with_brackets () ? L'>' : L'"'); + r = op + r + cl; + } + + return r; + } + + // Namespace + // + + void Namespace:: + pre (Type& n) + { + String ns (ctx_.ns_name (n)); + + String::size_type b (0), e; + + if (st_) + st_->enter (n, L"", ns ? false : true); + + do + { + e = ns.find (L"::", b); + + String name (ns, b, e == ns.npos ? e : e - b); + + if (!name.empty ()) + { + if (st_) + st_->enter (n, name, e == ns.npos); + + ctx_.os << "namespace " << name << "{"; + } + + b = e; + + if (b == ns.npos) + break; + + b += 2; + + } while (true); + } + + void Namespace:: + post (Type& n) + { + String ns (ctx_.ns_name (n)); + + String::size_type b (0), e; + + do + { + e = ns.find (L"::", b); + + String name (ns, b, e == ns.npos ? e : e - b); + + if (!name.empty ()) + { + ctx_.os << "}"; + + if (st_) + st_->leave (); + } + + + b = e; + + if (b == ns.npos) + break; + + b += 2; + + } + while (true); + + if (st_) + st_->leave (); + } +} diff --git a/xsd/xsd/cxx/elements.hxx b/xsd/xsd/cxx/elements.hxx new file mode 100644 index 0000000..62ba97c --- /dev/null +++ b/xsd/xsd/cxx/elements.hxx @@ -0,0 +1,626 @@ +// file : xsd/cxx/elements.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_ELEMENTS_HXX +#define XSD_CXX_ELEMENTS_HXX + +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include + +#include +#include + +namespace CXX +{ + using std::endl; + + // On some platforms std::toupper can be something other than a + // function with C++ linkage. + // + wchar_t + upcase (wchar_t c); + + + // Exceptions. + // + + struct UnrepresentableCharacter + { + UnrepresentableCharacter (String const& str, size_t pos) + : str_ (str), pos_ (pos) + { + } + + String const& + string () const + { + return str_; + } + + size_t + position () const + { + return pos_; + } + + private: + String str_; + size_t pos_; + }; + + struct NoNamespaceMapping + { + NoNamespaceMapping (SemanticGraph::Path const& file, + size_t line, + size_t column, + String const& ns) + : file_ (file), + line_ (line), + column_ (column), + ns_ (ns) + { + } + + + SemanticGraph::Path const& + file () const + { + return file_; + } + + size_t + line () const + { + return line_; + } + + size_t + column () const + { + return column_; + } + + String const& + ns () const + { + return ns_; + } + + private: + SemanticGraph::Path file_; + size_t line_; + size_t column_; + String ns_; + }; + + struct InvalidNamespaceMapping + { + InvalidNamespaceMapping (String const& mapping, + String const& reason) + : mapping_ (mapping), reason_ (reason) + { + } + + String const& + mapping () const + { + return mapping_; + } + + String const& + reason () const + { + return reason_; + } + + private: + String mapping_; + String reason_; + }; + + // + // + class Context + { + public: + typedef cutl::re::wregex RegexPat; + typedef cutl::re::wregexsub Regex; + typedef std::vector RegexMapping; + typedef std::map MapMapping; + typedef std::map MappingCache; + + typedef std::map ReservedNameMap; + typedef std::set KeywordSet; + + typedef CXX::options options_type; + + public: + Context (std::wostream& o, + SemanticGraph::Schema& root, + SemanticGraph::Path const& path, + options_type const& ops, + StringLiteralMap const* custom_literals_map); + + protected: + Context (Context& c) + : os (c.os), + schema_root (c.schema_root), + schema_path (c.schema_path), + options (c.options), + std (c.std), + char_type (c.char_type), + char_encoding (c.char_encoding), + L (c.L), + string_type (c.string_type), + auto_ptr (c.auto_ptr), + string_literal_map (c.string_literal_map), + type_exp (c.type_exp), + inst_exp (c.inst_exp), + inl (c.inl), + ns_mapping_cache (c.ns_mapping_cache), + xs_ns_ (c.xs_ns_), + cxx_id_expr (c.cxx_id_expr), + urn_mapping (c.urn_mapping), + nsr_mapping (c.nsr_mapping), + nsm_mapping (c.nsm_mapping), + include_mapping (c.include_mapping), + reserved_name_map (c.reserved_name_map), + keyword_set (c.keyword_set) + { + } + + Context (Context& c, std::wostream& o) + : os (o), + schema_root (c.schema_root), + schema_path (c.schema_path), + options (c.options), + std (c.std), + char_type (c.char_type), + char_encoding (c.char_encoding), + L (c.L), + string_type (c.string_type), + auto_ptr (c.auto_ptr), + string_literal_map (c.string_literal_map), + type_exp (c.type_exp), + inst_exp (c.inst_exp), + inl (c.inl), + ns_mapping_cache (c.ns_mapping_cache), + xs_ns_ (c.xs_ns_), + cxx_id_expr (c.cxx_id_expr), + urn_mapping (c.urn_mapping), + nsr_mapping (c.nsr_mapping), + nsm_mapping (c.nsm_mapping), + include_mapping (c.include_mapping), + reserved_name_map (c.reserved_name_map), + keyword_set (c.keyword_set) + { + } + + public: + static String + unclash (String const& name, String const& new_name) + { + return name == new_name ? (new_name + L'_') : new_name; + } + + public: + // Return UTF-32 character starting at this position. Position is + // advanced by 1 if this Unicode character takes more than one + // underlying character. + // + static unsigned int + unicode_char (String const& str, size_t& pos); + + static unsigned int + unicode_char (wchar_t const*& p); + + // Escape C++ keywords and illegal characters. + // + String + escape (String const&); + + // Create a string literal so that it can be used in C++ source + // code. It includes "". + // + String + strlit (String const&); + + // Escape the string so that it can be used in C++ comment. + // + String + comment (String const&); + + // Translate XML namespace name to a C++ identifier. + // + String + ns_name (SemanticGraph::Namespace&); + + // XML Schema namespace. + // + SemanticGraph::Namespace& + xs_ns (); + + // C++ namespace for XML Schema. + // + String + xs_ns_name (); + + // + // + SemanticGraph::Namespace& + namespace_ (SemanticGraph::Nameable& n); + + // Original XML namespace name. + // + String + xml_ns_name (SemanticGraph::Nameable& ns); + + + // Fully-qualified C++ name. + // + String + fq_name (SemanticGraph::Nameable& n, char const* name_key = "name"); + + public: + static SemanticGraph::Type& + ultimate_base (SemanticGraph::Complex&); + + public: + String + process_include_path (String const&) const; + + public: + static bool + skip (SemanticGraph::Member& m) + { + // "Subsequent" local element. + // + return !m.scope ().is_a () && + m.context ().count ("min") == 0; + } + + static size_t + min (SemanticGraph::Member const& m) + { + return m.context ().get ("min"); + } + + static size_t + min (SemanticGraph::Any const& a) + { + return a.context ().get ("min"); + } + + static size_t + max (SemanticGraph::Member const& m) + { + return m.context ().get ("max"); + } + + static size_t + max (SemanticGraph::Any const& a) + { + return a.context ().get ("max"); + } + + public: + // Get escaped name. + // + static String const& + ename (SemanticGraph::Nameable const& n) + { + return n.context ().get ("name"); + } + + public: + std::wostream& os; + + SemanticGraph::Schema& schema_root; + SemanticGraph::Path const& schema_path; + + options_type const& options; + + cxx_version std; + + String& char_type; + String& char_encoding; + String& L; // string literal prefix + String& string_type; + String& auto_ptr; + + StringLiteralMap const* string_literal_map; + + String& type_exp; + String& inst_exp; + String& inl; + + public: + MappingCache& ns_mapping_cache; + + private: + SemanticGraph::Path const schema_path_; + + SemanticGraph::Namespace* xs_ns_; + + String char_type_; + String char_encoding_; + String L_; + String string_type_; + String auto_ptr_; + + String type_exp_; + String inst_exp_; + String inl_; + + private: + RegexPat const cxx_id_expr_; + RegexPat const& cxx_id_expr; + Regex urn_mapping_; + RegexMapping nsr_mapping_; + MapMapping nsm_mapping_; + Regex const& urn_mapping; + RegexMapping const& nsr_mapping; + MapMapping const& nsm_mapping; + MappingCache ns_mapping_cache_; + + RegexMapping include_mapping_; + RegexMapping const& include_mapping; + + ReservedNameMap const& reserved_name_map; + ReservedNameMap reserved_name_map_; + + KeywordSet const& keyword_set; + KeywordSet keyword_set_; + }; + + inline unsigned int Context:: + unicode_char (String const& str, size_t& pos) + { + if (sizeof (wchar_t) == 4) + { + return str[pos]; + } + else if (sizeof (wchar_t) == 2) + { + wchar_t x (str[pos]); + + if (x < 0xD800 || x > 0xDBFF) + return x; + else + return ((x - 0xD800) << 10) + (str[++pos] - 0xDC00) + 0x10000; + } + else + return 0; + } + + inline unsigned int Context:: + unicode_char (wchar_t const*& p) + { + if (sizeof (wchar_t) == 4) + { + return *p; + } + else if (sizeof (wchar_t) == 2) + { + wchar_t x (*p); + + if (x < 0xD800 || x > 0xDBFF) + return x; + else + return ((x - 0xD800) << 10) + (*(++p) - 0xDC00) + 0x10000; + } + else + return 0; + } + + // Sources traverser that goes into each schema only once. + // + struct Sources: Traversal::Sources + { + virtual void + traverse (SemanticGraph::Sources& s) + { + if (schemas_.insert (&s.schema ()).second) + Traversal::Sources::traverse (s); + } + + private: + std::set schemas_; + }; + + // Usual namespace mapping. + // + struct Namespace: Traversal::Namespace + { + struct ScopeTracker + { + // First scope name if always empty (global scope). The last flag + // signals the last scope. + // + virtual void + enter (Type&, String const& name, bool last) = 0; + + virtual void + leave () = 0; + }; + + + Namespace (Context& c) + : ctx_ (c), st_ (0) + { + } + + Namespace (Context& c, ScopeTracker& st) + : ctx_ (c), st_ (&st) + { + } + + virtual void + pre (Type&); + + virtual void + post (Type&); + + private: + Context& ctx_; + ScopeTracker* st_; + }; + + // + // + template + struct Has : X + { + Has (bool& result) + : result_ (result) + { + } + + virtual void + traverse (typename X::Type&) + { + result_ = true; + } + + private: + bool& result_; + }; + + // Checks if scope 'Y' names any of 'X' + // + template + bool + has (Y& y) + { + using SemanticGraph::Scope; + + bool result (false); + Has t (result); + + for (Scope::NamesIterator i (y.names_begin ()), e (y.names_end ()); + !result && i != e; ++i) + t.dispatch (i->named ()); + + return result; + } + + // Checks if the compositor has any particle of 'X' + // + template + bool + has_particle (SemanticGraph::Compositor& y) + { + using SemanticGraph::Compositor; + + bool result (false); + Has t (result); + + for (Compositor::ContainsIterator i (y.contains_begin ()), + e (y.contains_end ()); !result && i != e; ++i) + { + SemanticGraph::Particle& p (i->particle ()); + + t.dispatch (p); + + if (!result && p.is_a ()) + result = has_particle (dynamic_cast (p)); + } + + return result; + } + + // Specialization for Complex + // + template + bool + has_particle (SemanticGraph::Complex& c) + { + return c.contains_compositor_p () && + has_particle (c.contains_compositor ().compositor ()); + } + + // Fundamental type mapping helper. + // + struct Fundamental: Traversal::Fundamental::Type, + Traversal::Fundamental::String, + Traversal::Fundamental::NormalizedString, + Traversal::Fundamental::Token, + Traversal::Fundamental::Name, + Traversal::Fundamental::NameToken, + Traversal::Fundamental::NCName, + Traversal::Fundamental::Id, + Traversal::Fundamental::IdRef + { + virtual void + fundamental_type (SemanticGraph::Fundamental::Type& t) = 0; + + virtual void + fundamental_template (SemanticGraph::Fundamental::Type& t) = 0; + + virtual void + traverse (SemanticGraph::Fundamental::Type& t) + { + fundamental_type (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::String& t) + { + fundamental_template (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::NormalizedString& t) + { + fundamental_template (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Token& t) + { + fundamental_template (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Name& t) + { + fundamental_template (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::NameToken& t) + { + fundamental_template (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::NCName& t) + { + fundamental_template (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Id& t) + { + fundamental_template (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::IdRef& t) + { + fundamental_template (t); + } + }; +} + +#endif // XSD_CXX_TREE_ELEMENTS_HXX diff --git a/xsd/xsd/cxx/literal-map.cxx b/xsd/xsd/cxx/literal-map.cxx new file mode 100644 index 0000000..b81f249 --- /dev/null +++ b/xsd/xsd/cxx/literal-map.cxx @@ -0,0 +1,261 @@ +// file : xsd/cxx/literal-map.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include // std::unique_ptr +#include // std::size_t +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include + +#include + +#include + +using namespace std; +using namespace xercesc; +namespace XML = XSDFrontend::XML; + +namespace CXX +{ + class Handler: public DefaultHandler + { + public: + struct Failed {}; + + Handler (String const& file, StringLiteralMap& map) + : state_ (s_init), file_ (file), map_ (map) + { + } + + virtual void + setDocumentLocator (const Locator* const l) + { + locator_ = l; + } + + virtual void + startElement (const XMLCh* const, + const XMLCh* const lname, + const XMLCh* const, + const xercesc::Attributes&) + { + String n (XML::transcode (lname)); + + if (n == L"string-literal-map" && state_ == s_init) + state_ = s_map; + else if (n == L"entry" && state_ == s_map) + { + str_seen_ = false; + lit_seen_ = false; + state_ = s_entry; + } + else if (n == L"string" && state_ == s_entry) + { + str_seen_ = true; + str_.clear (); + state_ = s_string; + } + else if (n == L"literal" && state_ == s_entry) + { + lit_seen_ = true; + lit_.clear (); + state_ = s_literal; + } + else + { + wcerr << file_ << ":" << line () << ":" << col () << ": error: " + << "unexpected element '" << n << "'" << endl; + throw Failed (); + } + } + + virtual void + endElement (const XMLCh* const, + const XMLCh* const lname, + const XMLCh* const) + { + String n (XML::transcode (lname)); + + if (n == L"string-literal-map") + state_ = s_init; + else if (n == L"entry") + { + if (!str_seen_) + { + wcerr << file_ << ":" << line () << ":" << col () << ": error: " + << "expected 'string' element" << endl; + throw Failed (); + } + + if (!lit_seen_) + { + wcerr << file_ << ":" << line () << ":" << col () << ": error: " + << "expected 'literal' element" << endl; + throw Failed (); + } + + map_[str_] = lit_; + state_ = s_map; + } + else if (n == L"string") + state_ = s_entry; + else if (n == L"literal") + state_ = s_entry; + } + + virtual void + characters (const XMLCh* const s, const XMLSize_t length) + { + String str (XML::transcode (s, length)); + + if (state_ == s_string) + str_ += str; + else if (state_ == s_literal) + lit_ += str; + else + { + for (size_t i (0); i < str.size (); ++i) + { + wchar_t c (str[i]); + + if (c != 0x20 && c != 0x0A && c != 0x0D && c != 0x09) + { + wcerr << file_ << ":" << line () << ":" << col () << ": error: " + << "unexpected character data" << endl; + throw Failed (); + } + } + } + } + + // Error hanlding. + // + enum Severity {s_warning, s_error, s_fatal}; + + virtual void + warning (const SAXParseException& e) + { + handle (e, s_warning); + } + + virtual void + error (const SAXParseException& e) + { + handle (e, s_error); + } + + virtual void + fatalError (const SAXParseException& e) + { + handle (e, s_fatal); + } + + virtual void + resetErrors () + { + } + + void + handle (const SAXParseException& e, Severity s) + { + String msg (XML::transcode (e.getMessage ())); + + wcerr << file_ << ":" + << e.getLineNumber () << ":" << e.getColumnNumber () << ": " + << (s == s_warning ? "warning: " : "error: ") << msg << endl; + + if (s != s_warning) + throw Failed (); + } + + size_t + line () const + { + return locator_ != 0 + ? static_cast (locator_->getLineNumber ()) + : 0; + } + + size_t + col () const + { + return locator_ != 0 + ? static_cast (locator_->getColumnNumber ()) + : 0; + } + + private: + const Locator* locator_; + + enum + { + s_init, + s_map, + s_entry, + s_string, + s_literal + } state_; + + String file_; + StringLiteralMap& map_; + + bool str_seen_; + bool lit_seen_; + + String str_; + String lit_; + }; + + bool + read_literal_map (NarrowString const& file, StringLiteralMap& map) + { + try + { + // Try to open the file with fstream. This way we get to + // report the error in a consistent manner. + // + { + ifstream ifs (file.c_str ()); + if (!ifs.is_open ()) + { + wcerr << file.c_str () << ": unable to open in read mode" << endl; + return false; + } + } + + String wfile (file); + + LocalFileInputSource is (XML::XMLChString (wfile).c_str ()); + Handler h (wfile, map); + + unique_ptr parser ( + XMLReaderFactory::createXMLReader ()); + + parser->setFeature (XMLUni::fgSAX2CoreNameSpaces, true); + parser->setFeature (XMLUni::fgSAX2CoreNameSpacePrefixes, true); + parser->setFeature (XMLUni::fgSAX2CoreValidation, false); + parser->setFeature (XMLUni::fgXercesSchema, false); + parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); + + parser->setErrorHandler (&h); + parser->setContentHandler (&h); + + parser->parse (is); + } + catch (Handler::Failed const&) + { + return false; + } + + return true; + } +} diff --git a/xsd/xsd/cxx/literal-map.hxx b/xsd/xsd/cxx/literal-map.hxx new file mode 100644 index 0000000..bc8fabb --- /dev/null +++ b/xsd/xsd/cxx/literal-map.hxx @@ -0,0 +1,19 @@ +// file : xsd/cxx/literal-map.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_LITERAL_MAP_HXX +#define XSD_CXX_LITERAL_MAP_HXX + +#include + +#include + +namespace CXX +{ + typedef std::map StringLiteralMap; + + bool + read_literal_map (NarrowString const& file, StringLiteralMap& map); +} + +#endif // XSD_CXX_LITERAL_MAP_HXX diff --git a/xsd/xsd/cxx/option-types.cxx b/xsd/xsd/cxx/option-types.cxx new file mode 100644 index 0000000..ad8a3c9 --- /dev/null +++ b/xsd/xsd/cxx/option-types.cxx @@ -0,0 +1,47 @@ +// file : xsd/cxx/option-types.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include + +#include + +using namespace std; + +namespace CXX +{ + // + // cxx_version + // + + static const char* cxx_version_[] = + { + "c++98", + "c++11" + }; + + string cxx_version:: + string () const + { + return cxx_version_[v_]; + } + + istream& + operator>> (istream& is, cxx_version& v) + { + string s; + is >> s; + + if (!is.fail ()) + { + if (s == "c++98") + v = cxx_version::cxx98; + else if (s == "c++11") + v = cxx_version::cxx11; + else + is.setstate (istream::failbit); + } + + return is; + } +} diff --git a/xsd/xsd/cxx/option-types.hxx b/xsd/xsd/cxx/option-types.hxx new file mode 100644 index 0000000..bbb15b3 --- /dev/null +++ b/xsd/xsd/cxx/option-types.hxx @@ -0,0 +1,34 @@ +// file : xsd/cxx/option-types.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_XSD_OPTION_TYPES_HXX +#define XSD_XSD_OPTION_TYPES_HXX + +#include +#include + +namespace CXX +{ + struct cxx_version + { + enum value + { + cxx98, + cxx11 + }; + + cxx_version (value v = value (0)) : v_ (v) {} + operator value () const {return v_;} + + std::string + string () const; + + private: + value v_; + }; + + std::istream& + operator>> (std::istream&, cxx_version&); +} + +#endif // XSD_XSD_OPTION_TYPES_HXX diff --git a/xsd/xsd/cxx/options.cli b/xsd/xsd/cxx/options.cli new file mode 100644 index 0000000..2c50f19 --- /dev/null +++ b/xsd/xsd/cxx/options.cli @@ -0,0 +1,550 @@ +// file : xsd/cxx/options.cli +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include ; // std::size_t + +include ; // NarrowString, NarrowStrings + +include ; + +include ; + +namespace CXX +{ + class options: ::options = 0 + { + // Language. + // + cxx_version --std = cxx_version::cxx98 + { + "", + "Specify the C++ standard that the generated code should conform to. + Valid values are \cb{c++98} (default) and \cb{c++11}. + + The C++ standard affects various aspects of the generated code that + are discussed in more detail in various mapping-specific + documentation. Overall, when C++11 is selected, the generated + code relies on the move semantics and uses \cb{std::unique_ptr} + instead of deprecated \cb{std::auto_ptr}. + + When the C++11 mode is selected, you normally don't need to + perform any extra steps other than enable C++11 in your C++ + compiler, if required. The XSD compiler will automatically + add the necessary macro defines to the generated header files + that will switch the header-only XSD runtime library (\cb{libxsd}) + to the C++11 mode. However, if you include any of the XSD runtime + headers directly in your application (normally you just include + the generated headers), then you will need to define the + \cb{XSD_CXX11} macro for your entire project." + }; + + // Character type and encoding. + // + NarrowString --char-type = "char" + { + "", + "Generate code using the provided character instead of the + default \cb{char}. Valid values are \cb{char} and \cb{wchar_t}." + }; + + NarrowString --char-encoding + { + "", + "Specify the character encoding that should be used in the generated + code. Valid values for the \cb{char} character type are \cb{utf8} + (default), \cb{iso8859-1}, \cb{lcp} (Xerces-C++ local code page), + and \cb{custom}. If you pass \cb{custom} as the value then you will + need to include the transcoder implementation header for your + encoding at the beginning of the generated header files (see the + \cb{--hxx-prologue} option). + + For the \cb{wchar_t} character type the only valid value is \cb{auto} + and the encoding is automatically selected between UTF-16 and + UTF-32/UCS-4, depending on the \cb{wchar_t} type size." + }; + + // Output options. + // + NarrowString --output-dir + { + "", + "Write generated files to instead of the current directory." + }; + + bool --generate-inline + { + "Generate simple functions inline. This option triggers creation of + the inline file." + }; + + // Extern XML Schema. + // + bool --generate-xml-schema + { + "Generate a C++ header file as if the schema being compiled defines the + XML Schema namespace. For the C++/Tree mapping, the resulting file will + contain definitions for all XML Schema built-in types. For the + C++/Parser mapping, the resulting file will contain definitions for + all the parser skeletons and implementations corresponding to the + XML Schema built-in types. + + The schema file provided to the compiler need not exist and is only + used to derive the name of the resulting header file. Use the + \cb{--extern-xml-schema} option to include this file in the + generated files for other schemas." + }; + + NarrowString --extern-xml-schema + { + "", + "Include a header file derived from instead of generating the + XML Schema namespace mapping inline. The provided file need not + exist and is only used to derive the name of the included header + file. Use the \cb{--generate-xml-schema} option to generate this + header file." + }; + + // Namespace mapping. + // + NarrowStrings --namespace-map + { + "=", + "Map XML Schema namespace to C++ namespace . Repeat + this option to specify mapping for more than one XML Schema namespace. + For example, the following option: + + \cb{--namespace-map http://example.com/foo/bar=foo::bar} + + Will map the \cb{http://example.com/foo/bar} XML Schema namespace to + the \cb{foo::bar} C++ namespace." + }; + + NarrowStrings --namespace-regex + { + "", + "Add to the list of regular expressions used to translate XML + Schema namespace names to C++ namespace names. is a Perl-like + regular expression in the form + \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. Any character can be + used as a delimiter instead of '\cb{/}'. Escaping of the delimiter + character in \ci{pattern} or \ci{replacement} is not supported. + + All the regular expressions are pushed into a stack with the last + specified expression considered first. The first match that + succeeds is used. Regular expressions are applied to a string in + the form + + \c{\i{filename} \i{namespace}} + + For example, if you have file \cb{hello.xsd} with namespace + \cb{http://example.com/hello} and you run \cb{xsd} on this file, + then the string in question will be: + + \cb{hello.xsd. http://example.com/hello} + + For the built-in XML Schema namespace the string is: + + \cb{XMLSchema.xsd http://www.w3.org/2001/XMLSchema} + + The following three steps are performed for each regular expression + until the match is found: + + 1. The expression is applied and if the result is empty the next + expression is considered. + + 2. All '\cb{/}' are replaced with '\cb{::}'. + + 3. The result is verified to be a valid C++ scope name (e.g., + \cb{foo::bar}). If this test succeeds, the result is used as a + C++ namespace name. + + As an example, the following expression maps XML Schema namespaces + in the form \cb{http://example.com/foo/bar} to C++ namespaces in the + form \cb{foo::bar}: + + \cb{%.* http://example.com/(.+)%$1%} + + See also the REGEX AND SHELL QUOTING section below." + }; + + bool --namespace-regex-trace + { + "Trace the process of applying regular expressions specified with the + \cb{--namespace-regex} option. Use this option to find out why your + regular expressions don't do what you expected them to do." + }; + + // Reserved names. + // + NarrowStrings --reserved-name + { + "[=]", + "Add name to the list of names that should not be used as + identifiers. The name can optionally be followed by \cb{=} and the + replacement name that should be used instead. All the C++ keywords + are already in this list." + }; + + // Include options. + // + bool --include-with-brackets + { + "Use angle brackets (<>) instead of quotes (\"\") in generated + \cb{#include} directives." + }; + + NarrowString --include-prefix + { + "", + "Add to generated \cb{#include} directive paths. + + For example, if you had the following import element in your schema + + \cb{} + + and compiled this fragment with \cb{--include-prefix schemas/}, then + the include directive in the generated code would be: + + \cb{#include \"schemas/base.hxx\"}" + }; + + NarrowStrings --include-regex + { + "", + "Add to the list of regular expressions used to transform + \cb{#include} directive paths. is a Perl-like regular + expression in the form \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. + Any character can be used as a delimiter instead of '\cb{/}'. Escaping + of the delimiter character in \ci{pattern} or \ci{replacement} is not + supported. + + All the regular expressions are pushed into a stack with the last + specified expression considered first. The first match that succeeds + is used. + + As an example, the following expression transforms paths in the form + \cb{schemas/foo/bar} to paths in the form \cb{generated/foo/bar}: + + \cb{%schemas/(.+)%generated/$1%} + + See also the REGEX AND SHELL QUOTING section below." + }; + + bool --include-regex-trace + { + "Trace the process of applying regular expressions specified with the + \cb{--include-regex} option. Use this option to find out why your + regular expressions don't do what you expected them to do." + }; + + NarrowString --guard-prefix + { + "", + "Add to generated header inclusion guards. The prefix is + transformed to upper case and characters that are illegal in a + preprocessor macro name are replaced with underscores. If this + option is not specified then the directory part of the input schema + file is used as a prefix." + }; + + // File suffixes. + // + NarrowString --hxx-suffix = ".hxx" + { + "", + "Use the provided instead of the default \cb{.hxx} to + construct the name of the header file. Note that this suffix is also + used to construct names of header files corresponding to + included/imported schemas." + }; + + NarrowString --ixx-suffix = ".ixx" + { + "", + "Use the provided instead of the default \cb{.ixx} to + construct the name of the inline file." + }; + + NarrowString --cxx-suffix = ".cxx" + { + "", + "Use the provided instead of the default \cb{.cxx} to + construct the name of the source file." + }; + + NarrowString --fwd-suffix = "-fwd.hxx" + { + "", + "Use the provided instead of the default \cb{-fwd.hxx} to + construct the name of the forward declaration file." + }; + + NarrowString --hxx-regex + { + "", + "Use the provided expression to construct the name of the header file. + is a Perl-like regular expression in the form + \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. + Note that this expression is also used to construct names of header + files corresponding to included/imported schemas. See also the REGEX + AND SHELL QUOTING section below." + }; + + NarrowString --ixx-regex + { + "", + "Use the provided expression to construct the name of the inline file. + is a Perl-like regular expression in the form + \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. See also the REGEX AND + SHELL QUOTING section below." + }; + + NarrowString --cxx-regex + { + "", + "Use the provided expression to construct the name of the source file. + is a Perl-like regular expression in the form + \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. See also the REGEX AND + SHELL QUOTING section below." + }; + + NarrowString --fwd-regex + { + "", + "Use the provided expression to construct the name of the forward + declaration file. is a Perl-like regular expression in the + form \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. See also the REGEX + AND SHELL QUOTING section below." + }; + + // Prologues/epilogues. + // + NarrowStrings --hxx-prologue + { + "", + "Insert at the beginning of the header file." + }; + + NarrowStrings --ixx-prologue + { + "", + "Insert at the beginning of the inline file." + }; + + NarrowStrings --cxx-prologue + { + "", + "Insert at the beginning of the source file." + }; + + NarrowStrings --fwd-prologue + { + "", + "Insert at the beginning of the forward declaration file." + }; + + NarrowStrings --prologue + { + "", + "Insert at the beginning of each generated file for which + there is no file-specific prologue." + }; + + NarrowStrings --hxx-epilogue + { + "", + "Insert at the end of the header file." + }; + + NarrowStrings --ixx-epilogue + { + "", + "Insert at the end of the inline file." + }; + + NarrowStrings --cxx-epilogue + { + "", + "Insert at the end of the source file." + }; + + NarrowStrings --fwd-epilogue + { + "", + "Insert at the end of the forward declaration file." + }; + + NarrowStrings --epilogue + { + "", + "Insert at the end of each generated file for which there + is no file-specific epilogue." + }; + + NarrowString --hxx-prologue-file + { + "", + "Insert the content of the at the beginning of the header file." + }; + + NarrowString --ixx-prologue-file + { + "", + "Insert the content of the at the beginning of the inline file." + }; + + NarrowString --cxx-prologue-file + { + "", + "Insert the content of the at the beginning of the source file." + }; + + NarrowString --fwd-prologue-file + { + "", + "Insert the content of the at the beginning of the forward + declaration file." + }; + + NarrowString --prologue-file + { + "", + "Insert the content of the at the beginning of each generated + file for which there is no file-specific prologue file." + }; + + NarrowString --hxx-epilogue-file + { + "", + "Insert the content of the at the end of the header file." + }; + + NarrowString --ixx-epilogue-file + { + "", + "Insert the content of the at the end of the inline file." + }; + + NarrowString --cxx-epilogue-file + { + "", + "Insert the content of the at the end of the source file." + }; + + NarrowString --fwd-epilogue-file + { + "", + "Insert the content of the at the end of the forward declaration + file." + }; + + NarrowString --epilogue-file + { + "", + "Insert the content of the at the end of each generated file + for which there is no file-specific epilogue file." + }; + + // Export options. + // + NarrowString --export-symbol + { + "", + "Insert in places where DLL export/import control statements + (\cb{__declspec(dllexport/dllimport)}) are necessary." + }; + + bool --export-xml-schema + { + "Export/import types in the XML Schema namespace using the export + symbol provided with the \cb{--export-symbol} option. The + \cb{XSD_NO_EXPORT} macro can be used to omit this code during C++ + compilation, which may be useful if you would like to use the same + generated code across multiple platforms." + }; + + bool --export-maps + { + "Export polymorphism support maps from a Win32 DLL into which this + generated code is placed. This is necessary when your type hierarchy + is split across several DLLs since otherwise each DLL will have its + own set of maps. In this situation the generated code for the DLL + which contains base types and/or substitution group heads should be + compiled with this option and the generated code for all other DLLs + should be compiled with \cb{--import-maps}. This option is only valid + together with \cb{--generate-polymorphic}. The \cb{XSD_NO_EXPORT} + macro can be used to omit this code during C++ compilation, which may + be useful if you would like to use the same generated code across + multiple platforms." + }; + + bool --import-maps + { + "Import polymorphism support maps to a Win32 DLL or executable into + which this generated code is linked. See the \cb{--export-maps} + option documentation for details. This options is only valid together + with \cb{--generate-polymorphic}. The \cb{XSD_NO_EXPORT} macro can be + used to omit this code during C++ compilation, which may be useful if + you would like to use the same generated code across multiple + platforms." + }; + + // Make dependency generation. + // + bool --generate-dep + { + "Generate \cb{make} dependency information. This option triggers the + creation of the \cb{.d} file containing the dependencies of the + generated files on the main schema file as well as all the schema + files that it includes/imports, transitively. This dependency file + is then normally included into the main \cb{makefile} to implement + automatic dependency tracking. + + Note also that automatic dependency generation is not supported in + the file-per-type mode (\cb{--file-per-type}). In this case, all + the generated files are produced with a single compiler invocation + and depend on all the schemas. As a result, it is easier to establish + such a dependency manually, perhaps with the help of the + \cb{--file-list*} options." + }; + + bool --generate-dep-only + { + "Generate \cb{make} dependency information only." + }; + + bool --dep-phony + { + "Generate phony targets for included/imported schema files, causing + each to depend on nothing. Such dummy rules work around \cb{make} + errors caused by the removal of schema files without also updating + the dependency file to match." + }; + + NarrowStrings --dep-target + { + "", + "Change the target of the dependency rule. By default it contains + all the generated C++ files as well as the dependency file itself, + without any directory prefixes. If you require multiple targets, + then you can specify them as a single, space-separated argument or + you can repeat this option multiple times." + }; + + NarrowString --dep-suffix = ".d" + { + "", + "Use the provided instead of the default \cb{.d} to + construct the name of the dependency file." + }; + + NarrowString --dep-regex + { + "", + "Use the provided expression to construct the name of the dependency + file. is a Perl-like regular expression in the form + \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. See also the REGEX + AND SHELL QUOTING section below." + }; + }; +} diff --git a/xsd/xsd/cxx/parser/attribute-validation-source.cxx b/xsd/xsd/cxx/parser/attribute-validation-source.cxx new file mode 100644 index 0000000..1c873fd --- /dev/null +++ b/xsd/xsd/cxx/parser/attribute-validation-source.cxx @@ -0,0 +1,412 @@ +// file : xsd/cxx/parser/attribute-validation-source.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include +#include + +namespace CXX +{ + namespace Parser + { + namespace + { + struct Test: Traversal::Attribute, + Traversal::AnyAttribute, + Context + { + Test (Context& c) + : Context (c) + { + } + + virtual void + traverse (SemanticGraph::Attribute& a) + { + String const& name (a.name ()); + + if (a.qualified_p () && a.namespace_ ().name ()) + { + String const& ns (a.namespace_ ().name ()); + + os << "n == " << strlit (name) << " &&" << endl + << "ns == " << strlit (ns); + } + else + os << "n == " << strlit (name) << " && ns.empty ()"; + } + + virtual void + traverse (SemanticGraph::AnyAttribute& a) + { + String const& ns (a.definition_namespace ().name ()); + + for (SemanticGraph::AnyAttribute::NamespaceIterator + i (a.namespace_begin ()), e (a.namespace_end ()); i != e;) + { + if (*i == L"##any") + { + os << "!n.empty ()"; + } + else if (*i == L"##other") + { + if (ns) + { + // Note that here I assume that ##other does not include + // unqualified names in a schema with target namespace. + // This is not what the spec says but that seems to be + // the consensus. + // + os << "(!ns.empty () && ns != " << strlit (ns) << ")"; + } + else + os << "!ns.empty ()"; + } + else if (*i == L"##local") + { + os << "(ns.empty () && !n.empty ())"; + } + else if (*i == L"##targetNamespace") + { + os << "ns == " << strlit (ns); + } + else + { + os << "ns == " << strlit (*i); + } + + if (++i != e) + os << " ||" << endl; + } + } + }; + + // + // + struct PhaseOne: Traversal::Attribute, Context + { + PhaseOne (Context& c) + : Context (c), test_ (c) + { + } + + virtual void + traverse (Type& a) + { + String const& name (ename (a)); + String const& inst (emember (a)); + + SemanticGraph::Type& type (a.type ()); + String const& post (post_name (type)); + String const& ret (ret_type (type)); + + os << "if ("; + + test_.traverse (a); + + os << ")" + << "{" + << "if (this->" << inst << ")" + << "{" + << "this->" << inst << "->pre ();" + << "this->" << inst << "->_pre_impl ();" + << "this->" << inst << "->_characters (s);" + << "this->" << inst << "->_post_impl ();"; + + if (ret == L"void") + os << "this->" << inst << "->" << post << " ();" + << "this->" << name << " ();"; + else + { + // Don't create an lvalue in C++11 (think std::unique_ptr). + // In C++98 we do it for compatibility with older/broken + // compilers (e.g., IBM xlC that needs an lvalue to pass + // std::auto_ptr). + // + if (std == cxx_version::cxx98) + os << arg_type (type) << " tmp (this->" << inst << "->" << + post << " ());" + << "this->" << name << " (tmp);"; + else + os << "this->" << name << " (this->" << inst << "->" << + post << " ());"; + } + + os << "}"; + + if (!a.optional_p ()) + os << "static_cast< v_state_attr_* > (" << + "this->v_state_attr_stack_.top ())->" << name << " = true;"; + + os << "return true;" + << "}"; + } + + private: + Test test_; + }; + + + // + // + struct PhaseTwo: Traversal::AnyAttribute, Context + { + PhaseTwo (Context& c) + : Context (c), test_ (c) + { + } + + virtual void + traverse (Type& a) + { + os << "if ("; + + test_.traverse (a); + + os << ")" << endl + << "{" + << "this->_any_attribute (ns, n, s);" + << "return true;" + << "}"; + } + + private: + Test test_; + }; + + + // + // + struct AttributeStateInit: Traversal::Attribute, Context + { + AttributeStateInit (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& a) + { + if (!a.optional_p ()) + os << "as." << ename (a) << " = false;"; + } + }; + + + // + // + struct AttributeStateCheck: Traversal::Attribute, Context + { + AttributeStateCheck (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& a) + { + if (!a.optional_p ()) + { + String ns (a.qualified_p () ? a.namespace_ ().name () : String ()); + + os << "if (!as." << ename (a) << ")" << endl + << "this->_expected_attribute (" << endl + << strlit (ns) << ", " << strlit (a.name ()) << ");"; + } + } + }; + + // + // + struct Complex: Traversal::Complex, Context + { + Complex (Context& c) + : Context (c), + phase_one_ (c), + phase_two_ (c), + attribute_state_init_ (c), + attribute_state_check_ (c) + { + names_phase_one_ >> phase_one_; + names_phase_two_ >> phase_two_; + + names_attribute_state_init_ >> attribute_state_init_; + names_attribute_state_check_ >> attribute_state_check_; + } + + virtual void + traverse (Type& c) + { + bool has_att (has (c)); + bool has_any (has (c)); + + if (!has_att && !has_any) + return; + + bool has_req_att (false); + if (has_att) + { + RequiredAttributeTest test (has_req_att); + Traversal::Names names_test (test); + names (c, names_test); + } + + String const& name (ename (c)); + + os <<"// Attribute validation and dispatch functions for " << + name << "." << endl + <<"//" << endl; + + if (has_att) + { + // _attribute_impl_phase_one + // + os << "bool " << name << "::" << endl + << "_attribute_impl_phase_one (const " << string_type << + "& ns," << endl + << "const " << string_type << "& n," << endl + << "const " << string_type << "& s)" << endl + << "{"; + + names (c, names_phase_one_); + + // Nothing matched - call our base (extension) or return false + // if there is no base (or restriction (even from anyType)). + // + os << "return "; + + if (c.inherits_p () && + !c.inherits ().is_a ()) + { + os << "this->" << fq_name (c.inherits ().base ()) << + "::_attribute_impl_phase_one (ns, n, s);"; + } + else + os << "false;"; + + os << "}"; + } + + + if (has_any) + { + // _attribute_impl_phase_two + // + os << "bool " << name << "::" << endl + << "_attribute_impl_phase_two (const " << string_type << + "& ns," << endl + << "const " << string_type << "& n," << endl + << "const " << string_type << "& s)" + << "{"; + + names (c, names_phase_two_); + + // Nothing matched - call our base (extension) or return false + // if there is no base (or restriction (even from anyType)). + // + os << "return "; + + if (c.inherits_p () && + !c.inherits ().is_a ()) + { + os << "this->" << fq_name (c.inherits ().base ()) << + "::_attribute_impl_phase_two (ns, n, s);"; + } + else + os << "false;"; + + os << "}"; + } + + if (has_req_att) + { + // _pre_a_validate + // + os << "void " << name << "::" << endl + << "_pre_a_validate ()" + << "{" + << "this->v_state_attr_stack_.push ();" + << "v_state_attr_& as = *static_cast< v_state_attr_* > (" << + "this->v_state_attr_stack_.top ());" + << endl; + + names (c, names_attribute_state_init_); + + // Call our base (extension) last. + // + if (c.inherits_p () && + !c.inherits ().is_a ()) + { + os << "this->" << fq_name (c.inherits ().base ()) << + "::_pre_a_validate ();"; + } + + os << "}"; + + + // _post_a_validate + // + os << "void " << name << "::" << endl + << "_post_a_validate ()" + << "{"; + + // Call our base (extension) first. + // + if (c.inherits_p () && + !c.inherits ().is_a ()) + { + os << "this->" << fq_name (c.inherits ().base ()) << + "::_post_a_validate ();" + << endl; + } + + os << "v_state_attr_& as = *static_cast< v_state_attr_* > (" << + "this->v_state_attr_stack_.top ());" + << endl; + + names (c, names_attribute_state_check_); + + os << endl + << "this->v_state_attr_stack_.pop ();" + << "}"; + } + } + + private: + PhaseOne phase_one_; + Traversal::Names names_phase_one_; + + PhaseTwo phase_two_; + Traversal::Names names_phase_two_; + + AttributeStateInit attribute_state_init_; + Traversal::Names names_attribute_state_init_; + + AttributeStateCheck attribute_state_check_; + Traversal::Names names_attribute_state_check_; + }; + } + + void + generate_attribute_validation_source (Context& ctx) + { + Traversal::Schema schema; + + Sources sources; + Traversal::Names schema_names; + + Namespace ns (ctx); + Traversal::Names names; + + schema >> sources >> schema; + schema >> schema_names >> ns >> names; + + Complex complex (ctx); + + names >> complex; + + schema.dispatch (ctx.schema_root); + } + } +} diff --git a/xsd/xsd/cxx/parser/attribute-validation-source.hxx b/xsd/xsd/cxx/parser/attribute-validation-source.hxx new file mode 100644 index 0000000..1f19bed --- /dev/null +++ b/xsd/xsd/cxx/parser/attribute-validation-source.hxx @@ -0,0 +1,18 @@ +// file : xsd/cxx/parser/attribute-validation-source.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_PARSER_ATTRIBUTE_VALIDATION_SOURCE_HXX +#define XSD_CXX_PARSER_ATTRIBUTE_VALIDATION_SOURCE_HXX + +#include + +namespace CXX +{ + namespace Parser + { + void + generate_attribute_validation_source (Context&); + } +} + +#endif // XSD_CXX_PARSER_ATTRIBUTE_VALIDATION_SOURCE_HXX diff --git a/xsd/xsd/cxx/parser/characters-validation-source.cxx b/xsd/xsd/cxx/parser/characters-validation-source.cxx new file mode 100644 index 0000000..749a4cc --- /dev/null +++ b/xsd/xsd/cxx/parser/characters-validation-source.cxx @@ -0,0 +1,73 @@ +// file : xsd/cxx/parser/characters-validation-source.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include +#include + +namespace CXX +{ + namespace Parser + { + namespace + { + // + // + struct Complex: Traversal::Complex, Context + { + Complex (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& c) + { + if (!c.mixed_p ()) + return; + + String const& name (ename (c)); + + os <<"// Character validation functions for " << name << "." << endl + <<"//" << endl; + + // _characters_impl + // + os << "bool " << name << "::" << endl + << "_characters_impl (const " << string_type << "& s)" + << "{" + << "this->_any_characters (s);" + << "return true;" + << "}"; + } + }; + } + + void + generate_characters_validation_source (Context& ctx) + { + //@@ Most of the time there is no mixed content type so + // we generate an empty namespace which looks ugly. Will + // need to implement smart namespace to handle this at + // some point. + // + Traversal::Schema schema; + + Sources sources; + Traversal::Names schema_names; + + Namespace ns (ctx); + Traversal::Names names; + + schema >> sources >> schema; + schema >> schema_names >> ns >> names; + + Complex complex (ctx); + + names >> complex; + + schema.dispatch (ctx.schema_root); + } + } +} diff --git a/xsd/xsd/cxx/parser/characters-validation-source.hxx b/xsd/xsd/cxx/parser/characters-validation-source.hxx new file mode 100644 index 0000000..909901b --- /dev/null +++ b/xsd/xsd/cxx/parser/characters-validation-source.hxx @@ -0,0 +1,18 @@ +// file : xsd/cxx/parser/characters-validation-source.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_PARSER_CHARACTERS_VALIDATION_SOURCE_HXX +#define XSD_CXX_PARSER_CHARACTERS_VALIDATION_SOURCE_HXX + +#include + +namespace CXX +{ + namespace Parser + { + void + generate_characters_validation_source (Context&); + } +} + +#endif // XSD_CXX_PARSER_CHARACTERS_VALIDATION_SOURCE_HXX diff --git a/xsd/xsd/cxx/parser/driver-source.cxx b/xsd/xsd/cxx/parser/driver-source.cxx new file mode 100644 index 0000000..d1e6b7f --- /dev/null +++ b/xsd/xsd/cxx/parser/driver-source.cxx @@ -0,0 +1,775 @@ +// file : xsd/cxx/parser/driver-source.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include +#include + +#include +#include + +#include +#include + +using namespace std; + +namespace CXX +{ + namespace Parser + { + namespace + { + typedef map TypeInstanceMap; + typedef set InstanceSet; + + // For base types we only want member's types, but not the + // base itself. + // + struct BaseType: Traversal::Complex, + Traversal::List, + Context + { + BaseType (Context& c, Traversal::NodeBase& def) + : Context (c), def_ (def) + { + } + + virtual void + traverse (SemanticGraph::Complex& c) + { + inherits (c); + + if (!restriction_p (c)) + names (c); + } + + virtual void + traverse (SemanticGraph::List& l) + { + def_.dispatch (l.argumented ().type ()); + } + + private: + Traversal::NodeBase& def_; + }; + + struct ParserDef: Traversal::Type, + Traversal::List, + Traversal::Complex, + + Traversal::AnyType, + Traversal::AnySimpleType, + + Traversal::Fundamental::Byte, + Traversal::Fundamental::UnsignedByte, + Traversal::Fundamental::Short, + Traversal::Fundamental::UnsignedShort, + Traversal::Fundamental::Int, + Traversal::Fundamental::UnsignedInt, + Traversal::Fundamental::Long, + Traversal::Fundamental::UnsignedLong, + Traversal::Fundamental::Integer, + Traversal::Fundamental::NonPositiveInteger, + Traversal::Fundamental::NonNegativeInteger, + Traversal::Fundamental::PositiveInteger, + Traversal::Fundamental::NegativeInteger, + + Traversal::Fundamental::Boolean, + + Traversal::Fundamental::Float, + Traversal::Fundamental::Double, + Traversal::Fundamental::Decimal, + + Traversal::Fundamental::String, + Traversal::Fundamental::NormalizedString, + Traversal::Fundamental::Token, + Traversal::Fundamental::Name, + Traversal::Fundamental::NameToken, + Traversal::Fundamental::NameTokens, + Traversal::Fundamental::NCName, + Traversal::Fundamental::Language, + + Traversal::Fundamental::QName, + + Traversal::Fundamental::Id, + Traversal::Fundamental::IdRef, + Traversal::Fundamental::IdRefs, + + Traversal::Fundamental::AnyURI, + + Traversal::Fundamental::Base64Binary, + Traversal::Fundamental::HexBinary, + + Traversal::Fundamental::Date, + Traversal::Fundamental::DateTime, + Traversal::Fundamental::Duration, + Traversal::Fundamental::Day, + Traversal::Fundamental::Month, + Traversal::Fundamental::MonthDay, + Traversal::Fundamental::Year, + Traversal::Fundamental::YearMonth, + Traversal::Fundamental::Time, + + Traversal::Fundamental::Entity, + Traversal::Fundamental::Entities, + + Context + { + ParserDef (Context& c, TypeInstanceMap& map, InstanceSet& set) + : Context (c), map_ (map), set_ (set), base_ (c, *this) + { + *this >> inherits_ >> base_ >> inherits_; + + *this >> names_; + base_ >> names_; + + names_ >> member_ >> belongs_ >> *this; + } + + virtual void + traverse (SemanticGraph::Type& t) + { + if (map_.find (&t) == map_.end ()) + { + String inst (find_instance_name (t)); + map_[&t] = inst; + + os << fq_name (t, "impl") << " " << inst << ";"; + } + } + + virtual void + traverse (SemanticGraph::List& l) + { + if (map_.find (&l) == map_.end ()) + { + String inst (find_instance_name (l)); + map_[&l] = inst; + + os << fq_name (l, "impl") << " " << inst << ";"; + + dispatch (l.argumented ().type ()); + } + } + + virtual void + traverse (SemanticGraph::Complex& c) + { + if (map_.find (&c) == map_.end ()) + { + String inst (find_instance_name (c)); + map_[&c] = inst; + + os << fq_name (c, "impl") << " " << inst << ";"; + + inherits (c); + + if (!restriction_p (c)) + names (c); + } + } + + // anyType & anySimpleType. + // + virtual void + traverse (SemanticGraph::AnyType& t) + { + fund_type (t, "any_type"); + } + + virtual void + traverse (SemanticGraph::AnySimpleType& t) + { + fund_type (t, "any_simple_type"); + } + + // Boolean. + // + virtual void + traverse (SemanticGraph::Fundamental::Boolean& t) + { + fund_type (t, "boolean"); + } + + // Integral types. + // + virtual void + traverse (SemanticGraph::Fundamental::Byte& t) + { + fund_type (t, "byte"); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedByte& t) + { + fund_type (t, "unsigned_byte"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Short& t) + { + fund_type (t, "short"); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedShort& t) + { + fund_type (t, "unsigned_short"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Int& t) + { + fund_type (t, "int"); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedInt& t) + { + fund_type (t, "unsigned_int"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Long& t) + { + fund_type (t, "long"); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedLong& t) + { + fund_type (t, "unsigned_long"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Integer& t) + { + fund_type (t, "integer"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) + { + fund_type (t, "non_positive_integer"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) + { + fund_type (t, "non_negative_integer"); + } + + virtual void + traverse (SemanticGraph::Fundamental::PositiveInteger& t) + { + fund_type (t, "positive_integer"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NegativeInteger& t) + { + fund_type (t, "negative_integer"); + } + + // Floats. + // + virtual void + traverse (SemanticGraph::Fundamental::Float& t) + { + fund_type (t, "float"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Double& t) + { + fund_type (t, "double"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Decimal& t) + { + fund_type (t, "decimal"); + } + + // Strings. + // + virtual void + traverse (SemanticGraph::Fundamental::String& t) + { + fund_type (t, "string"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NormalizedString& t) + { + fund_type (t, "normalized_string"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Token& t) + { + fund_type (t, "token"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NameToken& t) + { + fund_type (t, "nmtoken"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NameTokens& t) + { + fund_type (t, "nmtokens"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Name& t) + { + fund_type (t, "name"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NCName& t) + { + fund_type (t, "ncname"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Language& t) + { + fund_type (t, "language"); + } + + + // Qualified name. + // + virtual void + traverse (SemanticGraph::Fundamental::QName& t) + { + fund_type (t, "qname"); + } + + + // ID/IDREF. + // + virtual void + traverse (SemanticGraph::Fundamental::Id& t) + { + fund_type (t, "id"); + } + + virtual void + traverse (SemanticGraph::Fundamental::IdRef& t) + { + fund_type (t, "idref"); + } + + virtual void + traverse (SemanticGraph::Fundamental::IdRefs& t) + { + fund_type (t, "idrefs"); + } + + // URI. + // + virtual void + traverse (SemanticGraph::Fundamental::AnyURI& t) + { + fund_type (t, "uri"); + } + + // Binary. + // + virtual void + traverse (SemanticGraph::Fundamental::Base64Binary& t) + { + fund_type (t, "base64_binary"); + } + + virtual void + traverse (SemanticGraph::Fundamental::HexBinary& t) + { + fund_type (t, "hex_binary"); + } + + + // Date/time. + // + virtual void + traverse (SemanticGraph::Fundamental::Date& t) + { + fund_type (t, "date"); + } + + virtual void + traverse (SemanticGraph::Fundamental::DateTime& t) + { + fund_type (t, "date_time"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Duration& t) + { + fund_type (t, "duration"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Day& t) + { + fund_type (t, "day"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Month& t) + { + fund_type (t, "month"); + } + + virtual void + traverse (SemanticGraph::Fundamental::MonthDay& t) + { + fund_type (t, "month_day"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Year& t) + { + fund_type (t, "year"); + } + + virtual void + traverse (SemanticGraph::Fundamental::YearMonth& t) + { + fund_type (t, "year_month"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Time& t) + { + fund_type (t, "time"); + } + + // Entity. + // + virtual void + traverse (SemanticGraph::Fundamental::Entity& t) + { + fund_type (t, "entity"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Entities& t) + { + fund_type (t, "entities"); + } + + private: + virtual void + fund_type (SemanticGraph::Type& t, String const& name) + { + if (map_.find (&t) == map_.end ()) + { + String inst (find_instance_name (name)); + map_[&t] = inst; + + os << fq_name (t, "impl") << " " << inst << ";"; + } + } + + String + find_instance_name (String const& raw_name) + { + String base_name (escape (raw_name + L"_p")); + String name (base_name); + + for (size_t i (1); set_.find (name) != set_.end (); ++i) + { + std::wostringstream os; + os << i; + name = base_name + os.str (); + } + + set_.insert (name); + return name; + } + + String + find_instance_name (SemanticGraph::Type& t) + { + return find_instance_name (t.name ()); + } + + TypeInstanceMap& map_; + InstanceSet& set_; + + BaseType base_; + Traversal::Inherits inherits_; + + Traversal::Names names_; + Traversal::Member member_; + Traversal::Belongs belongs_; + }; + + struct ArgList: Traversal::Complex, + Traversal::List, + Traversal::Member, + Context + { + ArgList (Context& c, TypeInstanceMap& map) + : Context (c), map_ (map), first_ (true) + { + inherits_ >> *this; + names_ >> *this; + } + + virtual void + traverse (SemanticGraph::Complex& c) + { + inherits (c, inherits_); + + if (!restriction_p (c)) + names (c, names_); + } + + virtual void + traverse (SemanticGraph::List& l) + { + if (!first_) + os << "," << endl; + else + first_ = false; + + os << map_[&l.argumented ().type ()]; + } + + virtual void + traverse (SemanticGraph::Member& m) + { + if (skip (m)) + return; + + if (!first_) + os << "," << endl; + else + first_ = false; + + os << map_[&m.type ()]; + } + + private: + TypeInstanceMap& map_; + + Traversal::Inherits inherits_; + Traversal::Names names_; + + bool first_; + }; + + struct ParserConnect: Traversal::List, + Traversal::Complex, + Context + { + ParserConnect (Context& c, TypeInstanceMap& map) + : Context (c), map_ (map), base_ (c, *this) + { + *this >> inherits_ >> base_ >> inherits_; + + *this >> names_; + base_ >> names_; + + names_ >> member_ >> belongs_ >> *this; + } + + virtual void + traverse (SemanticGraph::List& l) + { + if (type_set_.find (&l) == type_set_.end ()) + { + os << map_[&l] << ".parsers (" << + map_[&l.argumented ().type ()] << ");" + << endl; + + type_set_.insert (&l); + } + } + + virtual void + traverse (SemanticGraph::Complex& c) + { + if (type_set_.find (&c) == type_set_.end ()) + { + if (has_members (c)) + { + os << map_[&c] << ".parsers ("; + + ArgList args (*this, map_); + args.dispatch (c); + + os << ");" + << endl; + } + + type_set_.insert (&c); + + inherits (c); + + if (!restriction_p (c)) + names (c); + } + } + + private: + bool + has_members (SemanticGraph::Complex& c) + { + using SemanticGraph::Complex; + + if (has (c)) + return true; + + if (c.inherits_p ()) + { + SemanticGraph::Type& b (c.inherits ().base ()); + + if (Complex* cb = dynamic_cast (&b)) + return has_members (*cb); + + return b.is_a (); + } + + return false; + } + + private: + TypeInstanceMap& map_; + set type_set_; + + BaseType base_; + Traversal::Inherits inherits_; + + Traversal::Names names_; + Traversal::Member member_; + Traversal::Belongs belongs_; + }; + } + + void + generate_driver_source (Context& ctx) + { + // Figure out the root element. Validator should have made sure + // it is unique. + // + SemanticGraph::Element* root (0); + { + Traversal::Schema schema; + Sources sources; + + schema >> sources >> schema; + + Traversal::Names schema_names; + Traversal::Namespace ns; + Traversal::Names ns_names; + RootElement root_element (ctx.options, root); + + schema >> schema_names >> ns >> ns_names >> root_element; + + schema.dispatch (ctx.schema_root); + } + + std::wostream& os (ctx.os); + String const& L (ctx.L); + String const& cerr (ctx.cerr_inst); + + InstanceSet set; + TypeInstanceMap map; + SemanticGraph::Type& root_type (root->type ()); + + set.insert ("doc_p"); + + os << "#include " << endl + << endl + << "int" << endl + << "main (int argc, char* argv[])" + << "{" + << "if (argc != 2)" + << "{" + << cerr << " << " << L << "\"usage: \" << argv[0] << " << + L << "\" file.xml\" << std::endl;" + << "return 1;" + << "}" + << "try" + << "{" + << "// Instantiate individual parsers." << endl + << "//" << endl; + + { + ParserDef def (ctx, map, set); + def.dispatch (root_type); + } + + os << endl + << "// Connect the parsers together." << endl + << "//" << endl; + + { + ParserConnect connect (ctx, map); + connect.dispatch (root_type); + } + + String const& root_p (map[&root_type]); + + os << "// Parse the XML document." << endl + << "//" << endl; + + if (root->namespace_().name ()) + os << ctx.xs_ns_name () << "::document doc_p (" << endl + << root_p << "," << endl + << ctx.strlit (root->namespace_().name ()) << "," << endl + << ctx.strlit (root->name ()) << ");" + << endl; + else + os << ctx.xs_ns_name () << "::document doc_p (" << root_p << ", " << + ctx.strlit (root->name ()) << ");" + << endl; + + os << root_p << ".pre ();" + << "doc_p.parse (argv[1]);"; + + String const& ret (Context::ret_type (root_type)); + String const& post (Context::post_name (root_type)); + + if (ret == L"void") + os << root_p << "." << post << " ();"; + else + { + os << Context::arg_type (root_type) << " v (" << + root_p << "." << post << " ());" + << endl; + + if (ctx.options.generate_print_impl ()) + { + PrintCall t (ctx, root->name (), "v"); + t.dispatch (root_type); + } + else + os << "// TODO" << endl + << "//" << endl; + } + + os << "}" // try + << "catch (const " << ctx.xs_ns_name () << "::exception& e)" + << "{" + << cerr << " << e << std::endl;" + << "return 1;" + << "}" + << "catch (const std::ios_base::failure&)" + << "{" + << cerr << " << argv[1] << " << + L << "\": error: io failure\" << std::endl;" + << "return 1;" + << "}" + << "}"; + } + } +} diff --git a/xsd/xsd/cxx/parser/driver-source.hxx b/xsd/xsd/cxx/parser/driver-source.hxx new file mode 100644 index 0000000..154091f --- /dev/null +++ b/xsd/xsd/cxx/parser/driver-source.hxx @@ -0,0 +1,18 @@ +// file : xsd/cxx/parser/driver-source.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_PARSER_DRIVER_SOURCE_HXX +#define XSD_CXX_PARSER_DRIVER_SOURCE_HXX + +#include + +namespace CXX +{ + namespace Parser + { + void + generate_driver_source (Context&); + } +} + +#endif // XSD_CXX_PARSER_DRIVER_SOURCE_HXX diff --git a/xsd/xsd/cxx/parser/element-validation-source.cxx b/xsd/xsd/cxx/parser/element-validation-source.cxx new file mode 100644 index 0000000..a5379c2 --- /dev/null +++ b/xsd/xsd/cxx/parser/element-validation-source.cxx @@ -0,0 +1,1600 @@ +// file : xsd/cxx/parser/element-validation-source.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include + +#include +#include + +using namespace std; + +namespace CXX +{ + namespace Parser + { + namespace + { + typedef vector Particles; + + // + // + struct ParticleTest: Traversal::Compositor, + Traversal::Element, + Traversal::Any, + Context + { + ParticleTest (Context& c) + : Context (c) + { + } + + virtual void + traverse (SemanticGraph::Element& e) + { + String const& name (e.name ()); + + if (polymorphic && e.global_p ()) + os << "("; + + if (e.qualified_p () && e.namespace_ ().name ()) + { + String const& ns (e.namespace_ ().name ()); + + os << "n == " << strlit (name) << " &&" << endl + << "ns == " << strlit (ns); + } + else + os << "n == " << strlit (name) << " && ns.empty ()"; + + + // Only a globally-defined element can be a subst-group root. + // + if (polymorphic && e.global_p ()) + { + os << ") ||" << endl + << "::xsd::cxx::parser::substitution_map_instance< " << + char_type << " > ().check (" << endl + << "ns, n, " << strlit (e.namespace_ ().name ()) << + ", " << strlit (name) << ", t)"; + } + } + + virtual void + traverse (SemanticGraph::Any& a) + { + String const& ns (a.definition_namespace ().name ()); + + // Note that we need to make sure the "flush" element (both name + // and namespace are empty) does not match any compositor. + // + for (SemanticGraph::Any::NamespaceIterator i (a.namespace_begin ()), + e (a.namespace_end ()); i != e;) + { + if (*i == L"##any") + { + os << "!n.empty ()"; + } + else if (*i == L"##other") + { + if (ns) + { + // Note that here I assume that ##other does not include + // unqualified names in a schema with target namespace. + // This is not what the spec says but that seems to be + // the consensus. + // + os << "(!ns.empty () && ns != " << strlit (ns) << ")"; + } + else + os << "!ns.empty ()"; + } + else if (*i == L"##local") + { + os << "(ns.empty () && !n.empty ())"; + } + else if (*i == L"##targetNamespace") + { + os << "ns == " << strlit (ns); + } + else + { + os << "ns == " << strlit (*i); + } + + if (++i != e) + os << " ||" << endl; + } + } + + virtual void + traverse (SemanticGraph::Compositor& c) + { + // This compositor should already have been tested for + // triviality (empty). + // + Particles const& p (c.context ().get ("prefixes")); + + bool paren (p.size () != 1); + + for (Particles::const_iterator i (p.begin ()), e (p.end ()); + i != e;) + { + if (paren) + os << "("; + + dispatch (**i); + + if (paren) + os << ")"; + + if (++i != e) + os << " ||" << endl; + } + } + }; + + + // Generates particle namespace-name pair. Used to generate + // the _expected_element call. + // + struct ParticleName: Traversal::Compositor, + Traversal::Element, + Traversal::Any, + Context + { + ParticleName (Context& c) + : Context (c) + { + } + + virtual void + traverse (SemanticGraph::Element& e) + { + String ns (e.qualified_p () ? e.namespace_ ().name () : String ()); + os << strlit (ns) << ", " << strlit (e.name ()); + } + + virtual void + traverse (SemanticGraph::Any& a) + { + String const& ns (*a.namespace_begin ()); + os << strlit (ns) << ", " << L << "\"*\""; + } + + virtual void + traverse (SemanticGraph::Compositor& c) + { + Particles const& p (c.context ().get ("prefixes")); + + dispatch (**p.begin ()); + } + }; + + + // Common base for the ParticleIn{All, Choice, Sequence} treversers. + // + struct ParticleInCompositor: Context + { + protected: + ParticleInCompositor (Context& c, SemanticGraph::Complex& type) + : Context (c), type_ (type), particle_test_ (c) + { + } + + + // Generate sub-parser setup code as well as the pre/post calls. + // + void + pre_post_calls (SemanticGraph::Particle& p) + { + using SemanticGraph::Element; + using SemanticGraph::Complex; + + if (Element* e = dynamic_cast (&p)) + { + SemanticGraph::Type& type (e->type ()); + String const& fq_type (fq_name (type)); + bool poly (polymorphic && !anonymous (type)); + + String name, inst, def_parser, map; + + if (e->context ().count("name")) + { + name = ename (*e); + + if (poly) + { + def_parser = emember (*e); + map = emember_map (*e); + inst = "p"; + } + else + inst = L"this->" + emember (*e); + } + else + { + // This is the subsequent mentioning of this element in the + // content. We need to find the first one in order to get + // to the escaped names. + // + Complex::NamesIteratorPair ip (type_.find (e->name ())); + assert (ip.first != ip.second); + Element& fe (dynamic_cast(ip.first->named ())); + + name = ename (fe); + + if (poly) + { + def_parser = emember (fe); + map = emember_map (fe); + inst = "p"; + } + else + inst = L"this->" + emember (fe); + } + + if (poly) + { + // For pre-computing length. + // + String type_id (type.name ()); + + if (String type_ns = xml_ns_name (type)) + { + type_id += L' '; + type_id += type_ns; + } + + os << fq_type << "* p = 0;" + << endl + << "if (t == 0 && this->" << def_parser << " != 0)" << endl + << inst << " = this->" << def_parser << ";" + << "else" + << "{" + << string_type << " ts (" << fq_name (type) << + "::_static_type (), " << type_id.size () << "UL);" + << endl + << "if (t == 0)" << endl + << "t = &ts;" + << endl + << "if (this->" << def_parser << " != 0 && *t == ts)" << endl + << inst << " = this->" << def_parser << ";" + << "else" + << "{"; + + // Check that the types are related by inheritance. + // + os << "if (t != &ts &&" << endl + << "!::xsd::cxx::parser::validating::" << + "inheritance_map_instance< " << char_type << + " > ().check (" << endl + << "t->data (), ts))" << endl + << "throw ::xsd::cxx::parser::dynamic_type< " << char_type << + " > (*t);" + << endl + << "if (this->" << map << " != 0)" << endl + << inst << " = dynamic_cast< " << fq_type << "* > (" << endl + << "this->" << map << "->find (*t));" + << "}" + << "}"; + } + + os << "this->" << complex_base << "::context_.top ()." << + "parser_ = " << inst << ";" + << endl + << "if (" << inst << ")" << endl + << inst << "->pre ();" + << "}" + << "else" // start + << "{"; + + if (poly) + os << fq_type << "* p =" << endl + << "dynamic_cast< " << fq_type << "* > (" << endl + << "this->" << complex_base << "::context_.top ().parser_);" + << endl; + + os << "if (" << inst << ")" + << "{"; + + String const& ret (ret_type (type)); + String const& post (post_name (type)); + + if (ret == L"void") + os << inst << "->" << post << " ();" + << "this->" << name << " ();"; + else + { + // Don't create an lvalue in C++11 (think std::unique_ptr). + // In C++98 we do it for compatibility with older/broken + // compilers (e.g., IBM xlC that needs an lvalue to pass + // std::auto_ptr). + // + if (std == cxx_version::cxx98) + os << arg_type (type) << " tmp (" << inst << "->" << + post << " ());" + << "this->" << name << " (tmp);"; + else + os << "this->" << name << " (" << inst << "->" << + post << " ());"; + } + + os << "}"; + } + else + { + os << "this->_start_any_element (ns, n, t);" + << "this->" << complex_base << "::context_.top ().any_ = true;" + << "}" + << "else" // start + << "{" + << "this->" << complex_base << "::context_.top ().any_ = false;" + << "this->_end_any_element (ns, n);"; + } + } + + protected: + SemanticGraph::Complex& type_; + ParticleTest particle_test_; + }; + + + + // The 'all' compositor can only contain elements with min={0,1}, max=1. + // + struct ParticleInAll: Traversal::Element, + ParticleInCompositor + { + ParticleInAll (Context& c, SemanticGraph::Complex& type) + : ParticleInCompositor (c, type) + { + } + + virtual void + traverse (SemanticGraph::Element& e) + { + size_t state (e.context ().get ("state")); + + if (state != 0) + os << "else "; + + os << "if ("; + + particle_test_.traverse (e); + + os << ")" + << "{" + << "if (count[" << state << "UL] == 0)" + << "{" + << "if (start)" + << "{"; + + pre_post_calls (e); + + os << "count[" << state << "UL] = 1;" + << "}" + << "}" + << "else" // count != 0 + << "{" + << "assert (start);" // Assuming well-formed XML. + + // Since there is never more content after 'all', we could have + // as well thrown here. But instead we will let the code in + // start_element handle this along with other unexpected + // elements. + // + << "state = ~0UL;" + << "}" + << "}"; + } + }; + + + // + // + struct ParticleInChoice: Traversal::Particle, + Traversal::Compositor, + ParticleInCompositor + { + ParticleInChoice (Context& c, SemanticGraph::Complex& type) + : ParticleInCompositor (c, type), particle_name_ (c) + { + } + + virtual void + traverse (SemanticGraph::Particle& p) + { + using SemanticGraph::Element; + + size_t state (p.context ().get ("state")); + + size_t min (p.min ()), max (p.max ()); + + os << "case " << state << "UL:" << endl + << "{"; + + if (max != 1) // We don't need the test if max == 1. + { + os << "if ("; + + particle_test_.dispatch (p); + + os << ")" + << "{"; + } + + os << "if (start)" + << "{"; + + pre_post_calls (p); + + switch (max) + { + case 0: + { + os << "count++;"; + break; + } + case 1: + { + // We do not need to increment count because min <= max and + // we do not generate min check for min <= 1 (see below). + // + os << "state = ~0UL;"; + break; + } + default: + { + os << "if (++count == " << max << "UL)" << endl + << "state = ~0UL;"; + } + }; + + os << "}"; // start + + // We've already moved to the final state if max == 1. + // + if (max != 1) + { + os << "}" + << "else" + << "{" + << "assert (start);"; // Assuming well-formed XML + + // Check if min cardinality requirements have been met. Since + // count is always >= 1, don't generate dead code if min <= 1. + // + if (min > 1) + { + os << "if (count < " << min << "UL)" << endl + << "this->_expected_element (" << endl; + + particle_name_.dispatch (p); + + os << "," << endl + << "ns, n);"; + } + + + os << "state = ~0UL;" + << "}"; + } + + os << "break;" + << "}"; // case + } + + virtual void + traverse (SemanticGraph::Compositor& c) + { + using SemanticGraph::Compositor; + + size_t max (c.max ()); + size_t min (c.context ().get ("effective-min")); + size_t n (c.context ().get ("comp-number")); + size_t state (c.context ().get ("state")); + + String func (c.is_a () ? + "choice_" : "sequence_"); + + os << "case " << state << "UL:" << endl + << "{" + << "unsigned long s (~0UL);" + << endl; + + bool first (true); + + for (Compositor::ContainsIterator ci (c.contains_begin ()); + ci != c.contains_end (); ++ci) + { + SemanticGraph::Particle& p (ci->particle ()); + + if (p.is_a () && !c.context ().count ("comp-number")) + continue; // Empty compositor. + + if (!p.context ().count ("prefix")) + break; + + size_t state (p.context ().get ("state")); + + if (first) + first = false; + else + os << "else "; + + os << "if ("; + + particle_test_.dispatch (p); + + os << ")" << endl + << "s = " << state << "UL;"; + } + + // This compositor. + // + os << endl + << "if (s != ~0UL)" + << "{" + << "assert (start);"; // End is handled by the sub-machine. + + switch (max) + { + case 0: + { + os << "count++;"; + break; + } + case 1: + { + // We do not need to increment count because min <= max and + // we do not generate min check for min <= 1 (see below). + // + os << "state = ~0UL;"; + break; + } + default: + { + os << "if (++count == " << max << "UL)" << endl + << "state = ~0UL;"; + } + }; + + // Delegate to the sub-machine. + // + + os << endl + << "v_state_& vs = *static_cast< v_state_* > (" << + "this->v_state_stack_.top ());" + << "v_state_descr_& vd = vs.data[vs.size++];" // push + << endl + << "vd.func = &" << ename (type_) << "::" << func << n << ";" + << "vd.state = s;" + << "vd.count = 0;" + << endl + << "this->" << func << n << " (vd.state, vd.count, ns, n, t, true);" + << "}"; + + + // Not this compositor. We've elready moved to the final state + // if max == 1. + // + if (max != 1) + { + os << "else" + << "{" + << "assert (start);"; // Assuming well-formed XML + + // Check if min cardinality requirements have been met. Since + // count is always >= 1, don't generate dead code if min <= 1. + // + if (min > 1) + { + os << "if (count < " << min << "UL)" << endl + << "this->_expected_element (" << endl; + + particle_name_.dispatch (c); + + os << "," << endl + << "ns, n);"; + } + + os << "state = ~0UL;" + << "}"; + } + + os << "break;" + << "}"; // case + } + + private: + ParticleName particle_name_; + }; + + + // + // + struct ParticleInSequence: Traversal::Particle, + Traversal::Compositor, + ParticleInCompositor + { + ParticleInSequence (Context& c, + size_t state, + size_t next_state, + SemanticGraph::Complex& type) + : ParticleInCompositor (c, type), + state_ (state), particle_name_ (c) + { + // next_state == 0 indicates the terminal state (~0UL). + // + if (next_state != 0) + { + std::wostringstream ostr; + ostr << next_state; + next_state_ = ostr.str (); + } + else + next_state_ = L"~0"; + } + + virtual void + traverse (SemanticGraph::Particle& p) + { + size_t min (p.min ()), max (p.max ()); + + os << "case " << state_ << "UL:" << endl + << "{" + << "if ("; + + particle_test_.dispatch (p); + + os << ")" + << "{"; + + // This element. + // + + os << "if (start)" + << "{"; + + pre_post_calls (p); + + switch (max) + { + case 0: + { + os << "count++;"; + break; + } + case 1: + { + os << "count = 0;" + << "state = " << next_state_ << "UL;"; + break; + } + default: + { + os << "if (++count == " << max << "UL)" + << "{" + << "count = 0;" + << "state = " << next_state_ << "UL;" + << "}"; + } + }; + + os << "}" // start + << "break;" + << "}"; + + // Not this element. + // + + os << "else" + << "{" + << "assert (start);"; // Assuming well-formed XML. + + // Check if min cardinality requirements have been met. Since + // count is always >= 0, don't generate dead code if min == 0. + // + if (min != 0) + { + os << "if (count < " << min << "UL)" << endl + << "this->_expected_element (" << endl; + + particle_name_.dispatch (p); + + os << "," << endl + << "ns, n);"; + } + + os << "count = 0;" + << "state = " << next_state_ << "UL;" + << "// Fall through." << endl + << "}" // else + << "}"; // case + } + + virtual void + traverse (SemanticGraph::Compositor& c) + { + using SemanticGraph::Compositor; + + size_t max (c.max ()); + size_t min (c.context ().get ("effective-min")); + size_t n (c.context ().get ("comp-number")); + + String func (c.is_a () ? + "choice_" : "sequence_"); + + os << "case " << state_ << "UL:" << endl + << "{" + << "unsigned long s (~0UL);" + << endl; + + bool first (true); + + for (Compositor::ContainsIterator ci (c.contains_begin ()); + ci != c.contains_end (); ++ci) + { + SemanticGraph::Particle& p (ci->particle ()); + + if (p.is_a () && !c.context ().count ("comp-number")) + continue; // Empty compositor. + + if (!p.context ().count ("prefix")) + break; + + size_t state (p.context ().get ("state")); + + if (first) + first = false; + else + os << "else "; + + os << "if ("; + + particle_test_.dispatch (p); + + os << ")" << endl + << "s = " << state << "UL;"; + } + + // This element. + // + + os << endl + << "if (s != ~0UL)" + << "{" + << "assert (start);"; // End is handled by the sub-machine. + + switch (max) + { + case 0: + { + os << "count++;" + << endl; + break; + } + case 1: + { + os << "count = 0;" + << "state = " << next_state_ << "UL;" + << endl; + break; + } + default: + { + os << "if (++count == " << max << "UL)" + << "{" + << "count = 0;" + << "state = " << next_state_ << "UL;" + << "}"; + } + }; + + // Delegate to the sub-machine. + // + + os << "v_state_& vs = *static_cast< v_state_* > (" << + "this->v_state_stack_.top ());" + << "v_state_descr_& vd = vs.data[vs.size++];" // push + << endl + << "vd.func = &" << ename (type_) << "::" << func << n << ";" + << "vd.state = s;" + << "vd.count = 0;" + << endl + << "this->" << func << n << " (vd.state, vd.count, ns, n, t, true);" + << "break;" + << "}"; + + // Not this compositor. + // + + os << "else" + << "{" + << "assert (start);"; // Assuming well-formed XML + + // Check if min cardinality requirements have been met. Since + // count is always >= 0, don't generate dead code if min == 0. + // + if (min != 0) + { + os << "if (count < " << min << "UL)" << endl + << "this->_expected_element (" << endl; + + particle_name_.dispatch (c); + + os << "," << endl + << "ns, n);"; + } + + os << "count = 0;" + << "state = " << next_state_ << "UL;" + << "// Fall through." << endl + << "}" // else + << "}"; // case + } + + private: + size_t state_; + String next_state_; + + ParticleName particle_name_; + }; + + + // + // + struct ParticleFunction: Traversal::All, + Traversal::Choice, + Traversal::Sequence, + Context + { + ParticleFunction (Context& c, SemanticGraph::Complex& type) + : Context (c), type_ (type) + { + *this >> contains_particle_ >> *this; + } + + + virtual void + traverse (SemanticGraph::All& a) + { + if (!a.context().count ("comp-number")) // Empty compositor. + return; + + using SemanticGraph::Element; + using SemanticGraph::Compositor; + + + os << "void " << ename (type_) << "::" << endl + << "all_0 (unsigned long& state," << endl + << "unsigned char* count," << endl + << "const " << string_type << "& ns," << endl + << "const " << string_type << "& n," << endl + << "const " << string_type << "* t," << endl + << "bool start)" + << "{" + << "XSD_UNUSED (t);" + << endl; + + for (Compositor::ContainsIterator ci (a.contains_begin ()), + ce (a.contains_end ()); ci != ce; ++ci) + { + ParticleInAll t (*this, type_); + t.dispatch (ci->particle ()); + } + + // Handle the flush. + // + os << "else if (n.empty () && ns.empty ())" + << "{"; + + for (Compositor::ContainsIterator ci (a.contains_begin ()), + ce (a.contains_end ()); ci != ce; ++ci) + { + if (ci->min () == 0) + continue; + + Element& e (dynamic_cast (ci->particle ())); + String ns (e.qualified_p () ? e.namespace_ ().name () : String ()); + size_t state (e.context ().get ("state")); + + os << "if (count[" << state << "UL] == 0)" << endl + << "this->_expected_element (" << endl + << strlit (ns) << ", " << + strlit (e.name ()) << ");" + << endl; + } + + os << "state = ~0UL;" + << "}" + << "else" << endl + << "state = ~0UL;" + << "}"; + } + + virtual void + traverse (SemanticGraph::Choice& c) + { + if (!c.context().count ("comp-number")) // Empty compositor. + return; + + using SemanticGraph::Compositor; + + size_t n (c.context ().get ("comp-number")); + + os << "void " << ename (type_) << "::" << endl + << "choice_" << n << " (unsigned long& state," << endl + << "unsigned long& count," << endl + << "const " << string_type << "& ns," << endl + << "const " << string_type << "& n," << endl + << "const " << string_type << "* t," << endl + << "bool start)" + << "{" + << "XSD_UNUSED (count);" + << "XSD_UNUSED (ns);" + << "XSD_UNUSED (n);" + << "XSD_UNUSED (t);" + << endl + << "switch (state)" + << "{"; + + for (Compositor::ContainsIterator ci (c.contains_begin ()), + ce (c.contains_end ()); ci != ce; ++ci) + { + SemanticGraph::Particle& p (ci->particle ()); + + if (p.is_a () && !p.context().count ("comp-number")) + continue; // Empty compositor. + + ParticleInChoice t (*this, type_); + t.dispatch (p); + } + + os << "}" // switch + << "}"; + + // Generate nested compositor functions. + // + Traversal::Choice::traverse (c); + } + + virtual void + traverse (SemanticGraph::Sequence& s) + { + if (!s.context().count ("comp-number")) // Empty compositor. + return; + + using SemanticGraph::Compositor; + + size_t n (s.context ().get ("comp-number")); + + os << "void " << ename (type_) << "::" << endl + << "sequence_" << n << " (unsigned long& state," << endl + << "unsigned long& count," << endl + << "const " << string_type << "& ns," << endl + << "const " << string_type << "& n," << endl + << "const " << string_type << "* t," << endl + << "bool start)" + << "{" + << "XSD_UNUSED (t);" + << endl + << "switch (state)" + << "{"; + + size_t state (0); + + for (Compositor::ContainsIterator ci (s.contains_begin ()), + ce (s.contains_end ()); ci != ce;) + { + SemanticGraph::Particle& p (ci->particle ()); + + if (p.is_a () && !p.context().count ("comp-number")) + { + // Empty compositor. + // + ++ci; + continue; + } + + // Find the next state. + // + do + ++ci; + while (ci != ce && + ci->particle ().is_a () && + !ci->particle ().context().count ("comp-number")); + + size_t next (ci == ce ? 0 : state + 1); + + ParticleInSequence t (*this, state++, next, type_); + t.dispatch (p); + } + + os << "case ~0UL:" << endl + << "break;" + << "}" // switch + << "}"; + + // Generate nested compositor functions. + // + Traversal::Sequence::traverse (s); + } + + private: + SemanticGraph::Complex& type_; + Traversal::ContainsParticle contains_particle_; + }; + + + // + // + struct CompositorPre: Traversal::All, + Traversal::Compositor, + Context + { + CompositorPre (Context& c) + : Context (c) + { + } + + virtual void + traverse (SemanticGraph::All& a) + { + // Clear the counts and push the initial state. + // + os << "v_all_count_.push ();" + << endl; + + SemanticGraph::Compositor& c (a); + traverse (c); + } + + virtual void + traverse (SemanticGraph::Compositor&) // Choice and sequence. + { + os << "v_state_& vs = *static_cast< v_state_* > (" << + "this->v_state_stack_.top ());" + << "v_state_descr_& vd = vs.data[vs.size++];" // push + << endl + << "vd.func = 0;" + << "vd.state = 0;" + << "vd.count = 0;"; + } + }; + + + // + // + struct CompositorStartElement: Traversal::All, + Traversal::Compositor, + Context + { + CompositorStartElement (Context& c, SemanticGraph::Complex& type) + : Context (c), type_ (type), + particle_test_ (c), particle_name_ (c) + { + } + + virtual void + traverse (SemanticGraph::All&) + { + // The 'all' state machine reaches the final state only + // on an unknown element, in which case we won't get here + // again (it would be a validation error). Note that 'all' + // compositor cannot contain nested compositors so we don't + // need to re-set vd. + // + os << "all_0 (vd->state, v_all_count_.top (), ns, n, t, true);" + << endl + << "if (vd->state != ~0UL)" << endl + << "vd->count++;" + << "else" << endl + << "return false;" // Let our parent handle this. + << endl; + } + + virtual void + traverse (SemanticGraph::Compositor& c) // Choice and sequence. + { + using SemanticGraph::Compositor; + + size_t max (c.max ()); + size_t min (c.context ().get ("effective-min")); + size_t n (c.context ().get ("comp-number")); + + String func (c.is_a () ? + "choice_" : "sequence_"); + + // Invoke the current state machine. If it reaches its + // terminal state, pop it and invoke the next one until + // we reach the top, which requires special handling. + // + os << "while (vd->func != 0)" + << "{" + << "(this->*vd->func) (vd->state, vd->count, ns, n, t, true);" + << endl + << "vd = vs.data + (vs.size - 1);" // re-acquire + << endl + << "if (vd->state == ~0UL)" << endl + << "vd = vs.data + (--vs.size - 1);" // pop + << "else" << endl + << "break;" + << "}"; + + + // Check if we got to the top. This code is pretty much the + // same as the one found in ParticleInSequence. + // + os << "if (vd->func == 0)" + << "{" + << "if (vd->state != ~0UL)" + << "{" + << "unsigned long s = ~0UL;" + << endl; + + bool first (true); + + // Note that we don't need to worry about the compositor + // being empty - this case is handled by our caller. + // + for (Compositor::ContainsIterator ci (c.contains_begin ()); + ci != c.contains_end (); ++ci) + { + SemanticGraph::Particle& p (ci->particle ()); + + if (p.is_a () && !c.context ().count ("comp-number")) + continue; // Empty compositor. + + if (!p.context ().count ("prefix")) + break; + + size_t state (p.context ().get ("state")); + + if (first) + first = false; + else + os << "else "; + + os << "if ("; + + particle_test_.dispatch (p); + + os << ")" << endl + << "s = " << state << "UL;"; + } + + os << endl + << "if (s != ~0UL)" + << "{"; + + // This element is a prefix of the root compositor. + // + + switch (max) + { + case 0: + { + os << "vd->count++;"; + break; + } + case 1: + { + os << "vd->count++;" + << "vd->state = ~0UL;"; + break; + } + default: + { + os << "if (++vd->count == " << max << "UL)" << endl + << "vd->state = ~0UL;"; + } + }; + + // Delegate to the sub-machine. + // + + os << endl + << "vd = vs.data + vs.size++;" // push + << "vd->func = &" << ename (type_) << "::" << func << n << ";" + << "vd->state = s;" + << "vd->count = 0;" + << endl + << "this->" << func << n << " (vd->state, vd->count, ns, n, t, true);" + << "}"; + + // This element is not our prefix. + // + + os << "else" + << "{"; + + // Check if min cardinality requirements have been met. Since + // count is always >= 0, don't generate dead code if min == 0. + // + if (min != 0) + { + os << "if (vd->count < " << min << "UL)" << endl + << "this->_expected_element (" << endl; + + particle_name_.dispatch (c); + + os << "," << endl + << "ns, n);"; + } + + // Return false to indicate that we are not handling this element. + // + os << "return false;" + << "}" + << "}" // if (state != ~0) + << "else" << endl + << "return false;" + << "}"; // if (function == 0) + } + + private: + SemanticGraph::Complex& type_; + ParticleTest particle_test_; + ParticleName particle_name_; + }; + + + // + // + struct CompositorEndElement: Traversal::All, + Traversal::Compositor, + Context + { + CompositorEndElement (Context& c) + : Context (c) + { + } + + virtual void + traverse (SemanticGraph::All&) + { + os << "all_0 (vd.state, v_all_count_.top (), " << + "ns, n, 0, false);" + << endl; + } + + virtual void + traverse (SemanticGraph::Compositor&) // Choice and sequence. + { + os << "assert (vd.func != 0);" + << "(this->*vd.func) (vd.state, vd.count, ns, n, 0, false);" + << endl + << "if (vd.state == ~0UL)" << endl + << "vs.size--;" // pop + << endl; + } + }; + + + // + // + struct CompositorPost: Traversal::All, + Traversal::Compositor, + Context + { + CompositorPost (Context& c) + : Context (c), particle_name_ (c) + { + } + + virtual void + traverse (SemanticGraph::All& a) + { + using SemanticGraph::Element; + + os << "v_state_& vs = *static_cast< v_state_* > (" << + "this->v_state_stack_.top ());" + << "v_state_descr_& vd = vs.data[vs.size - 1];" + << endl; + + // Flush the state machine with the empty element name. This + // allows us to detect missing content. + // + os << "if (vd.count != 0)" + << "{" + << string_type << " empty;" + << "all_0 (vd.state, v_all_count_.top (), empty, empty, 0, true);" + << "}"; + + if (a.context ().get ("effective-min") != 0) + { + os << "else" << endl + << "this->_expected_element (" << endl; + + particle_name_.dispatch (a); + + os << ");"; + } + + os << endl + << "vs.size--;" // pop + << "v_all_count_.pop ();"; + } + + virtual void + traverse (SemanticGraph::Compositor& c) // Choice and sequence. + { + size_t min (c.context ().get ("effective-min")); + + os << "v_state_& vs = *static_cast< v_state_* > (" << + "this->v_state_stack_.top ());" + << "v_state_descr_* vd = vs.data + (vs.size - 1);" + << endl; + + + // Flush unfinished state machines with the empty element name. + // This allows us to detect missing content. Note that I am + // not re-setting vd since no new compositors are pushed on + // flush. + // + os << string_type << " empty;" + << "while (vd->func != 0)" + << "{" + << "(this->*vd->func) (vd->state, vd->count, empty, empty, 0, true);" + << "assert (vd->state == ~0UL);" + << "vd = vs.data + (--vs.size - 1);" // pop + << "}"; + + // Check if min cardinality requirements have been met. Since + // count is always >= 0, don't generate dead code if min == 0. + // + if (min != 0) + { + os << "if (vd->count < " << min << "UL)" << endl + << "this->_expected_element (" << endl; + + particle_name_.dispatch (c); + + os << ");"; + } + } + + private: + ParticleName particle_name_; + }; + + + // + // + struct Complex: Traversal::Complex, Context + { + Complex (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& c) + { + // Nothing to generate if we don't have any elements and wildcards. + // + if (!has (c) && + !has_particle (c)) + return; + + using SemanticGraph::Compositor; + + String const& name (ename (c)); + Compositor& comp (c.contains_compositor ().compositor ()); + + // Don't use restriction_p here since we don't want special + // treatment of anyType. + // + bool restriction ( + c.inherits_p () && + c.inherits ().is_a ()); + + os <<"// Element validation and dispatch functions for " << + name << "." << endl + <<"//" << endl; + + // _start_element_impl + // + + os << "bool " << name << "::" << endl + << "_start_element_impl (const " << string_type << "& ns," << endl + << "const " << string_type << "& n," << endl + << "const " << string_type << "* t)" + << "{" + << "XSD_UNUSED (t);" + << endl; + + os << "v_state_& vs = *static_cast< v_state_* > (" << + "this->v_state_stack_.top ());" + << "v_state_descr_* vd = vs.data + (vs.size - 1);" + << endl; + + //@@ OPT: I don't really need to call parser_base since it always + // returns false. + // + // In case of an inheritance-by-extension, call our base first. + // We don't need to generate this code for the 'all' compositor + // because it can only inherit from the empty content model. + // States of the root machine for sequence and choice: + // + // 0 - calling base + // 1 - base returned false + // ~0 - terminal state + // + if (!restriction && !comp.is_a ()) + { + os << "if (vd->func == 0 && vd->state == 0)" + << "{" + << "if (this->"; + + if (c.inherits_p ()) + os << fq_name (c.inherits ().base ()); + else + os << complex_base; + + + os << "::_start_element_impl (ns, n, t))" << endl + << "return true;" + << "else" << endl + << "vd->state = 1;" + << "}"; + } + + { + CompositorStartElement t (*this, c); + t.dispatch (comp); + } + + os << "return true;" + << "}"; + + + // _end_element_impl + // + + os << "bool " << name << "::" << endl + << "_end_element_impl (const " << string_type << "& ns," << endl + << "const " << string_type << "& n)" + << "{"; + + os << "v_state_& vs = *static_cast< v_state_* > (" << + "this->v_state_stack_.top ());" + << "v_state_descr_& vd = vs.data[vs.size - 1];" + << endl; + + //@@ OPT: I don't really need to call parser_base since it always + // returns false. + // + // In case of an inheritance-by-extension, call our base first. + // We don't need to generate this code for the 'all' compositor + // because it can only inherit from the empty content model. + // + if (!restriction && !comp.is_a ()) + { + os << "if (vd.func == 0 && vd.state == 0)" + << "{" + << "if (!"; + + if (c.inherits_p ()) + os << fq_name (c.inherits ().base ()); + else + os << complex_base; + + os << "::_end_element_impl (ns, n))" << endl + << "assert (false);" // Start and end should match. + << "return true;" + << "}"; + } + + { + CompositorEndElement t (*this); + t.dispatch (comp); + } + + os << "return true;" + << "}"; + + + // _pre_e_validate + // + os << "void " << name << "::" << endl + << "_pre_e_validate ()" + << "{" + << "this->v_state_stack_.push ();" + << "static_cast< v_state_* > (this->v_state_stack_.top ())->" << + "size = 0;" + << endl; + + { + CompositorPre t (*this); + t.dispatch (comp); + } + + // In case of an inheritance-by-extension, call our base + // _pre_e_validate. We don't need to generate this code for the + // 'all' compositor because it can only inherit from the empty + // content model. + // + if (!restriction && !comp.is_a ()) + { + // We don't need to call parser_base's implementation + // since it does nothing. + // + if (c.inherits_p ()) + { + os << endl + << fq_name (c.inherits ().base ()) << "::_pre_e_validate ();"; + } + } + + os << "}"; + + + // _post_e_validate + // + os << "void " << name << "::" << endl + << "_post_e_validate ()" + << "{"; + + // In case of an inheritance-by-extension, call our base + // _post_e_validate. We don't need to generate this code for + // the 'all' compositor because it can only inherit from + // the empty content model. + // + if (!restriction && !comp.is_a ()) + { + // We don't need to call parser_base's implementation + // since it does nothing. + // + if (c.inherits_p ()) + { + os << fq_name (c.inherits ().base ()) << "::_post_e_validate ();" + << endl; + } + } + + { + CompositorPost t (*this); + t.dispatch (c.contains_compositor ().compositor ()); + } + + os << endl + << "this->v_state_stack_.pop ();" + << "}"; + + // + // + ParticleFunction t (*this, c); + t.dispatch (c.contains_compositor ().compositor ()); + } + }; + } + + void + generate_element_validation_source (Context& ctx) + { + ctx.os << "#include " << endl + << endl; + + Traversal::Schema schema; + + Sources sources; + Traversal::Names schema_names; + + Namespace ns (ctx); + Traversal::Names names; + + schema >> sources >> schema; + schema >> schema_names >> ns >> names; + + Complex complex (ctx); + + names >> complex; + + schema.dispatch (ctx.schema_root); + } + } +} diff --git a/xsd/xsd/cxx/parser/element-validation-source.hxx b/xsd/xsd/cxx/parser/element-validation-source.hxx new file mode 100644 index 0000000..b358aee --- /dev/null +++ b/xsd/xsd/cxx/parser/element-validation-source.hxx @@ -0,0 +1,18 @@ +// file : xsd/cxx/parser/element-validation-source.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_PARSER_ELEMENT_VALIDATION_SOURCE_HXX +#define XSD_CXX_PARSER_ELEMENT_VALIDATION_SOURCE_HXX + +#include + +namespace CXX +{ + namespace Parser + { + void + generate_element_validation_source (Context&); + } +} + +#endif // XSD_CXX_PARSER_ELEMENT_VALIDATION_SOURCE_HXX diff --git a/xsd/xsd/cxx/parser/elements.cxx b/xsd/xsd/cxx/parser/elements.cxx new file mode 100644 index 0000000..63fb3d5 --- /dev/null +++ b/xsd/xsd/cxx/parser/elements.cxx @@ -0,0 +1,247 @@ +// file : xsd/cxx/parser/elements.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +namespace CXX +{ + namespace Parser + { + Context:: + Context (std::wostream& o, + SemanticGraph::Schema& root, + SemanticGraph::Path const& path, + options_type const& ops, + StringLiteralMap const* map, + Regex const* he, + Regex const* ie, + Regex const* hie) + : CXX::Context (o, root, path, ops, map), + options (ops), + xml_parser (xml_parser_), + simple_base (simple_base_), + complex_base (complex_base_), + list_base (list_base_), + cout_inst (cout_inst_), + cerr_inst (cerr_inst_), + parser_map (parser_map_), + std_string_type (std_string_type_), + validation (validation_), + polymorphic (polymorphic_), + hxx_expr (he), + ixx_expr (ie), + hxx_impl_expr (hie), + xml_parser_ (ops.xml_parser ()), + validation_ ((ops.xml_parser () == "expat" || + ops.generate_validation ()) && + !ops.suppress_validation ()), + polymorphic_ (ops.generate_polymorphic ()) + { + if (char_type == L"char") + std_string_type = L"::std::string"; + else if (char_type == L"wchar_t") + std_string_type = L"::std::wstring"; + else + std_string_type = L"::std::basic_string< " + char_type + L" >"; + + String xs_ns (xs_ns_name ()); + + string_type = xs_ns + L"::ro_string"; + simple_base = xs_ns + L"::simple_content"; + complex_base = xs_ns + L"::complex_content"; + list_base = xs_ns + L"::list_base"; + + cout_inst = (char_type == L"char" ? L"std::cout" : L"std::wcout"); + cerr_inst = (char_type == L"char" ? L"std::cerr" : L"std::wcerr"); + + if (polymorphic) + parser_map_ = xs_ns + L"::parser_map"; + } + + Context:: + Context (Context& c) + : CXX::Context (c), + options (c.options), + xml_parser (c.xml_parser), + simple_base (c.simple_base), + complex_base (c.complex_base), + list_base (c.list_base), + cout_inst (c.cout_inst), + cerr_inst (c.cerr_inst), + parser_map (c.parser_map), + std_string_type (c.std_string_type), + validation (c.validation), + polymorphic (c.polymorphic), + hxx_expr (c.hxx_expr), + ixx_expr (c.ixx_expr), + hxx_impl_expr (c.hxx_impl_expr) + { + } + + Context:: + Context (Context& c, std::wostream& o) + : CXX::Context (c, o), + options (c.options), + xml_parser (c.xml_parser), + simple_base (c.simple_base), + complex_base (c.complex_base), + list_base (c.list_base), + cout_inst (c.cout_inst), + cerr_inst (c.cerr_inst), + parser_map (c.parser_map), + std_string_type (c.std_string_type), + validation (c.validation), + polymorphic (c.polymorphic), + hxx_expr (c.hxx_expr), + ixx_expr (c.ixx_expr), + hxx_impl_expr (c.hxx_impl_expr) + { + } + + Content::Value Context:: + content (SemanticGraph::Complex& c) + { + using namespace SemanticGraph; + + if (c.mixed_p ()) + return Content::mixed; + + if (c.inherits_p ()) + { + Type& base (c.inherits ().base ()); + + if (Complex* cb = dynamic_cast (&base)) + return content (*cb); + + if (base.is_a ()) + return Content::complex; + + // Everyhting else (built-in type and AnySimpleType) is simple + // content. + // + return Content::simple; + } + else + return Content::complex; + } + + bool Context:: + anonymous (SemanticGraph::Type& t) + { + return t.context ().count ("anonymous"); + } + + String const& Context:: + ret_type (SemanticGraph::Type& t) + { + return t.context ().get ("ret-type"); + } + + String const& Context:: + arg_type (SemanticGraph::Type& t) + { + return t.context ().get ("arg-type"); + } + + String const& Context:: + post_name (SemanticGraph::Type& t) + { + return t.context ().get ("post"); + } + + String const& Context:: + eparser (SemanticGraph::Member& m) + { + return m.context ().get ("parser"); + } + + String const& Context:: + emember (SemanticGraph::Member& m) + { + return m.context ().get ("member"); + } + + String const& Context:: + emember_map (SemanticGraph::Member& m) + { + return m.context ().get ("member-map"); + } + + String const& Context:: + eimpl (SemanticGraph::Type& t) + { + return t.context ().get ("impl"); + } + + // Includes + // + void TypeForward:: + traverse (SemanticGraph::Type& t) + { + os << "class " << t.context ().get (name_key_) << ";"; + } + + void Includes:: + traverse_ (SemanticGraph::Uses& u) + { + // Support for weak (forward) inclusion used in the file-per-type + // compilation model. + // + SemanticGraph::Schema& s (u.schema ()); + bool weak (u.context ().count ("weak")); + + if (weak && (type_ == header || type_ == impl_header)) + { + // Generate forward declarations. We don't really need them + // in the impl files. + // + if (type_ == header) + schema_.dispatch (s); + + return; + } + + if (type_ == source && !weak) + return; + + SemanticGraph::Path path ( + s.context ().count ("renamed") + ? s.context ().get ("renamed") + : u.path ()); + path.normalize (); + + // Try to use the portable representation of the path. If that + // fails, fall back to the native representation. + // + NarrowString path_str; + try + { + path_str = path.posix_string (); + } + catch (SemanticGraph::InvalidPath const&) + { + path_str = path.string (); + } + + String inc_path; + + switch (type_) + { + case header: + case source: + { + inc_path = ctx_.hxx_expr->replace (path_str); + break; + } + case impl_header: + { + inc_path = ctx_.hxx_impl_expr->replace (path_str); + break; + } + } + + ctx_.os << "#include " << ctx_.process_include_path (inc_path) << endl + << endl; + } + } +} diff --git a/xsd/xsd/cxx/parser/elements.hxx b/xsd/xsd/cxx/parser/elements.hxx new file mode 100644 index 0000000..0015923 --- /dev/null +++ b/xsd/xsd/cxx/parser/elements.hxx @@ -0,0 +1,315 @@ +// file : xsd/cxx/parser/elements.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_PARSER_ELEMENTS_HXX +#define XSD_CXX_PARSER_ELEMENTS_HXX + +#include + +#include + +#include + +#include + +#include + +namespace CXX +{ + namespace Parser + { + struct Content + { + enum Value + { + simple, + complex, + mixed + }; + }; + + // + // + class Context: public CXX::Context + { + public: + typedef cutl::re::regexsub Regex; + + typedef Parser::options options_type; + + public: + Context (std::wostream&, + SemanticGraph::Schema&, + SemanticGraph::Path const& path, + options_type const&, + StringLiteralMap const*, + Regex const* hxx_expr, + Regex const* ixx_expr, + Regex const* hxx_impl_expr); + + protected: + Context (Context& c); + Context (Context& c, std::wostream& o); + + public: + bool + restriction_p (SemanticGraph::Complex& c) const + { + if (c.inherits_p () && + c.inherits ().is_a ()) + { + // Restriction of anyType is a special case. + // + return !c.inherits ().base ().is_a (); + } + + return false; + } + + public: + static Content::Value + content (SemanticGraph::Complex&); + + public: + static bool + anonymous (SemanticGraph::Type&); + + public: + static String const& + ret_type (SemanticGraph::Type&); + + static String const& + arg_type (SemanticGraph::Type&); + + static String const& + post_name (SemanticGraph::Type&); + + public: + static String const& + eparser (SemanticGraph::Member&); + + static String const& + emember (SemanticGraph::Member&); + + static String const& + emember_map (SemanticGraph::Member&); + + public: + static String const& + eimpl (SemanticGraph::Type&); + + public: + options_type const& options; + String& xml_parser; + String& simple_base; + String& complex_base; + String& list_base; + String& cout_inst; + String& cerr_inst; + String& parser_map; + String& std_string_type; + bool& validation; + bool& polymorphic; + + Regex const* hxx_expr; + Regex const* ixx_expr; + Regex const* hxx_impl_expr; + + private: + String xml_parser_; + String simple_base_; + String complex_base_; + String list_base_; + String cout_inst_; + String cerr_inst_; + String parser_map_; + String std_string_type_; + bool validation_; + bool polymorphic_; + }; + + // + // + struct RequiredAttributeTest: Traversal::Attribute + { + RequiredAttributeTest (bool& result) + : result_ (result) + { + } + + virtual void + traverse (Type& a) + { + if (!result_ && !a.optional_p ()) + result_ = true; + } + + private: + bool& result_; + }; + + // + // + struct ParserParamDecl: Traversal::Complex, + Traversal::List, + Traversal::Member, + Context + { + ParserParamDecl (Context& c, bool name_arg) + : Context (c), first_ (true), name_arg_ (name_arg) + { + inherits_ >> *this; + names_ >> *this; + } + + virtual void + traverse (SemanticGraph::Complex& c) + { + inherits (c, inherits_); + + if (!restriction_p (c)) + names (c, names_); + } + + virtual void + traverse (SemanticGraph::List& l) + { + if (!first_) + os << "," << endl; + else + first_ = false; + + os << fq_name (l.argumented ().type ()) << "&"; + + if (name_arg_) + os << " " << ename (l) << "_item"; + else + os << " /* " << comment (l.name ()) << " item */"; + } + + virtual void + traverse (SemanticGraph::Member& m) + { + if (skip (m)) return; + + if (!first_) + os << "," << endl; + else + first_ = false; + + os << fq_name (m.type ()) << "&"; + + if (name_arg_) + os << " " << ename (m); + else + os << " /* " << comment (m.name ()) << " */"; + } + + private: + Traversal::Inherits inherits_; + Traversal::Names names_; + + bool first_; + bool name_arg_; + }; + + + // + // + struct TypeForward: Traversal::Type, Context + { + TypeForward (Context& c, char const* name_key) + : Context (c), name_key_ (name_key) + { + } + + virtual void + traverse (SemanticGraph::Type& t); + + private: + char const* name_key_; + }; + + struct Includes: Traversal::Imports, + Traversal::Includes + { + enum Type + { + header, + source, + impl_header + }; + + Includes (Context& c, Type t) + : ctx_ (c), + type_ (t), + namespace_ (c), + type_forward_ (c, t == header ? "name" : "impl") + { + schema_ >> schema_names_ >> namespace_ >> names_ >> type_forward_; + } + + virtual void + traverse (SemanticGraph::Imports& i) + { + traverse_ (i); + } + + virtual void + traverse (SemanticGraph::Includes& i) + { + traverse_ (i); + } + + private: + void + traverse_ (SemanticGraph::Uses&); + + private: + Context& ctx_; + Type type_; + + Traversal::Schema schema_; + Traversal::Names schema_names_; + Namespace namespace_; + Traversal::Names names_; + TypeForward type_forward_; + }; + + // Find root element for the test driver. + // + struct RootElement: Traversal::Element + { + typedef Parser::options options_type; + + RootElement (options_type const& options, + SemanticGraph::Element*& element) + : options_ (options), element_ (element) + { + } + + virtual void + traverse (Type& e) + { + if (options_.root_element_first ()) + { + if (element_ == 0) + element_ = &e; + } + else if (String name = options_.root_element ()) + { + if (e.name () == name) + element_ = &e; + } + else + element_ = &e; // Cover root-element-last and no option. + } + + private: + options_type const& options_; + SemanticGraph::Element*& element_; + }; + } +} + +#endif // XSD_CXX_PARSER_ELEMENTS_HXX diff --git a/xsd/xsd/cxx/parser/generator.cxx b/xsd/xsd/cxx/parser/generator.cxx new file mode 100644 index 0000000..91af898 --- /dev/null +++ b/xsd/xsd/cxx/parser/generator.cxx @@ -0,0 +1,1099 @@ +// file : xsd/cxx/parser/generator.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include +#include + +#include + +#include +#include +#include + +#include + +#include + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include + +using std::endl; +using std::wcerr; +using std::wcout; + +using namespace XSDFrontend::SemanticGraph; + +// +// +typedef std::wifstream WideInputFileStream; +typedef std::wofstream WideOutputFileStream; +typedef std::ifstream NarrowInputFileStream; + +namespace CXX +{ + namespace + { + char const copyright_gpl[] = + "// Copyright (c) " XSD_COPYRIGHT ".\n" + "//\n" + "// This program was generated by CodeSynthesis XSD, an XML Schema to\n" + "// C++ data binding compiler.\n" + "//\n" + "// This program is free software; you can redistribute it and/or modify\n" + "// it under the terms of the GNU General Public License version 2 as\n" + "// published by the Free Software Foundation.\n" + "//\n" + "// This program is distributed in the hope that it will be useful,\n" + "// but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + "// GNU General Public License for more details.\n" + "//\n" + "// You should have received a copy of the GNU General Public License\n" + "// along with this program; if not, write to the Free Software\n" + "// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n" + "//\n" + "// In addition, as a special exception, Code Synthesis Tools CC gives\n" + "// permission to link this program with the Xerces-C++ library (or with\n" + "// modified versions of Xerces-C++ that use the same license as Xerces-C++),\n" + "// and distribute linked combinations including the two. You must obey\n" + "// the GNU General Public License version 2 in all respects for all of\n" + "// the code used other than Xerces-C++. If you modify this copy of the\n" + "// program, you may extend this exception to your version of the program,\n" + "// but you are not obligated to do so. If you do not wish to do so, delete\n" + "// this exception statement from your version.\n" + "//\n" + "// Furthermore, Code Synthesis Tools CC makes a special exception for\n" + "// the Free/Libre and Open Source Software (FLOSS) which is described\n" + "// in the accompanying FLOSSE file.\n" + "//\n\n"; + + char const copyright_proprietary[] = + "// Copyright (c) " XSD_COPYRIGHT ".\n" + "//\n" + "// This program was generated by CodeSynthesis XSD, an XML Schema\n" + "// to C++ data binding compiler, in the Proprietary License mode.\n" + "// You should have received a proprietary license from Code Synthesis\n" + "// Tools CC prior to generating this code. See the license text for\n" + "// conditions.\n" + "//\n\n"; + + char const copyright_impl[] = + "// Not copyrighted - public domain.\n" + "//\n" + "// This sample parser implementation was generated by CodeSynthesis XSD,\n" + "// an XML Schema to C++ data binding compiler. You may use it in your\n" + "// programs without any restrictions.\n" + "//\n\n"; + } + + void Parser::Generator:: + usage () + { + CXX::Parser::options::print_usage (wcout); + CXX::options::print_usage (wcout); + } + + namespace + { + template + void + open (S& ifs, NarrowString const& path) + { + try + { + Path fs_path (path); + ifs.open (fs_path.string ().c_str (), + std::ios_base::in | std::ios_base::binary); + + if (!ifs.is_open ()) + { + wcerr << path.c_str () << ": error: unable to open in read mode" + << endl; + + throw Parser::Generator::Failed (); + } + } + catch (InvalidPath const&) + { + wcerr << "error: '" << path.c_str () << "' is not a valid " + << "filesystem path" << endl; + + throw Parser::Generator::Failed (); + } + } + + void + append (WideOutputFileStream& os, + NarrowString const& path, + WideInputFileStream& default_is) + { + using std::ios_base; + + if (path) + { + WideInputFileStream is; + open (is, path); + os << is.rdbuf (); + } + else if (default_is.is_open ()) + { + os << default_is.rdbuf (); + default_is.seekg (0, ios_base::beg); + } + } + + void + append (WideOutputFileStream& os, + NarrowStrings const& primary, + NarrowStrings const& def) + { + NarrowStrings const& v (primary.empty () ? def : primary); + + for (NarrowStrings::const_iterator i (v.begin ()), e (v.end ()); + i != e; ++i) + { + os << i->c_str () << endl; + } + } + } + + + size_t Parser::Generator:: + generate (Parser::options const& ops, + Schema& schema, + Path const& file_path, + bool fpt, + StringLiteralMap const& string_literal_map, + bool gen_driver, + const WarningSet& disabled_warnings, + FileList& file_list, + AutoUnlinks& unlinks) + { + using std::ios_base; + + typedef cutl::re::regexsub Regex; + + try + { + bool generate_xml_schema (ops.generate_xml_schema ()); + + // We could be compiling several schemas at once in which case + // handling of the --generate-xml-schema option gets tricky: we + // will need to rely on the presence of the --extern-xml-schema + // to tell us which (fake) schema file corresponds to XML Schema. + // + if (generate_xml_schema) + { + if (NarrowString name = ops.extern_xml_schema ()) + { + if (file_path.string () != name) + generate_xml_schema = false; + } + } + + bool impl (!generate_xml_schema && + (ops.generate_noop_impl () || + ops.generate_print_impl ())); + + bool driver (gen_driver && !generate_xml_schema && + ops.generate_test_driver ()); + + // Evaluate the graph for possibility of generating something useful. + // + { + Validator validator; + if (!validator.validate ( + ops, schema, file_path, driver, disabled_warnings)) + throw Failed (); + } + + // Process names. + // + { + NameProcessor proc; + proc.process (ops, schema, file_path, string_literal_map); + } + + bool validation ((ops.xml_parser () == "expat" || + ops.generate_validation ()) && + !ops.suppress_validation ()); + + // Compute state machine info. + // + if (validation) + { + StateProcessor proc; + proc.process (schema, file_path); + } + + // Read-in type maps. + // + TypeMap::Namespaces type_map; + { + using namespace TypeMap; + + NarrowStrings const& files (ops.type_map ()); + + for (NarrowStrings::const_iterator f (files.begin ()); + f != files.end (); ++f ) + { + NarrowInputFileStream ifs; + open (ifs, *f); + + Lexer l (ifs, *f); + TypeMap::Parser p (l, *f); + + if (!p.parse (type_map)) + throw Failed (); + } + + // Add the built-in mappings at the end. + // + + // String-based types. + // + String char_type (ops.char_type ()); + String string_type; + + if (char_type == L"char") + string_type = L"::std::string"; + else if (char_type == L"wchar_t") + string_type = L"::std::wstring"; + else + string_type = L"::std::basic_string< " + char_type + L" >"; + + String xns; + String auto_ptr; + { + Context ctx (std::wcerr, schema, file_path, ops, 0, 0, 0, 0); + xns = ctx.xs_ns_name (); + auto_ptr = ctx.auto_ptr; + } + + String buffer (auto_ptr + L"< " + xns + L"::buffer >"); + TypeMap::Namespace xsd ("http://www\\.w3\\.org/2001/XMLSchema"); + + xsd.types_push_back ("string", string_type); + xsd.types_push_back ("normalizedString", string_type); + xsd.types_push_back ("token", string_type); + xsd.types_push_back ("Name", string_type); + xsd.types_push_back ("NMTOKEN", string_type); + xsd.types_push_back ("NMTOKENS", xns + L"::string_sequence"); + xsd.types_push_back ("NCName", string_type); + + xsd.types_push_back ("ID", string_type); + xsd.types_push_back ("IDREF", string_type); + xsd.types_push_back ("IDREFS", xns + L"::string_sequence"); + + xsd.types_push_back ("language", string_type); + xsd.types_push_back ("anyURI", string_type); + xsd.types_push_back ("QName", xns + L"::qname"); + + xsd.types_push_back ("base64Binary", buffer, buffer); + xsd.types_push_back ("hexBinary", buffer, buffer); + + xsd.types_push_back ("gDay", xns + L"::gday"); + xsd.types_push_back ("gMonth", xns + L"::gmonth"); + xsd.types_push_back ("gYear", xns + L"::gyear"); + xsd.types_push_back ("gMonthDay", xns + L"::gmonth_day"); + xsd.types_push_back ("gYearMonth", xns + L"::gyear_month"); + xsd.types_push_back ("date", xns + L"::date"); + xsd.types_push_back ("time", xns + L"::time"); + xsd.types_push_back ("dateTime", xns + L"::date_time"); + xsd.types_push_back ("duration", xns + L"::duration"); + + // Fundamental C++ types. + // + xsd.types_push_back ("boolean", "bool", "bool"); + + xsd.types_push_back ("byte", "signed char", "signed char"); + xsd.types_push_back ("unsignedByte", + "unsigned char", + "unsigned char"); + + xsd.types_push_back ("short", "short", "short"); + xsd.types_push_back ("unsignedShort", + "unsigned short", + "unsigned short"); + + xsd.types_push_back ("int", "int", "int"); + xsd.types_push_back ("unsignedInt", "unsigned int", "unsigned int"); + + xsd.types_push_back ("long", "long long", "long long"); + xsd.types_push_back ("unsignedLong", + "unsigned long long", + "unsigned long long"); + + xsd.types_push_back ("integer", "long long", "long long"); + + xsd.types_push_back ("negativeInteger", "long long", "long long"); + xsd.types_push_back ("nonPositiveInteger", "long long", "long long"); + + xsd.types_push_back ("positiveInteger", + "unsigned long long", + "unsigned long long"); + xsd.types_push_back ("nonNegativeInteger", + "unsigned long long", + "unsigned long long"); + + xsd.types_push_back ("float", "float", "float"); + xsd.types_push_back ("double", "double", "double"); + xsd.types_push_back ("decimal", "double", "double"); + + type_map.push_back (xsd); + + // Everything else maps to void. + // + TypeMap::Namespace rest (".*"); + rest.types_push_back (".*", "void", "void"); + type_map.push_back (rest); + } + + // Process types. + // + { + TypeProcessor proc; + proc.process (ops, schema, gen_driver, type_map); + } + + // + // + bool inline_ (ops.generate_inline () && !generate_xml_schema); + bool source (!generate_xml_schema); + + // Generate code. + // + NarrowString name (file_path.leaf ().string ()); + NarrowString skel_suffix (ops.skel_file_suffix ()); + NarrowString impl_suffix (ops.impl_file_suffix ()); + + NarrowString hxx_suffix (ops.hxx_suffix ()); + NarrowString ixx_suffix (ops.ixx_suffix ()); + NarrowString cxx_suffix (ops.cxx_suffix ()); + + Regex hxx_expr ( + ops.hxx_regex ().empty () + ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + skel_suffix + hxx_suffix + "#" + : ops.hxx_regex ()); + + Regex ixx_expr ( + ops.ixx_regex ().empty () + ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + skel_suffix + ixx_suffix + "#" + : ops.ixx_regex ()); + + Regex cxx_expr ( + ops.cxx_regex ().empty () + ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + skel_suffix + cxx_suffix + "#" + : ops.cxx_regex ()); + + + Regex hxx_impl_expr; + Regex cxx_impl_expr; + Regex cxx_driver_expr; + + if (impl || driver) + { + hxx_impl_expr = + "#^(.+?)(\\.[^./\\\\]+)?$#$1" + impl_suffix + hxx_suffix + "#"; + + cxx_impl_expr = + "#^(.+?)(\\.[^./\\\\]+)?$#$1" + impl_suffix + cxx_suffix + "#"; + + cxx_driver_expr = + "#^(.+?)(\\.[^./\\\\]+)?$#$1-driver" + cxx_suffix + "#"; + } + + if (!hxx_expr.match (name)) + { + wcerr << "error: header expression '" << + hxx_expr.regex ().str ().c_str () << "' does not match '" << + name.c_str () << "'" << endl; + throw Failed (); + } + + if (inline_ && !ixx_expr.match (name)) + { + wcerr << "error: inline expression '" << + ixx_expr.regex ().str ().c_str () << "' does not match '" << + name.c_str () << "'" << endl; + throw Failed (); + } + + if (source && !cxx_expr.match (name)) + { + wcerr << "error: source expression '" << + cxx_expr.regex ().str ().c_str () << "' does not match '" << + name.c_str () << "'" << endl; + throw Failed (); + } + + if (impl || driver) + { + if (!hxx_impl_expr.match (name)) + { + wcerr << "error: implementation header expression '" << + hxx_impl_expr.regex ().str ().c_str () << "' does not match '" << + name.c_str () << "'" << endl; + throw Failed (); + } + + if (!cxx_impl_expr.match (name)) + { + wcerr << "error: implementation source expression '" << + cxx_impl_expr.regex ().str ().c_str () << "' does not match '" << + name.c_str () << "'" << endl; + throw Failed (); + } + + if (!cxx_driver_expr.match (name)) + { + wcerr << "error: driver source expression '" << + cxx_driver_expr.regex ().str ().c_str () << "' does not match '" << + name.c_str () << "'" << endl; + throw Failed (); + } + } + + NarrowString hxx_name (hxx_expr.replace (name)); + NarrowString ixx_name (inline_ ? ixx_expr.replace (name) : NarrowString ()); + NarrowString cxx_name (source ? cxx_expr.replace (name) : NarrowString ()); + + NarrowString hxx_impl_name; + NarrowString cxx_impl_name; + NarrowString cxx_driver_name; + + if (impl || driver) + { + hxx_impl_name = hxx_impl_expr.replace (name); + cxx_impl_name = cxx_impl_expr.replace (name); + cxx_driver_name = cxx_driver_expr.replace (name); + } + + Path hxx_path (hxx_name); + Path ixx_path (ixx_name); + Path cxx_path (cxx_name); + + Path hxx_impl_path; + Path cxx_impl_path; + Path cxx_driver_path; + + if (impl || driver) + { + hxx_impl_path = Path (hxx_impl_name); + cxx_impl_path = Path (cxx_impl_name); + cxx_driver_path = Path (cxx_driver_name); + } + + Path out_dir; + + if (NarrowString dir = ops.output_dir ()) + { + try + { + out_dir = Path (dir); + } + catch (InvalidPath const&) + { + wcerr << dir.c_str () << ": error: invalid path" << endl; + throw Failed (); + } + } + + if (fpt && !generate_xml_schema) + { + // In the file-per-type mode the schema files are always local + // unless the user added the directory so that we propagate this + // to the output files. + // + Path fpt_dir (file_path.directory ()); + + if (!fpt_dir.empty ()) + out_dir /= fpt_dir; + } + + if (!out_dir.empty ()) + { + hxx_path = out_dir / hxx_path; + ixx_path = out_dir / ixx_path; + cxx_path = out_dir / cxx_path; + + if (impl || driver) + { + hxx_impl_path = out_dir / hxx_impl_path; + cxx_impl_path = out_dir / cxx_impl_path; + cxx_driver_path = out_dir /cxx_driver_path; + } + } + + // Open the impl files first so that if open fails, the skel files + // are not deleted. + // + WideOutputFileStream hxx_impl; + WideOutputFileStream cxx_impl; + WideOutputFileStream cxx_driver; + + if (impl) + { + if (!ops.force_overwrite ()) + { + WideInputFileStream tmp ( + hxx_impl_path.string ().c_str (), ios_base::in); + + if (tmp.is_open ()) + { + wcerr << hxx_impl_path << ": error: cowardly refusing to " << + "overwrite an existing file" << endl; + throw Failed (); + } + + tmp.close (); + } + + hxx_impl.open (hxx_impl_path.string ().c_str (), ios_base::out); + + if (!hxx_impl.is_open ()) + { + wcerr << hxx_impl_path << ": error: unable to open in write mode" + << endl; + throw Failed (); + } + + unlinks.add (hxx_impl_path); + file_list.push_back (hxx_impl_path.string ()); + + if (!ops.force_overwrite ()) + { + WideInputFileStream tmp ( + cxx_impl_path.string ().c_str (), ios_base::in); + + if (tmp.is_open ()) + { + wcerr << cxx_impl_path << ": error: cowardly refusing to " << + "overwrite an existing file" << endl; + throw Failed (); + } + + tmp.close (); + } + + cxx_impl.open (cxx_impl_path.string ().c_str (), ios_base::out); + + if (!cxx_impl.is_open ()) + { + wcerr << cxx_impl_path << ": error: unable to open in write mode" + << endl; + throw Failed (); + } + + unlinks.add (cxx_impl_path); + file_list.push_back (cxx_impl_path.string ()); + } + + if (driver) + { + if (!ops.force_overwrite ()) + { + WideInputFileStream tmp ( + cxx_driver_path.string ().c_str (), ios_base::in); + + if (tmp.is_open ()) + { + wcerr << cxx_driver_path << ": error: cowardly refusing to " << + "overwrite an existing file" << endl; + throw Failed (); + } + + tmp.close (); + } + + cxx_driver.open (cxx_driver_path.string ().c_str (), ios_base::out); + + if (!cxx_driver.is_open ()) + { + wcerr << cxx_driver_path << ": error: unable to open in write " << + "mode" << endl; + throw Failed (); + } + + unlinks.add (cxx_driver_path); + file_list.push_back (cxx_driver_path.string ()); + } + + // Open the skel files. + // + WideOutputFileStream hxx (hxx_path.string ().c_str (), ios_base::out); + WideOutputFileStream ixx; + WideOutputFileStream cxx; + + if (!hxx.is_open ()) + { + wcerr << hxx_path << ": error: unable to open in write mode" << endl; + throw Failed (); + } + + unlinks.add (hxx_path); + file_list.push_back (hxx_path.string ()); + + if (inline_) + { + ixx.open (ixx_path.string ().c_str (), ios_base::out); + + if (!ixx.is_open ()) + { + wcerr << ixx_path << ": error: unable to open in write mode" << endl; + throw Failed (); + } + + unlinks.add (ixx_path); + file_list.push_back (ixx_path.string ()); + } + + + if (source) + { + cxx.open (cxx_path.string ().c_str (), ios_base::out); + + if (!cxx.is_open ()) + { + wcerr << cxx_path << ": error: unable to open in write mode" << endl; + throw Failed (); + } + + unlinks.add (cxx_path); + file_list.push_back (cxx_path.string ()); + } + + // Print copyright and license. + // + char const* copyright ( + ops.proprietary_license () ? copyright_proprietary : copyright_gpl); + + hxx << copyright; + + if (inline_) + ixx << copyright; + + if (source) + cxx << copyright; + + if (impl) + { + hxx_impl << copyright_impl; + cxx_impl << copyright_impl; + } + + if (driver) + cxx_driver << copyright_impl; + + // Prologue. + // + WideInputFileStream prologue; + { + NarrowString name (ops.prologue_file ()); + + if (name) + open (prologue, name); + } + + // Epilogue. + // + WideInputFileStream epilogue; + { + NarrowString name (ops.epilogue_file ()); + + if (name) + open (epilogue, name); + } + + // SLOC counter. + // + size_t sloc_total (0); + bool show_sloc (ops.show_sloc ()); + + typedef + compiler::ostream_filter + ind_filter; + + typedef + compiler::ostream_filter + sloc_filter; + + // + // + Regex guard_expr ("/([a-z])([A-Z])/$1_$2/"); // Split words. + + NarrowString guard_prefix (ops.guard_prefix ()); + + if (!guard_prefix) + guard_prefix = file_path.directory ().string (); + + if (guard_prefix) + guard_prefix += '_'; + + // HXX + // + { + Context ctx (hxx, + schema, + file_path, + ops, + &string_literal_map, + &hxx_expr, + &ixx_expr, + &hxx_impl_expr); + + sloc_filter sloc (hxx); + + String guard (guard_expr.replace (guard_prefix + hxx_name)); + guard = ctx.escape (guard); // Make it a C++ id. + std::transform (guard.begin (), guard.end(), guard.begin (), upcase); + + hxx << "#ifndef " << guard << endl + << "#define " << guard << endl + << endl; + + if (ctx.std >= cxx_version::cxx11) + { + hxx << "#ifndef XSD_CXX11" << endl + << "#define XSD_CXX11" << endl + << "#endif" << endl + << endl; + } + + // Copy prologue. + // + hxx << "// Begin prologue." << endl + << "//" << endl; + + append (hxx, ops.hxx_prologue (), ops.prologue ()); + append (hxx, ops.hxx_prologue_file (), prologue); + + hxx << "//" << endl + << "// End prologue." << endl + << endl; + + // Version check. + // + hxx << "#include " << endl + << endl + << "#if (LIBXSD_VERSION != " << XSD_VERSION << "L)" << endl + << "#error XSD runtime version mismatch" << endl + << "#endif" << endl + << endl; + + hxx << "#include " << endl + << endl; + + // Generate. + // + { + ind_filter ind (hxx); // We don't want to indent prologues/epilogues. + + if (!generate_xml_schema) + generate_parser_forward (ctx); + + generate_parser_header (ctx, generate_xml_schema); + } + + if (inline_) + hxx << "#include " << ctx.process_include_path (ixx_name) << endl; + + hxx << "#include " << endl + << endl; + + // Copy epilogue. + // + hxx << "// Begin epilogue." << endl + << "//" << endl; + + append (hxx, ops.hxx_epilogue_file (), epilogue); + append (hxx, ops.hxx_epilogue (), ops.epilogue ()); + + hxx << "//" << endl + << "// End epilogue." << endl + << endl; + + hxx << "#endif // " << guard << endl; + + if (show_sloc) + wcerr << hxx_path << ": " << sloc.stream ().count () << endl; + + sloc_total += sloc.stream ().count (); + } + + + // IXX + // + if (inline_) + { + Context ctx (ixx, + schema, + file_path, + ops, + &string_literal_map, + &hxx_expr, + &ixx_expr, + &hxx_impl_expr); + + sloc_filter sloc (ixx); + + // Copy prologue. + // + ixx << "// Begin prologue." << endl + << "//" << endl; + + append (ixx, ops.ixx_prologue (), ops.prologue ()); + append (ixx, ops.ixx_prologue_file (), prologue); + + ixx << "//" << endl + << "// End prologue." << endl + << endl; + + // Generate. + // + { + ind_filter ind (ixx); // We don't want to indent prologues/epilogues. + generate_parser_inline (ctx); + } + + // Copy epilogue. + // + ixx << "// Begin epilogue." << endl + << "//" << endl; + + append (ixx, ops.ixx_epilogue_file (), epilogue); + append (ixx, ops.ixx_epilogue (), ops.epilogue ()); + + ixx << "//" << endl + << "// End epilogue." << endl + << endl; + + if (show_sloc) + wcerr << ixx_path << ": " << sloc.stream ().count () << endl; + + sloc_total += sloc.stream ().count (); + } + + + // CXX + // + if (source) + { + Context ctx (cxx, + schema, + file_path, + ops, + &string_literal_map, + &hxx_expr, + &ixx_expr, + &hxx_impl_expr); + + sloc_filter sloc (cxx); + + // Copy prologue. + // + cxx << "// Begin prologue." << endl + << "//" << endl; + + append (cxx, ops.cxx_prologue (), ops.prologue ()); + append (cxx, ops.cxx_prologue_file (), prologue); + + cxx << "//" << endl + << "// End prologue." << endl + << endl; + + cxx << "#include " << endl + << endl; + + cxx << "#include " << ctx.process_include_path (hxx_name) << endl + << endl; + + // Generate. + // + { + ind_filter ind (cxx); // We don't want to indent prologues/epilogues. + + if (!inline_) + generate_parser_inline (ctx); + + generate_parser_source (ctx); + + if (validation) + { + generate_element_validation_source (ctx); + generate_attribute_validation_source (ctx); + generate_characters_validation_source (ctx); + } + } + + cxx << "#include " << endl + << endl; + + // Copy epilogue. + // + cxx << "// Begin epilogue." << endl + << "//" << endl; + + append (cxx, ops.cxx_epilogue_file (), epilogue); + append (cxx, ops.cxx_epilogue (), ops.epilogue ()); + + cxx << "//" << endl + << "// End epilogue." << endl + << endl; + + if (show_sloc) + wcerr << cxx_path << ": " << sloc.stream ().count () << endl; + + sloc_total += sloc.stream ().count (); + } + + // HXX impl + // + if (impl) + { + Context ctx (hxx_impl, + schema, + file_path, + ops, + &string_literal_map, + &hxx_expr, + &ixx_expr, + &hxx_impl_expr); + + String guard (guard_expr.replace (guard_prefix + hxx_impl_name)); + guard = ctx.escape (guard); // Make it a C++ id. + std::transform (guard.begin (), guard.end(), guard.begin (), upcase); + + hxx_impl << "#ifndef " << guard << endl + << "#define " << guard << endl + << endl; + + hxx_impl << "#include " << ctx.process_include_path (hxx_name) + << endl << endl; + + { + ind_filter ind (hxx_impl); + generate_impl_header (ctx); + } + + hxx_impl << "#endif // " << guard << endl; + } + + // CXX impl + // + if (impl) + { + Context ctx (cxx_impl, + schema, + file_path, + ops, + &string_literal_map, + &hxx_expr, + &ixx_expr, + &hxx_impl_expr); + + cxx_impl << "#include " << ctx.process_include_path (hxx_impl_name) + << endl << endl; + + { + ind_filter ind (cxx_impl); + generate_impl_source (ctx); + } + } + + // CXX driver + // + if (driver) + { + Context ctx (cxx_driver, + schema, + file_path, + ops, + &string_literal_map, + &hxx_expr, + &ixx_expr, + &hxx_impl_expr); + + cxx_driver << "#include " << ctx.process_include_path (hxx_impl_name) + << endl << endl; + + { + ind_filter ind (cxx_driver); + generate_driver_source (ctx); + } + } + + return sloc_total; + } + catch (UnrepresentableCharacter const& e) + { + wcerr << "error: character at position " << e.position () << " " + << "in string '" << e.string () << "' is unrepresentable in " + << "the target encoding" << endl; + + wcerr << "info: use the --custom-literals option to provide custom " + << "string literals mapping" << endl; + + throw Failed (); + } + catch (NoNamespaceMapping const& e) + { + wcerr << e.file () << ":" << e.line () << ":" << e.column () + << ": error: unable to map XML Schema namespace '" << e.ns () + << "' to C++ namespace" << endl; + + wcerr << e.file () << ":" << e.line () << ":" << e.column () + << ": info: use the --namespace-map or --namespace-regex option " + << "to provide custom mapping" << endl; + + throw Failed (); + } + catch (InvalidNamespaceMapping const& e) + { + wcerr << "error: invalid XML to C++ namespace mapping specified: " + << "'" << e.mapping () << "': " << e.reason () << endl; + + throw Failed (); + } + catch (cutl::re::format const& e) + { + wcerr << "error: invalid regex: '" << + e.regex ().c_str () << "': " << + e.description ().c_str () << endl; + + throw Failed (); + } + catch (cutl::re::wformat const& e) + { + wcerr << "error: invalid regex: '" << + e.regex () << "': " << e.description ().c_str () << endl; + + throw Failed (); + } + } +} diff --git a/xsd/xsd/cxx/parser/generator.hxx b/xsd/xsd/cxx/parser/generator.hxx new file mode 100644 index 0000000..150cd74 --- /dev/null +++ b/xsd/xsd/cxx/parser/generator.hxx @@ -0,0 +1,45 @@ +// file : xsd/cxx/parser/generator.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_PARSER_GENERATOR_HXX +#define XSD_CXX_PARSER_GENERATOR_HXX + +#include // Path +#include + +#include +#include + +#include +#include + +namespace CXX +{ + namespace Parser + { + class Generator + { + public: + static void + usage (); + + struct Failed {}; + + static size_t + generate (options const&, + XSDFrontend::SemanticGraph::Schema&, + XSDFrontend::SemanticGraph::Path const& file, + bool file_per_type, + StringLiteralMap const&, + bool gen_driver, + const WarningSet& disabled_warnings, + FileList& file_list, + AutoUnlinks& unlinks); + + private: + Generator (); + }; + } +} + +#endif // XSD_CXX_PARSER_GENERATOR_HXX diff --git a/xsd/xsd/cxx/parser/impl-header.cxx b/xsd/xsd/cxx/parser/impl-header.cxx new file mode 100644 index 0000000..be14dfa --- /dev/null +++ b/xsd/xsd/cxx/parser/impl-header.cxx @@ -0,0 +1,232 @@ +// file : xsd/cxx/parser/impl-header.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include +#include + +namespace CXX +{ + namespace Parser + { + namespace + { + struct Enumeration: Traversal::Enumeration, Context + { + Enumeration (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& e) + { + String const& name (eimpl (e)); + String const& ret (ret_type (e)); + SemanticGraph::Type& base (e.inherits ().base ()); + + os << "class " << type_exp << name << ": " << + "public virtual " << ename (e) << "," << endl + << " public " << fq_name (base, "impl") + << "{" + << "public:" << endl + << "virtual void" << endl + << "pre ();" + << endl + << "virtual " << ret << endl + << post_name (e) << " ();" + << "};"; + } + }; + + // + // + struct List: Traversal::List, Context + { + List (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& l) + { + String const& name (eimpl (l)); + SemanticGraph::Type& t (l.argumented ().type ()); + + String item (unclash (ename (l), "item")); + + os << "class " << type_exp << name << ": public virtual " << + ename (l) + << "{" + << "public:" << endl + << "virtual void" << endl + << "pre ();" + << endl; + + // item + // + String const& arg (arg_type (t)); + + os << "virtual void" << endl + << item; + + if (arg == L"void") + os << " ();"; + else + os << " (" << arg << ");"; + + os << endl; + + // post + // + String const& ret (ret_type (l)); + + os << "virtual " << ret << endl + << post_name (l) << " ();" + << "};"; + } + }; + + struct Union: Traversal::Union, Context + { + Union (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& u) + { + String const& name (eimpl (u)); + String const& ret (ret_type (u)); + + os << "class " << type_exp << name << ": public virtual " << + ename (u) + << "{" + << "public:" << endl + << "virtual void" << endl + << "pre ();" + << endl + << "virtual void" << endl + << "_characters (const " << string_type << "&);" + << endl + << "virtual " << ret << endl + << post_name (u) << " ();" + << "};"; + } + }; + + + // + // + struct ParserCallback: Traversal::Member, Context + { + ParserCallback (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& m) + { + if (skip (m)) + return; + + String const& arg (arg_type (m.type ())); + + os << "virtual void" << endl + << ename (m); + + if (arg == L"void") + os << " ();"; + else + os << " (" << arg << ");"; + + os << endl; + } + }; + + // + // + struct Complex: Traversal::Complex, Context + { + Complex (Context& c) + : Context (c), + parser_callback_ (c) + { + names_parser_callback_ >> parser_callback_; + } + + virtual void + traverse (Type& c) + { + String const& name (eimpl (c)); + String const& ret (ret_type (c)); + + os << "class " << type_exp << name << ": public virtual " << + ename (c); + + if (c.inherits_p ()) + os << "," << endl + << " public " << fq_name (c.inherits ().base (), "impl"); + + os << "{" + << "public:" << endl + << "virtual void" << endl + << "pre ();" + << endl; + + // In case of an inheritance-by-restriction, we don't need to + // generate parser callbacks, etc. since they are the same as in + // the base. + // + if (!restriction_p (c)) + { + names (c, names_parser_callback_); + } + + os << "virtual " << ret << endl + << post_name (c) << " ();" + << "};"; + } + + private: + // + // + ParserCallback parser_callback_; + Traversal::Names names_parser_callback_; + }; + } + + void + generate_impl_header (Context& ctx) + { + Traversal::Schema schema; + + Sources sources; + Includes includes (ctx, Includes::impl_header); + Traversal::Names schema_names; + + Namespace ns (ctx); + Traversal::Names names; + + schema >> includes; + schema >> sources >> schema; + schema >> schema_names >> ns >> names; + + List list (ctx); + Union union_ (ctx); + Complex complex (ctx); + Enumeration enumeration (ctx); + + names >> list; + names >> union_; + names >> complex; + names >> enumeration; + + schema.dispatch (ctx.schema_root); + } + } +} diff --git a/xsd/xsd/cxx/parser/impl-header.hxx b/xsd/xsd/cxx/parser/impl-header.hxx new file mode 100644 index 0000000..1939e05 --- /dev/null +++ b/xsd/xsd/cxx/parser/impl-header.hxx @@ -0,0 +1,18 @@ +// file : xsd/cxx/parser/impl-header.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_PARSER_IMPL_HEADER_HXX +#define XSD_CXX_PARSER_IMPL_HEADER_HXX + +#include + +namespace CXX +{ + namespace Parser + { + void + generate_impl_header (Context&); + } +} + +#endif // XSD_CXX_PARSER_IMPL_HEADER_HXX diff --git a/xsd/xsd/cxx/parser/impl-source.cxx b/xsd/xsd/cxx/parser/impl-source.cxx new file mode 100644 index 0000000..80a9644 --- /dev/null +++ b/xsd/xsd/cxx/parser/impl-source.cxx @@ -0,0 +1,384 @@ +// file : xsd/cxx/parser/impl-source.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include + +#include +#include + +namespace CXX +{ + namespace Parser + { + namespace + { + struct Enumeration: Traversal::Enumeration, Context + { + Enumeration (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& e) + { + String const& name (eimpl (e)); + String const& ret (ret_type (e)); + SemanticGraph::Type& base (e.inherits ().base ()); + String const& base_ret (ret_type (base)); + + os << "// " << name << endl + << "//" << endl + << endl; + + // pre + // + os << "void " << name << "::" << endl + << "pre ()" + << "{" + << "}"; + + // post + // + os << ret << " " << name << "::" << endl + << post_name (e) << " ()" + << "{"; + + if (ret == base_ret) + { + os << (ret != L"void" ? "return " : "") << + post_name (base) << " ();"; + } + else if (ret == L"void") + { + os << arg_type (base) << " v (" << post_name (base) << " ());" + << endl; + + if (options.generate_print_impl ()) + { + PrintCall t (*this, e.name (), "v"); + t.dispatch (base); + } + else + os << "// TODO" << endl + << "//" << endl; + } + else + { + if (base_ret == L"void") + os << post_name (base) << " ();"; + else + os << arg_type (base) << " v (" << post_name (base) << " ());" + << endl + << "// TODO" << endl + << "//" << endl + << "// return ... ;" << endl; + } + + os << "}"; + } + }; + + // + // + struct List: Traversal::List, Context + { + List (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& l) + { + String const& name (eimpl (l)); + SemanticGraph::Type& type (l.argumented ().type ()); + + String item (unclash (ename (l), "item")); + + os << "// " << name << endl + << "//" << endl + << endl; + + // pre + // + os << "void " << name << "::" << endl + << "pre ()" + << "{" + << "}"; + + // item + // + String const& arg (arg_type (type)); + + os << "void " << name << "::" << endl + << item; + + if (arg == L"void") + os << " ()"; + else + os << " (" << arg << " " << item << ")"; + + os << "{"; + + if (arg != L"void") + { + if (options.generate_print_impl ()) + { + PrintCall t (*this, type.name (), item); + t.dispatch (type); + } + else + os << "// TODO" << endl + << "//" << endl; + } + + os << "}"; + + // post + // + String const& ret (ret_type (l)); + + os << ret << " " << name << "::" << endl + << post_name (l) << " ()" + << "{"; + + if (ret != L"void") + os << "// TODO" << endl + << "//" << endl + << "// return ... ;" << endl; + + os << "}"; + } + }; + + // + // + struct Union: Traversal::Union, Context + { + Union (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& u) + { + String const& name (eimpl (u)); + + os << "// " << name << endl + << "//" << endl + << endl; + + // pre + // + os << "void " << name << "::" << endl + << "pre ()" + << "{" + << "}"; + + // _characters + // + os << "void " << name << "::" << endl + << "_characters (const " << string_type << "& s)" + << "{"; + + if (options.generate_print_impl ()) + os << cout_inst << " << " << strlit (u.name () + L": ") << + " << s << std::endl;"; + else + os << "// TODO" << endl + << "//" << endl; + + os << "}"; + + // post + // + String const& ret (ret_type (u)); + + os << ret << " " << name << "::" << endl + << post_name (u) << " ()" + << "{"; + + if (ret != L"void") + os << "// TODO" << endl + << "//" << endl + << "// return ... ;" << endl; + + os << "}"; + } + }; + + // + // + struct ParserCallback: Traversal::Member, Context + { + ParserCallback (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& m) + { + if (skip (m)) + return; + + String const& name (ename (m)); + String const& arg (arg_type (m.type ())); + + os << "void " << + eimpl (dynamic_cast (m.scope ())) << + "::" << endl + << name; + + if (arg == L"void") + os << " ()"; + else + os << " (" << arg << " " << name << ")"; + + os << "{"; + + if (arg != L"void") + { + if (options.generate_print_impl ()) + { + PrintCall t (*this, m.name (), name); + t.dispatch (m.type ()); + } + else + os << "// TODO" << endl + << "//" << endl; + } + + os << "}"; + } + }; + + // + // + struct Complex: Traversal::Complex, Context + { + Complex (Context& c) + : Context (c), parser_callback_ (c) + { + names_parser_callback_ >> parser_callback_; + } + + virtual void + traverse (Type& c) + { + String const& name (eimpl (c)); + + bool restriction (restriction_p (c)); + + os << "// " << name << endl + << "//" << endl + << endl; + + // pre + // + os << "void " << name << "::" << endl + << "pre ()" + << "{" + << "}"; + + // Parser callbacks. + // + if (!restriction) + names (c, names_parser_callback_); + + // post + // + String const& ret (ret_type (c)); + + os << ret << " " << name << "::" << endl + << post_name (c) << " ()" + << "{"; + + if (c.inherits_p ()) + { + SemanticGraph::Type& base (c.inherits ().base ()); + String const& base_ret (ret_type (base)); + + if (ret == base_ret) + { + os << (ret != L"void" ? "return " : "") << + post_name (base) << " ();"; + } + else if (ret == L"void") + { + os << arg_type (base) << " v (" << post_name (base) << " ());" + << endl; + + if (options.generate_print_impl ()) + { + PrintCall t (*this, c.name (), "v"); + t.dispatch (base); + } + else + os << "// TODO" << endl + << "//" << endl; + } + else + { + if (base_ret == L"void") + os << post_name (base) << " ();"; + else + os << arg_type (base) << " v (" << post_name (base) << " ());" + << endl + << "// TODO" << endl + << "//" << endl + << "// return ... ;" << endl; + } + } + else + { + if (ret != L"void") + os << "// TODO" << endl + << "//" << endl + << "// return ... ;" << endl; + } + + os << "}"; + } + + private: + // + // + ParserCallback parser_callback_; + Traversal::Names names_parser_callback_; + }; + } + + void + generate_impl_source (Context& ctx) + { + if (ctx.options.generate_print_impl ()) + ctx.os << "#include " << endl + << endl; + + Traversal::Schema schema; + Sources sources; + Traversal::Names schema_names; + Namespace ns (ctx); + Traversal::Names names; + + schema >> sources >> schema; + schema >> schema_names >> ns >> names; + + List list (ctx); + Union union_ (ctx); + Complex complex (ctx); + Enumeration enumeration (ctx); + + names >> list; + names >> union_; + names >> complex; + names >> enumeration; + + schema.dispatch (ctx.schema_root); + } + } +} diff --git a/xsd/xsd/cxx/parser/impl-source.hxx b/xsd/xsd/cxx/parser/impl-source.hxx new file mode 100644 index 0000000..0fc8060 --- /dev/null +++ b/xsd/xsd/cxx/parser/impl-source.hxx @@ -0,0 +1,18 @@ +// file : xsd/cxx/parser/impl-source.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_PARSER_IMPL_SOURCE_HXX +#define XSD_CXX_PARSER_IMPL_SOURCE_HXX + +#include + +namespace CXX +{ + namespace Parser + { + void + generate_impl_source (Context&); + } +} + +#endif // XSD_CXX_PARSER_IMPL_SOURCE_HXX diff --git a/xsd/xsd/cxx/parser/name-processor.cxx b/xsd/xsd/cxx/parser/name-processor.cxx new file mode 100644 index 0000000..73710ba --- /dev/null +++ b/xsd/xsd/cxx/parser/name-processor.cxx @@ -0,0 +1,1175 @@ +// file : xsd/cxx/parser/name-processor.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include +#include +#include + +#include + +#include +#include + + +using namespace std; + +namespace CXX +{ + namespace Parser + { + namespace + { + // + // + typedef set NameSet; + + class Context: public CXX::Context + { + public: + Context (Parser::options const& ops, + SemanticGraph::Schema& root, + SemanticGraph::Path const& path, + StringLiteralMap const* map) + : CXX::Context (std::wcerr, root, path, ops, map), + skel_suffix_ (ops.skel_type_suffix ()), + impl_suffix_ (ops.impl_type_suffix ()), + impl (ops.generate_noop_impl () || + ops.generate_print_impl () || + ops.generate_test_driver ()), + skel_suffix (skel_suffix_), + impl_suffix (impl_suffix_), + global_type_names (global_type_names_), + polymorphic (ops.generate_polymorphic ()) + { + } + + protected: + Context (Context& c) + : CXX::Context (c), + impl (c.impl), + skel_suffix (c.skel_suffix), + impl_suffix (c.impl_suffix), + global_type_names (c.global_type_names), + polymorphic (c.polymorphic) + { + } + + public: + String + find_name (String const& n, NameSet& set) + { + String base_name (escape (n)); + String name (base_name); + + for (size_t i (1); set.find (name) != set.end (); ++i) + { + std::wostringstream os; + os << i; + name = base_name + os.str (); + } + + set.insert (name); + return name; + } + + private: + String const skel_suffix_; + String const impl_suffix_; + + map global_type_names_; + + public: + bool const impl; + String const& skel_suffix; + String const& impl_suffix; + + map& global_type_names; + + bool polymorphic; + }; + + + // + // + struct PrimaryMember: Traversal::Member, Context + { + PrimaryMember (Context& c, NameSet& set) + : Context (c), set_ (set) + { + } + + virtual void + traverse (Type& m) + { + if (Parser::Context::skip (m)) + return; + + m.context ().set ("name", find_name (m.name (), set_)); + } + + private: + NameSet& set_; + }; + + struct DerivedMember: Traversal::Member, Context + { + DerivedMember (Context& c, NameSet& set) + : Context (c), set_ (set) + { + } + + virtual void + traverse (Type& m) + { + if (Parser::Context::skip (m)) + return; + + m.context ().set ("parser", + find_name (m.name () + L"_parser", set_)); + + String const& base (m.context ().get ("name")); + m.context ().set ("member", find_name (base + L"_parser_", set_)); + + if (polymorphic && + m.is_a () && + !m.type ().context ().count ("anonymous")) + { + m.context ().set ( + "member-map", find_name (base + L"_parser_map_", set_)); + + m.context ().set ( + "member-map-impl", + find_name (base + L"_parser_map_impl_", set_)); + } + } + + private: + NameSet& set_; + }; + + + // + // + struct MemberInRestrictionBase: Traversal::Member + { + protected: + MemberInRestrictionBase (NameSet& set, SemanticGraph::Complex& base) + : set_ (set), base_ (base) + { + } + + struct NotFound {}; + + Type& + find_member (SemanticGraph::Complex& c, Type& m) + { + using SemanticGraph::Complex; + + Complex::NamesIteratorPair r (c.find (m.name ())); + + for (; r.first != r.second; ++r.first) + { + if (r.first->named ().is_a ()) + { + Type& bm (dynamic_cast (r.first->named ())); + + if (typeid (bm) != typeid (m)) + continue; + + if (m.qualified_p ()) + { + if (bm.qualified_p () && + m.name () == bm.name () && + m.namespace_ ().name () == bm.namespace_ ().name ()) + return bm; + } + else + { + if (!bm.qualified_p () && m.name () == bm.name ()) + return bm; + } + } + } + + // If we didn't find anything, try our base. + // + if (c.inherits_p ()) + { + SemanticGraph::Type& base (c.inherits ().base ()); + + if (base.is_a ()) + return find_member (dynamic_cast (base), m); + } + + //std::wcerr << "unable to find member " << m.name () << " in " + // << c.name () << std::endl; + + throw NotFound (); + } + + protected: + NameSet& set_; + SemanticGraph::Complex& base_; + }; + + struct PrimaryMemberInRestriction: MemberInRestrictionBase, Context + { + PrimaryMemberInRestriction (Context& c, + NameSet& set, + SemanticGraph::Complex& base) + : MemberInRestrictionBase (set, base), Context (c) + { + } + + virtual void + traverse (Type& m) + { + if (Parser::Context::skip (m)) + return; + + String name; + + try + { + // Try to find corresponding member in one of our bases. + // This may fail if we use an element that substitutes + // one in our base. + // + Type& bm (find_member (base_, m)); + name = bm.context ().get ("name"); + } + catch (NotFound const&) + { + // Fall back to the standard name assignment. + // + name = find_name (m.name (), set_); + } + + m.context ().set ("name", name); + } + }; + + struct DerivedMemberInRestriction: MemberInRestrictionBase, Context + { + DerivedMemberInRestriction (Context& c, + NameSet& set, + SemanticGraph::Complex& base) + : MemberInRestrictionBase (set, base), Context (c) + { + } + + virtual void + traverse (Type& m) + { + if (Parser::Context::skip (m)) + return; + + bool poly (polymorphic && + m.is_a () && + !m.type ().context ().count ("anonymous")); + + String parser, member, member_map, member_map_impl; + + try + { + // Try to find corresponding member in one of our bases. + // This may fail if we use an element that substitutes + // one in our base. + // + Type& bm (find_member (base_, m)); + parser = bm.context ().get ("parser"); + member = bm.context ().get ("member"); + + if (poly) + { + member_map = bm.context ().get ("member-map"); + member_map_impl = bm.context ().get ("member-map-impl"); + } + } + catch (NotFound const&) + { + // Fall back to the standard name assignment. + // + String const& base (m.context ().get ("name")); + + parser = find_name (m.name () + L"_parser", set_); + member = find_name (base + L"_parser_", set_); + + if (poly) + { + member_map = find_name (base + L"_parser_map_", set_); + member_map_impl = find_name (base + L"_parser_map_impl_", set_); + } + } + + m.context ().set ("parser", parser); + m.context ().set ("member", member); + + if (poly) + { + m.context ().set ("member-map", member_map); + m.context ().set ("member-map-impl", member_map_impl); + } + } + }; + + // + // + struct Complex: Traversal::Complex, Context + { + Complex (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& c) + { + SemanticGraph::Context& cc (c.context ()); + + // Use processed name. + // + String const& name (cc.get ("name")); + + // We leave this set around to allow other mappings to use + // this information. + // + cc.set ("cxx-parser-name-processor-member-set", NameSet ()); + NameSet& member_set ( + cc.get ("cxx-parser-name-processor-member-set")); + + member_set.insert (name); + + // Add our base's members to the initial list unless we are + // inheriting by restriction in which case we need to have + // the same names as our base. + // + bool restriction (false); + + if (c.inherits_p ()) + { + // @@ What if this types name is the same as one of base's + // members? + // + SemanticGraph::Type& base (c.inherits ().base ()); + + if (base.is_a ()) + { + if (!base.context ().count ( + "cxx-parser-name-processor-member-set")) + { + dispatch (base); + } + + NameSet const& base_set ( + base.context ().get ( + "cxx-parser-name-processor-member-set")); + + member_set.insert (base_set.begin (), base_set.end ()); + + // Inheritance by restriction from anyType is a special case. + // + restriction = c.inherits ().is_a () && + !c.inherits ().base ().is_a (); + } + } + + if (restriction) + { + // First assign the "primary" names. + // + { + PrimaryMemberInRestriction member ( + *this, + member_set, + dynamic_cast ( + c.inherits ().base ())); + + Traversal::Names names (member); + + Complex::names (c, names); + } + + // Assign "derived" names. + // + { + DerivedMemberInRestriction member ( + *this, + member_set, + dynamic_cast ( + c.inherits ().base ())); + + Traversal::Names names (member); + + Complex::names (c, names); + } + } + else + { + // First assign the "primary" names. + // + { + PrimaryMember member (*this, member_set); + Traversal::Names names (member); + + Complex::names (c, names); + } + + // Assign "derived" names. + // + { + DerivedMember member (*this, member_set); + Traversal::Names names (member); + + Complex::names (c, names); + } + } + } + }; + + + // + // + struct GlobalType: Traversal::Type, Context + { + GlobalType (Context& c, NameSet& set) + : Context (c), set_ (set) + { + } + + virtual void + traverse (SemanticGraph::Type& t) + { + SemanticGraph::Context& c (t.context ()); + String const& n (t.name ()); + + String name (find_name (n + skel_suffix, set_)); + c.set ("name", name); + + // Assign the post_* name. + // + c.set ("post", find_post_name (t)); + + // Note that we do not add this name to the set so that it + // does not influence other names. + // + if (impl) + c.set ("impl", escape (n + impl_suffix)); + } + + private: + String + find_post_name (SemanticGraph::Type& t) + { + String const& n (t.name ()); + + // It is possible that our base has the same type name (just + // in a different namespaces). Avoid name clash in this case. + // + using SemanticGraph::Complex; + + Complex* c = dynamic_cast (&t); + + if (c == 0 || !c->inherits_p ()) + { + return escape (L"post_" + n); + } + else + { + NameSet set; + + // Collect all base's post_*. In some mutual inclusion cases it + // is possible that our base won't have the post name assigned + // yet. In this situation will will have to figure it out + // ourselves (we can do it since we use the "raw" type name). + // + SemanticGraph::Type* b (&c->inherits ().base ()); + + while (true) + { + if (b->context ().count ("post")) + set.insert (b->context ().get ("post")); + else + set.insert (find_post_name (*b)); + + Complex* cb (dynamic_cast (b)); + + if (cb != 0 && cb->inherits_p ()) + { + b = &cb->inherits ().base (); + continue; + } + + break; + } + + String base_name (escape (L"post_" + n)); + String post (base_name); + + for (size_t i (1); set.find (post) != set.end (); ++i) + { + std::wostringstream os; + os << i; + post = base_name + os.str (); + } + + return post; + } + } + + private: + NameSet& set_; + }; + + + struct Namespace: Traversal::Namespace, Context + { + Namespace (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& ns) + { + NameSet& type_set (global_type_names[ns.name ()]); + + GlobalType type (*this, type_set); + Traversal::Names names (type); + + Traversal::Namespace::names (ns, names); + } + }; + + + struct FundType: Traversal::AnyType, + Traversal::AnySimpleType, + + Traversal::Fundamental::Byte, + Traversal::Fundamental::UnsignedByte, + Traversal::Fundamental::Short, + Traversal::Fundamental::UnsignedShort, + Traversal::Fundamental::Int, + Traversal::Fundamental::UnsignedInt, + Traversal::Fundamental::Long, + Traversal::Fundamental::UnsignedLong, + Traversal::Fundamental::Integer, + Traversal::Fundamental::NonPositiveInteger, + Traversal::Fundamental::NonNegativeInteger, + Traversal::Fundamental::PositiveInteger, + Traversal::Fundamental::NegativeInteger, + + Traversal::Fundamental::Boolean, + + Traversal::Fundamental::Float, + Traversal::Fundamental::Double, + Traversal::Fundamental::Decimal, + + Traversal::Fundamental::String, + Traversal::Fundamental::NormalizedString, + Traversal::Fundamental::Token, + Traversal::Fundamental::Name, + Traversal::Fundamental::NameToken, + Traversal::Fundamental::NameTokens, + Traversal::Fundamental::NCName, + Traversal::Fundamental::Language, + + Traversal::Fundamental::QName, + + Traversal::Fundamental::Id, + Traversal::Fundamental::IdRef, + Traversal::Fundamental::IdRefs, + + Traversal::Fundamental::AnyURI, + + Traversal::Fundamental::Base64Binary, + Traversal::Fundamental::HexBinary, + + Traversal::Fundamental::Date, + Traversal::Fundamental::DateTime, + Traversal::Fundamental::Duration, + Traversal::Fundamental::Day, + Traversal::Fundamental::Month, + Traversal::Fundamental::MonthDay, + Traversal::Fundamental::Year, + Traversal::Fundamental::YearMonth, + Traversal::Fundamental::Time, + + Traversal::Fundamental::Entity, + Traversal::Fundamental::Entities, + + Context + { + FundType (Context& c) + : Context (c) + { + } + + // anyType & anySimpleType. + // + virtual void + traverse (SemanticGraph::AnyType& t) + { + t.context ().set ("name", make_skel_name ("any_type")); + t.context ().set ("impl", make_impl_name ("any_type")); + t.context ().set ("post", String ("post_any_type")); + } + + virtual void + traverse (SemanticGraph::AnySimpleType& t) + { + t.context ().set ("name", make_skel_name ("any_simple_type")); + t.context ().set ("impl", make_impl_name ("any_simple_type")); + t.context ().set ("post", String ("post_any_simple_type")); + } + + // Boolean. + // + virtual void + traverse (SemanticGraph::Fundamental::Boolean& t) + { + t.context ().set ("name", make_skel_name ("boolean")); + t.context ().set ("impl", make_impl_name ("boolean")); + t.context ().set ("post", String ("post_boolean")); + } + + // Integral types. + // + virtual void + traverse (SemanticGraph::Fundamental::Byte& t) + { + t.context ().set ("name", make_skel_name ("byte")); + t.context ().set ("impl", make_impl_name ("byte")); + t.context ().set ("post", String ("post_byte")); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedByte& t) + { + t.context ().set ("name", make_skel_name ("unsigned_byte")); + t.context ().set ("impl", make_impl_name ("unsigned_byte")); + t.context ().set ("post", String ("post_unsigned_byte")); + } + + virtual void + traverse (SemanticGraph::Fundamental::Short& t) + { + t.context ().set ("name", make_skel_name ("short")); + t.context ().set ("impl", make_impl_name ("short")); + t.context ().set ("post", String ("post_short")); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedShort& t) + { + t.context ().set ("name", make_skel_name ("unsigned_short")); + t.context ().set ("impl", make_impl_name ("unsigned_short")); + t.context ().set ("post", String ("post_unsigned_short")); + } + + virtual void + traverse (SemanticGraph::Fundamental::Int& t) + { + t.context ().set ("name", make_skel_name ("int")); + t.context ().set ("impl", make_impl_name ("int")); + t.context ().set ("post", String ("post_int")); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedInt& t) + { + t.context ().set ("name", make_skel_name ("unsigned_int")); + t.context ().set ("impl", make_impl_name ("unsigned_int")); + t.context ().set ("post", String ("post_unsigned_int")); + } + + virtual void + traverse (SemanticGraph::Fundamental::Long& t) + { + t.context ().set ("name", make_skel_name ("long")); + t.context ().set ("impl", make_impl_name ("long")); + t.context ().set ("post", String ("post_long")); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedLong& t) + { + t.context ().set ("name", make_skel_name ("unsigned_long")); + t.context ().set ("impl", make_impl_name ("unsigned_long")); + t.context ().set ("post", String ("post_unsigned_long")); + } + + virtual void + traverse (SemanticGraph::Fundamental::Integer& t) + { + t.context ().set ("name", make_skel_name ("integer")); + t.context ().set ("impl", make_impl_name ("integer")); + t.context ().set ("post", String ("post_integer")); + } + + virtual void + traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) + { + t.context ().set ("name", make_skel_name ("non_positive_integer")); + t.context ().set ("impl", make_impl_name ("non_positive_integer")); + t.context ().set ("post", String ("post_non_positive_integer")); + } + + virtual void + traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) + { + t.context ().set ("name", make_skel_name ("non_negative_integer")); + t.context ().set ("impl", make_impl_name ("non_negative_integer")); + t.context ().set ("post", String ("post_non_negative_integer")); + } + + virtual void + traverse (SemanticGraph::Fundamental::PositiveInteger& t) + { + t.context ().set ("name", make_skel_name ("positive_integer")); + t.context ().set ("impl", make_impl_name ("positive_integer")); + t.context ().set ("post", String ("post_positive_integer")); + } + + virtual void + traverse (SemanticGraph::Fundamental::NegativeInteger& t) + { + t.context ().set ("name", make_skel_name ("negative_integer")); + t.context ().set ("impl", make_impl_name ("negative_integer")); + t.context ().set ("post", String ("post_negative_integer")); + } + + // Floats. + // + virtual void + traverse (SemanticGraph::Fundamental::Float& t) + { + t.context ().set ("name", make_skel_name ("float")); + t.context ().set ("impl", make_impl_name ("float")); + t.context ().set ("post", String ("post_float")); + } + + virtual void + traverse (SemanticGraph::Fundamental::Double& t) + { + t.context ().set ("name", make_skel_name ("double")); + t.context ().set ("impl", make_impl_name ("double")); + t.context ().set ("post", String ("post_double")); + } + + virtual void + traverse (SemanticGraph::Fundamental::Decimal& t) + { + t.context ().set ("name", make_skel_name ("decimal")); + t.context ().set ("impl", make_impl_name ("decimal")); + t.context ().set ("post", String ("post_decimal")); + } + + // Strings. + // + virtual void + traverse (SemanticGraph::Fundamental::String& t) + { + t.context ().set ("name", make_skel_name ("string")); + t.context ().set ("impl", make_impl_name ("string")); + t.context ().set ("post", String ("post_string")); + } + + virtual void + traverse (SemanticGraph::Fundamental::NormalizedString& t) + { + t.context ().set ("name", make_skel_name ("normalized_string")); + t.context ().set ("impl", make_impl_name ("normalized_string")); + t.context ().set ("post", String ("post_normalized_string")); + } + + virtual void + traverse (SemanticGraph::Fundamental::Token& t) + { + t.context ().set ("name", make_skel_name ("token")); + t.context ().set ("impl", make_impl_name ("token")); + t.context ().set ("post", String ("post_token")); + } + + virtual void + traverse (SemanticGraph::Fundamental::NameToken& t) + { + t.context ().set ("name", make_skel_name ("nmtoken")); + t.context ().set ("impl", make_impl_name ("nmtoken")); + t.context ().set ("post", String ("post_nmtoken")); + } + + virtual void + traverse (SemanticGraph::Fundamental::NameTokens& t) + { + t.context ().set ("name", make_skel_name ("nmtokens")); + t.context ().set ("impl", make_impl_name ("nmtokens")); + t.context ().set ("post", String ("post_nmtokens")); + } + + virtual void + traverse (SemanticGraph::Fundamental::Name& t) + { + t.context ().set ("name", make_skel_name ("name")); + t.context ().set ("impl", make_impl_name ("name")); + t.context ().set ("post", String ("post_name")); + } + + virtual void + traverse (SemanticGraph::Fundamental::NCName& t) + { + t.context ().set ("name", make_skel_name ("ncname")); + t.context ().set ("impl", make_impl_name ("ncname")); + t.context ().set ("post", String ("post_ncname")); + } + + virtual void + traverse (SemanticGraph::Fundamental::Language& t) + { + t.context ().set ("name", make_skel_name ("language")); + t.context ().set ("impl", make_impl_name ("language")); + t.context ().set ("post", String ("post_language")); + } + + + // Qualified name. + // + virtual void + traverse (SemanticGraph::Fundamental::QName& t) + { + t.context ().set ("name", make_skel_name ("qname")); + t.context ().set ("impl", make_impl_name ("qname")); + t.context ().set ("post", String ("post_qname")); + } + + + // ID/IDREF. + // + virtual void + traverse (SemanticGraph::Fundamental::Id& t) + { + t.context ().set ("name", make_skel_name ("id")); + t.context ().set ("impl", make_impl_name ("id")); + t.context ().set ("post", String ("post_id")); + } + + virtual void + traverse (SemanticGraph::Fundamental::IdRef& t) + { + t.context ().set ("name", make_skel_name ("idref")); + t.context ().set ("impl", make_impl_name ("idref")); + t.context ().set ("post", String ("post_idref")); + } + + virtual void + traverse (SemanticGraph::Fundamental::IdRefs& t) + { + t.context ().set ("name", make_skel_name ("idrefs")); + t.context ().set ("impl", make_impl_name ("idrefs")); + t.context ().set ("post", String ("post_idrefs")); + } + + // URI. + // + virtual void + traverse (SemanticGraph::Fundamental::AnyURI& t) + { + t.context ().set ("name", make_skel_name ("uri")); + t.context ().set ("impl", make_impl_name ("uri")); + t.context ().set ("post", String ("post_uri")); + } + + // Binary. + // + virtual void + traverse (SemanticGraph::Fundamental::Base64Binary& t) + { + t.context ().set ("name", make_skel_name ("base64_binary")); + t.context ().set ("impl", make_impl_name ("base64_binary")); + t.context ().set ("post", String ("post_base64_binary")); + } + + virtual void + traverse (SemanticGraph::Fundamental::HexBinary& t) + { + t.context ().set ("name", make_skel_name ("hex_binary")); + t.context ().set ("impl", make_impl_name ("hex_binary")); + t.context ().set ("post", String ("post_hex_binary")); + } + + + // Date/time. + // + virtual void + traverse (SemanticGraph::Fundamental::Date& t) + { + t.context ().set ("name", make_skel_name ("date")); + t.context ().set ("impl", make_impl_name ("date")); + t.context ().set ("post", String ("post_date")); + } + + virtual void + traverse (SemanticGraph::Fundamental::DateTime& t) + { + t.context ().set ("name", make_skel_name ("date_time")); + t.context ().set ("impl", make_impl_name ("date_time")); + t.context ().set ("post", String ("post_date_time")); + } + + virtual void + traverse (SemanticGraph::Fundamental::Duration& t) + { + t.context ().set ("name", make_skel_name ("duration")); + t.context ().set ("impl", make_impl_name ("duration")); + t.context ().set ("post", String ("post_duration")); + } + + virtual void + traverse (SemanticGraph::Fundamental::Day& t) + { + t.context ().set ("name", make_skel_name ("gday")); + t.context ().set ("impl", make_impl_name ("gday")); + t.context ().set ("post", String ("post_gday")); + } + + virtual void + traverse (SemanticGraph::Fundamental::Month& t) + { + t.context ().set ("name", make_skel_name ("gmonth")); + t.context ().set ("impl", make_impl_name ("gmonth")); + t.context ().set ("post", String ("post_gmonth")); + } + + virtual void + traverse (SemanticGraph::Fundamental::MonthDay& t) + { + t.context ().set ("name", make_skel_name ("gmonth_day")); + t.context ().set ("impl", make_impl_name ("gmonth_day")); + t.context ().set ("post", String ("post_gmonth_day")); + } + + virtual void + traverse (SemanticGraph::Fundamental::Year& t) + { + t.context ().set ("name", make_skel_name ("gyear")); + t.context ().set ("impl", make_impl_name ("gyear")); + t.context ().set ("post", String ("post_gyear")); + } + + virtual void + traverse (SemanticGraph::Fundamental::YearMonth& t) + { + t.context ().set ("name", make_skel_name ("gyear_month")); + t.context ().set ("impl", make_impl_name ("gyear_month")); + t.context ().set ("post", String ("post_gyear_month")); + } + + virtual void + traverse (SemanticGraph::Fundamental::Time& t) + { + t.context ().set ("name", make_skel_name ("time")); + t.context ().set ("impl", make_impl_name ("time")); + t.context ().set ("post", String ("post_time")); + } + + // Entity. + // + virtual void + traverse (SemanticGraph::Fundamental::Entity& t) + { + t.context ().set ("name", make_skel_name ("entity")); + t.context ().set ("impl", make_impl_name ("entity")); + t.context ().set ("post", String ("post_entity")); + } + + virtual void + traverse (SemanticGraph::Fundamental::Entities& t) + { + t.context ().set ("name", make_skel_name ("entities")); + t.context ().set ("impl", make_impl_name ("entities")); + t.context ().set ("post", String ("post_entities")); + } + + private: + String + make_skel_name (String const& base) + { + return escape (base + skel_suffix); + } + + String + make_impl_name (String const& base) + { + return escape (base + impl_suffix); + } + }; + + // Go into sourced/included/imported schemas while making sure + // we don't process the same stuff more than once. + // + struct Uses: Traversal::Sources, + Traversal::Includes, + Traversal::Imports + { + virtual void + traverse (SemanticGraph::Sources& sr) + { + SemanticGraph::Schema& s (sr.schema ()); + + if (!s.context ().count ("cxx-parser-name-processor-seen")) + { + s.context ().set ("cxx-parser-name-processor-seen", true); + Traversal::Sources::traverse (sr); + } + } + + virtual void + traverse (SemanticGraph::Includes& i) + { + SemanticGraph::Schema& s (i.schema ()); + + if (!s.context ().count ("cxx-parser-name-processor-seen")) + { + s.context ().set ("cxx-parser-name-processor-seen", true); + Traversal::Includes::traverse (i); + } + } + + virtual void + traverse (SemanticGraph::Imports& i) + { + SemanticGraph::Schema& s (i.schema ()); + + if (!s.context ().count ("cxx-parser-name-processor-seen")) + { + s.context ().set ("cxx-parser-name-processor-seen", true); + Traversal::Imports::traverse (i); + } + } + }; + + // Go into implied schemas while making sure we don't process + // the same stuff more than once. + // + struct Implies: Traversal::Implies + { + virtual void + traverse (SemanticGraph::Implies& i) + { + SemanticGraph::Schema& s (i.schema ()); + + if (!s.context ().count ("cxx-parser-name-processor-seen")) + { + s.context ().set ("cxx-parser-name-processor-seen", true); + Traversal::Implies::traverse (i); + } + } + }; + + void + process_impl (options const& ops, + SemanticGraph::Schema& tu, + SemanticGraph::Path const& file, + StringLiteralMap const& map) + { + Context ctx (ops, tu, file, &map); + + if (tu.names_begin ()->named ().name () == + L"http://www.w3.org/2001/XMLSchema") + { + // XML Schema namespace. + // + Traversal::Schema schema; + + Traversal::Names schema_names; + Traversal::Namespace ns; + Traversal::Names ns_names; + FundType fund_type (ctx); + + schema >> schema_names >> ns >> ns_names >> fund_type; + + schema.dispatch (tu); + } + else + { + + // Pass one - assign names to fundamental types. + // + { + Traversal::Schema schema; + Implies implies; + Traversal::Schema xs_schema; + + schema >> implies >> xs_schema; + + Traversal::Names xs_schema_names; + Traversal::Namespace ns; + Traversal::Names ns_names; + FundType fund_type (ctx); + + xs_schema >> xs_schema_names >> ns >> ns_names >> fund_type; + + schema.dispatch (tu); + } + + // Pass two - assign names to global types. This pass cannot + // be combined with pass three because of possible recursive + // schema inclusions. Also note that we check first if this + // schema has already been processed which may happen in the + // file-per-type compilation mode. + // + if (!tu.context ().count ("cxx-parser-name-processor-seen")) + { + Traversal::Schema schema; + Uses uses; + + schema >> uses >> schema; + + Traversal::Names schema_names; + Namespace ns (ctx); + + schema >> schema_names >> ns; + + // Some twisted schemas do recusive self-inclusion. + // + tu.context ().set ("cxx-parser-name-processor-seen", true); + + schema.dispatch (tu); + } + + // Pass three - assign names inside complex types. Here we don't + // need to go into included/imported schemas. + // + { + Traversal::Schema schema; + Sources sources; + + schema >> sources >> schema; + + Traversal::Names schema_names; + Traversal::Namespace ns; + Traversal::Names ns_names; + + schema >> schema_names >> ns >> ns_names; + + Complex complex (ctx); + + ns_names >> complex; + + schema.dispatch (tu); + } + } + } + } + + void NameProcessor:: + process (options const& ops, + SemanticGraph::Schema& tu, + SemanticGraph::Path const& file, + StringLiteralMap const& map) + { + process_impl (ops, tu, file, map); + } + } +} diff --git a/xsd/xsd/cxx/parser/name-processor.hxx b/xsd/xsd/cxx/parser/name-processor.hxx new file mode 100644 index 0000000..f8ac28c --- /dev/null +++ b/xsd/xsd/cxx/parser/name-processor.hxx @@ -0,0 +1,30 @@ +// file : xsd/cxx/parser/name-processor.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_PARSER_NAME_PROCESSOR_HXX +#define XSD_CXX_PARSER_NAME_PROCESSOR_HXX + +#include + +#include + +#include +#include + +namespace CXX +{ + namespace Parser + { + class NameProcessor + { + public: + void + process (options const&, + XSDFrontend::SemanticGraph::Schema&, + XSDFrontend::SemanticGraph::Path const& file, + StringLiteralMap const& map); + }; + } +} + +#endif // XSD_CXX_PARSER_NAME_PROCESSOR_HXX diff --git a/xsd/xsd/cxx/parser/options.cli b/xsd/xsd/cxx/parser/options.cli new file mode 100644 index 0000000..e430333 --- /dev/null +++ b/xsd/xsd/cxx/parser/options.cli @@ -0,0 +1,147 @@ +// file : xsd/cxx/parser/options.cli +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include ; // std::size_t + +include ; // NarrowString, NarrowStrings + +include ; + +namespace CXX +{ + namespace Parser + { + class options: CXX::options + { + NarrowStrings --type-map + { + "", + "Read XML Schema to C++ type mapping information from . + Repeat this option to specify several type maps. Type maps are + considered in order of appearance and the first match is used. By + default all user-defined types are mapped to \cb{void}. See the + TYPE MAP section below for more information." + }; + + NarrowString --xml-parser = "xerces" + { + "", + "Use as the underlying XML parser. Valid values are + \cb{xerces} for Xerces-C++ (default) and \cb{expat} for Expat." + }; + + // Features. + // + bool --generate-validation + { + "Generate validation code. The validation code (\"perfect parser\") + ensures that instance documents conform to the schema. Validation + code is generated by default when the selected underlying XML parser + is non-validating (\cb{expat})." + }; + + bool --suppress-validation + { + "Suppress the generation of validation code. Validation is suppressed + by default when the selected underlying XML parser is validating + (\cb{xerces})." + }; + + bool --generate-polymorphic + { + "Generate polymorphism-aware code. Specify this option if you use + substitution groups or \cb{xsi:type}." + }; + + bool --generate-noop-impl + { + "Generate a sample parser implementation that does nothing (no + operation). The sample implementation can then be filled with + the application-specific code. For an input file in the form + \cb{name.xsd} this option triggers the generation of two + additional C++ files in the form: \cb{name-pimpl.hxx} (parser + implementation header file) and \cb{name-pimpl.cxx} (parser + implementation source file)." + }; + + bool --generate-print-impl + { + "Generate a sample parser implementation that prints the XML data + to \c{STDOUT}. For an input file in the form \cb{name.xsd} this + option triggers the generation of two additional C++ files in the + form: \cb{name-pimpl.hxx} (parser implementation header file) and + \cb{name-pimpl.cxx} (parser implementation source file)." + }; + + bool --generate-test-driver + { + "Generate a test driver for the sample parser implementation. For an + input file in the form \cb{name.xsd} this option triggers the + generation of an additional C++ file in the form + \cb{name-driver.cxx}." + }; + + bool --force-overwrite + { + "Force overwriting of the existing implementation and test driver + files. Use this option only if you do not mind loosing the changes + you have made in the sample implementation or test driver files." + }; + + // Root element. + // + bool --root-element-first + { + "Indicate that the first global element is the document root. This + information is used to generate the test driver for the sample + implementation." + }; + + bool --root-element-last + { + "Indicate that the last global element is the document root. This + information is used to generate the test driver for the sample + implementation." + }; + + NarrowString --root-element + { + "", + "Indicate that is the document root. This information is + used to generate the test driver for the sample implementation." + }; + + // Suffixes. + // + NarrowString --skel-type-suffix = "_pskel" + { + "", + "Use the provided instead of the default \cb{_pskel} to + construct the names of the generated parser skeletons." + }; + + NarrowString --skel-file-suffix = "-pskel" + { + "", + "Use the provided instead of the default \cb{-pskel} to + construct the names of the generated parser skeleton files." + }; + + NarrowString --impl-type-suffix = "_pimpl" + { + "", + "Use the provided instead of the default \cb{_pimpl} to + construct the names of the parser implementations for the built-in + XML Schema types as well as sample parser implementations." + }; + + NarrowString --impl-file-suffix = "-pimpl" + { + "", + "Use the provided instead of the default \cb{-pimpl} to + construct the names of the generated sample parser implementation + files." + }; + }; + } +} diff --git a/xsd/xsd/cxx/parser/parser-forward.cxx b/xsd/xsd/cxx/parser/parser-forward.cxx new file mode 100644 index 0000000..65603fd --- /dev/null +++ b/xsd/xsd/cxx/parser/parser-forward.cxx @@ -0,0 +1,110 @@ +// file : xsd/cxx/parser/parser-forward.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include +#include + +namespace CXX +{ + namespace Parser + { + namespace + { + struct Enumeration: Traversal::Enumeration, Context + { + Enumeration (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& e) + { + os << "class " << ename (e) << ";"; + } + }; + + // + // + struct List: Traversal::List, Context + { + List (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& l) + { + os << "class " << ename (l) << ";"; + } + }; + + // + // + struct Union: Traversal::Union, Context + { + Union (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& u) + { + os << "class " << ename (u) << ";"; + } + }; + + // + // + struct Complex: Traversal::Complex, Context + { + Complex (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& c) + { + os << "class " << ename (c) << ";"; + } + }; + } + + void + generate_parser_forward (Context& ctx) + { + ctx.os << "// Forward declarations" << endl + << "//" << endl; + + Traversal::Schema schema; + + Sources sources; + Traversal::Names schema_names; + + Namespace ns (ctx); + Traversal::Names names; + + schema >> sources >> schema; + schema >> schema_names >> ns >> names; + + List list (ctx); + Union union_ (ctx); + Complex complex (ctx); + Enumeration enumeration (ctx); + + names >> list; + names >> union_; + names >> complex; + names >> enumeration; + + schema.dispatch (ctx.schema_root); + + ctx.os << endl; + } + } +} diff --git a/xsd/xsd/cxx/parser/parser-forward.hxx b/xsd/xsd/cxx/parser/parser-forward.hxx new file mode 100644 index 0000000..b5345a5 --- /dev/null +++ b/xsd/xsd/cxx/parser/parser-forward.hxx @@ -0,0 +1,18 @@ +// file : xsd/cxx/parser/parser-forward.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_PARSER_PARSER_FORWARD_HXX +#define XSD_CXX_PARSER_PARSER_FORWARD_HXX + +#include + +namespace CXX +{ + namespace Parser + { + void + generate_parser_forward (Context&); + } +} + +#endif // XSD_CXX_PARSER_PARSER_FORWARD_HXX diff --git a/xsd/xsd/cxx/parser/parser-header.cxx b/xsd/xsd/cxx/parser/parser-header.cxx new file mode 100644 index 0000000..327bb07 --- /dev/null +++ b/xsd/xsd/cxx/parser/parser-header.cxx @@ -0,0 +1,1440 @@ +// file : xsd/cxx/parser/parser-header.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include + +#include +#include + +using namespace std; + +namespace CXX +{ + namespace Parser + { + namespace + { + struct Enumeration: Traversal::Enumeration, Context + { + Enumeration (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& e) + { + String const& name (ename (e)); + SemanticGraph::Type& base (e.inherits ().base ()); + + os << "class " << type_exp << name << ": public virtual " << + fq_name (base) + << "{" + << "public:" << endl + << "// Parser callbacks. Override them in your " << + "implementation." << endl + << "//" << endl; + + os << "// virtual void" << endl + << "// pre ();" << endl + << endl; + + String const& ret (ret_type (e)); + + bool same (ret == ret_type (base)); + + os << "virtual " << ret << endl + << post_name (e) << " ()" << + (same || ret == L"void" ? ";" : " = 0;"); + + if (polymorphic) + { + os << endl + << "public:" << endl + << "static const " << char_type << "*" << endl + << "_static_type ();" + << endl + << "virtual const " << char_type << "*" << endl + << "_dynamic_type () const;"; + } + + os << "};"; + } + }; + + // + // + struct List: Traversal::List, Context + { + List (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& l) + { + String const& name (ename (l)); + SemanticGraph::Type& t (l.argumented ().type ()); + + String item (unclash (name, "item")); + + os << "class " << type_exp << name << ": public " << list_base + << "{" + << "public:" << endl + << "// Parser callbacks. Override them in your " << + "implementation." << endl + << "//" << endl; + + // pre + // + os << "// virtual void" << endl + << "// pre ();" << endl + << endl; + + // item + // + String const& arg (arg_type (t)); + + os << "virtual void" << endl + << item; + + if (arg == L"void") + os << " ();"; + else + os << " (" << arg << ");"; + + os << endl; + + // post + // + String const& ret (ret_type (l)); + + os << "virtual " << ret << endl + << post_name (l) << " ()" << (ret == L"void" ? ";" : " = 0;") + << endl; + + // + // + os << "// Parser construction API." << endl + << "//" << endl; + + // item_parser + // + os << "void" << endl + << unclash (name, "item_parser") << " (" << fq_name (t) << "&);" + << endl; + + // parsers + // + os << "void" << endl + << "parsers (" << fq_name (t) << "& /* item */);" + << endl; + + // c-tor + // + os << "// Constructor." << endl + << "//" << endl + << name << " ();" + << endl; + + + if (polymorphic) + { + os << "public:" << endl + << "static const " << char_type << "*" << endl + << "_static_type ();" + << endl + << "virtual const " << char_type << "*" << endl + << "_dynamic_type () const;" + << endl; + } + + // + // + os << "// Implementation." << endl + << "//" << endl + << "protected:" << endl; + + os << "virtual void" << endl + << "_xsd_parse_item (const " << string_type << "&);" + << endl; + + os << "protected:" << endl + << fq_name (t) << "* _xsd_" << item << "_;" + << "};"; + } + }; + + struct Union: Traversal::Union, Context + { + Union (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& u) + { + String const& name (ename (u)); + + os << "class " << type_exp << name << ": public " << simple_base + << "{" + << "public:" << endl + << "// Parser callbacks. Override them in your " << + "implementation." << endl + << "//" << endl; + + os << "// virtual void" << endl + << "// pre ();" << endl + << "//" << endl + << "// virtual void" << endl + << "// _characters (const " << string_type << "&);" << endl + << endl; + + String const& ret (ret_type (u)); + + os << "virtual " << ret << endl + << post_name (u) << " ()" << (ret == L"void" ? ";" : " = 0;"); + + if (polymorphic) + { + os << endl + << "public:" << endl + << "static const " << char_type << "*" << endl + << "_static_type ();" + << endl + << "virtual const " << char_type << "*" << endl + << "_dynamic_type () const;"; + } + + os << "};"; + } + }; + + + // + // + struct ParserCallback: Traversal::Member, Context + { + ParserCallback (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& m) + { + if (skip (m)) return; + + String const& arg (arg_type (m.type ())); + + os << "virtual void" << endl + << ename (m); + + if (arg == L"void") + os << " ();"; + else + os << " (" << arg << ");"; + + os << endl; + } + }; + + + // + // + struct ParserModifier: Traversal::Member, Context + { + ParserModifier (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& m) + { + if (skip (m)) + return; + + os << "void" << endl + << eparser (m) << " (" << fq_name (m.type ()) << "&);" + << endl; + + if (polymorphic && + m.is_a () && + !anonymous (m.type ())) + { + os << "void" << endl + << eparser (m) << " (const " << parser_map << "&);" + << endl; + } + } + }; + + // + // + struct ParserMember: Traversal::Member, Context + { + ParserMember (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& m) + { + if (skip (m)) + return; + + String type (fq_name (m.type ())); + + os << type << "* " << emember (m) << ";"; + + if (polymorphic && + m.is_a () && + !anonymous (m.type ())) + { + os << "const " << parser_map << "* " << emember_map (m) << ";" + << endl; + } + } + }; + + // + // + struct Particle: Traversal::All, + Traversal::Choice, + Traversal::Sequence, + Context + { + Particle (Context& c) + : Context (c) + { + *this >> contains_particle_ >> *this; + } + + + virtual void + traverse (SemanticGraph::All& a) + { + if (!a.context().count ("comp-number")) + return; + + size_t state_count (a.context().get ("state-count")); + + os << "void" << endl + << "all_0 (unsigned long& state," << endl + << "unsigned char* count," << endl + << "const " << string_type << "& ns," << endl + << "const " << string_type << "& n," << endl + << "const " << string_type << "* t," << endl + << "bool start);" + << endl + << "unsigned char v_all_first_[" << state_count << "UL];" + << "::xsd::cxx::parser::validating::all_stack v_all_count_;" + << endl; + } + + virtual void + traverse (SemanticGraph::Choice& c) + { + if (!c.context().count ("comp-number")) + return; + + size_t n (c.context ().get ("comp-number")); + + os << "void" << endl + << "choice_" << n << " (unsigned long& state," << endl + << "unsigned long& count," << endl + << "const " << string_type << "& ns," << endl + << "const " << string_type << "& n," << endl + << "const " << string_type << "* t," << endl + << "bool start);" + << endl; + + Traversal::Choice::traverse (c); + } + + virtual void + traverse (SemanticGraph::Sequence& s) + { + if (!s.context().count ("comp-number")) + return; + + size_t n (s.context ().get ("comp-number")); + + os << "void" << endl + << "sequence_" << n << " (unsigned long& state," << endl + << "unsigned long& count," << endl + << "const " << string_type << "& ns," << endl + << "const " << string_type << "& n," << endl + << "const " << string_type << "* t," << endl + << "bool start);" + << endl; + + Traversal::Sequence::traverse (s); + } + + private: + Traversal::ContainsParticle contains_particle_; + }; + + + // + // + struct AttributeValidationState: Traversal::Attribute, Context + { + AttributeValidationState (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& a) + { + if (!a.optional_p ()) + { + os << "bool " << ename (a) << ";"; + } + } + }; + + // + // + struct Complex: Traversal::Complex, Context + { + Complex (Context& c) + : Context (c), + parser_callback_ (c), + parser_member_ (c), + parser_modifier_ (c), + attribute_validation_state_ (c) + { + names_parser_callback_ >> parser_callback_; + names_parser_member_ >> parser_member_; + names_parser_modifier_ >> parser_modifier_; + names_attribute_validation_state_ >> attribute_validation_state_; + } + + virtual void + traverse (Type& c) + { + String const& name (ename (c)); + + // In case of an inheritance-by-restriction, we don't need to + // generate parser callbacks, etc. since they are the same as in + // the base. We only need the parsing/validation code. + // + bool restriction (restriction_p (c)); + + bool he (has (c)); + bool ha (has (c)); + + bool hae (has_particle (c)); + bool haa (has (c)); + + bool hra (false); // Has required attribute. + if (ha) + { + RequiredAttributeTest test (hra); + Traversal::Names names_test (test); + names (c, names_test); + } + + + // + // + os << "class " << type_exp << name << ": public "; + + if (c.inherits_p ()) + os << "virtual " << fq_name (c.inherits ().base ()); + else + os << complex_base; + + os << "{" + << "public:" << endl + << "// Parser callbacks. Override them in your " << + "implementation." << endl + << "//" << endl; + + os << "// virtual void" << endl + << "// pre ();" << endl + << endl; + + + if (!restriction && (ha || he)) + { + names (c, names_parser_callback_); + } + + String const& ret (ret_type (c)); + + bool same (c.inherits_p () && + ret == ret_type (c.inherits ().base ())); + + os << "virtual " << ret << endl + << post_name (c) << " ()" << + (same || ret == L"void" ? ";" : " = 0;") + << endl; + + // + // + if (!restriction && (he || ha)) + { + os << "// Parser construction API." << endl + << "//" << endl; + + names (c, names_parser_modifier_); + + os << "void" << endl + << "parsers ("; + + { + ParserParamDecl decl (*this, false); + decl.traverse (c); + } + + os << ");" + << endl; + } + + // Default c-tor. + // + if ((!restriction && (he || ha)) || + (validation && (he || hae || hra))) + { + os << "// Constructor." << endl + << "//" << endl + << name << " ();" + << endl; + } + + if (polymorphic) + { + os << "public:" << endl + << "static const " << char_type << "*" << endl + << "_static_type ();" + << endl + << "virtual const " << char_type << "*" << endl + << "_dynamic_type () const;" + << endl; + } + + // Implementation. + // + if (he || ha || (validation && (hae || haa))) + { + os << "// Implementation." << endl + << "//" << endl + << "protected:" << endl; + } + + // element + // + if (he || (validation && hae)) + { + // _start_element_impl + // + os << "virtual bool" << endl + << "_start_element_impl (const " << string_type << "&," << endl + << "const " << string_type << "&," << endl + << "const " << string_type << "*);" + << endl; + + // end_element + // + os << "virtual bool" << endl + << "_end_element_impl (const " << string_type << "&," << endl + << "const " << string_type << "&);" + << endl; + } + + // attribute + // + if (validation) + { + if (ha) + { + os << "virtual bool" << endl + << "_attribute_impl_phase_one (const " << string_type << + "&," << endl + << "const " << string_type << "&," << endl + << "const " << string_type << "&);" << endl + << endl; + } + + if (haa) + { + os << "virtual bool" << endl + << "_attribute_impl_phase_two (const " << string_type << + "&," << endl + << "const " << string_type << "&," << endl + << "const " << string_type << "&);" + << endl; + } + } + else + { + if (ha) + { + os << "virtual bool" << endl + << "_attribute_impl (const " << string_type << "&," << endl + << "const " << string_type << "&," << endl + << "const " << string_type << "&);" + << endl; + } + } + + // characters + // + if (validation && c.mixed_p ()) + { + os << "virtual bool" << endl + << "_characters_impl (const " << string_type << "&);" + << endl; + } + + if (!restriction && (he || ha)) + { + os << "protected:" << endl; + names (c, names_parser_member_); + os << endl; + } + + if (validation && (he || hae)) + { + size_t depth (c.context ().get ("depth")); + + os << "protected:" << endl; + + os << "struct v_state_descr_" + << "{" + << "void (" << fq_name (c) << "::*func) (" << endl + << "unsigned long&," << endl + << "unsigned long&," << endl + << "const " << string_type << "&," << endl + << "const " << string_type << "&," << endl + << "const " << string_type << "*," << endl + << "bool);" + << "unsigned long state;" + << "unsigned long count;" + << "};"; + + // Allocate one extra slot for the special state. + // + os << "struct v_state_" + << "{" + << "v_state_descr_ data[" << depth + 1 << "UL];" + << "unsigned long size;" + << "};"; + + os << "v_state_ v_state_first_;" + << "::xsd::cxx::parser::pod_stack v_state_stack_;" + << endl; + + os << "virtual void" << endl + << "_pre_e_validate ();" + << endl; + + os << "virtual void" << endl + << "_post_e_validate ();" + << endl; + + Particle t (*this); + t.dispatch (c.contains_compositor ().compositor ()); + } + + if (validation && hra) + { + os << "protected:" << endl; + + os << "struct v_state_attr_" + << "{"; + + names (c, names_attribute_validation_state_); + + os << "};"; + + os << "v_state_attr_ v_state_attr_first_;" + << "::xsd::cxx::parser::pod_stack v_state_attr_stack_;" + << endl; + + os << "virtual void" << endl + << "_pre_a_validate ();" + << endl; + + os << "virtual void" << endl + << "_post_a_validate ();" + << endl; + } + + os << "};"; + } + + private: + // + // + ParserCallback parser_callback_; + Traversal::Names names_parser_callback_; + + // + // + ParserMember parser_member_; + Traversal::Names names_parser_member_; + + // + // + ParserModifier parser_modifier_; + Traversal::Names names_parser_modifier_; + + // + // + AttributeValidationState attribute_validation_state_; + Traversal::Names names_attribute_validation_state_; + }; + + struct FundType : Context, + + Traversal::AnyType, + Traversal::AnySimpleType, + + Traversal::Fundamental::Byte, + Traversal::Fundamental::UnsignedByte, + Traversal::Fundamental::Short, + Traversal::Fundamental::UnsignedShort, + Traversal::Fundamental::Int, + Traversal::Fundamental::UnsignedInt, + Traversal::Fundamental::Long, + Traversal::Fundamental::UnsignedLong, + Traversal::Fundamental::Integer, + Traversal::Fundamental::NonPositiveInteger, + Traversal::Fundamental::NonNegativeInteger, + Traversal::Fundamental::PositiveInteger, + Traversal::Fundamental::NegativeInteger, + + Traversal::Fundamental::Boolean, + + Traversal::Fundamental::Float, + Traversal::Fundamental::Double, + Traversal::Fundamental::Decimal, + + Traversal::Fundamental::String, + Traversal::Fundamental::NormalizedString, + Traversal::Fundamental::Token, + Traversal::Fundamental::Name, + Traversal::Fundamental::NameToken, + Traversal::Fundamental::NameTokens, + Traversal::Fundamental::NCName, + Traversal::Fundamental::Language, + + Traversal::Fundamental::QName, + + Traversal::Fundamental::Id, + Traversal::Fundamental::IdRef, + Traversal::Fundamental::IdRefs, + + Traversal::Fundamental::AnyURI, + + Traversal::Fundamental::Base64Binary, + Traversal::Fundamental::HexBinary, + + Traversal::Fundamental::Date, + Traversal::Fundamental::DateTime, + Traversal::Fundamental::Duration, + Traversal::Fundamental::Day, + Traversal::Fundamental::Month, + Traversal::Fundamental::MonthDay, + Traversal::Fundamental::Year, + Traversal::Fundamental::YearMonth, + Traversal::Fundamental::Time, + + Traversal::Fundamental::Entity, + Traversal::Fundamental::Entities + { + FundType (Context& c) + : Context (c), xs_ns_ (xs_ns_name ()) + { + impl_ns_ = "::xsd::cxx::parser::"; + impl_ns_ += (validation ? L"validating" : L"non_validating"); + + if (char_type == L"char") + string_type_ = L"::std::string"; + else if (char_type == L"wchar_t") + string_type_ = L"::std::wstring"; + else + string_type_ = L"::std::basic_string< " + char_type + L" >"; + } + + // anyType & anySimpleType. + // + virtual void + traverse (SemanticGraph::AnyType& t) + { + gen_typedef (t, "void", "any_type_pskel", "any_type_pimpl"); + } + + virtual void + traverse (SemanticGraph::AnySimpleType& t) + { + gen_typedef (t, "void", + "any_simple_type_pskel", "any_simple_type_pimpl"); + } + + // Boolean. + // + virtual void + traverse (SemanticGraph::Fundamental::Boolean& t) + { + gen_typedef (t, "bool", "boolean_pskel", "boolean_pimpl"); + } + + // Integral types. + // + virtual void + traverse (SemanticGraph::Fundamental::Byte& t) + { + gen_typedef (t, "signed char", "byte_pskel", "byte_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedByte& t) + { + gen_typedef (t, "unsigned char", + "unsigned_byte_pskel", "unsigned_byte_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Short& t) + { + gen_typedef (t, "short", "short_pskel", "short_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedShort& t) + { + gen_typedef (t, "unsigned short", + "unsigned_short_pskel", "unsigned_short_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Int& t) + { + gen_typedef (t, "int", "int_pskel", "int_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedInt& t) + { + gen_typedef (t, "unsigned int", + "unsigned_int_pskel", "unsigned_int_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Long& t) + { + gen_typedef (t, "long long", "long_pskel", "long_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedLong& t) + { + gen_typedef (t, "unsigned long long", + "unsigned_long_pskel", "unsigned_long_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Integer& t) + { + gen_typedef (t, "long long", "integer_pskel", "integer_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NegativeInteger& t) + { + gen_typedef (t, "long long", + "negative_integer_pskel", "negative_integer_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) + { + gen_typedef (t, "long long", + "non_positive_integer_pskel", + "non_positive_integer_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::PositiveInteger& t) + { + gen_typedef (t, "unsigned long long", + "positive_integer_pskel", "positive_integer_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) + { + gen_typedef (t, "unsigned long long", + "non_negative_integer_pskel", + "non_negative_integer_pimpl"); + } + + // Floats. + // + virtual void + traverse (SemanticGraph::Fundamental::Float& t) + { + gen_typedef (t, "float", "float_pskel", "float_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Double& t) + { + gen_typedef (t, "double", "double_pskel", "double_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Decimal& t) + { + gen_typedef (t, "double", "decimal_pskel", "decimal_pimpl"); + } + + // Strings. + // + virtual void + traverse (SemanticGraph::Fundamental::String& t) + { + gen_typedef (t, string_type_, "string_pskel", "string_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NormalizedString& t) + { + gen_typedef (t, string_type_, + "normalized_string_pskel", "normalized_string_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Token& t) + { + gen_typedef (t, string_type_, "token_pskel", "token_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NameToken& t) + { + nmtoken_ = gen_typedef (t, string_type_, + "nmtoken_pskel", "nmtoken_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NameTokens& t) + { + // NMTOKENS uses NMTOKEN implementation to parse individual items. + // As a result, we don't generate NMTOKENS if we didn't generate + // NMTOKEN. Here we assume NMTOKEN is handled before NMTOKENS. + // + if(nmtoken_) + gen_typedef (t, xs_ns_ + L"::string_sequence", + "nmtokens_pskel", "nmtokens_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Name& t) + { + gen_typedef (t, string_type_, "name_pskel", "name_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NCName& t) + { + gen_typedef (t, string_type_, "ncname_pskel", "ncname_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Language& t) + { + gen_typedef (t, string_type_, "language_pskel", "language_pimpl"); + } + + // Qualified name. + // + virtual void + traverse (SemanticGraph::Fundamental::QName& t) + { + gen_typedef (t, xs_ns_ + L"::qname", "qname_pskel", "qname_pimpl"); + } + + // ID/IDREF. + // + virtual void + traverse (SemanticGraph::Fundamental::Id& t) + { + gen_typedef (t, string_type_, "id_pskel", "id_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::IdRef& t) + { + idref_ = gen_typedef (t, string_type_, "idref_pskel", "idref_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::IdRefs& t) + { + // IDREFS uses IDREF implementation to parse individual items. + // As a result, we don't generate IDREFS if we didn't generate + // IDREF. Here we assume IDREF is handled before IDREFS. + // + if (idref_) + gen_typedef (t, xs_ns_ + L"::string_sequence", + "idrefs_pskel", "idrefs_pimpl"); + } + + // URI. + // + virtual void + traverse (SemanticGraph::Fundamental::AnyURI& t) + { + gen_typedef (t, string_type_, "uri_pskel", "uri_pimpl"); + } + + // Binary. + // + virtual void + traverse (SemanticGraph::Fundamental::Base64Binary& t) + { + String buffer (auto_ptr + L"< " + xs_ns_ + L"::buffer >"); + gen_typedef (t, buffer, + "base64_binary_pskel", "base64_binary_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::HexBinary& t) + { + String buffer (auto_ptr + L"< " + xs_ns_ + L"::buffer >"); + gen_typedef (t, buffer, "hex_binary_pskel", "hex_binary_pimpl"); + } + + + // Date/time. + // + virtual void + traverse (SemanticGraph::Fundamental::Date& t) + { + gen_typedef (t, xs_ns_ + L"::date", "date_pskel", "date_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::DateTime& t) + { + gen_typedef (t, xs_ns_ + L"::date_time", + "date_time_pskel", "date_time_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Duration& t) + { + gen_typedef (t, xs_ns_ + L"::duration", + "duration_pskel", "duration_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Day& t) + { + gen_typedef (t, xs_ns_ + L"::gday", "gday_pskel", "gday_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Month& t) + { + gen_typedef (t, xs_ns_ + L"::gmonth", + "gmonth_pskel", "gmonth_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::MonthDay& t) + { + gen_typedef (t, xs_ns_ + L"::gmonth_day", + "gmonth_day_pskel", "gmonth_day_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Year& t) + { + gen_typedef (t, xs_ns_ + L"::gyear", "gyear_pskel", "gyear_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::YearMonth& t) + { + gen_typedef (t, xs_ns_ + L"::gyear_month", + "gyear_month_pskel", "gyear_month_pimpl"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Time& t) + { + gen_typedef (t, xs_ns_ + L"::time", "time_pskel", "time_pimpl"); + } + + // Entity. + // + virtual void + traverse (SemanticGraph::Fundamental::Entity&) + { + } + + virtual void + traverse (SemanticGraph::Fundamental::Entities&) + { + } + + private: + bool + gen_typedef (SemanticGraph::Type& t, + String const& type, + String const& pskel, + String const& pimpl) + { + if (ret_type (t) == type) + { + os << "typedef " << impl_ns_ << "::" << pskel << "< " << + char_type << " > " << ename (t) << ";"; + + String const& pimpl_name (t.context ().get ("impl")); + + os << "typedef " << impl_ns_ << "::" << pimpl << "< " << + char_type << " > " << pimpl_name << ";" + << endl; + + return true; + } + + return false; + } + + String xs_ns_; + String impl_ns_; + String string_type_; + + bool idref_; + bool nmtoken_; + }; + + struct FundNamespace: Namespace, Context + { + FundNamespace (Context& c) + : Namespace (c), Context (c) + { + } + + void + traverse (Type& ns) + { + pre (ns); + + String impl ("::xsd::cxx::parser::"); + impl += (validation ? L"validating" : L"non_validating"); + + String const c (char_type); + + os << "// Built-in XML Schema types mapping." << endl + << "//" << endl + << "typedef ::xsd::cxx::parser::string_sequence< " << c << + " > string_sequence;" + << "typedef ::xsd::cxx::parser::qname< " << c << " > qname;" + << "typedef ::xsd::cxx::parser::buffer buffer;" + << "typedef ::xsd::cxx::parser::time_zone time_zone;" + << "typedef ::xsd::cxx::parser::gday gday;" + << "typedef ::xsd::cxx::parser::gmonth gmonth;" + << "typedef ::xsd::cxx::parser::gyear gyear;" + << "typedef ::xsd::cxx::parser::gmonth_day gmonth_day;" + << "typedef ::xsd::cxx::parser::gyear_month gyear_month;" + << "typedef ::xsd::cxx::parser::date date;" + << "typedef ::xsd::cxx::parser::time time;" + << "typedef ::xsd::cxx::parser::date_time date_time;" + << "typedef ::xsd::cxx::parser::duration duration;" + << endl; + + os << "// Base parser skeletons." << endl + << "//" << endl + << "typedef ::xsd::cxx::parser::parser_base< " << c << + " > parser_base;" + << "typedef " << impl << "::empty_content< " << c << + " > empty_content;" + << "typedef " << impl << "::simple_content< " << c << + " > simple_content;" + << "typedef " << impl << "::complex_content< " << c << + " > complex_content;" + << "typedef " << impl << "::list_base< " << c << " > list_base;" + << endl; + + if (polymorphic) + { + os << "// Parser map interface and default implementation." << endl + << "//" << endl + << "typedef ::xsd::cxx::parser::parser_map< " << c << + " > parser_map;" + << "typedef ::xsd::cxx::parser::parser_map_impl< " << c << + " > parser_map_impl;" + << endl; + } + + os << "// Parser skeletons and implementations for the XML Schema" << endl + << "// built-in types." << endl + << "//" << endl; + + names (ns); + + os << "// Exceptions. See xsd/cxx/parser/exceptions.hxx " << + "for details." << endl + << "//" << endl + << "typedef ::xsd::cxx::parser::exception< " << + char_type << " > exception;" + << endl + << "// Parsing diagnostics." << endl + << "//" << endl + << "typedef ::xsd::cxx::parser::severity severity;" + << "typedef ::xsd::cxx::parser::error< " << c << " > error;" + << "typedef ::xsd::cxx::parser::diagnostics< " << c << + " > diagnostics;" + << "typedef ::xsd::cxx::parser::parsing< " << c << " > parsing;" + << endl; + + os << "// Error handler. See " << + "xsd/cxx/xml/error-handler.hxx for details." << endl + << "//" << endl + << "typedef ::xsd::cxx::xml::error_handler< " << c << + " > error_handler;" + << endl; + + os << "// Read-only string." << endl + << "//" << endl + << "typedef ::xsd::cxx::ro_string< " << c << " > ro_string;" + << endl; + + if (xml_parser == L"xerces") + { + os << "// Parsing flags. See " << + "xsd/cxx/parser/xerces/elements.hxx" << endl + << "// for details." << endl + << "//" << endl + << "typedef ::xsd::cxx::parser::xerces::flags flags;" + << endl; + + os << "// Parsing properties. See " << + "xsd/cxx/parser/xerces/elements.hxx" << endl + << "// for details." << endl + << "//" << endl + << "typedef ::xsd::cxx::parser::xerces::properties< " << c << + " > properties;" + << endl; + + os << "// Document type. See " << + "xsd/cxx/parser/xerces/elements.hxx" << endl + << "// for details." << endl + << "//" << endl + << "typedef ::xsd::cxx::parser::xerces::document< " << c << + " > document;" + << endl; + + } + else if (xml_parser == L"expat") + { + os << "// Document type. See " << + "xsd/cxx/parser/expat/elements.hxx" << endl + << "// for details." << endl + << "//" << endl + << "typedef ::xsd::cxx::parser::expat::document< " << c << + " > document;" + << endl; + } + + post (ns); + } + }; + } + + void + generate_parser_header (Context& ctx, bool generate_xml_schema) + { + String c (ctx.char_type); + + // + // + if (c == L"char") + { + ctx.os << "#ifndef XSD_USE_CHAR" << endl + << "#define XSD_USE_CHAR" << endl + << "#endif" << endl + << endl; + + ctx.os << "#ifndef XSD_CXX_PARSER_USE_CHAR" << endl + << "#define XSD_CXX_PARSER_USE_CHAR" << endl + << "#endif" << endl + << endl; + } + else if (c == L"wchar_t") + { + ctx.os << "#ifndef XSD_USE_WCHAR" << endl + << "#define XSD_USE_WCHAR" << endl + << "#endif" << endl + << endl; + + ctx.os << "#ifndef XSD_CXX_PARSER_USE_WCHAR" << endl + << "#define XSD_CXX_PARSER_USE_WCHAR" << endl + << "#endif" << endl + << endl; + } + + // + // + NarrowString extern_xml_schema; + + if (!generate_xml_schema) + extern_xml_schema = ctx.options.extern_xml_schema (); + + if (extern_xml_schema) + { + String name (ctx.hxx_expr->replace (extern_xml_schema)); + + ctx.os << "#include " << ctx.process_include_path (name) << endl + << endl; + + // Generate includes that came from the type map. + // + if (ctx.schema_root.context ().count ("includes")) + { + typedef set Includes; + + Includes const& is ( + ctx.schema_root.context ().get ("includes")); + + for (Includes::const_reverse_iterator i (is.rbegin ()); + i != is.rend (); ++i) + { + ctx.os << "#include " << *i << endl; + } + + ctx.os << endl; + } + } + else + { + if (ctx.char_type == L"char" && + ctx.xml_parser == L"xerces" && + ctx.char_encoding != L"custom") + { + ctx.os << "#include " << endl; + } + + ctx.os << "#include " << endl + << "#include " << endl + << "#include " << endl + << "#include " << endl; + + if (ctx.polymorphic) + ctx.os << "#include " << endl; + + if (ctx.validation) + ctx.os << "#include " << endl + << "#include " << endl + << "#include " << endl + << "#include " << endl; + else + ctx.os << "#include " << endl + << "#include " << endl + << "#include " << endl; + + ctx.os << "#include " << endl + << endl; + + // Generate includes that came from the type map. + // + if (ctx.schema_root.context ().count ("includes")) + { + typedef set Includes; + + Includes const& is ( + ctx.schema_root.context ().get ("includes")); + + for (Includes::const_reverse_iterator i (is.rbegin ()); + i != is.rend (); ++i) + { + ctx.os << "#include " << *i << endl; + } + + ctx.os << endl; + } + + // Generate fundamental types. + // + if (generate_xml_schema) + { + Traversal::Schema schema; + Traversal::Names names; + FundNamespace ns (ctx); + + schema >> names >> ns; + + Traversal::Names ns_names; + FundType type (ctx); + + ns >> ns_names >> type; + + schema.dispatch (ctx.schema_root); + } + else + { + Traversal::Schema schema, xsd; + Traversal::Implies implies; + Traversal::Names names; + FundNamespace ns (ctx); + + schema >> implies >> xsd >> names >> ns; + + Traversal::Names ns_names; + FundType type (ctx); + + ns >> ns_names >> type; + + schema.dispatch (ctx.schema_root); + } + } + + // Generate user type mapping. + // + if (!generate_xml_schema) + { + Traversal::Schema schema; + + Sources sources; + Includes includes (ctx, Includes::header); + Traversal::Names schema_names; + + Namespace ns (ctx); + Traversal::Names names; + + schema >> includes; + schema >> sources >> schema; + schema >> schema_names >> ns >> names; + + List list (ctx); + Union union_ (ctx); + Complex complex (ctx); + Enumeration enumeration (ctx); + + names >> list; + names >> union_; + names >> complex; + names >> enumeration; + + schema.dispatch (ctx.schema_root); + } + } + } +} diff --git a/xsd/xsd/cxx/parser/parser-header.hxx b/xsd/xsd/cxx/parser/parser-header.hxx new file mode 100644 index 0000000..642da40 --- /dev/null +++ b/xsd/xsd/cxx/parser/parser-header.hxx @@ -0,0 +1,18 @@ +// file : xsd/cxx/parser/parser-header.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_PARSER_PARSER_HEADER_HXX +#define XSD_CXX_PARSER_PARSER_HEADER_HXX + +#include + +namespace CXX +{ + namespace Parser + { + void + generate_parser_header (Context&, bool generate_xml_schema); + } +} + +#endif // XSD_CXX_PARSER_PARSER_HEADER_HXX diff --git a/xsd/xsd/cxx/parser/parser-inline.cxx b/xsd/xsd/cxx/parser/parser-inline.cxx new file mode 100644 index 0000000..6705d5b --- /dev/null +++ b/xsd/xsd/cxx/parser/parser-inline.cxx @@ -0,0 +1,399 @@ +// file : xsd/cxx/parser/parser-inline.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include +#include + +namespace CXX +{ + namespace Parser + { + namespace + { + // + // + struct List: Traversal::List, Context + { + List (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& l) + { + String const& name (ename (l)); + SemanticGraph::Type& t (l.argumented ().type ()); + + String item (unclash (name, "item")); + + os << "// " << name << endl + << "//" << endl + << endl; + + // item_parser + // + os << inl + << "void " << name << "::" << endl + << unclash (name, "item_parser") << " (" << + fq_name (t) << "& " << item << ")" + << "{" + << "this->_xsd_" << item << "_ = &" << item << ";" + << "}"; + + // parsers + // + os << inl + << "void " << name << "::" << endl + << "parsers (" << fq_name (t) << "& " << item << ")" + << "{" + << "this->_xsd_" << item << "_ = &" << item << ";" + << "}"; + + // c-tor + // + os << inl + << name << "::" << endl + << name << " ()" << endl + << ": _xsd_" << item << "_ (0)" + << "{" + << "}"; + } + }; + + + // + // + struct ParserModifier: Traversal::Member, Context + { + ParserModifier (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& m) + { + if (skip (m)) + return; + + String const& scope (ename (m.scope ())); + String const& parser (eparser (m)); + + bool poly (polymorphic && + m.is_a () && + !anonymous (m.type ())); + + os << inl + << "void " << scope << "::" << endl + << parser << " (" << fq_name (m.type ()) << "& p)" + << "{" + << "this->" << emember (m) << " = &p;" + << "}"; + + if (poly) + { + os << inl + << "void " << scope << "::" << endl + << parser << " (const " << parser_map << "& m)" + << "{" + << "this->" << emember_map (m) << " = &m;" + << "}"; + } + } + }; + + + // + // + struct ParserMemberSet: Traversal::Member, Context + { + ParserMemberSet (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& m) + { + if (skip (m)) return; + + String const& name (ename (m)); + + os << "this->" << emember (m) << " = &" << name << ";"; + } + }; + + + // + // + struct ParserMemberInit: Traversal::Member, Context + { + ParserMemberInit (Context& c) + : Context (c), first_ (true) + { + } + + virtual void + traverse (Type& m) + { + if (skip (m)) return; + + if (first_) + first_ = false; + else + os << "," << endl << " "; + + os << emember (m) << " (0)"; + + if (polymorphic && + m.is_a () && + !anonymous (m.type ())) + { + os << "," << endl + << " " << emember_map (m) << " (0)"; + } + } + + bool + comma () const + { + return !first_; + } + + private: + bool first_; + }; + + struct ParserBaseSet: Traversal::Complex, + Traversal::List, + Context + { + ParserBaseSet (Context& c) + : Context (c), member_ (c) + { + inherits_ >> *this; + names_ >> member_; + } + + virtual void + traverse (SemanticGraph::Complex& c) + { + inherits (c, inherits_); + + if (!restriction_p (c)) + names (c, names_); + } + + virtual void + traverse (SemanticGraph::List& l) + { + String const& name (ename (l)); + String item (unclash (name, "item")); + + os << "this->_xsd_" << item << "_ = &" << name << "_item;"; + } + + private: + Traversal::Inherits inherits_; + + ParserMemberSet member_; + Traversal::Names names_; + }; + + struct Particle: Traversal::All, Context + { + Particle (Context& c) + : Context (c) + { + } + + virtual void + traverse (SemanticGraph::All& a) + { + if (!a.context().count ("comp-number")) + return; + + size_t state_count (a.context().get ("state-count")); + + os << "," << endl + << " v_all_count_ (" << state_count << "UL, v_all_first_)"; + } + }; + + // + // + struct Complex: Traversal::Complex, Context + { + Complex (Context& c) + : Context (c), + parser_modifier_ (c), + parser_base_set_ (c), + parser_member_set_ (c), + particle_ (c) + { + names_parser_modifier_ >> parser_modifier_; + inherits_parser_base_set_ >> parser_base_set_; + names_parser_member_set_ >> parser_member_set_; + } + + virtual void + traverse (Type& c) + { + bool he (has (c)); + bool ha (has (c)); + + bool hae (has_particle (c)); + + bool hra (false); // Has required attribute. + if (ha) + { + RequiredAttributeTest test (hra); + Traversal::Names names_test (test); + names (c, names_test); + } + + bool restriction (restriction_p (c)); + + if (!((!restriction && (he || ha)) || + (validation && (he || hae || hra)))) + return; + + String const& name (ename (c)); + + os << "// " << name << endl + << "//" << endl + << endl; + + if (!restriction && (he || ha)) + { + // _parser () + // + names (c, names_parser_modifier_); + + + // parsers () + // + + os << inl + << "void " << name << "::" << endl + << "parsers ("; + + { + ParserParamDecl decl (*this, true); + decl.traverse (c); + } + + os << ")" + << "{"; + + inherits (c, inherits_parser_base_set_); + names (c, names_parser_member_set_); + + os << "}"; + } + + // Default c-tor. + // + os << inl + << name << "::" << endl + << name << " ()" << endl + << ": "; + + bool comma (false); + + if (!restriction && (he || ha)) + { + ParserMemberInit member_init (*this); + Traversal::Names names_member_init (member_init); + + names (c, names_member_init); + + comma = member_init.comma (); + } + + if (validation && (he || hae)) + { + if (comma) + os << "," << endl << " "; + + os << "v_state_stack_ (sizeof (v_state_), &v_state_first_)"; + + particle_.dispatch (c.contains_compositor ().compositor ()); + + comma = true; + } + + if (validation && (hra)) + { + if (comma) + os << "," << endl << " "; + + os << "v_state_attr_stack_ (sizeof (v_state_attr_), " << + "&v_state_attr_first_)"; + } + + os << "{" + << "}"; + } + + private: + // + // + ParserModifier parser_modifier_; + Traversal::Names names_parser_modifier_; + + // + // + ParserBaseSet parser_base_set_; + Traversal::Inherits inherits_parser_base_set_; + + // + // + ParserMemberSet parser_member_set_; + Traversal::Names names_parser_member_set_; + + // + // + Particle particle_; + }; + } + + void + generate_parser_inline (Context& ctx) + { + // Emit "weak" header includes that are used in the file-per-type + // compilation model. + // + if (!ctx.options.generate_inline ()) + { + Traversal::Schema schema; + Includes includes (ctx, Includes::source); + + schema >> includes; + schema.dispatch (ctx.schema_root); + } + + Traversal::Schema schema; + + Sources sources; + Traversal::Names schema_names; + + Namespace ns (ctx); + Traversal::Names names; + + schema >> sources >> schema; + schema >> schema_names >> ns >> names; + + List list (ctx); + Complex complex (ctx); + + names >> list; + names >> complex; + + schema.dispatch (ctx.schema_root); + } + } +} diff --git a/xsd/xsd/cxx/parser/parser-inline.hxx b/xsd/xsd/cxx/parser/parser-inline.hxx new file mode 100644 index 0000000..aee0cdf --- /dev/null +++ b/xsd/xsd/cxx/parser/parser-inline.hxx @@ -0,0 +1,18 @@ +// file : xsd/cxx/parser/parser-inline.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_PARSER_PARSER_INLINE_HXX +#define XSD_CXX_PARSER_PARSER_INLINE_HXX + +#include + +namespace CXX +{ + namespace Parser + { + void + generate_parser_inline (Context&); + } +} + +#endif // XSD_CXX_PARSER_PARSER_INLINE_HXX diff --git a/xsd/xsd/cxx/parser/parser-source.cxx b/xsd/xsd/cxx/parser/parser-source.cxx new file mode 100644 index 0000000..2887f96 --- /dev/null +++ b/xsd/xsd/cxx/parser/parser-source.cxx @@ -0,0 +1,957 @@ +// file : xsd/cxx/parser/parser-source.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include +#include + +namespace CXX +{ + namespace Parser + { + namespace + { + struct Enumeration: Traversal::Enumeration, Context + { + Enumeration (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& e) + { + String const& name (ename (e)); + String const& ret (ret_type (e)); + + SemanticGraph::Type& base (e.inherits ().base ()); + + bool same (ret == ret_type (base)); + + if (same || ret == L"void" || polymorphic) + { + os << "// " << name << endl + << "//" << endl + << endl; + } + + if (same || ret == L"void") + { + os << ret << " " << name << "::" << endl + << post_name (e) << " ()" + << "{"; + + if (same) + { + if (ret == L"void") + os << post_name (base) << " ();"; + else + os << "return " << post_name (base) << " ();"; + } + + os << "}"; + } + + if (polymorphic) + { + String id (e.name ()); + + if (String ns = xml_ns_name (e)) + { + id += L' '; + id += ns; + } + + os << "const " << char_type << "* " << name << "::" << endl + << "_static_type ()" + << "{" + << "return " << strlit (id) << ";" + << "}"; + + os << "const " << char_type << "* " << name << "::" << endl + << "_dynamic_type () const" + << "{" + << "return _static_type ();" + << "}"; + + if (validation) + { + bool gen (!anonymous (e)); + + // We normally don't need to enter anonymous types into + // the inheritance map. The only exception is when an + // anonymous types is defined inside an element that + // is a member of a substitution group. + // + if (!gen) + { + // The first instance that this anonymous type classifies + // is the prototype for others if any. If this type does + // not classify anything (e.g., it is a base), then we + // don't need to do anything. + // + if (e.classifies_begin () != e.classifies_end ()) + { + SemanticGraph::Instance& i ( + e.classifies_begin ()->instance ()); + + if (SemanticGraph::Element* e = + dynamic_cast (&i)) + { + if (e->substitutes_p ()) + gen = true; + } + } + } + + if (gen) + { + os << "static" << endl + << "const ::xsd::cxx::parser::validating::inheritance_map_entry< " << + char_type << " >" << endl + << "_xsd_" << name << "_inheritance_map_entry_ (" << endl + << name << "::_static_type ()," << endl + << fq_name (base) << "::_static_type ());" + << endl; + } + } + } + } + }; + + // + // + struct List: Traversal::List, Context + { + List (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& l) + { + String const& name (ename (l)); + SemanticGraph::Type& t (l.argumented ().type ()); + + String item (unclash (name, "item")); + + os << "// " << name << endl + << "//" << endl + << endl; + + // item + // + String const& arg (arg_type (t)); + + os << "void " << name << "::" << endl + << item; + + if (arg == L"void") + os << " ()"; + else + os << " (" << arg << ")"; + + os << "{" + << "}"; + + // post + // + if (ret_type (l) == L"void") + os << "void " << name << "::" << endl + << post_name (l) << " ()" + << "{" + << "}"; + + // parse_item + // + String inst (L"_xsd_" + item + L"_"); + String const& post (post_name (t)); + + os << "void " << name << "::" << endl + << "_xsd_parse_item (const " << string_type << "& v)" + << "{" + << "if (this->" << inst << ")" + << "{" + << "this->" << inst << "->pre ();" + << "this->" << inst << "->_pre_impl ();" + << "this->" << inst << "->_characters (v);" + << "this->" << inst << "->_post_impl ();"; + + if (ret_type (t) == L"void") + os << "this->" << inst << "->" << post << " ();" + << "this->" << item << " ();"; + else + os << "this->" << item << " (this->" << inst << "->" << + post << " ());"; + + os << "}" + << "}"; + + // + // + if (polymorphic) + { + String id (l.name ()); + + if (String ns = xml_ns_name (l)) + { + id += L' '; + id += ns; + } + + os << "const " << char_type << "* " << name << "::" << endl + << "_static_type ()" + << "{" + << "return " << strlit (id) << ";" + << "}"; + + os << "const " << char_type << "* " << name << "::" << endl + << "_dynamic_type () const" + << "{" + << "return _static_type ();" + << "}"; + } + } + }; + + // + // + struct Union: Traversal::Union, Context + { + Union (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& u) + { + String const& name (ename (u)); + String const& ret (ret_type (u)); + + if (ret == L"void" || polymorphic) + { + os << "// " << name << endl + << "//" << endl + << endl; + } + + if (ret == L"void") + { + os << "void " << name << "::" << endl + << post_name (u) << " ()" + << "{" + << "}"; + } + + if (polymorphic) + { + String id (u.name ()); + + if (String ns = xml_ns_name (u)) + { + id += L' '; + id += ns; + } + + os << "const " << char_type << "* " << name << "::" << endl + << "_static_type ()" + << "{" + << "return " << strlit (id) << ";" + << "}"; + + os << "const " << char_type << "* " << name << "::" << endl + << "_dynamic_type () const" + << "{" + << "return _static_type ();" + << "}"; + } + } + }; + + // + // + struct StartElement: Traversal::Element, Context + { + StartElement (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& e) + { + if (skip (e)) + return; + + bool poly (polymorphic && !anonymous (e.type ())); + + os << "if ("; + + if (poly && e.global_p ()) + os << "("; + + if (e.qualified_p () && e.namespace_ ().name ()) + { + os << "n == " << strlit (e.name ()) << " && " << + "ns == " << strlit (e.namespace_ ().name ()); + } + else + { + os << "n == " << strlit (e.name ()) << " && ns.empty ()"; + } + + // Only a globally-defined element can be a subst-group root. + // + if (poly && e.global_p ()) + { + os << ") ||" << endl + << "::xsd::cxx::parser::substitution_map_instance< " << + char_type << " > ().check (" << endl + << "ns, n, " << strlit (e.namespace_ ().name ()) << + ", " << strlit (e.name ()) << ", t)"; + } + + os << ")" + << "{"; + + String inst; + + if (poly) + { + SemanticGraph::Type& t (e.type ()); + inst = "p"; + + // For pre-computing length. + // + String type_id (t.name ()); + + if (String type_ns = xml_ns_name (t)) + { + type_id += L' '; + type_id += type_ns; + } + + String fq_type (fq_name (t)); + String const& member (emember (e)); + String const& member_map (emember_map (e)); + + os << fq_type << "* p = 0;" + << endl + << "if (t == 0 && this->" << member << " != 0)" << endl + << inst << " = this->" << member << ";" + << "else" + << "{" + << string_type << " ts (" << fq_type << + "::_static_type (), " << type_id.size () << "UL);" + << endl + << "if (t == 0)" << endl + << "t = &ts;" + << endl + << "if (this->" << member << " != 0 && *t == ts)" << endl + << inst << " = this->" << member << ";" + << "else if (this->" << member_map << " != 0)" << endl + << inst << " = dynamic_cast< " << fq_type << + "* > (" << endl + << "this->" << member_map << "->find (*t));" + << "}"; + } + else + inst = L"this->" + emember (e); + + os << "this->" << complex_base << "::context_.top ().parser_ = " << + inst << ";" + << endl + << "if (" << inst << ")" << endl + << inst << "->pre ();" // _start_element calls _pre + << endl + << "return true;" + << "}"; + } + }; + + + // + // + struct EndElement: Traversal::Element, Context + { + EndElement (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& e) + { + if (skip (e)) + return; + + bool poly (polymorphic && !anonymous (e.type ())); + String const& name (ename (e)); + + os << "if ("; + + if (poly && e.global_p ()) + os << "("; + + if (e.qualified_p () && e.namespace_ ().name ()) + { + os << "n == " << strlit (e.name ()) << " && " << + "ns == " << strlit (e.namespace_ ().name ()); + } + else + { + os << "n == " << strlit (e.name ()) << " && ns.empty ()"; + } + + // Only a globally-defined element can be a subst-group root. + // + if (poly && e.global_p ()) + { + os << ") ||" << endl + << "::xsd::cxx::parser::substitution_map_instance< " << + char_type << " > ().check (" << endl + << "ns, n, " << strlit (e.namespace_ ().name ()) << + ", " << strlit (e.name ()) << ")"; + } + + os << ")" + << "{"; + + // _end_element calls post + // + + SemanticGraph::Type& type (e.type ()); + String const& post (post_name (type)); + String inst; + + if (poly) + { + String const& fq_type (fq_name (type)); + inst = "p"; + + os << fq_type << "* p =" << endl + << "dynamic_cast< " << fq_type << "* > (" << endl + << "this->" << complex_base << "::context_.top ().parser_);" + << endl; + } + else + inst = L"this->" + emember (e); + + os << "if (" << inst << ")"; + + if (ret_type (type) == L"void") + os << "{" + << inst << "->" << post << " ();" + << "this->" << name << " ();" + << "}"; + else + os << endl + << "this->" << name << " (" << inst << "->" << post << " ());" + << endl; + + os << "return true;" + << "}"; + } + }; + + // + // + struct Attribute: Traversal::Attribute, Context + { + Attribute (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& a) + { + String const& name (ename (a)); + String const& inst (emember (a)); + + if (a.qualified_p () && a.namespace_ ().name ()) + { + os << "if (n == " << strlit (a.name ()) << " && " << + "ns == " << strlit (a.namespace_ ().name ()) << ")" + << "{"; + } + else + { + os << "if (n == " << strlit (a.name ()) << " && ns.empty ())" + << "{"; + } + + SemanticGraph::Type& type (a.type ()); + String const& post (post_name (type)); + String const& ret (ret_type (type)); + + os << "if (this->" << inst << ")" + << "{" + << "this->" << inst << "->pre ();" + << "this->" << inst << "->_pre_impl ();" + << "this->" << inst << "->_characters (v);" + << "this->" << inst << "->_post_impl ();"; + + if (ret == L"void") + os << "this->" << inst << "->" << post << " ();" + << "this->" << name << " ();"; + else + os << "this->" << name << " (this->" << inst << "->" << + post << " ());"; + + os << "}" + << "return true;" + << "}"; + } + }; + + // + // + struct ParserCallback: Traversal::Member, Context + { + ParserCallback (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& m) + { + if (skip (m)) + return; + + String const& arg (arg_type (m.type ())); + + os << "void " << ename (m.scope ()) << "::" << endl + << ename (m); + + if (arg == L"void") + os << " ()"; + else + os << " (" << arg << ")"; + + os << "{" + << "}"; + } + }; + + // + // + struct Complex: Traversal::Complex, Context + { + Complex (Context& c) + : Context (c), + parser_callback_ (c), + start_element_ (c), + end_element_ (c), + attribute_ (c) + { + names_parser_callback_ >> parser_callback_; + names_start_element_ >> start_element_; + names_end_element_ >> end_element_; + names_attribute_ >> attribute_; + } + + virtual void + traverse (Type& c) + { + bool he (has (c)); + bool ha (has (c)); + + String const& ret (ret_type (c)); + bool same (c.inherits_p () && + ret == ret_type (c.inherits ().base ())); + + String const& name (ename (c)); + + if ((he || ha || same || ret == L"void") || polymorphic) + { + os << "// " << name << endl + << "//" << endl + << endl; + } + + if (polymorphic) + { + String id (c.name ()); + + if (String ns = xml_ns_name (c)) + { + id += L' '; + id += ns; + } + + os << "const " << char_type << "* " << name << "::" << endl + << "_static_type ()" + << "{" + << "return " << strlit (id) << ";" + << "}"; + + os << "const " << char_type << "* " << name << "::" << endl + << "_dynamic_type () const" + << "{" + << "return _static_type ();" + << "}"; + + if (c.inherits_p () && validation) + { + bool gen (!anonymous (c)); + + // We normally don't need to enter anonymous types into + // the inheritance map. The only exception is when an + // anonymous types is defined inside an element that + // is a member of a substitution group. + // + if (!gen) + { + // The first instance that this anonymous type classifies + // is the prototype for others if any. If this type does + // not classify anything (e.g., it is a base), then we + // don't need to do anything. + // + if (c.classifies_begin () != c.classifies_end ()) + { + SemanticGraph::Instance& i ( + c.classifies_begin ()->instance ()); + + if (SemanticGraph::Element* e = + dynamic_cast (&i)) + { + if (e->substitutes_p ()) + gen = true; + } + } + } + + if (gen) + { + SemanticGraph::Type& base (c.inherits ().base ()); + + os << "static" << endl + << "const ::xsd::cxx::parser::validating::inheritance_map_entry< " << + char_type << " >" << endl + << "_xsd_" << name << "_inheritance_map_entry_ (" << endl + << name << "::_static_type ()," << endl + << fq_name (base) << "::_static_type ());" + << endl; + } + } + } + + if (!(he || ha || same || ret == L"void")) + return; + + // Parser callbacks. + // + if (!restriction_p (c)) + names (c, names_parser_callback_); + + if (same || ret == L"void") + { + os << ret << " " << name << "::" << endl + << post_name (c) << " ()" + << "{"; + + if (same) + { + SemanticGraph::Type& base (c.inherits ().base ()); + + if (ret == L"void") + os << post_name (base) << " ();"; + else + os << "return " << post_name (base) << " ();"; + } + + os << "}"; + } + + // The rest is parsing/validation code which is generated in + // *-validation-source.cxx. + // + if (validation) + return; + + // Don't use restriction_p here since we don't want special + // treatment of anyType. + // + bool restriction ( + c.inherits_p () && + c.inherits ().is_a ()); + + // _start_element_impl & _end_element_impl + // + if (he) + { + os << "bool " << name << "::" << endl + << "_start_element_impl (const " << string_type << "& ns," << endl + << "const " << string_type << "& n," << endl + << "const " << string_type << "* t)" + << "{" + << "XSD_UNUSED (t);" + << endl; + + if (!restriction) + { + os << "if (this->"; + + if (c.inherits_p ()) + os << fq_name (c.inherits ().base ()); + else + os << complex_base; + + os << "::_start_element_impl (ns, n, t))" << endl + << "return true;" + << endl; + } + + names (c, names_start_element_); + + os << "return false;" + << "}"; + + + // _end_element_impl + // + os << "bool " << name << "::" << endl + << "_end_element_impl (const " << string_type << "& ns," << endl + << "const " << string_type << "& n)" + << "{"; + + if (!restriction) + { + os << "if (this->"; + + if (c.inherits_p () && !restriction) + os << fq_name (c.inherits ().base ()); + else + os << complex_base; + + os << "::_end_element_impl (ns, n))" << endl + << "return true;" + << endl; + } + + names (c, names_end_element_); + + os << "return false;" + << "}"; + } + + + if (ha) + { + // _attribute_impl + // + os << "bool " << name << "::" << endl + << "_attribute_impl (const " << string_type << "& ns," << endl + << "const " << string_type << "& n," << endl + << "const " << string_type << "& v)" + << "{"; + + if (!restriction) + { + os << "if (this->"; + + if (c.inherits_p ()) + os << fq_name (c.inherits ().base ()); + else + os << complex_base; + + os << "::_attribute_impl (ns, n, v))" << endl + << "return true;" + << endl; + } + + names (c, names_attribute_); + + os << "return false;" + << "}"; + } + } + + private: + // + // + ParserCallback parser_callback_; + Traversal::Names names_parser_callback_; + + // + // + StartElement start_element_; + Traversal::Names names_start_element_; + + // + // + EndElement end_element_; + Traversal::Names names_end_element_; + + // + // + Attribute attribute_; + Traversal::Names names_attribute_; + }; + + + // Generate substitution group map entries. + // + struct GlobalElement: Traversal::Element, Context + { + GlobalElement (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& e) + { + if (e.substitutes_p ()) + { + String name (escape (e.name ())); + Type& r (e.substitutes ().root ()); + + SemanticGraph::Type& type (e.type ()); + + os << "// Substitution map entry for " << comment (e.name ()) << "." << endl + << "//" << endl + << "static" << endl + << "const ::xsd::cxx::parser::substitution_map_entry< " << + char_type << " >" << endl + << "_xsd_" << name << "_substitution_map_entry_ (" << endl + << strlit (e.namespace_ ().name ()) << "," << endl + << strlit (e.name ()) << "," << endl + << strlit (r.namespace_ ().name ()) << "," << endl + << strlit (r.name ()) << "," << endl + << fq_name (type) << "::_static_type ());" + << endl; + } + } + }; + } + + void + generate_parser_source (Context& ctx) + { + if (ctx.polymorphic) + { + ctx.os << "#include " << endl; + + if (ctx.validation) + ctx.os << "#include " << endl + << endl; + else + ctx.os << endl; + + bool import_maps (ctx.options.import_maps ()); + bool export_maps (ctx.options.export_maps ()); + + if (import_maps || export_maps) + { + ctx.os << "#ifndef XSD_NO_EXPORT" << endl + << endl + << "namespace xsd" + << "{" + << "namespace cxx" + << "{" + << "namespace parser" + << "{" + << "#ifdef _MSC_VER" << endl; + + if (export_maps) + ctx.os << "template struct __declspec (dllexport) " << + "substitution_map_init< " << ctx.char_type << " >;"; + + if (import_maps) + ctx.os << "template struct __declspec (dllimport) " << + "substitution_map_init< " << ctx.char_type << " >;"; + + if (ctx.validation && export_maps) + ctx.os << "template struct __declspec (dllexport) " << + "inheritance_map_init< " << ctx.char_type << " >;"; + + if (ctx.validation && import_maps) + ctx.os << "template struct __declspec (dllimport) " << + "inheritance_map_init< " << ctx.char_type << " >;"; + + ctx.os << "#elif defined(__GNUC__) && __GNUC__ >= 4" << endl + << "template struct __attribute__ ((visibility(\"default\"))) " << + "substitution_map_init< " << ctx.char_type << " >;"; + + if (ctx.validation) + ctx.os << "template struct __attribute__ ((visibility(\"default\"))) " << + "inheritance_map_init< " << ctx.char_type << " >;"; + + ctx.os << "#elif defined(XSD_MAP_VISIBILITY)" << endl + << "template struct XSD_MAP_VISIBILITY " << + "substitution_map_init< " << ctx.char_type << " >;"; + + if (ctx.validation) + ctx.os << "template struct XSD_MAP_VISIBILITY " << + "inheritance_map_init< " << ctx.char_type << " >;"; + + ctx.os << "#endif" << endl + << "}" // parser + << "}" // cxx + << "}" // xsd + << "#endif // XSD_NO_EXPORT" << endl + << endl; + } + + ctx.os << "static" << endl + << "const ::xsd::cxx::parser::substitution_map_init< " << + ctx.char_type << " >" << endl + << "_xsd_substitution_map_init_;" + << endl; + + if (ctx.validation) + { + ctx.os << "static" << endl + << "const ::xsd::cxx::parser::validating::inheritance_map_init< " << + ctx.char_type << " >" << endl + << "_xsd_inheritance_map_init_;" + << endl; + } + } + + // Emit "weak" header includes that are used in the file-per-type + // compilation model. + // + if (ctx.options.generate_inline ()) + { + Traversal::Schema schema; + Includes includes (ctx, Includes::source); + + schema >> includes; + schema.dispatch (ctx.schema_root); + } + + Traversal::Schema schema; + Sources sources; + Traversal::Names schema_names; + + Namespace ns (ctx); + Traversal::Names names; + + schema >> sources >> schema; + schema >> schema_names >> ns >> names; + + List list (ctx); + Union union_ (ctx); + Complex complex (ctx); + Enumeration enumeration (ctx); + GlobalElement global_element (ctx); + + names >> list; + names >> union_; + names >> complex; + names >> enumeration; + + if (ctx.polymorphic) + names >> global_element; + + schema.dispatch (ctx.schema_root); + } + } +} diff --git a/xsd/xsd/cxx/parser/parser-source.hxx b/xsd/xsd/cxx/parser/parser-source.hxx new file mode 100644 index 0000000..3598a00 --- /dev/null +++ b/xsd/xsd/cxx/parser/parser-source.hxx @@ -0,0 +1,18 @@ +// file : xsd/cxx/parser/parser-source.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_PARSER_PARSER_SOURCE_HXX +#define XSD_CXX_PARSER_PARSER_SOURCE_HXX + +#include + +namespace CXX +{ + namespace Parser + { + void + generate_parser_source (Context&); + } +} + +#endif // XSD_CXX_PARSER_PARSER_SOURCE_HXX diff --git a/xsd/xsd/cxx/parser/print-impl-common.hxx b/xsd/xsd/cxx/parser/print-impl-common.hxx new file mode 100644 index 0000000..14bfbc2 --- /dev/null +++ b/xsd/xsd/cxx/parser/print-impl-common.hxx @@ -0,0 +1,641 @@ +// file : xsd/cxx/parser/print-impl-common.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_PARSER_PRINT_IMPL_COMMON_HXX +#define XSD_CXX_PARSER_PRINT_IMPL_COMMON_HXX + +#include +#include + +#include + +namespace CXX +{ + namespace Parser + { + struct PrintCall: Traversal::Type, + + Traversal::Fundamental::Boolean, + + Traversal::Fundamental::Byte, + Traversal::Fundamental::UnsignedByte, + Traversal::Fundamental::Short, + Traversal::Fundamental::UnsignedShort, + Traversal::Fundamental::Int, + Traversal::Fundamental::UnsignedInt, + Traversal::Fundamental::Long, + Traversal::Fundamental::UnsignedLong, + Traversal::Fundamental::Integer, + Traversal::Fundamental::NonPositiveInteger, + Traversal::Fundamental::NonNegativeInteger, + Traversal::Fundamental::PositiveInteger, + Traversal::Fundamental::NegativeInteger, + + Traversal::Fundamental::Float, + Traversal::Fundamental::Double, + Traversal::Fundamental::Decimal, + + Traversal::Fundamental::String, + Traversal::Fundamental::NormalizedString, + Traversal::Fundamental::Token, + Traversal::Fundamental::Name, + Traversal::Fundamental::NameToken, + Traversal::Fundamental::NameTokens, + Traversal::Fundamental::NCName, + Traversal::Fundamental::Language, + + Traversal::Fundamental::QName, + + Traversal::Fundamental::Id, + Traversal::Fundamental::IdRef, + Traversal::Fundamental::IdRefs, + + Traversal::Fundamental::AnyURI, + + Traversal::Fundamental::Base64Binary, + Traversal::Fundamental::HexBinary, + + Traversal::Fundamental::Date, + Traversal::Fundamental::DateTime, + Traversal::Fundamental::Duration, + Traversal::Fundamental::Day, + Traversal::Fundamental::Month, + Traversal::Fundamental::MonthDay, + Traversal::Fundamental::Year, + Traversal::Fundamental::YearMonth, + Traversal::Fundamental::Time, + + Context + { + PrintCall (Context& c, String const& tag, String const& arg) + : Context (c), tag_ (tag), arg_ (arg) + { + } + + virtual void + traverse (SemanticGraph::Type&) + { + gen_user_type (); + } + + // Boolean. + // + virtual void + traverse (SemanticGraph::Fundamental::Boolean& t) + { + if (default_type (t, "bool")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << + arg_ << " << std::endl;"; + } + else + gen_user_type (); + } + + // Integral types. + // + virtual void + traverse (SemanticGraph::Fundamental::Byte& t) + { + if (default_type (t, "signed char")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << + " << static_cast (" << arg_ << ") << std::endl;"; + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedByte& t) + { + if (default_type (t, "unsigned char")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << + " << static_cast (" << arg_ << ") << std::endl;"; + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::Short& t) + { + if (default_type (t, "short")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << + arg_ << " << std::endl;"; + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedShort& t) + { + if (default_type (t, "unsigned short")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << + arg_ << " << std::endl;"; + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::Int& t) + { + if (default_type (t, "int")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << + arg_ << " << std::endl;"; + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedInt& t) + { + if (default_type (t, "unsigned int")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << + arg_ << " << std::endl;"; + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::Long& t) + { + if (default_type (t, "long long")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << + arg_ << " << std::endl;"; + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedLong& t) + { + if (default_type (t, "unsigned long long")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << + arg_ << " << std::endl;"; + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::Integer& t) + { + if (default_type (t, "long long")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << + arg_ << " << std::endl;"; + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::NegativeInteger& t) + { + if (default_type (t, "long long")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << + arg_ << " << std::endl;"; + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) + { + if (default_type (t, "long long")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << + arg_ << " << std::endl;"; + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::PositiveInteger& t) + { + if (default_type (t, "unsigned long long")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << + arg_ << " << std::endl;"; + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) + { + if (default_type (t, "unsigned long long")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << + arg_ << " << std::endl;"; + } + else + gen_user_type (); + } + + // Floats. + // + virtual void + traverse (SemanticGraph::Fundamental::Float& t) + { + if (default_type (t, "float")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << + arg_ << " << std::endl;"; + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::Double& t) + { + if (default_type (t, "double")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << + arg_ << " << std::endl;"; + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::Decimal& t) + { + if (default_type (t, "double")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << + arg_ << " << std::endl;"; + } + else + gen_user_type (); + } + + // Strings. + // + virtual void + traverse (SemanticGraph::Fundamental::String& t) + { + gen_string (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::NormalizedString& t) + { + gen_string (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Token& t) + { + gen_string (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::NameToken& t) + { + gen_string (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Name& t) + { + gen_string (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::NCName& t) + { + gen_string (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Language& t) + { + gen_string (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Id& t) + { + gen_string (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::IdRef& t) + { + gen_string (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::AnyURI& t) + { + gen_string (t); + } + + // String sequences. + // + + virtual void + traverse (SemanticGraph::Fundamental::NameTokens& t) + { + gen_sequence (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::IdRefs& t) + { + gen_sequence (t); + } + + // QName + // + + virtual void + traverse (SemanticGraph::Fundamental::QName& t) + { + if (default_type (t, xs_ns_name () + L"::qname")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << ";" + << endl + << "if (" << arg_ << ".prefix ().empty ())" << endl + << cout_inst << " << " << arg_ << ".name ();" + << "else" << endl + << cout_inst << " << " << arg_ << ".prefix () << " << L << + "':' << " << arg_ << ".name ();" + << endl + << cout_inst << " << std::endl;"; + } + else + gen_user_type (); + } + + // Binary. + // + virtual void + traverse (SemanticGraph::Fundamental::Base64Binary& t) + { + gen_buffer (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::HexBinary& t) + { + gen_buffer (t); + } + + // Date/time. + // + virtual void + traverse (SemanticGraph::Fundamental::Date& t) + { + if (default_type (t, xs_ns_name () + L"::date")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << endl + << " << " << arg_ << ".year () << '-'" << endl + << " << " << arg_ << ".month () << '-'" << endl + << " << " << arg_ << ".day ();"; + + gen_time_zone (); + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::DateTime& t) + { + if (default_type (t, xs_ns_name () + L"::date_time")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << endl + << " << " << arg_ << ".year () << '-'" << endl + << " << " << arg_ << ".month () << '-'" << endl + << " << " << arg_ << ".day () << 'T'" << endl + << " << " << arg_ << ".hours () << ':'" << endl + << " << " << arg_ << ".minutes () << ':'" << endl + << " << " << arg_ << ".seconds ();"; + + gen_time_zone (); + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::Duration& t) + { + if (default_type (t, xs_ns_name () + L"::duration")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << ";" + << endl + << "if (" << arg_ << ".negative ())" << endl + << cout_inst << " << '-';" + << endl + << cout_inst << " << 'P'" << endl + << " << " << arg_ << ".years () << 'Y'" << endl + << " << " << arg_ << ".months () << 'M'" << endl + << " << " << arg_ << ".days () << " << L << "\"DT\"" << endl + << " << " << arg_ << ".hours () << 'H'" << endl + << " << " << arg_ << ".minutes () << 'M'" << endl + << " << " << arg_ << ".seconds () << 'S'" + << " << std::endl;"; + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::Day& t) + { + if (default_type (t, xs_ns_name () + L"::gday")) + { + os << cout_inst << " << " << strlit (tag_ + L": ---") << + " << " << arg_ << ".day ();"; + + gen_time_zone (); + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::Month& t) + { + if (default_type (t, xs_ns_name () + L"::gmonth")) + { + os << cout_inst << " << " << strlit (tag_ + L": --") << + " << " << arg_ << ".month ();"; + + gen_time_zone (); + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::MonthDay& t) + { + if (default_type (t, xs_ns_name () + L"::gmonth_day")) + { + os << cout_inst << " << " << strlit (tag_ + L": --") << endl + << " << " << arg_ << ".month () << '-'" << endl + << " << " << arg_ << ".day ();"; + + gen_time_zone (); + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::Year& t) + { + if (default_type (t, xs_ns_name () + L"::gyear")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << + arg_ << ".year ();"; + + gen_time_zone (); + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::YearMonth& t) + { + if (default_type (t, xs_ns_name () + L"::gyear_month")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << endl + << " << " << arg_ << ".year () << '-'" << endl + << " << " << arg_ << ".month ();"; + + gen_time_zone (); + } + else + gen_user_type (); + } + + virtual void + traverse (SemanticGraph::Fundamental::Time& t) + { + if (default_type (t, xs_ns_name () + L"::time")) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << endl + << " << " << arg_ << ".hours () << ':'" << endl + << " << " << arg_ << ".minutes () << ':'" << endl + << " << " << arg_ << ".seconds ();"; + + gen_time_zone (); + } + else + gen_user_type (); + } + + private: + bool + default_type (SemanticGraph::Type& t, String const& def_type) + { + return ret_type (t) == def_type; + } + + void + gen_user_type () + { + os << "// TODO" << endl + << "//" << endl; + } + + void + gen_string (SemanticGraph::Type& t) + { + if ((char_type == L"char" && default_type (t, "::std::string")) || + (char_type == L"wchar_t" && default_type (t, "::std::wstring"))) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << " << " << + arg_ << " << std::endl;"; + } + else + gen_user_type (); + } + + void + gen_sequence (SemanticGraph::Type& t) + { + String type (xs_ns_name () + L"::string_sequence"); + + if (default_type (t, type)) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << ";" + << endl; + + os << "for (" << type << "::const_iterator i (" << arg_ << + ".begin ()), e (" << arg_ << ".end ());" << endl + << "i != e;)" + << "{" + << cout_inst << " << *i++;" + << "if (i != e)" << endl + << cout_inst << " << ' ';" + << "}" + << cout_inst << " << std::endl;"; + } + else + gen_user_type (); + } + + void + gen_buffer (SemanticGraph::Type& t) + { + String type (auto_ptr + L"< " + xs_ns_name () + L"::buffer >"); + + if (default_type (t, type)) + { + os << cout_inst << " << " << strlit (tag_ + L": ") << " << " + << arg_ << "->size () << " << L << "\" bytes\" << std::endl;"; + } + else + gen_user_type (); + } + + void + gen_time_zone () + { + os << endl + << "if (" << arg_ << ".zone_present ())" + << "{" + << "if (" << arg_ << ".zone_hours () < 0)" << endl + << cout_inst << " << " << arg_ << ".zone_hours () << ':' << -" << + arg_ << ".zone_minutes ();" + << "else" << endl + << cout_inst << " << '+' << " << arg_ << ".zone_hours () << " << + "':' << " << arg_ << ".zone_minutes ();"; + + os << "}" + << cout_inst << " << std::endl;"; + } + + private: + String tag_; + String arg_; + }; + } +} + +#endif // XSD_CXX_PARSER_PRINT_IMPL_COMMON_HXX diff --git a/xsd/xsd/cxx/parser/state-processor.cxx b/xsd/xsd/cxx/parser/state-processor.cxx new file mode 100644 index 0000000..b380895 --- /dev/null +++ b/xsd/xsd/cxx/parser/state-processor.cxx @@ -0,0 +1,319 @@ +// file : xsd/cxx/parser/state-processor.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include + +#include + +#include + +#include +#include + +using namespace std; + +namespace CXX +{ + namespace Parser + { + namespace + { + typedef vector Particles; + + /* + void + print (Particles const& p) + { + using std::wcerr; + using std::endl; + + wcerr << "prefixes: " << endl; + + for (Particles::const_iterator i (p.begin ()); i != p.end (); ++i) + { + if (SemanticGraph::Element* e = + dynamic_cast (*i)) + { + wcerr << e->name () << endl; + } + else + { + wcerr << "" << endl; + } + } + + wcerr << endl; + } + */ + + // + // + struct Particle: Traversal::All, + Traversal::Choice, + Traversal::Sequence + { + Particle (size_t& all, + size_t& choice, + size_t& sequence, + size_t& depth) + : all_ (all), + choice_ (choice), + sequence_ (sequence), + depth_ (depth) + { + } + + virtual void + traverse (SemanticGraph::All& a) + { + using SemanticGraph::Compositor; + + // Go over particles, collecting "prefix" particles in prefixes_, + // assigning state numbers and calculating effective minOccurs. + // If all prefixes of this compositor have minOccurs = 0, then + // the compositor itself effectively has minOccurs = 0 regardless + // of the actual value specified in the schema. + // + // Note that we don't need to care about depth since the 'all' + // compositor cannot contain any nested compositors. + // + + size_t state (0); + size_t min (0); + + for (Compositor::ContainsIterator ci (a.contains_begin ()); + ci != a.contains_end (); ++ci) + { + SemanticGraph::Particle& p (ci->particle ()); + + // The 'all' compositor can only include elements. + // + prefixes_.push_back (&p); + + if (min == 0 && ci->min () != 0) + min = 1; + + p.context ().set ("prefix", true); + p.context ().set ("state", state++); + } + + if (!prefixes_.empty ()) + { + a.context ().set ("comp-number", choice_++); + a.context ().set ("prefixes", prefixes_); + a.context ().set ("state-count", size_t (prefixes_.size ())); + + // effective-min = min * actual-min + // + if (min == 1) + min = a.min (); + + a.context ().set ("effective-min", min); + + // print (prefixes_); + } + } + + virtual void + traverse (SemanticGraph::Choice& c) + { + using SemanticGraph::Compositor; + + // Go over particles, collecting "prefix" particles in prefixes_, + // assigning state numbers and calculating effective minOccurs. + // If any prefix of this compositor have minOccurs = 0, then the + // compositor itself effectively has minOccurs = 0 regardless of + // the actual value specified in the schema. + // + + size_t state (0); + size_t min (1); + + for (Compositor::ContainsIterator ci (c.contains_begin ()); + ci != c.contains_end (); ++ci) + { + SemanticGraph::Particle& p (ci->particle ()); + + if (p.is_a () || + p.is_a ()) + { + prefixes_.push_back (&p); + + if (min == 1 && ci->min () == 0) + min = 0; + } + else + { + size_t depth (0); + Particle t (all_, choice_, sequence_, depth); + t.dispatch (p); + + if (t.prefixes_.empty ()) + continue; // Skip empty compositors. + + if (++depth > depth_) // One for this compositor. + depth_ = depth; + + prefixes_.insert (prefixes_.end (), + t.prefixes_.begin ().base (), + t.prefixes_.end ().base ()); + + if (min == 1 && + p.context ().get ("effective-min") == 0) + min = 0; + } + + p.context ().set ("prefix", true); + p.context ().set ("state", state++); + } + + if (!prefixes_.empty ()) + { + c.context ().set ("comp-number", choice_++); + c.context ().set ("prefixes", prefixes_); + + // effective-min = min * actual-min + // + if (min == 1) + min = c.min (); + + c.context ().set ("effective-min", min); + + // print (prefixes_); + } + } + + virtual void + traverse (SemanticGraph::Sequence& s) + { + using SemanticGraph::Compositor; + + // Go over particles, collecting "prefix" particles in prefixes_, + // assigning state numbers and calculating effective minOccurs. + // If all prefixes of this compositor have minOccurs = 0, then + // the compositor itself effectively has minOccurs = 0 regardless + // of the actual value specified in the schema. + // + + bool prefix (true); + size_t state (0); + size_t min (0); + + for (Compositor::ContainsIterator ci (s.contains_begin ()); + ci != s.contains_end (); ++ci) + { + SemanticGraph::Particle& p (ci->particle ()); + + if (p.is_a () || + p.is_a ()) + { + if (prefix) + { + prefixes_.push_back (&p); + + if (ci->min () != 0) + min = 1; + } + } + else + { + size_t depth (0); + Particle t (all_, choice_, sequence_, depth); + t.dispatch (p); + + if (t.prefixes_.empty ()) + continue; // Skip empty compositors. + + if (++depth > depth_) // One for this compositor. + depth_ = depth; + + if (prefix) + { + prefixes_.insert (prefixes_.end (), + t.prefixes_.begin ().base (), + t.prefixes_.end ().base ()); + + if (p.context ().get ("effective-min") != 0) + min = 1; + } + } + + p.context ().set ("state", state++); + + if (prefix) + p.context ().set ("prefix", true); + + if (prefix && min != 0) + prefix = false; + } + + if (!prefixes_.empty ()) + { + s.context ().set ("comp-number", sequence_++); + s.context ().set ("prefixes", prefixes_); + + // effective-min = min * actual-min + // + if (min == 1) + min = s.min (); + + s.context ().set ("effective-min", min); + + // print (prefixes_); + } + } + + private: + Particles prefixes_; + + size_t& all_; + size_t& choice_; + size_t& sequence_; + + size_t& depth_; + }; + + + // + // + struct Complex: Traversal::Complex + { + virtual void + traverse (Type& c) + { + if (c.contains_compositor_p ()) + { + size_t all (0), choice (0), sequence (0), depth (0); + Particle t (all, choice, sequence, depth); + t.dispatch (c.contains_compositor ().compositor ()); + + // Set the maximum stack depth for this type. Used to + // allocate fixed-size state stack. + // + c.context ().set ("depth", depth + 1); + } + } + }; + } + + void StateProcessor:: + process (SemanticGraph::Schema& tu, SemanticGraph::Path const&) + { + Traversal::Schema schema; + Sources sources; + Traversal::Names schema_names; + Traversal::Namespace ns; + Traversal::Names ns_names; + + schema >> sources >> schema; + schema >> schema_names >> ns >> ns_names; + + Complex complex_type; + + ns_names >> complex_type; + + schema.dispatch (tu); + } + } +} diff --git a/xsd/xsd/cxx/parser/state-processor.hxx b/xsd/xsd/cxx/parser/state-processor.hxx new file mode 100644 index 0000000..eacc14a --- /dev/null +++ b/xsd/xsd/cxx/parser/state-processor.hxx @@ -0,0 +1,25 @@ +// file : xsd/cxx/parser/state-processor.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_PARSER_STATE_PROCESSOR_HXX +#define XSD_CXX_PARSER_STATE_PROCESSOR_HXX + +#include + +#include + +namespace CXX +{ + namespace Parser + { + class StateProcessor + { + public: + void + process (XSDFrontend::SemanticGraph::Schema&, + XSDFrontend::SemanticGraph::Path const& file); + }; + } +} + +#endif // XSD_CXX_PARSER_STATE_PROCESSOR_HXX diff --git a/xsd/xsd/cxx/parser/type-processor.cxx b/xsd/xsd/cxx/parser/type-processor.cxx new file mode 100644 index 0000000..6496b2a --- /dev/null +++ b/xsd/xsd/cxx/parser/type-processor.cxx @@ -0,0 +1,347 @@ +// file : xsd/cxx/parser/type-processor.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include +#include + +#include +#include + +using namespace std; + +namespace CXX +{ + namespace Parser + { + namespace + { + // + // + struct Type: Traversal::Type + { + Type (SemanticGraph::Schema& schema, + TypeMap::Namespaces& type_map, + bool add_includes) + : schema_ (schema), + type_map_ (type_map), + add_includes_ (add_includes) + { + } + + virtual void + traverse (SemanticGraph::Type& type) + { + using TypeMap::Namespace; + using TypeMap::Namespaces; + + SemanticGraph::Context& tc (type.context ()); + + // There are two situations where we may try to process the + // same type more than once. The first is when the type is + // used in several element declarations in the same schema. + // The second situation only occurs when we are in the file- + // per-type mode. In this case the type was processed as part + // of another root schema. In the second case, while the ret + // and arg types are assumed to be the same, we need to re- + // match the type in order to add include directives to the + // new root schema. + // + bool set (true); + + if (tc.count ("ret-type")) + { + SemanticGraph::Schema* s ( + tc.get ("root-schema")); + + if (&schema_ == s) + return; + + set = false; + } + + SemanticGraph::Namespace& ns ( + dynamic_cast (type.scope ())); + + String ns_name (ns.name ()); + String t_name (type.name ()); + + //std::wcerr << "traversing: " << ns_name << "#" << t_name << endl; + + for (Namespaces::const_iterator n (type_map_.begin ()); + n != type_map_.end (); ++n) + { + // Check if the namespace matches. + // + bool ns_match; + + if (!n->xsd_name ().empty ()) + { + ns_match = n->xsd_name ().match (ns_name); + } + else + ns_match = ns_name.empty (); + + //std::wcerr << "considering ns expr: " << n->xsd_name () + // << " for " << ns_name + // << ": " << (ns_match ? "+" : "-") << endl; + + if (ns_match) + { + // Namespace matched. See if there is a type that matches. + // + for (Namespace::TypesIterator t (n->types_begin ()); + t != n->types_end (); ++t) + { + if (t->xsd_name ().match (t_name)) + { + if (set) + { + // Got a match. See if the namespace has the C++ + // namespace mapping. + // + String cxx_ns; + + if (n->has_cxx_name ()) + { + if (!n->xsd_name ().empty ()) + { + cxx_ns = n->xsd_name ().replace ( + ns_name, n->cxx_name (), true); + } + else + cxx_ns = n->cxx_name (); + + cxx_ns += L"::"; + } + + // Figure out ret and arg type names. + // + String ret_type (cxx_ns); + + ret_type += t->xsd_name ().replace ( + t_name, t->cxx_ret_name (), true); + + String arg_type; + + if (t->cxx_arg_name ()) + { + arg_type = cxx_ns; + arg_type += t->xsd_name ().replace ( + t_name, t->cxx_arg_name (), true); + } + else + { + if (ret_type == L"void") + arg_type = ret_type; + else + { + wchar_t last (ret_type[ret_type.size () - 1]); + + // If it is already a pointer or reference then use + // it as is. + // + if (last == L'*' || last == L'&') + arg_type = ret_type; + else + arg_type = L"const " + ret_type + L"&"; + } + } + + tc.set ("ret-type", ret_type); + tc.set ("arg-type", arg_type); + + //std::wcerr << t_name << " -> " << ret_type << endl; + } + + tc.set ("root-schema", &schema_); + + // See of we need to add any includes to the translations + // unit. + // + if (add_includes_) + { + if (n->includes_begin () != n->includes_end ()) + { + typedef std::set Includes; + + if (!schema_.context ().count ("includes")) + schema_.context ().set ("includes", Includes ()); + + Includes& is ( + schema_.context ().get ("includes")); + + for (Namespace::IncludesIterator i (n->includes_begin ()); + i != n->includes_end (); ++i) + { + is.insert (*i); + } + } + } + + return; + } + } + } + } + } + + private: + SemanticGraph::Schema& schema_; + TypeMap::Namespaces& type_map_; + bool add_includes_; + }; + + + // + // + struct GlobalType: Traversal::Type, + Traversal::List, + Traversal::Complex, + Traversal::Enumeration + { + GlobalType (SemanticGraph::Schema& schema, + TypeMap::Namespaces& type_map, + bool add_includes) + : type_ (schema, type_map, add_includes) + { + inherits_ >> type_; + names_ >> instance_ >> belongs_ >> type_; + argumented_ >> type_; + } + + virtual void + traverse (SemanticGraph::Type& t) + { + type_.traverse (t); + } + + virtual void + traverse (SemanticGraph::List& l) + { + type_.traverse (l); + Traversal::List::argumented (l, argumented_); + } + + virtual void + traverse (SemanticGraph::Complex& c) + { + type_.traverse (c); + Complex::inherits (c, inherits_); + Complex::names (c, names_); + } + + virtual void + traverse (SemanticGraph::Enumeration& e) + { + type_.traverse (e); + Complex::inherits (e, inherits_); + } + + private: + Parser::Type type_; + Traversal::Names names_; + Traversal::Instance instance_; + Traversal::Inherits inherits_; + Traversal::Belongs belongs_; + Traversal::Argumented argumented_; + }; + + void + process_impl (options const& ops, + XSDFrontend::SemanticGraph::Schema& tu, + bool gen_driver, + TypeMap::Namespaces& type_map) + { + if (tu.names_begin ()->named ().name () == + L"http://www.w3.org/2001/XMLSchema") + { + // XML Schema namespace. + // + Traversal::Schema schema; + + Traversal::Names schema_names; + Traversal::Namespace ns; + Traversal::Names ns_names; + GlobalType global_type (tu, type_map, true); + + schema >> schema_names >> ns >> ns_names >> global_type; + + schema.dispatch (tu); + } + else + { + // If --extern-xml-schema is specified, then we don't want + // includes from the XML Schema type map. + // + bool extern_xml_schema (ops.extern_xml_schema ()); + + // + // + Traversal::Schema schema; + Traversal::Schema xs_schema; + Sources sources; + Traversal::Implies implies; + + schema >> sources >> schema; + schema >> implies >> xs_schema; + + Traversal::Names schema_names; + Traversal::Namespace ns; + Traversal::Names ns_names; + GlobalType global_type (tu, type_map, true); + + schema >> schema_names >> ns >> ns_names >> global_type; + + Traversal::Names xs_schema_names; + Traversal::Namespace xs_ns; + Traversal::Names xs_ns_names; + GlobalType xs_global_type (tu, type_map, !extern_xml_schema); + + xs_schema >> xs_schema_names >> xs_ns >> xs_ns_names >> + xs_global_type; + + schema.dispatch (tu); + + // If we are generating the test driver, make sure the root + // element type is processed. + // + if (gen_driver && ops.generate_test_driver ()) + { + // Figure out the root element. Validator should have made sure + // it is unique. + // + SemanticGraph::Element* root (0); + { + Traversal::Schema schema; + Sources sources; + + schema >> sources >> schema; + + Traversal::Names schema_names; + Traversal::Namespace ns; + Traversal::Names ns_names; + RootElement root_element (ops, root); + + schema >> schema_names >> ns >> ns_names >> root_element; + + schema.dispatch (tu); + } + + global_type.dispatch (root->type ()); + } + } + } + } + + void TypeProcessor:: + process (options const& ops, + XSDFrontend::SemanticGraph::Schema& s, + bool gen_driver, + TypeMap::Namespaces& tm) + { + process_impl (ops, s, gen_driver, tm); + } + } +} diff --git a/xsd/xsd/cxx/parser/type-processor.hxx b/xsd/xsd/cxx/parser/type-processor.hxx new file mode 100644 index 0000000..6800024 --- /dev/null +++ b/xsd/xsd/cxx/parser/type-processor.hxx @@ -0,0 +1,31 @@ +// file : xsd/cxx/parser/type-processor.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_PARSER_TYPE_PROCESSOR_HXX +#define XSD_CXX_PARSER_TYPE_PROCESSOR_HXX + +#include + +#include + +#include + +#include + +namespace CXX +{ + namespace Parser + { + class TypeProcessor + { + public: + void + process (options const&, + XSDFrontend::SemanticGraph::Schema&, + bool gen_driver, + TypeMap::Namespaces&); + }; + } +} + +#endif // XSD_CXX_PARSER_TYPE_PROCESSOR_HXX diff --git a/xsd/xsd/cxx/parser/validator.cxx b/xsd/xsd/cxx/parser/validator.cxx new file mode 100644 index 0000000..83429cf --- /dev/null +++ b/xsd/xsd/cxx/parser/validator.cxx @@ -0,0 +1,718 @@ +// file : xsd/cxx/parser/validator.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include + +#include + +#include +#include + +#include + +using namespace std; + +namespace CXX +{ + namespace Parser + { + namespace + { + class ValidationContext: public Context + { + public: + ValidationContext (SemanticGraph::Schema& root, + SemanticGraph::Path const& path, + Parser::options const& ops, + const WarningSet& disabled_warnings, + bool& valid_) + : Context (std::wcerr, root, path, ops, 0, 0, 0, 0), + disabled_warnings_ (disabled_warnings), + disabled_warnings_all_ (false), + valid (valid_), + subst_group_warning_issued (subst_group_warning_issued_), + subst_group_warning_issued_ (false) + { + } + + public: + bool + is_disabled (char const* w) + { + return disabled_warnings_all_ || + disabled_warnings_.find (w) != disabled_warnings_.end (); + } + + public: + String + xpath (SemanticGraph::Nameable& n) + { + if (n.is_a ()) + return L""; // There is a bug if you see this. + + assert (n.named_p ()); + + SemanticGraph::Scope& scope (n.scope ()); + + if (scope.is_a ()) + return n.name (); + + return xpath (scope) + L"/" + n.name (); + } + + protected: + ValidationContext (ValidationContext& c) + : Context (c), + disabled_warnings_ (c.disabled_warnings_), + disabled_warnings_all_ (c.disabled_warnings_all_), + valid (c.valid), + subst_group_warning_issued (c.subst_group_warning_issued) + { + } + + protected: + const WarningSet& disabled_warnings_; + bool disabled_warnings_all_; + bool& valid; + bool& subst_group_warning_issued; + bool subst_group_warning_issued_; + }; + + // + // + struct Any: Traversal::Any, ValidationContext + { + Any (ValidationContext& c) + : ValidationContext (c) + { + } + + struct Element: Traversal::Element, ValidationContext + { + Element (ValidationContext& c, SemanticGraph::Any& any) + : ValidationContext (c), + any_ (any), + ns_ (any.definition_namespace ().name ()) + { + } + + virtual void + traverse (SemanticGraph::Element& e) + { + if (skip (e)) return; + + using SemanticGraph::Any; + + bool q (e.qualified_p ()); + String ns (q ? e.namespace_ ().name () : ""); + + for (Any::NamespaceIterator i (any_.namespace_begin ()); + i != any_.namespace_end (); ++i) + { + bool failed (false); + + if (*i == L"##any") + { + failed = true; + } + else if (*i == L"##other") + { + if (ns_) + { + // Note that here I assume that ##other does not + // include names without target namespace. This + // is not what the spec says but that seems to be + // the consensus. + // + failed = q && ns != ns_; + } + else + { + // No target namespace. + // + failed = q && ns != L""; + } + } + else if (*i == L"##local") + { + failed = !q || ns == L""; + } + else if (*i == L"##targetNamespace") + { + failed = (q && ns_ == ns) || (!q && ns_ == L""); + } + else + { + failed = q && *i == ns; + } + + if (failed) + { + Any& a (any_); + + os << a.file () << ":" << a.line () << ":" << a.column () + << ": warning P001: namespace '" << *i << "' allows for " + << "element '" << e.name () << "'" << endl; + + os << a.file () << ":" << a.line () << ":" << a.column () + << ": warning P001: generated code may not associate element '" + << e.name () << "' correctly if it appears in place of " + << "this wildcard" << endl; + + os << e.file () << ":" << e.line () << ":" << e.column () + << ": info: element '" << e.name () << "' is defined " + << "here" << endl; + + os << a.file () << ":" << a.line () << ":" << a.column () + << ": info: turn on validation to ensure correct " + << "association" << endl; + } + } + } + + private: + SemanticGraph::Any& any_; + String ns_; + }; + + struct Complex: Traversal::Complex + { + Complex () + : up_ (true), down_ (true) + { + } + + virtual void + post (Type& c) + { + // Go down the inheritance hierarchy. + // + if (down_) + { + bool up = up_; + up_ = false; + + if (c.inherits_p ()) + dispatch (c.inherits ().base ()); + + up_ = up; + } + + // Go up the inheritance hierarchy. + // + if (up_) + { + bool down = down_; + down_ = false; + + for (Type::BegetsIterator i (c.begets_begin ()); + i != c.begets_end (); ++i) + { + dispatch (i->derived ()); + } + + down_ = down; + } + } + + private: + bool up_, down_; + }; + + virtual void + traverse (SemanticGraph::Any& a) + { + using SemanticGraph::Compositor; + + // Find our complex type. + // + Compositor* c (&a.contained_particle ().compositor ()); + + while(!c->contained_compositor_p ()) + c = &c->contained_particle ().compositor (); + + SemanticGraph::Complex& type ( + dynamic_cast ( + c->contained_compositor ().container ())); + + Complex complex; + Traversal::Names names; + Element element (*this, a); + + complex >> names >> element; + + complex.dispatch (type); + } + }; + + + // + // + struct Traverser: Traversal::Schema, + Traversal::Complex, + Traversal::Type, + Traversal::Element, + ValidationContext + { + Traverser (ValidationContext& c) + : ValidationContext (c), + any_ (c) + { + *this >> sources_ >> *this; + *this >> schema_names_ >> ns_ >> names_ >> *this; + + // Any + // + if (!validation && !is_disabled ("P001")) + { + *this >> contains_compositor_ >> compositor_ >> contains_particle_; + contains_particle_ >> compositor_; + contains_particle_ >> any_; + } + } + + virtual void + traverse (SemanticGraph::Complex& c) + { + using SemanticGraph::Schema; + + traverse (static_cast (c)); + + if (c.inherits_p ()) + { + SemanticGraph::Type& t (c.inherits ().base ()); + + if (t.named_p () && + types_.find ( + t.scope ().name () + L"#" + t.name ()) == types_.end ()) + { + // Don't worry about types that are in included/imported + // schemas. + // + Schema& s (dynamic_cast (t.scope ().scope ())); + + if (&s == &schema_root || sources_p (schema_root, s)) + { + valid = false; + + wcerr << c.file () << ":" << c.line () << ":" << c.column () + << ": error: type '" << xpath (c) << "' inherits from " + << "yet undefined type '" << xpath (t) << "'" << endl; + + wcerr << t.file () << ":" << t.line () << ":" << t.column () + << ": info: '" << xpath (t) << "' is defined here" + << endl; + + wcerr << c.file () << ":" << c.line () << ":" << c.column () + << ": info: inheritance from a yet-undefined type is " + << "not supported" << endl; + + wcerr << c.file () << ":" << c.line () << ":" << c.column () + << ": info: re-arrange your schema and try again" + << endl; + } + } + } + + Complex::traverse (c); + } + + virtual void + traverse (SemanticGraph::Type& t) + { + if (t.named_p ()) + { + types_.insert (t.scope ().name () + L"#" + t.name ()); + } + } + + virtual void + traverse (SemanticGraph::Element& e) + { + if (is_disabled ("P002")) + return; + + if (e.substitutes_p () && + !options.generate_polymorphic () && + !subst_group_warning_issued) + { + subst_group_warning_issued = true; + + os << e.file () << ":" << e.line () << ":" << e.column () + << ": warning P002: substitution groups are used but " + << "--generate-polymorphic was not specified" << endl; + + os << e.file () << ":" << e.line () << ":" << e.column () + << ": info: generated code may not be able to parse " + << "some conforming instances" << endl; + } + } + + // Return true if root sources s. + // + bool + sources_p (SemanticGraph::Schema& root, SemanticGraph::Schema& s) + { + using SemanticGraph::Schema; + using SemanticGraph::Sources; + + for (Schema::UsesIterator i (root.uses_begin ()); + i != root.uses_end (); ++i) + { + if (i->is_a ()) + { + if (&i->schema () == &s || sources_p (i->schema (), s)) + return true; + } + } + + return false; + } + + private: + set types_; + + Sources sources_; + + Traversal::Names schema_names_; + Traversal::Namespace ns_; + + Traversal::Names names_; + + // Any. + // + Any any_; + Traversal::Compositor compositor_; + Traversal::ContainsParticle contains_particle_; + Traversal::ContainsCompositor contains_compositor_; + }; + + + struct AnonymousType: Traversal::Schema, + Traversal::Complex, + Traversal::Element, + Traversal::Attribute, + ValidationContext + { + AnonymousType (ValidationContext& c) + : ValidationContext (c), + anonymous_error_issued_ (false) + { + *this >> sources_ >> *this; + *this >> schema_names_ >> ns_ >> names_ >> *this; + *this >> names_; + } + + bool + traverse_common (SemanticGraph::Member& m) + { + SemanticGraph::Type& t (m.type ()); + + if (!t.named_p () + && !t.is_a () + && !t.is_a ()) + { + if (!anonymous_error_issued_) + { + valid = false; + anonymous_error_issued_ = true; + + wcerr << t.file () + << ": error: anonymous types detected" + << endl; + + wcerr << t.file () + << ": info: " + << "anonymous types are not supported in this mapping" + << endl; + + wcerr << t.file () + << ": info: consider explicitly naming these types or " + << "remove the --preserve-anonymous option to " + << "automatically name them" + << endl; + + if (!options.show_anonymous ()) + wcerr << t.file () + << ": info: use --show-anonymous option to see these " + << "types" << endl; + } + + return true; + } + + return false; + } + + virtual void + traverse (SemanticGraph::Element& e) + { + if (skip (e)) return; + + if (traverse_common (e)) + { + if (options.show_anonymous ()) + { + wcerr << e.file () << ":" << e.line () << ":" << e.column () + << ": error: element '" << xpath (e) << "' " + << "is of anonymous type" << endl; + } + } + else + Traversal::Element::traverse (e); + } + + virtual void + traverse (SemanticGraph::Attribute& a) + { + if (traverse_common (a)) + { + if (options.show_anonymous ()) + { + wcerr << a.file () << ":" << a.line () << ":" << a.column () + << ": error: attribute '" << xpath (a) << "' " + << "is of anonymous type" << endl; + } + } + else + Traversal::Attribute::traverse (a); + } + + private: + bool anonymous_error_issued_; + + set types_; + + Sources sources_; + + Traversal::Names schema_names_; + Traversal::Namespace ns_; + + Traversal::Names names_; + }; + + struct GlobalElement: Traversal::Element, ValidationContext + { + GlobalElement (ValidationContext& c, SemanticGraph::Element*& element) + : ValidationContext (c), element_ (element) + { + } + + virtual void + traverse (Type& e) + { + if (!valid) + return; + + if (options.root_element_first ()) + { + if (element_ == 0) + element_ = &e; + } + else if (options.root_element_last ()) + { + element_ = &e; + } + else if (String name = options.root_element ()) + { + if (e.name () == name) + element_ = &e; + } + else + { + if (element_ == 0) + element_ = &e; + else + { + wcerr << schema_root.file () << ": error: unable to generate " + << "the test driver without a unique document root" + << endl; + + wcerr << schema_root.file () << ": info: use --root-element-* " + << "options to specify the document root" << endl; + + valid = false; + } + } + } + + private: + SemanticGraph::Element*& element_; + }; + + } + + bool Validator:: + validate (options const& ops, + SemanticGraph::Schema& root, + SemanticGraph::Path const& path, + bool gen_driver, + const WarningSet& disabled_warnings) + { + bool valid (true); + ValidationContext ctx (root, path, ops, disabled_warnings, valid); + + // + // + if (ops.char_type () != "char" && + ops.char_type () != "wchar_t" && + !ctx.is_disabled ("P003")) + { + wcerr << "warning P003: unknown base character type '" << + ops.char_type ().c_str () << "'" << endl; + } + + // + // + if (ops.xml_parser () != "xerces" && + ops.xml_parser () != "expat" && + !ctx.is_disabled ("P004")) + { + wcerr << "warning P004: unknown underlying XML parser '" << + ops.xml_parser ().c_str () << "'" << endl; + } + + // + // + if (ops.xml_parser () == "expat" && + ops.char_type () == "wchar_t") + { + wcerr << "error: using expat with wchar_t is not supported" + << endl; + + return false; + } + + // + // + if (ops.xml_parser () == "expat" && + !ops.char_encoding ().empty () && + ops.char_encoding () != "utf8") + { + wcerr << "error: using expat with character encoding other than " + << "utf8 is not supported" + << endl; + + return false; + } + + // + // + if (ops.generate_validation () && ops.suppress_validation ()) + { + wcerr << "error: mutually exclusive options specified: " + << "--generate-validation and --suppress-validation" + << endl; + + return false; + } + + // + // + if (ops.generate_noop_impl () && ops.generate_print_impl ()) + { + wcerr << "error: mutually exclusive options specified: " + << "--generate-noop-impl and --generate-print-impl" + << endl; + + return false; + } + + // + // + { + bool ref (ops.root_element_first ()); + bool rel (ops.root_element_last ()); + bool re (ops.root_element ()); + + if ((ref && rel) || (ref && re) || (rel && re)) + { + wcerr << "error: mutually exclusive options specified: " + << "--root-element-last, --root-element-first, and " + << "--root-element" + << endl; + + return false; + } + } + + // + // + bool import_maps (ops.import_maps ()); + bool export_maps (ops.export_maps ()); + + if (import_maps && export_maps) + { + wcerr << "error: --import-maps and --export-maps are " + << "mutually exclusive" << endl; + + return false; + } + + if (import_maps && !ctx.polymorphic) + { + wcerr << "error: --import-maps can only be specified together with " + << "--generate-polymorphic" << endl; + + return false; + } + + if (export_maps && !ctx.polymorphic) + { + wcerr << "error: --export-maps can only be specified together with " + << "--generate-polymorphic" << endl; + + return false; + } + + // Test for anonymout types. + // + { + AnonymousType traverser (ctx); + traverser.dispatch (root); + } + + + // Test the rest. + // + if (valid) + { + Traverser traverser (ctx); + traverser.dispatch (root); + } + + // Test that the document root is unique. + // + if (valid && gen_driver) + { + SemanticGraph::Element* element (0); + + Traversal::Schema schema; + Sources sources; + + schema >> sources >> schema; + + Traversal::Names schema_names; + Traversal::Namespace ns; + Traversal::Names ns_names; + GlobalElement global_element (ctx, element); + + schema >> schema_names >> ns >> ns_names >> global_element; + + schema.dispatch (root); + + if (valid && element == 0) + { + wcerr << root.file () << ": error: unable to generate the " + << "test driver without a global element (document root)" + << endl; + + valid = false; + } + } + + return valid; + } + } +} diff --git a/xsd/xsd/cxx/parser/validator.hxx b/xsd/xsd/cxx/parser/validator.hxx new file mode 100644 index 0000000..daffdc8 --- /dev/null +++ b/xsd/xsd/cxx/parser/validator.hxx @@ -0,0 +1,30 @@ +// file : xsd/cxx/parser/validator.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_PARSER_VALIDATOR_HXX +#define XSD_CXX_PARSER_VALIDATOR_HXX + +#include +#include + +#include +#include + +namespace CXX +{ + namespace Parser + { + class Validator + { + public: + bool + validate (options const&, + SemanticGraph::Schema&, + SemanticGraph::Path const& tu, + bool gen_driver, + const WarningSet& disabled_warnings); + }; + } +} + +#endif // XSD_CXX_PARSER_VALIDATOR_HXX diff --git a/xsd/xsd/cxx/tree/counter.cxx b/xsd/xsd/cxx/tree/counter.cxx new file mode 100644 index 0000000..94bcc87 --- /dev/null +++ b/xsd/xsd/cxx/tree/counter.cxx @@ -0,0 +1,260 @@ +// file : xsd/cxx/tree/counter.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include + +namespace CXX +{ + namespace Tree + { + namespace + { + struct Member: Traversal::Member + { + Member (size_t& complexity) + : complexity_ (complexity) + { + } + + virtual void + traverse (Type&) + { + complexity_++; + } + + size_t& complexity_; + }; + + struct Any: Traversal::Any, Traversal::AnyAttribute + { + Any (size_t& complexity) + : complexity_ (complexity) + { + } + + virtual void + traverse (SemanticGraph::Any&) + { + complexity_++; + } + + virtual void + traverse (SemanticGraph::AnyAttribute&) + { + complexity_++; + } + + size_t& complexity_; + }; + + struct TypeBase: Traversal::List, + Traversal::Union, + Traversal::Enumeration, + Traversal::Complex, + Context + { + TypeBase (Context& c, size_t& complexity) + : Context (c), complexity_ (complexity) + { + } + + virtual void + traverse (SemanticGraph::List&) + { + complexity_++; + } + + virtual void + traverse (SemanticGraph::Union&) + { + complexity_++; + } + + virtual void + traverse (SemanticGraph::Enumeration& e) + { + bool string_based (false); + { + IsStringBasedType t (string_based); + t.dispatch (e); + } + + complexity_ += (string_based ? 1 : 2); + } + + virtual void + traverse (SemanticGraph::Complex& c) + { + complexity_++; // One for the type itself. + + // Plus some for each member. + // + Any any (complexity_); + Member member (complexity_); + Traversal::Names names; + + names >> member; + + if (options.generate_wildcard ()) + names >> any; + + Complex::names (c, names); + } + + private: + size_t& complexity_; + }; + + + // + // + struct GlobalType: Traversal::Type, Context + + { + GlobalType (Context& c, Counts& counts) + : Context (c), counts_ (counts) + { + } + + virtual void + traverse (SemanticGraph::Type& t) + { + counts_.global_types++; + + size_t complexity (0); + TypeBase type (*this, complexity); + type.dispatch (t); + + counts_.complexity_total += complexity; + counts_.complexity.push_back (complexity); + } + + private: + Counts& counts_; + }; + + // + // + struct GlobalElement: Traversal::Element, + GlobalElementBase, + Context + { + GlobalElement (Context& c, Counts& counts) + : GlobalElementBase (c), + Context (c), + counts_ (counts), + last_ (0) + { + } + + ~GlobalElement () + { + if (last_ != 0) + { + last_->context ().set ("last", true); + count_last (); + } + } + + virtual void + traverse (Type& e) + { + // Check if the previous element we saw needs to be generated. + // + if (last_ != 0) + count_last (); + + last_ = &e; + + if (counts_.global_elements == 0) + e.context ().set ("first", true); + + counts_.global_elements++; + } + + private: + void + count_last () + { + if (generate_p (*last_)) + { + counts_.generated_global_elements++; + + size_t complexity (0); + + if (doc_root_p (*last_)) + { + if (options.generate_element_type ()) + { + complexity += 1; // For c-tors and d-tor. + + if (!options.suppress_parsing ()) + complexity += 1; + + if (options.generate_serialization ()) + complexity += 1; + } + else + { + if (!options.suppress_parsing ()) + complexity += 6; // 13 parsing functions. + + if (options.generate_serialization ()) + complexity += 4; // 8 serialization functions. + } + } + + if (complexity == 0) + { + // This element must be a substitution group members. For + // such elements we are only generating an entry in a map. + // We will assign it a complexity of 1 so that we don't + // end up with the total complexity that is less than the + // number of elements and types. + // + complexity = 1; + } + + counts_.complexity_total += complexity; + counts_.complexity.push_back (complexity); + } + } + + private: + Counts& counts_; + SemanticGraph::Element* last_; + }; + } + + Counts Counter:: + count (options const& ops, + SemanticGraph::Schema& tu, + SemanticGraph::Path const& path) + { + Counts counts; + Context ctx (std::wcerr, tu, path, ops, counts, false, 0, 0, 0, 0); + + Traversal::Schema schema; + Sources sources; + + schema >> sources >> schema; + + Traversal::Names schema_names; + Traversal::Namespace ns; + Traversal::Names ns_names; + GlobalType global_type (ctx, counts); + GlobalElement global_element (ctx, counts); + + schema >> schema_names >> ns >> ns_names; + + ns_names >> global_element; + ns_names >> global_type; + + schema.dispatch (tu); + + return counts; + } + } +} diff --git a/xsd/xsd/cxx/tree/counter.hxx b/xsd/xsd/cxx/tree/counter.hxx new file mode 100644 index 0000000..bc1dc79 --- /dev/null +++ b/xsd/xsd/cxx/tree/counter.hxx @@ -0,0 +1,25 @@ +// file : xsd/cxx/tree/counter.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_TREE_COUNTER_HXX +#define XSD_CXX_TREE_COUNTER_HXX + +#include +#include + +namespace CXX +{ + namespace Tree + { + class Counter + { + public: + Counts + count (options const&, + SemanticGraph::Schema&, + SemanticGraph::Path const&); + }; + } +} + +#endif // XSD_CXX_TREE_COUNTER_HXX diff --git a/xsd/xsd/cxx/tree/default-value.cxx b/xsd/xsd/cxx/tree/default-value.cxx new file mode 100644 index 0000000..aefeda3 --- /dev/null +++ b/xsd/xsd/cxx/tree/default-value.cxx @@ -0,0 +1,1273 @@ +// file : xsd/cxx/tree/default-value.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +using std::hex; +using std::dec; + +namespace CXX +{ + namespace Tree + { + namespace + { + void + normalize (String& s) + { + size_t n (s.size ()); + + for (size_t i (0); i < n; ++i) + { + wchar_t& c (s[i]); + + if (c == 0x0D || // carriage return + c == 0x09 || // tab + c == 0x0A) + c = 0x20; + } + } + + void + collapse (String& s) + { + size_t n (s.size ()), j (0); + bool subs (false), trim (true); + + for (size_t i (0); i < n; ++i) + { + wchar_t c (s[i]); + + if (c == 0x20 || c == 0x09 || c == 0x0A) + subs = true; + else + { + if (subs) + { + subs = false; + + if (!trim) + s[j++] = 0x20; + } + + if (trim) + trim = false; + + s[j++] = c; + } + } + + s.resize (j); + } + + void + strip_zeros (String& s) + { + size_t n (s.size ()), i (0); + + if (n > 0 && (s[i] == '-' || s[i] == '+')) + i++; + + size_t j (i); + + bool strip (true); + + for (; i < n; ++i) + { + wchar_t c (s[i]); + + if (c == '0') + { + if (!strip) + s[j++] = c; + } + else + { + s[j++] = c; + + if (strip) + strip = false; + } + } + + if (strip && j < n) + s[j++] = '0'; // There was nothing except zeros so add one back. + + s.resize (j); + } + + void + make_float (String& s) + { + if (s.find ('.') == String::npos && + s.find ('e') == String::npos && + s.find ('E') == String::npos) + s += L".0"; + } + } + + // + // IsLiteralValue + // + + IsLiteralValue:: + IsLiteralValue (bool& r) + : IsFundamentalType (r) + { + *this >> inherits_ >> *this; + } + + void IsLiteralValue:: + traverse (SemanticGraph::Complex& c) + { + inherits (c); + } + + // + // LiteralValue + // + + LiteralValue:: + LiteralValue (Context& c) + : Context (c) + { + *this >> inherits_ >> *this; + } + + String LiteralValue:: + dispatch (SemanticGraph::Node& type, String const& value) + { + literal_.clear (); + value_ = value; + Traversal::NodeBase::dispatch (type); + return literal_; + } + + void LiteralValue:: + traverse (SemanticGraph::Complex& c) + { + inherits (c); + } + + // Boolean. + // + void LiteralValue:: + traverse (SemanticGraph::Fundamental::Boolean&) + { + collapse (value_); + literal_ = (value_ == L"true" || value_ == L"1") ? L"true" : L"false"; + } + + // Integral types. + // + void LiteralValue:: + traverse (SemanticGraph::Fundamental::Byte&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_; + } + + void LiteralValue:: + traverse (SemanticGraph::Fundamental::UnsignedByte&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_ + L"U"; + } + + void LiteralValue:: + traverse (SemanticGraph::Fundamental::Short&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_; + } + + void LiteralValue:: + traverse (SemanticGraph::Fundamental::UnsignedShort&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_ + L"U"; + } + + void LiteralValue:: + traverse (SemanticGraph::Fundamental::Int&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_; + } + + void LiteralValue:: + traverse (SemanticGraph::Fundamental::UnsignedInt&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_ + L"U"; + } + + void LiteralValue:: + traverse (SemanticGraph::Fundamental::Long&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_; + literal_ += L"LL"; + } + + void LiteralValue:: + traverse (SemanticGraph::Fundamental::UnsignedLong&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_; + literal_ += L"ULL"; + } + + void LiteralValue:: + traverse (SemanticGraph::Fundamental::Integer&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_ + L"LL"; + } + + void LiteralValue:: + traverse (SemanticGraph::Fundamental::NonPositiveInteger&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_ + L"LL"; + } + + void LiteralValue:: + traverse (SemanticGraph::Fundamental::NonNegativeInteger&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_ + L"ULL"; + } + + void LiteralValue:: + traverse (SemanticGraph::Fundamental::PositiveInteger&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_ + L"ULL"; + } + + void LiteralValue:: + traverse (SemanticGraph::Fundamental::NegativeInteger&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_ + L"LL"; + } + + // Floats. + // + void LiteralValue:: + traverse (SemanticGraph::Fundamental::Float& t) + { + collapse (value_); + + if (value_ == L"NaN") + { + literal_ = L"::std::numeric_limits< " + fq_name (t) + + L" >::quiet_NaN ()"; + } + else if (value_ == L"INF") + { + literal_ = L"::std::numeric_limits< " + fq_name (t) + + L" >::infinity ()"; + } + else if (value_ == L"-INF") + { + literal_ = L"- ::std::numeric_limits< " + fq_name (t) + + L" >::infinity ()"; + } + else + { + strip_zeros (value_); + make_float (value_); + literal_ = value_ + L"F"; + } + } + + void LiteralValue:: + traverse (SemanticGraph::Fundamental::Double& t) + { + collapse (value_); + + if (value_ == L"NaN") + { + literal_ = L"::std::numeric_limits< " + fq_name (t) + + L" >::quiet_NaN ()"; + } + else if (value_ == L"INF") + { + literal_ = L"::std::numeric_limits< " + fq_name (t) + + L" >::infinity ()"; + } + else if (value_ == L"-INF") + { + literal_ = L"- ::std::numeric_limits< " + fq_name (t) + + L" >::infinity ()"; + } + else + { + strip_zeros (value_); + make_float (value_); + literal_ = value_; + } + } + + void LiteralValue:: + traverse (SemanticGraph::Fundamental::Decimal&) + { + collapse (value_); + strip_zeros (value_); + make_float (value_); + literal_ = value_; + } + + // + // InitKind + // + + InitKind:: + InitKind (Kind& r) + : r_ (r) + { + *this >> inherits_ >> *this; + } + + void InitKind:: + traverse (SemanticGraph::List&) + { + r_ = function; + } + + void InitKind:: + traverse (SemanticGraph::Complex& c) + { + inherits (c); + } + + void InitKind:: + traverse (SemanticGraph::Fundamental::Base64Binary&) + { + r_ = data; + } + + void InitKind:: + traverse (SemanticGraph::Fundamental::HexBinary&) + { + r_ = data; + } + + void InitKind:: + traverse (SemanticGraph::Fundamental::NameTokens&) + { + r_ = function; + } + + void InitKind:: + traverse (SemanticGraph::Fundamental::IdRefs&) + { + r_ = function; + } + + void InitKind:: + traverse (SemanticGraph::Fundamental::Entities&) + { + r_ = function; + } + + // + // InitValue + // + + InitValue:: + InitValue (Context& c) + : Context (c), type_name_ (c), literal_value_ (c) + { + } + + void InitValue:: + dispatch (SemanticGraph::Node& type, String const& value) + { + value_ = value; + Traversal::NodeBase::dispatch (type); + } + + void InitValue:: + traverse (SemanticGraph::List& l) + { + collapse (value_); + + if (!value_) + return; + + SemanticGraph::Type& t (l.argumented ().type ()); + + String ov (value_); + size_t b (0); + + for (size_t e (ov.find (' ')); ; e = ov.find (' ', b)) + { + String v (ov, b, e != String::npos ? e - b : e); + + os << "{"; + type_name_.dispatch (t); + os << " tmp ("; + + String lit (literal_value_.dispatch (t, v)); + + if (lit) + os << lit; + else + { + value_ = v; + Traversal::NodeBase::dispatch (t); + } + + os << ");" + << "r.push_back (tmp);" + << "}"; + + if (e == String::npos) + break; + + b = e + 1; + } + + value_ = ov; + } + + void InitValue:: + traverse (SemanticGraph::Union&) + { + os << strlit (value_); + } + + void InitValue:: + traverse (SemanticGraph::Complex& c) + { + Traversal::NodeBase::dispatch (ultimate_base (c)); + } + + // anyType & anySimpleType. + // + void InitValue:: + traverse (SemanticGraph::AnyType& t) + { + os << fq_name (t) << " (" << strlit (value_) << ")"; + } + + void InitValue:: + traverse (SemanticGraph::AnySimpleType& t) + { + os << fq_name (t) << " (" << strlit (value_) << ")"; + } + + // Strings. + // + void InitValue:: + traverse (SemanticGraph::Fundamental::String&) + { + os << strlit (value_); + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::NormalizedString&) + { + normalize (value_); + os << strlit (value_); + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::Token&) + { + collapse (value_); + os << strlit (value_); + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::NameToken&) + { + collapse (value_); + os << strlit (value_); + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::NameTokens&) + { + string_sequence_type ( + dynamic_cast ( + xs_ns ().find ("NMTOKEN").first->named ())); + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::Name&) + { + collapse (value_); + os << strlit (value_); + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::NCName&) + { + collapse (value_); + os << strlit (value_); + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::Language&) + { + collapse (value_); + os << strlit (value_); + } + + // Qualified name. + // + void InitValue:: + traverse (SemanticGraph::Fundamental::QName& t) + { + size_t p (value_.rfind ('#')); + + if (p != String::npos) + { + String ns (value_, 0, p); + String qname (value_, p + 1, String::npos); + + collapse (ns); + collapse (qname); + + p = qname.find (':'); + + String name; + if (p != String::npos) + name.assign (qname, p + 1, String::npos); + else + name = qname; + + os << fq_name (t) << " (" << strlit (ns) << ", " << + strlit (name) << ")"; + } + else + { + // Unqualified name. + // + collapse (value_); + os << fq_name (t) << " (" << strlit (value_) << ")"; + } + } + + // ID/IDREF. + // + void InitValue:: + traverse (SemanticGraph::Fundamental::Id&) + { + collapse (value_); + os << strlit (value_); + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::IdRef&) + { + collapse (value_); + os << strlit (value_); + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::IdRefs&) + { + string_sequence_type ( + dynamic_cast ( + xs_ns ().find ("IDREF").first->named ())); + } + + // URI. + // + void InitValue:: + traverse (SemanticGraph::Fundamental::AnyURI&) + { + collapse (value_); + os << strlit (value_); + } + + // Binary. + // + static unsigned char + base64_decode (unsigned char c) + { + unsigned char r = 0xFF; + + if (c >= 'A' && c <= 'Z') + r = static_cast (c - 'A'); + else if (c >= 'a' && c <= 'z') + r = static_cast (c - 'a' + 26); + else if (c >= '0' && c <= '9') + r = static_cast (c - '0' + 52); + else if (c == '+') + r = 62; + else if (c == '/') + r = 63; + + return r; + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::Base64Binary& t) + { + collapse (value_); + + if (dispatch_count_++ == 0) + { + if (value_) + { + os << "unsigned char " << data_ << "[] = {"; + + // Decode. + // + size_t size (value_.size ()); + + // Remove all whitespaces. + // + { + size_t j (0); + bool subs (false); + + for (size_t i (0); i < size; ++i) + { + wchar_t c (value_[i]); + + if (c == 0x20 || c == 0x0A || c == 0x0D || c == 0x09) + subs = true; + else + { + if (subs) + subs = false; + + value_[j++] = c; + } + } + + size = j; + value_.resize (size, '\0'); + } + + // Our length should be a multiple of four. + // + size_t quad_count (size / 4); + + // Source and destination indexes. + // + size_t si (0), di (0); + + // Process all quads except the last one. + // + unsigned short v; + unsigned char b1, b2, b3, b4; + + wchar_t prev_fill (os.fill ('0')); + + for (size_t q (0); q < quad_count - 1; ++q) + { + b1 = base64_decode (value_[si++]); + b2 = base64_decode (value_[si++]); + b3 = base64_decode (value_[si++]); + b4 = base64_decode (value_[si++]); + + if (q != 0) + os << ", "; + + if (di % 9 == 0) + os << endl; + + os << hex; + + v = static_cast ((b1 << 2) | (b2 >> 4)); + os.width (2); + os << "0x" << v; + + v = static_cast ((b2 << 4) | (b3 >> 2)); + os.width (2); + os << ", 0x" << v; + + v = static_cast ((b3 << 6) | b4); + os.width (2); + os << ", 0x" << v; + + os << dec; + + di += 3; + } + + // Process the last quad. The first two octets are always there. + // + b1 = base64_decode (value_[si++]); + b2 = base64_decode (value_[si++]); + + wchar_t e3 (value_[si++]), e4 (value_[si++]); + + if (quad_count != 1) + os << ", "; + + if (di % 9 == 0) + os << endl; + + if (e4 == '=') + { + if (e3 == '=') + { + // Two pads. Last 4 bits in b2 should be zero. + // + v = static_cast ((b1 << 2) | (b2 >> 4)); + os << "0x" << hex << v << dec; + di++; + } + else + { + // One pad. Last 2 bits in b3 should be zero. + // + b3 = base64_decode (e3); + + os << hex; + + v = static_cast ((b1 << 2) | (b2 >> 4)); + os.width (2); + os << "0x" << v; + + v = static_cast ((b2 << 4) | (b3 >> 2)); + os.width (2); + os << ", 0x" << v; + + os << dec; + + di += 2; + } + } + else + { + // No pads. + // + b3 = base64_decode (e3); + b4 = base64_decode (e4); + + os << hex; + + v = static_cast ((b1 << 2) | (b2 >> 4)); + os.width (2); + os << "0x" << v; + + v = static_cast ((b2 << 4) | (b3 >> 2)); + os.width (2); + os << ", 0x" << v; + + v = static_cast ((b3 << 6) | b4); + os.width (2); + os << ", 0x" << v; + + os << dec; + + di += 3; + } + + os.fill (prev_fill); + + os << "};"; + } + } + else + { + os << fq_name (t) << " ("; + + if (value_) + os << data_ << "," << endl + << "sizeof (" << data_ << ")," << endl + << "sizeof (" << data_ << ")," << endl + << "false"; + else + os << "0"; + + + os << ")"; + } + } + + static unsigned char + hex_decode (unsigned char c) + { + unsigned char r = 0xFF; + + if (c >= '0' && c <= '9') + r = static_cast (c - '0'); + else if (c >= 'A' && c <= 'F') + r = static_cast (10 + (c - 'A')); + else if (c >= 'a' && c <= 'f') + r = static_cast (10 + (c - 'a')); + + return r; + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::HexBinary& t) + { + collapse (value_); + + if (dispatch_count_++ == 0) + { + if (value_) + { + os << "unsigned char " << data_ << "[] = {"; + + // Decode. + // + size_t n (value_.size () / 2); + wchar_t prev_fill (os.fill ('0')); + + for (size_t i (0); i < n; ++i) + { + unsigned char h (hex_decode (value_[2 * i])); + unsigned char l (hex_decode (value_[2 * i + 1])); + + if (h == 0xFF || l == 0xFF) + break; + + if (i != 0) + os << ", "; + + if (i % 9 == 0) + os << endl; + + unsigned short v = static_cast ((h << 4) | l); + os.width (2); + os << "0x" << hex << v << dec; + } + + os.fill (prev_fill); + + os << "};"; + } + } + else + { + os << fq_name (t) << " ("; + + if (value_) + os << data_ << "," << endl + << "sizeof (" << data_ << ")," << endl + << "sizeof (" << data_ << ")," << endl + << "false"; + else + os << "0"; + + + os << ")"; + } + } + + // Date/time. + // + void InitValue:: + traverse (SemanticGraph::Fundamental::Date& t) + { + // date := [-]CCYY[N]*-MM-DD[Z|(+|-)HH:MM] + // + collapse (value_); + + size_t b (0); + size_t e (value_.find ('-', value_[0] == '-' ? 5 : 4)); + String year (value_, 0, e); + + b = e + 1; + String month (value_, b, 2); + + b += 3; + String day (value_, b, 2); + + strip_zeros (year); + strip_zeros (month); + strip_zeros (day); + + os << fq_name (t) << " (" << year << ", " << month << ", " << day; + time_zone (b + 2); + os << ")"; + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::DateTime& t) + { + // date_time := [-]CCYY[N]*-MM-DDTHH:MM:SS[.S+][Z|(+|-)HH:MM] + // + collapse (value_); + + size_t b (0); + size_t e (value_.find ('-', value_[0] == '-' ? 5 : 4)); + String year (value_, 0, e); + b = e + 1; + + String month (value_, b, 2); + b += 3; + + String day (value_, b, 2); + b += 3; + + String hours (value_, b, 2); + b += 3; + + String minutes (value_, b, 2); + b += 3; + + e = b + 2; + for (; e < value_.size (); ++e) + { + wchar_t c (value_[e]); + + if (c == 'Z' || c == '+' || c == '-') + break; + } + + String seconds (value_, b, e - b); + + strip_zeros (year); + strip_zeros (month); + strip_zeros (day); + strip_zeros (hours); + strip_zeros (minutes); + strip_zeros (seconds); + make_float (seconds); + + os << fq_name (t) << " (" + << year << ", " << month << ", " << day << ", " + << hours << ", " << minutes << ", " << seconds; + time_zone (e); + os << ")"; + } + + namespace + { + size_t + find_delim (String const& s, size_t pos) + { + for (; pos < s.size (); ++pos) + { + wchar_t c (s[pos]); + + if (c == 'Y' || c == 'D' || c == 'M' || c == 'H' || + c == 'M' || c == 'S' || c == 'T') + break; + } + + return pos; + } + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::Duration& t) + { + // duration := [-]P[nY][nM][nD][TnHnMn[.n+]S] + // + collapse (value_); + + size_t b (1), e, n (value_.size ()); + + os << fq_name (t) << " ("; + + if (value_[0] == '-') + { + os << "true, "; + b++; + } + else + os << "false, "; + + e = find_delim (value_, b); + + if (e < n && value_[e] == 'Y') + { + String v (value_, b, e - b); + strip_zeros (v); + os << v << ", "; + + b = e + 1; + e = find_delim (value_, b); + } + else + os << "0, "; + + if (e < n && value_[e] == 'M') + { + String v (value_, b, e - b); + strip_zeros (v); + os << v << ", "; + + b = e + 1; + e = find_delim (value_, b); + } + else + os << "0, "; + + if (e < n && value_[e] == 'D') + { + String v (value_, b, e - b); + strip_zeros (v); + os << v << ", "; + + b = e + 1; + e = find_delim (value_, b); + } + else + os << "0, "; + + if (e < n && value_[e] == 'T') + { + b = e + 1; + e = find_delim (value_, b); + } + + if (e < n && value_[e] == 'H') + { + String v (value_, b, e - b); + strip_zeros (v); + os << v << ", "; + + b = e + 1; + e = find_delim (value_, b); + } + else + os << "0, "; + + if (e < n && value_[e] == 'M') + { + String v (value_, b, e - b); + strip_zeros (v); + os << v << ", "; + + b = e + 1; + e = find_delim (value_, b); + } + else + os << "0, "; + + if (e < n && value_[e] == 'S') + { + String v (value_, b, e - b); + strip_zeros (v); + make_float (v); + os << v; + + b = e + 1; + e = find_delim (value_, b); + } + else + os << "0.0"; + + os << ")"; + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::Day& t) + { + // gday := ---DD[Z|(+|-)HH:MM] + // + collapse (value_); + + String day (value_, 3, 2); + strip_zeros (day); + + os << fq_name (t) << " (" << day; + time_zone (5); + os << ")"; + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::Month& t) + { + // gmonth := --MM[Z|(+|-)HH:MM] + // + collapse (value_); + + String month (value_, 2, 2); + strip_zeros (month); + + os << fq_name (t) << " (" << month; + time_zone (4); + os << ")"; + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::MonthDay& t) + { + // gmonth_day := --MM-DD[Z|(+|-)HH:MM] + // + collapse (value_); + + String month (value_, 2, 2); + String day (value_, 5, 2); + + strip_zeros (month); + strip_zeros (day); + + os << fq_name (t) << " (" << month << ", " << day; + time_zone (7); + os << ")"; + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::Year& t) + { + // gyear := [-]CCYY[N]*[Z|(+|-)HH:MM] + // + collapse (value_); + + size_t pos (value_[0] == '-' ? 5 : 4); + for (; pos < value_.size (); ++pos) + { + wchar_t c (value_[pos]); + + if (c == 'Z' || c == '+' || c == '-') + break; + } + + String year (value_, 0, pos); + strip_zeros (year); + + os << fq_name (t) << " (" << year; + time_zone (pos); + os << ")"; + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::YearMonth& t) + { + // gyear_month := [-]CCYY[N]*-MM[Z|(+|-)HH:MM] + // + collapse (value_); + + size_t pos (value_.find ('-', value_[0] == '-' ? 5 : 4)); + + String year (value_, 0, pos); + String month (value_, pos + 1, 2); + + strip_zeros (year); + strip_zeros (month); + + os << fq_name (t) << " (" << year << ", " << month; + time_zone (pos + 3); + os << ")"; + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::Time& t) + { + // time := HH:MM:SS[.S+][Z|(+|-)HH:MM] + // + collapse (value_); + + String hours (value_, 0, 2); + String minutes (value_, 3, 2); + + size_t e (8); + for (; e < value_.size (); ++e) + { + wchar_t c (value_[e]); + + if (c == 'Z' || c == '+' || c == '-') + break; + } + + String seconds (value_, 6, e - 6); + + strip_zeros (hours); + strip_zeros (minutes); + strip_zeros (seconds); + make_float (seconds); + + os << fq_name (t) << " (" << hours << ", " << minutes << ", " << seconds; + time_zone (e); + os << ")"; + } + + void InitValue:: + time_zone (size_t pos) + { + // time_zone := Z|(+|-)HH:MM + // + if (pos < value_.size ()) + { + String h, m; + + if (value_[pos] == 'Z') + { + h = "0"; + m = "0"; + } + else + { + if (value_[pos] == '-') + { + h = "-"; + m = "-"; + } + + h.append (value_, pos + 1, 2); + m.append (value_, pos + 4, 2); + + strip_zeros (h); + strip_zeros (m); + } + + os << ", " << h << ", " << m; + } + } + + // Entity. + // + void InitValue:: + traverse (SemanticGraph::Fundamental::Entity&) + { + collapse (value_); + os << strlit (value_); + } + + void InitValue:: + traverse (SemanticGraph::Fundamental::Entities&) + { + string_sequence_type ( + dynamic_cast ( + xs_ns ().find ("ENTITY").first->named ())); + } + + void InitValue:: + string_sequence_type (SemanticGraph::Type& t) + { + collapse (value_); + + if (!value_) + return; + + size_t b (0); + + for (size_t e (value_.find (' ')); ; e = value_.find (' ', b)) + { + String v (value_, b, e != String::npos ? e - b : e); + + os << "{"; + type_name_.dispatch (t); + os << " tmp (" << strlit (v) << ");" + << "r.push_back (tmp);" + << "}"; + + if (e == String::npos) + break; + + b = e + 1; + } + } + } +} diff --git a/xsd/xsd/cxx/tree/default-value.hxx b/xsd/xsd/cxx/tree/default-value.hxx new file mode 100644 index 0000000..5485669 --- /dev/null +++ b/xsd/xsd/cxx/tree/default-value.hxx @@ -0,0 +1,355 @@ +// file : xsd/cxx/tree/default-value.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_TREE_DEFAULT_VALUE_HXX +#define XSD_CXX_TREE_DEFAULT_VALUE_HXX + +#include +#include + +#include + +namespace CXX +{ + namespace Tree + { + struct IsLiteralValue: IsFundamentalType, Traversal::Complex + { + IsLiteralValue (bool& r); + + virtual void + traverse (SemanticGraph::Complex&); + + private: + Traversal::Inherits inherits_; + }; + + struct LiteralValue: Traversal::Fundamental::Byte, + Traversal::Fundamental::UnsignedByte, + Traversal::Fundamental::Short, + Traversal::Fundamental::UnsignedShort, + Traversal::Fundamental::Int, + Traversal::Fundamental::UnsignedInt, + Traversal::Fundamental::Long, + Traversal::Fundamental::UnsignedLong, + Traversal::Fundamental::Integer, + Traversal::Fundamental::NonPositiveInteger, + Traversal::Fundamental::NonNegativeInteger, + Traversal::Fundamental::PositiveInteger, + Traversal::Fundamental::NegativeInteger, + + Traversal::Fundamental::Boolean, + + Traversal::Fundamental::Float, + Traversal::Fundamental::Double, + Traversal::Fundamental::Decimal, + + Traversal::Complex, + + Context + { + LiteralValue (Context&); + + String + dispatch (SemanticGraph::Node& type, String const& value); + + // Handle inheritance. + // + virtual void + traverse (SemanticGraph::Complex&); + + // Boolean. + // + virtual void + traverse (SemanticGraph::Fundamental::Boolean&); + + // Integral types. + // + virtual void + traverse (SemanticGraph::Fundamental::Byte&); + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedByte&); + + virtual void + traverse (SemanticGraph::Fundamental::Short&); + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedShort&); + + virtual void + traverse (SemanticGraph::Fundamental::Int&); + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedInt&); + + virtual void + traverse (SemanticGraph::Fundamental::Long&); + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedLong&); + + virtual void + traverse (SemanticGraph::Fundamental::Integer&); + + virtual void + traverse (SemanticGraph::Fundamental::NonPositiveInteger&); + + virtual void + traverse (SemanticGraph::Fundamental::NonNegativeInteger&); + + virtual void + traverse (SemanticGraph::Fundamental::PositiveInteger&); + + virtual void + traverse (SemanticGraph::Fundamental::NegativeInteger&); + + // Floats. + // + virtual void + traverse (SemanticGraph::Fundamental::Float&); + + virtual void + traverse (SemanticGraph::Fundamental::Double&); + + virtual void + traverse (SemanticGraph::Fundamental::Decimal&); + + private: + String value_; + String literal_; + + Traversal::Inherits inherits_; + }; + + // Some initialization (e.g., list) need a function body while others + // (e.g., *binary) require extra data. + // + struct InitKind: Traversal::List, + Traversal::Complex, + + Traversal::Fundamental::Base64Binary, + Traversal::Fundamental::HexBinary, + + Traversal::Fundamental::NameTokens, + Traversal::Fundamental::IdRefs, + Traversal::Fundamental::Entities + { + enum Kind + { + simple, + data, + function + }; + + // Should be simple initially. + // + InitKind (Kind& r); + + virtual void + traverse (SemanticGraph::List&); + + virtual void + traverse (SemanticGraph::Complex&); + + virtual void + traverse (SemanticGraph::Fundamental::Base64Binary&); + + virtual void + traverse (SemanticGraph::Fundamental::HexBinary&); + + virtual void + traverse (SemanticGraph::Fundamental::NameTokens&); + + virtual void + traverse (SemanticGraph::Fundamental::IdRefs&); + + virtual void + traverse (SemanticGraph::Fundamental::Entities&); + + private: + Kind& r_; + Traversal::Inherits inherits_; + }; + + struct InitValue: Traversal::List, + Traversal::Union, + Traversal::Complex, + + Traversal::AnyType, + Traversal::AnySimpleType, + + Traversal::Fundamental::String, + Traversal::Fundamental::NormalizedString, + Traversal::Fundamental::Token, + Traversal::Fundamental::Name, + Traversal::Fundamental::NameToken, + Traversal::Fundamental::NameTokens, + Traversal::Fundamental::NCName, + Traversal::Fundamental::Language, + + Traversal::Fundamental::QName, + + Traversal::Fundamental::Id, + Traversal::Fundamental::IdRef, + Traversal::Fundamental::IdRefs, + + Traversal::Fundamental::AnyURI, + + Traversal::Fundamental::Base64Binary, + Traversal::Fundamental::HexBinary, + + Traversal::Fundamental::Date, + Traversal::Fundamental::DateTime, + Traversal::Fundamental::Duration, + Traversal::Fundamental::Day, + Traversal::Fundamental::Month, + Traversal::Fundamental::MonthDay, + Traversal::Fundamental::Year, + Traversal::Fundamental::YearMonth, + Traversal::Fundamental::Time, + + Traversal::Fundamental::Entity, + Traversal::Fundamental::Entities, + + Context + { + InitValue (Context&); + + void + data (String const& data) + { + data_ = data; + dispatch_count_ = 0; + } + + void + dispatch (SemanticGraph::Node& type, String const& value); + + virtual void + traverse (SemanticGraph::List&); + + virtual void + traverse (SemanticGraph::Union&); + + virtual void + traverse (SemanticGraph::Complex&); + + // anyType & anySimpleType. + // + virtual void + traverse (SemanticGraph::AnyType&); + + virtual void + traverse (SemanticGraph::AnySimpleType&); + + // Strings. + // + virtual void + traverse (SemanticGraph::Fundamental::String&); + + virtual void + traverse (SemanticGraph::Fundamental::NormalizedString&); + + virtual void + traverse (SemanticGraph::Fundamental::Token&); + + virtual void + traverse (SemanticGraph::Fundamental::NameToken&); + + virtual void + traverse (SemanticGraph::Fundamental::NameTokens&); + + virtual void + traverse (SemanticGraph::Fundamental::Name&); + + virtual void + traverse (SemanticGraph::Fundamental::NCName&); + + virtual void + traverse (SemanticGraph::Fundamental::Language&); + + // Qualified name. + // + virtual void + traverse (SemanticGraph::Fundamental::QName&); + + // ID/IDREF. + // + virtual void + traverse (SemanticGraph::Fundamental::Id&); + + virtual void + traverse (SemanticGraph::Fundamental::IdRef&); + + virtual void + traverse (SemanticGraph::Fundamental::IdRefs&); + + // URI. + // + virtual void + traverse (SemanticGraph::Fundamental::AnyURI&); + + // Binary. + // + virtual void + traverse (SemanticGraph::Fundamental::Base64Binary&); + + virtual void + traverse (SemanticGraph::Fundamental::HexBinary&); + + // Date/time. + // + virtual void + traverse (SemanticGraph::Fundamental::Date&); + + virtual void + traverse (SemanticGraph::Fundamental::DateTime&); + + virtual void + traverse (SemanticGraph::Fundamental::Duration&); + + virtual void + traverse (SemanticGraph::Fundamental::Day&); + + virtual void + traverse (SemanticGraph::Fundamental::Month&); + + virtual void + traverse (SemanticGraph::Fundamental::MonthDay&); + + virtual void + traverse (SemanticGraph::Fundamental::Year&); + + virtual void + traverse (SemanticGraph::Fundamental::YearMonth&); + + virtual void + traverse (SemanticGraph::Fundamental::Time&); + + // Entity. + // + virtual void + traverse (SemanticGraph::Fundamental::Entity&); + + virtual void + traverse (SemanticGraph::Fundamental::Entities&); + + private: + void + string_sequence_type (SemanticGraph::Type& element_type); + + void + time_zone (size_t pos); + + private: + String value_; + String data_; + size_t dispatch_count_; + MemberTypeName type_name_; + LiteralValue literal_value_; + }; + } +} + +#endif // XSD_CXX_TREE_DEFAULT_VALUE_HXX diff --git a/xsd/xsd/cxx/tree/elements.cxx b/xsd/xsd/cxx/tree/elements.cxx new file mode 100644 index 0000000..fc080c8 --- /dev/null +++ b/xsd/xsd/cxx/tree/elements.cxx @@ -0,0 +1,1409 @@ +// file : xsd/cxx/tree/elements.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +namespace CXX +{ + namespace Tree + { + // Context + // + Context:: + Context (std::wostream& o, + SemanticGraph::Schema& root, + SemanticGraph::Path const& path, + options_type const& ops, + Counts const& counts_, + bool generate_xml_schema__, + StringLiteralMap const* map, + Regex const* fe, + Regex const* he, + Regex const* ie) + : CXX::Context (o, root, path, ops, map), + options (ops), + counts (counts_), + any_type (any_type_), + any_simple_type (any_simple_type_), + element_type (element_type_), + container (container_), + flags_type (flags_type_), + qname_type (qname_type_), + xs_string_type (xs_string_type_), + properties_type (properties_type_), + error_handler_type (error_handler_type_), + list_stream_type (list_stream_type_), + namespace_infomap_type (namespace_infomap_type_), + parser_type (parser_type_), + std_ostream_type (std_ostream_type_), + ostream_type (ostream_type_), + istream_type (istream_type_), + xerces_ns (xerces_ns_), + dom_auto_ptr (dom_auto_ptr_), + dom_node_key (dom_node_key_), + as_double_type (as_double_type_), + as_decimal_type (as_decimal_type_), + generate_xml_schema (generate_xml_schema_), + doxygen (doxygen_), + polymorphic (ops.generate_polymorphic ()), + polymorphic_all (ops.polymorphic_type_all ()), + poly_plate (ops.polymorphic_plate ()), + detach (ops.generate_detach ()), + fwd_expr (fe), + hxx_expr (he), + ixx_expr (ie), + ns_scope (ns_scope_), + regex_custom_type_map (regex_custom_type_map_), + direct_custom_type_map (direct_custom_type_map_), + qname_type_ (L"::xsd::cxx::xml::qualified_name< " + char_type + L" >"), + parser_type_ (L"::xsd::cxx::xml::dom::parser< " + char_type + L" >"), + generate_xml_schema_ (generate_xml_schema__), + doxygen_ (ops.generate_doxygen ()), + ns_scope_stack (ns_scope_stack_), + cxx_uq_id_expr_ (L"^[a-zA-Z_]\\w*$"), + cxx_uq_id_expr (cxx_uq_id_expr_) + { + SemanticGraph::Namespace& xs (xs_ns ()); + SemanticGraph::Context& xsc (xs.context ()); + + // Cache some often-used names from the XML Schema namespace + // if names have already been processed. + // + if (xsc.count ("container")) + { + String xs_name (ns_name (xs)); + + any_type = fq_name (xs.find ("anyType").first->named ()); + any_simple_type = fq_name (xs.find ("anySimpleType").first->named ()); + xs_string_type = fq_name (xs.find ("string").first->named ()); + + container = xs_name + L"::" + xsc.get ("container"); + flags_type = xs_name + L"::" + xsc.get ("flags"); + + if (ops.generate_element_type ()) + element_type = xs_name + L"::" + xsc.get ("element-type"); + + properties_type = xs_name + L"::" + xsc.get ("properties"); + + if (!ops.suppress_parsing () || ops.generate_serialization ()) + { + error_handler_type = xs_name + L"::" + + xsc.get ("error-handler"); + } + + dom_auto_ptr_ = xs_name + (std >= cxx_version::cxx11 + ? L"::dom::unique_ptr" + : L"::dom::auto_ptr"); + + dom_node_key_ = xs_name + L"::dom::" + + xsc.get ("tree-node-key"); + + if (ops.generate_serialization ()) + { + as_double_type_ = xs_name + L"::" + + xsc.get ("as-double"); + + as_decimal_type_ = xs_name + L"::" + + xsc.get ("as-decimal"); + + list_stream_type = xs_name + L"::" + + xsc.get ("list-stream"); + + namespace_infomap_type = xs_name + L"::" + + xsc.get ("namespace-infomap"); + } + + // istream and ostream are templates and for now use the same + // names regardless of the naming convention. + // + if (!ops.generate_extraction ().empty ()) + istream_type = xs_name + L"::istream"; + + if (!ops.generate_insertion ().empty ()) + ostream_type = xs_name + L"::ostream"; + } + + // Xerces-C++ namespace. IntelliSense for some reason does not like + // it fully-qualified (maybe because it's a namespace alias). + // + if (ops.generate_intellisense ()) + xerces_ns = "xercesc"; + else + xerces_ns = "::xercesc"; + + // + // + if (char_type == L"char") + std_ostream_type_ = L"::std::ostream"; + else if (char_type == L"wchar_t") + std_ostream_type_ = L"::std::wostream"; + else + std_ostream_type_ = L"::std::basic_ostream< " + char_type + L" >"; + + // Custom type mapping. + // + + // Direct custom type mapping. + // + { + NarrowStrings const& v (ops.custom_type ()); + + for (NarrowStrings::const_iterator i (v.begin ()), + e (v.end ()); i != e; ++i) + { + String s (*i); + + if (s.empty ()) + throw InvalidCustomTypeMapping (s, "mapping string is empty"); + + // Split the string in two parts at the last '='. + // + size_t pos (s.rfind ('=')); + + // If no delimiter found then both type and base are empty. + // + if (pos == String::npos) + { + direct_custom_type_map[s].type.clear (); + direct_custom_type_map[s].base.clear (); + continue; + } + + String name (s, 0, pos); + String rest (s, pos + 1); + + // See if we've got the base part after '/'. + // + pos = rest.rfind ('/'); + + String type, base; + + if (pos != String::npos) + { + type.assign (rest, 0, pos); + base.assign (rest, pos + 1, String::npos); + } + else + type = rest; + + // type can be a potentially-qualified template-id. base is + // an unqualified C++ name. + // + + if (!base.empty () && !cxx_uq_id_expr.match (base)) + throw InvalidCustomTypeMapping (s, "invalid C++ identifier"); + + direct_custom_type_map[name].type = type; + direct_custom_type_map[name].base = base; + } + } + + // Regex custom type mapping. + // + { + NarrowStrings const& v (ops.custom_type_regex ()); + + for (NarrowStrings::const_iterator i (v.begin ()), + e (v.end ()); i != e; ++i) + { + String s (*i); + + if (s.empty ()) + throw InvalidCustomTypeMapping (s, "mapping string is empty"); + + wchar_t delimiter (s[0]); + + // First get pattern. + // + size_t pos (s.find (delimiter, 1)); + + if (pos == String::npos) + throw InvalidCustomTypeMapping ( + s, "missing pattern-substitution separator"); + + String pat (s, 1, pos - 1); + String rest (s, pos + 1); + + String type, base; + + // See if we've got type and base. + // + if (!rest.empty ()) + { + pos = rest.find (delimiter); + + if (pos == String::npos) + throw InvalidCustomTypeMapping ( + s, "missing pattern-substitution separator"); + + type.assign (rest, 0, pos); + rest = String (rest, pos + 1); + + if (!rest.empty ()) + { + pos = rest.find (delimiter); + + if (pos == String::npos) + throw InvalidCustomTypeMapping ( + s, "missing pattern-substitution separator"); + + base.assign (rest, 0, pos); + rest = String (rest, pos + 1); + + if (!rest.empty ()) + throw InvalidCustomTypeMapping (s, "invalid format"); + } + } + + regex_custom_type_map.push_back ( + RegexCustomTypeMapInfo (WideRegexPat (pat), type, base)); + } + } + } + + Context:: + Context (Context& c) + : CXX::Context (c), + options (c.options), + counts (c.counts), + any_type (c.any_type), + any_simple_type (c.any_simple_type), + element_type (c.element_type), + container (c.container), + flags_type (c.flags_type), + qname_type (c.qname_type), + xs_string_type (c.xs_string_type), + properties_type (c.properties_type), + error_handler_type (c.error_handler_type), + list_stream_type (c.list_stream_type), + namespace_infomap_type (c.namespace_infomap_type), + parser_type (c.parser_type), + std_ostream_type (c.std_ostream_type), + ostream_type (c.ostream_type), + istream_type (c.istream_type), + xerces_ns (c.xerces_ns), + dom_auto_ptr (c.dom_auto_ptr), + dom_node_key (c.dom_node_key), + as_double_type (c.as_double_type), + as_decimal_type (c.as_decimal_type), + generate_xml_schema (c.generate_xml_schema), + doxygen (c.doxygen), + polymorphic (c.polymorphic), + polymorphic_all (c.polymorphic_all), + poly_plate (c.poly_plate), + detach (c.detach), + fwd_expr (c.fwd_expr), + hxx_expr (c.hxx_expr), + ixx_expr (c.ixx_expr), + ns_scope (c.ns_scope), + regex_custom_type_map (c.regex_custom_type_map), + direct_custom_type_map (c.direct_custom_type_map), + ns_scope_stack (c.ns_scope_stack), + cxx_uq_id_expr (c.cxx_uq_id_expr) + { + } + + Context:: + Context (Context& c, std::wostream& o) + : CXX::Context (c, o), + options (c.options), + counts (c.counts), + any_type (c.any_type), + any_simple_type (c.any_simple_type), + element_type (c.element_type), + container (c.container), + flags_type (c.flags_type), + qname_type (c.qname_type), + xs_string_type (c.xs_string_type), + properties_type (c.properties_type), + error_handler_type (c.error_handler_type), + list_stream_type (c.list_stream_type), + namespace_infomap_type (c.namespace_infomap_type), + parser_type (c.parser_type), + std_ostream_type (c.std_ostream_type), + ostream_type (c.ostream_type), + istream_type (c.istream_type), + xerces_ns (c.xerces_ns), + dom_auto_ptr (c.dom_auto_ptr), + dom_node_key (c.dom_node_key), + as_double_type (c.as_double_type), + as_decimal_type (c.as_decimal_type), + generate_xml_schema (c.generate_xml_schema), + doxygen (c.doxygen), + polymorphic (c.polymorphic), + polymorphic_all (c.polymorphic_all), + poly_plate (c.poly_plate), + detach (c.detach), + fwd_expr (c.fwd_expr), + hxx_expr (c.hxx_expr), + ixx_expr (c.ixx_expr), + ns_scope (c.ns_scope), + regex_custom_type_map (c.regex_custom_type_map), + direct_custom_type_map (c.direct_custom_type_map), + ns_scope_stack (c.ns_scope_stack), + cxx_uq_id_expr (c.cxx_uq_id_expr) + { + } + + void Context:: + update_ns_scope () + { + ns_scope.clear (); + + bool first (true); + + for (NamespaceStack::iterator i (ns_scope_stack.begin ()); + i != ns_scope_stack.end (); + ++i) + { + // We only qualify names until the namespace level. + // + if (first) + first = false; + else + ns_scope += L"::"; + + ns_scope += *i; + } + } + + bool Context:: + custom_type (SemanticGraph::Type const& t, String& r) const + { + String const& name (t.name ()); + + // First search the direct mapping. + // + { + DirectCustomTypeMap::const_iterator i ( + direct_custom_type_map.find (name)); + + if (i != direct_custom_type_map.end ()) + { + r = i->second.type; + return true; + } + } + + + // Second search the regex mapping. + // + for (RegexCustomTypeMap::const_iterator + i (regex_custom_type_map.begin ()), + e (regex_custom_type_map.end ()); + i != e; ++i) + { + if (i->pat.match (name)) + { + // Empty type sub tells us to use the original name. + // + if (i->type_sub.empty ()) + { + r.clear (); + return true; + } + + r = i->pat.replace (name, i->type_sub); + return true; + } + } + + return false; + } + + String Context:: + custom_type (SemanticGraph::Type const& t) const + { + String r; + if (custom_type (t, r)) + { + // Empty type name tells us to use the original name. + // + if (r.empty ()) + r = ename (t); + } + + return r; + } + + bool Context:: + renamed_type (SemanticGraph::Type const& t, String& r) const + { + String const& name (t.name ()); + + // First search the direct mapping. + // + { + DirectCustomTypeMap::const_iterator i ( + direct_custom_type_map.find (name)); + + if (i != direct_custom_type_map.end ()) + { + r = i->second.base; + return true; + } + } + + + // Second search the regex mapping. + // + for (RegexCustomTypeMap::const_iterator + i (regex_custom_type_map.begin ()), + e (regex_custom_type_map.end ()); + i != e; ++i) + { + if (i->pat.match (name)) + { + if (!i->base_sub.empty ()) + { + r = i->pat.replace (name, i->base_sub); + } + else + r.clear (); + + return true; + } + } + + return false; + } + + void Context:: + write_annotation (SemanticGraph::Annotation& a) + { + String const& doc (a.documentation ()); + wchar_t const* s (doc.c_str ()); + size_t size (doc.size ()); + + // Remove leading and trailing whitespaces. + // + while (*s == wchar_t (0x20) || *s == wchar_t (0x0A) || + *s == wchar_t (0x0D) || *s == wchar_t (0x09)) + { + s++; + size--; + } + + if (size != 0) + { + wchar_t const* e (s + size - 1); + + while (e > s && + (*e == wchar_t (0x20) || *e == wchar_t (0x0A) || + *e == wchar_t (0x0D) || *e == wchar_t (0x09))) + --e; + + size = s <= e ? e - s + 1 : 0; + } + + if (size != 0) + { + os << " * "; + + // Go over the data, forcing newline after 80 chars and adding + // ' * ' after each new line. + // + wchar_t const* last_space (0); + wchar_t const* b (s); + wchar_t const* e (s); + bool after_newline (false); + bool rogue (false); + + for (; e < s + size; ++e) + { + unsigned int u (unicode_char (e)); // May advance e. + + // We are going to treat \v and \f as rogue here even though + // they can be present in C++ source code. + // + if (u > 127 || (u < 32 && u != '\t' && u != '\n')) + rogue = true; + + if (u == ' ' || u == '\t') + { + if (after_newline) + { + if (e == b) + b++; // Skip leading spaces after newline. + + continue; + } + else + last_space = e; + } + else if (after_newline) + { + os << " * "; + after_newline = false; + } + + if (u == '\n') + { + write_rogue_text (b, e - b + 1, rogue); + + b = e + 1; + last_space = 0; + after_newline = true; + rogue = false; + continue; + } + + if (e - b >= 70 && last_space != 0) + { + write_rogue_text (b, last_space - b, rogue); + os << endl; + + b = last_space + 1; + last_space = 0; + after_newline = true; + // Cannot reset rogue since we don't output the whole string. + } + } + + if (e != b) + write_rogue_text (b, e - b, rogue); + + if (!after_newline) + os << endl; + } + } + + void Context:: + write_rogue_text (wchar_t const* s, size_t size, bool rogue) + { + if (!rogue) + os.write (s, size); + else + { + for (wchar_t const* p (s); p < s + size; ++p) + { + unsigned int u (unicode_char (p)); // May advance p. + + // We are going to treat \v and \f as rogue here even though + // they can be present in C++ source code. + // + if (u > 127 || (u < 32 && u != '\t' && u != '\n')) + os.put ('?'); + else + os.put (static_cast (u)); + } + } + } + + bool Context:: + polymorphic_p (SemanticGraph::Type& t) + { + // IDREF templates cannot be polymorphic. + // + if (!t.named_p () && + (t.is_a () || + t.is_a ())) + return false; + + if (polymorphic_all) + { + bool fund (false); + IsFundamentalType test (fund); + test.dispatch (t); + return !fund; + } + else + return t.context ().get ("polymorphic"); + } + + bool Context:: + anonymous_substitutes_p (SemanticGraph::Type& t) + { + // IDREF templates cannot match. + // + if (!t.named_p () && + (t.is_a () || + t.is_a ())) + return false; + + // See which elements this type classifies. + // + for (SemanticGraph::Type::ClassifiesIterator i (t.classifies_begin ()), + e (t.classifies_end ()); i != e; ++i) + { + if (SemanticGraph::Element* e = + dynamic_cast (&i->instance ())) + { + if (e->substitutes_p ()) + return true; + } + } + + return false; + } + + // GenerateDefautCtor + // + GenerateDefaultCtor:: + GenerateDefaultCtor (Context& c, bool& generate, bool no_base) + : Context (c), generate_ (generate), no_base_ (no_base) + { + *this >> inherits_ >> *this; + *this >> names_ >> *this; + } + + void GenerateDefaultCtor:: + traverse (SemanticGraph::Complex& c) + { + // Make sure we figure out if we have any required members before + // we base our decision on the base type. + // + Complex::names (c, names_); + + if (!generate_) + Complex::inherits (c, inherits_); + } + + void GenerateDefaultCtor:: + traverse (SemanticGraph::Type&) + { + if (!no_base_) + generate_ = true; + } + + void GenerateDefaultCtor:: + traverse (SemanticGraph::Enumeration&) + { + if (!no_base_) + generate_ = true; + } + + void GenerateDefaultCtor:: + traverse (SemanticGraph::Element& e) + { + if (!skip (e) && min (e) == 1 && max (e) == 1) + generate_ = true; + } + + void GenerateDefaultCtor:: + traverse (SemanticGraph::Attribute& a) + { + if (min (a) == 1 && !a.fixed_p ()) + generate_ = true; + } + + void GenerateDefaultCtor:: + traverse (SemanticGraph::Any& a) + { + if (options.generate_wildcard () && + min (a) == 1 && max (a) == 1) + generate_ = true; + } + + + // GenerateFromBaseCtor + // + GenerateFromBaseCtor:: + GenerateFromBaseCtor (Context& c, bool& generate) + : generate_ (generate), + custom_ (false), + traverser_ (c, generate, custom_) + { + inherits_ >> traverser_; + } + + void GenerateFromBaseCtor:: + traverse (SemanticGraph::Complex& c) + { + inherits (c, inherits_); + + if (!generate_ && custom_) + { + // We have a customized type in the hierarchy. In this case we + // want to generate the c-tor unless base and ultimate-base are + // the same (see CtorArgs). + // + SemanticGraph::Type& b (c.inherits ().base ()); + generate_ = b.is_a () && + !b.is_a (); + } + } + + GenerateFromBaseCtor::Traverser:: + Traverser (Context& c, bool& generate, bool& custom) + : Context (c), generate_ (generate), custom_ (custom) + { + *this >> inherits_ >> *this; + *this >> names_ >> *this; + } + + void GenerateFromBaseCtor::Traverser:: + traverse (SemanticGraph::Type& t) + { + if (!custom_) + { + String tmp; + custom_ = custom_type (t, tmp); + } + } + + void GenerateFromBaseCtor::Traverser:: + traverse (SemanticGraph::Complex& c) + { + names (c, names_); + + if (!generate_) + inherits (c, inherits_); + + if (!generate_) + traverse (static_cast (c)); + } + + void GenerateFromBaseCtor::Traverser:: + traverse (SemanticGraph::Element& e) + { + if (!skip (e) && min (e) == 1 && max (e) == 1) + generate_ = true; + } + + void GenerateFromBaseCtor::Traverser:: + traverse (SemanticGraph::Attribute& a) + { + if (min (a) == 1 && !a.fixed_p ()) + generate_ = true; + } + + void GenerateFromBaseCtor::Traverser:: + traverse (SemanticGraph::Any& a) + { + if (options.generate_wildcard () && + min (a) == 1 && max (a) == 1) + generate_ = true; + } + + // HasComplexNonOptArgs + // + HasComplexPolyNonOptArgs:: + HasComplexPolyNonOptArgs (Context& c, + bool base, + bool& complex, + bool& poly, + bool& clash) + : Context (c), + complex_ (complex), + poly_ (poly), + clash_ (clash) + { + if (base) + *this >> inherits_ >> *this; + + *this >> names_ >> *this; + } + + void HasComplexPolyNonOptArgs:: + traverse (SemanticGraph::Complex& c) + { + // No optimizations: need to check every arg for clashes. + // + inherits (c, inherits_); + names (c, names_); + } + + void HasComplexPolyNonOptArgs:: + traverse (SemanticGraph::Element& e) + { + if (!skip (e) && min (e) == 1 && max (e) == 1) + { + bool poly (polymorphic && polymorphic_p (e.type ())); + + bool simple (true); + IsSimpleType t (simple); + t.dispatch (e.type ()); + + if (poly) + poly_ = true; + + if (!simple) + complex_ = true; + + if (poly && simple) + clash_ = false; + } + } + + // FromBaseCtorArg + // + FromBaseCtorArg:: + FromBaseCtorArg (Context& c, CtorArgType at, bool arg) + : Context (c), arg_type_ (at), arg_ (arg) + { + } + + void FromBaseCtorArg:: + traverse (SemanticGraph::Any& a) + { + if (!options.generate_wildcard ()) + return; + + if (min (a) == 1 && max (a) == 1) + { + String const& name (ename (a)); + + os << "," << endl + << "const " << xerces_ns << "::DOMElement&"; + + if (arg_) + os << " " << name; + } + } + + void FromBaseCtorArg:: + traverse (SemanticGraph::Element& e) + { + if (skip (e)) + return; + + if (min (e) == 1 && max (e) == 1) + { + String const& name (ename (e)); + + os << "," << endl; + + bool ptr (false); + + switch (arg_type_) + { + case CtorArgType::complex_auto_ptr: + { + bool simple (true); + IsSimpleType t (simple); + t.dispatch (e.type ()); + ptr = !simple; + break; + } + case CtorArgType::poly_auto_ptr: + { + ptr = polymorphic && polymorphic_p (e.type ()); + break; + } + case CtorArgType::type: + break; + } + + if (ptr) + os << auto_ptr << "< " << etype (e) << " >"; + else + os << "const " << etype (e) << "&"; + + if (arg_) + os << " " << name; + } + } + + void FromBaseCtorArg:: + traverse (SemanticGraph::Attribute& a) + { + // Note that we are not going to include attributes with + // default or required fixed values here. Instead we are + // going to default-initialize them. + // + if (min (a) == 1 && !a.fixed_p ()) + { + String const& name (ename (a)); + + os << "," << endl + << "const " << etype (a) << "&"; + + if (arg_) + os << " " << name; + } + } + + // CtorArgs + // + CtorArgs:: + CtorArgs (Context& c, CtorArgType at) + : Context (c), + arg_type_ (at), + base_arg_ (0), + first_ (true), + member_name_ (c) + { + *this >> inherits_ >> *this; + *this >> names_ >> *this; + } + + CtorArgs:: + CtorArgs (Context& c, CtorArgType at, String& base_arg) + : Context (c), + arg_type_ (at), + base_arg_ (&base_arg), + first_ (true), + member_name_ (c) + { + *this >> inherits_ >> *this; + *this >> names_ >> *this; + } + + void CtorArgs:: + traverse (SemanticGraph::Type& t) + { + os << comma () << "const "; + + member_name_.dispatch (t); + + os << "&"; + + if (base_arg_ != 0) + { + // IDREF templates don't have a name. + // + *base_arg_ = t.named_p () + ? (L"_xsd_" + ename (t) + L"_base") + : L"_xsd_base"; + + os << " " << *base_arg_; + } + } + + void CtorArgs:: + traverse (SemanticGraph::Enumeration& e) + { + os << comma () << "const "; + + member_name_.traverse (e); + + os << "&"; + + if (base_arg_ != 0) + { + *base_arg_ = L"_xsd_" + ename (e) + L"_base"; + + os << " " << *base_arg_; + } + } + + void CtorArgs:: + traverse (SemanticGraph::Any& a) + { + if (!options.generate_wildcard ()) + return; + + if (min (a) == 1 && max (a) == 1) + { + os << comma () << "const " << xerces_ns << "::DOMElement&"; + + if (base_arg_ != 0) + os << " " << ename (a); + } + } + + void CtorArgs:: + traverse (SemanticGraph::Element& e) + { + if (skip (e)) + return; + + if (min (e) == 1 && max (e) == 1) + { + bool ptr (false); + + switch (arg_type_) + { + case CtorArgType::complex_auto_ptr: + { + bool simple (true); + IsSimpleType t (simple); + t.dispatch (e.type ()); + ptr = !simple; + break; + } + case CtorArgType::poly_auto_ptr: + { + ptr = polymorphic && polymorphic_p (e.type ()); + break; + } + case CtorArgType::type: + break; + } + + if (ptr) + os << comma () << auto_ptr << "< " << etype (e) << " >"; + else + os << comma () << "const " << etype (e) << "&"; + + if (base_arg_ != 0) + os << " " << ename (e); + } + } + + void CtorArgs:: + traverse (SemanticGraph::Attribute& a) + { + // Note that we are not going to include attributes with + // default or required fixed values here. Instead we are + // going to default-initialize them. + // + if (min (a) == 1 && !a.fixed_p ()) + { + os << comma () << "const " << etype (a) << "&"; + + if (base_arg_ != 0) + os << " " << ename (a); + } + } + + String CtorArgs:: + comma () + { + bool tmp (first_); + first_ = false; + return tmp ? "" : ",\n"; + } + + + // CtorArgsWithoutBase + // + CtorArgsWithoutBase:: + CtorArgsWithoutBase (Context& c, CtorArgType at, bool arg, bool first) + : Context (c), arg_type_ (at), arg_ (arg), first_ (first) + { + *this >> inherits_ >> *this; + *this >> names_ >> *this; + } + + void CtorArgsWithoutBase:: + traverse (SemanticGraph::Any& a) + { + if (!options.generate_wildcard ()) + return; + + if (min (a) == 1 && max (a) == 1) + { + os << comma () << "const " << xerces_ns << "::DOMElement&"; + + if (arg_) + os << " " << ename (a); + } + } + + void CtorArgsWithoutBase:: + traverse (SemanticGraph::Element& e) + { + if (skip (e)) + return; + + if (min (e) == 1 && max (e) == 1) + { + bool ptr (false); + + switch (arg_type_) + { + case CtorArgType::complex_auto_ptr: + { + bool simple (true); + IsSimpleType t (simple); + t.dispatch (e.type ()); + ptr = !simple; + break; + } + case CtorArgType::poly_auto_ptr: + { + ptr = polymorphic && polymorphic_p (e.type ()); + break; + } + case CtorArgType::type: + break; + } + + if (ptr) + os << comma () << auto_ptr << "< " << etype (e) << " >"; + else + os << comma () << "const " << etype (e) << "&"; + + if (arg_) + os << " " << ename (e); + } + } + + void CtorArgsWithoutBase:: + traverse (SemanticGraph::Attribute& a) + { + // Note that we are not going to include attributes with + // default or required fixed values here. Instead we are + // going to default-initialize them. + // + if (min (a) == 1 && !a.fixed_p ()) + { + os << comma () << "const " << etype (a) << "&"; + + if (arg_) + os << " " << ename (a); + } + } + + String CtorArgsWithoutBase:: + comma () + { + bool tmp (first_); + first_ = false; + return tmp ? "" : ",\n"; + } + + // GlobalElementBase + // + bool GlobalElementBase:: + generate_p (SemanticGraph::Element& e) + { + if (e.substitutes_p () && ctx_.polymorphic) + return true; + + if (!doc_root_p (e)) + return false; + + // If we are not generating element types nor parsing/serialization + // code then we won't generate anything from it. + // + if (!ctx_.options.generate_element_type () && + ctx_.options.suppress_parsing () && + !ctx_.options.generate_serialization ()) + return false; + + return true; + } + + bool GlobalElementBase:: + doc_root_p (SemanticGraph::Element& e) + { + if (!ctx_.options.root_element_first () && + !ctx_.options.root_element_last () && + !ctx_.options.root_element_all () && + !ctx_.options.root_element_none () && + ctx_.options.root_element ().empty ()) + return true; // By default treat them all. + + if (ctx_.options.root_element_none ()) + return false; + + if (ctx_.options.root_element_all ()) + return true; + + if (ctx_.options.root_element_first () && + e.context ().count ("first") != 0) + return true; + + if (ctx_.options.root_element_last () && + e.context ().count ("last") != 0) + return true; + + NarrowStrings const& names (ctx_.options.root_element ()); + + // Hopefully nobody will specify more than a handful of names ;-). + // + for (NarrowStrings::const_iterator i (names.begin ()); + i != names.end (); ++i) + { + String name (*i); + + if (e.name () == name) + return true; + } + + return false; + } + + // Namespace + // + Namespace:: + Namespace (Context& c, + size_t first, + size_t last) + : CXX::Namespace (c, *this), + GlobalElementBase (c), + ctx_ (c), + first_ (first), + last_ (last), + count_ (0) + { + } + + void Namespace:: + traverse (Type& ns) + { + using SemanticGraph::Element; + + if (first_ > last_) + CXX::Namespace::traverse (ns); + else + { + bool opened (false); + + for (Type::NamesIterator i (ns.names_begin ()); + i != ns.names_end (); ++i) + { + SemanticGraph::Nameable& n (i->named ()); + + if (n.is_a () || + (n.is_a () && generate_p (dynamic_cast (n)))) + { + if (count_ >= first_ && count_ <= last_) + { + if (!opened) + { + opened = true; + pre (ns); + } + + edge_traverser ().dispatch (*i); + } + + ++count_; + } + } + + if (opened) + post (ns); + } + } + + void Namespace:: + enter (Type&, String const& name, bool) + { + ctx_.enter_ns_scope (name); + } + + void Namespace:: + leave () + { + ctx_.leave_ns_scope (); + } + + // Includes + // + void TypeForward:: + traverse (SemanticGraph::Type& t) + { + String const& name (ename (t)); + + if (String custom = custom_type (t)) + { + String new_name; + renamed_type (t, new_name); + + if (new_name) + os << "class " << new_name << ";"; + + if (custom == name) + os << "class " << name << ";"; + else + os << "typedef " << custom << " " << name << ";"; + } + else + os << "class " << name << ";"; + } + + void Includes:: + traverse_ (SemanticGraph::Uses& u) + { + // Support for weak (forward) inclusion used in the file-per-type + // compilation model. + // + Type t (type_); + bool weak (u.context ().count ("weak")); + SemanticGraph::Schema& s (u.schema ()); + + if (weak && t == header) + { + // Generate forward declarations. + // + if (forward_) + t = forward; + else + { + schema_.dispatch (s); + return; + } + } + + if (t == source && !weak) + { + if (u.user ().context ().count ("type-schema")) + { + // Strong include into a type schema -- this is a base class. + // We have already included its header in our header so it + // would seem we don't need to do anything here. There is one + // subtle issue, however: Our constructors include arguments + // for base members which we simply pass to the base. The base + // header has only forward declarations for its members. This + // is not a problem if we pass references to base members -- + // forward declarations are sufficient for this case. The + // problematic case is when we pass them as auto/unique_ptr. + // Because we pass them by value (which is done to support + // unique_ptr move semantics), the compiler needs to be able + // to destroy the member, presumably if an exception is thrown. + // And for that forward declarations are not enough. + // + // So what we are going to do here is include all the base + // member headers (transitively), just like the base's source + // file does. + // + // Note that we only do this for source since in the inline + // case the necessary files are already pulled via the the + // .ixx file includes. + // + Traversal::Schema schema; + schema >> *this; + schema.dispatch (s); + } + + return; + } + + SemanticGraph::Path path ( + s.context ().count ("renamed") + ? s.context ().get ("renamed") + : u.path ()); + path.normalize (); + + // Try to use the portable representation of the path. If that + // fails, fall back to the native representation. + // + NarrowString path_str; + try + { + path_str = path.posix_string (); + } + catch (SemanticGraph::InvalidPath const&) + { + path_str = path.string (); + } + + String inc_path; + + switch (t) + { + case forward: + { + inc_path = ctx_.fwd_expr->replace (path_str); + break; + } + case header: + case source: + { + inc_path = ctx_.hxx_expr->replace (path_str); + break; + } + case inline_: + { + if (weak) + { + inc_path = ctx_.hxx_expr->replace (path_str); + ctx_.os << "#include " << ctx_.process_include_path (inc_path) + << endl; + } + + inc_path = ctx_.ixx_expr->replace (path_str); + break; + } + } + + ctx_.os << "#include " << ctx_.process_include_path (inc_path) << endl + << endl; + } + } +} diff --git a/xsd/xsd/cxx/tree/elements.hxx b/xsd/xsd/cxx/tree/elements.hxx new file mode 100644 index 0000000..ed5eb77 --- /dev/null +++ b/xsd/xsd/cxx/tree/elements.hxx @@ -0,0 +1,2118 @@ +// file : xsd/cxx/tree/elements.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_TREE_ELEMENTS_HXX +#define XSD_CXX_TREE_ELEMENTS_HXX + +#include +#include +#include +#include +#include + +#include + +#include + +#include + +#include + +namespace CXX +{ + namespace Tree + { + struct Counts + { + Counts () + : global_types (0), + global_elements (0), + generated_global_elements (0), + complexity_total (0) + { + } + + size_t global_types; + size_t global_elements; + size_t generated_global_elements; + + // Complexity value for each global type and generated global + // element, in order. + // + std::vector complexity; + size_t complexity_total; + }; + + struct InvalidCustomTypeMapping + { + InvalidCustomTypeMapping (String const& mapping, + String const& reason) + : mapping_ (mapping), reason_ (reason) + { + } + + String const& + mapping () const + { + return mapping_; + } + + String const& + reason () const + { + return reason_; + } + + private: + String mapping_; + String reason_; + }; + + // A set of potentially qualified XML Schema type names. + // + struct TypeNameSet + { + template + TypeNameSet (I begin, I end) + { + for (; begin != end; ++begin) + insert (*begin); + } + + void + insert (String const& name) + { + size_t p (name.rfind ('#')); + + if (p == String::npos) + unames_.insert (name); + else + qnames_.insert (name); + } + + bool + find (SemanticGraph::Type& t) + { + if (!unames_.empty ()) + { + if (unames_.find (t.name ()) != unames_.end ()) + return true; + } + + if (!qnames_.empty ()) + { + if (qnames_.find (t.scope ().name () + L"#" + t.name ()) != + qnames_.end ()) + return true; + } + + return false; + } + + private: + typedef std::set StringSet; + + StringSet unames_; + StringSet qnames_; + }; + + // + // + class Context: public CXX::Context + { + public: + typedef cutl::re::regexsub Regex; + typedef cutl::re::wregex WideRegexPat; + + typedef Tree::options options_type; + + struct DirectCustomTypeMapInfo + { + DirectCustomTypeMapInfo (String const& t = L"", + String const& b = L"") + : type (t), base (b) + { + } + + String type; + String base; + }; + + struct RegexCustomTypeMapInfo + { + RegexCustomTypeMapInfo (WideRegexPat const& p, + String const& t, + String const& b) + : pat (p), type_sub (t), base_sub (b) + { + } + + WideRegexPat pat; + String type_sub; + String base_sub; + }; + + typedef std::vector RegexCustomTypeMap; + typedef std::map DirectCustomTypeMap; + + public: + Context (std::wostream& o, + SemanticGraph::Schema& root, + SemanticGraph::Path const& path, + options_type const& ops, + Counts const& counts_, + bool generate_xml_schema, + StringLiteralMap const*, + Regex const* fwd_expr, + Regex const* hxx_expr, + Regex const* ixx_expr); + + protected: + Context (Context& c); + Context (Context& c, std::wostream& o); + + // Custom type mapping. + // + public: + // Returns empty string if custom mapping is not required. + // + String + custom_type (SemanticGraph::Type const&) const; + + // Returns true if custom mapping is required. name is + // populated with the custom type name or empty if the + // original name should be used. + // + bool + custom_type (SemanticGraph::Type const&, String& name) const; + + // Returns true if this type has been renamed as part of the + // customization process. If the function returns true, the + // name string is populated with the new name or empty if + // the type should not be generated at all. + // + bool + renamed_type (SemanticGraph::Type const&, String& name) const; + + public: + // Performs a number of processing steps, including forcing a new + // line after 80 characters as well as "commentizing" the text by + // adding '* ' after each newline. + // + void + write_annotation (SemanticGraph::Annotation&); + + // + // + public: + static bool + ordered_p (SemanticGraph::Type const& t) + { + return t.context ().count ("ordered") && + t.context ().get ("ordered"); + } + + // Check if we are generating mixed support for this type. We only + // do it for ordered types. + // + static bool + mixed_p (SemanticGraph::Complex const& c) + { + return c.mixed_p () && ordered_p (c); + } + + bool + polymorphic_p (SemanticGraph::Type&); + + bool + anonymous_p (SemanticGraph::Type const& t) + { + return t.context ().count ("anonymous"); + } + + // Return true if this anonymous type is defined in an element + // that belongs to a substitution group. + // + bool + anonymous_substitutes_p (SemanticGraph::Type&); + + // Escaped names. + // + public: + // Accessor name. + // + static String const& + eaname (SemanticGraph::Member const& m) + { + return m.context ().get ("aname"); + } + + static String const& + eaname (SemanticGraph::Any const& a) + { + return a.context ().get ("aname"); + } + + static String const& + eaname (SemanticGraph::AnyAttribute const& a) + { + return a.context ().get ("aname"); + } + + // Modifier name. + // + static String const& + emname (SemanticGraph::Member const& m) + { + return m.context ().get ("mname"); + } + + static String const& + emname (SemanticGraph::Any const& a) + { + return a.context ().get ("mname"); + } + + static String const& + emname (SemanticGraph::AnyAttribute const& a) + { + return a.context ().get ("mname"); + } + + // Detach name. + // + static String const& + edname (SemanticGraph::Member const& m) + { + return m.context ().get ("dname"); + } + + // + // + static String const& + etype (SemanticGraph::Member const& m) + { + return m.context ().get ("type"); + } + + static String const& + etraits (SemanticGraph::Member const& m) + { + return m.context ().get ("traits"); + } + + static String const& + econtainer (SemanticGraph::Member const& m) + { + return m.context ().get ("container"); + } + + static String const& + econtainer (SemanticGraph::Any const& a) + { + return a.context ().get ("container"); + } + + static String const& + econtainer (SemanticGraph::AnyAttribute const& a) + { + return a.context ().get ("container"); + } + + static String const& + eiterator (SemanticGraph::Member const& m) + { + return m.context ().get ("iterator"); + } + + static String const& + eiterator (SemanticGraph::Any const& a) + { + return a.context ().get ("iterator"); + } + + static String const& + eiterator (SemanticGraph::AnyAttribute const& a) + { + return a.context ().get ("iterator"); + } + + static String const& + econst_iterator (SemanticGraph::Member const& m) + { + return m.context ().get ("const-iterator"); + } + + static String const& + econst_iterator (SemanticGraph::Any const& a) + { + return a.context ().get ("const-iterator"); + } + + static String const& + econst_iterator (SemanticGraph::AnyAttribute const& a) + { + return a.context ().get ("const-iterator"); + } + + static String const& + emember (SemanticGraph::Member const& m) + { + return m.context ().get ("member"); + } + + static String const& + emember (SemanticGraph::Any const& a) + { + return a.context ().get ("member"); + } + + static String const& + emember (SemanticGraph::AnyAttribute const& a) + { + return a.context ().get ("member"); + } + + static String const& + edefault_value (SemanticGraph::Member const& m) + { + return m.context ().get ("default-value"); + } + + static String const& + edefault_value_member (SemanticGraph::Member const& m) + { + return m.context ().get ("default-value-member"); + } + + // Underlying enum value type. + // + static String const& + evalue (SemanticGraph::Enumeration const& e) + { + return e.context ().get ("value"); + } + + // dom_document + // + static bool + edom_document_p (SemanticGraph::Complex const& c) + { + return c.context ().count ("dom-document"); + } + + static String const& + edom_document (SemanticGraph::Complex const& c) + { + return c.context ().get ("dom-document"); + } + + static bool + edom_document_member_p (SemanticGraph::Complex const& c) + { + return c.context ().count ("dom-document-member"); + } + + static String const& + edom_document_member (SemanticGraph::Complex const& c) + { + return c.context ().get ("dom-document-member"); + } + + // Parsing and serialization function names. + // + static String const& + eparser (SemanticGraph::Element const& e) + { + return e.context ().get ("parser"); + } + + static String const& + eserializer (SemanticGraph::Element const& e) + { + return e.context ().get ("serializer"); + } + + public: + void + enter_ns_scope (String const& name) + { + ns_scope_stack.push_back (name); + update_ns_scope (); + } + + void + leave_ns_scope () + { + ns_scope_stack.pop_back (); + update_ns_scope (); + } + + private: + void + update_ns_scope (); + + private: + // Write text that may contain characters that we will have + // to escape (indicated by the rogue flag). + // + void + write_rogue_text (wchar_t const* s, size_t size, bool rogue); + + public: + options_type const& options; + Counts const& counts; + String& any_type; + String& any_simple_type; + String& element_type; + String& container; + String& flags_type; + String& qname_type; + String& xs_string_type; + String& properties_type; + String& error_handler_type; + String& list_stream_type; + String& namespace_infomap_type; + String& parser_type; + String& std_ostream_type; + String& ostream_type; + String& istream_type; + String& xerces_ns; + String& dom_auto_ptr; + String& dom_node_key; + String& as_double_type; + String& as_decimal_type; + + bool& generate_xml_schema; + bool& doxygen; + bool polymorphic; + bool polymorphic_all; + unsigned long poly_plate; + bool detach; + + Regex const* fwd_expr; + Regex const* hxx_expr; + Regex const* ixx_expr; + + String& ns_scope; + + RegexCustomTypeMap& regex_custom_type_map; + DirectCustomTypeMap& direct_custom_type_map; + + private: + String any_type_; + String any_simple_type_; + String element_type_; + String container_; + String flags_type_; + String qname_type_; + String xs_string_type_; + String properties_type_; + String error_handler_type_; + String list_stream_type_; + String namespace_infomap_type_; + String parser_type_; + String std_ostream_type_; + String ostream_type_; + String istream_type_; + String xerces_ns_; + String dom_auto_ptr_; + String dom_node_key_; + String as_double_type_; + String as_decimal_type_; + + bool generate_xml_schema_; + bool doxygen_; + + typedef std::deque NamespaceStack; + typedef std::deque ScopeStack; + + String ns_scope_; + + NamespaceStack& ns_scope_stack; + NamespaceStack ns_scope_stack_; + + RegexCustomTypeMap regex_custom_type_map_; + DirectCustomTypeMap direct_custom_type_map_; + + private: + WideRegexPat const cxx_uq_id_expr_; + WideRegexPat const& cxx_uq_id_expr; + }; + + // Check whether this Schema type maps to a fundamental C++ type. + // + struct IsFundamentalType: Traversal::Fundamental::Byte, + Traversal::Fundamental::UnsignedByte, + Traversal::Fundamental::Short, + Traversal::Fundamental::UnsignedShort, + Traversal::Fundamental::Int, + Traversal::Fundamental::UnsignedInt, + Traversal::Fundamental::Long, + Traversal::Fundamental::UnsignedLong, + Traversal::Fundamental::Integer, + Traversal::Fundamental::NonPositiveInteger, + Traversal::Fundamental::NonNegativeInteger, + Traversal::Fundamental::PositiveInteger, + Traversal::Fundamental::NegativeInteger, + + Traversal::Fundamental::Boolean, + + Traversal::Fundamental::Float, + Traversal::Fundamental::Double, + Traversal::Fundamental::Decimal + + { + IsFundamentalType (bool& r) + : r_ (r) + { + } + + // Integral types. + // + virtual void + traverse (SemanticGraph::Fundamental::Byte&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedByte&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::Short&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedShort&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::Int&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedInt&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::Long&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedLong&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::Integer&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::NonPositiveInteger&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::NonNegativeInteger&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::PositiveInteger&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::NegativeInteger&) + { + r_ = true; + } + + // Boolean. + // + virtual void + traverse (SemanticGraph::Fundamental::Boolean&) + { + r_ = true; + } + + // Floats. + // + virtual void + traverse (SemanticGraph::Fundamental::Float&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::Double&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::Decimal&) + { + r_ = true; + } + + private: + bool& r_; + }; + + // Check whether this is a string-based type. + // + struct IsStringBasedType: Traversal::Complex, + Traversal::Union, + Traversal::Fundamental::String, + Traversal::Fundamental::NormalizedString, + Traversal::Fundamental::Token, + Traversal::Fundamental::Name, + Traversal::Fundamental::NameToken, + Traversal::Fundamental::NCName, + Traversal::Fundamental::Language + { + IsStringBasedType (bool& r) + : r_ (r) + { + *this >> inherits_ >> *this; + } + + virtual void + traverse (SemanticGraph::Complex& c) + { + inherits (c, inherits_); + } + + virtual void + traverse (SemanticGraph::Union&) + { + // Current mapping of union is string-based. + // + r_ = true; + } + + // Strings. + // + virtual void + traverse (SemanticGraph::Fundamental::String&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::NormalizedString&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::Token&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::NameToken&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::Name&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::NCName&) + { + r_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::Language&) + { + r_ = true; + } + + private: + bool& r_; + Traversal::Inherits inherits_; + }; + + + // Check whether this is a enumeration-based type. + // + struct IsEnumBasedType: Traversal::Complex + { + IsEnumBasedType (SemanticGraph::Enumeration*& e) + : enum_ (e) + { + *this >> inherits_; + + inherits_ >> *this; + inherits_ >> enum_; + } + + virtual void + traverse (SemanticGraph::Complex& c) + { + inherits (c, inherits_); + } + + private: + struct Enumeration: Traversal::Enumeration + { + Enumeration (SemanticGraph::Enumeration*& e) + : e_ (e) + { + } + + virtual void + traverse (Type& e) + { + if (e_ == 0) + e_ = &e; + } + + private: + SemanticGraph::Enumeration*& e_; + }; + + + private: + Enumeration enum_; + Traversal::Inherits inherits_; + }; + + + // + // + struct MemberTypeName : Context, + Traversal::Type, + Traversal::List, + Traversal::Union, + Traversal::Complex, + + Traversal::AnyType, + Traversal::AnySimpleType, + + Traversal::Fundamental::Byte, + Traversal::Fundamental::UnsignedByte, + Traversal::Fundamental::Short, + Traversal::Fundamental::UnsignedShort, + Traversal::Fundamental::Int, + Traversal::Fundamental::UnsignedInt, + Traversal::Fundamental::Long, + Traversal::Fundamental::UnsignedLong, + Traversal::Fundamental::Integer, + Traversal::Fundamental::NonPositiveInteger, + Traversal::Fundamental::NonNegativeInteger, + Traversal::Fundamental::PositiveInteger, + Traversal::Fundamental::NegativeInteger, + + Traversal::Fundamental::Boolean, + + Traversal::Fundamental::Float, + Traversal::Fundamental::Double, + Traversal::Fundamental::Decimal, + + Traversal::Fundamental::String, + Traversal::Fundamental::NormalizedString, + Traversal::Fundamental::Token, + Traversal::Fundamental::Name, + Traversal::Fundamental::NameToken, + Traversal::Fundamental::NameTokens, + Traversal::Fundamental::NCName, + Traversal::Fundamental::Language, + + Traversal::Fundamental::QName, + + Traversal::Fundamental::Id, + Traversal::Fundamental::IdRef, + Traversal::Fundamental::IdRefs, + + Traversal::Fundamental::AnyURI, + + Traversal::Fundamental::Base64Binary, + Traversal::Fundamental::HexBinary, + + Traversal::Fundamental::Date, + Traversal::Fundamental::DateTime, + Traversal::Fundamental::Duration, + Traversal::Fundamental::Day, + Traversal::Fundamental::Month, + Traversal::Fundamental::MonthDay, + Traversal::Fundamental::Year, + Traversal::Fundamental::YearMonth, + Traversal::Fundamental::Time, + + Traversal::Fundamental::Entity, + Traversal::Fundamental::Entities + + { + MemberTypeName (Context& c) + : Context (c) + { + } + + MemberTypeName (Context& c, std::wostream& o) + : Context (c, o) + { + } + + virtual void + traverse (SemanticGraph::Type&) + { + abort (); + } + + virtual void + traverse (SemanticGraph::List& l) + { + os << fq_name (l); + } + + virtual void + traverse (SemanticGraph::Union& u) + { + os << fq_name (u); + } + + virtual void + traverse (SemanticGraph::Complex& c) + { + os << fq_name (c); + } + + // anyType & anySimpleType. + // + virtual void + traverse (SemanticGraph::AnyType& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::AnySimpleType& t) + { + os << fq_name (t); + } + + // Integral types. + // + virtual void + traverse (SemanticGraph::Fundamental::Byte& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedByte& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Short& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedShort& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Int& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedInt& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Long& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedLong& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Integer& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::PositiveInteger& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::NegativeInteger& t) + { + os << fq_name (t); + } + + // Boolean. + // + virtual void + traverse (SemanticGraph::Fundamental::Boolean& t) + { + os << fq_name (t); + } + + // Floats. + // + virtual void + traverse (SemanticGraph::Fundamental::Float& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Double& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Decimal& t) + { + os << fq_name (t); + } + + // Strings. + // + virtual void + traverse (SemanticGraph::Fundamental::String& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::NormalizedString& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Token& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::NameToken& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::NameTokens& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Name& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::NCName& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Language& t) + { + os << fq_name (t); + } + + + // Qualified name. + // + virtual void + traverse (SemanticGraph::Fundamental::QName& t) + { + os << fq_name (t); + } + + + // ID/IDREF. + // + virtual void + traverse (SemanticGraph::Fundamental::Id& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::IdRef& t) + { + if (t.named_p ()) + { + // IDREF + // + os << fq_name (t); + } + else + { + SemanticGraph::Nameable& ncname ( + xs_ns ().find ("NCName").first->named ()); + + os << "::xsd::cxx::tree::idref< " << char_type << ", " << + fq_name (ncname) << ", " << + type_name (t.argumented ().type ()) << " >"; + } + } + + virtual void + traverse (SemanticGraph::Fundamental::IdRefs& t) + { + if (t.named_p ()) + { + // IDREFS + // + os << fq_name (t); + } + else + { + SemanticGraph::Nameable& ncname ( + xs_ns ().find ("NCName").first->named ()); + + os << "::xsd::cxx::tree::idrefs< " << char_type << ", " << + any_simple_type << ", ::xsd::cxx::tree::idref< " << + char_type << ", " << fq_name (ncname) << ", " << + type_name (t.argumented ().type ()) << " > >"; + } + } + + // URI. + // + virtual void + traverse (SemanticGraph::Fundamental::AnyURI& t) + { + os << fq_name (t); + } + + // Binary. + // + virtual void + traverse (SemanticGraph::Fundamental::Base64Binary& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::HexBinary& t) + { + os << fq_name (t); + } + + + // Date/time. + // + virtual void + traverse (SemanticGraph::Fundamental::Date& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::DateTime& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Duration& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Day& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Month& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::MonthDay& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Year& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::YearMonth& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Time& t) + { + os << fq_name (t); + } + + // Entity. + // + virtual void + traverse (SemanticGraph::Fundamental::Entity& t) + { + os << fq_name (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Entities& t) + { + os << fq_name (t); + } + + private: + // For idref/idrefs + // + String + type_name (SemanticGraph::Type& t) + { + // This type is always named. + // + std::wostringstream o; + + MemberTypeName type (*this, o); + type.dispatch (t); + + return o.str (); + } + }; + + + // + // + struct BaseTypeName : MemberTypeName + { + BaseTypeName (Context& c) + : MemberTypeName (c) + { + } + + BaseTypeName (Context& c, std::wostream& o) + : MemberTypeName (c, o) + { + } + + virtual void + fundamental_base (SemanticGraph::Type& t) + { + os << "::xsd::cxx::tree::fundamental_base< " << + fq_name (t) << ", " << char_type << ", " << + any_simple_type << " >"; + } + + // Integrals. + // + virtual void + traverse (SemanticGraph::Fundamental::Byte& t) + { + fundamental_base (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedByte& t) + { + fundamental_base (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Short& t) + { + fundamental_base (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedShort& t) + { + fundamental_base (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Int& t) + { + fundamental_base (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedInt& t) + { + fundamental_base (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Long& t) + { + fundamental_base (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedLong& t) + { + fundamental_base (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Integer& t) + { + fundamental_base (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) + { + fundamental_base (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) + { + fundamental_base (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::PositiveInteger& t) + { + fundamental_base (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::NegativeInteger& t) + { + fundamental_base (t); + } + + // Boolean. + // + virtual void + traverse (SemanticGraph::Fundamental::Boolean& t) + { + fundamental_base (t); + } + + // Floats. + // + virtual void + traverse (SemanticGraph::Fundamental::Float& t) + { + fundamental_base (t); + } + + virtual void + traverse (SemanticGraph::Fundamental::Double& t) + { + os << "::xsd::cxx::tree::fundamental_base< " << + fq_name (t) << ", " << char_type << ", " << + any_simple_type << ", " << + "::xsd::cxx::tree::schema_type::double_ >"; + } + + virtual void + traverse (SemanticGraph::Fundamental::Decimal& t) + { + os << "::xsd::cxx::tree::fundamental_base< " << + fq_name (t) << ", " << char_type << ", " << + any_simple_type << ", " << + "::xsd::cxx::tree::schema_type::decimal >"; + } + }; + + // Initial value should be true. + // + struct IsSimpleType: Traversal::Complex, + Traversal::Member, + Traversal::Any, + Traversal::AnyAttribute + { + IsSimpleType (bool& v) + : v_ (v) + { + *this >> names_ >> *this; + *this >> inherits_ >> *this; + } + + virtual void + traverse (SemanticGraph::Complex& c) + { + if (c.mixed_p ()) + v_ = false; + + if (v_) + names (c, names_); + + if (v_) + inherits (c, inherits_); + } + + virtual void + traverse (SemanticGraph::Member&) + { + v_ = false; + } + + virtual void + traverse (SemanticGraph::Any&) + { + v_ = false; + } + + virtual void + traverse (SemanticGraph::AnyAttribute&) + { + v_ = false; + } + + private: + bool& v_; + Traversal::Names names_; + Traversal::Inherits inherits_; + }; + + // Test whether we need to generate default c-tor. Note that we are not + // interested in anyAttribute since it is always mapped to a sequence. + // + struct GenerateDefaultCtor: Traversal::Complex, + Traversal::Enumeration, + Traversal::Type, + Traversal::Element, + Traversal::Attribute, + Traversal::Any, + Context + { + // generate should initially be false. + // + GenerateDefaultCtor (Context&, bool& generate, bool no_base); + + virtual void + traverse (SemanticGraph::Complex&); + + virtual void + traverse (SemanticGraph::Type&); + + virtual void + traverse (SemanticGraph::Enumeration&); + + virtual void + traverse (SemanticGraph::Element&); + + virtual void + traverse (SemanticGraph::Attribute&); + + virtual void + traverse (SemanticGraph::Any&); + + private: + bool& generate_; + bool no_base_; + + private: + Traversal::Inherits inherits_; + Traversal::Names names_; + }; + + // Test whether we need to generate from-base c-tor. + // + struct GenerateFromBaseCtor: Traversal::Complex + { + // generate should initially be false. + // + GenerateFromBaseCtor (Context& c, bool& generate); + + virtual void + traverse (SemanticGraph::Complex& c); + + private: + bool& generate_; + bool custom_; + + // Note that we are not interested in anyAttribute since it is always + // mapped to a sequence. + // + struct Traverser: Traversal::Type, + Traversal::Complex, + Traversal::Element, + Traversal::Attribute, + Traversal::Any, + Context + { + Traverser (Context& c, bool& generate, bool& custom); + + virtual void + traverse (SemanticGraph::Type&); + + virtual void + traverse (SemanticGraph::Complex&); + + virtual void + traverse (SemanticGraph::Attribute&); + + virtual void + traverse (SemanticGraph::Element&); + + virtual void + traverse (SemanticGraph::Any&); + + private: + bool& generate_; + bool& custom_; + + private: + Traversal::Inherits inherits_; + Traversal::Names names_; + } traverser_; + + Traversal::Inherits inherits_; + }; + + // Test whether the type has any non-optional element of complex + // (has attributes/elements) and polymorpjic types. + // + struct HasComplexPolyNonOptArgs: Traversal::Complex, + Traversal::Element, + Context + { + // complex and poly should initially be false. clash + // should initially be true. + // + HasComplexPolyNonOptArgs (Context& c, + bool including_base, + bool& complex, + bool& poly, + bool& clash); + + virtual void + traverse (SemanticGraph::Complex&); + + virtual void + traverse (SemanticGraph::Element&); + + private: + bool& complex_; + bool& poly_; + bool& clash_; + + Traversal::Inherits inherits_; + Traversal::Names names_; + }; + + // Contructor argument types. + // + struct CtorArgType + { + enum Value + { + type, + complex_auto_ptr, + poly_auto_ptr + }; + + CtorArgType (Value v = Value (0)) : v_ (v) {} + operator Value () const {return v_;} + + private: + Value v_; + }; + + // Immediate non-optional member. Note that AnyAttribute is always + // mapped to a sequence. + // + struct FromBaseCtorArg: Traversal::Any, + Traversal::Element, + Traversal::Attribute, + Context + { + FromBaseCtorArg (Context& c, CtorArgType, bool arg); + + virtual void + traverse (SemanticGraph::Any&); + + virtual void + traverse (SemanticGraph::Attribute&); + + virtual void + traverse (SemanticGraph::Element&); + + private: + CtorArgType arg_type_; + bool arg_; + }; + + // List of all non-optional members and a simple base. Note that + // AnyAttribute is always mapped to a sequence. + // + struct CtorArgs: Traversal::Complex, + Traversal::Enumeration, + Traversal::Type, + Traversal::Any, + Traversal::Element, + Traversal::Attribute, + Context + { + // The second version outputs the argument name and stores + // in in the base_arg string. + // + CtorArgs (Context&, CtorArgType); + CtorArgs (Context&, CtorArgType, String& base_arg); + + virtual void + traverse (SemanticGraph::Type&); + + virtual void + traverse (SemanticGraph::Enumeration&); + + virtual void + traverse (SemanticGraph::Any&); + + virtual void + traverse (SemanticGraph::Attribute&); + + virtual void + traverse (SemanticGraph::Element&); + + private: + String + comma (); + + private: + CtorArgType arg_type_; + String base_; + String* base_arg_; + bool first_; + + private: + Traversal::Inherits inherits_; + Traversal::Names names_; + + MemberTypeName member_name_; + }; + + + // Check whether we need to generate c-tor without the base argument. + // + struct GenerateWithoutBaseCtor: Traversal::List, + Traversal::Union, + Traversal::Complex, + Traversal::Enumeration, + + Traversal::AnyType, + Traversal::AnySimpleType, + + Traversal::Fundamental::String, + Traversal::Fundamental::NormalizedString, + Traversal::Fundamental::Token, + + Traversal::Fundamental::NameTokens, + Traversal::Fundamental::IdRefs, + + Traversal::Fundamental::Base64Binary, + Traversal::Fundamental::HexBinary + { + // generate should initially be false. + // + GenerateWithoutBaseCtor (bool& generate) + : generate_ (generate) + { + *this >> inherits_ >> *this; + } + + virtual void + traverse (SemanticGraph::List&) + { + generate_ = true; + } + + virtual void + traverse (SemanticGraph::Union&) + { + // No default initialization. + } + + virtual void + traverse (SemanticGraph::Complex& c) + { + Complex::inherits (c); + } + + virtual void + traverse (SemanticGraph::Enumeration&) + { + // No default initialization. + } + + virtual void + traverse (SemanticGraph::AnyType&) + { + generate_ = true; + } + + virtual void + traverse (SemanticGraph::AnySimpleType&) + { + generate_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::String&) + { + generate_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::NormalizedString&) + { + generate_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::Token&) + { + generate_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::NameTokens&) + { + generate_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::IdRefs&) + { + generate_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::Base64Binary&) + { + generate_ = true; + } + + virtual void + traverse (SemanticGraph::Fundamental::HexBinary&) + { + generate_ = true; + } + + private: + bool& generate_; + Traversal::Inherits inherits_; + }; + + + // List of all non-optional members sans simple base. Note that + // AnyAttribute is always mapped to a sequence. + // + struct CtorArgsWithoutBase: Traversal::Complex, + Traversal::Any, + Traversal::Element, + Traversal::Attribute, + Context + { + CtorArgsWithoutBase (Context& c, CtorArgType, bool arg, bool first); + + virtual void + traverse (SemanticGraph::Any&); + + virtual void + traverse (SemanticGraph::Element&); + + virtual void + traverse (SemanticGraph::Attribute&); + + private: + String + comma (); + + private: + CtorArgType arg_type_; + bool arg_; + bool first_; + + private: + Traversal::Inherits inherits_; + Traversal::Names names_; + }; + + // + // + struct GlobalElementBase + { + GlobalElementBase (Context& c) + : ctx_ (c) + { + } + + bool + generate_p (SemanticGraph::Element&); + + bool + doc_root_p (SemanticGraph::Element&); + + private: + Context& ctx_; + }; + + + // + // + struct Namespace: CXX::Namespace, + GlobalElementBase, + CXX::Namespace::ScopeTracker + { + Namespace (Context&, + size_t first = 1, + size_t last = 0); + + virtual void + traverse (Type&); + + protected: + virtual void + enter (Type&, String const& name, bool last); + + virtual void + leave (); + + protected: + Context& ctx_; + + private: + size_t first_; + size_t last_; + size_t count_; + }; + + // + // + struct DocumentedNamespace: Namespace + { + DocumentedNamespace (Context& c) + : Namespace (c) + { + } + + virtual void + enter (Type& ns, String const& name, bool last) + { + Namespace::enter (ns, name, last); + + // Only add documentation to the innermost namespace. + // + if (ctx_.doxygen && name && last) + { + ctx_.os << "/**" << endl + << " * @brief C++ namespace for the %" << + ctx_.comment (ns.name ()) << endl + << " * schema namespace." << endl + << " */" << endl; + } + } + }; + + // + // + struct TypeForward: Traversal::Type, Context + { + TypeForward (Context& c) + : Context (c) + { + } + + virtual void + traverse (SemanticGraph::Type& t); + }; + + struct Includes: Traversal::Imports, + Traversal::Includes + { + enum Type + { + forward, + header, + inline_, + source + }; + + Includes (Context& c, Type type) + : ctx_ (c), + type_ (type), + forward_ (c.options.generate_forward ()), + namespace_ (c), + type_forward_ (c) + { + schema_ >> schema_names_ >> namespace_ >> names_ >> type_forward_; + } + + virtual void + traverse (SemanticGraph::Imports& i) + { + traverse_ (i); + } + + virtual void + traverse (SemanticGraph::Includes& i) + { + traverse_ (i); + } + + private: + void + traverse_ (SemanticGraph::Uses&); + + private: + Context& ctx_; + Type type_; + bool forward_; + + Traversal::Schema schema_; + Traversal::Names schema_names_; + Namespace namespace_; + Traversal::Names names_; + TypeForward type_forward_; + }; + + // + // + struct FundIncludes: Traversal::Fundamental::Byte, + Traversal::Fundamental::UnsignedByte, + Traversal::Fundamental::Short, + Traversal::Fundamental::UnsignedShort, + Traversal::Fundamental::Int, + Traversal::Fundamental::UnsignedInt, + Traversal::Fundamental::Long, + Traversal::Fundamental::UnsignedLong, + Traversal::Fundamental::Integer, + Traversal::Fundamental::NonPositiveInteger, + Traversal::Fundamental::NonNegativeInteger, + Traversal::Fundamental::PositiveInteger, + Traversal::Fundamental::NegativeInteger, + + Traversal::Fundamental::Boolean, + + Traversal::Fundamental::Float, + Traversal::Fundamental::Double, + Traversal::Fundamental::Decimal, + Context + { + FundIncludes (Context& c, String const& prefix) + : Context (c), prefix_ (prefix), + long_ (false), unsigned_long_ (false) + { + } + + // Integral types. + // + virtual void + traverse (SemanticGraph::Fundamental::Byte& t) + { + gen_include (t, "byte.hxx"); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedByte& t) + { + gen_include (t, "unsigned-byte.hxx"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Short& t) + { + gen_include (t, "short.hxx"); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedShort& t) + { + gen_include (t, "unsigned-short.hxx"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Int& t) + { + gen_include (t, "int.hxx"); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedInt& t) + { + gen_include (t, "unsigned-int.hxx"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Long& t) + { + if (!long_) + long_ = gen_include (t, "long.hxx"); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedLong& t) + { + if (!unsigned_long_) + unsigned_long_ = gen_include (t, "unsigned-long.hxx"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Integer& t) + { + if (!long_) + long_ = gen_include (t, "long.hxx"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) + { + if (!long_) + long_ = gen_include (t, "long.hxx"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) + { + if (!unsigned_long_) + unsigned_long_ = gen_include (t, "unsigned-long.hxx"); + } + + virtual void + traverse (SemanticGraph::Fundamental::PositiveInteger& t) + { + if (!unsigned_long_) + unsigned_long_ = gen_include (t, "unsigned-long.hxx"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NegativeInteger& t) + { + if (!long_) + long_ = gen_include (t, "long.hxx"); + } + + // Boolean. + // + virtual void + traverse (SemanticGraph::Fundamental::Boolean& t) + { + gen_include (t, "boolean.hxx"); + } + + // Floats. + // + virtual void + traverse (SemanticGraph::Fundamental::Float& t) + { + gen_include (t, "float.hxx"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Double& t) + { + gen_include (t, "double.hxx"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Decimal& t) + { + gen_include (t, "decimal.hxx"); + } + + private: + bool + gen_include (SemanticGraph::Type& t, String const& file) + { + String custom; + + // XML Schema built-in type customization is only possible when + // we are generating separate header. + // + if (generate_xml_schema && custom_type (t, custom)) + { + String new_name; + renamed_type (t, new_name); + + if (!new_name) + return false; + } + + os << "#include " + << endl; + + return true; + } + + private: + String prefix_; + bool long_; + bool unsigned_long_; + }; + } +} + +#endif // XSD_CXX_TREE_ELEMENTS_HXX diff --git a/xsd/xsd/cxx/tree/fundamental-header.hxx b/xsd/xsd/cxx/tree/fundamental-header.hxx new file mode 100644 index 0000000..a470154 --- /dev/null +++ b/xsd/xsd/cxx/tree/fundamental-header.hxx @@ -0,0 +1,1335 @@ +// file : xsd/cxx/tree/fundamental-header.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_TREE_FUNDAMENTAL_HEADER_HXX +#define XSD_CXX_TREE_FUNDAMENTAL_HEADER_HXX + +#include +#include +#include + +#include +#include + +#include + +namespace CXX +{ + namespace Tree + { + struct FundamentalNamespace : DocumentedNamespace, + + Traversal::AnyType, + Traversal::AnySimpleType, + + Traversal::Fundamental::Byte, + Traversal::Fundamental::UnsignedByte, + Traversal::Fundamental::Short, + Traversal::Fundamental::UnsignedShort, + Traversal::Fundamental::Int, + Traversal::Fundamental::UnsignedInt, + Traversal::Fundamental::Long, + Traversal::Fundamental::UnsignedLong, + Traversal::Fundamental::Integer, + Traversal::Fundamental::NonPositiveInteger, + Traversal::Fundamental::NonNegativeInteger, + Traversal::Fundamental::PositiveInteger, + Traversal::Fundamental::NegativeInteger, + + Traversal::Fundamental::Boolean, + + Traversal::Fundamental::Float, + Traversal::Fundamental::Double, + Traversal::Fundamental::Decimal, + + Traversal::Fundamental::String, + Traversal::Fundamental::NormalizedString, + Traversal::Fundamental::Token, + Traversal::Fundamental::Name, + Traversal::Fundamental::NameToken, + Traversal::Fundamental::NameTokens, + Traversal::Fundamental::NCName, + Traversal::Fundamental::Language, + + Traversal::Fundamental::Id, + Traversal::Fundamental::IdRef, + Traversal::Fundamental::IdRefs, + + Traversal::Fundamental::AnyURI, + + Traversal::Fundamental::QName, + + Traversal::Fundamental::Base64Binary, + Traversal::Fundamental::HexBinary, + + Traversal::Fundamental::Date, + Traversal::Fundamental::DateTime, + Traversal::Fundamental::Duration, + Traversal::Fundamental::Day, + Traversal::Fundamental::Month, + Traversal::Fundamental::MonthDay, + Traversal::Fundamental::Year, + Traversal::Fundamental::YearMonth, + Traversal::Fundamental::Time, + + Traversal::Fundamental::Entity, + Traversal::Fundamental::Entities, + Context + { + FundamentalNamespace (Context& c) + : DocumentedNamespace (c), + Context (c), + export_ (c.options.export_xml_schema () && type_exp) + { + *this >> names_ >> *this; + + if (export_) + xs_ns_ = ns_name (xs_ns ()); + } + + void + gen_typedef (String const& name, + String const& type, + String const& arg1 = L"", + String const& arg2 = L"", + String const& arg3 = L"", + bool export_type = true) + { + os << "typedef " << type; + + // Use unqualified arguments since we are in the same + // namespace. + // + if (arg1) + { + os << arg1; + + if (arg2) + { + os << ", " << arg2; + + if (arg3) + os << ", " << arg3; + } + + os << " >"; + } + + os << " " << name << ";"; + + if (export_type && export_ && type.find (L'<') != String::npos) + { + String s (type); + + // Use qualified arguments. + // + if (arg1) + { + s += xs_ns_; + s += L"::"; + s += arg1; + + if (arg2) + { + s += L", "; + s += xs_ns_; + s += L"::"; + s += arg2; + + if (arg3) + { + s += L", "; + s += xs_ns_; + s += L"::"; + s += arg3; + } + } + + s += " >"; + } + + if (exports_set_.count (s) == 0) + { + exports_.push_back (s); + exports_set_.insert (s); + } + } + } + + String + built_in_type (SemanticGraph::Type& t, + String const& type, + String const& arg1 = L"", + String const& arg2 = L"", + String const& arg3 = L"") + { + String custom; + + String name (ename (t)); + + // XML Schema built-in type customization is only possible when + // we are generating separate header. + // + if (generate_xml_schema && custom_type (t, custom)) + { + if (custom.empty ()) + custom = name; + + String new_name; + renamed_type (t, new_name); + + if (new_name) + { + gen_typedef (new_name, type, arg1, arg2, arg3); + + if (doxygen) + os << endl; + } + + if (doxygen) + os << "/**" << endl + << " * @brief C++ type corresponding to the " << + comment (t.name ()) << " XML Schema" << endl + << " * built-in type." << endl + << " */" << endl; + + if (custom == name) + os << "class " << name << ";"; + else + os << "typedef " << custom << " " << name << ";"; + + if (doxygen) + os << endl; + } + else + { + // Otherwise generate simple typedef. + // + + if (doxygen) + os << "/**" << endl + << " * @brief C++ type corresponding to the " << + comment (t.name ()) << " XML Schema" << endl + << " * built-in type." << endl + << " */" << endl; + + gen_typedef (name, type, arg1, arg2, arg3); + + if (doxygen) + os << endl; + } + + return name; + } + + // anyType and anySimpleType + // + virtual void + traverse (SemanticGraph::AnyType& t) + { + os << "// anyType and anySimpleType." << endl + << "//" << endl; + + if (doxygen) + os << endl; + + type_ = built_in_type (t, "::xsd::cxx::tree::type"); + } + + virtual void + traverse (SemanticGraph::AnySimpleType& t) + { + simple_type_ = built_in_type ( + t, L"::xsd::cxx::tree::simple_type< " + char_type + L", ", type_); + + if (doxygen) + os << "/**" << endl + << " * @brief Alias for the anyType type." << endl + << " */" << endl; + + gen_typedef (xs_ns ().context().get ("container"), + "::xsd::cxx::tree::type"); + + os << endl; + + if (doxygen) + os << endl; + } + + // Integrals. + // + virtual void + traverse (SemanticGraph::Fundamental::Byte& t) + { + os << "// 8-bit" << endl + << "//" << endl; + + if (doxygen) + os << endl; + + built_in_type (t, "signed char"); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedByte& t) + { + built_in_type (t, "unsigned char"); + os << endl; + } + + virtual void + traverse (SemanticGraph::Fundamental::Short& t) + { + os << "// 16-bit" << endl + << "//" << endl; + + if (doxygen) + os << endl; + + built_in_type (t, "short"); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedShort& t) + { + built_in_type (t, "unsigned short"); + os << endl; + } + + virtual void + traverse (SemanticGraph::Fundamental::Int& t) + { + os << "// 32-bit" << endl + << "//" << endl; + + if (doxygen) + os << endl; + + built_in_type (t, "int"); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedInt& t) + { + built_in_type (t, "unsigned int"); + os << endl; + } + + virtual void + traverse (SemanticGraph::Fundamental::Long& t) + { + os << "// 64-bit" << endl + << "//" < ("buffer"), + L"::xsd::cxx::tree::buffer< " + char_type + L" >"); + + if (doxygen) + os << endl; + + built_in_type ( + t, + L"::xsd::cxx::tree::base64_binary< " + char_type + L", ", + simple_type_); + } + + virtual void + traverse (SemanticGraph::Fundamental::HexBinary& t) + { + built_in_type ( + t, + L"::xsd::cxx::tree::hex_binary< " + char_type + L", ", + simple_type_); + + os << endl; + } + + + // Date/time. + // + virtual void + traverse (SemanticGraph::Fundamental::Date& t) + { + os << "// Date/time." << endl + << "//" << endl; + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Time zone type." << endl + << " */" << endl; + + gen_typedef (xs_ns ().context().get ("time-zone"), + "::xsd::cxx::tree::time_zone"); + + if (doxygen) + os << endl; + + built_in_type ( + t, L"::xsd::cxx::tree::date< " + char_type + L", ", simple_type_); + } + + virtual void + traverse (SemanticGraph::Fundamental::DateTime& t) + { + built_in_type ( + t, + L"::xsd::cxx::tree::date_time< " + char_type + L", ", + simple_type_); + } + + virtual void + traverse (SemanticGraph::Fundamental::Duration& t) + { + built_in_type ( + t, + L"::xsd::cxx::tree::duration< " + char_type + L", ", + simple_type_); + } + + virtual void + traverse (SemanticGraph::Fundamental::Day& t) + { + built_in_type ( + t, L"::xsd::cxx::tree::gday< " + char_type + L", ", simple_type_); + } + + virtual void + traverse (SemanticGraph::Fundamental::Month& t) + { + built_in_type ( + t, L"::xsd::cxx::tree::gmonth< " + char_type + L", ", simple_type_); + } + + virtual void + traverse (SemanticGraph::Fundamental::MonthDay& t) + { + built_in_type ( + t, + L"::xsd::cxx::tree::gmonth_day< " + char_type + L", ", + simple_type_); + } + + virtual void + traverse (SemanticGraph::Fundamental::Year& t) + { + built_in_type ( + t, L"::xsd::cxx::tree::gyear< " + char_type + L", ", simple_type_); + } + + virtual void + traverse (SemanticGraph::Fundamental::YearMonth& t) + { + built_in_type ( + t, + L"::xsd::cxx::tree::gyear_month< " + char_type + L", ", + simple_type_); + } + + virtual void + traverse (SemanticGraph::Fundamental::Time& t) + { + built_in_type ( + t, L"::xsd::cxx::tree::time< " + char_type + L", ", simple_type_); + + os << endl; + } + + // Entity. + // + virtual void + traverse (SemanticGraph::Fundamental::Entity& t) + { + os << "// Entity." << endl + << "//" << endl; + + if (doxygen) + os << endl; + + entity_ = built_in_type ( + t, L"::xsd::cxx::tree::entity< " + char_type + L", ", ncname_); + } + + virtual void + traverse (SemanticGraph::Fundamental::Entities& t) + { + built_in_type ( + t, + L"::xsd::cxx::tree::entities< " + char_type + L", ", + simple_type_, + entity_); + + os << endl; + } + + virtual void + post (SemanticGraph::Namespace& n) + { + SemanticGraph::Context& c (xs_ns ().context()); + + bool parsing (!options.suppress_parsing ()); + bool serialization (options.generate_serialization ()); + bool element_map (options.generate_element_map ()); + + { + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Content order sequence entry." << endl + << " */" << endl; + + gen_typedef (c.get ("content-order"), + "::xsd::cxx::tree::content_order"); + } + + if (options.generate_element_type ()) + { + if (doxygen) + os << "/**" << endl + << " * @brief Base class for element types." << endl + << " */" << endl; + else + os << "// Base class for element types." << endl + << "//" << endl; + + gen_typedef ( + c.get ("element-type"), + L"::xsd::cxx::tree::element_type< " + char_type + L", ", + type_); + + os << endl; + } + + if (element_map) + { + if (doxygen) + os << "/**" << endl + << " * @brief Root element map." << endl + << " */" << endl; + else + os << "// Root element map." << endl + << "//" << endl; + + gen_typedef ( + c.get ("element-map"), + L"::xsd::cxx::tree::element_map< " + char_type + L", ", + type_); + + os << endl; + } + + if (serialization) + { + os << "// Namespace information and list stream. Used in" << endl + << "// serialization functions." << endl + << "//" << endl; + + if (doxygen) + os << "/**" << endl + << " * @brief Namespace serialization information." << endl + << " */" << endl; + + gen_typedef ( + c.get ("namespace-info"), + L"::xsd::cxx::xml::dom::namespace_info< " + char_type + L" >"); + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Namespace serialization information map." << endl + << " */" << endl; + + gen_typedef (c.get ("namespace-infomap"), + L"::xsd::cxx::xml::dom::namespace_infomap< " + + char_type + L" >"); + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief List serialization stream." << endl + << " */" << endl; + + gen_typedef ( + c.get ("list-stream"), + L"::xsd::cxx::tree::list_stream< " + char_type + L" >"); + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Serialization wrapper for the %double type." << endl + << " */" << endl; + + // Do not export as_double and as_decimal since they are already + // instantiated. + // + gen_typedef (c.get ("as-double"), + L"::xsd::cxx::tree::as_double< ", + double_, + "", + "", + false); + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Serialization wrapper for the %decimal type." << endl + << " */" << endl; + + gen_typedef (c.get ("as-decimal"), + L"::xsd::cxx::tree::as_decimal< ", + decimal_, + "", + "", + false); + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Simple type facet." << endl + << " */" << endl; + + gen_typedef (c.get ("facet"), "::xsd::cxx::tree::facet"); + + os << endl; + } + + //@@ Can't change names of ostream/istream since they are + // templates. + // + if (!options.generate_insertion ().empty ()) + { + if (doxygen) + os << "/**" << endl + << " * @brief Data representation output stream template." << endl + << " */" << endl; + else + os << "// Data representation output stream template." << endl + << "//" << endl; + + os << "using ::xsd::cxx::tree::ostream;" + << endl; + } + + if (!options.generate_extraction ().empty ()) + { + if (doxygen) + os << "/**" << endl + << " * @brief Data representation input stream template." << endl + << " */" << endl; + else + os << "// Data representation input stream template." << endl + << "//" << endl; + + os << "using ::xsd::cxx::tree::istream;" + << endl; + } + + os << "// Flags and properties." << endl + << "//" << endl; + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Parsing and serialization flags." << endl + << " */" << endl; + + gen_typedef (c.get ("flags"), "::xsd::cxx::tree::flags"); + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Parsing properties." << endl + << " */" << endl; + + gen_typedef (c.get ("properties"), + L"::xsd::cxx::tree::properties< " + char_type + L" >"); + os << endl; + + + // + // + if (parsing || serialization) + { + os << "// Parsing/serialization diagnostics." << endl + << "//" << endl; + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Error severity." << endl + << " */" << endl; + + gen_typedef (c.get ("severity"), + "::xsd::cxx::tree::severity"); + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Error condition." << endl + << " */" << endl; + + gen_typedef (c.get ("error"), + L"::xsd::cxx::tree::error< " + char_type + L" >"); + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief List of %error conditions." << endl + << " */" << endl; + + gen_typedef (c.get ("diagnostics"), + L"::xsd::cxx::tree::diagnostics< " + char_type + L" >"); + os << endl; + } + + // + // + os << "// Exceptions." << endl + << "//" << endl; + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Root of the C++/Tree %exception hierarchy." << endl + << " */" << endl; + + gen_typedef (c.get ("exception"), + L"::xsd::cxx::tree::exception< " + char_type + L" >"); + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Exception indicating that the size argument exceeds" << + endl + << " * the capacity argument." << endl + << " */" << endl; + + gen_typedef (c.get ("bounds"), + L"::xsd::cxx::tree::bounds< " + char_type + L" >"); + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Exception indicating that a duplicate ID value" << + endl + << " * was encountered in the object model." << endl + << " */" << endl; + + gen_typedef (c.get ("duplicate-id"), + L"::xsd::cxx::tree::duplicate_id< " + char_type + L" >"); + + if (parsing) + { + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Exception indicating a parsing failure." << endl + << " */" << endl; + + gen_typedef (c.get ("parsing"), + L"::xsd::cxx::tree::parsing< " + char_type + L" >"); + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Exception indicating that an expected element" << + endl + << " * was not encountered." << endl + << " */" << endl; + + gen_typedef ( + c.get ("expected-element"), + L"::xsd::cxx::tree::expected_element< " + char_type + L" >"); + } + + if (parsing || serialization) + { + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Exception indicating that an unexpected " << + "element" << endl + << " * was encountered." << endl + << " */" << endl; + + gen_typedef ( + c.get ("unexpected-element"), + L"::xsd::cxx::tree::unexpected_element< " + char_type + L" >"); + } + + if (parsing) + { + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Exception indicating that an expected " << + "attribute" << endl + << " * was not encountered." << endl + << " */" << endl; + + gen_typedef ( + c.get ("expected-attribute"), + L"::xsd::cxx::tree::expected_attribute< " + char_type + L" >"); + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Exception indicating that an unexpected " << + "enumerator" << endl + << " * was encountered." << endl + << " */" << endl; + + gen_typedef ( + c.get ("unexpected-enumerator"), + L"::xsd::cxx::tree::unexpected_enumerator< " + char_type + L" >"); + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Exception indicating that the text content " << + "was" << endl + << " * expected for an element." << endl + << " */" << endl; + + gen_typedef ( + c.get ("expected-text-content"), + L"::xsd::cxx::tree::expected_text_content< " + char_type + L" >"); + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Exception indicating that a prefix-namespace" << + endl + << " * mapping was not provided." << endl + << " */" << endl; + + gen_typedef ( + c.get ("no-prefix-mapping"), + L"::xsd::cxx::tree::no_prefix_mapping< " + char_type + L" >"); + } + + if (options.generate_polymorphic ()) + { + if (parsing || serialization) + { + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Exception indicating that the type " << + "information" << endl + << " * is not available for a type." << endl + << " */" << endl; + + gen_typedef ( + c.get ("no-type-info"), + L"::xsd::cxx::tree::no_type_info< " + char_type + L" >"); + } + + if (parsing) + { + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Exception indicating that the types are not" << + endl + << " * related by inheritance." << endl + << " */" << endl; + + gen_typedef ( + c.get ("not-derived"), + L"::xsd::cxx::tree::not_derived< " + char_type + L" >"); + } + } + + if (element_map) + { + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Exception indicating that parsing or " << + "serialization" << endl + << " * information is not available for an element." << endl + << " */" << endl; + + gen_typedef ( + c.get ("no-element-info"), + L"::xsd::cxx::tree::no_element_info< " + char_type + L" >"); + } + + if (serialization) + { + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Exception indicating a serialization " << + "failure." << endl + << " */" << endl; + + gen_typedef ( + c.get ("serialization"), + L"::xsd::cxx::tree::serialization< " + char_type + L" >"); + } + + os << endl; + + if (parsing || serialization) + { + if (doxygen) + os << "/**" << endl + << " * @brief Error handler callback interface." << endl + << " */" << endl; + else + os << "// Error handler callback interface." << endl + << "//" << endl; + + gen_typedef ( + c.get ("error-handler"), + L"::xsd::cxx::xml::error_handler< " + char_type + L" >"); + + os << endl; + } + + if (parsing || serialization) + { + if (doxygen) + os << "/**" << endl + << " * @brief DOM interaction." << endl + << " */" << endl; + else + os << "// DOM interaction." << endl + << "//" << endl; + + os << "namespace dom" + << "{"; + + // @@ Disregarding current naming convention by using the + // fixed name (even in C++11, template alias is not yet + // widely supported). + // + if (doxygen) + os << "/**" << endl + << " * @brief Automatic pointer for DOMDocument." << endl + << " */" << endl; + else + os << "// Automatic pointer for DOMDocument." << endl + << "//" << endl; + + if (std >= cxx_version::cxx11) + os << "using ::xsd::cxx::xml::dom::unique_ptr;"; + else + os << "using ::xsd::cxx::xml::dom::auto_ptr;"; + + os << endl; + + if (parsing) + { + if (!generate_xml_schema) + { + String g (L"XSD_CXX_TREE_TREE_NODE_KEY" + ns_name (n)); + + std::transform (g.begin (), g.end(), g.begin (), upcase); + g = escape (g); // Make it a C++ id. + + os << "#ifndef " << g << endl + << "#define " << g << endl; + } + + if (doxygen) + os << "/**" << endl + << " * @brief DOM user data key for back pointers to " << + "tree nodes." << endl + << " */" << endl; + else + os << "// DOM user data key for back pointers to tree nodes." << endl + << "//" << endl; + + os << "const XMLCh* const " << c.get ("tree-node-key") << + " = ::xsd::cxx::tree::user_data_keys::node;"; + + if (!generate_xml_schema) + os << "#endif" << endl; + } + + os << "}"; // namespace dom + } + + if (element_map) + { + if (doxygen) + os << "//@cond" << endl + << endl; + + if (!generate_xml_schema) + { + String g (L"XSD_CXX_TREE_ELEMENT_MAP_INIT" + ns_name (n)); + + std::transform (g.begin (), g.end(), g.begin (), upcase); + g = escape (g); // Make it a C++ id. + + os << "#ifndef " << g << endl + << "#define " << g << endl; + } + + os << "static" << endl + << "const ::xsd::cxx::tree::element_map_init< " << + char_type << ", " << type_ << " >" << endl + << "_xsd_element_map_init;"; + + if (!generate_xml_schema) + os << "#endif" << endl; + + if (doxygen) + os << endl + << "//@endcond" << endl; + } + + Namespace::post (n); + + // Generate exports. + // + if (export_) + { + StringSet ns_set; + + for (StringList::const_iterator i (exports_.begin ()); + i != exports_.end (); ++i) + { + String const& e (*i); + + // 12 is to skip ::xsd::cxx:: + // + ns_set.insert (String (e, 12, e.rfind (':', e.find ('<')) - 13)); + } + + os << "#ifndef XSD_NO_EXPORT" << endl + << endl + << "namespace xsd" + << "{" + << "namespace cxx" + << "{"; + + for (StringSet::const_iterator i (ns_set.begin ()); + i != ns_set.end (); ++i) + { + String const& ns (*i); + String prefix (L"::xsd::cxx::" + ns); + + size_t n (1); + for (size_t b (0), e (ns.find (':')); ; n++) + { + os << "namespace " << String (ns, b, e) + << "{"; + + if (e == String::npos) + break; + + b = e + 2; + e = ns.find (':', b); + } + + for (StringList::const_iterator i (exports_.begin ()); + i != exports_.end (); ++i) + { + String const& e (*i); + String ens (e, 12, e.rfind (':', e.find ('<')) - 13); + + if (ns == ens) + { + String type (e, e.rfind (':', e.find ('<')) + 1); + os << "template class " << type_exp << type << ";"; + } + } + + while (n--) + os << "}"; + } + + os << "}" // cxx + << "}" // xsd + << "#endif // XSD_NO_EXPORT" << endl + << endl; + } + } + + private: + typedef std::set StringSet; + typedef std::vector StringList; + + bool export_; + StringList exports_; + StringSet exports_set_; + String xs_ns_; + + Traversal::Names names_; + + String type_; + String simple_type_; + String string_; + String norm_string_; + String token_; + String nmtoken_; + String name_; + String ncname_; + String idref_; + String uri_; + String entity_; + + String double_; + String decimal_; + }; + } +} + +#endif // XSD_CXX_TREE_FUNDAMENTAL_HEADER_HXX diff --git a/xsd/xsd/cxx/tree/generator.cxx b/xsd/xsd/cxx/tree/generator.cxx new file mode 100644 index 0000000..5601f4e --- /dev/null +++ b/xsd/xsd/cxx/tree/generator.cxx @@ -0,0 +1,1227 @@ +// file : xsd/cxx/tree/generator.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include + +#include + +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include + +#include + +using namespace std; +using namespace cutl; +using namespace XSDFrontend::SemanticGraph; + +// +// +typedef std::wifstream WideInputFileStream; +typedef std::wofstream WideOutputFileStream; + +namespace CXX +{ + namespace + { + char const copyright_gpl[] = + "// Copyright (c) " XSD_COPYRIGHT ".\n" + "//\n" + "// This program was generated by CodeSynthesis XSD, an XML Schema to\n" + "// C++ data binding compiler.\n" + "//\n" + "// This program is free software; you can redistribute it and/or modify\n" + "// it under the terms of the GNU General Public License version 2 as\n" + "// published by the Free Software Foundation.\n" + "//\n" + "// This program is distributed in the hope that it will be useful,\n" + "// but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + "// GNU General Public License for more details.\n" + "//\n" + "// You should have received a copy of the GNU General Public License\n" + "// along with this program; if not, write to the Free Software\n" + "// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n" + "//\n" + "// In addition, as a special exception, Code Synthesis Tools CC gives\n" + "// permission to link this program with the Xerces-C++ library (or with\n" + "// modified versions of Xerces-C++ that use the same license as Xerces-C++),\n" + "// and distribute linked combinations including the two. You must obey\n" + "// the GNU General Public License version 2 in all respects for all of\n" + "// the code used other than Xerces-C++. If you modify this copy of the\n" + "// program, you may extend this exception to your version of the program,\n" + "// but you are not obligated to do so. If you do not wish to do so, delete\n" + "// this exception statement from your version.\n" + "//\n" + "// Furthermore, Code Synthesis Tools CC makes a special exception for\n" + "// the Free/Libre and Open Source Software (FLOSS) which is described\n" + "// in the accompanying FLOSSE file.\n" + "//\n\n"; + + char const copyright_proprietary[] = + "// Copyright (c) " XSD_COPYRIGHT ".\n" + "//\n" + "// This program was generated by CodeSynthesis XSD, an XML Schema\n" + "// to C++ data binding compiler, in the Proprietary License mode.\n" + "// You should have received a proprietary license from Code Synthesis\n" + "// Tools CC prior to generating this code. See the license text for\n" + "// conditions.\n" + "//\n\n"; + } + + void Tree::Generator:: + usage () + { + CXX::Tree::options::print_usage (wcout); + CXX::options::print_usage (wcout); + } + + namespace + { + void + open (WideInputFileStream& ifs, NarrowString const& path) + { + try + { + Path fs_path (path); + ifs.open (fs_path.string ().c_str (), + std::ios_base::in | std::ios_base::binary); + + if (!ifs.is_open ()) + { + wcerr << path.c_str () << ": error: unable to open in read mode" + << endl; + + throw Tree::Generator::Failed (); + } + } + catch (InvalidPath const&) + { + wcerr << "error: '" << path.c_str () << "' is not a valid " + << "filesystem path" << endl; + + throw Tree::Generator::Failed (); + } + } + + void + append (WideOutputFileStream& os, + NarrowString const& path, + WideInputFileStream& default_is) + { + using std::ios_base; + + if (path) + { + WideInputFileStream is; + open (is, path); + os << is.rdbuf (); + } + else if (default_is.is_open ()) + { + os << default_is.rdbuf (); + default_is.seekg (0, ios_base::beg); + } + } + + void + append (WideOutputFileStream& os, + NarrowStrings const& primary, + NarrowStrings const& def) + { + NarrowStrings const& v (primary.empty () ? def : primary); + + for (NarrowStrings::const_iterator i (v.begin ()), e (v.end ()); + i != e; ++i) + { + os << i->c_str () << endl; + } + } + } + + + size_t Tree::Generator:: + generate (Tree::options const& ops, + Schema& schema, + Path const& file_path, + bool fpt, + StringLiteralMap const& string_literal_map, + const WarningSet& disabled_warnings, + FileList& file_list, + AutoUnlinks& unlinks) + { + using cutl::shared_ptr; + typedef cutl::re::regexsub Regex; + + typedef vector Paths; + typedef vector > WideOutputFileStreams; + + try + { + // Do option validation. + // + if (ops.parts () < 1) + { + wcerr << "error: invalid value for option --parts: " << + ops.parts () << endl; + throw Failed (); + } + + // Get counts. + // + Counts counts; + { + Counter counter; + counts = counter.count (ops, schema, file_path); + + /* + wcerr << "global type count: " << counts.global_types << endl; + wcerr << "global element count: " << counts.global_elements << endl; + wcerr << "generated global element count: " << + counts.generated_global_elements << endl; + + wcerr << "total complexity: " << counts.complexity_total << endl; + wcerr << "complexity vector size: " << counts.complexity.size () + << endl; + */ + } + + // Evaluate the graph for possibility of generating something useful. + // + { + Validator validator; + if (!validator.validate ( + ops, schema, file_path, disabled_warnings, counts)) + throw Failed (); + } + + bool gen_cxx (!ops.generate_dep_only ()); + + // Process ordered types. + // + if (gen_cxx) + { + OrderProcessor proc; + if (!proc.process (ops, schema, file_path)) + throw Failed (); + } + + // Process names. + // + if (gen_cxx) + { + NameProcessor proc; + if (!proc.process (ops, schema, file_path, string_literal_map)) + throw Failed (); + } + + // Process polymorphic types. + // + if (gen_cxx && + ops.generate_polymorphic () && + !ops.polymorphic_type_all ()) + { + PolymorphismProcessor proc; + if (!proc.process (ops, schema, file_path, disabled_warnings)) + throw Failed (); + } + + // Parts. + // + size_t parts (ops.parts ()); + size_t units (counts.global_types + counts.generated_global_elements); + size_t units_per_part (units / parts); + + if (parts != 1 && units_per_part < 1) + { + wcerr << "error: too many parts specified: " << parts << endl; + throw Failed (); + } + + size_t complexity_per_part (counts.complexity_total / parts); + + + NarrowString parts_suffix (ops.parts_suffix ()); + + // + // + bool generate_xml_schema (ops.generate_xml_schema ()); + + // We could be compiling several schemas at once in which case + // handling of the --generate-xml-schema option gets tricky: we + // will need to rely on the presence of the --extern-xml-schema + // to tell us which (fake) schema file corresponds to XML Schema. + // + if (generate_xml_schema) + { + if (NarrowString name = ops.extern_xml_schema ()) + { + if (file_path.string () != name) + generate_xml_schema = false; + } + } + + bool header (true); + bool inline_ (ops.generate_inline () && !generate_xml_schema); + bool forward (ops.generate_forward () && !generate_xml_schema); + bool source (!generate_xml_schema); + bool gen_dep ((ops.generate_dep () || ops.generate_dep_only ()) && + !generate_xml_schema); + + if (ops.generate_dep_only () && generate_xml_schema) + { + wcerr << "error: no dependency information can be generated for " + "XML Schema header" << endl; + throw Failed (); + } + + if (gen_dep && fpt) + { + wcerr << "error: dependency generation not support in the " << + "file-per-type mode" << endl; + throw Failed (); + } + + // Generate code. + // + NarrowString name (file_path.leaf ().string ()); + + NarrowString hxx_suffix (ops.hxx_suffix ()); + NarrowString ixx_suffix (ops.ixx_suffix ()); + NarrowString cxx_suffix (ops.cxx_suffix ()); + NarrowString fwd_suffix (ops.fwd_suffix ()); + NarrowString dep_suffix (ops.dep_suffix ()); + + Regex hxx_expr (ops.hxx_regex ().empty () + ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + hxx_suffix + "#" + : ops.hxx_regex ()); + + Regex ixx_expr (ops.ixx_regex ().empty () + ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + ixx_suffix + "#" + : ops.ixx_regex ()); + + Regex cxx_expr (ops.cxx_regex ().empty () + ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + cxx_suffix + "#" + : ops.cxx_regex ()); + + Regex fwd_expr (ops.fwd_regex ().empty () + ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + fwd_suffix + "#" + : ops.fwd_regex ()); + + Regex dep_expr (ops.dep_regex ().empty () + ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + dep_suffix + "#" + : ops.dep_regex ()); + + if (header && !hxx_expr.match (name)) + { + wcerr << "error: header expression '" << + hxx_expr.regex ().str ().c_str () << "' does not match '" << + name.c_str () << "'" << endl; + throw Failed (); + } + + if (inline_ && !ixx_expr.match (name)) + { + wcerr << "error: inline expression '" << + ixx_expr.regex ().str ().c_str () << "' does not match '" << + name.c_str () << "'" << endl; + throw Failed (); + } + + if (source && parts == 1 && !cxx_expr.match (name)) + { + wcerr << "error: source expression '" << + cxx_expr.regex ().str ().c_str () << "' does not match '" << + name.c_str () << "'" << endl; + throw Failed (); + } + + if (forward && !fwd_expr.match (name)) + { + wcerr << "error: forward expression '" << + fwd_expr.regex ().str ().c_str () << "' does not match '" << + name.c_str () << "'" << endl; + throw Failed (); + } + + if (gen_dep && !dep_expr.match (name)) + { + wcerr << "error: dependency expression '" << + dep_expr.regex ().str ().c_str () << "' does not match '" << + name.c_str () << "'" << endl; + throw Failed (); + } + + NarrowString hxx_name (header ? hxx_expr.replace (name) : NarrowString ()); + NarrowString ixx_name (inline_ ? ixx_expr.replace (name) : NarrowString ()); + NarrowString fwd_name (forward ? fwd_expr.replace (name) : NarrowString ()); + NarrowString dep_name (gen_dep ? dep_expr.replace (name) : NarrowString ()); + + Path hxx_path (hxx_name); + Path ixx_path (ixx_name); + Path fwd_path (fwd_name); + Path dep_path (dep_name); + Paths cxx_paths; + + if (source) + { + if (parts > 1) + { + for (size_t i (0); i < parts; ++i) + { + std::ostringstream os; + os << i; + + Regex expr ( + "#^(.+?)(\\.[^./\\\\]+)?$#$1" + parts_suffix + os.str () + "$2#"); + + NarrowString part_name (expr.replace (name)); + + if (!cxx_expr.match (part_name)) + { + wcerr << "error: source expression '" << + cxx_expr.regex ().str ().c_str () << "' does not match '" << + part_name.c_str () << "'" << endl; + throw Failed (); + } + + cxx_paths.push_back (Path (cxx_expr.replace (part_name))); + } + } + else + cxx_paths.push_back (Path (cxx_expr.replace (name))); + } + + Path out_dir; + + if (NarrowString dir = ops.output_dir ()) + { + try + { + out_dir = Path (dir); + } + catch (InvalidPath const&) + { + wcerr << dir.c_str () << ": error: invalid path" << endl; + throw Failed (); + } + } + + if (fpt && !generate_xml_schema) + { + // In the file-per-type mode the schema files are always local + // unless the user added the directory so that we propagate this + // to the output files. + // + Path fpt_dir (file_path.directory ()); + + if (!fpt_dir.empty ()) + out_dir /= fpt_dir; + } + + if (!out_dir.empty ()) + { + hxx_path = out_dir / hxx_path; + ixx_path = out_dir / ixx_path; + fwd_path = out_dir / fwd_path; + dep_path = out_dir / dep_path; + + for (Paths::iterator i (cxx_paths.begin ()); + i != cxx_paths.end (); ++i) + *i = out_dir / *i; + } + + // + // + WideOutputFileStream hxx; + WideOutputFileStream ixx; + WideOutputFileStream fwd; + WideOutputFileStream dep; + WideOutputFileStreams cxx; + + // DEP + // + if (gen_dep) + { + dep.open (dep_path.string ().c_str (), ios_base::out); + + if (!dep.is_open ()) + { + wcerr << dep_path << ": error: unable to open in write mode" << endl; + throw Failed (); + } + + unlinks.add (dep_path); + file_list.push_back (dep_path.string ()); + } + + // FWD + // + if (gen_cxx && forward) + { + fwd.open (fwd_path.string ().c_str (), ios_base::out); + + if (!fwd.is_open ()) + { + wcerr << fwd_path << ": error: unable to open in write mode" << endl; + throw Failed (); + } + + unlinks.add (fwd_path); + file_list.push_back (fwd_path.string ()); + } + + // HXX + // + if (gen_cxx && header) + { + hxx.open (hxx_path.string ().c_str (), ios_base::out); + + if (!hxx.is_open ()) + { + wcerr << hxx_path << ": error: unable to open in write mode" << endl; + throw Failed (); + } + + unlinks.add (hxx_path); + file_list.push_back (hxx_path.string ()); + } + + // IXX + // + if (gen_cxx && inline_) + { + ixx.open (ixx_path.string ().c_str (), ios_base::out); + + if (!ixx.is_open ()) + { + wcerr << ixx_path << ": error: unable to open in write mode" << endl; + throw Failed (); + } + + unlinks.add (ixx_path); + file_list.push_back (ixx_path.string ()); + } + + // CXX + // + if (gen_cxx && source) + { + for (Paths::iterator i (cxx_paths.begin ()); + i != cxx_paths.end (); ++i) + { + shared_ptr s ( + new (shared) WideOutputFileStream ( + i->string ().c_str (), ios_base::out)); + + if (!s->is_open ()) + { + wcerr << *i << ": error: unable to open in write mode" << endl; + throw Failed (); + } + + unlinks.add (*i); + file_list.push_back (i->string ()); + cxx.push_back (s); + } + } + + // Print copyright and license. + // + char const* copyright ( + ops.proprietary_license () ? copyright_proprietary : copyright_gpl); + + if (gen_cxx && header) + hxx << copyright; + + if (gen_cxx && forward) + fwd << copyright; + + if (ops.generate_doxygen ()) + { + // Use native path format. + // + hxx << "/**" << endl + << " * @file" << endl + << " * @brief Generated from " << name.c_str () << "." << endl + << " */" << endl + << endl; + + } + + if (gen_cxx && inline_) + ixx << copyright; + + if (gen_cxx && source) + { + for (WideOutputFileStreams::iterator i (cxx.begin ()); + i != cxx.end (); ++i) + **i << copyright; + } + + + // Prologue. + // + WideInputFileStream prologue; + { + NarrowString name (ops.prologue_file ()); + + if (name) + open (prologue, name); + } + + // Epilogue. + // + WideInputFileStream epilogue; + { + NarrowString name (ops.epilogue_file ()); + + if (name) + open (epilogue, name); + } + + // SLOC counter. + // + size_t sloc_total (0); + bool show_sloc (ops.show_sloc ()); + + typedef + compiler::ostream_filter + ind_filter; + + typedef + compiler::ostream_filter + sloc_filter; + + // + // + Regex guard_expr ("/([a-z])([A-Z])/$1_$2/"); // Split words. + NarrowString guard_prefix (ops.guard_prefix ()); + + if (!guard_prefix) + guard_prefix = file_path.directory ().string (); + + if (guard_prefix) + guard_prefix += '_'; + + // DEP + // + if (gen_dep) + { + NarrowString target; + NarrowStrings const& ts (ops.dep_target ()); + + if (!ts.empty ()) + { + for (NarrowStrings::const_iterator i (ts.begin ()); + i != ts.end (); ++i) + target += (target.empty () ? "" : " \\\n") + *i; + } + else + { + target = hxx_path.string (); + + if (forward) + target += " \\\n" + fwd_path.string (); + + if (inline_) + target += " \\\n" + ixx_path.string (); + + for (Paths::iterator i (cxx_paths.begin ()); + i != cxx_paths.end (); ++i) + target += " \\\n" + i->string (); + + target += " \\\n" + dep_path.string (); + } + + dep << target.c_str () << ':'; + + XSDFrontend::Generators::Dependencies gen; + Paths prq (gen.generate (schema, file_path)); + + for (Paths::iterator i (prq.begin ()); i != prq.end (); ++i) + dep << " \\" << endl + << " " << *i; + + dep << endl; + + // If requested, generate phony rules for included/imported schemas + // but not the main file which is the first in the list. + // + if (ops.dep_phony () && prq.size () > 1) + { + for (Paths::iterator i (prq.begin () + 1); i != prq.end (); ++i) + dep << endl + << *i << ':' << endl; + } + } + + // FWD + // + if (gen_cxx && forward) + { + Context ctx (fwd, + schema, + file_path, + ops, + counts, + generate_xml_schema, + &string_literal_map, + &fwd_expr, + &hxx_expr, + &ixx_expr); + + sloc_filter sloc (fwd); + + // Guard + // + String guard (guard_expr.replace (guard_prefix + fwd_name)); + guard = ctx.escape (guard); // make a c++ id + std::transform (guard.begin (), guard.end(), guard.begin (), upcase); + + fwd << "#ifndef " << guard << endl + << "#define " << guard << endl + << endl; + + if (ctx.std >= cxx_version::cxx11) + { + fwd << "#ifndef XSD_CXX11" << endl + << "#define XSD_CXX11" << endl + << "#endif" << endl + << endl; + } + + if (ctx.char_type == L"char") + { + fwd << "#ifndef XSD_USE_CHAR" << endl + << "#define XSD_USE_CHAR" << endl + << "#endif" << endl + << endl; + + fwd << "#ifndef XSD_CXX_TREE_USE_CHAR" << endl + << "#define XSD_CXX_TREE_USE_CHAR" << endl + << "#endif" << endl + << endl; + } + else if (ctx.char_type == L"wchar_t") + { + fwd << "#ifndef XSD_USE_WCHAR" << endl + << "#define XSD_USE_WCHAR" << endl + << "#endif" << endl + << endl; + + fwd << "#ifndef XSD_CXX_TREE_USE_WCHAR" << endl + << "#define XSD_CXX_TREE_USE_WCHAR" << endl + << "#endif" << endl + << endl; + } + + // Copy prologue. + // + fwd << "// Begin prologue." << endl + << "//" << endl; + + append (fwd, ops.fwd_prologue (), ops.prologue ()); + append (fwd, ops.fwd_prologue_file (), prologue); + + fwd << "//" << endl + << "// End prologue." << endl + << endl; + + // Version check. + // + fwd << "#include " << endl + << endl + << "#if (LIBXSD_VERSION != " << XSD_VERSION << "L)" << endl + << "#error XSD runtime version mismatch" << endl + << "#endif" << endl + << endl; + + fwd << "#include " << endl + << endl; + + // Generate. + // + { + ind_filter ind (fwd); // We don't want to indent prologues/epilogues. + generate_forward (ctx); + } + + fwd << "#include " << endl + << endl; + + // Copy epilogue. + // + fwd << "// Begin epilogue." << endl + << "//" << endl; + + append (fwd, ops.fwd_epilogue_file (), epilogue); + append (fwd, ops.fwd_epilogue (), ops.epilogue ()); + + fwd << "//" << endl + << "// End epilogue." << endl + << endl; + + fwd << "#endif // " << guard << endl; + + if (show_sloc) + wcerr << fwd_path << ": " << sloc.stream ().count () << endl; + + sloc_total += sloc.stream ().count (); + } + + // HXX + // + if (gen_cxx && header) + { + Context ctx (hxx, + schema, + file_path, + ops, + counts, + generate_xml_schema, + &string_literal_map, + &fwd_expr, + &hxx_expr, + &ixx_expr); + + sloc_filter sloc (hxx); + + // Guard + // + String guard (guard_expr.replace (guard_prefix + hxx_name)); + guard = ctx.escape (guard); // make a c++ id + std::transform (guard.begin (), guard.end(), guard.begin (), upcase); + + hxx << "#ifndef " << guard << endl + << "#define " << guard << endl + << endl; + + if (!forward) + { + if (ctx.std >= cxx_version::cxx11) + { + hxx << "#ifndef XSD_CXX11" << endl + << "#define XSD_CXX11" << endl + << "#endif" << endl + << endl; + } + + if (ctx.char_type == L"char") + { + hxx << "#ifndef XSD_USE_CHAR" << endl + << "#define XSD_USE_CHAR" << endl + << "#endif" << endl + << endl; + + hxx << "#ifndef XSD_CXX_TREE_USE_CHAR" << endl + << "#define XSD_CXX_TREE_USE_CHAR" << endl + << "#endif" << endl + << endl; + } + else if (ctx.char_type == L"wchar_t") + { + hxx << "#ifndef XSD_USE_WCHAR" << endl + << "#define XSD_USE_WCHAR" << endl + << "#endif" << endl + << endl; + + hxx << "#ifndef XSD_CXX_TREE_USE_WCHAR" << endl + << "#define XSD_CXX_TREE_USE_WCHAR" << endl + << "#endif" << endl + << endl; + } + } + else if (!generate_xml_schema) + { + // Generate it before the prologue so that we get the above + // defines. + // + hxx << "#include " << ctx.process_include_path (fwd_name) + << endl << endl; + } + + // Copy prologue. + // + hxx << "// Begin prologue." << endl + << "//" << endl; + + append (hxx, ops.hxx_prologue (), ops.prologue ()); + append (hxx, ops.hxx_prologue_file (), prologue); + + hxx << "//" << endl + << "// End prologue." << endl + << endl; + + // Version check. + // + hxx << "#include " << endl + << endl + << "#if (LIBXSD_VERSION != " << XSD_VERSION << "L)" << endl + << "#error XSD runtime version mismatch" << endl + << "#endif" << endl + << endl; + + hxx << "#include " << endl + << endl; + + // Generate. + // + { + ind_filter ind (hxx); // We don't want to indent prologues/epilogues. + + if (!generate_xml_schema && !forward) + generate_forward (ctx); + + generate_tree_header (ctx); + + if (!generate_xml_schema) + { + if (ops.generate_ostream ()) + generate_stream_header (ctx); + + if (!ops.generate_element_type () && !ops.suppress_parsing ()) + generate_parser_header (ctx); + + if (ops.generate_serialization ()) + generate_serialization_header (ctx); + + if (!ops.generate_insertion ().empty ()) + generate_stream_insertion_header (ctx); + } + } + + if (inline_) + { + hxx << "#ifndef XSD_DONT_INCLUDE_INLINE" << endl + << "#include " << ctx.process_include_path (ixx_name) << endl + << "#endif // XSD_DONT_INCLUDE_INLINE" << endl + << endl; + } + + hxx << "#include " << endl + << endl; + + // Copy epilogue. + // + hxx << "// Begin epilogue." << endl + << "//" << endl; + + append (hxx, ops.hxx_epilogue_file (), epilogue); + append (hxx, ops.hxx_epilogue (), ops.epilogue ()); + + hxx << "//" << endl + << "// End epilogue." << endl + << endl; + + hxx << "#endif // " << guard << endl; + + if (show_sloc) + wcerr << hxx_path << ": " << sloc.stream ().count () << endl; + + sloc_total += sloc.stream ().count (); + } + + + // IXX + // + if (gen_cxx && inline_) + { + Context ctx (ixx, + schema, + file_path, + ops, + counts, + generate_xml_schema, + &string_literal_map, + &fwd_expr, + &hxx_expr, + &ixx_expr); + + sloc_filter sloc (ixx); + + // Guard + // + String guard (guard_expr.replace (guard_prefix + ixx_name)); + guard = ctx.escape (guard); // make a c++ id + std::transform (guard.begin (), guard.end(), guard.begin (), upcase); + + ixx << "#ifndef " << guard.c_str () << endl + << "#define " << guard.c_str () << endl + << endl; + + // Copy prologue. + // + ixx << "// Begin prologue." << endl + << "//" << endl; + + append (ixx, ops.ixx_prologue (), ops.prologue ()); + append (ixx, ops.ixx_prologue_file (), prologue); + + ixx << "//" << endl + << "// End prologue." << endl + << endl; + + // Generate. + // + { + ind_filter ind (ixx); // We don't want to indent prologues/epilogues. + generate_tree_inline (ctx, 1, 0); + } + + // Copy epilogue. + // + ixx << "// Begin epilogue." << endl + << "//" << endl; + + append (ixx, ops.ixx_epilogue_file (), epilogue); + append (ixx, ops.ixx_epilogue (), ops.epilogue ()); + + ixx << "//" << endl + << "// End epilogue." << endl + << endl; + + ixx << "#endif // " << guard.c_str () << endl; + + if (show_sloc) + wcerr << ixx_path << ": " << sloc.stream ().count () << endl; + + sloc_total += sloc.stream ().count (); + } + + // CXX + // + if (gen_cxx && source) + { + size_t first_unit (0); // First unit in the current part. + + for (size_t part (0); part < parts; ++part) + { + // Figure out the range of units for this part. + // + size_t last_unit (first_unit); + + if (units != 0) + { + size_t complexity (counts.complexity[last_unit]); + + while (complexity < complexity_per_part) + { + // Make sure there will be at least one unit for each part left. + // + if ((last_unit + 1) >= units || + (units - (last_unit + 1) - 1) < (parts - part - 1)) + break; + + // Check if the increase in complexity should be kept in this + // part or moved to the next. + // + size_t new_complexity ( + complexity + counts.complexity[last_unit + 1]); + + if (new_complexity > complexity_per_part) + { + if ((new_complexity - complexity_per_part) > + (counts.complexity[last_unit + 1] / 2)) + break; + } + + last_unit++; + complexity = new_complexity; + } + + if (part + 1 == parts) + { + // Last part. + // + last_unit = units - 1; + } + } + + // + // + size_t first (first_unit); + size_t last (last_unit); + + first_unit = last_unit + 1; + + //wcerr << "[" << first << ", " << last << "]: " << complexity + // << endl; + + WideOutputFileStream& os (*cxx[part]); + + Context ctx (os, + schema, + file_path, + ops, + counts, + generate_xml_schema, + &string_literal_map, + &fwd_expr, + &hxx_expr, + &ixx_expr); + + sloc_filter sloc (os); + + // Copy prologue. + // + os << "// Begin prologue." << endl + << "//" << endl; + + append (os, ops.cxx_prologue (), ops.prologue ()); + append (os, ops.cxx_prologue_file (), prologue); + + os << "//" << endl + << "// End prologue." << endl + << endl; + + os << "#include " << endl + << endl; + + os << "#include " << ctx.process_include_path (hxx_name) << endl + << endl; + + // Generate. + // + { + // We don't want to indent prologues/epilogues. + // + ind_filter ind (os); + + if (!inline_) + generate_tree_inline (ctx, first, last); + + generate_tree_source (ctx, first, last); + + if (ops.generate_ostream ()) + generate_stream_source (ctx, first, last); + + if (!ops.generate_element_type () && !ops.suppress_parsing ()) + generate_parser_source (ctx, first, last); + + if (ops.generate_serialization ()) + generate_serialization_source (ctx, first, last); + + if (!ops.generate_extraction ().empty ()) + generate_stream_extraction_source (ctx); + + if (!ops.generate_insertion ().empty ()) + generate_stream_insertion_source (ctx); + } + + os << "#include " << endl + << endl; + + // Copy epilogue. + // + os << "// Begin epilogue." << endl + << "//" << endl; + + append (os, ops.cxx_epilogue_file (), epilogue); + append (os, ops.cxx_epilogue (), ops.epilogue ()); + + os << "//" << endl + << "// End epilogue." << endl + << endl; + + if (show_sloc) + wcerr << cxx_paths[part] << ": " << sloc.stream ().count () + << endl; + + sloc_total += sloc.stream ().count (); + } + } + + return sloc_total; + } + catch (UnrepresentableCharacter const& e) + { + wcerr << "error: character at position " << e.position () << " " + << "in string '" << e.string () << "' is unrepresentable in " + << "the target encoding" << endl; + + wcerr << "info: use the --custom-literals option to provide custom " + << "string literals mapping" << endl; + + throw Failed (); + } + catch (NoNamespaceMapping const& e) + { + wcerr << e.file () << ":" << e.line () << ":" << e.column () + << ": error: unable to map XML Schema namespace '" << e.ns () + << "' to C++ namespace" << endl; + + wcerr << e.file () << ":" << e.line () << ":" << e.column () + << ": info: use the --namespace-map or --namespace-regex option " + << "to provide custom mapping" << endl; + + throw Failed (); + } + catch (InvalidNamespaceMapping const& e) + { + wcerr << "error: invalid XML to C++ namespace mapping specified: " + << "'" << e.mapping () << "': " << e.reason () << endl; + + throw Failed (); + } + catch (InvalidCustomTypeMapping const& e) + { + wcerr << "error: invalid custom type mapping specified: " + << "'" << e.mapping () << "': " << e.reason () << endl; + + throw Failed (); + } + catch (cutl::re::format const& e) + { + wcerr << "error: invalid regex: '" << + e.regex ().c_str () << "': " << + e.description ().c_str () << endl; + + throw Failed (); + } + catch (cutl::re::wformat const& e) + { + wcerr << "error: invalid regex: '" << + e.regex () << "': " << e.description ().c_str () << endl; + + throw Failed (); + } + } +} diff --git a/xsd/xsd/cxx/tree/generator.hxx b/xsd/xsd/cxx/tree/generator.hxx new file mode 100644 index 0000000..a9b96fe --- /dev/null +++ b/xsd/xsd/cxx/tree/generator.hxx @@ -0,0 +1,44 @@ +// file : xsd/cxx/tree/generator.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_TREE_GENERATOR_HXX +#define XSD_CXX_TREE_GENERATOR_HXX + +#include // Path +#include + +#include +#include + +#include +#include + +namespace CXX +{ + namespace Tree + { + class Generator + { + public: + static void + usage (); + + struct Failed {}; + + static size_t + generate (options const&, + XSDFrontend::SemanticGraph::Schema&, + XSDFrontend::SemanticGraph::Path const& file, + bool file_per_type, + StringLiteralMap const&, + const WarningSet& disabled_warnings, + FileList& file_list, + AutoUnlinks& unlinks); + + private: + Generator (); + }; + } +} + +#endif // XSD_CXX_TREE_GENERATOR_HXX diff --git a/xsd/xsd/cxx/tree/name-processor.cxx b/xsd/xsd/cxx/tree/name-processor.cxx new file mode 100644 index 0000000..e26a5d8 --- /dev/null +++ b/xsd/xsd/cxx/tree/name-processor.cxx @@ -0,0 +1,2399 @@ +// file : xsd/cxx/tree/name-processor.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include +#include +#include +#include + +#include + +#include +#include + +using namespace std; + +namespace CXX +{ + namespace Tree + { + namespace + { + // + // + typedef set NameSet; + + class Context: public Tree::Context + { + public: + struct Failed {}; + + Context (Tree::options const& ops, + Counts const& counts, + bool generate_xml_schema, + SemanticGraph::Schema& root, + SemanticGraph::Path const& path, + StringLiteralMap const& map) + : Tree::Context (std::wcerr, + root, + path, + ops, + counts, + generate_xml_schema, + &map, + 0, + 0, + 0), + global_type_names (global_type_names_), + global_element_names (global_element_names_), + detach (ops.generate_detach ()), + type_regex (type_regex_), + accessor_regex (accessor_regex_), + one_accessor_regex (one_accessor_regex_), + opt_accessor_regex (opt_accessor_regex_), + seq_accessor_regex (seq_accessor_regex_), + modifier_regex (modifier_regex_), + one_modifier_regex (one_modifier_regex_), + opt_modifier_regex (opt_modifier_regex_), + seq_modifier_regex (seq_modifier_regex_), + parser_regex (parser_regex_), + serializer_regex (serializer_regex_), + const_regex (const_regex_), + enumerator_regex (enumerator_regex_), + element_type_regex (element_type_regex_) + { + NarrowString tn (options.type_naming ()); + NarrowString fn (options.function_naming ()); + + // Type name regex. + // + { + // Predefined rules. The most frequently used come last: global + // names, two components (,type), three components + // (,const,iterator), and one component (value in enum). + // + if (tn == "knr") + { + type_regex.push_back ("/(?:[^ ]* )?([^,]+),([^,]+),([^,]+),([^,]+)/$1_$2_$3_$4/"); + type_regex.push_back ("/(?:[^ ]* )?([^,]+),([^,]+),([^,]+)/$1_$2_$3/"); + type_regex.push_back ("/(?:[^ ]* )?([^,]+),([^,]+)/$1_$2/"); + type_regex.push_back ("/(?:[^ ]* )?([^,]+)/$1/"); + + /* + type_regex.push_back ("/([^,]+)/$1/"); + type_regex.push_back ("/([^,]+),([^,]+),([^,]+),([^,]+)/$1_$2_$3_$4/"); + type_regex.push_back ("/([^,]+),([^,]+),([^,]+)/$1_$2_$3/"); + type_regex.push_back ("/([^,]+),([^,]+)/$1_$2/"); + type_regex.push_back ("/[^ ]* (.+)/$1/"); + */ + } + else + { + // Upper camel case or Java. + // + type_regex.push_back ("/(?:[^ ]* )?([^,]+),([^,]+),([^,]+),([^,]+)/\\u$1\\u$2\\u$3\\u$4/"); + type_regex.push_back ("/(?:[^ ]* )?([^,]+),([^,]+),([^,]+)/\\u$1\\u$2\\u$3/"); + type_regex.push_back ("/(?:[^ ]* )?([^,]+),([^,]+)/\\u$1\\u$2/"); + type_regex.push_back ("/(?:[^ ]* )?([^,]+)/\\u$1/"); + + /* + type_regex.push_back ("/([^,]+)/\\u$1/"); + type_regex.push_back ("/([^,]+),([^,]+),([^,]+),([^,]+)/\\u$1\\u$2\\u$3\\u$4/"); + type_regex.push_back ("/([^,]+),([^,]+),([^,]+)/\\u$1\\u$2\\u$3/"); + type_regex.push_back ("/([^,]+),([^,]+)/\\u$1\\u$2/"); + type_regex.push_back ("/[^ ]* (.+)/\\u$1/"); + */ + + } + + compile_regex (options.type_regex (), type_regex, "type"); + } + + // Accessor name regex. + // + { + // Predefined rules. The most frequently used come last: one + // component, three components (,default,value) and two + // component (dom,document). + // + if (fn == "knr") + { + accessor_regex.push_back ("/([^,]+),([^,]+)/$1_$2/"); + accessor_regex.push_back ("/([^,]+),([^,]+),([^,]+)/$1_$2_$3/"); + accessor_regex.push_back ("/([^,]+)/$1/"); + } + else if (fn == "lcc") + { + accessor_regex.push_back ("/([^,]+),([^,]+)/\\l$1\\u$2/"); + accessor_regex.push_back ("/([^,]+),([^,]+),([^,]+)/\\l$1\\u$2\\u$3/"); + accessor_regex.push_back ("/([^,]+)/\\l$1/"); + } + else + { + // Java: add get. + // + accessor_regex.push_back ("/([^,]+),([^,]+)/get\\u$1\\u$2/"); + accessor_regex.push_back ("/([^,]+),([^,]+),([^,]+)/get\\u$1\\u$2\\u$3/"); + accessor_regex.push_back ("/([^,]+)/get\\u$1/"); + } + + compile_regex (options.accessor_regex (), + accessor_regex, + "accessor"); + + compile_regex (options.one_accessor_regex (), + one_accessor_regex, + "one accessor"); + + compile_regex (options.opt_accessor_regex (), + opt_accessor_regex, + "optional accessor"); + + compile_regex (options.seq_accessor_regex (), + seq_accessor_regex, + "sequence accessor"); + } + + // Modifier name regex. + // + { + if (fn == "knr") + { + // any,attribute + // + modifier_regex.push_back ("/([^,]+),([^,]+)/$1_$2/"); + } + else if (fn == "lcc") + { + modifier_regex.push_back ("/([^,]+),([^,]+)/\\l$1\\u$2/"); + modifier_regex.push_back ("/([^,]+)/\\l$1/"); + } + else + { + // Java: add set. + // + modifier_regex.push_back ("/([^,]+),([^,]+)/set\\u$1\\u$2/"); + modifier_regex.push_back ("/([^,]+)/set\\u$1/"); + modifier_regex.push_back ("/detach,([^,]+)/detach\\u$1/"); + } + + compile_regex (options.modifier_regex (), + modifier_regex, + "modifier"); + + compile_regex (options.one_modifier_regex (), + one_modifier_regex, + "one modifier"); + + compile_regex (options.opt_modifier_regex (), + opt_modifier_regex, + "optional modifier"); + + compile_regex (options.seq_modifier_regex (), + seq_modifier_regex, + "sequence modifier"); + } + + // Parser name regex. + // + { + if (fn == "lcc") + { + parser_regex.push_back ("/(.+)/\\l$1/"); + } + else if (fn == "java") + { + // Java: add parse. + // + parser_regex.push_back ("/(.+)/parse\\u$1/"); + } + + compile_regex (options.parser_regex (), parser_regex, "parser"); + } + + // Serializer name regex. + // + { + if (fn == "lcc") + { + serializer_regex.push_back ("/(.+)/\\l$1/"); + } + else if (fn == "java") + { + // Java: add serialize. + // + serializer_regex.push_back ("/(.+)/serialize\\u$1/"); + } + + compile_regex (options.serializer_regex (), + serializer_regex, + "serializer"); + } + + // Const regex. + // + { + if (fn == "knr") + { + const_regex.push_back ("/([^,]+),([^,]+),([^,]+)/$1_$2_$3/"); + const_regex.push_back ("/([^,]+),([^,]+)/$1_$2/"); + } + else if (fn == "lcc") + { + const_regex.push_back ("/([^,]+),([^,]+),([^,]+)/\\l$1_\\u$2_\\u$3/"); + const_regex.push_back ("/([^,]+),([^,]+)/\\l$1\\u$2/"); + } + else + { + // Java: all uppercase. + // + const_regex.push_back ("/([^,]+),([^,]+),([^,]+)/\\U$1_$2_$3/"); + const_regex.push_back ("/([^,]+),([^,]+)/\\U$1_$2/"); + } + + compile_regex (options.const_regex (), const_regex, "const"); + } + + // Enumerator name regex. + // + { + // By default map an empty enumerator to the 'empty' word. + // + enumerator_regex.push_back ("/^$/empty/"); + + compile_regex (options.enumerator_regex (), + enumerator_regex, + "enumerator"); + } + + // Element type regex. + // + compile_regex (options.element_type_regex (), + element_type_regex, + "element_type"); + } + + protected: + Context (Context& c) + : Tree::Context (c), + global_type_names (c.global_type_names), + global_element_names (c.global_element_names), + detach (c.detach), + type_regex (c.type_regex), + accessor_regex (c.accessor_regex), + one_accessor_regex (c.one_accessor_regex), + opt_accessor_regex (c.opt_accessor_regex), + seq_accessor_regex (c.seq_accessor_regex), + modifier_regex (c.modifier_regex), + one_modifier_regex (c.one_modifier_regex), + opt_modifier_regex (c.opt_modifier_regex), + seq_modifier_regex (c.seq_modifier_regex), + parser_regex (c.parser_regex), + serializer_regex (c.serializer_regex), + const_regex (c.const_regex), + enumerator_regex (c.enumerator_regex), + element_type_regex (c.element_type_regex) + { + } + + public: + typedef cutl::re::wregexsub Regex; + typedef cutl::re::wformat RegexFormat; + + struct RegexVector: vector + { + void + push_back (String const& r) + { + vector::push_back (Regex (r)); + } + }; + + String + process_regex (String const& name, + RegexVector const& rv, + String const& id) + { + bool trace (options.name_regex_trace ()); + + if (trace) + os << id << " name: '" << name << "'" << endl; + + for (RegexVector::const_reverse_iterator i (rv.rbegin ()); + i != rv.rend (); ++i) + { + if (trace) + os << "try: '" << i->regex () << "' : "; + + if (i->match (name)) + { + String r (i->replace (name)); + + if (trace) + os << "'" << r << "' : +" << endl; + + return r; + } + + if (trace) + os << '-' << endl; + } + + return name; + } + + String + process_regex (String const& name, + RegexVector const& primary, + RegexVector const& backup, + String const& id) + { + bool trace (options.name_regex_trace ()); + + if (trace) + os << id << " name: '" << name << "'" << endl; + + for (RegexVector::const_reverse_iterator i (primary.rbegin ()); + i != primary.rend (); ++i) + { + if (trace) + os << "try: '" << i->regex () << "' : "; + + if (i->match (name)) + { + String r (i->replace (name)); + + if (trace) + os << "'" << r << "' : +" << endl; + + return r; + } + + if (trace) + os << '-' << endl; + } + + for (RegexVector::const_reverse_iterator i (backup.rbegin ()); + i != backup.rend (); ++i) + { + if (trace) + os << "try: '" << i->regex () << "' : "; + + if (i->match (name)) + { + String r (i->replace (name)); + + if (trace) + os << "'" << r << "' : +" << endl; + + return r; + } + + if (trace) + os << '-' << endl; + } + + return name; + } + + String + process_regex (String const& ns, + String const& name, + RegexVector const& rv, + String const& id) + { + String s (ns + L' ' + name); + bool trace (options.name_regex_trace ()); + + if (trace) + os << id << " name: '" << s << "'" << endl; + + for (RegexVector::const_reverse_iterator i (rv.rbegin ()); + i != rv.rend (); ++i) + { + if (trace) + os << "try: '" << i->regex () << "' : "; + + if (i->match (s)) + { + String r (i->replace (s)); + + if (trace) + os << "'" << r << "' : +" << endl; + + return r; + } + + if (trace) + os << '-' << endl; + } + + return name; + } + + String + process_regex (String const& ns, + String const& name, + RegexVector const& primary, + RegexVector const& backup, + String const& id) + { + String s (ns + L' ' + name); + bool trace (options.name_regex_trace ()); + + if (trace) + os << id << " name: '" << s << "'" << endl; + + for (RegexVector::const_reverse_iterator i (primary.rbegin ()); + i != primary.rend (); ++i) + { + if (trace) + os << "try: '" << i->regex () << "' : "; + + if (i->match (s)) + { + String r (i->replace (s)); + + if (trace) + os << "'" << r << "' : +" << endl; + + return r; + } + + if (trace) + os << '-' << endl; + } + + for (RegexVector::const_reverse_iterator i (backup.rbegin ()); + i != backup.rend (); ++i) + { + if (trace) + os << "try: '" << i->regex () << "' : "; + + if (i->match (s)) + { + String r (i->replace (s)); + + if (trace) + os << "'" << r << "' : +" << endl; + + return r; + } + + if (trace) + os << '-' << endl; + } + + return name; + } + + public: + String + find_name (String const& base_name, + NameSet& set, + bool insert = true) + { + String name (base_name); + + for (size_t i (1); set.find (name) != set.end (); ++i) + { + std::wostringstream os; + os << i; + name = base_name + os.str (); + } + + if (insert) + set.insert (name); + + return name; + } + + private: + void + compile_regex (NarrowStrings const& sv, + RegexVector& rv, + String const& id) + { + for (NarrowStrings::const_iterator i (sv.begin ()); i != sv.end (); + ++i) + { + try + { + rv.push_back (*i); + } + catch (RegexFormat const& e) + { + os << "error: invalid " << id << " name regex: '" << + e.regex () << "': " << e.description ().c_str () << endl; + + throw Failed (); + } + } + } + + private: + map global_type_names_; + map global_element_names_; + + RegexVector type_regex_; + RegexVector accessor_regex_; + RegexVector one_accessor_regex_; + RegexVector opt_accessor_regex_; + RegexVector seq_accessor_regex_; + RegexVector modifier_regex_; + RegexVector one_modifier_regex_; + RegexVector opt_modifier_regex_; + RegexVector seq_modifier_regex_; + RegexVector parser_regex_; + RegexVector serializer_regex_; + RegexVector const_regex_; + RegexVector enumerator_regex_; + RegexVector element_type_regex_; + + public: + map& global_type_names; + map& global_element_names; + + bool detach; + + RegexVector& type_regex; + RegexVector& accessor_regex; + RegexVector& one_accessor_regex; + RegexVector& opt_accessor_regex; + RegexVector& seq_accessor_regex; + RegexVector& modifier_regex; + RegexVector& one_modifier_regex; + RegexVector& opt_modifier_regex; + RegexVector& seq_modifier_regex; + RegexVector& parser_regex; + RegexVector& serializer_regex; + RegexVector& const_regex; + RegexVector& enumerator_regex; + RegexVector& element_type_regex; + }; + + // + // + struct Enumerator: Traversal::Enumerator, Context + { + Enumerator (Context& c, NameSet& set) + : Context (c), set_ (set) + { + } + + virtual void + traverse (Type& e) + { + // Process the name with enumerator name regex. + // + String name ( + process_regex (e.name (), enumerator_regex, L"enumerator")); + + // Escape and unclash. + // + name = find_name (escape (name), set_); + e.context ().set ("name", name); + } + + private: + NameSet& set_; + }; + + // + // + struct Enumeration: Traversal::Enumeration, Context + { + Enumeration (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& e) + { + // Use processed name. + // + String name (e.context ().get ("name")); + + // If renamed name is empty then we are not generating + // anything for this type and name processing is not + // required. + // + if (renamed_type (e, name) && !name) + return; + + NameSet enum_set; + enum_set.insert (name); + + Enumerator enumerator (*this, enum_set); + Traversal::Names names (enumerator); + + Traversal::Enumeration::names (e, names); + + // Assign name to the value type. First process the name + // with type name regex. + // + String value_name ( + escape (process_regex ("value", type_regex, L"type"))); + e.context ().set ("value", find_name (value_name, enum_set)); + } + }; + + // + // + struct PrimaryMember: Traversal::Member, Context + { + PrimaryMember (Context& c, NameSet& name_set, NameSet& stem_set) + : Context (c), name_set_ (name_set), stem_set_ (stem_set) + { + } + + virtual void + traverse (Type& m) + { + if (Tree::Context::skip (m)) + return; + + String stem (find_name (m.name (), stem_set_)); + + m.context ().set ("stem", stem); + m.context ().set ("name", + find_name (escape (stem), name_set_, false)); + } + + private: + NameSet& name_set_; + NameSet& stem_set_; + }; + + // + // + struct DerivedMember: Traversal::Member, Context + { + DerivedMember (Context& c, NameSet& name_set) + : Context (c), name_set_ (name_set) + { + } + + virtual void + traverse (Type& m) + { + if (Tree::Context::skip (m)) + return; + + SemanticGraph::Complex& c ( + dynamic_cast (m.scope ())); + + size_t max (Tree::Context::max (m)); + size_t min (Tree::Context::min (m)); + + String const& s (m.context ().get ("stem")); + String const& b (m.context ().get ("name")); + + bool def_attr (m.default_p () && + m.is_a ()); + + // Accessors/modifiers. Note that we postpone inserting + // the names into the name_set to avoid over-escaping. + // + String an, mn; + + if (max != 1) + { + an = find_name ( + escape (process_regex (s, + seq_accessor_regex, + accessor_regex, + L"sequence accessor")), + name_set_, + false); + + mn = find_name ( + escape (process_regex (s, + seq_modifier_regex, + modifier_regex, + L"sequence modifier")), + name_set_, + false); + } + else if (min == 0 && !def_attr) + { + an = find_name ( + escape (process_regex (s, + opt_accessor_regex, + accessor_regex, + L"optional accessor")), + name_set_, + false); + + mn = find_name ( + escape (process_regex (s, + opt_modifier_regex, + modifier_regex, + L"optional modifier")), + name_set_, + false); + } + else + { + an = find_name ( + escape (process_regex (s, + one_accessor_regex, + accessor_regex, + L"one accessor")), + name_set_, + false); + + mn = find_name ( + escape (process_regex (s, + one_modifier_regex, + modifier_regex, + L"one modifier")), + name_set_, + false); + } + + m.context ().set ("aname", an); + m.context ().set ("mname", mn); + + name_set_.insert (b); + + if (an != b) + name_set_.insert (an); + + if (mn != b && mn != an) + name_set_.insert (mn); + + // Detach. + // + if (detach && max == 1 && (min == 1 || def_attr)) + { + String dn (find_name ( + escape (process_regex (L"detach," + s, + one_modifier_regex, + modifier_regex, + L"one modifier")), + name_set_)); + + m.context ().set ("dname", dn); + } + + // Types. + // + m.context ().set ( + "type", + find_name ( + escape (process_regex (s + L",type", type_regex, L"type")), + name_set_)); + + m.context ().set ( + "traits", + find_name ( + escape (process_regex (s + L",traits", type_regex, L"type")), + name_set_)); + + if (max != 1) + { + m.context ().set ( + "container", + find_name ( + escape (process_regex (s + L",sequence", type_regex, L"type")), + name_set_)); + + m.context ().set ( + "iterator", + find_name ( + escape (process_regex (s + L",iterator", type_regex, L"type")), + name_set_)); + + m.context ().set ( + "const-iterator", + find_name ( + escape ( + process_regex (s + L",const,iterator", type_regex, L"type")), + name_set_)); + } + else if (min == 0 && !def_attr) + { + m.context ().set ( + "container", + find_name ( + escape (process_regex (s + L",optional", type_regex, L"type")), + name_set_)); + } + + // Data member. + // + m.context ().set ("member", find_name (b + L"_", name_set_)); + + // Default value. + // + if (m.default_p ()) + { + bool simple (true); + + if (m.is_a ()) + { + IsSimpleType test (simple); + test.dispatch (m.type ()); + } + + if (simple) + { + String an ( + escape ( + process_regex ( + s + L",default,value", accessor_regex, L"accessor"))); + + m.context ().set ("default-value", find_name (an, name_set_)); + + bool lit (false); + { + IsLiteralValue test (lit); + test.dispatch (m.type ()); + } + + if (!lit) + { + m.context ().set ( + "default-value-member", + find_name (b + L"_default_value_", name_set_)); + } + } + } + + // Element id. + // + if (m.is_a () && ordered_p (c)) + { + String id ( + escape ( + process_regex ( + s + L",id", const_regex, L"const"))); + + m.context ().set ("ordered-id-name", find_name (id, name_set_)); + } + } + + private: + NameSet& name_set_; + }; + + + // + // + struct Any: Traversal::Any, Traversal::AnyAttribute, Context + { + Any (Context& c, + NameSet& name_set, + NameSet& stem_set, + bool& has_wildcard) + : Context (c), + name_set_ (name_set), + stem_set_ (stem_set), + has_wildcard_ (has_wildcard) + { + } + + virtual void + traverse (SemanticGraph::Any& a) + { + SemanticGraph::Complex& c ( + dynamic_cast (a.scope ())); + + size_t max (Tree::Context::max (a)); + size_t min (Tree::Context::min (a)); + + String s (find_name (L"any", stem_set_)); + + String b (find_name (escape (s), name_set_, false)); + a.context ().set ("name", b); + + // Accessors/modifiers. Note that we postpone inserting the + // names into the name_set to avoid over-escaping. + // + String an, mn; + + if (max != 1) + { + an = find_name ( + escape (process_regex (s, + seq_accessor_regex, + accessor_regex, + L"sequence accessor")), + name_set_, + false); + + mn = find_name ( + escape (process_regex (s, + seq_modifier_regex, + modifier_regex, + L"sequence modifier")), + name_set_, + false); + } + else if (min == 0) + { + an = find_name ( + escape (process_regex (s, + opt_accessor_regex, + accessor_regex, + L"optional accessor")), + name_set_, + false); + + mn = find_name ( + escape (process_regex (s, + opt_modifier_regex, + modifier_regex, + L"optional modifier")), + name_set_, + false); + } + else + { + an = find_name ( + escape (process_regex (s, + one_accessor_regex, + accessor_regex, + L"one accessor")), + name_set_, + false); + + mn = find_name ( + escape (process_regex (s, + one_modifier_regex, + modifier_regex, + L"one modifier")), + name_set_, + false); + } + + a.context ().set ("aname", an); + a.context ().set ("mname", mn); + + name_set_.insert (b); + + if (an != b) + name_set_.insert (an); + + if (mn != b && mn != an) + name_set_.insert (mn); + + // Types + // + if (max != 1) + { + a.context ().set ( + "container", + find_name ( + escape (process_regex (s + L",sequence", type_regex, L"type")), + name_set_)); + + a.context ().set ( + "iterator", + find_name ( + escape (process_regex (s + L",iterator", type_regex, L"type")), + name_set_)); + + a.context ().set ( + "const-iterator", + find_name ( + escape ( + process_regex (s + L",const,iterator", type_regex, L"type")), + name_set_)); + } + else if (min == 0) + { + a.context ().set ( + "container", + find_name ( + escape (process_regex (s + L",optional", type_regex, L"type")), + name_set_)); + } + + // Data member. + // + a.context ().set ("member", find_name (b + L"_", name_set_)); + + // Wildcard id. + // + if (ordered_p (c)) + { + String id ( + escape ( + process_regex ( + s + L",id", const_regex, L"const"))); + + a.context ().set ("ordered-id-name", find_name (id, name_set_)); + } + + if (!has_wildcard_) + has_wildcard_ = true; + } + + virtual void + traverse (SemanticGraph::AnyAttribute& a) + { + String s (find_name (L"any,attribute", stem_set_)); + + String b (find_name (escape (s), name_set_, false)); + a.context ().set ("name", b); + + // Accessors/modifiers. Note that we postpone inserting the + // names into the name_set to avoid over-escaping. + // + String an ( + find_name ( + escape (process_regex (s, accessor_regex, L"accessor")), + name_set_, + false)); + + String mn ( + find_name ( + escape (process_regex (s, modifier_regex, L"modifier")), + name_set_, + false)); + + a.context ().set ("aname", an); + a.context ().set ("mname", mn); + + name_set_.insert (b); + + if (an != b) + name_set_.insert (an); + + if (mn != b && mn != an) + name_set_.insert (mn); + + // Types + // + a.context ().set ( + "container", + find_name ( + escape (process_regex (s + L",set", type_regex, L"type")), + name_set_)); + + a.context ().set ( + "iterator", + find_name ( + escape (process_regex (s + L",iterator", type_regex, L"type")), + name_set_)); + + a.context ().set ( + "const-iterator", + find_name ( + escape ( + process_regex (s + L",const,iterator", type_regex, L"type")), + name_set_)); + + // Data member. + // + a.context ().set ("member", find_name (b + L"_", name_set_)); + + if (!has_wildcard_) + has_wildcard_ = true; + } + + private: + NameSet& name_set_; + NameSet& stem_set_; + bool& has_wildcard_; + }; + + // + // + struct Complex: Traversal::Complex, Context + { + Complex (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& c) + { + SemanticGraph::Context& ctx (c.context ()); + + // We leave this set around to allow other mappings to use + // this information. + // + ctx.set ("cxx-tree-name-processor-stem-set", NameSet ()); + ctx.set ("cxx-tree-name-processor-member-set", NameSet ()); + + // Use processed name. + // + String name (ctx.get ("name")); + + // If renamed name is empty then we are not generating + // anything for this type and name processing is not + // required. + // + if (renamed_type (c, name) && !name) + return; + + NameSet& stem_set ( + ctx.get ("cxx-tree-name-processor-stem-set")); + + NameSet& member_set ( + ctx.get ("cxx-tree-name-processor-member-set")); + + stem_set.insert (c.name ()); + member_set.insert (name); + + // Add our base's stems and members to the initial list. + // + if (c.inherits_p ()) + { + // @@ What if this types name is the same as one of base's + // members? + // + SemanticGraph::Type& base (c.inherits ().base ()); + + if (base.is_a () && + !base.is_a ()) + { + if (!base.context ().count ( + "cxx-tree-name-processor-member-set")) + { + dispatch (base); + } + + NameSet const& base_stem_set ( + base.context ().get ( + "cxx-tree-name-processor-stem-set")); + + stem_set.insert (base_stem_set.begin (), base_stem_set.end ()); + + NameSet const& base_member_set ( + base.context ().get ( + "cxx-tree-name-processor-member-set")); + + member_set.insert (base_member_set.begin (), + base_member_set.end ()); + } + } + + // First assign the "primary" names. + // + { + PrimaryMember member (*this, member_set, stem_set); + Traversal::Names names (member); + + Complex::names (c, names); + } + + // Derived names for members. + // + { + DerivedMember member (*this, member_set); + Traversal::Names names (member); + + Complex::names (c, names); + } + + // Names for the mixed content. + // + if (mixed_p (c)) + { + // Check if we already have the mixed content down inheritance + // hierarchy. + // + using SemanticGraph::Complex; + + for (Complex* p (&c); p->inherits_p ();) + { + if (Complex* b = dynamic_cast ( + &p->inherits ().base ())) + { + if (mixed_p (*b)) + { + SemanticGraph::Context& bctx (b->context ()); + ctx.set ("mixed-type", bctx.get ("mixed-type")); + ctx.set ("mixed-const-iterator", + bctx.get ("mixed-const-iterator")); + ctx.set ("mixed-ordered-id-name", + bctx.get ("mixed-ordered-id-name")); + ctx.set ("mixed-aname", bctx.get ("mixed-aname")); + ctx.set ("mixed-member", bctx.get ("mixed-member")); + ctx.set ("mixed-in-base", true); + break; + } + + p = b; + } + else + break; + } + + // If not, set up the names. + // + if (!ctx.count ("mixed-in-base")) + { + String s (find_name (L"text,content", stem_set)); + String n (find_name (escape (s), member_set, false)); + + String an (find_name ( + escape (process_regex (s, + seq_accessor_regex, + accessor_regex, + L"sequence accessor")), + member_set, + false)); + + String mn (find_name ( + escape (process_regex (s, + seq_modifier_regex, + modifier_regex, + L"sequence modifier")), + member_set, + false)); + + ctx.set ("mixed-aname", an); + ctx.set ("mixed-mname", mn); + + member_set.insert (name); + + if (an != n) + member_set.insert (an); + + if (mn != n && mn != an) + member_set.insert (mn); + + // Types. + // + ctx.set ( + "mixed-type", + find_name ( + escape (process_regex (s + L",type", type_regex, L"type")), + member_set)); + + ctx.set ( + "mixed-container", + find_name ( + escape (process_regex (s + L",sequence", type_regex, L"type")), + member_set)); + + ctx.set ( + "mixed-iterator", + find_name ( + escape (process_regex (s + L",iterator", type_regex, L"type")), + member_set)); + + ctx.set ( + "mixed-const-iterator", + find_name ( + escape ( + process_regex (s + L",const,iterator", type_regex, L"type")), + member_set)); + + // Text content id. + // + ctx.set ( + "mixed-ordered-id-name", + find_name ( + escape ( + process_regex (s + L",id", const_regex, L"const")), + member_set)); + + // Data member. + // + ctx.set ("mixed-member", find_name (n + L"_", member_set)); + } + } + + // Names for wildcards. + // + if (options.generate_wildcard ()) + { + bool has_wildcard (false); + Any any (*this, member_set, stem_set, has_wildcard); + Traversal::Names names (any); + Complex::names (c, names); + + // Assign names for dom_document. + // + if (has_wildcard) + { + // Check if we already have dom_document down inheritance + // hierarchy. + // + for (SemanticGraph::Complex* p (&c); p->inherits_p ();) + { + if (SemanticGraph::Complex* base = + dynamic_cast ( + &p->inherits ().base ())) + { + if (base->context ().count ("dom-document")) + { + c.context ().set ( + "dom-document", + base->context ().get ("dom-document")); + break; + } + + p = base; + } + else + break; + } + + // If not, set up the names. + // + if (!c.context ().count ("dom-document")) + { + String stem (find_name (L"dom,document", stem_set)); + + String an ( + escape ( + process_regex (stem, accessor_regex, L"accessor"))); + + c.context ().set ("dom-document", find_name (an, member_set)); + + c.context ().set ( + "dom-document-member", + find_name (escape (stem + L"_"), member_set)); + } + } + } + + // Names for the order container. + // + if (ordered_p (c)) + { + // Check if we already have the order container down + // inheritance hierarchy. + // + using SemanticGraph::Complex; + + for (Complex* p (&c); p->inherits_p ();) + { + if (Complex* b = dynamic_cast ( + &p->inherits ().base ())) + { + if (ordered_p (*b)) + { + SemanticGraph::Context& bctx (b->context ()); + ctx.set ("order-type", bctx.get ("order-type")); + ctx.set ("order-const-iterator", + bctx.get ("order-const-iterator")); + ctx.set ("order-aname", bctx.get ("order-aname")); + ctx.set ("order-member", bctx.get ("order-member")); + ctx.set ("order-in-base", true); + break; + } + + p = b; + } + else + break; + } + + // If not, set up the names. + // + if (!ctx.count ("order-in-base")) + { + String s (find_name (L"content,order", stem_set)); + String n (find_name (escape (s), member_set, false)); + + String an (find_name ( + escape (process_regex (s, + seq_accessor_regex, + accessor_regex, + L"sequence accessor")), + member_set, + false)); + + String mn (find_name ( + escape (process_regex (s, + seq_modifier_regex, + modifier_regex, + L"sequence modifier")), + member_set, + false)); + + ctx.set ("order-aname", an); + ctx.set ("order-mname", mn); + + member_set.insert (name); + + if (an != n) + member_set.insert (an); + + if (mn != n && mn != an) + member_set.insert (mn); + + // Types. + // + ctx.set ( + "order-type", + find_name ( + escape (process_regex (s + L",type", type_regex, L"type")), + member_set)); + + ctx.set ( + "order-container", + find_name ( + escape (process_regex (s + L",sequence", type_regex, L"type")), + member_set)); + + ctx.set ( + "order-iterator", + find_name ( + escape (process_regex (s + L",iterator", type_regex, L"type")), + member_set)); + + ctx.set ( + "order-const-iterator", + find_name ( + escape ( + process_regex (s + L",const,iterator", type_regex, L"type")), + member_set)); + + // Data member. + // + ctx.set ("order-member", find_name (n + L"_", member_set)); + } + } + } + }; + + + // + // + struct GlobalType: Traversal::Type, Context + { + GlobalType (Context& c, NameSet& set) + : Context (c), set_ (set) + { + } + + virtual void + traverse (SemanticGraph::Type& t) + { + // Process the name with type name regex. + // + String name (process_regex ( + namespace_ (t).name (), + t.name (), + type_regex, + L"type")); + + // Escape and unclash. + // + name = find_name (escape (name), set_); + t.context ().set ("name", name); + + // Also add renamed name if any. + // + if (renamed_type (t, name) && name) + set_.insert (name); + } + + private: + NameSet& set_; + }; + + + // + // + struct GlobalElement: Traversal::Element, + GlobalElementBase, + Context + { + GlobalElement (Context& c, + NameSet const& type_set, + NameSet& element_set) + : GlobalElementBase (c), + Context (c), + type_set_ (type_set), + element_set_ (element_set) + { + } + + virtual void + traverse (Type& e) + { + // First we need to figure out if we need to process this + // global element. + // + if (!generate_p (e)) + return; + + if (options.generate_element_type ()) + { + SemanticGraph::Context& ec (e.context ()); + + String name; + + if (doc_root_p (e)) + { + name = find_name ( + escape ( + process_regex ( + namespace_ (e).name (), + e.name (), + element_type_regex, + type_regex, + L"element type"))); + + // Assign inner names. + // + NameSet set; + set.insert (name); + + ec.set ( + "type", + Context::find_name ( + escape (process_regex (L"value,type", type_regex, L"type")), + set)); + + ec.set ( + "traits", + Context::find_name ( + escape (process_regex (L"value,traits", type_regex, L"type")), + set)); + + String an (Context::find_name ( + escape (process_regex ("value", + one_accessor_regex, + accessor_regex, + L"one accessor")), + set, + false)); + + String mn (Context::find_name ( + escape (process_regex ("value", + one_modifier_regex, + modifier_regex, + L"one modifier")), + set, + false)); + + ec.set ("aname", an); + ec.set ("mname", mn); + + set.insert (an); + + if (an != mn) + set.insert (mn); + + // Detach. + // + if (detach) + { + String dn (Context::find_name ( + escape (process_regex (L"detach,value", + one_modifier_regex, + modifier_regex, + L"one modifier")), + set)); + + ec.set ("dname", dn); + } + + // Assign name() and namespace_() names. + // + ec.set ( + "element-name", + Context::find_name ( + escape ( + process_regex ("name", accessor_regex, L"modifier")), + set)); + + ec.set ( + "element-ns", + Context::find_name ( + escape ( + process_regex ("namespace", accessor_regex, L"modifier")), + set)); + + // Data members. + // + ec.set ("member", Context::find_name ("value_", set)); + ec.set ("element-name-member", + Context::find_name ("name_", set)); + ec.set ("element-ns-member", + Context::find_name ("namespace__", set)); + } + else + name = find_name (escape (e.name ())); + + ec.set ("name", name); + element_set_.insert (name); + } + else + { + // Make sure the name is unique among global elements and + // does not collide with a global type name. + // + String base (find_name (escape (e.name ()))); + e.context ().set ("name", base); + + String n (e.name ()); + + // Assign the parsing function name. + // + String p; + + if (!options.suppress_parsing () && doc_root_p (e)) + { + p = find_name ( + escape ( + process_regex (n, parser_regex, L"parsing function"))); + + e.context ().set ("parser", p); + } + + // Assign the serialization function name. + // + String s; + + if (options.generate_serialization () && doc_root_p (e)) + { + s = find_name ( + escape ( + process_regex ( + n, serializer_regex, L"serialization function"))); + + e.context ().set ("serializer", s); + } + + // Add the names to the set only after processing parsing and + // serialization function names so that we do not over-escape + // them. + // + element_set_.insert (base); + + if (p && p != base) + element_set_.insert (p); + + if (s && s != base && s != p) + element_set_.insert (s); + } + } + + private: + String + find_name (String const& name) + { + String r (name); + + // If we are conflicting with a type name let's first try to + // simply append an underscore and only resort to ugly names + // like name1, etc., if this fails. + // + if (type_set_.find (r) != type_set_.end ()) + r += L"_"; + + for (size_t i (1); + element_set_.find (r) != element_set_.end () || + type_set_.find (r) != type_set_.end (); ++i) + { + std::wostringstream os; + os << i; + r = name + os.str (); + } + + return r; + } + + private: + NameSet const& type_set_; + NameSet& element_set_; + }; + + struct NamespacePassOne: Traversal::Namespace, Context + { + NamespacePassOne (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& ns) + { + NameSet& type_set (global_type_names[ns.name ()]); + + GlobalType type (*this, type_set); + Traversal::Names names (type); + + Traversal::Namespace::names (ns, names); + Traversal::Namespace::names (ns); + } + }; + + + struct NamespacePassThree: Traversal::Namespace, Context + { + NamespacePassThree (Context& c) + : Context (c) + { + } + + virtual void + traverse (Type& ns) + { + String const& name (ns.name ()); + + NameSet const& type_set (global_type_names[name]); + NameSet& element_set (global_element_names[name]); + + GlobalElement element (*this, type_set, element_set); + Traversal::Names names (element); + + Traversal::Namespace::names (ns, names); + } + }; + + + struct FundamentalNamespace: Traversal::Namespace, + + Traversal::AnyType, + Traversal::AnySimpleType, + + Traversal::Fundamental::Byte, + Traversal::Fundamental::UnsignedByte, + Traversal::Fundamental::Short, + Traversal::Fundamental::UnsignedShort, + Traversal::Fundamental::Int, + Traversal::Fundamental::UnsignedInt, + Traversal::Fundamental::Long, + Traversal::Fundamental::UnsignedLong, + Traversal::Fundamental::Integer, + Traversal::Fundamental::NonPositiveInteger, + Traversal::Fundamental::NonNegativeInteger, + Traversal::Fundamental::PositiveInteger, + Traversal::Fundamental::NegativeInteger, + + Traversal::Fundamental::Boolean, + + Traversal::Fundamental::Float, + Traversal::Fundamental::Double, + Traversal::Fundamental::Decimal, + + Traversal::Fundamental::String, + Traversal::Fundamental::NormalizedString, + Traversal::Fundamental::Token, + Traversal::Fundamental::Name, + Traversal::Fundamental::NameToken, + Traversal::Fundamental::NameTokens, + Traversal::Fundamental::NCName, + Traversal::Fundamental::Language, + + Traversal::Fundamental::Id, + Traversal::Fundamental::IdRef, + Traversal::Fundamental::IdRefs, + + Traversal::Fundamental::AnyURI, + + Traversal::Fundamental::QName, + + Traversal::Fundamental::Base64Binary, + Traversal::Fundamental::HexBinary, + + Traversal::Fundamental::Date, + Traversal::Fundamental::DateTime, + Traversal::Fundamental::Duration, + Traversal::Fundamental::Day, + Traversal::Fundamental::Month, + Traversal::Fundamental::MonthDay, + Traversal::Fundamental::Year, + Traversal::Fundamental::YearMonth, + Traversal::Fundamental::Time, + + Traversal::Fundamental::Entity, + Traversal::Fundamental::Entities, + + Context + { + FundamentalNamespace (Context& c) + : Context (c) + { + *this >> names_ >> *this; + } + + void + process_name (SemanticGraph::Type& t, String const& name) + { + String r ( + process_regex ( + namespace_ (t).name (), name, type_regex, L"type")); + + t.context ().set ("name", escape (r)); + } + + void + process_name (SemanticGraph::Namespace& n, + String const& name, + char const* key) + { + String r (process_regex (name, type_regex, L"type")); + n.context ().set (key, escape (r)); + } + + // anyType and anySimpleType + // + virtual void + traverse (SemanticGraph::AnyType& t) + { + process_name (t, "type"); + } + + virtual void + traverse (SemanticGraph::AnySimpleType& t) + { + process_name (t, "simple,type"); + } + + // Integrals. + // + virtual void + traverse (SemanticGraph::Fundamental::Byte& t) + { + process_name (t, "byte"); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedByte& t) + { + process_name (t, "unsigned,byte"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Short& t) + { + process_name (t, "short"); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedShort& t) + { + process_name (t, "unsigned,short"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Int& t) + { + process_name (t, "int"); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedInt& t) + { + process_name (t, "unsigned,int"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Long& t) + { + process_name (t, "long"); + } + + virtual void + traverse (SemanticGraph::Fundamental::UnsignedLong& t) + { + process_name (t, "unsigned,long"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Integer& t) + { + process_name (t, "integer"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) + { + process_name (t, "non,positive,integer"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) + { + process_name (t, "non,negative,integer"); + } + + virtual void + traverse (SemanticGraph::Fundamental::PositiveInteger& t) + { + process_name (t, "positive,integer"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NegativeInteger& t) + { + process_name (t, "negative,integer"); + } + + // Boolean. + // + virtual void + traverse (SemanticGraph::Fundamental::Boolean& t) + { + process_name (t, "boolean"); + } + + // Floats. + // + virtual void + traverse (SemanticGraph::Fundamental::Float& t) + { + process_name (t, "float"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Double& t) + { + process_name (t, "double"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Decimal& t) + { + process_name (t, "decimal"); + } + + // Strings. + // + virtual void + traverse (SemanticGraph::Fundamental::String& t) + { + process_name (t, "string"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NormalizedString& t) + { + process_name (t, "normalized,string"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Token& t) + { + process_name (t, "token"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NameToken& t) + { + process_name (t, "nmtoken"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NameTokens& t) + { + process_name (t, "nmtokens"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Name& t) + { + process_name (t, "name"); + } + + virtual void + traverse (SemanticGraph::Fundamental::NCName& t) + { + process_name (t, "ncname"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Language& t) + { + process_name (t, "language"); + } + + // ID/IDREF. + // + virtual void + traverse (SemanticGraph::Fundamental::Id& t) + { + process_name (t, "id"); + } + + virtual void + traverse (SemanticGraph::Fundamental::IdRef& t) + { + process_name (t, "idref"); + } + + virtual void + traverse (SemanticGraph::Fundamental::IdRefs& t) + { + process_name (t, "idrefs"); + } + + + // URI. + // + virtual void + traverse (SemanticGraph::Fundamental::AnyURI& t) + { + process_name (t, "uri"); + } + + // Qualified name. + // + virtual void + traverse (SemanticGraph::Fundamental::QName& t) + { + process_name (t, "qname"); + } + + // Binary. + // + virtual void + traverse (SemanticGraph::Fundamental::Base64Binary& t) + { + process_name (t, "base64,binary"); + } + + virtual void + traverse (SemanticGraph::Fundamental::HexBinary& t) + { + process_name (t, "hex,binary"); + } + + + // Date/time. + // + virtual void + traverse (SemanticGraph::Fundamental::Date& t) + { + process_name (t, "date"); + } + + virtual void + traverse (SemanticGraph::Fundamental::DateTime& t) + { + process_name (t, "date,time"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Duration& t) + { + process_name (t, "duration"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Day& t) + { + process_name (t, "gday"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Month& t) + { + process_name (t, "gmonth"); + } + + virtual void + traverse (SemanticGraph::Fundamental::MonthDay& t) + { + process_name (t, "gmonth,day"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Year& t) + { + process_name (t, "gyear"); + } + + virtual void + traverse (SemanticGraph::Fundamental::YearMonth& t) + { + process_name (t, "gyear,month"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Time& t) + { + process_name (t, "time"); + } + + // Entity. + // + virtual void + traverse (SemanticGraph::Fundamental::Entity& t) + { + process_name (t, "entity"); + } + + virtual void + traverse (SemanticGraph::Fundamental::Entities& t) + { + process_name (t, "entities"); + } + + virtual void + post (SemanticGraph::Namespace& n) + { + // Assign names to extra stuff in the XML Schema namespace. + // + process_name (n, "container", "container"); + process_name (n, "buffer", "buffer"); + process_name (n, "time,zone", "time-zone"); + + process_name (n, "content,order", "content-order"); + + if (options.generate_element_type ()) + process_name (n, "element,type", "element-type"); + + if (options.generate_element_map ()) + process_name (n, "element,map", "element-map"); + + if (options.generate_serialization ()) + { + process_name (n, "namespace,info", "namespace-info"); + process_name (n, "namespace,infomap", "namespace-infomap"); + process_name (n, "list,stream", "list-stream"); + process_name (n, "as,double", "as-double"); + process_name (n, "as,decimal", "as-decimal"); + process_name (n, "facet", "facet"); + } + + if (!options.generate_insertion ().empty ()) + { + process_name (n, "ostream", "ostream"); + } + + if (!options.generate_extraction ().empty ()) + { + process_name (n, "istream", "istream"); + } + + process_name (n, "flags", "flags"); + process_name (n, "properties", "properties"); + + NarrowString fn (options.function_naming ()); + + if (fn == "knr") + n.context ().set ("tree-node-key", String ("tree_node_key")); + else + n.context ().set ("tree-node-key", String ("treeNodeKey")); + + process_name (n, "exception", "exception"); + process_name (n, "parsing", "parsing"); + process_name (n, "expected,element", "expected-element"); + process_name (n, "unexpected,element", "unexpected-element"); + process_name (n, "expected,attribute", "expected-attribute"); + process_name (n, "unexpected,enumerator", "unexpected-enumerator"); + process_name (n, "expected,text,content", "expected-text-content"); + process_name (n, "no,type,info", "no-type-info"); + process_name (n, "no,element,info", "no-element-info"); + process_name (n, "not,derived", "not-derived"); + process_name (n, "duplicate,id", "duplicate-id"); + process_name (n, "serialization", "serialization"); + process_name (n, "no,namespace,mapping", "no-namespace-mapping"); + process_name (n, "no,prefix,mapping", "no-prefix-mapping"); + process_name (n, "xsi,already,in,use", "xsi-already-in-use"); + process_name (n, "bounds", "bounds"); + + process_name (n, "severity", "severity"); + process_name (n, "error", "error"); + process_name (n, "diagnostics", "diagnostics"); + + if (!options.suppress_parsing () || + options.generate_serialization ()) + { + process_name (n, "error,handler", "error-handler"); + } + + Namespace::post (n); + } + + private: + Traversal::Names names_; + }; + + + // Go into sourced/included/imported schemas while making sure + // we don't process the same stuff more than once. + // + struct UsesPassOne: Traversal::Uses + { + virtual void + traverse (Type& u) + { + SemanticGraph::Schema& s (u.schema ()); + + if (!s.context ().count ("cxx-tree-name-processor-pass-1")) + { + s.context ().set ("cxx-tree-name-processor-pass-1", true); + Traversal::Uses::traverse (u); + } + } + }; + + struct UsesPassThree: Traversal::Uses + { + virtual void + traverse (Type& u) + { + SemanticGraph::Schema& s (u.schema ()); + + if (!s.context ().count ("cxx-tree-name-processor-pass-3")) + { + s.context ().set ("cxx-tree-name-processor-pass-3", true); + Traversal::Uses::traverse (u); + } + } + }; + + // Go into implied schemas while making sure we don't process + // the same stuff more than once. + // + struct Implies: Traversal::Implies + { + virtual void + traverse (SemanticGraph::Implies& i) + { + SemanticGraph::Schema& s (i.schema ()); + + if (!s.context ().count ("cxx-tree-name-processor-seen")) + { + s.context ().set ("cxx-tree-name-processor-seen", true); + Traversal::Implies::traverse (i); + } + } + }; + + bool + process_impl (options const& ops, + SemanticGraph::Schema& tu, + SemanticGraph::Path const& file, + StringLiteralMap const& map) + { + try + { + Counts counts; + Context ctx (ops, counts, false, tu, file, map); + + if (tu.names_begin ()->named ().name () == + L"http://www.w3.org/2001/XMLSchema") + { + // XML Schema namespace. + // + Traversal::Schema xs_schema; + Traversal::Names xs_schema_names; + FundamentalNamespace xs_ns (ctx); + + xs_schema >> xs_schema_names >> xs_ns; + + xs_schema.dispatch (tu); + } + else + { + + // Pass one - assign names to global types. This pass cannot + // be combined with pass two because of possible recursive + // schema inclusions. Also note that we check first if this + // schema has already been processed which may happen in the + // file-per-type compilation mode. + // + if (!tu.context ().count ("cxx-tree-name-processor-pass-1")) + { + Traversal::Schema schema; + Traversal::Schema xs_schema; + UsesPassOne uses; + Implies implies; + + schema >> uses >> schema; + schema >> implies >> xs_schema; + + Traversal::Names schema_names; + Traversal::Names xs_schema_names; + NamespacePassOne ns (ctx); + FundamentalNamespace xs_ns (ctx); + + schema >> schema_names >> ns; + xs_schema >> xs_schema_names >> xs_ns; + + // Some twisted schemas do recusive self-inclusion. + // + tu.context ().set ("cxx-tree-name-processor-pass-1", true); + + schema.dispatch (tu); + } + + // Pass two - assign names inside complex types. Here + // we don't need to go into included/imported schemas. + // + { + Traversal::Schema schema; + Sources sources; + + schema >> sources >> schema; + + Traversal::Names schema_names; + Traversal::Namespace ns; + Traversal::Names ns_names; + + schema >> schema_names >> ns >> ns_names; + + Complex complex (ctx); + Traversal::Enumeration enumeration; // Avoid fallback on complex. + + ns_names >> complex; + ns_names >> enumeration; + + schema.dispatch (tu); + } + + // Pass three - assign names to global elements as well as + // inside enums. Also note that we check first if this schema + // has already been processed which may happen in the file-per- + // type compilation mode. + // + if (!tu.context ().count ("cxx-tree-name-processor-pass-3")) + { + Traversal::Schema schema; + UsesPassThree uses; + + schema >> uses >> schema; + + Traversal::Names schema_names; + NamespacePassThree ns (ctx); + Traversal::Namespace ns_enum; + + schema >> schema_names; + + schema_names >> ns; + schema_names >> ns_enum; + + Traversal::Names ns_names; + Enumeration enumeration (ctx); + + ns_enum >> ns_names >> enumeration; + + // Some twisted schemas do recusive self-inclusion. + // + tu.context ().set ("cxx-tree-name-processor-pass-3", true); + + schema.dispatch (tu); + } + } + } + catch (Context::Failed const&) + { + // Diagnostics has already been issued. + // + return false; + } + + return true; + } + } + + bool NameProcessor:: + process (options const& ops, + SemanticGraph::Schema& tu, + SemanticGraph::Path const& file, + StringLiteralMap const& map) + { + return process_impl (ops, tu, file, map); + } + } +} diff --git a/xsd/xsd/cxx/tree/name-processor.hxx b/xsd/xsd/cxx/tree/name-processor.hxx new file mode 100644 index 0000000..632b05e --- /dev/null +++ b/xsd/xsd/cxx/tree/name-processor.hxx @@ -0,0 +1,28 @@ +// file : xsd/cxx/tree/name-processor.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_TREE_NAME_PROCESSOR_HXX +#define XSD_CXX_TREE_NAME_PROCESSOR_HXX + +#include + +#include +#include + +namespace CXX +{ + namespace Tree + { + class NameProcessor + { + public: + bool + process (options const&, + XSDFrontend::SemanticGraph::Schema&, + XSDFrontend::SemanticGraph::Path const& file, + StringLiteralMap const&); + }; + } +} + +#endif // XSD_CXX_TREE_NAME_PROCESSOR_HXX diff --git a/xsd/xsd/cxx/tree/options.cli b/xsd/xsd/cxx/tree/options.cli new file mode 100644 index 0000000..1f0b23f --- /dev/null +++ b/xsd/xsd/cxx/tree/options.cli @@ -0,0 +1,479 @@ +// file : xsd/cxx/tree/options.cli +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include ; // std::size_t + +include ; // NarrowString, NarrowStrings + +include ; + +namespace CXX +{ + namespace Tree + { + class options: CXX::options + { + // Polymorphism. + // + bool --generate-polymorphic + { + "Generate polymorphism-aware code. Specify this option if you use + substitution groups or \cb{xsi:type}. Use the \cb{--polymorphic-type} + or \cb{--polymorphic-type-all} option to specify which type + hierarchies are polymorphic." + }; + + NarrowStrings --polymorphic-type + { + "", + "Indicate that is a root of a polymorphic type hierarchy. The + compiler can often automatically determine which types are + polymorphic based on the substitution group declarations. However, + you may need to use this option if you are not using substitution + groups or if substitution groups are defined in another schema. You + need to specify this option when compiling every schema file that + references . The argument is an XML Schema type name + that can be optionally qualified with a namespace in the + \c{\i{namespace}\b{#}\i{name}} form." + }; + + bool --polymorphic-type-all + { + "Indicate that all types should be treated as polymorphic." + }; + + unsigned long --polymorphic-plate = 0 + { + "", + "Specify the polymorphic map plate the generated code should register + on. This functionality is primarily useful to segregate multiple + schemas that define the same polymorphic types." + }; + + // Ordered content. + // + NarrowStrings --ordered-type + { + "", + "Indicate that element order in is significant. An example + would be a complex type with unbounded choice as a content model + where the element order in XML has application-specific semantics. + For ordered types the compiler generates a special container data + member and a corresponding set of accessors and modifiers that are + used to capture the order of elements and, for mixed content, of + text. + + The argument is an XML Schema type name that can be optionally + qualified with a namespace in the \c{\i{namespace}\b{#}\i{name}} form. + Note also that you will need to specify this option when compiling + every schema file that has other ordered types derived from this + type." + }; + + bool --ordered-type-derived + { + "Automatically treat types derived from ordered bases as also + ordered. This is primarily useful if you would like to be able + to iterate over the complete content using the content order + container." + }; + + bool --ordered-type-mixed + { + "Automatically treat complex types with mixed content as ordered." + }; + + bool --ordered-type-all + { + "Indicate that element order in all types is significant." + }; + + NarrowString --order-container + { + "", + "Specify a custom class template that should be used as a container + for the content order in ordered types instead of the default + \cb{std::vector}. See \cb{--ordered-type} for more information on + ordered type. This option is primarily useful if you need to + perform more complex lookups in the content order container, for + example by element id. In this case, a container like Boost + multi-index may be more convenient. Note that if using a custom + container, you will also most likely need to include the relevant + headers using the \cb{--hxx-prologue*} options." + }; + + // Features. + // + bool --generate-serialization + { + "Generate serialization functions. Serialization functions convert + the object model back to XML." + }; + + bool --generate-ostream + { + "Generate ostream insertion operators (\cb{operator<<}) for generated + types. This allows one to easily print a fragment or the whole object + model for debugging or logging." + }; + + bool --generate-doxygen + { + "Generate documentation comments suitable for extraction by the + Doxygen documentation system. Documentation from annotations is + added to the comments if present in the schema." + }; + + bool --generate-comparison + { + "Generate comparison operators (\cb{operator==} and \cb{operator!=}) + for complex types. Comparison is performed member-wise." + }; + + bool --generate-default-ctor + { + "Generate default constructors even for types that have required + members. Required members of an instance constructed using such a + constructor are not initialized and accessing them results in + undefined behavior." + }; + + bool --generate-from-base-ctor + { + "Generate constructors that expect an instance of a base type + followed by all required members." + }; + + bool --suppress-assignment + { + "Suppress the generation of copy assignment operators for complex + types. If this option is specified, the copy assignment operators + for such types are declared private and left unimplemented." + }; + + bool --generate-detach + { + "Generate detach functions for required elements and attributes. + Detach functions for optional and sequence cardinalities are + provided by the respective containers. These functions, for + example, allow you to move sub-trees in the object model either + within the same tree or between different trees." + }; + + bool --generate-wildcard + { + "Generate accessors and modifiers as well as parsing and serialization + code for XML Schema wildcards (\cb{any} and \cb{anyAttribute}). XML + content matched by wildcards is presented as DOM fragments. Note + that you need to initialize the Xerces-C++ runtime if you are using + this option." + }; + + bool --generate-any-type + { + "Extract and store content of the XML Schema \cb{anyType} type as a + DOM fragment. Note that you need to initialize the Xerces-C++ runtime + if you are using this option." + }; + + NarrowStrings --generate-insertion + { + "", + "Generate data representation stream insertion operators for the + output stream type. Repeat this option to specify more than one + stream type. The ACE CDR stream (\cb{ACE_OutputCDR}) and RPC XDR + are recognized by the compiler and the necessary \cb{#include} + directives are automatically generated. For custom stream types use + the \cb{--hxx-prologue*} options to provide the necessary + declarations." + }; + + NarrowStrings --generate-extraction + { + "", + "Generate data representation stream extraction constructors for the + input stream type. Repeat this option to specify more than one + stream type. The ACE CDR stream (\cb{ACE_InputCDR}) and RPC XDR are + recognized by the compiler and the necessary \cb{#include} directives + are automatically generated. For custom stream types use the + \cb{--hxx-prologue*} options to provide the necessary declarations." + }; + + bool --generate-forward + { + "Generate a separate header file with forward declarations for the + types being generated." + }; + + bool --suppress-parsing + { + "Suppress the generation of the parsing functions and constructors. + Use this option to reduce the generated code size when parsing from + XML is not needed." + }; + + bool --generate-element-type + { + "Generate types instead of parsing and serialization functions for + root elements. This is primarily useful to distinguish object models + with the same root type but with different root elements." + }; + + bool --generate-element-map + { + "Generate a root element map that allows uniform parsing and + serialization of multiple root elements. This option is only valid + together with \cb{--generate-element-type}." + }; + + bool --generate-intellisense + { + "Generate workarounds for IntelliSense bugs in Visual Studio 2005 + (8.0). When this option is used, the resulting code is slightly + more verbose. IntelliSense in Visual Studio 2008 (9.0) and later + does not require these workarounds. Support for IntelliSense in + Visual Studio 2003 (7.1) is improved with this option but is + still incomplete." + }; + + bool --omit-default-attributes + { + "Omit attributes with default and fixed values from serialized XML + documents." + }; + + // Naming. + // + NarrowString --type-naming = "knr" + { + "