From 2615896faa646e5830abf2c269150e1165c66515 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 18 Dec 2020 18:48:46 +0300 Subject: Switch to build2 --- libxsd/.gitignore | 19 + libxsd/FLOSSE | 90 +- libxsd/GPLv2 | 341 +- libxsd/INSTALL | 19 +- libxsd/LICENSE | 29 +- libxsd/NEWS | 1 + libxsd/README | 5 +- 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 | 9 + libxsd/doc/buildfile | 86 + 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/libxsd/buildfile | 38 + libxsd/libxsd/cxx/auto-array.hxx | 118 + libxsd/libxsd/cxx/compilers/vc-8/post.hxx | 4 + libxsd/libxsd/cxx/compilers/vc-8/pre.hxx | 27 + libxsd/libxsd/cxx/config.hxx | 46 + libxsd/libxsd/cxx/exceptions.hxx | 19 + libxsd/libxsd/cxx/parser/document.hxx | 88 + libxsd/libxsd/cxx/parser/document.txx | 127 + libxsd/libxsd/cxx/parser/elements.hxx | 93 + libxsd/libxsd/cxx/parser/elements.txx | 58 + libxsd/libxsd/cxx/parser/error-handler.hxx | 55 + libxsd/libxsd/cxx/parser/error-handler.txx | 39 + libxsd/libxsd/cxx/parser/exceptions.hxx | 151 + libxsd/libxsd/cxx/parser/exceptions.ixx | 127 + libxsd/libxsd/cxx/parser/exceptions.txx | 57 + libxsd/libxsd/cxx/parser/expat/elements.hxx | 363 ++ libxsd/libxsd/cxx/parser/expat/elements.txx | 823 ++++ libxsd/libxsd/cxx/parser/map.hxx | 77 + libxsd/libxsd/cxx/parser/map.ixx | 25 + libxsd/libxsd/cxx/parser/map.txx | 29 + libxsd/libxsd/cxx/parser/non-validating/parser.hxx | 246 ++ libxsd/libxsd/cxx/parser/non-validating/parser.txx | 462 +++ .../cxx/parser/non-validating/xml-schema-pimpl.hxx | 791 ++++ .../cxx/parser/non-validating/xml-schema-pimpl.ixx | 127 + .../cxx/parser/non-validating/xml-schema-pimpl.txx | 2066 ++++++++++ .../cxx/parser/non-validating/xml-schema-pskel.hxx | 647 ++++ .../cxx/parser/non-validating/xml-schema-pskel.ixx | 1247 +++++++ .../cxx/parser/non-validating/xml-schema-pskel.txx | 67 + libxsd/libxsd/cxx/parser/schema-exceptions.hxx | 185 + libxsd/libxsd/cxx/parser/schema-exceptions.ixx | 143 + libxsd/libxsd/cxx/parser/schema-exceptions.txx | 73 + libxsd/libxsd/cxx/parser/substitution-map.hxx | 239 ++ libxsd/libxsd/cxx/parser/substitution-map.txx | 82 + libxsd/libxsd/cxx/parser/validating/exceptions.hxx | 151 + libxsd/libxsd/cxx/parser/validating/exceptions.ixx | 161 + libxsd/libxsd/cxx/parser/validating/exceptions.txx | 95 + .../cxx/parser/validating/inheritance-map.hxx | 99 + .../cxx/parser/validating/inheritance-map.txx | 71 + libxsd/libxsd/cxx/parser/validating/parser.hxx | 469 +++ libxsd/libxsd/cxx/parser/validating/parser.txx | 665 ++++ .../cxx/parser/validating/xml-schema-pimpl.hxx | 1121 ++++++ .../cxx/parser/validating/xml-schema-pimpl.ixx | 674 ++++ .../cxx/parser/validating/xml-schema-pimpl.txx | 2756 ++++++++++++++ .../cxx/parser/validating/xml-schema-pskel.hxx | 647 ++++ .../cxx/parser/validating/xml-schema-pskel.ixx | 1247 +++++++ .../cxx/parser/validating/xml-schema-pskel.txx | 67 + libxsd/libxsd/cxx/parser/xerces/elements.hxx | 463 +++ libxsd/libxsd/cxx/parser/xerces/elements.txx | 951 +++++ libxsd/libxsd/cxx/parser/xml-schema.hxx | 570 +++ libxsd/libxsd/cxx/parser/xml-schema.ixx | 1020 +++++ libxsd/libxsd/cxx/parser/xml-schema.txx | 32 + libxsd/libxsd/cxx/post.hxx | 8 + libxsd/libxsd/cxx/pre.hxx | 10 + libxsd/libxsd/cxx/ro-string.hxx | 428 +++ libxsd/libxsd/cxx/ro-string.txx | 131 + libxsd/libxsd/cxx/tree/ace-cdr-stream-common.hxx | 24 + .../libxsd/cxx/tree/ace-cdr-stream-extraction.hxx | 346 ++ .../libxsd/cxx/tree/ace-cdr-stream-insertion.hxx | 247 ++ libxsd/libxsd/cxx/tree/bits/literals.hxx | 259 ++ libxsd/libxsd/cxx/tree/bits/literals.ixx | 874 +++++ libxsd/libxsd/cxx/tree/buffer.hxx | 335 ++ libxsd/libxsd/cxx/tree/buffer.txx | 145 + libxsd/libxsd/cxx/tree/comparison-map.hxx | 111 + libxsd/libxsd/cxx/tree/comparison-map.txx | 298 ++ libxsd/libxsd/cxx/tree/containers-wildcard.hxx | 1337 +++++++ libxsd/libxsd/cxx/tree/containers.hxx | 1200 ++++++ libxsd/libxsd/cxx/tree/containers.txx | 295 ++ libxsd/libxsd/cxx/tree/date-time-extraction.txx | 155 + libxsd/libxsd/cxx/tree/date-time-insertion.txx | 186 + libxsd/libxsd/cxx/tree/date-time-ostream.txx | 322 ++ libxsd/libxsd/cxx/tree/date-time.hxx | 1949 ++++++++++ libxsd/libxsd/cxx/tree/date-time.ixx | 891 +++++ libxsd/libxsd/cxx/tree/date-time.txx | 92 + libxsd/libxsd/cxx/tree/element-map.hxx | 146 + libxsd/libxsd/cxx/tree/element-map.txx | 69 + libxsd/libxsd/cxx/tree/elements.hxx | 1867 +++++++++ libxsd/libxsd/cxx/tree/elements.ixx | 265 ++ libxsd/libxsd/cxx/tree/elements.txx | 55 + libxsd/libxsd/cxx/tree/error-handler.hxx | 60 + libxsd/libxsd/cxx/tree/error-handler.txx | 30 + libxsd/libxsd/cxx/tree/exceptions.hxx | 1032 +++++ libxsd/libxsd/cxx/tree/exceptions.txx | 508 +++ libxsd/libxsd/cxx/tree/facet.hxx | 41 + libxsd/libxsd/cxx/tree/istream-fwd.hxx | 19 + libxsd/libxsd/cxx/tree/istream.hxx | 453 +++ libxsd/libxsd/cxx/tree/iterator-adapter.hxx | 269 ++ libxsd/libxsd/cxx/tree/list.hxx | 133 + libxsd/libxsd/cxx/tree/ostream.hxx | 290 ++ libxsd/libxsd/cxx/tree/parsing.hxx | 10 + libxsd/libxsd/cxx/tree/parsing.txx | 918 +++++ libxsd/libxsd/cxx/tree/parsing/boolean.hxx | 74 + libxsd/libxsd/cxx/tree/parsing/byte.hxx | 78 + libxsd/libxsd/cxx/tree/parsing/date-time.txx | 700 ++++ libxsd/libxsd/cxx/tree/parsing/decimal.hxx | 83 + libxsd/libxsd/cxx/tree/parsing/double.hxx | 92 + libxsd/libxsd/cxx/tree/parsing/element-map.txx | 40 + libxsd/libxsd/cxx/tree/parsing/float.hxx | 92 + libxsd/libxsd/cxx/tree/parsing/int.hxx | 78 + libxsd/libxsd/cxx/tree/parsing/long.hxx | 78 + libxsd/libxsd/cxx/tree/parsing/short.hxx | 78 + libxsd/libxsd/cxx/tree/parsing/unsigned-byte.hxx | 78 + libxsd/libxsd/cxx/tree/parsing/unsigned-int.hxx | 78 + libxsd/libxsd/cxx/tree/parsing/unsigned-long.hxx | 78 + libxsd/libxsd/cxx/tree/parsing/unsigned-short.hxx | 78 + libxsd/libxsd/cxx/tree/serialization.hxx | 64 + libxsd/libxsd/cxx/tree/serialization.txx | 801 ++++ libxsd/libxsd/cxx/tree/serialization/boolean.hxx | 50 + libxsd/libxsd/cxx/tree/serialization/byte.hxx | 44 + libxsd/libxsd/cxx/tree/serialization/date-time.txx | 618 +++ libxsd/libxsd/cxx/tree/serialization/decimal.hxx | 124 + libxsd/libxsd/cxx/tree/serialization/double.hxx | 94 + .../libxsd/cxx/tree/serialization/element-map.txx | 38 + libxsd/libxsd/cxx/tree/serialization/float.hxx | 92 + libxsd/libxsd/cxx/tree/serialization/int.hxx | 44 + libxsd/libxsd/cxx/tree/serialization/long.hxx | 44 + libxsd/libxsd/cxx/tree/serialization/short.hxx | 44 + .../cxx/tree/serialization/unsigned-byte.hxx | 44 + .../libxsd/cxx/tree/serialization/unsigned-int.hxx | 44 + .../cxx/tree/serialization/unsigned-long.hxx | 44 + .../cxx/tree/serialization/unsigned-short.hxx | 44 + libxsd/libxsd/cxx/tree/std-ostream-map.hxx | 112 + libxsd/libxsd/cxx/tree/std-ostream-map.txx | 291 ++ libxsd/libxsd/cxx/tree/std-ostream-operators.hxx | 276 ++ libxsd/libxsd/cxx/tree/stream-extraction-map.hxx | 105 + libxsd/libxsd/cxx/tree/stream-extraction-map.txx | 331 ++ libxsd/libxsd/cxx/tree/stream-extraction.hxx | 304 ++ libxsd/libxsd/cxx/tree/stream-insertion-map.hxx | 152 + libxsd/libxsd/cxx/tree/stream-insertion-map.txx | 355 ++ libxsd/libxsd/cxx/tree/stream-insertion.hxx | 275 ++ libxsd/libxsd/cxx/tree/text.hxx | 28 + libxsd/libxsd/cxx/tree/text.txx | 61 + libxsd/libxsd/cxx/tree/type-factory-map.hxx | 173 + libxsd/libxsd/cxx/tree/type-factory-map.txx | 481 +++ libxsd/libxsd/cxx/tree/type-serializer-map.hxx | 234 ++ libxsd/libxsd/cxx/tree/type-serializer-map.txx | 572 +++ libxsd/libxsd/cxx/tree/types.hxx | 3946 ++++++++++++++++++++ libxsd/libxsd/cxx/tree/types.txx | 528 +++ libxsd/libxsd/cxx/tree/xdr-stream-common.hxx | 24 + libxsd/libxsd/cxx/tree/xdr-stream-extraction.hxx | 306 ++ libxsd/libxsd/cxx/tree/xdr-stream-insertion.hxx | 270 ++ libxsd/libxsd/cxx/version.hxx | 0 libxsd/libxsd/cxx/version.hxx.in | 43 + libxsd/libxsd/cxx/xml/bits/literals.hxx | 81 + libxsd/libxsd/cxx/xml/bits/literals.ixx | 259 ++ libxsd/libxsd/cxx/xml/char-iso8859-1.hxx | 70 + libxsd/libxsd/cxx/xml/char-iso8859-1.txx | 110 + libxsd/libxsd/cxx/xml/char-lcp.hxx | 54 + libxsd/libxsd/cxx/xml/char-lcp.txx | 73 + libxsd/libxsd/cxx/xml/char-utf8.hxx | 55 + libxsd/libxsd/cxx/xml/char-utf8.txx | 306 ++ libxsd/libxsd/cxx/xml/dom/auto-ptr.hxx | 232 ++ .../cxx/xml/dom/bits/error-handler-proxy.hxx | 59 + .../cxx/xml/dom/bits/error-handler-proxy.txx | 66 + libxsd/libxsd/cxx/xml/dom/elements.hxx | 34 + libxsd/libxsd/cxx/xml/dom/elements.txx | 55 + libxsd/libxsd/cxx/xml/dom/parsing-header.hxx | 22 + libxsd/libxsd/cxx/xml/dom/parsing-source.hxx | 152 + libxsd/libxsd/cxx/xml/dom/parsing-source.txx | 379 ++ libxsd/libxsd/cxx/xml/dom/serialization-header.hxx | 79 + libxsd/libxsd/cxx/xml/dom/serialization-header.txx | 188 + libxsd/libxsd/cxx/xml/dom/serialization-source.hxx | 181 + libxsd/libxsd/cxx/xml/dom/serialization-source.txx | 362 ++ libxsd/libxsd/cxx/xml/dom/wildcard-source.hxx | 29 + libxsd/libxsd/cxx/xml/dom/wildcard-source.txx | 36 + libxsd/libxsd/cxx/xml/elements.hxx | 116 + libxsd/libxsd/cxx/xml/elements.txx | 71 + libxsd/libxsd/cxx/xml/error-handler.hxx | 57 + libxsd/libxsd/cxx/xml/exceptions.hxx | 18 + libxsd/libxsd/cxx/xml/qualified-name.hxx | 82 + .../cxx/xml/sax/bits/error-handler-proxy.hxx | 78 + .../cxx/xml/sax/bits/error-handler-proxy.txx | 76 + libxsd/libxsd/cxx/xml/sax/std-input-source.hxx | 151 + libxsd/libxsd/cxx/xml/std-memory-manager.hxx | 53 + libxsd/libxsd/cxx/xml/string.hxx | 89 + libxsd/libxsd/cxx/xml/string.ixx | 169 + libxsd/libxsd/cxx/xml/string.txx | 161 + libxsd/libxsd/cxx/zc-istream.hxx | 215 ++ libxsd/libxsd/cxx/zc-istream.txx | 92 + libxsd/makefile | 43 - libxsd/manifest | 24 + libxsd/tests/.gitignore | 3 + libxsd/tests/build/.gitignore | 3 + libxsd/tests/build/bootstrap.build | 8 + libxsd/tests/build/root.build | 23 + libxsd/tests/buildfile | 4 + libxsd/tests/cxx/parser/basic/.gitignore | 2 + libxsd/tests/cxx/parser/basic/buildfile | 13 + libxsd/tests/cxx/parser/basic/driver.cxx | 127 + libxsd/tests/cxx/parser/basic/testscript | 41 + libxsd/tests/cxx/tree/basic/buildfile | 6 + libxsd/tests/cxx/tree/basic/driver.cxx | 61 + libxsd/tests/cxx/tree/basic/testscript | 73 + libxsd/xsd/cxx/auto-array.hxx | 118 - libxsd/xsd/cxx/compilers/vc-8/post.hxx | 4 - libxsd/xsd/cxx/compilers/vc-8/pre.hxx | 27 - libxsd/xsd/cxx/config.hxx | 46 - libxsd/xsd/cxx/exceptions.hxx | 19 - libxsd/xsd/cxx/parser/document.hxx | 88 - libxsd/xsd/cxx/parser/document.txx | 127 - libxsd/xsd/cxx/parser/elements.hxx | 93 - libxsd/xsd/cxx/parser/elements.txx | 58 - libxsd/xsd/cxx/parser/error-handler.hxx | 55 - libxsd/xsd/cxx/parser/error-handler.txx | 39 - libxsd/xsd/cxx/parser/exceptions.hxx | 151 - libxsd/xsd/cxx/parser/exceptions.ixx | 127 - libxsd/xsd/cxx/parser/exceptions.txx | 57 - libxsd/xsd/cxx/parser/expat/elements.hxx | 363 -- libxsd/xsd/cxx/parser/expat/elements.txx | 823 ---- libxsd/xsd/cxx/parser/map.hxx | 77 - libxsd/xsd/cxx/parser/map.ixx | 25 - libxsd/xsd/cxx/parser/map.txx | 29 - libxsd/xsd/cxx/parser/non-validating/parser.hxx | 246 -- libxsd/xsd/cxx/parser/non-validating/parser.txx | 462 --- .../cxx/parser/non-validating/xml-schema-pimpl.hxx | 791 ---- .../cxx/parser/non-validating/xml-schema-pimpl.ixx | 127 - .../cxx/parser/non-validating/xml-schema-pimpl.txx | 2066 ---------- .../cxx/parser/non-validating/xml-schema-pskel.hxx | 647 ---- .../cxx/parser/non-validating/xml-schema-pskel.ixx | 1247 ------- .../cxx/parser/non-validating/xml-schema-pskel.txx | 67 - libxsd/xsd/cxx/parser/schema-exceptions.hxx | 185 - libxsd/xsd/cxx/parser/schema-exceptions.ixx | 143 - libxsd/xsd/cxx/parser/schema-exceptions.txx | 73 - libxsd/xsd/cxx/parser/substitution-map.hxx | 239 -- libxsd/xsd/cxx/parser/substitution-map.txx | 82 - libxsd/xsd/cxx/parser/validating/exceptions.hxx | 151 - libxsd/xsd/cxx/parser/validating/exceptions.ixx | 161 - libxsd/xsd/cxx/parser/validating/exceptions.txx | 95 - .../xsd/cxx/parser/validating/inheritance-map.hxx | 99 - .../xsd/cxx/parser/validating/inheritance-map.txx | 71 - libxsd/xsd/cxx/parser/validating/parser.hxx | 469 --- libxsd/xsd/cxx/parser/validating/parser.txx | 665 ---- .../xsd/cxx/parser/validating/xml-schema-pimpl.hxx | 1121 ------ .../xsd/cxx/parser/validating/xml-schema-pimpl.ixx | 674 ---- .../xsd/cxx/parser/validating/xml-schema-pimpl.txx | 2756 -------------- .../xsd/cxx/parser/validating/xml-schema-pskel.hxx | 647 ---- .../xsd/cxx/parser/validating/xml-schema-pskel.ixx | 1247 ------- .../xsd/cxx/parser/validating/xml-schema-pskel.txx | 67 - libxsd/xsd/cxx/parser/xerces/elements.hxx | 463 --- libxsd/xsd/cxx/parser/xerces/elements.txx | 951 ----- libxsd/xsd/cxx/parser/xml-schema.hxx | 570 --- libxsd/xsd/cxx/parser/xml-schema.ixx | 1020 ----- libxsd/xsd/cxx/parser/xml-schema.txx | 32 - libxsd/xsd/cxx/post.hxx | 8 - libxsd/xsd/cxx/pre.hxx | 10 - libxsd/xsd/cxx/ro-string.hxx | 428 --- libxsd/xsd/cxx/ro-string.txx | 131 - libxsd/xsd/cxx/tree/ace-cdr-stream-common.hxx | 24 - libxsd/xsd/cxx/tree/ace-cdr-stream-extraction.hxx | 346 -- libxsd/xsd/cxx/tree/ace-cdr-stream-insertion.hxx | 247 -- libxsd/xsd/cxx/tree/bits/literals.hxx | 259 -- libxsd/xsd/cxx/tree/bits/literals.ixx | 874 ----- libxsd/xsd/cxx/tree/buffer.hxx | 335 -- libxsd/xsd/cxx/tree/buffer.txx | 145 - libxsd/xsd/cxx/tree/comparison-map.hxx | 111 - libxsd/xsd/cxx/tree/comparison-map.txx | 298 -- libxsd/xsd/cxx/tree/containers-wildcard.hxx | 1337 ------- libxsd/xsd/cxx/tree/containers.hxx | 1200 ------ libxsd/xsd/cxx/tree/containers.txx | 295 -- libxsd/xsd/cxx/tree/date-time-extraction.txx | 155 - libxsd/xsd/cxx/tree/date-time-insertion.txx | 186 - libxsd/xsd/cxx/tree/date-time-ostream.txx | 322 -- libxsd/xsd/cxx/tree/date-time.hxx | 1949 ---------- libxsd/xsd/cxx/tree/date-time.ixx | 891 ----- libxsd/xsd/cxx/tree/date-time.txx | 92 - libxsd/xsd/cxx/tree/element-map.hxx | 146 - libxsd/xsd/cxx/tree/element-map.txx | 69 - libxsd/xsd/cxx/tree/elements.hxx | 1865 --------- libxsd/xsd/cxx/tree/elements.ixx | 265 -- libxsd/xsd/cxx/tree/elements.txx | 55 - libxsd/xsd/cxx/tree/error-handler.hxx | 60 - libxsd/xsd/cxx/tree/error-handler.txx | 30 - libxsd/xsd/cxx/tree/exceptions.hxx | 1032 ----- libxsd/xsd/cxx/tree/exceptions.txx | 508 --- libxsd/xsd/cxx/tree/facet.hxx | 41 - libxsd/xsd/cxx/tree/istream-fwd.hxx | 19 - libxsd/xsd/cxx/tree/istream.hxx | 453 --- libxsd/xsd/cxx/tree/iterator-adapter.hxx | 269 -- libxsd/xsd/cxx/tree/list.hxx | 133 - libxsd/xsd/cxx/tree/ostream.hxx | 290 -- libxsd/xsd/cxx/tree/parsing.hxx | 10 - libxsd/xsd/cxx/tree/parsing.txx | 918 ----- libxsd/xsd/cxx/tree/parsing/boolean.hxx | 74 - libxsd/xsd/cxx/tree/parsing/byte.hxx | 78 - libxsd/xsd/cxx/tree/parsing/date-time.txx | 700 ---- libxsd/xsd/cxx/tree/parsing/decimal.hxx | 83 - libxsd/xsd/cxx/tree/parsing/double.hxx | 92 - libxsd/xsd/cxx/tree/parsing/element-map.txx | 40 - libxsd/xsd/cxx/tree/parsing/float.hxx | 92 - libxsd/xsd/cxx/tree/parsing/int.hxx | 78 - libxsd/xsd/cxx/tree/parsing/long.hxx | 78 - libxsd/xsd/cxx/tree/parsing/short.hxx | 78 - libxsd/xsd/cxx/tree/parsing/unsigned-byte.hxx | 78 - libxsd/xsd/cxx/tree/parsing/unsigned-int.hxx | 78 - libxsd/xsd/cxx/tree/parsing/unsigned-long.hxx | 78 - libxsd/xsd/cxx/tree/parsing/unsigned-short.hxx | 78 - libxsd/xsd/cxx/tree/serialization.hxx | 64 - libxsd/xsd/cxx/tree/serialization.txx | 801 ---- libxsd/xsd/cxx/tree/serialization/boolean.hxx | 50 - libxsd/xsd/cxx/tree/serialization/byte.hxx | 44 - libxsd/xsd/cxx/tree/serialization/date-time.txx | 618 --- libxsd/xsd/cxx/tree/serialization/decimal.hxx | 124 - libxsd/xsd/cxx/tree/serialization/double.hxx | 94 - libxsd/xsd/cxx/tree/serialization/element-map.txx | 38 - libxsd/xsd/cxx/tree/serialization/float.hxx | 92 - libxsd/xsd/cxx/tree/serialization/int.hxx | 44 - libxsd/xsd/cxx/tree/serialization/long.hxx | 44 - libxsd/xsd/cxx/tree/serialization/short.hxx | 44 - .../xsd/cxx/tree/serialization/unsigned-byte.hxx | 44 - libxsd/xsd/cxx/tree/serialization/unsigned-int.hxx | 44 - .../xsd/cxx/tree/serialization/unsigned-long.hxx | 44 - .../xsd/cxx/tree/serialization/unsigned-short.hxx | 44 - libxsd/xsd/cxx/tree/std-ostream-map.hxx | 112 - libxsd/xsd/cxx/tree/std-ostream-map.txx | 291 -- libxsd/xsd/cxx/tree/std-ostream-operators.hxx | 276 -- libxsd/xsd/cxx/tree/stream-extraction-map.hxx | 105 - libxsd/xsd/cxx/tree/stream-extraction-map.txx | 331 -- libxsd/xsd/cxx/tree/stream-extraction.hxx | 304 -- libxsd/xsd/cxx/tree/stream-insertion-map.hxx | 152 - libxsd/xsd/cxx/tree/stream-insertion-map.txx | 355 -- libxsd/xsd/cxx/tree/stream-insertion.hxx | 275 -- libxsd/xsd/cxx/tree/text.hxx | 28 - libxsd/xsd/cxx/tree/text.txx | 61 - libxsd/xsd/cxx/tree/type-factory-map.hxx | 173 - libxsd/xsd/cxx/tree/type-factory-map.txx | 481 --- libxsd/xsd/cxx/tree/type-serializer-map.hxx | 234 -- libxsd/xsd/cxx/tree/type-serializer-map.txx | 572 --- libxsd/xsd/cxx/tree/types.hxx | 3942 ------------------- libxsd/xsd/cxx/tree/types.txx | 528 --- libxsd/xsd/cxx/tree/xdr-stream-common.hxx | 24 - libxsd/xsd/cxx/tree/xdr-stream-extraction.hxx | 306 -- libxsd/xsd/cxx/tree/xdr-stream-insertion.hxx | 270 -- libxsd/xsd/cxx/version.hxx | 27 - libxsd/xsd/cxx/xml/bits/literals.hxx | 81 - libxsd/xsd/cxx/xml/bits/literals.ixx | 259 -- libxsd/xsd/cxx/xml/char-iso8859-1.hxx | 70 - libxsd/xsd/cxx/xml/char-iso8859-1.txx | 110 - libxsd/xsd/cxx/xml/char-lcp.hxx | 54 - libxsd/xsd/cxx/xml/char-lcp.txx | 73 - libxsd/xsd/cxx/xml/char-utf8.hxx | 55 - libxsd/xsd/cxx/xml/char-utf8.txx | 302 -- libxsd/xsd/cxx/xml/dom/auto-ptr.hxx | 232 -- .../xsd/cxx/xml/dom/bits/error-handler-proxy.hxx | 59 - .../xsd/cxx/xml/dom/bits/error-handler-proxy.txx | 66 - libxsd/xsd/cxx/xml/dom/elements.hxx | 34 - libxsd/xsd/cxx/xml/dom/elements.txx | 55 - libxsd/xsd/cxx/xml/dom/parsing-header.hxx | 22 - libxsd/xsd/cxx/xml/dom/parsing-source.hxx | 152 - libxsd/xsd/cxx/xml/dom/parsing-source.txx | 379 -- libxsd/xsd/cxx/xml/dom/serialization-header.hxx | 79 - libxsd/xsd/cxx/xml/dom/serialization-header.txx | 188 - libxsd/xsd/cxx/xml/dom/serialization-source.hxx | 181 - libxsd/xsd/cxx/xml/dom/serialization-source.txx | 362 -- libxsd/xsd/cxx/xml/dom/wildcard-source.hxx | 29 - libxsd/xsd/cxx/xml/dom/wildcard-source.txx | 36 - libxsd/xsd/cxx/xml/elements.hxx | 116 - libxsd/xsd/cxx/xml/elements.txx | 71 - libxsd/xsd/cxx/xml/error-handler.hxx | 57 - libxsd/xsd/cxx/xml/exceptions.hxx | 18 - libxsd/xsd/cxx/xml/qualified-name.hxx | 82 - .../xsd/cxx/xml/sax/bits/error-handler-proxy.hxx | 78 - .../xsd/cxx/xml/sax/bits/error-handler-proxy.txx | 76 - libxsd/xsd/cxx/xml/sax/std-input-source.hxx | 151 - libxsd/xsd/cxx/xml/std-memory-manager.hxx | 53 - libxsd/xsd/cxx/xml/string.hxx | 89 - libxsd/xsd/cxx/xml/string.ixx | 169 - libxsd/xsd/cxx/xml/string.txx | 161 - libxsd/xsd/cxx/zc-istream.hxx | 215 -- libxsd/xsd/cxx/zc-istream.txx | 92 - 385 files changed, 54772 insertions(+), 53375 deletions(-) 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 create mode 100644 libxsd/libxsd/buildfile create mode 100644 libxsd/libxsd/cxx/auto-array.hxx create mode 100644 libxsd/libxsd/cxx/compilers/vc-8/post.hxx create mode 100644 libxsd/libxsd/cxx/compilers/vc-8/pre.hxx create mode 100644 libxsd/libxsd/cxx/config.hxx create mode 100644 libxsd/libxsd/cxx/exceptions.hxx create mode 100644 libxsd/libxsd/cxx/parser/document.hxx create mode 100644 libxsd/libxsd/cxx/parser/document.txx create mode 100644 libxsd/libxsd/cxx/parser/elements.hxx create mode 100644 libxsd/libxsd/cxx/parser/elements.txx create mode 100644 libxsd/libxsd/cxx/parser/error-handler.hxx create mode 100644 libxsd/libxsd/cxx/parser/error-handler.txx create mode 100644 libxsd/libxsd/cxx/parser/exceptions.hxx create mode 100644 libxsd/libxsd/cxx/parser/exceptions.ixx create mode 100644 libxsd/libxsd/cxx/parser/exceptions.txx create mode 100644 libxsd/libxsd/cxx/parser/expat/elements.hxx create mode 100644 libxsd/libxsd/cxx/parser/expat/elements.txx create mode 100644 libxsd/libxsd/cxx/parser/map.hxx create mode 100644 libxsd/libxsd/cxx/parser/map.ixx create mode 100644 libxsd/libxsd/cxx/parser/map.txx create mode 100644 libxsd/libxsd/cxx/parser/non-validating/parser.hxx create mode 100644 libxsd/libxsd/cxx/parser/non-validating/parser.txx create mode 100644 libxsd/libxsd/cxx/parser/non-validating/xml-schema-pimpl.hxx create mode 100644 libxsd/libxsd/cxx/parser/non-validating/xml-schema-pimpl.ixx create mode 100644 libxsd/libxsd/cxx/parser/non-validating/xml-schema-pimpl.txx create mode 100644 libxsd/libxsd/cxx/parser/non-validating/xml-schema-pskel.hxx create mode 100644 libxsd/libxsd/cxx/parser/non-validating/xml-schema-pskel.ixx create mode 100644 libxsd/libxsd/cxx/parser/non-validating/xml-schema-pskel.txx create mode 100644 libxsd/libxsd/cxx/parser/schema-exceptions.hxx create mode 100644 libxsd/libxsd/cxx/parser/schema-exceptions.ixx create mode 100644 libxsd/libxsd/cxx/parser/schema-exceptions.txx create mode 100644 libxsd/libxsd/cxx/parser/substitution-map.hxx create mode 100644 libxsd/libxsd/cxx/parser/substitution-map.txx create mode 100644 libxsd/libxsd/cxx/parser/validating/exceptions.hxx create mode 100644 libxsd/libxsd/cxx/parser/validating/exceptions.ixx create mode 100644 libxsd/libxsd/cxx/parser/validating/exceptions.txx create mode 100644 libxsd/libxsd/cxx/parser/validating/inheritance-map.hxx create mode 100644 libxsd/libxsd/cxx/parser/validating/inheritance-map.txx create mode 100644 libxsd/libxsd/cxx/parser/validating/parser.hxx create mode 100644 libxsd/libxsd/cxx/parser/validating/parser.txx create mode 100644 libxsd/libxsd/cxx/parser/validating/xml-schema-pimpl.hxx create mode 100644 libxsd/libxsd/cxx/parser/validating/xml-schema-pimpl.ixx create mode 100644 libxsd/libxsd/cxx/parser/validating/xml-schema-pimpl.txx create mode 100644 libxsd/libxsd/cxx/parser/validating/xml-schema-pskel.hxx create mode 100644 libxsd/libxsd/cxx/parser/validating/xml-schema-pskel.ixx create mode 100644 libxsd/libxsd/cxx/parser/validating/xml-schema-pskel.txx create mode 100644 libxsd/libxsd/cxx/parser/xerces/elements.hxx create mode 100644 libxsd/libxsd/cxx/parser/xerces/elements.txx create mode 100644 libxsd/libxsd/cxx/parser/xml-schema.hxx create mode 100644 libxsd/libxsd/cxx/parser/xml-schema.ixx create mode 100644 libxsd/libxsd/cxx/parser/xml-schema.txx create mode 100644 libxsd/libxsd/cxx/post.hxx create mode 100644 libxsd/libxsd/cxx/pre.hxx create mode 100644 libxsd/libxsd/cxx/ro-string.hxx create mode 100644 libxsd/libxsd/cxx/ro-string.txx create mode 100644 libxsd/libxsd/cxx/tree/ace-cdr-stream-common.hxx create mode 100644 libxsd/libxsd/cxx/tree/ace-cdr-stream-extraction.hxx create mode 100644 libxsd/libxsd/cxx/tree/ace-cdr-stream-insertion.hxx create mode 100644 libxsd/libxsd/cxx/tree/bits/literals.hxx create mode 100644 libxsd/libxsd/cxx/tree/bits/literals.ixx create mode 100644 libxsd/libxsd/cxx/tree/buffer.hxx create mode 100644 libxsd/libxsd/cxx/tree/buffer.txx create mode 100644 libxsd/libxsd/cxx/tree/comparison-map.hxx create mode 100644 libxsd/libxsd/cxx/tree/comparison-map.txx create mode 100644 libxsd/libxsd/cxx/tree/containers-wildcard.hxx create mode 100644 libxsd/libxsd/cxx/tree/containers.hxx create mode 100644 libxsd/libxsd/cxx/tree/containers.txx create mode 100644 libxsd/libxsd/cxx/tree/date-time-extraction.txx create mode 100644 libxsd/libxsd/cxx/tree/date-time-insertion.txx create mode 100644 libxsd/libxsd/cxx/tree/date-time-ostream.txx create mode 100644 libxsd/libxsd/cxx/tree/date-time.hxx create mode 100644 libxsd/libxsd/cxx/tree/date-time.ixx create mode 100644 libxsd/libxsd/cxx/tree/date-time.txx create mode 100644 libxsd/libxsd/cxx/tree/element-map.hxx create mode 100644 libxsd/libxsd/cxx/tree/element-map.txx create mode 100644 libxsd/libxsd/cxx/tree/elements.hxx create mode 100644 libxsd/libxsd/cxx/tree/elements.ixx create mode 100644 libxsd/libxsd/cxx/tree/elements.txx create mode 100644 libxsd/libxsd/cxx/tree/error-handler.hxx create mode 100644 libxsd/libxsd/cxx/tree/error-handler.txx create mode 100644 libxsd/libxsd/cxx/tree/exceptions.hxx create mode 100644 libxsd/libxsd/cxx/tree/exceptions.txx create mode 100644 libxsd/libxsd/cxx/tree/facet.hxx create mode 100644 libxsd/libxsd/cxx/tree/istream-fwd.hxx create mode 100644 libxsd/libxsd/cxx/tree/istream.hxx create mode 100644 libxsd/libxsd/cxx/tree/iterator-adapter.hxx create mode 100644 libxsd/libxsd/cxx/tree/list.hxx create mode 100644 libxsd/libxsd/cxx/tree/ostream.hxx create mode 100644 libxsd/libxsd/cxx/tree/parsing.hxx create mode 100644 libxsd/libxsd/cxx/tree/parsing.txx create mode 100644 libxsd/libxsd/cxx/tree/parsing/boolean.hxx create mode 100644 libxsd/libxsd/cxx/tree/parsing/byte.hxx create mode 100644 libxsd/libxsd/cxx/tree/parsing/date-time.txx create mode 100644 libxsd/libxsd/cxx/tree/parsing/decimal.hxx create mode 100644 libxsd/libxsd/cxx/tree/parsing/double.hxx create mode 100644 libxsd/libxsd/cxx/tree/parsing/element-map.txx create mode 100644 libxsd/libxsd/cxx/tree/parsing/float.hxx create mode 100644 libxsd/libxsd/cxx/tree/parsing/int.hxx create mode 100644 libxsd/libxsd/cxx/tree/parsing/long.hxx create mode 100644 libxsd/libxsd/cxx/tree/parsing/short.hxx create mode 100644 libxsd/libxsd/cxx/tree/parsing/unsigned-byte.hxx create mode 100644 libxsd/libxsd/cxx/tree/parsing/unsigned-int.hxx create mode 100644 libxsd/libxsd/cxx/tree/parsing/unsigned-long.hxx create mode 100644 libxsd/libxsd/cxx/tree/parsing/unsigned-short.hxx create mode 100644 libxsd/libxsd/cxx/tree/serialization.hxx create mode 100644 libxsd/libxsd/cxx/tree/serialization.txx create mode 100644 libxsd/libxsd/cxx/tree/serialization/boolean.hxx create mode 100644 libxsd/libxsd/cxx/tree/serialization/byte.hxx create mode 100644 libxsd/libxsd/cxx/tree/serialization/date-time.txx create mode 100644 libxsd/libxsd/cxx/tree/serialization/decimal.hxx create mode 100644 libxsd/libxsd/cxx/tree/serialization/double.hxx create mode 100644 libxsd/libxsd/cxx/tree/serialization/element-map.txx create mode 100644 libxsd/libxsd/cxx/tree/serialization/float.hxx create mode 100644 libxsd/libxsd/cxx/tree/serialization/int.hxx create mode 100644 libxsd/libxsd/cxx/tree/serialization/long.hxx create mode 100644 libxsd/libxsd/cxx/tree/serialization/short.hxx create mode 100644 libxsd/libxsd/cxx/tree/serialization/unsigned-byte.hxx create mode 100644 libxsd/libxsd/cxx/tree/serialization/unsigned-int.hxx create mode 100644 libxsd/libxsd/cxx/tree/serialization/unsigned-long.hxx create mode 100644 libxsd/libxsd/cxx/tree/serialization/unsigned-short.hxx create mode 100644 libxsd/libxsd/cxx/tree/std-ostream-map.hxx create mode 100644 libxsd/libxsd/cxx/tree/std-ostream-map.txx create mode 100644 libxsd/libxsd/cxx/tree/std-ostream-operators.hxx create mode 100644 libxsd/libxsd/cxx/tree/stream-extraction-map.hxx create mode 100644 libxsd/libxsd/cxx/tree/stream-extraction-map.txx create mode 100644 libxsd/libxsd/cxx/tree/stream-extraction.hxx create mode 100644 libxsd/libxsd/cxx/tree/stream-insertion-map.hxx create mode 100644 libxsd/libxsd/cxx/tree/stream-insertion-map.txx create mode 100644 libxsd/libxsd/cxx/tree/stream-insertion.hxx create mode 100644 libxsd/libxsd/cxx/tree/text.hxx create mode 100644 libxsd/libxsd/cxx/tree/text.txx create mode 100644 libxsd/libxsd/cxx/tree/type-factory-map.hxx create mode 100644 libxsd/libxsd/cxx/tree/type-factory-map.txx create mode 100644 libxsd/libxsd/cxx/tree/type-serializer-map.hxx create mode 100644 libxsd/libxsd/cxx/tree/type-serializer-map.txx create mode 100644 libxsd/libxsd/cxx/tree/types.hxx create mode 100644 libxsd/libxsd/cxx/tree/types.txx create mode 100644 libxsd/libxsd/cxx/tree/xdr-stream-common.hxx create mode 100644 libxsd/libxsd/cxx/tree/xdr-stream-extraction.hxx create mode 100644 libxsd/libxsd/cxx/tree/xdr-stream-insertion.hxx create mode 100644 libxsd/libxsd/cxx/version.hxx create mode 100644 libxsd/libxsd/cxx/version.hxx.in create mode 100644 libxsd/libxsd/cxx/xml/bits/literals.hxx create mode 100644 libxsd/libxsd/cxx/xml/bits/literals.ixx create mode 100644 libxsd/libxsd/cxx/xml/char-iso8859-1.hxx create mode 100644 libxsd/libxsd/cxx/xml/char-iso8859-1.txx create mode 100644 libxsd/libxsd/cxx/xml/char-lcp.hxx create mode 100644 libxsd/libxsd/cxx/xml/char-lcp.txx create mode 100644 libxsd/libxsd/cxx/xml/char-utf8.hxx create mode 100644 libxsd/libxsd/cxx/xml/char-utf8.txx create mode 100644 libxsd/libxsd/cxx/xml/dom/auto-ptr.hxx create mode 100644 libxsd/libxsd/cxx/xml/dom/bits/error-handler-proxy.hxx create mode 100644 libxsd/libxsd/cxx/xml/dom/bits/error-handler-proxy.txx create mode 100644 libxsd/libxsd/cxx/xml/dom/elements.hxx create mode 100644 libxsd/libxsd/cxx/xml/dom/elements.txx create mode 100644 libxsd/libxsd/cxx/xml/dom/parsing-header.hxx create mode 100644 libxsd/libxsd/cxx/xml/dom/parsing-source.hxx create mode 100644 libxsd/libxsd/cxx/xml/dom/parsing-source.txx create mode 100644 libxsd/libxsd/cxx/xml/dom/serialization-header.hxx create mode 100644 libxsd/libxsd/cxx/xml/dom/serialization-header.txx create mode 100644 libxsd/libxsd/cxx/xml/dom/serialization-source.hxx create mode 100644 libxsd/libxsd/cxx/xml/dom/serialization-source.txx create mode 100644 libxsd/libxsd/cxx/xml/dom/wildcard-source.hxx create mode 100644 libxsd/libxsd/cxx/xml/dom/wildcard-source.txx create mode 100644 libxsd/libxsd/cxx/xml/elements.hxx create mode 100644 libxsd/libxsd/cxx/xml/elements.txx create mode 100644 libxsd/libxsd/cxx/xml/error-handler.hxx create mode 100644 libxsd/libxsd/cxx/xml/exceptions.hxx create mode 100644 libxsd/libxsd/cxx/xml/qualified-name.hxx create mode 100644 libxsd/libxsd/cxx/xml/sax/bits/error-handler-proxy.hxx create mode 100644 libxsd/libxsd/cxx/xml/sax/bits/error-handler-proxy.txx create mode 100644 libxsd/libxsd/cxx/xml/sax/std-input-source.hxx create mode 100644 libxsd/libxsd/cxx/xml/std-memory-manager.hxx create mode 100644 libxsd/libxsd/cxx/xml/string.hxx create mode 100644 libxsd/libxsd/cxx/xml/string.ixx create mode 100644 libxsd/libxsd/cxx/xml/string.txx create mode 100644 libxsd/libxsd/cxx/zc-istream.hxx create mode 100644 libxsd/libxsd/cxx/zc-istream.txx delete mode 100644 libxsd/makefile create mode 100644 libxsd/manifest create mode 100644 libxsd/tests/.gitignore 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/basic/.gitignore create mode 100644 libxsd/tests/cxx/parser/basic/buildfile create mode 100644 libxsd/tests/cxx/parser/basic/driver.cxx create mode 100644 libxsd/tests/cxx/parser/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 delete mode 100644 libxsd/xsd/cxx/auto-array.hxx delete mode 100644 libxsd/xsd/cxx/compilers/vc-8/post.hxx delete mode 100644 libxsd/xsd/cxx/compilers/vc-8/pre.hxx delete mode 100644 libxsd/xsd/cxx/config.hxx delete mode 100644 libxsd/xsd/cxx/exceptions.hxx delete mode 100644 libxsd/xsd/cxx/parser/document.hxx delete mode 100644 libxsd/xsd/cxx/parser/document.txx delete mode 100644 libxsd/xsd/cxx/parser/elements.hxx delete mode 100644 libxsd/xsd/cxx/parser/elements.txx delete mode 100644 libxsd/xsd/cxx/parser/error-handler.hxx delete mode 100644 libxsd/xsd/cxx/parser/error-handler.txx delete mode 100644 libxsd/xsd/cxx/parser/exceptions.hxx delete mode 100644 libxsd/xsd/cxx/parser/exceptions.ixx delete mode 100644 libxsd/xsd/cxx/parser/exceptions.txx delete mode 100644 libxsd/xsd/cxx/parser/expat/elements.hxx delete mode 100644 libxsd/xsd/cxx/parser/expat/elements.txx delete mode 100644 libxsd/xsd/cxx/parser/map.hxx delete mode 100644 libxsd/xsd/cxx/parser/map.ixx delete mode 100644 libxsd/xsd/cxx/parser/map.txx delete mode 100644 libxsd/xsd/cxx/parser/non-validating/parser.hxx delete mode 100644 libxsd/xsd/cxx/parser/non-validating/parser.txx delete mode 100644 libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.hxx delete mode 100644 libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.ixx delete mode 100644 libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.txx delete mode 100644 libxsd/xsd/cxx/parser/non-validating/xml-schema-pskel.hxx delete mode 100644 libxsd/xsd/cxx/parser/non-validating/xml-schema-pskel.ixx delete mode 100644 libxsd/xsd/cxx/parser/non-validating/xml-schema-pskel.txx delete mode 100644 libxsd/xsd/cxx/parser/schema-exceptions.hxx delete mode 100644 libxsd/xsd/cxx/parser/schema-exceptions.ixx delete mode 100644 libxsd/xsd/cxx/parser/schema-exceptions.txx delete mode 100644 libxsd/xsd/cxx/parser/substitution-map.hxx delete mode 100644 libxsd/xsd/cxx/parser/substitution-map.txx delete mode 100644 libxsd/xsd/cxx/parser/validating/exceptions.hxx delete mode 100644 libxsd/xsd/cxx/parser/validating/exceptions.ixx delete mode 100644 libxsd/xsd/cxx/parser/validating/exceptions.txx delete mode 100644 libxsd/xsd/cxx/parser/validating/inheritance-map.hxx delete mode 100644 libxsd/xsd/cxx/parser/validating/inheritance-map.txx delete mode 100644 libxsd/xsd/cxx/parser/validating/parser.hxx delete mode 100644 libxsd/xsd/cxx/parser/validating/parser.txx delete mode 100644 libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.hxx delete mode 100644 libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.ixx delete mode 100644 libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.txx delete mode 100644 libxsd/xsd/cxx/parser/validating/xml-schema-pskel.hxx delete mode 100644 libxsd/xsd/cxx/parser/validating/xml-schema-pskel.ixx delete mode 100644 libxsd/xsd/cxx/parser/validating/xml-schema-pskel.txx delete mode 100644 libxsd/xsd/cxx/parser/xerces/elements.hxx delete mode 100644 libxsd/xsd/cxx/parser/xerces/elements.txx delete mode 100644 libxsd/xsd/cxx/parser/xml-schema.hxx delete mode 100644 libxsd/xsd/cxx/parser/xml-schema.ixx delete mode 100644 libxsd/xsd/cxx/parser/xml-schema.txx delete mode 100644 libxsd/xsd/cxx/post.hxx delete mode 100644 libxsd/xsd/cxx/pre.hxx delete mode 100644 libxsd/xsd/cxx/ro-string.hxx delete mode 100644 libxsd/xsd/cxx/ro-string.txx delete mode 100644 libxsd/xsd/cxx/tree/ace-cdr-stream-common.hxx delete mode 100644 libxsd/xsd/cxx/tree/ace-cdr-stream-extraction.hxx delete mode 100644 libxsd/xsd/cxx/tree/ace-cdr-stream-insertion.hxx delete mode 100644 libxsd/xsd/cxx/tree/bits/literals.hxx delete mode 100644 libxsd/xsd/cxx/tree/bits/literals.ixx delete mode 100644 libxsd/xsd/cxx/tree/buffer.hxx delete mode 100644 libxsd/xsd/cxx/tree/buffer.txx delete mode 100644 libxsd/xsd/cxx/tree/comparison-map.hxx delete mode 100644 libxsd/xsd/cxx/tree/comparison-map.txx delete mode 100644 libxsd/xsd/cxx/tree/containers-wildcard.hxx delete mode 100644 libxsd/xsd/cxx/tree/containers.hxx delete mode 100644 libxsd/xsd/cxx/tree/containers.txx delete mode 100644 libxsd/xsd/cxx/tree/date-time-extraction.txx delete mode 100644 libxsd/xsd/cxx/tree/date-time-insertion.txx delete mode 100644 libxsd/xsd/cxx/tree/date-time-ostream.txx delete mode 100644 libxsd/xsd/cxx/tree/date-time.hxx delete mode 100644 libxsd/xsd/cxx/tree/date-time.ixx delete mode 100644 libxsd/xsd/cxx/tree/date-time.txx delete mode 100644 libxsd/xsd/cxx/tree/element-map.hxx delete mode 100644 libxsd/xsd/cxx/tree/element-map.txx delete mode 100644 libxsd/xsd/cxx/tree/elements.hxx delete mode 100644 libxsd/xsd/cxx/tree/elements.ixx delete mode 100644 libxsd/xsd/cxx/tree/elements.txx delete mode 100644 libxsd/xsd/cxx/tree/error-handler.hxx delete mode 100644 libxsd/xsd/cxx/tree/error-handler.txx delete mode 100644 libxsd/xsd/cxx/tree/exceptions.hxx delete mode 100644 libxsd/xsd/cxx/tree/exceptions.txx delete mode 100644 libxsd/xsd/cxx/tree/facet.hxx delete mode 100644 libxsd/xsd/cxx/tree/istream-fwd.hxx delete mode 100644 libxsd/xsd/cxx/tree/istream.hxx delete mode 100644 libxsd/xsd/cxx/tree/iterator-adapter.hxx delete mode 100644 libxsd/xsd/cxx/tree/list.hxx delete mode 100644 libxsd/xsd/cxx/tree/ostream.hxx delete mode 100644 libxsd/xsd/cxx/tree/parsing.hxx delete mode 100644 libxsd/xsd/cxx/tree/parsing.txx delete mode 100644 libxsd/xsd/cxx/tree/parsing/boolean.hxx delete mode 100644 libxsd/xsd/cxx/tree/parsing/byte.hxx delete mode 100644 libxsd/xsd/cxx/tree/parsing/date-time.txx delete mode 100644 libxsd/xsd/cxx/tree/parsing/decimal.hxx delete mode 100644 libxsd/xsd/cxx/tree/parsing/double.hxx delete mode 100644 libxsd/xsd/cxx/tree/parsing/element-map.txx delete mode 100644 libxsd/xsd/cxx/tree/parsing/float.hxx delete mode 100644 libxsd/xsd/cxx/tree/parsing/int.hxx delete mode 100644 libxsd/xsd/cxx/tree/parsing/long.hxx delete mode 100644 libxsd/xsd/cxx/tree/parsing/short.hxx delete mode 100644 libxsd/xsd/cxx/tree/parsing/unsigned-byte.hxx delete mode 100644 libxsd/xsd/cxx/tree/parsing/unsigned-int.hxx delete mode 100644 libxsd/xsd/cxx/tree/parsing/unsigned-long.hxx delete mode 100644 libxsd/xsd/cxx/tree/parsing/unsigned-short.hxx delete mode 100644 libxsd/xsd/cxx/tree/serialization.hxx delete mode 100644 libxsd/xsd/cxx/tree/serialization.txx delete mode 100644 libxsd/xsd/cxx/tree/serialization/boolean.hxx delete mode 100644 libxsd/xsd/cxx/tree/serialization/byte.hxx delete mode 100644 libxsd/xsd/cxx/tree/serialization/date-time.txx delete mode 100644 libxsd/xsd/cxx/tree/serialization/decimal.hxx delete mode 100644 libxsd/xsd/cxx/tree/serialization/double.hxx delete mode 100644 libxsd/xsd/cxx/tree/serialization/element-map.txx delete mode 100644 libxsd/xsd/cxx/tree/serialization/float.hxx delete mode 100644 libxsd/xsd/cxx/tree/serialization/int.hxx delete mode 100644 libxsd/xsd/cxx/tree/serialization/long.hxx delete mode 100644 libxsd/xsd/cxx/tree/serialization/short.hxx delete mode 100644 libxsd/xsd/cxx/tree/serialization/unsigned-byte.hxx delete mode 100644 libxsd/xsd/cxx/tree/serialization/unsigned-int.hxx delete mode 100644 libxsd/xsd/cxx/tree/serialization/unsigned-long.hxx delete mode 100644 libxsd/xsd/cxx/tree/serialization/unsigned-short.hxx delete mode 100644 libxsd/xsd/cxx/tree/std-ostream-map.hxx delete mode 100644 libxsd/xsd/cxx/tree/std-ostream-map.txx delete mode 100644 libxsd/xsd/cxx/tree/std-ostream-operators.hxx delete mode 100644 libxsd/xsd/cxx/tree/stream-extraction-map.hxx delete mode 100644 libxsd/xsd/cxx/tree/stream-extraction-map.txx delete mode 100644 libxsd/xsd/cxx/tree/stream-extraction.hxx delete mode 100644 libxsd/xsd/cxx/tree/stream-insertion-map.hxx delete mode 100644 libxsd/xsd/cxx/tree/stream-insertion-map.txx delete mode 100644 libxsd/xsd/cxx/tree/stream-insertion.hxx delete mode 100644 libxsd/xsd/cxx/tree/text.hxx delete mode 100644 libxsd/xsd/cxx/tree/text.txx delete mode 100644 libxsd/xsd/cxx/tree/type-factory-map.hxx delete mode 100644 libxsd/xsd/cxx/tree/type-factory-map.txx delete mode 100644 libxsd/xsd/cxx/tree/type-serializer-map.hxx delete mode 100644 libxsd/xsd/cxx/tree/type-serializer-map.txx delete mode 100644 libxsd/xsd/cxx/tree/types.hxx delete mode 100644 libxsd/xsd/cxx/tree/types.txx delete mode 100644 libxsd/xsd/cxx/tree/xdr-stream-common.hxx delete mode 100644 libxsd/xsd/cxx/tree/xdr-stream-extraction.hxx delete mode 100644 libxsd/xsd/cxx/tree/xdr-stream-insertion.hxx delete mode 100644 libxsd/xsd/cxx/version.hxx delete mode 100644 libxsd/xsd/cxx/xml/bits/literals.hxx delete mode 100644 libxsd/xsd/cxx/xml/bits/literals.ixx delete mode 100644 libxsd/xsd/cxx/xml/char-iso8859-1.hxx delete mode 100644 libxsd/xsd/cxx/xml/char-iso8859-1.txx delete mode 100644 libxsd/xsd/cxx/xml/char-lcp.hxx delete mode 100644 libxsd/xsd/cxx/xml/char-lcp.txx delete mode 100644 libxsd/xsd/cxx/xml/char-utf8.hxx delete mode 100644 libxsd/xsd/cxx/xml/char-utf8.txx delete mode 100644 libxsd/xsd/cxx/xml/dom/auto-ptr.hxx delete mode 100644 libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.hxx delete mode 100644 libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx delete mode 100644 libxsd/xsd/cxx/xml/dom/elements.hxx delete mode 100644 libxsd/xsd/cxx/xml/dom/elements.txx delete mode 100644 libxsd/xsd/cxx/xml/dom/parsing-header.hxx delete mode 100644 libxsd/xsd/cxx/xml/dom/parsing-source.hxx delete mode 100644 libxsd/xsd/cxx/xml/dom/parsing-source.txx delete mode 100644 libxsd/xsd/cxx/xml/dom/serialization-header.hxx delete mode 100644 libxsd/xsd/cxx/xml/dom/serialization-header.txx delete mode 100644 libxsd/xsd/cxx/xml/dom/serialization-source.hxx delete mode 100644 libxsd/xsd/cxx/xml/dom/serialization-source.txx delete mode 100644 libxsd/xsd/cxx/xml/dom/wildcard-source.hxx delete mode 100644 libxsd/xsd/cxx/xml/dom/wildcard-source.txx delete mode 100644 libxsd/xsd/cxx/xml/elements.hxx delete mode 100644 libxsd/xsd/cxx/xml/elements.txx delete mode 100644 libxsd/xsd/cxx/xml/error-handler.hxx delete mode 100644 libxsd/xsd/cxx/xml/exceptions.hxx delete mode 100644 libxsd/xsd/cxx/xml/qualified-name.hxx delete mode 100644 libxsd/xsd/cxx/xml/sax/bits/error-handler-proxy.hxx delete mode 100644 libxsd/xsd/cxx/xml/sax/bits/error-handler-proxy.txx delete mode 100644 libxsd/xsd/cxx/xml/sax/std-input-source.hxx delete mode 100644 libxsd/xsd/cxx/xml/std-memory-manager.hxx delete mode 100644 libxsd/xsd/cxx/xml/string.hxx delete mode 100644 libxsd/xsd/cxx/xml/string.ixx delete mode 100644 libxsd/xsd/cxx/xml/string.txx delete mode 100644 libxsd/xsd/cxx/zc-istream.hxx delete mode 100644 libxsd/xsd/cxx/zc-istream.txx (limited to 'libxsd') 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..8a37421 100644 --- a/libxsd/README +++ b/libxsd/README @@ -1,5 +1,5 @@ -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. @@ -9,4 +9,3 @@ 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..7e8d36a --- /dev/null +++ b/libxsd/README-GIT @@ -0,0 +1,4 @@ +The checked out libxsd/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 libxsd/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..c432329 --- /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 libxsd/ +} + +export $out_root/libxsd/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..552635c --- /dev/null +++ b/libxsd/buildfile @@ -0,0 +1,9 @@ +# file : buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +./: {*/ -build/} doc{INSTALL NEWS README} legal{GPLv2 LICENSE FLOSSE} manifest + +# Don't install tests or the INSTALL file. +# +tests/: install = false +doc{INSTALL}@./: install = false diff --git a/libxsd/doc/buildfile b/libxsd/doc/buildfile new file mode 100644 index 0000000..76640e6 --- /dev/null +++ b/libxsd/doc/buildfile @@ -0,0 +1,86 @@ +# 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: doc +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]) + { + # Listing the generated html/ directory content here doesn't look right, + # so we specify the directory as a prerequisite. + # + ../../../: doxytag{libxsd} + + headers = buffer types date-time elements element-map exceptions + + : doxygen{libxsd} \ + html{footer} \ + $src_root/libxsd/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/libxsd/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..6ebaceb --- /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 = %src_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/libxsd/buildfile b/libxsd/libxsd/buildfile new file mode 100644 index 0000000..1549f19 --- /dev/null +++ b/libxsd/libxsd/buildfile @@ -0,0 +1,38 @@ +# file : libxsd/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import int_libs = libxerces-c%lib{xerces-c} +import int_libs += libexpat%lib{expat} + +lib{xsd}: cxx/{hxx ixx txx}{** -version} cxx/{hxx}{version} $int_libs + +# 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" + cxx.export.libs = $int_libs +} + +# Install into the libxsd/ subdirectory of, say, /usr/include/ recreating +# subdirectories. +# +{hxx ixx txx}{*}: +{ + install = include/libxsd/ + install.subdirs = true +} diff --git a/libxsd/libxsd/cxx/auto-array.hxx b/libxsd/libxsd/cxx/auto-array.hxx new file mode 100644 index 0000000..d44a5d2 --- /dev/null +++ b/libxsd/libxsd/cxx/auto-array.hxx @@ -0,0 +1,118 @@ +// file : libxsd/cxx/auto-array.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_AUTO_ARRAY_HXX +#define LIBXSD_CXX_AUTO_ARRAY_HXX + +#include // XSD_CXX11 + +#ifdef XSD_CXX11 +# error use std::unique_ptr instead of non-standard auto_array +#endif + +#include // std::size_t + +namespace xsd +{ + namespace cxx + { + template + struct std_array_deleter + { + void + operator() (T* p) const + { + delete[] p; + } + }; + + // Simple automatic array. The second template parameter is + // an optional deleter type. If not specified, delete[] + // is used. + // + template > + struct auto_array + { + auto_array (T a[]) + : a_ (a), d_ (0) + { + } + + auto_array (T a[], const D& d) + : a_ (a), d_ (&d) + { + } + + ~auto_array () + { + if (d_ != 0) + (*d_) (a_); + else + delete[] a_; + } + + T& + operator[] (std::size_t index) const + { + return a_[index]; + } + + T* + get () const + { + return a_; + } + + T* + release () + { + T* tmp (a_); + a_ = 0; + return tmp; + } + + void + reset (T a[] = 0) + { + if (a_ != a) + { + if (d_ != 0) + (*d_) (a_); + else + delete[] a_; + + a_ = a; + } + } + + typedef void (auto_array::*bool_convertible)(); + + operator bool_convertible () const + { + return a_ ? &auto_array::true_ : 0; + } + + private: + auto_array (const auto_array&); + + auto_array& + operator= (const auto_array&); + + private: + void + true_ (); + + private: + T* a_; + const D* d_; + }; + + template + void auto_array:: + true_ () + { + } + } +} + +#endif // LIBXSD_CXX_AUTO_ARRAY_HXX diff --git a/libxsd/libxsd/cxx/compilers/vc-8/post.hxx b/libxsd/libxsd/cxx/compilers/vc-8/post.hxx new file mode 100644 index 0000000..080b0d3 --- /dev/null +++ b/libxsd/libxsd/cxx/compilers/vc-8/post.hxx @@ -0,0 +1,4 @@ +// file : libxsd/cxx/compilers/vc-8/post.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#pragma warning (pop) diff --git a/libxsd/libxsd/cxx/compilers/vc-8/pre.hxx b/libxsd/libxsd/cxx/compilers/vc-8/pre.hxx new file mode 100644 index 0000000..632a200 --- /dev/null +++ b/libxsd/libxsd/cxx/compilers/vc-8/pre.hxx @@ -0,0 +1,27 @@ +// file : libxsd/cxx/compilers/vc-8/pre.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// These warnings had to be disabled "for good". +// +#pragma warning (disable:4250) // inherits via dominance +#pragma warning (disable:4661) // no definition for explicit instantiation + + +// Push warning state. +// +#pragma warning (push, 3) + + +// Disabled warnings. +// +#pragma warning (disable:4355) // passing 'this' to a member +#pragma warning (disable:4800) // forcing value to bool +#pragma warning (disable:4275) // non dll-interface base +#pragma warning (disable:4251) // base needs to have dll-interface +#pragma warning (disable:4224) // nonstandard extension (/Za option) +#pragma warning (disable:4503) // decorated name length exceeded + + +// Elevated warnings. +// +#pragma warning (2:4239) // standard doesn't allow this conversion diff --git a/libxsd/libxsd/cxx/config.hxx b/libxsd/libxsd/cxx/config.hxx new file mode 100644 index 0000000..394c687 --- /dev/null +++ b/libxsd/libxsd/cxx/config.hxx @@ -0,0 +1,46 @@ +// file : libxsd/cxx/config.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_CONFIG_HXX +#define LIBXSD_CXX_CONFIG_HXX + +#include + +// Available C++11 features. +// +#ifdef XSD_CXX11 +#ifdef _MSC_VER +# if _MSC_VER >= 1600 +# define XSD_CXX11_NULLPTR +# if _MSC_VER >= 1800 +# define XSD_CXX11_TEMPLATE_ALIAS +# endif +# endif +#else +# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L +# ifdef __GNUC__ +# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4 +# define XSD_CXX11_NULLPTR +# endif +# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || __GNUC__ > 4 +# define XSD_CXX11_TEMPLATE_ALIAS +# endif +# else +# define XSD_CXX11_NULLPTR +# define XSD_CXX11_TEMPLATE_ALIAS +# endif +# endif +#endif +#endif // XSD_CXX11 + +#ifdef XSD_CXX11 +# define XSD_AUTO_PTR std::unique_ptr +#else +# define XSD_AUTO_PTR std::auto_ptr +#endif + +// Macro to suppress the unused variable warning. +// +#define XSD_UNUSED(x) (void)x + +#endif // LIBXSD_CXX_CONFIG_HXX diff --git a/libxsd/libxsd/cxx/exceptions.hxx b/libxsd/libxsd/cxx/exceptions.hxx new file mode 100644 index 0000000..ffbf6f6 --- /dev/null +++ b/libxsd/libxsd/cxx/exceptions.hxx @@ -0,0 +1,19 @@ +// file : libxsd/cxx/exceptions.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_EXCEPTIONS_HXX +#define LIBXSD_CXX_EXCEPTIONS_HXX + +#include // std::exception + +namespace xsd +{ + namespace cxx + { + struct exception: std::exception + { + }; + } +} + +#endif // LIBXSD_CXX_EXCEPTIONS_HXX diff --git a/libxsd/libxsd/cxx/parser/document.hxx b/libxsd/libxsd/cxx/parser/document.hxx new file mode 100644 index 0000000..c142f57 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/document.hxx @@ -0,0 +1,88 @@ +// file : libxsd/cxx/parser/document.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_PARSER_DOCUMENT_HXX +#define LIBXSD_CXX_PARSER_DOCUMENT_HXX + +#include +#include // std::size_t + +#include +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + // If you want to use a different underlying XML parser, all you + // need to do is to route events to this interface. + // + template + class document + { + public: + virtual + ~document (); + + document (parser_base& root, + const std::basic_string& ns, + const std::basic_string& name); + + public: + // The type argument is a type name and namespace from the + // xsi:type attribute in the form " " with + // the space and namespace part absent if the type does not + // have a namespace or 0 if xsi:type is not present. + // + void + start_element (const ro_string& ns, + const ro_string& name, + const ro_string* type); + + void + end_element (const ro_string& ns, const ro_string& name); + + void + attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value); + + void + characters (const ro_string&); + + protected: + document (); + + // This function is called to obtain the root element type parser. + // If the returned pointed is 0 then the whole document content + // is ignored. + // + virtual parser_base* + start_root_element (const ro_string& ns, + const ro_string& name, + const ro_string* type); + + // 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, + parser_base* parser); + + private: + parser_base* root_; + std::basic_string ns_; + std::basic_string name_; + std::size_t depth_; + }; + } + } +} + +#include + +#endif // LIBXSD_CXX_PARSER_DOCUMENT_HXX diff --git a/libxsd/libxsd/cxx/parser/document.txx b/libxsd/libxsd/cxx/parser/document.txx new file mode 100644 index 0000000..4d7b5ba --- /dev/null +++ b/libxsd/libxsd/cxx/parser/document.txx @@ -0,0 +1,127 @@ +// file : libxsd/cxx/parser/document.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + // document + // + template + document:: + ~document () + { + } + + template + document:: + document (parser_base& root, + const std::basic_string& ns, + const std::basic_string& name) + : root_ (&root), ns_ (ns), name_ (name), depth_ (0) + { + } + + template + document:: + document () + : root_ (0), depth_ (0) + { + } + + template + void document:: + start_element (const ro_string& ns, + const ro_string& name, + const ro_string* type) + { + if (depth_++ > 0) + { + if (root_) + root_->_start_element (ns, name, type); + } + else + { + root_ = start_root_element (ns, name, type); + + if (root_) + { + // pre () is called by the user. + // + root_->_pre_impl (); + } + } + } + + template + void document:: + end_element (const ro_string& ns, const ro_string& name) + { + assert (depth_ > 0); + + if (--depth_ > 0) + { + if (root_) + root_->_end_element (ns, name); + } + else + { + if (root_) + { + root_->_post_impl (); + // + // post() is called by the user. + } + + end_root_element (ns, name, root_); + } + } + + template + void document:: + attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value) + { + if (root_) + root_->_attribute (ns, name, value); + } + + template + void document:: + characters (const ro_string& s) + { + if (root_) + root_->_characters (s); + } + + template + parser_base* document:: + start_root_element (const ro_string& ns, + const ro_string& name, + const ro_string*) + { + if (name_ == name && ns_ == ns) + { + return root_; + } + else + throw expected_element (ns_, name_, ns, name); + } + + template + void document:: + end_root_element (const ro_string&, + const ro_string&, + parser_base*) + { + } + } + } +} diff --git a/libxsd/libxsd/cxx/parser/elements.hxx b/libxsd/libxsd/cxx/parser/elements.hxx new file mode 100644 index 0000000..d0085be --- /dev/null +++ b/libxsd/libxsd/cxx/parser/elements.hxx @@ -0,0 +1,93 @@ +// file : libxsd/cxx/parser/elements.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_PARSER_ELEMENTS_HXX +#define LIBXSD_CXX_PARSER_ELEMENTS_HXX + +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + // pre() and post() are overridable pre/post callbacks, i.e., the + // derived parser can override them without calling the base version. + // _pre() and _post() are not overridable pre/post callbacks in the + // sense that the derived parser may override them but has to call + // the base version. The call sequence is as shown below: + // + // pre () + // _pre () + // _post () + // post () + // + template + class parser_base + { + public: + virtual + ~parser_base (); + + virtual void + pre (); + + virtual void + _pre (); + + // The type argument is a type name and namespace from the + // xsi:type attribute in the form " " with + // the space and namespace part absent if the type does not + // have a namespace or 0 if xsi:type is not present. + // + virtual void + _start_element (const ro_string& ns, + const ro_string& name, + const ro_string* type) = 0; + + virtual void + _end_element (const ro_string& ns, + const ro_string& name) = 0; + + virtual void + _attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value) = 0; + + virtual void + _characters (const ro_string&) = 0; + + virtual void + _post (); + + // The post() signature varies depending on the parser return + // type. + // + + // Implementation callbacks for _pre and _post. The _pre and _post + // callbacks should never be called directly. Instead, the *_impl + // versions should be used. By default _pre_impl and _post_impl + // simply call _pre and _post respectively. + // + virtual void + _pre_impl (); + + virtual void + _post_impl (); + + public: + // Dynamic type in the form " " with + // the space and namespace part absent if the type does + // not have a namespace. Used in polymorphism-aware code. + // + virtual const C* + _dynamic_type () const; + }; + } + } +} + +#include + +#endif // LIBXSD_CXX_PARSER_ELEMENTS_HXX diff --git a/libxsd/libxsd/cxx/parser/elements.txx b/libxsd/libxsd/cxx/parser/elements.txx new file mode 100644 index 0000000..5abf5f5 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/elements.txx @@ -0,0 +1,58 @@ +// file : libxsd/cxx/parser/elements.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsd +{ + namespace cxx + { + namespace parser + { + // parser_base + // + template + parser_base:: + ~parser_base () + { + } + + template + void parser_base:: + pre () + { + } + + template + void parser_base:: + _pre () + { + } + + template + void parser_base:: + _post () + { + } + + template + void parser_base:: + _pre_impl () + { + _pre (); + } + + template + void parser_base:: + _post_impl () + { + _post (); + } + + template + const C* parser_base:: + _dynamic_type () const + { + return 0; + } + } + } +} diff --git a/libxsd/libxsd/cxx/parser/error-handler.hxx b/libxsd/libxsd/cxx/parser/error-handler.hxx new file mode 100644 index 0000000..7b44325 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/error-handler.hxx @@ -0,0 +1,55 @@ +// file : libxsd/cxx/parser/error-handler.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_PARSER_ERROR_HANDLER_HXX +#define LIBXSD_CXX_PARSER_ERROR_HANDLER_HXX + +#include + +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + template + class error_handler: public xml::error_handler + { + public: + typedef typename xml::error_handler::severity severity; + + error_handler () + : failed_ (false) + { + } + + virtual bool + handle (const std::basic_string& id, + unsigned long line, + unsigned long column, + severity s, + const std::basic_string& message); + + void + throw_if_failed () const; + + void + reset () + { + failed_ = false; + diagnostics_.clear (); + } + + private: + bool failed_; + diagnostics diagnostics_; + }; + } + } +} + +#include + +#endif // LIBXSD_CXX_PARSER_ERROR_HANDLER_HXX diff --git a/libxsd/libxsd/cxx/parser/error-handler.txx b/libxsd/libxsd/cxx/parser/error-handler.txx new file mode 100644 index 0000000..65550e2 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/error-handler.txx @@ -0,0 +1,39 @@ +// file : libxsd/cxx/parser/error-handler.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsd +{ + namespace cxx + { + namespace parser + { + template + bool error_handler:: + handle (const std::basic_string& id, + unsigned long line, + unsigned long column, + severity s, + const std::basic_string& message) + { + diagnostics_.push_back ( + error (s == severity::warning + ? cxx::parser::severity::warning + : cxx::parser::severity::error, + id, line, column, message)); + + if (!failed_ && s != severity::warning) + failed_ = true; + + return true; + } + + template + void error_handler:: + throw_if_failed () const + { + if (failed_) + throw parsing (diagnostics_); + } + } + } +} diff --git a/libxsd/libxsd/cxx/parser/exceptions.hxx b/libxsd/libxsd/cxx/parser/exceptions.hxx new file mode 100644 index 0000000..05fa6b0 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/exceptions.hxx @@ -0,0 +1,151 @@ +// file : libxsd/cxx/parser/exceptions.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_PARSER_EXCEPTIONS_HXX +#define LIBXSD_CXX_PARSER_EXCEPTIONS_HXX + +#include +#include +#include + +#include // xsd::cxx::exception +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + // + // + template + struct exception: xsd::cxx::exception + { + friend + std::basic_ostream& + operator<< (std::basic_ostream& os, const exception& e) + { + e.print (os); + return os; + } + + protected: + virtual void + print (std::basic_ostream&) const = 0; + }; + + + // + // + struct severity + { + enum value + { + warning, + error + }; + + severity (value v) : v_ (v) {} + operator value () const { return v_; } + + private: + value v_; + }; + + template + struct error + { + error (cxx::parser::severity, + const std::basic_string& id, + unsigned long line, + unsigned long column, + const std::basic_string& message); + + cxx::parser::severity + severity () const + { + return severity_; + } + + const std::basic_string& + id () const + { + return id_; + } + + unsigned long + line () const + { + return line_; + } + + unsigned long + column () const + { + return column_; + } + + const std::basic_string& + message () const + { + return message_; + } + + private: + cxx::parser::severity severity_; + std::basic_string id_; + unsigned long line_; + unsigned long column_; + std::basic_string message_; + }; + + // See exceptions.ixx for operator<< (error). + + + // + // + template + struct diagnostics: std::vector > + { + }; + + // See exceptions.ixx for operator<< (diagnostics). + + // + // + template + struct parsing: exception + { + virtual + ~parsing () throw (); + + parsing (); + + parsing (const cxx::parser::diagnostics&); + + const cxx::parser::diagnostics& + diagnostics () const + { + return diagnostics_; + } + + virtual const char* + what () const throw (); + + protected: + virtual void + print (std::basic_ostream&) const; + + private: + cxx::parser::diagnostics diagnostics_; + }; + } + } +} + +#include + +#endif // LIBXSD_CXX_PARSER_EXCEPTIONS_HXX + +#include diff --git a/libxsd/libxsd/cxx/parser/exceptions.ixx b/libxsd/libxsd/cxx/parser/exceptions.ixx new file mode 100644 index 0000000..35decbc --- /dev/null +++ b/libxsd/libxsd/cxx/parser/exceptions.ixx @@ -0,0 +1,127 @@ +// file : libxsd/cxx/parser/exceptions.ixx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#if defined(XSD_CXX_PARSER_USE_CHAR) || !defined(XSD_CXX_PARSER_USE_WCHAR) + +#ifndef XSD_CXX_PARSER_EXCEPTIONS_IXX_CHAR +#define XSD_CXX_PARSER_EXCEPTIONS_IXX_CHAR + +namespace xsd +{ + namespace cxx + { + namespace parser + { + // error + // + inline + std::basic_ostream& + operator<< (std::basic_ostream& os, const error& e) + { + return os << e.id () << ':' << e.line () << ':' << e.column () + << (e.severity () == severity::error + ? " error: " + : " warning: ") << e.message (); + } + + + // diagnostics + // + inline + std::basic_ostream& + operator<< (std::basic_ostream& os, const diagnostics& d) + { + for (diagnostics::const_iterator b (d.begin ()), i (b); + i != d.end (); + ++i) + { + if (i != b) + os << "\n"; + + os << *i; + } + + return os; + } + + // parsing + // + template<> + inline + void parsing:: + print (std::basic_ostream& os) const + { + if (diagnostics_.empty ()) + os << "instance document parsing failed"; + else + os << diagnostics_; + } + } + } +} + +#endif // XSD_CXX_PARSER_EXCEPTIONS_IXX_CHAR +#endif // XSD_CXX_PARSER_USE_CHAR + + +#if defined(XSD_CXX_PARSER_USE_WCHAR) || !defined(XSD_CXX_PARSER_USE_CHAR) + +#ifndef XSD_CXX_PARSER_EXCEPTIONS_IXX_WCHAR +#define XSD_CXX_PARSER_EXCEPTIONS_IXX_WCHAR + +namespace xsd +{ + namespace cxx + { + namespace parser + { + // error + // + inline + std::basic_ostream& + operator<< (std::basic_ostream& os, const error& e) + { + return os << e.id () << L':' << e.line () << L':' << e.column () + << (e.severity () == severity::error + ? L" error: " + : L" warning: ") << e.message (); + } + + // diagnostics + // + inline + std::basic_ostream& + operator<< (std::basic_ostream& os, + const diagnostics& d) + { + for (diagnostics::const_iterator b (d.begin ()), i (b); + i != d.end (); + ++i) + { + if (i != b) + os << L"\n"; + + os << *i; + } + + return os; + } + + // parsing + // + template<> + inline + void parsing:: + print (std::basic_ostream& os) const + { + if (diagnostics_.empty ()) + os << L"instance document parsing failed"; + else + os << diagnostics_; + } + } + } +} + +#endif // XSD_CXX_PARSER_EXCEPTIONS_IXX_WCHAR +#endif // XSD_CXX_PARSER_USE_WCHAR diff --git a/libxsd/libxsd/cxx/parser/exceptions.txx b/libxsd/libxsd/cxx/parser/exceptions.txx new file mode 100644 index 0000000..b23188a --- /dev/null +++ b/libxsd/libxsd/cxx/parser/exceptions.txx @@ -0,0 +1,57 @@ +// file : libxsd/cxx/parser/exceptions.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsd +{ + namespace cxx + { + namespace parser + { + // error + // + template + error:: + error (cxx::parser::severity s, + const std::basic_string& id, + unsigned long line, + unsigned long column, + const std::basic_string& message) + : severity_ (s), + id_ (id), + line_ (line), + column_ (column), + message_ (message) + { + } + + + // parsing + // + template + parsing:: + ~parsing () throw () + { + } + + template + parsing:: + parsing () + { + } + + template + parsing:: + parsing (const cxx::parser::diagnostics& diagnostics) + : diagnostics_ (diagnostics) + { + } + + template + const char* parsing:: + what () const throw () + { + return "instance document parsing failed"; + } + } + } +} diff --git a/libxsd/libxsd/cxx/parser/expat/elements.hxx b/libxsd/libxsd/cxx/parser/expat/elements.hxx new file mode 100644 index 0000000..65868aa --- /dev/null +++ b/libxsd/libxsd/cxx/parser/expat/elements.hxx @@ -0,0 +1,363 @@ +// file : libxsd/cxx/parser/expat/elements.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_PARSER_EXPAT_ELEMENTS_HXX +#define LIBXSD_CXX_PARSER_EXPAT_ELEMENTS_HXX + +#include // XSD_CXX11 + +#include +#include +#include // std::size_t +#include + +#ifdef XSD_CXX11 +# include // std::unique_ptr +#endif + +#include + +// We only support UTF-8 expat for now. +// +#ifdef XML_UNICODE +#error UTF-16 expat (XML_UNICODE defined) is not supported +#endif + +#include + +#include +#include +#include +#include +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace expat + { +#ifdef XSD_CXX11 + struct parser_deleter + { + void + operator() (XML_Parser p) const + { + if (p != 0) + XML_ParserFree (p); + } + }; + + typedef + std::unique_ptr + parser_auto_ptr; +#else + // Simple auto pointer for Expat's XML_Parser object. + // + struct parser_auto_ptr + { + ~parser_auto_ptr () + { + if (parser_ != 0) + XML_ParserFree (parser_); + } + + explicit + parser_auto_ptr (XML_Parser parser = 0) + : parser_ (parser) + { + } + + parser_auto_ptr& + operator= (XML_Parser parser) + { + if (parser_ != 0) + XML_ParserFree (parser_); + + parser_ = parser; + return *this; + } + + XML_Parser + get () const + { + return parser_; + } + + private: + parser_auto_ptr (const parser_auto_ptr&); + + parser_auto_ptr& + operator= (const parser_auto_ptr&); + + private: + XML_Parser parser_; + }; +#endif // XSD_CXX11 + + // + // + template + struct document: cxx::parser::document // VC likes it qualified + { + public: + document (parser_base&, + const C* root_element_name, + bool polymorphic = false); + + document (parser_base&, + const std::basic_string& root_element_name, + bool polymorphic = false); + + document (parser_base&, + const C* root_element_namespace, + const C* root_element_name, + bool polymorphic = false); + + document (parser_base&, + const std::basic_string& root_element_namespace, + const std::basic_string& root_element_name, + bool polymorphic = false); + + protected: + document (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::basic_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::basic_string& file, xml::error_handler&); + + public: + // System id is a "system" identifier of the resources (e.g., + // URI or a full file path). Public id is a "public" identifier + // of the resource (e.g., application-specific name or relative + // file path). System id is used to resolve relative paths. + // In diagnostics messages system id is used if public id is + // not available. Otherwise public id is used. + // + + // Parse std::istream. + // + void + parse (std::istream&); + + // Parse std::istream with a user-provided error_handler object. + // + void + parse (std::istream&, xml::error_handler&); + + // Parse std::istream with a system id. + // + void + parse (std::istream&, const std::basic_string& system_id); + + // Parse std::istream with a system id and a user-provided + // error_handler object. + // + void + parse (std::istream&, + const std::basic_string& system_id, + xml::error_handler&); + + // Parse std::istream with system and public ids. + // + void + parse (std::istream&, + const std::basic_string& system_id, + const std::basic_string& public_id); + + // Parse std::istream with system and public ids and a user-provided + // error_handler object. + // + void + parse (std::istream&, + const std::basic_string& system_id, + const std::basic_string& public_id, + xml::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, + xml::error_handler&); + + void + parse (const void* data, std::size_t size, bool last, + const std::basic_string& system_id); + + void + parse (const void* data, std::size_t size, bool last, + const std::basic_string& system_id, + xml::error_handler&); + + void + parse (const void* data, std::size_t size, bool last, + const std::basic_string& system_id, + const std::basic_string& public_id); + + void + parse (const void* data, std::size_t size, bool last, + const std::basic_string& system_id, + const std::basic_string& public_id, + xml::error_handler&); + + public: + // Low-level Expat-specific parsing API. A typical use case + // would look like this (pseudo-code): + // + // xxx_pimpl root; + // document doc (root, "root"); + // + // root.pre (); + // doc.parse_begin (xml_parser, "file.xml"); + // + // while (more_stuff_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.post_xxx ()); + // + // Notes: + // + // 1. If your XML instances use 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). + // + void + parse_begin (XML_Parser); + + void + parse_begin (XML_Parser, const std::basic_string& public_id); + + void + parse_begin (XML_Parser, xml::error_handler&); + + void + parse_begin (XML_Parser, + const std::basic_string& public_id, + xml::error_handler&); + void + parse_end (); + + // Event routing. + // + public: + static void XMLCALL + start_element_thunk_ (void*, const XML_Char*, const XML_Char**); + + static void XMLCALL + end_element_thunk_ (void*, const XML_Char*); + + static void XMLCALL + characters_thunk_ (void*, const XML_Char*, int); + + static void XMLCALL + start_namespace_decl_thunk_ ( + void*, const XML_Char*, const XML_Char*); + + static void XMLCALL + end_namespace_decl_thunk_ (void*, const XML_Char*); + + protected: + void + start_element_ (const XML_Char* ns_name, const XML_Char** atts); + + void + end_element_ (const XML_Char* ns_name); + + void + characters_ (const XML_Char* s, std::size_t n); + + void + start_namespace_decl_ (const XML_Char* prefix, const XML_Char* ns); + + void + end_namespace_decl_ (const XML_Char* prefix); + + protected: + void + set (); + + void + clear (); + + bool + parse (std::istream&, + const std::basic_string* system_id, + const std::basic_string* public_id, + xml::error_handler&); + + bool + parse (const void* data, std::size_t size, bool last, + const std::basic_string* system_id, + const std::basic_string* public_id, + xml::error_handler&); + + + void + translate_schema_exception (const schema_exception& e); + + protected: + XML_Parser xml_parser_; + parser_auto_ptr auto_xml_parser_; + + xml::error_handler* eh_; + error_handler default_eh_; + std::basic_string public_id_; + + bool polymorphic_; + + // Namespace-prefix mapping. Only maintained in the polymorphic + // case. + // + struct ns_decl + { + ns_decl (const std::basic_string& p, + const std::basic_string& n) + : prefix (p), ns (n) + { + } + + std::basic_string prefix; + std::basic_string ns; + }; + + typedef std::vector ns_decls; + + ns_decls ns_decls_; + }; + } + } + } +} + +#include + +#endif // LIBXSD_CXX_PARSER_EXPAT_ELEMENTS_HXX diff --git a/libxsd/libxsd/cxx/parser/expat/elements.txx b/libxsd/libxsd/cxx/parser/expat/elements.txx new file mode 100644 index 0000000..8a068c4 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/expat/elements.txx @@ -0,0 +1,823 @@ +// file : libxsd/cxx/parser/expat/elements.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include // std::bad_alloc +#include +#include +#include // std::strchr +#include + +#include // xml::bits::{xml_prefix, etc} + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace expat + { + + // document + // + + template + document:: + document (parser_base& p, + const std::basic_string& name, + bool polymorphic) + : cxx::parser::document (p, std::basic_string (), name), + xml_parser_ (0), + eh_ (0), + polymorphic_ (polymorphic) + { + } + + template + document:: + document (parser_base& p, + const C* name, + bool polymorphic) + : cxx::parser::document (p, std::basic_string (), name), + xml_parser_ (0), + eh_ (0), + polymorphic_ (polymorphic) + { + } + + template + document:: + document (parser_base& p, + const C* ns, + const C* name, + bool polymorphic) + : cxx::parser::document (p, ns, name), + xml_parser_ (0), + eh_ (0), + polymorphic_ (polymorphic) + { + } + + template + document:: + document (parser_base& p, + const std::basic_string& ns, + const std::basic_string& name, + bool polymorphic) + : cxx::parser::document (p, ns, name), + xml_parser_ (0), + eh_ (0), + polymorphic_ (polymorphic) + { + } + + template + document:: + document (bool polymorphic) + : xml_parser_ (0), + eh_ (0), + polymorphic_ (polymorphic) + { + } + + // file + // + + template + void document:: + parse (const std::basic_string& file) + { + std::ifstream ifs; + ifs.exceptions (std::ios_base::badbit | std::ios_base::failbit); + ifs.open (file.c_str (), std::ios_base::in | std::ios_base::binary); + + parse (ifs, file); + } + + template + void document:: + parse (const std::basic_string& file, xml::error_handler& eh) + { + std::ifstream ifs; + ifs.exceptions (std::ios_base::badbit | std::ios_base::failbit); + ifs.open (file.c_str (), std::ios_base::in | std::ios_base::binary); + + parse (ifs, file, eh); + } + + + // istream + // + + template + void document:: + parse (std::istream& is) + { + parse (is, 0, 0, default_eh_); + } + + template + void document:: + parse (std::istream& is, xml::error_handler& eh) + { + if (!parse (is, 0, 0, eh)) + throw parsing (); + } + + template + void document:: + parse (std::istream& is, const std::basic_string& system_id) + { + default_eh_.reset (); + parse (is, &system_id, 0, default_eh_); + } + + template + void document:: + parse (std::istream& is, + const std::basic_string& system_id, + xml::error_handler& eh) + { + if (!parse (is, &system_id, 0, eh)) + throw parsing (); + } + + template + void document:: + parse (std::istream& is, + const std::basic_string& system_id, + const std::basic_string& public_id) + { + default_eh_.reset (); + parse (is, &system_id, &public_id, default_eh_); + } + + template + void document:: + parse (std::istream& is, + const std::basic_string& system_id, + const std::basic_string& public_id, + xml::error_handler& eh) + { + if (!parse (is, &system_id, &public_id, eh)) + throw parsing (); + } + + // data + // + + template + void document:: + parse (const void* data, std::size_t size, bool last) + { + default_eh_.reset (); + parse (data, size, last, 0, 0, default_eh_); + } + + template + void document:: + parse (const void* data, std::size_t size, bool last, + xml::error_handler& eh) + { + if (!parse (data, size, last, 0, 0, eh)) + throw parsing (); + } + + template + void document:: + parse (const void* data, std::size_t size, bool last, + const std::basic_string& system_id) + { + default_eh_.reset (); + parse (data, size, last, &system_id, 0, default_eh_); + } + + template + void document:: + parse (const void* data, std::size_t size, bool last, + const std::basic_string& system_id, + xml::error_handler& eh) + { + if (!parse (data, size, last, &system_id, 0, eh)) + throw parsing (); + } + + template + void document:: + parse (const void* data, std::size_t size, bool last, + const std::basic_string& system_id, + const std::basic_string& public_id) + { + default_eh_.reset (); + parse (data, size, last, &system_id, &public_id, default_eh_); + } + + template + void document:: + parse (const void* data, std::size_t size, bool last, + const std::basic_string& system_id, + const std::basic_string& public_id, + xml::error_handler& eh) + { + if (!parse (data, size, last, &system_id, &public_id, eh)) + throw parsing (); + } + + // Implementation details. + // + + namespace bits + { + struct stream_exception_controller + { + ~stream_exception_controller () + { + std::ios_base::iostate s = is_.rdstate (); + s &= ~std::ios_base::failbit; + + // If our error state (sans failbit) intersects with the + // exception state then that means we have an active + // exception and changing error/exception state will + // cause another to be thrown. + // + if (!(old_state_ & s)) + { + // Clear failbit if it was caused by eof. + // + if (is_.fail () && is_.eof ()) + is_.clear (s); + + is_.exceptions (old_state_); + } + } + + stream_exception_controller (std::istream& is) + : is_ (is), old_state_ (is_.exceptions ()) + { + is_.exceptions (old_state_ & ~std::ios_base::failbit); + } + + private: + stream_exception_controller (const stream_exception_controller&); + + stream_exception_controller& + operator= (const stream_exception_controller&); + + private: + std::istream& is_; + std::ios_base::iostate old_state_; + }; + }; + + template + bool document:: + parse (std::istream& is, + const std::basic_string* system_id, + const std::basic_string* public_id, + xml::error_handler& eh) + { + parser_auto_ptr parser (XML_ParserCreateNS (0, XML_Char (' '))); + + if (parser.get () == 0) + throw std::bad_alloc (); + + if (system_id || public_id) + parse_begin ( + parser.get (), system_id ? *system_id : *public_id, eh); + else + parse_begin (parser.get (), eh); + + // Temporarily unset the exception failbit. Also clear the + // fail bit when we reset the old state if it was caused + // by eof. + // + bits::stream_exception_controller sec (is); + + char buf[16384]; // 4 x page size. + + bool r (true); + + do + { + is.read (buf, sizeof (buf)); + + if (is.bad () || (is.fail () && !is.eof ())) + { + // If the stream is not using exceptions then the user + // will have to test for stream failures before calling + // post. + // + break; + } + + if (XML_Parse (parser.get (), + buf, + is.gcount (), + is.eof ()) == XML_STATUS_ERROR) + { + r = false; + break; + } + } while (!is.eof ()); + + parse_end (); + return r; + } + + template + bool document:: + parse (const void* data, + std::size_t size, + bool last, + const std::basic_string* system_id, + const std::basic_string* public_id, + xml::error_handler& eh) + { + // First call. + // + if (auto_xml_parser_.get () == 0) + { + auto_xml_parser_ = XML_ParserCreateNS (0, XML_Char (' ')); + + if (auto_xml_parser_.get () == 0) + throw std::bad_alloc (); + + if (system_id || public_id) + parse_begin (auto_xml_parser_.get (), + system_id ? *system_id : *public_id, eh); + else + parse_begin (auto_xml_parser_.get (), eh); + } + + bool r (XML_Parse (xml_parser_, + static_cast (data), + static_cast (size), + last) != XML_STATUS_ERROR); + parse_end (); + return r; + } + + // XML_Parser + // + + template + void document:: + parse_begin (XML_Parser parser) + { + xml_parser_ = parser; + eh_ = &default_eh_; + public_id_.clear (); + set (); + } + + template + void document:: + parse_begin (XML_Parser parser, + const std::basic_string& public_id) + { + xml_parser_ = parser; + eh_ = &default_eh_; + public_id_ = public_id; + set (); + } + + template + void document:: + parse_begin (XML_Parser parser, xml::error_handler& eh) + { + xml_parser_ = parser; + eh_ = &eh; + public_id_.clear (); + set (); + } + + template + void document:: + parse_begin (XML_Parser parser, + const std::basic_string& public_id, + xml::error_handler& eh) + { + xml_parser_ = parser; + eh_ = &eh; + public_id_ = public_id; + set (); + } + + template + void document:: + parse_end () + { + XML_Error e (XML_GetErrorCode (xml_parser_)); + + if (e == XML_ERROR_NONE || e == XML_ERROR_ABORTED) + { + clear (); + xml_parser_ = 0; + auto_xml_parser_ = 0; + } + else + { + unsigned long l = XML_GetCurrentLineNumber (xml_parser_); + unsigned long c = XML_GetCurrentColumnNumber (xml_parser_); + std::basic_string message (XML_ErrorString (e)); + + eh_->handle (public_id_, + l, c, + xml::error_handler::severity::fatal, + message); + + clear (); + xml_parser_ = 0; + auto_xml_parser_ = 0; + + // We don't want to throw an empty parsing exception here + // since the user probably already knows about the error. + } + + if (eh_ == &default_eh_) + default_eh_.throw_if_failed (); + } + + // + // + template + void document:: + set () + { + assert (xml_parser_ != 0); + + XML_SetUserData(xml_parser_, this); + + XML_SetStartElementHandler (xml_parser_, start_element_thunk_); + XML_SetEndElementHandler (xml_parser_, end_element_thunk_); + XML_SetCharacterDataHandler (xml_parser_, characters_thunk_); + + if (polymorphic_) + { + XML_SetNamespaceDeclHandler (xml_parser_, + start_namespace_decl_thunk_, + end_namespace_decl_thunk_); + } + } + + template + void document:: + clear () + { + assert (xml_parser_ != 0); + + XML_SetUserData (xml_parser_, 0); + XML_SetStartElementHandler (xml_parser_, 0); + XML_SetEndElementHandler (xml_parser_, 0); + XML_SetCharacterDataHandler (xml_parser_, 0); + + if (polymorphic_) + XML_SetNamespaceDeclHandler (xml_parser_, 0, 0); + } + + template + void document:: + translate_schema_exception (const schema_exception& e) + { + unsigned long l = XML_GetCurrentLineNumber (xml_parser_); + unsigned long c = XML_GetCurrentColumnNumber (xml_parser_); + + eh_->handle (public_id_, + l, c, + xml::error_handler::severity::fatal, + e.message ()); + + XML_StopParser (xml_parser_, false); + } + + // Event routing. + // + + // Expat thunks. + // + template + void XMLCALL document:: + start_element_thunk_ (void* data, + const XML_Char* ns_name, + const XML_Char** atts) + { + document& d (*reinterpret_cast (data)); + d.start_element_ (ns_name, atts); + } + + template + void XMLCALL document:: + end_element_thunk_ (void* data, const XML_Char* ns_name) + { + document& d (*reinterpret_cast (data)); + d.end_element_ (ns_name); + } + + template + void XMLCALL document:: + characters_thunk_ (void* data, const XML_Char* s, int n) + { + document& d (*reinterpret_cast (data)); + d.characters_ (s, static_cast (n)); + } + + template + void XMLCALL document:: + start_namespace_decl_thunk_ (void* data, + const XML_Char* prefix, + const XML_Char* ns) + { + document& d (*reinterpret_cast (data)); + d.start_namespace_decl_ (prefix, ns); + } + + template + void XMLCALL document:: + end_namespace_decl_thunk_ (void* data, const XML_Char* prefix) + { + document& d (*reinterpret_cast (data)); + d.end_namespace_decl_ (prefix); + } + + namespace bits + { + inline void + split_name (const XML_Char* s, + const char*& ns, std::size_t& ns_s, + const char*& name, std::size_t& name_s) + { + const char* p (std::strchr (s, ' ')); + + if (p) + { + ns = s; + ns_s = p - s; + name = p + 1; + } + else + { + ns = s; + ns_s = 0; + name = s; + } + + name_s = std::char_traits::length (name); + } + } + + template + void document:: + start_element_ (const XML_Char* ns_name, const XML_Char** atts) + { + // Current Expat (2.0.0) has a (mis)-feature of a possibility of + // calling callbacks even after the non-resumable XML_StopParser + // call. The following code accounts for this. + // + { + XML_ParsingStatus s; + XML_GetParsingStatus (xml_parser_, &s); + if (s.parsing == XML_FINISHED) + return; + } + + typedef std::basic_string string; + + const char* ns_p; + const char* name_p; + size_t ns_s, name_s; + + bits::split_name (ns_name, ns_p, ns_s, name_p, name_s); + + { + const ro_string ns (ns_p, ns_s), name (name_p, name_s); + + if (!polymorphic_) + { + try + { + this->start_element (ns, name, 0); + } + catch (const schema_exception& e) + { + translate_schema_exception (e); + return; + } + } + else + { + // Search for the xsi:type attribute. + // + const XML_Char** p = atts; // VC8 can't handle p (atts) + for (; *p != 0; p += 2) + { + bits::split_name (*p, ns_p, ns_s, name_p, name_s); + const ro_string ns (ns_p, ns_s), name (name_p, name_s); + + if (name == xml::bits::type () && + ns == xml::bits::xsi_namespace ()) + break; + } + + if (*p == 0) + { + try + { + this->start_element (ns, name, 0); + } + catch (const schema_exception& e) + { + translate_schema_exception (e); + return; + } + } + else + { + // @@ Need proper QName validation. + // + // Get the qualified type name and try to resolve it. + // + ro_string qn (*(p + 1)); + + ro_string tp, tn; + typename ro_string::size_type pos (qn.find (C (':'))); + + try + { + if (pos != ro_string::npos) + { + tp.assign (qn.data (), pos); + tn.assign (qn.data () + pos + 1); + + if (tp.empty ()) + throw dynamic_type (qn); + } + else + tn.assign (qn.data (), qn.size ()); + + if (tn.empty ()) + throw dynamic_type (qn); + + // Search our namespace declaration stack. Note that + // we need to do this even if prefix is empty. Sun CC + // 5.7 blows if we use const_reverse_iterator. + // + ro_string tns; + for (typename ns_decls::reverse_iterator + it (ns_decls_.rbegin ()), e (ns_decls_.rend ()); + it != e; ++it) + { + if (it->prefix == tp) + { + tns.assign (it->ns); + break; + } + } + + if (!tp.empty () && tns.empty ()) + { + // The 'xml' prefix requires special handling. + // + if (tp == xml::bits::xml_prefix ()) + tns.assign (xml::bits::xml_namespace ()); + else + throw dynamic_type (qn); + } + + // Construct the compound type id. + // + string id (tn.data (), tn.size ()); + + if (!tns.empty ()) + { + id += C (' '); + id.append (tns.data (), tns.size ()); + } + + ro_string ro_id (id); + this->start_element (ns, name, &ro_id); + } + catch (const schema_exception& e) + { + translate_schema_exception (e); + return; + } + } + } + } + + for (; *atts != 0; atts += 2) + { + bits::split_name (*atts, ns_p, ns_s, name_p, name_s); + + const ro_string ns (ns_p, ns_s), name (name_p, name_s); + const ro_string value (*(atts + 1)); + + try + { + this->attribute (ns, name, value); + } + catch (const schema_exception& e) + { + translate_schema_exception (e); + break; + } + } + } + + template + void document:: + end_element_ (const XML_Char* ns_name) + { + // Current Expat (2.0.0) has a (mis)-feature of a possibility of + // calling callbacks even after the non-resumable XML_StopParser + // call. The following code accounts for this. + // + { + XML_ParsingStatus s; + XML_GetParsingStatus (xml_parser_, &s); + if (s.parsing == XML_FINISHED) + return; + } + + const char* ns_p; + const char* name_p; + size_t ns_s, name_s; + + bits::split_name (ns_name, ns_p, ns_s, name_p, name_s); + + const ro_string ns (ns_p, ns_s), name (name_p, name_s); + + try + { + this->end_element (ns, name); + } + catch (const schema_exception& e) + { + translate_schema_exception (e); + } + } + + template + void document:: + characters_ (const XML_Char* s, std::size_t n) + { + // Current Expat (2.0.0) has a (mis)-feature of a possibility of + // calling callbacks even after the non-resumable XML_StopParser + // call. The following code accounts for this. + // + { + XML_ParsingStatus s; + XML_GetParsingStatus (xml_parser_, &s); + if (s.parsing == XML_FINISHED) + return; + } + + if (n != 0) + { + const ro_string str (s, n); + + try + { + this->characters (str); + } + catch (const schema_exception& e) + { + translate_schema_exception (e); + } + } + } + + template + void document:: + start_namespace_decl_ (const XML_Char* p, const XML_Char* ns) + { + // prefix is 0 for default namespace + // namespace is 0 when unsetting default namespace + // + if (polymorphic_) + ns_decls_.push_back (ns_decl ((p ? p : ""), (ns ? ns : ""))); + } + + template + void document:: + end_namespace_decl_ (const XML_Char* p) + { + // prefix is 0 for default namespace + // + if (polymorphic_) + { + // Here we assume the prefixes are removed in the reverse + // order of them being added. This appears to how every + // sensible implementation works. + // + assert (p + ? ns_decls_.back ().prefix == p + : ns_decls_.back ().prefix.empty ()); + + ns_decls_.pop_back (); + } + } + } + } + } +} diff --git a/libxsd/libxsd/cxx/parser/map.hxx b/libxsd/libxsd/cxx/parser/map.hxx new file mode 100644 index 0000000..055abe8 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/map.hxx @@ -0,0 +1,77 @@ +// file : libxsd/cxx/parser/map.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_PARSER_MAP_HXX +#define LIBXSD_CXX_PARSER_MAP_HXX + +#include +#include + +#include +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + // Parser map. Used in the polymorphic document parsing. + // + template + struct parser_map + { + virtual + ~parser_map (); + + // The type argument is the type name and namespace from the + // xsi:type attribute or substitution group map in the form + // " " with the space and namespace part + // absent if the type does not have a namespace. + // + virtual parser_base* + find (const ro_string& type) const = 0; + }; + + + // Parser map implementation. + // + template + struct parser_map_impl: parser_map + { + parser_map_impl (); + + 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&); + + private: + struct string_comparison + { + bool + operator() (const C* x, const C* y) const + { + ro_string s (x); + return s.compare (y) < 0; + } + }; + + typedef std::map*, string_comparison> map; + map map_; + }; + } + } +} + +#include +#include + +#endif // LIBXSD_CXX_PARSER_MAP_HXX diff --git a/libxsd/libxsd/cxx/parser/map.ixx b/libxsd/libxsd/cxx/parser/map.ixx new file mode 100644 index 0000000..fd52e85 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/map.ixx @@ -0,0 +1,25 @@ +// file : libxsd/cxx/parser/map.ixx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsd +{ + namespace cxx + { + namespace parser + { + // parser_map_impl + // + template + inline parser_map_impl::parser_map_impl () + { + } + + template + inline void parser_map_impl:: + insert (parser_base& parser) + { + map_[parser._dynamic_type ()] = &parser; + } + } + } +} diff --git a/libxsd/libxsd/cxx/parser/map.txx b/libxsd/libxsd/cxx/parser/map.txx new file mode 100644 index 0000000..a611c90 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/map.txx @@ -0,0 +1,29 @@ +// file : libxsd/cxx/parser/map.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsd +{ + namespace cxx + { + namespace parser + { + // parser_map + // + template + parser_map:: + ~parser_map () + { + } + + // parser_map_impl + // + template + parser_base* parser_map_impl:: + find (const ro_string& type) const + { + typename map::const_iterator i (map_.find (type.data ())); + return i != map_.end () ? i->second : 0; + } + } + } +} diff --git a/libxsd/libxsd/cxx/parser/non-validating/parser.hxx b/libxsd/libxsd/cxx/parser/non-validating/parser.hxx new file mode 100644 index 0000000..e0319c3 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/non-validating/parser.hxx @@ -0,0 +1,246 @@ +// file : libxsd/cxx/parser/non-validating/parser.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_PARSER_NON_VALIDATING_PARSER_HXX +#define LIBXSD_CXX_PARSER_NON_VALIDATING_PARSER_HXX + +#include +#include +#include // std::size_t + +#include +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // + // + template + struct empty_content: parser_base + { + // The _*_any_* functions are called when wildcard content + // is encountered. Use them to handle mixed content models, + // any/anyAttribute, and anyType/anySimpleType. By default + // these functions do nothing. + // + + // The type argument is a type name and namespace from the + // xsi:type attribute in the form " " with + // the space and namespace part absent if the type does not + // have a namespace or 0 if xsi:type is not present. + // + virtual void + _start_any_element (const ro_string& ns, + const ro_string& name, + const ro_string* type); + + virtual void + _end_any_element (const ro_string& ns, + const ro_string& name); + + virtual void + _any_attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value); + + virtual void + _any_characters (const ro_string&); + + + // + // + 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&); + + virtual bool + _attribute_impl (const ro_string&, + const ro_string&, + const ro_string&); + + virtual bool + _characters_impl (const ro_string&); + + + // + // + virtual void + _start_element (const ro_string& ns, + const ro_string& name, + const ro_string* type); + + virtual void + _end_element (const ro_string& ns, + const ro_string& name); + + virtual void + _attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value); + + virtual void + _characters (const ro_string& s); + }; + + + // + // + template + struct simple_content: empty_content + { + // + // + virtual void + _attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value); + + virtual void + _characters (const ro_string&); + }; + + + // + // + template + struct complex_content: empty_content + { + // + // + virtual void + _start_element (const ro_string& ns, + const ro_string& name, + const ro_string* type); + + virtual void + _end_element (const ro_string& ns, + const ro_string& name); + + virtual void + _attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value); + + virtual void + _characters (const ro_string&); + + + // + // + virtual void + _pre_impl (); + + virtual void + _post_impl (); + + protected: + struct state + { + state () + : any_ (false), depth_ (0), parser_ (0) + { + } + + bool any_; + std::size_t depth_; + parser_base* parser_; + }; + + // Optimized state stack for non-recursive case (one element). + // + struct state_stack + { + state_stack () + : size_ (0) + { + } + + void + push (const state& s) + { + if (size_ > 0) + rest_.push (top_); + + top_ = s; + ++size_; + } + + void + pop () + { + if (size_ > 1) + { + top_ = rest_.top (); + rest_.pop (); + } + + --size_; + } + + const state& + top () const + { + return top_; + } + + state& + top () + { + return top_; + } + + state& + under_top () + { + return rest_.top (); + } + + private: + state top_; + std::stack rest_; + std::size_t size_; + }; + + state_stack context_; + }; + + + // Base for xsd:list. + // + template + struct list_base: simple_content + { + virtual void + _xsd_parse_item (const ro_string&) = 0; + + virtual void + _pre_impl (); + + virtual void + _characters (const ro_string&); + + virtual void + _post_impl (); + + protected: + std::basic_string buf_; + }; + } + } + } +} + +#include + +#endif // LIBXSD_CXX_PARSER_NON_VALIDATING_PARSER_HXX diff --git a/libxsd/libxsd/cxx/parser/non-validating/parser.txx b/libxsd/libxsd/cxx/parser/non-validating/parser.txx new file mode 100644 index 0000000..4d78595 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/non-validating/parser.txx @@ -0,0 +1,462 @@ +// file : libxsd/cxx/parser/non-validating/parser.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + + // empty_content + // + + template + void empty_content:: + _start_any_element (const ro_string&, + const ro_string&, + const ro_string*) + { + } + + template + void empty_content:: + _end_any_element (const ro_string&, + const ro_string&) + { + } + + template + void empty_content:: + _any_attribute (const ro_string&, + const ro_string&, + const ro_string&) + { + } + + template + void empty_content:: + _any_characters (const ro_string&) + { + } + + // + // + template + bool empty_content:: + _start_element_impl (const ro_string&, + const ro_string&, + const ro_string*) + { + return false; + } + + template + bool empty_content:: + _end_element_impl (const ro_string&, + const ro_string&) + { + return false; + } + + template + bool empty_content:: + _attribute_impl (const ro_string&, + const ro_string&, + const ro_string&) + { + return false; + } + + template + bool empty_content:: + _characters_impl (const ro_string&) + { + return false; + } + + template + void empty_content:: + _start_element (const ro_string& ns, + const ro_string& name, + const ro_string* type) + { + if (!_start_element_impl (ns, name, type)) + _start_any_element (ns, name, type); + } + + template + void empty_content:: + _end_element (const ro_string& ns, + const ro_string& name) + { + if (!_end_element_impl (ns, name)) + _end_any_element (ns, name); + } + + template + void empty_content:: + _attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value) + { + // Weed out special attributes: xsi:type, xsi:nil, + // xsi:schemaLocation and noNamespaceSchemaLocation. + // See section 3.2.7 in Structures for details. + // + if (ns == xml::bits::xsi_namespace () && + (name == xml::bits::type () || + name == xml::bits::nil_lit () || + name == xml::bits::schema_location () || + name == xml::bits::no_namespace_schema_location ())) + return; + + // Also some parsers (notably Xerces-C++) supplies us with + // namespace-prefix mapping attributes. + // + if (ns == xml::bits::xmlns_namespace ()) + return; + + if (!_attribute_impl (ns, name, value)) + _any_attribute (ns, name, value); + } + + template + void empty_content:: + _characters (const ro_string& s) + { + if (!_characters_impl (s)) + _any_characters (s); + } + + + // simple_content + // + + template + void simple_content:: + _attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value) + { + // Weed out special attributes: xsi:type, xsi:nil, + // xsi:schemaLocation and xsi:noNamespaceSchemaLocation. + // See section 3.2.7 in Structures for details. + // + if (ns == xml::bits::xsi_namespace () && + (name == xml::bits::type () || + name == xml::bits::nil_lit () || + name == xml::bits::schema_location () || + name == xml::bits::no_namespace_schema_location ())) + return; + + // Also some parsers (notably Xerces-C++) supplies us with + // namespace-prefix mapping attributes. + // + if (ns == xml::bits::xmlns_namespace ()) + return; + + if (!this->_attribute_impl (ns, name, value)) + this->_any_attribute (ns, name, value); + } + + template + void simple_content:: + _characters (const ro_string& str) + { + this->_characters_impl (str); + } + + + // complex_content + // + + template + void complex_content:: + _start_element (const ro_string& ns, + const ro_string& name, + const ro_string* type) + { + state& s (context_.top ()); + + if (s.depth_++ > 0) + { + if (s.any_) + this->_start_any_element (ns, name, type); + else if (s.parser_) + s.parser_->_start_element (ns, name, type); + } + else + { + if (!this->_start_element_impl (ns, name, type)) + { + this->_start_any_element (ns, name, type); + s.any_ = true; + } + else if (s.parser_ != 0) + s.parser_->_pre_impl (); + } + } + + template + void complex_content:: + _end_element (const ro_string& ns, + const ro_string& name) + { + // To understand what's going on here it is helpful to think of + // a "total depth" as being the sum of individual depths over + // all elements. + // + + if (context_.top ().depth_ == 0) + { + state& s (context_.under_top ()); // One before last. + + if (--s.depth_ > 0) + { + // Indirect recursion. + // + if (s.parser_) + s.parser_->_end_element (ns, name); + } + else + { + // Direct recursion. + // + assert (this == s.parser_); + + this->_post_impl (); + + if (!this->_end_element_impl (ns, name)) + assert (false); + } + } + else + { + state& s (context_.top ()); + + if (--s.depth_ > 0) + { + if (s.any_) + this->_end_any_element (ns, name); + else if (s.parser_) + s.parser_->_end_element (ns, name); + } + else + { + if (s.parser_ != 0 && !s.any_) + s.parser_->_post_impl (); + + if (!this->_end_element_impl (ns, name)) + { + s.any_ = false; + this->_end_any_element (ns, name); + } + } + } + } + + template + void complex_content:: + _attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value) + { + // Weed out special attributes: xsi:type, xsi:nil, + // xsi:schemaLocation and xsi:noNamespaceSchemaLocation. + // See section 3.2.7 in Structures for details. + // + if (ns == xml::bits::xsi_namespace () && + (name == xml::bits::type () || + name == xml::bits::nil_lit () || + name == xml::bits::schema_location () || + name == xml::bits::no_namespace_schema_location ())) + return; + + // Also some parsers (notably Xerces-C++) supplies us with + // namespace-prefix mapping attributes. + // + if (ns == xml::bits::xmlns_namespace ()) + return; + + state& s (context_.top ()); + + if (s.depth_ > 0) + { + if (s.any_) + this->_any_attribute (ns, name, value); + else if (s.parser_) + s.parser_->_attribute (ns, name, value); + } + else + { + if (!this->_attribute_impl (ns, name, value)) + this->_any_attribute (ns, name, value); + } + } + + template + void complex_content:: + _characters (const ro_string& str) + { + state& s (context_.top ()); + + if (s.depth_ > 0) + { + if (s.any_) + this->_any_characters (str); + else if (s.parser_) + s.parser_->_characters (str); + } + else + { + if (!this->_characters_impl (str)) + this->_any_characters (str); + } + } + + template + void complex_content:: + _pre_impl () + { + context_.push (state ()); + this->_pre (); + } + + template + void complex_content:: + _post_impl () + { + this->_post (); + context_.pop (); + } + + // list_base + // + namespace bits + { + // Find first non-space character. + // + template + typename ro_string::size_type + find_ns (const C* s, + typename ro_string::size_type size, + typename ro_string::size_type pos) + { + while (pos < size && + (s[pos] == C (0x20) || s[pos] == C (0x0A) || + s[pos] == C (0x0D) || s[pos] == C (0x09))) + ++pos; + + return pos < size ? pos : ro_string::npos; + } + + // Find first space character. + // + template + typename ro_string::size_type + find_s (const C* s, + typename ro_string::size_type size, + typename ro_string::size_type pos) + { + while (pos < size && + s[pos] != C (0x20) && s[pos] != C (0x0A) && + s[pos] != C (0x0D) && s[pos] != C (0x09)) + ++pos; + + return pos < size ? pos : ro_string::npos; + } + } + + // Relevant XML Schema Part 2: Datatypes sections: 4.2.1.2, 4.3.6. + // + + template + void list_base:: + _pre_impl () + { + simple_content::_pre_impl (); + buf_.clear (); + } + + template + void list_base:: + _characters (const ro_string& s) + { + typedef typename ro_string::size_type size_type; + + const C* data (s.data ()); + size_type size (s.size ()); + + // Handle the previous chunk if we start with a ws. + // + if (!buf_.empty () && + (data[0] == C (0x20) || data[0] == C (0x0A) || + data[0] == C (0x0D) || data[0] == C (0x09))) + { + ro_string tmp (buf_); // Private copy ctor. + _xsd_parse_item (tmp); + buf_.clear (); + } + + // Traverse the data while logically collapsing spaces. + // + for (size_type i (bits::find_ns (data, size, 0)); + i != ro_string::npos;) + { + size_type j (bits::find_s (data, size, i)); + + if (j != ro_string::npos) + { + if (buf_.empty ()) + { + ro_string tmp (data + i, j - i); // Private copy ctor. + _xsd_parse_item (tmp); + } + else + { + // Assemble the first item in str from buf_ and s. + // + std::basic_string str; + str.swap (buf_); + str.append (data + i, j - i); + ro_string tmp (str); // Private copy ctor. + _xsd_parse_item (tmp); + } + + i = bits::find_ns (data, size, j); + } + else + { + // Last fragment, append it to the buf_. + // + buf_.append (data + i, size - i); + break; + } + } + } + + template + void list_base:: + _post_impl () + { + // Handle the last item. + // + if (!buf_.empty ()) + { + ro_string tmp (buf_); // Private copy ctor. + _xsd_parse_item (tmp); + } + + simple_content::_post_impl (); + } + } + } + } +} diff --git a/libxsd/libxsd/cxx/parser/non-validating/xml-schema-pimpl.hxx b/libxsd/libxsd/cxx/parser/non-validating/xml-schema-pimpl.hxx new file mode 100644 index 0000000..69a4fe5 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/non-validating/xml-schema-pimpl.hxx @@ -0,0 +1,791 @@ +// file : libxsd/cxx/parser/non-validating/xml-schema-pimpl.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PIMPL_HXX +#define LIBXSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PIMPL_HXX + +#include + +#include // XSD_AUTO_PTR + +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // any_type + // + template + struct any_type_pimpl: virtual any_type_pskel + { + virtual void + post_any_type (); + }; + + // any_simple_type + // + template + struct any_simple_type_pimpl: virtual any_simple_type_pskel + { + virtual void + post_any_simple_type (); + }; + + // boolean + // + template + struct boolean_pimpl: virtual boolean_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual bool + post_boolean (); + + protected: + std::basic_string str_; + }; + + + // 8-bit + // + template + struct byte_pimpl: virtual byte_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual signed char + post_byte (); + + protected: + std::basic_string str_; + }; + + + template + struct unsigned_byte_pimpl: virtual unsigned_byte_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual unsigned char + post_unsigned_byte (); + + protected: + std::basic_string str_; + }; + + + // 16-bit + // + template + struct short_pimpl: virtual short_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual short + post_short (); + + protected: + std::basic_string str_; + }; + + + template + struct unsigned_short_pimpl: virtual unsigned_short_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual unsigned short + post_unsigned_short (); + + protected: + std::basic_string str_; + }; + + + // 32-bit + // + template + struct int_pimpl: virtual int_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual int + post_int (); + + protected: + std::basic_string str_; + }; + + + template + struct unsigned_int_pimpl: virtual unsigned_int_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual unsigned int + post_unsigned_int (); + + protected: + std::basic_string str_; + }; + + + // 64-bit + // + template + struct long_pimpl: virtual long_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual long long + post_long (); + + protected: + std::basic_string str_; + }; + + + template + struct unsigned_long_pimpl: virtual unsigned_long_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual unsigned long long + post_unsigned_long (); + + protected: + std::basic_string str_; + }; + + + // Arbitrary-length integers. + // + template + struct integer_pimpl: virtual integer_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual long long + post_integer (); + + protected: + std::basic_string str_; + }; + + template + struct negative_integer_pimpl: virtual negative_integer_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual long long + post_negative_integer (); + + protected: + std::basic_string str_; + }; + + template + struct non_positive_integer_pimpl: virtual non_positive_integer_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual long long + post_non_positive_integer (); + + protected: + std::basic_string str_; + }; + + template + struct positive_integer_pimpl: virtual positive_integer_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual unsigned long long + post_positive_integer (); + + protected: + std::basic_string str_; + }; + + template + struct non_negative_integer_pimpl: virtual non_negative_integer_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual unsigned long long + post_non_negative_integer (); + + protected: + std::basic_string str_; + }; + + + // Floats. + // + template + struct float_pimpl: virtual float_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual float + post_float (); + + protected: + std::basic_string str_; + }; + + + template + struct double_pimpl: virtual double_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual double + post_double (); + + protected: + std::basic_string str_; + }; + + + template + struct decimal_pimpl: virtual decimal_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual double + post_decimal (); + + protected: + std::basic_string str_; + }; + + + // Strings. + // + template + struct string_pimpl: virtual string_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::basic_string + post_string (); + + protected: + std::basic_string str_; + }; + + template + struct normalized_string_pimpl: virtual normalized_string_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::basic_string + post_normalized_string (); + + protected: + std::basic_string str_; + }; + + template + struct token_pimpl: virtual token_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::basic_string + post_token (); + + protected: + std::basic_string str_; + }; + + template + struct name_pimpl: virtual name_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::basic_string + post_name (); + + protected: + std::basic_string str_; + }; + + template + struct nmtoken_pimpl: virtual nmtoken_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::basic_string + post_nmtoken (); + + protected: + std::basic_string str_; + }; + + template + struct nmtokens_pimpl: virtual nmtokens_pskel + { + virtual void + _pre (); + + virtual void + _xsd_parse_item (const ro_string&); + + virtual string_sequence + post_nmtokens (); + + protected: + string_sequence seq_; + nmtoken_pimpl parser_; + }; + + template + struct ncname_pimpl: virtual ncname_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::basic_string + post_ncname (); + + protected: + std::basic_string str_; + }; + + template + struct id_pimpl: virtual id_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::basic_string + post_id (); + + protected: + std::basic_string str_; + }; + + template + struct idref_pimpl: virtual idref_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::basic_string + post_idref (); + + protected: + std::basic_string str_; + }; + + template + struct idrefs_pimpl: virtual idrefs_pskel + { + virtual void + _pre (); + + virtual void + _xsd_parse_item (const ro_string&); + + virtual string_sequence + post_idrefs (); + + protected: + string_sequence seq_; + idref_pimpl parser_; + }; + + // language + // + template + struct language_pimpl: virtual language_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::basic_string + post_language (); + + protected: + std::basic_string str_; + }; + + // anyURI + // + template + struct uri_pimpl: virtual uri_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::basic_string + post_uri (); + + protected: + std::basic_string str_; + }; + + // QName + // + template + struct qname_pimpl: virtual qname_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual qname + post_qname (); + + protected: + std::basic_string str_; + }; + + // base64Binary + // + template + struct base64_binary_pimpl: virtual base64_binary_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual XSD_AUTO_PTR + post_base64_binary (); + + protected: + std::basic_string str_; + }; + + // hexBinary + // + template + struct hex_binary_pimpl: virtual hex_binary_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual XSD_AUTO_PTR + post_hex_binary (); + + protected: + std::basic_string str_; + }; + + // gday + // + template + struct gday_pimpl: virtual gday_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual gday + post_gday (); + + protected: + std::basic_string str_; + }; + + // gmonth + // + template + struct gmonth_pimpl: virtual gmonth_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual gmonth + post_gmonth (); + + protected: + std::basic_string str_; + }; + + // gyear + // + template + struct gyear_pimpl: virtual gyear_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual gyear + post_gyear (); + + protected: + std::basic_string str_; + }; + + // gmonth_day + // + template + struct gmonth_day_pimpl: virtual gmonth_day_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual gmonth_day + post_gmonth_day (); + + protected: + std::basic_string str_; + }; + + // gyear_month + // + template + struct gyear_month_pimpl: virtual gyear_month_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual gyear_month + post_gyear_month (); + + protected: + std::basic_string str_; + }; + + // date + // + template + struct date_pimpl: virtual date_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual date + post_date (); + + protected: + std::basic_string str_; + }; + + // time + // + template + struct time_pimpl: virtual time_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual time + post_time (); + + protected: + std::basic_string str_; + }; + + // date_time + // + template + struct date_time_pimpl: virtual date_time_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual date_time + post_date_time (); + + protected: + std::basic_string str_; + }; + + // duration + // + template + struct duration_pimpl: virtual duration_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual duration + post_duration (); + + protected: + std::basic_string str_; + }; + + // + // + namespace bits + { + // float literals: INF -INF NaN + // + template + const C* + positive_inf (); + + template + const C* + negative_inf (); + + template + const C* + nan (); + + // boolean literals + // + template + const C* + true_ (); + + template + const C* + one (); + } + } + } + } +} + +#include + +#endif // LIBXSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PIMPL_HXX + +#include diff --git a/libxsd/libxsd/cxx/parser/non-validating/xml-schema-pimpl.ixx b/libxsd/libxsd/cxx/parser/non-validating/xml-schema-pimpl.ixx new file mode 100644 index 0000000..8ce3621 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/non-validating/xml-schema-pimpl.ixx @@ -0,0 +1,127 @@ +// file : libxsd/cxx/parser/non-validating/xml-schema-pimpl.ixx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#if defined(XSD_CXX_PARSER_USE_CHAR) || !defined(XSD_CXX_PARSER_USE_WCHAR) + +#ifndef XSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PIMPL_IXX_CHAR +#define XSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PIMPL_IXX_CHAR + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + namespace bits + { + // + // + template<> + inline const char* + positive_inf () + { + return "INF"; + } + + template<> + inline const char* + negative_inf () + { + return "-INF"; + } + + template<> + inline const char* + nan () + { + return "NaN"; + } + + // + // + template<> + inline const char* + true_ () + { + return "true"; + } + + template<> + inline const char* + one () + { + return "1"; + } + } + } + } + } +} + +#endif // XSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PIMPL_IXX_CHAR +#endif // XSD_CXX_PARSER_USE_CHAR + + +#if defined(XSD_CXX_PARSER_USE_WCHAR) || !defined(XSD_CXX_PARSER_USE_CHAR) + +#ifndef XSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PIMPL_IXX_WCHAR +#define XSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PIMPL_IXX_WCHAR + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + namespace bits + { + // + // + template<> + inline const wchar_t* + positive_inf () + { + return L"INF"; + } + + template<> + inline const wchar_t* + negative_inf () + { + return L"-INF"; + } + + template<> + inline const wchar_t* + nan () + { + return L"NaN"; + } + + // + // + template<> + inline const wchar_t* + true_ () + { + return L"true"; + } + + template<> + inline const wchar_t* + one () + { + return L"1"; + } + } + } + } + } +} + +#endif // XSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PIMPL_IXX_WCHAR +#endif // XSD_CXX_PARSER_USE_WCHAR diff --git a/libxsd/libxsd/cxx/parser/non-validating/xml-schema-pimpl.txx b/libxsd/libxsd/cxx/parser/non-validating/xml-schema-pimpl.txx new file mode 100644 index 0000000..a045f5c --- /dev/null +++ b/libxsd/libxsd/cxx/parser/non-validating/xml-schema-pimpl.txx @@ -0,0 +1,2066 @@ +// file : libxsd/cxx/parser/non-validating/xml-schema-pimpl.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include + +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // Note that most of the types implemented here cannot have + // whitespaces in the value. 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. + // + + // any_type + // + + template + void any_type_pimpl:: + post_any_type () + { + } + + // any_simple_type + // + + template + void any_simple_type_pimpl:: + post_any_simple_type () + { + } + + // boolean + // + template + void boolean_pimpl:: + _pre () + { + str_.clear (); + } + + template + void boolean_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + bool boolean_pimpl:: + post_boolean () + { + std::basic_string tmp; + tmp.swap (str_); + + ro_string str (tmp); + trim (str); + + return str == bits::true_ () || str == bits::one (); + } + + // byte + // + + template + void byte_pimpl:: + _pre () + { + str_.clear (); + } + + template + void byte_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + signed char byte_pimpl:: + post_byte () + { + std::basic_string tmp; + tmp.swap (str_); + + ro_string str (tmp); + trim (str); + + short t; + zc_istream is (str); + is >> t; + + return static_cast (t); + } + + // unsigned_byte + // + + template + void unsigned_byte_pimpl:: + _pre () + { + str_.clear (); + } + + template + void unsigned_byte_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + unsigned char unsigned_byte_pimpl:: + post_unsigned_byte () + { + std::basic_string tmp; + tmp.swap (str_); + + ro_string str (tmp); + trim (str); + + unsigned short t; + zc_istream is (str); + is >> t; + + return static_cast (t); + } + + // short + // + + template + void short_pimpl:: + _pre () + { + str_.clear (); + } + + template + void short_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + short short_pimpl:: + post_short () + { + std::basic_string tmp; + tmp.swap (str_); + + ro_string str (tmp); + trim (str); + + short t; + zc_istream is (str); + is >> t; + + return t; + } + + // unsigned_short + // + + template + void unsigned_short_pimpl:: + _pre () + { + str_.clear (); + } + + template + void unsigned_short_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + unsigned short unsigned_short_pimpl:: + post_unsigned_short () + { + std::basic_string tmp; + tmp.swap (str_); + + ro_string str (tmp); + trim (str); + + unsigned short t; + zc_istream is (str); + is >> t; + + return t; + } + + // int + // + + template + void int_pimpl:: + _pre () + { + str_.clear (); + } + + template + void int_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + int int_pimpl:: + post_int () + { + std::basic_string tmp; + tmp.swap (str_); + + ro_string str (tmp); + trim (str); + + int t; + zc_istream is (str); + is >> t; + + return t; + } + + // unsigned_int + // + + template + void unsigned_int_pimpl:: + _pre () + { + str_.clear (); + } + + template + void unsigned_int_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + unsigned int unsigned_int_pimpl:: + post_unsigned_int () + { + std::basic_string tmp; + tmp.swap (str_); + + ro_string str (tmp); + trim (str); + + unsigned int t; + zc_istream is (str); + is >> t; + + return t; + } + + // long + // + template + void long_pimpl:: + _pre () + { + str_.clear (); + } + + template + void long_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + long long long_pimpl:: + post_long () + { + std::basic_string tmp; + tmp.swap (str_); + + ro_string str (tmp); + trim (str); + + long long t; + zc_istream is (str); + is >> t; + + return t; + } + + // unsigned_long + // + template + void unsigned_long_pimpl:: + _pre () + { + str_.clear (); + } + + template + void unsigned_long_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + unsigned long long unsigned_long_pimpl:: + post_unsigned_long () + { + std::basic_string tmp; + tmp.swap (str_); + + ro_string str (tmp); + trim (str); + + unsigned long long t; + zc_istream is (str); + is >> t; + + return t; + } + + // integer + // + template + void integer_pimpl:: + _pre () + { + str_.clear (); + } + + template + void integer_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + long long integer_pimpl:: + post_integer () + { + std::basic_string tmp; + tmp.swap (str_); + + ro_string str (tmp); + trim (str); + + long long t; + zc_istream is (str); + is >> t; + + return t; + } + + // negative_integer + // + template + void negative_integer_pimpl:: + _pre () + { + str_.clear (); + } + + template + void negative_integer_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + long long negative_integer_pimpl:: + post_negative_integer () + { + std::basic_string tmp; + tmp.swap (str_); + + ro_string str (tmp); + trim (str); + + long long t; + zc_istream is (str); + is >> t; + + return t; + } + + // non_positive_integer + // + template + void non_positive_integer_pimpl:: + _pre () + { + str_.clear (); + } + + template + void non_positive_integer_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + long long non_positive_integer_pimpl:: + post_non_positive_integer () + { + std::basic_string tmp; + tmp.swap (str_); + + ro_string str (tmp); + trim (str); + + long long t; + zc_istream is (str); + is >> t; + + return t; + } + + // positive_integer + // + template + void positive_integer_pimpl:: + _pre () + { + str_.clear (); + } + + template + void positive_integer_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + unsigned long long positive_integer_pimpl:: + post_positive_integer () + { + std::basic_string tmp; + tmp.swap (str_); + + ro_string str (tmp); + trim (str); + + unsigned long long t; + zc_istream is (str); + is >> t; + + return t; + } + + // non_negative_integer + // + template + void non_negative_integer_pimpl:: + _pre () + { + str_.clear (); + } + + template + void non_negative_integer_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + unsigned long long non_negative_integer_pimpl:: + post_non_negative_integer () + { + std::basic_string tmp; + tmp.swap (str_); + + ro_string str (tmp); + trim (str); + + unsigned long long t; + zc_istream is (str); + is >> t; + + return t; + } + + // float + // + template + void float_pimpl:: + _pre () + { + str_.clear (); + } + + template + void float_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + float float_pimpl:: + post_float () + { + std::basic_string tmp; + tmp.swap (str_); + + ro_string str (tmp); + trim (str); + + if (str == bits::positive_inf ()) + return std::numeric_limits::infinity (); + + if (str == bits::negative_inf ()) + return -std::numeric_limits::infinity (); + + if (str == bits::nan ()) + return std::numeric_limits::quiet_NaN (); + + float t; + zc_istream is (str); + is.imbue (std::locale::classic ()); + is >> t; + + return t; + } + + // double + // + template + void double_pimpl:: + _pre () + { + str_.clear (); + } + + template + void double_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + double double_pimpl:: + post_double () + { + std::basic_string tmp; + tmp.swap (str_); + + ro_string str (tmp); + trim (str); + + if (str == bits::positive_inf ()) + return std::numeric_limits::infinity (); + + if (str == bits::negative_inf ()) + return -std::numeric_limits::infinity (); + + if (str == bits::nan ()) + return std::numeric_limits::quiet_NaN (); + + double t; + zc_istream is (str); + is.imbue (std::locale::classic ()); + is >> t; + + return t; + } + + // decimal + // + template + void decimal_pimpl:: + _pre () + { + str_.clear (); + } + + template + void decimal_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + double decimal_pimpl:: + post_decimal () + { + std::basic_string tmp; + tmp.swap (str_); + + ro_string str (tmp); + trim (str); + + double t; + zc_istream is (str); + is.imbue (std::locale::classic ()); + is >> t; + + return t; + } + + + // string + // + template + void string_pimpl:: + _pre () + { + str_.clear (); + } + + template + void string_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + std::basic_string string_pimpl:: + post_string () + { + std::basic_string r; + r.swap (str_); + return r; + } + + // normalized_string + // + template + void normalized_string_pimpl:: + _pre () + { + str_.clear (); + } + + template + void normalized_string_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + std::basic_string normalized_string_pimpl:: + post_normalized_string () + { + typedef typename std::basic_string::size_type size_type; + + size_type size (str_.size ()); + + for (size_type i (0); i < size; ++i) + { + C& c = str_[i]; + + if (c == C (0x0A) || c == C (0x0D) || c == C (0x09)) + c = C (0x20); + } + + std::basic_string r; + r.swap (str_); + return r; + } + + // token + // + template + void token_pimpl:: + _pre () + { + str_.clear (); + } + + template + void token_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + std::basic_string token_pimpl:: + post_token () + { + typedef typename std::basic_string::size_type size_type; + + size_type size (str_.size ()); + size_type j (0); + + bool subs (false); + + for (size_type i (0); i < size; ++i) + { + C c = str_[i]; + + if (c == C (0x20) || c == C (0x0A) || + c == C (0x0D) || c == C (0x09)) + { + subs = true; + } + else + { + if (subs) + { + subs = false; + str_[j++] = C (0x20); + } + + str_[j++] = c; + } + } + + str_.resize (j); + + std::basic_string r; + r.swap (str_); + return r; + } + + // name + // + template + void name_pimpl:: + _pre () + { + str_.clear (); + } + + template + void name_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + std::basic_string name_pimpl:: + post_name () + { + ro_string tmp (str_); + str_.resize (trim_right (tmp)); + + std::basic_string r; + r.swap (str_); + return r; + } + + // nmtoken + // + template + void nmtoken_pimpl:: + _pre () + { + str_.clear (); + } + + template + void nmtoken_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + std::basic_string nmtoken_pimpl:: + post_nmtoken () + { + ro_string tmp (str_); + str_.resize (trim_right (tmp)); + + std::basic_string r; + r.swap (str_); + return r; + } + + // nmtokens + // + template + void nmtokens_pimpl:: + _pre () + { + nmtokens_pskel::_pre (); + seq_.clear (); + } + + template + string_sequence nmtokens_pimpl:: + post_nmtokens () + { + string_sequence r; + r.swap (seq_); + return r; + } + + template + void nmtokens_pimpl:: + _xsd_parse_item (const ro_string& s) + { + parser_.pre (); + parser_._pre (); + parser_._characters (s); + parser_._post (); + seq_.push_back (parser_.post_nmtoken ()); + } + + // ncname + // + template + void ncname_pimpl:: + _pre () + { + str_.clear (); + } + + template + void ncname_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + std::basic_string ncname_pimpl:: + post_ncname () + { + ro_string tmp (str_); + str_.resize (trim_right (tmp)); + + std::basic_string r; + r.swap (str_); + return r; + } + + // id + // + template + void id_pimpl:: + _pre () + { + str_.clear (); + } + + template + void id_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + std::basic_string id_pimpl:: + post_id () + { + ro_string tmp (str_); + str_.resize (trim_right (tmp)); + + std::basic_string r; + r.swap (str_); + return r; + } + + // idref + // + template + void idref_pimpl:: + _pre () + { + str_.clear (); + } + + template + void idref_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + std::basic_string idref_pimpl:: + post_idref () + { + ro_string tmp (str_); + str_.resize (trim_right (tmp)); + + std::basic_string r; + r.swap (str_); + return r; + } + + // idrefs + // + template + void idrefs_pimpl:: + _pre () + { + idrefs_pskel::_pre (); + seq_.clear (); + } + + template + string_sequence idrefs_pimpl:: + post_idrefs () + { + string_sequence r; + r.swap (seq_); + return r; + } + + template + void idrefs_pimpl:: + _xsd_parse_item (const ro_string& s) + { + parser_.pre (); + parser_._pre (); + parser_._characters (s); + parser_._post (); + seq_.push_back (parser_.post_idref ()); + } + + // language + // + template + void language_pimpl:: + _pre () + { + str_.clear (); + } + + template + void language_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + std::basic_string language_pimpl:: + post_language () + { + ro_string tmp (str_); + str_.resize (trim_right (tmp)); + + std::basic_string r; + r.swap (str_); + return r; + } + + // uri + // + template + void uri_pimpl:: + _pre () + { + str_.clear (); + } + + template + void uri_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + std::basic_string uri_pimpl:: + post_uri () + { + ro_string tmp (str_); + str_.resize (trim_right (tmp)); + + std::basic_string r; + r.swap (str_); + return r; + } + + // qname + // + template + void qname_pimpl:: + _pre () + { + str_.clear (); + } + + template + void qname_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + qname qname_pimpl:: + post_qname () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + size_type pos (tmp.find (C (':'))); + + if (pos != ro_string::npos) + { + std::basic_string prefix (tmp.data (), pos++); + std::basic_string name (tmp.data () + pos, size - pos); + return qname (prefix, name); + } + else + { + str_.resize (size); + return qname (str_); + } + } + + // base64_binary + // + template + void base64_binary_pimpl:: + _pre () + { + str_.clear (); + } + + template + void base64_binary_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + namespace bits + { + template + inline unsigned char + base64_decode (C c) + { + unsigned char r (0xFF); + + if (c >= C('A') && c <= C ('Z')) + r = static_cast (c - C ('A')); + else if (c >= C('a') && c <= C ('z')) + r = static_cast (c - C ('a') + 26); + else if (c >= C('0') && c <= C ('9')) + r = static_cast (c - C ('0') + 52); + else if (c == C ('+')) + r = 62; + else if (c == C ('/')) + r = 63; + + return r; + } + } + + template + XSD_AUTO_PTR base64_binary_pimpl:: + post_base64_binary () + { + typedef typename std::basic_string::size_type size_type; + + size_type size (str_.size ()); + const C* src (str_.c_str ()); + + // Remove all whitespaces. + // + { + size_type j (0); + + bool subs (false); + + for (size_type i (0); i < size; ++i) + { + C c = str_[i]; + + if (c == C (0x20) || c == C (0x0A) || + c == C (0x0D) || c == C (0x09)) + { + subs = true; + } + else + { + if (subs) + subs = false; + + str_[j++] = c; + } + } + + size = j; + str_.resize (size); + } + + // Our length should be a multiple of four. + // + size_type quad_count (size / 4); + size_type capacity (quad_count * 3 + 1); + + XSD_AUTO_PTR buf (new buffer (capacity, capacity)); + char* dst (buf->data ()); + + size_type si (0), di (0); // Source and destination indexes. + + // Process all quads except the last one. + // + unsigned char b1, b2, b3, b4; + + for (size_type q (0); q < quad_count - 1; ++q) + { + b1 = bits::base64_decode (src[si++]); + b2 = bits::base64_decode (src[si++]); + b3 = bits::base64_decode (src[si++]); + b4 = bits::base64_decode (src[si++]); + + dst[di++] = (b1 << 2) | (b2 >> 4); + dst[di++] = (b2 << 4) | (b3 >> 2); + dst[di++] = (b3 << 6) | b4; + } + + // Process the last quad. The first two octets are always there. + // + b1 = bits::base64_decode (src[si++]); + b2 = bits::base64_decode (src[si++]); + + C e3 (src[si++]); + C e4 (src[si++]); + + if (e4 == C ('=')) + { + if (e3 == C ('=')) + { + // Two pads. Last 4 bits in b2 should be zero. + // + dst[di++] = (b1 << 2) | (b2 >> 4); + } + else + { + // One pad. Last 2 bits in b3 should be zero. + // + b3 = bits::base64_decode (e3); + + dst[di++] = (b1 << 2) | (b2 >> 4); + dst[di++] = (b2 << 4) | (b3 >> 2); + } + } + else + { + // No pads. + // + b3 = bits::base64_decode (e3); + b4 = bits::base64_decode (e4); + + dst[di++] = (b1 << 2) | (b2 >> 4); + dst[di++] = (b2 << 4) | (b3 >> 2); + dst[di++] = (b3 << 6) | b4; + } + + // Set the real size. + // + buf->size (di); + + return buf; + } + + // hex_binary + // + template + void hex_binary_pimpl:: + _pre () + { + str_.clear (); + } + + template + void hex_binary_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + namespace bits + { + template + inline unsigned char + hex_decode (C c) + { + unsigned char r (0xFF); + + if (c >= C('0') && c <= C ('9')) + r = static_cast (c - C ('0')); + else if (c >= C ('A') && c <= C ('F')) + r = static_cast (10 + (c - C ('A'))); + else if (c >= C ('a') && c <= C ('f')) + r = static_cast (10 + (c - C ('a'))); + + return r; + } + } + + template + XSD_AUTO_PTR hex_binary_pimpl:: + post_hex_binary () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + + buffer::size_t n (size / 2); + XSD_AUTO_PTR buf (new buffer (n)); + + const C* src (tmp.data ()); + char* dst (buf->data ()); + + for (buffer::size_t i (0); i < n; ++i) + { + unsigned char h (bits::hex_decode (src[2 * i])); + unsigned char l (bits::hex_decode (src[2 * i + 1])); + dst[i] = (h << 4) | l; + } + + return buf; + } + + // time_zone + // + namespace bits + { + // Datatypes 3.2.7.3. + // + template + void + parse_tz (const C* s, + typename std::basic_string::size_type n, + short& h, short& m) + { + // time_zone := Z|(+|-)HH:MM + // + if (n == 0) + { + return; + } + else if (s[0] == 'Z') + { + h = 0; + m = 0; + } + else if (n == 6) + { + // Parse hours. + // + h = 10 * (s[1] - '0') + (s[2] - '0'); + + // Parse minutes. + // + m = 10 * (s[4] - '0') + (s[5] - '0'); + + if (s[0] == '-') + { + h = -h; + m = -m; + } + } + } + } + + // gday + // + template + void gday_pimpl:: + _pre () + { + str_.clear (); + } + + template + void gday_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + gday gday_pimpl:: + post_gday () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + const C* s (tmp.data ()); + + unsigned short day (0); + bool z (false); + short zh (0), zm (0); + + // gday := ---DD[Z|(+|-)HH:MM] + // + if (size >= 5) + { + day = 10 * (s[3] - '0') + (s[4] - '0'); + + if (size > 5) + { + bits::parse_tz (s + 5, size - 5, zh, zm); + z = true; + } + } + + return z ? gday (day, zh, zm) : gday (day); + } + + // gmonth + // + template + void gmonth_pimpl:: + _pre () + { + str_.clear (); + } + + template + void gmonth_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + gmonth gmonth_pimpl:: + post_gmonth () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + const C* s (tmp.data ()); + + unsigned short month (0); + bool z (false); + short zh (0), zm (0); + + // gmonth := --MM[Z|(+|-)HH:MM] + // + if (size >= 4) + { + month = 10 * (s[2] - '0') + (s[3] - '0'); + + if (size > 4) + { + bits::parse_tz (s + 4, size - 4, zh, zm); + z = true; + } + } + + return z ? gmonth (month, zh, zm) : gmonth (month); + } + + // gyear + // + template + void gyear_pimpl:: + _pre () + { + str_.clear (); + } + + template + void gyear_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + gyear gyear_pimpl:: + post_gyear () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + const C* s (tmp.data ()); + + int year (0); + bool z (false); + short zh (0), zm (0); + + // gyear := [-]CCYY[N]*[Z|(+|-)HH:MM] + // + + if (size >= 4) + { + // Find the end of the year token. + // + size_type pos (4); + for (; pos < size; ++pos) + { + C c (s[pos]); + + if (c == C ('Z') || c == C ('+') || c == C ('-')) + break; + } + + ro_string year_fragment (s, pos); + zc_istream is (year_fragment); + is >> year; + + if (pos < size) + { + bits::parse_tz (s + pos, size - pos, zh, zm); + z = true; + } + } + + return z ? gyear (year, zh, zm) : gyear (year); + } + + // gmonth_day + // + template + void gmonth_day_pimpl:: + _pre () + { + str_.clear (); + } + + template + void gmonth_day_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + gmonth_day gmonth_day_pimpl:: + post_gmonth_day () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + const C* s (tmp.data ()); + + unsigned short month (0), day (0); + bool z (false); + short zh (0), zm (0); + + // gmonth_day := --MM-DD[Z|(+|-)HH:MM] + // + if (size >= 7) + { + month = 10 * (s[2] - '0') + (s[3] - '0'); + day = 10 * (s[5] - '0') + (s[6] - '0'); + + if (size > 7) + { + bits::parse_tz (s + 7, size - 7, zh, zm); + z = true; + } + } + + return z + ? gmonth_day (month, day, zh, zm) + : gmonth_day (month, day); + } + + // gyear_month + // + template + void gyear_month_pimpl:: + _pre () + { + str_.clear (); + } + + template + void gyear_month_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + gyear_month gyear_month_pimpl:: + post_gyear_month () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + const C* s (tmp.data ()); + + int year (0); + unsigned short month (0); + bool z (false); + short zh (0), zm (0); + + // gyear_month := [-]CCYY[N]*-MM[Z|(+|-)HH:MM] + // + + if (size >= 7) + { + // Find the end of the year token. + // + size_type pos (tmp.find (C ('-'), 4)); + + if (pos != ro_string::npos && (size - pos - 1) >= 2) + { + ro_string year_fragment (s, pos); + zc_istream yis (year_fragment); + yis >> year; + + month = 10 * (s[pos + 1] - '0') + (s[pos + 2] - '0'); + + pos += 3; + + if (pos < size) + { + bits::parse_tz (s + pos, size - pos, zh, zm); + z = true; + } + } + } + + return z + ? gyear_month (year, month, zh, zm) + : gyear_month (year, month); + } + + // date + // + template + void date_pimpl:: + _pre () + { + str_.clear (); + } + + template + void date_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + date date_pimpl:: + post_date () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + const C* s (tmp.data ()); + + int year (0); + unsigned short month (0), day (0); + bool z (false); + short zh (0), zm (0); + + // date := [-]CCYY[N]*-MM-DD[Z|(+|-)HH:MM] + // + + if (size >= 10) + { + // Find the end of the year token. + // + size_type pos (tmp.find (C ('-'), 4)); + + if (pos != ro_string::npos && (size - pos - 1) >= 5) + { + ro_string year_fragment (s, pos); + zc_istream yis (year_fragment); + yis >> year; + + month = 10 * (s[pos + 1] - '0') + (s[pos + 2] - '0'); + day = 10 * (s[pos + 4] - '0') + (s[pos + 5] - '0'); + + pos += 6; + + if (pos < size) + { + bits::parse_tz (s + pos, size - pos, zh, zm); + z = true; + } + } + } + + return z + ? date (year, month, day, zh, zm) + : date (year, month, day); + } + + // time + // + template + void time_pimpl:: + _pre () + { + str_.clear (); + } + + template + void time_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + time time_pimpl:: + post_time () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + const C* s (tmp.data ()); + + unsigned short hours (0), minutes (0); + double seconds (0.0); + bool z (false); + short zh (0), zm (0); + + // time := HH:MM:SS[.S+][Z|(+|-)HH:MM] + // + + if (size >= 8) + { + hours = 10 * (s[0] - '0') + (s[1] - '0'); + minutes = 10 * (s[3] - '0') + (s[4] - '0'); + + // Find the end of the seconds fragment. + // + size_type pos (8); + for (; pos < size; ++pos) + { + C c (s[pos]); + + if (c == C ('Z') || c == C ('+') || c == C ('-')) + break; + } + + ro_string seconds_fragment (s + 6, pos - 6); + zc_istream sis (seconds_fragment); + sis >> seconds; + + if (pos < size) + { + bits::parse_tz (s + pos, size - pos, zh, zm); + z = true; + } + } + + return z + ? time (hours, minutes, seconds, zh, zm) + : time (hours, minutes, seconds); + } + + + // date_time + // + template + void date_time_pimpl:: + _pre () + { + str_.clear (); + } + + template + void date_time_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + date_time date_time_pimpl:: + post_date_time () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + const C* s (tmp.data ()); + + int year (0); + unsigned short month (0), day (0), hours (0), minutes (0); + double seconds (0.0); + bool z (false); + short zh (0), zm (0); + + // date_time := [-]CCYY[N]*-MM-DDTHH:MM:SS[.S+][Z|(+|-)HH:MM] + // + + if (size >= 19) + { + // Find the end of the year token. + // + size_type pos (tmp.find (C ('-'), 4)); + + if (pos != ro_string::npos && (size - pos - 1) >= 14) + { + ro_string year_fragment (s, pos); + zc_istream yis (year_fragment); + yis >> year; + + month = 10 * (s[pos + 1] - '0') + (s[pos + 2] - '0'); + day = 10 * (s[pos + 4] - '0') + (s[pos + 5] - '0'); + + pos += 7; // Point to the first H. + + hours = 10 * (s[pos] - '0') + (s[pos + 1] - '0'); + minutes = 10 * (s[pos + 3] - '0') + (s[pos + 4] - '0'); + + // Find the end of the seconds fragment. + // + pos += 6; // Point to the first S. + + size_type sec_end (pos + 2); + for (; sec_end < size; ++sec_end) + { + C c (s[sec_end]); + + if (c == C ('Z') || c == C ('+') || c == C ('-')) + break; + } + + ro_string seconds_fragment (s + pos, sec_end - pos); + zc_istream sis (seconds_fragment); + sis >> seconds; + + if (sec_end < size) + { + bits::parse_tz (s + sec_end, size - sec_end, zh, zm); + z = true; + } + } + } + + return z + ? date_time (year, month, day, hours, minutes, seconds, zh, zm) + : date_time (year, month, day, hours, minutes, seconds); + } + + // duration + // + template + void duration_pimpl:: + _pre () + { + str_.clear (); + } + + template + void duration_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + namespace bits + { + template + inline typename ro_string::size_type + duration_delim (const C* s, + typename ro_string::size_type pos, + typename ro_string::size_type size) + { + const C* p (s + pos); + for (; p < (s + size); ++p) + { + if (*p == C ('Y') || *p == C ('D') || *p == C ('M') || + *p == C ('H') || *p == C ('M') || *p == C ('S') || + *p == C ('T')) + break; + } + + return p - s; + } + } + + template + duration duration_pimpl:: + post_duration () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + + bool negative (false); + unsigned int years (0), months (0), days (0), hours (0), minutes (0); + double seconds (0.0); + + // duration := [-]P[nY][nM][nD][TnHnMn[.n+]S] + // + const C* s (tmp.data ()); + + if (size >= 3) + { + size_type pos (0); + + if (s[0] == C ('-')) + { + negative = true; + pos++; + } + + pos++; // Skip 'P'. + + size_type del (bits::duration_delim (s, pos, size)); + + if (del != size && s[del] == C ('Y')) + { + ro_string fragment (s + pos, del - pos); + zc_istream is (fragment); + is >> years; + + pos = del + 1; + del = bits::duration_delim (s, pos, size); + } + + if (del != size && s[del] == C ('M')) + { + ro_string fragment (s + pos, del - pos); + zc_istream is (fragment); + is >> months; + + pos = del + 1; + del = bits::duration_delim (s, pos, size); + } + + if (del != size && s[del] == C ('D')) + { + ro_string fragment (s + pos, del - pos); + zc_istream is (fragment); + is >> days; + + pos = del + 1; + del = bits::duration_delim (s, pos, size); + } + + if (del != size && s[del] == C ('T')) + { + pos = del + 1; + del = bits::duration_delim (s, pos, size); + + if (del != size && s[del] == C ('H')) + { + ro_string fragment (s + pos, del - pos); + zc_istream is (fragment); + is >> hours; + + pos = del + 1; + del = bits::duration_delim (s, pos, size); + } + + if (del != size && s[del] == C ('M')) + { + ro_string fragment (s + pos, del - pos); + zc_istream is (fragment); + is >> minutes; + + pos = del + 1; + del = bits::duration_delim (s, pos, size); + } + + if (del != size && s[del] == C ('S')) + { + ro_string fragment (s + pos, del - pos); + zc_istream is (fragment); + is >> seconds; + } + } + } + + return duration ( + negative, years, months, days, hours, minutes, seconds); + } + } + } + } +} diff --git a/libxsd/libxsd/cxx/parser/non-validating/xml-schema-pskel.hxx b/libxsd/libxsd/cxx/parser/non-validating/xml-schema-pskel.hxx new file mode 100644 index 0000000..9fde0d8 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/non-validating/xml-schema-pskel.hxx @@ -0,0 +1,647 @@ +// file : libxsd/cxx/parser/non-validating/xml-schema-pskel.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PSKEL_HXX +#define LIBXSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PSKEL_HXX + +#include +#include // std::auto_ptr/unique_ptr + +#include // XSD_AUTO_PTR + +#include +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // anyType and anySimpleType. All events are routed to the + // _any_* callbacks. + // + template + struct any_type_pskel: complex_content + { + 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&); + + virtual bool + _attribute_impl (const ro_string&, + const ro_string&, + const ro_string&); + + virtual bool + _characters_impl (const ro_string&); + + virtual void + post_any_type () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct any_simple_type_pskel: simple_content + { + virtual bool + _characters_impl (const ro_string&); + + virtual void + post_any_simple_type () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + + // Boolean. + // + template + struct boolean_pskel: simple_content + { + virtual bool + post_boolean () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + + // 8-bit + // + template + struct byte_pskel: simple_content + { + virtual signed char + post_byte () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct unsigned_byte_pskel: simple_content + { + virtual unsigned char + post_unsigned_byte () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + + // 16-bit + // + template + struct short_pskel: simple_content + { + virtual short + post_short () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct unsigned_short_pskel: simple_content + { + virtual unsigned short + post_unsigned_short () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + + // 32-bit + // + template + struct int_pskel: simple_content + { + virtual int + post_int () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct unsigned_int_pskel: simple_content + { + virtual unsigned int + post_unsigned_int () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + + // 64-bit + // + template + struct long_pskel: simple_content + { + virtual long long + post_long () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct unsigned_long_pskel: simple_content + { + virtual unsigned long long + post_unsigned_long () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + + // Arbitrary-length integers. + // + template + struct integer_pskel: simple_content + { + virtual long long + post_integer () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct negative_integer_pskel: simple_content + { + virtual long long + post_negative_integer () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct non_positive_integer_pskel: simple_content + { + virtual long long + post_non_positive_integer () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct positive_integer_pskel: simple_content + { + virtual unsigned long long + post_positive_integer () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct non_negative_integer_pskel: simple_content + { + virtual unsigned long long + post_non_negative_integer () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + + // Floats. + // + template + struct float_pskel: simple_content + { + virtual float + post_float () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct double_pskel: simple_content + { + virtual double + post_double () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct decimal_pskel: simple_content + { + virtual double + post_decimal () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + + // Strings. + // + template + struct string_pskel: simple_content + { + virtual std::basic_string + post_string () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct normalized_string_pskel: simple_content + { + virtual std::basic_string + post_normalized_string () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct token_pskel: simple_content + { + virtual std::basic_string + post_token () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct name_pskel: simple_content + { + virtual std::basic_string + post_name () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct nmtoken_pskel: simple_content + { + virtual std::basic_string + post_nmtoken () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct nmtokens_pskel: list_base + { + virtual string_sequence + post_nmtokens () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct ncname_pskel: simple_content + { + virtual std::basic_string + post_ncname () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct id_pskel: simple_content + { + virtual std::basic_string + post_id () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct idref_pskel: simple_content + { + virtual std::basic_string + post_idref () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct idrefs_pskel: list_base + { + virtual string_sequence + post_idrefs () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + // Language. + // + template + struct language_pskel: simple_content + { + virtual std::basic_string + post_language () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + // URI. + // + template + struct uri_pskel: simple_content + { + virtual std::basic_string + post_uri () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + // QName. + // + template + struct qname_pskel: simple_content + { + virtual qname + post_qname () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + // Base64 and hex binaries. + // + template + struct base64_binary_pskel: simple_content + { + virtual XSD_AUTO_PTR + post_base64_binary () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct hex_binary_pskel: simple_content + { + virtual XSD_AUTO_PTR + post_hex_binary () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + // Time and date types. + // + template + struct gday_pskel: simple_content + { + virtual gday + post_gday () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct gmonth_pskel: simple_content + { + virtual gmonth + post_gmonth () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct gyear_pskel: simple_content + { + virtual gyear + post_gyear () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct gmonth_day_pskel: simple_content + { + virtual gmonth_day + post_gmonth_day () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct gyear_month_pskel: simple_content + { + virtual gyear_month + post_gyear_month () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct date_pskel: simple_content + { + virtual date + post_date () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct time_pskel: simple_content + { + virtual time + post_time () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct date_time_pskel: simple_content + { + virtual date_time + post_date_time () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct duration_pskel: simple_content + { + virtual duration + post_duration () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + } + } + } +} + +#include + +#endif // LIBXSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PSKEL_HXX + +#include diff --git a/libxsd/libxsd/cxx/parser/non-validating/xml-schema-pskel.ixx b/libxsd/libxsd/cxx/parser/non-validating/xml-schema-pskel.ixx new file mode 100644 index 0000000..d3914fb --- /dev/null +++ b/libxsd/libxsd/cxx/parser/non-validating/xml-schema-pskel.ixx @@ -0,0 +1,1247 @@ +// file : libxsd/cxx/parser/non-validating/xml-schema-pskel.ixx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#if defined(XSD_CXX_PARSER_USE_CHAR) || !defined(XSD_CXX_PARSER_USE_WCHAR) + +#ifndef XSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PSKEL_IXX_CHAR +#define XSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PSKEL_IXX_CHAR + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + template<> + inline const char* any_type_pskel:: + _static_type () + { + return "anyType http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* any_type_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* any_simple_type_pskel:: + _static_type () + { + return "anySimpleType http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* any_simple_type_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* boolean_pskel:: + _static_type () + { + return "boolean http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* boolean_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* byte_pskel:: + _static_type () + { + return "byte http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* byte_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* unsigned_byte_pskel:: + _static_type () + { + return "unsignedByte http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* unsigned_byte_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* short_pskel:: + _static_type () + { + return "short http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* short_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* unsigned_short_pskel:: + _static_type () + { + return "unsignedShort http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* unsigned_short_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* int_pskel:: + _static_type () + { + return "int http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* int_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* unsigned_int_pskel:: + _static_type () + { + return "unsignedInt http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* unsigned_int_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* long_pskel:: + _static_type () + { + return "long http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* long_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* unsigned_long_pskel:: + _static_type () + { + return "unsignedLong http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* unsigned_long_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* integer_pskel:: + _static_type () + { + return "integer http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* negative_integer_pskel:: + _static_type () + { + return "negativeInteger http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* negative_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* non_positive_integer_pskel:: + _static_type () + { + return "nonPositiveInteger http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* non_positive_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* positive_integer_pskel:: + _static_type () + { + return "positiveInteger http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* positive_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* non_negative_integer_pskel:: + _static_type () + { + return "nonNegativeInteger http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* non_negative_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* float_pskel:: + _static_type () + { + return "float http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* float_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* double_pskel:: + _static_type () + { + return "double http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* double_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* decimal_pskel:: + _static_type () + { + return "decimal http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* decimal_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* string_pskel:: + _static_type () + { + return "string http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* string_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* normalized_string_pskel:: + _static_type () + { + return "normalizedString http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* normalized_string_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* token_pskel:: + _static_type () + { + return "token http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* token_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* name_pskel:: + _static_type () + { + return "Name http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* name_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* nmtoken_pskel:: + _static_type () + { + return "NMTOKEN http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* nmtoken_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* nmtokens_pskel:: + _static_type () + { + return "NMTOKENS http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* nmtokens_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* ncname_pskel:: + _static_type () + { + return "NCName http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* ncname_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* id_pskel:: + _static_type () + { + return "ID http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* id_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* idref_pskel:: + _static_type () + { + return "IDREF http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* idref_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* idrefs_pskel:: + _static_type () + { + return "IDREFS http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* idrefs_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* language_pskel:: + _static_type () + { + return "language http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* language_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* uri_pskel:: + _static_type () + { + return "anyURI http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* uri_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* qname_pskel:: + _static_type () + { + return "QName http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* qname_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* base64_binary_pskel:: + _static_type () + { + return "base64Binary http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* base64_binary_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* hex_binary_pskel:: + _static_type () + { + return "hexBinary http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* hex_binary_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* gday_pskel:: + _static_type () + { + return "gDay http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* gday_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* gmonth_pskel:: + _static_type () + { + return "gMonth http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* gmonth_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* gyear_pskel:: + _static_type () + { + return "gYear http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* gyear_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* gmonth_day_pskel:: + _static_type () + { + return "gMonthDay http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* gmonth_day_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* gyear_month_pskel:: + _static_type () + { + return "gYearMonth http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* gyear_month_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* date_pskel:: + _static_type () + { + return "date http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* date_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* time_pskel:: + _static_type () + { + return "time http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* time_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* date_time_pskel:: + _static_type () + { + return "dateTime http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* date_time_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* duration_pskel:: + _static_type () + { + return "duration http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* duration_pskel:: + _dynamic_type () const + { + return _static_type (); + } + } + } + } +} + +#endif // XSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PSKEL_IXX_CHAR +#endif // XSD_CXX_PARSER_USE_CHAR + + +#if defined(XSD_CXX_PARSER_USE_WCHAR) || !defined(XSD_CXX_PARSER_USE_CHAR) + +#ifndef XSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PSKEL_IXX_WCHAR +#define XSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PSKEL_IXX_WCHAR + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + template<> + inline const wchar_t* any_type_pskel:: + _static_type () + { + return L"anyType http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* any_type_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* any_simple_type_pskel:: + _static_type () + { + return L"anySimpleType http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* any_simple_type_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* boolean_pskel:: + _static_type () + { + return L"boolean http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* boolean_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* byte_pskel:: + _static_type () + { + return L"byte http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* byte_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* unsigned_byte_pskel:: + _static_type () + { + return L"unsignedByte http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* unsigned_byte_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* short_pskel:: + _static_type () + { + return L"short http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* short_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* unsigned_short_pskel:: + _static_type () + { + return L"unsignedShort http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* unsigned_short_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* int_pskel:: + _static_type () + { + return L"int http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* int_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* unsigned_int_pskel:: + _static_type () + { + return L"unsignedInt http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* unsigned_int_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* long_pskel:: + _static_type () + { + return L"long http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* long_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* unsigned_long_pskel:: + _static_type () + { + return L"unsignedLong http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* unsigned_long_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* integer_pskel:: + _static_type () + { + return L"integer http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* negative_integer_pskel:: + _static_type () + { + return L"negativeInteger http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* negative_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* non_positive_integer_pskel:: + _static_type () + { + return L"nonPositiveInteger http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* non_positive_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* positive_integer_pskel:: + _static_type () + { + return L"positiveInteger http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* positive_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* non_negative_integer_pskel:: + _static_type () + { + return L"nonNegativeInteger http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* non_negative_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* float_pskel:: + _static_type () + { + return L"float http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* float_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* double_pskel:: + _static_type () + { + return L"double http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* double_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* decimal_pskel:: + _static_type () + { + return L"decimal http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* decimal_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* string_pskel:: + _static_type () + { + return L"string http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* string_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* normalized_string_pskel:: + _static_type () + { + return L"normalizedString http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* normalized_string_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* token_pskel:: + _static_type () + { + return L"token http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* token_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* name_pskel:: + _static_type () + { + return L"Name http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* name_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* nmtoken_pskel:: + _static_type () + { + return L"NMTOKEN http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* nmtoken_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* nmtokens_pskel:: + _static_type () + { + return L"NMTOKENS http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* nmtokens_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* ncname_pskel:: + _static_type () + { + return L"NCName http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* ncname_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* id_pskel:: + _static_type () + { + return L"ID http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* id_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* idref_pskel:: + _static_type () + { + return L"IDREF http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* idref_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* idrefs_pskel:: + _static_type () + { + return L"IDREFS http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* idrefs_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* language_pskel:: + _static_type () + { + return L"language http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* language_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* uri_pskel:: + _static_type () + { + return L"anyURI http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* uri_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* qname_pskel:: + _static_type () + { + return L"QName http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* qname_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* base64_binary_pskel:: + _static_type () + { + return L"base64Binary http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* base64_binary_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* hex_binary_pskel:: + _static_type () + { + return L"hexBinary http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* hex_binary_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* gday_pskel:: + _static_type () + { + return L"gDay http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* gday_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* gmonth_pskel:: + _static_type () + { + return L"gMonth http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* gmonth_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* gyear_pskel:: + _static_type () + { + return L"gYear http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* gyear_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* gmonth_day_pskel:: + _static_type () + { + return L"gMonthDay http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* gmonth_day_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* gyear_month_pskel:: + _static_type () + { + return L"gYearMonth http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* gyear_month_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* date_pskel:: + _static_type () + { + return L"date http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* date_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* time_pskel:: + _static_type () + { + return L"time http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* time_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* date_time_pskel:: + _static_type () + { + return L"dateTime http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* date_time_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* duration_pskel:: + _static_type () + { + return L"duration http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* duration_pskel:: + _dynamic_type () const + { + return _static_type (); + } + } + } + } +} + +#endif // XSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PSKEL_IXX_WCHAR +#endif // XSD_CXX_PARSER_USE_WCHAR diff --git a/libxsd/libxsd/cxx/parser/non-validating/xml-schema-pskel.txx b/libxsd/libxsd/cxx/parser/non-validating/xml-schema-pskel.txx new file mode 100644 index 0000000..b7b78bb --- /dev/null +++ b/libxsd/libxsd/cxx/parser/non-validating/xml-schema-pskel.txx @@ -0,0 +1,67 @@ +// file : libxsd/cxx/parser/non-validating/xml-schema-pskel.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // any_type + // + + template + bool any_type_pskel:: + _start_element_impl (const ro_string& ns, + const ro_string& name, + const ro_string* type) + { + this->_start_any_element (ns, name, type); + this->complex_content::context_.top ().any_ = true; + return true; + } + + template + bool any_type_pskel:: + _end_element_impl (const ro_string& ns, const ro_string& name) + { + this->complex_content::context_.top ().any_ = false; + this->_end_any_element (ns, name); + return true; + } + + + template + bool any_type_pskel:: + _attribute_impl (const ro_string& ns, + const ro_string& name, + const ro_string& value) + { + this->_any_attribute (ns, name, value); + return true; + } + + template + bool any_type_pskel:: + _characters_impl (const ro_string& s) + { + this->_any_characters (s); + return true; + } + + // any_simple_type + // + + template + bool any_simple_type_pskel:: + _characters_impl (const ro_string& s) + { + this->_any_characters (s); + return true; + } + } + } + } +} diff --git a/libxsd/libxsd/cxx/parser/schema-exceptions.hxx b/libxsd/libxsd/cxx/parser/schema-exceptions.hxx new file mode 100644 index 0000000..d7d6599 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/schema-exceptions.hxx @@ -0,0 +1,185 @@ +// file : libxsd/cxx/parser/schema-exceptions.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_PARSER_SCHEMA_EXCEPTIONS_HXX +#define LIBXSD_CXX_PARSER_SCHEMA_EXCEPTIONS_HXX + +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + template + struct schema_exception + { + public: + virtual + ~schema_exception () + { + } + + unsigned long + line () const + { + return line_; + } + + void + line (unsigned long l) + { + line_ = l; + } + + unsigned long + column () const + { + return column_; + } + + void + column (unsigned long c) + { + column_ = c; + } + + const std::basic_string& + id () const + { + return id_; + } + + void + id (const std::basic_string& id) + { + id_ = id; + } + + virtual std::basic_string + message () const = 0; + + protected: + unsigned long line_; + unsigned long column_; + std::basic_string id_; + }; + + // + // + template + struct expected_element: schema_exception + { + virtual + ~expected_element (); + + expected_element (const std::basic_string& expected_namespace, + const std::basic_string& expected_name); + + expected_element (const std::basic_string& expected_namespace, + const std::basic_string& expected_name, + const std::basic_string& encountered_namespace, + const std::basic_string& encountered_name); + + const std::basic_string& + expected_namespace () const + { + return expected_namespace_; + } + + const std::basic_string& + expected_name () const + { + return expected_name_; + } + + // Encountered element namespace and name are empty if none + // encountered. + // + const std::basic_string& + encountered_namespace () const + { + return encountered_namespace_; + } + + const std::basic_string& + encountered_name () const + { + return encountered_name_; + } + + virtual std::basic_string + message () const; + + private: + std::basic_string expected_namespace_; + std::basic_string expected_name_; + + std::basic_string encountered_namespace_; + std::basic_string encountered_name_; + }; + + + // + // + template + struct unexpected_element: schema_exception + { + virtual + ~unexpected_element (); + + unexpected_element (const std::basic_string& encountered_namespace, + const std::basic_string& encountered_name); + + const std::basic_string& + encountered_namespace () const + { + return encountered_namespace_; + } + + const std::basic_string& + encountered_name () const + { + return encountered_name_; + } + + virtual std::basic_string + message () const; + + private: + std::basic_string encountered_namespace_; + std::basic_string encountered_name_; + }; + + // + // + template + struct dynamic_type: schema_exception + { + virtual + ~dynamic_type () throw (); + + dynamic_type (const std::basic_string& type); + + const std::basic_string& + type () const + { + return type_; + } + + virtual std::basic_string + message () const; + + private: + std::basic_string type_; + }; + } + } +} + +#include + +#endif // LIBXSD_CXX_PARSER_SCHEMA_EXCEPTIONS_HXX + +#include diff --git a/libxsd/libxsd/cxx/parser/schema-exceptions.ixx b/libxsd/libxsd/cxx/parser/schema-exceptions.ixx new file mode 100644 index 0000000..e07b569 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/schema-exceptions.ixx @@ -0,0 +1,143 @@ +// file : libxsd/cxx/parser/schema-exceptions.ixx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#if defined(XSD_CXX_PARSER_USE_CHAR) || !defined(XSD_CXX_PARSER_USE_WCHAR) + +#ifndef XSD_CXX_PARSER_SCHEMA_EXCEPTIONS_IXX_CHAR +#define XSD_CXX_PARSER_SCHEMA_EXCEPTIONS_IXX_CHAR + +namespace xsd +{ + namespace cxx + { + namespace parser + { + // expected_element + // + template<> + inline + std::basic_string expected_element:: + message () const + { + std::basic_string r ("expected element '"); + r += expected_namespace_; + r += expected_namespace_.empty () ? "" : "#"; + r += expected_name_; + r += "'"; + + if (!encountered_name_.empty ()) + { + r += " instead of '"; + r += encountered_namespace_; + r += encountered_namespace_.empty () ? "" : "#"; + r += encountered_name_; + r += "'"; + } + + return r; + } + + // unexpected_element + // + template<> + inline + std::basic_string unexpected_element:: + message () const + { + std::basic_string r ("unexpected element '"); + r += encountered_namespace_; + r += encountered_namespace_.empty () ? "" : "#"; + r += encountered_name_; + r += "'"; + return r; + } + + // dynamic_type + // + template<> + inline + std::basic_string dynamic_type:: + message () const + { + std::basic_string r ("invalid xsi:type '"); + r += type_; + r += "'"; + return r; + } + } + } +} + +#endif // XSD_CXX_PARSER_SCHEMA_EXCEPTIONS_IXX_CHAR +#endif // XSD_CXX_PARSER_USE_CHAR + + +#if defined(XSD_CXX_PARSER_USE_WCHAR) || !defined(XSD_CXX_PARSER_USE_CHAR) + +#ifndef XSD_CXX_PARSER_SCHEMA_EXCEPTIONS_IXX_WCHAR +#define XSD_CXX_PARSER_SCHEMA_EXCEPTIONS_IXX_WCHAR + +namespace xsd +{ + namespace cxx + { + namespace parser + { + // expected_element + // + template<> + inline + std::basic_string expected_element:: + message () const + { + std::basic_string r (L"expected element '"); + r += expected_namespace_; + r += expected_namespace_.empty () ? L"" : L"#"; + r += expected_name_; + r += L"'"; + + if (!encountered_name_.empty ()) + { + r += L" instead of '"; + r += encountered_namespace_; + r += encountered_namespace_.empty () ? L"" : L"#"; + r += encountered_name_; + r += L"'"; + } + + return r; + } + + // unexpected_element + // + template<> + inline + std::basic_string unexpected_element:: + message () const + { + std::basic_string r (L"unexpected element '"); + r += encountered_namespace_; + r += encountered_namespace_.empty () ? L"" : L"#"; + r += encountered_name_; + r += L"'"; + return r; + } + + // dynamic_type + // + template<> + inline + std::basic_string dynamic_type:: + message () const + { + std::basic_string r (L"invalid xsi:type '"); + r += type_; + r += L"'"; + return r; + } + } + } +} + +#endif // XSD_CXX_PARSER_SCHEMA_EXCEPTIONS_IXX_WCHAR +#endif // XSD_CXX_PARSER_USE_WCHAR diff --git a/libxsd/libxsd/cxx/parser/schema-exceptions.txx b/libxsd/libxsd/cxx/parser/schema-exceptions.txx new file mode 100644 index 0000000..1e90b2b --- /dev/null +++ b/libxsd/libxsd/cxx/parser/schema-exceptions.txx @@ -0,0 +1,73 @@ +// file : libxsd/cxx/parser/schema-exceptions.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsd +{ + namespace cxx + { + namespace parser + { + // expected_element + // + template + expected_element:: + ~expected_element () + { + } + + template + expected_element:: + expected_element (const std::basic_string& expected_namespace, + const std::basic_string& expected_name) + : expected_namespace_ (expected_namespace), + expected_name_ (expected_name) + { + } + + template + expected_element:: + expected_element (const std::basic_string& expected_namespace, + const std::basic_string& expected_name, + const std::basic_string& encountered_namespace, + const std::basic_string& encountered_name) + : expected_namespace_ (expected_namespace), + expected_name_ (expected_name), + encountered_namespace_ (encountered_namespace), + encountered_name_ (encountered_name) + { + } + + // unexpected_element + // + template + unexpected_element:: + ~unexpected_element () + { + } + + template + unexpected_element:: + unexpected_element (const std::basic_string& encountered_namespace, + const std::basic_string& encountered_name) + : encountered_namespace_ (encountered_namespace), + encountered_name_ (encountered_name) + { + } + + // dynamic_type + // + template + dynamic_type:: + ~dynamic_type () throw () + { + } + + template + dynamic_type:: + dynamic_type (const std::basic_string& type) + : type_ (type) + { + } + } + } +} diff --git a/libxsd/libxsd/cxx/parser/substitution-map.hxx b/libxsd/libxsd/cxx/parser/substitution-map.hxx new file mode 100644 index 0000000..86501f0 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/substitution-map.hxx @@ -0,0 +1,239 @@ +// file : libxsd/cxx/parser/substitution-map.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_PARSER_SUBSTITUTION_MAP_HXX +#define LIBXSD_CXX_PARSER_SUBSTITUTION_MAP_HXX + +#include +#include // std::size_t + +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + template + struct substitution_map_key + { + substitution_map_key (const C* ns, const C* name) + : ns_ (ns), name_ (name) + { + } + + substitution_map_key (const ro_string& ns, + const ro_string& name) + : ns_ (ns.data (), ns.size ()), + name_ (name.data (), name.size ()) + { + } + + substitution_map_key (const substitution_map_key& x) + : ns_ (x.ns_.data (), x.ns_.size ()), + name_ (x.name_.data (), x.name_.size ()) + { + } + + private: + substitution_map_key& + operator= (const substitution_map_key&); + + public: + const ro_string& + ns () const + { + return ns_; + } + + const ro_string& + name () const + { + return name_; + } + + private: + const ro_string ns_; + const ro_string name_; + }; + + template + inline bool + operator< (const substitution_map_key& x, + const substitution_map_key& y) + { + int r (x.name ().compare (y.name ())); + return r < 0 || (r == 0 && x.ns () < y.ns ()); + } + + template + struct substitution_map_value + { + substitution_map_value (const C* ns, const C* name, const C* type) + : ns_ (ns), name_ (name), type_ (type) + { + } + + substitution_map_value (const substitution_map_value& x) + : ns_ (x.ns_.data (), x.ns_.size ()), + name_ (x.name_.data (), x.name_.size ()), + type_ (x.type_.data (), x.type_.size ()) + { + } + + substitution_map_value& + operator= (const substitution_map_value& x) + { + if (this != &x) + { + ns_.assign (x.ns_.data (), x.ns_.size ()); + name_.assign (x.name_.data (), x.name_.size ()); + type_.assign (x.type_.data (), x.type_.size ()); + } + + return *this; + } + + public: + const ro_string& + ns () const + { + return ns_; + } + + const ro_string& + name () const + { + return name_; + } + + const ro_string& + type () const + { + return type_; + } + + private: + ro_string ns_; + ro_string name_; + ro_string type_; + }; + + template + struct substitution_map + { + void + insert (const C* member_ns, + const C* member_name, + const C* root_ns, + const C* root_name, + const C* member_type) + { + key k (member_ns, member_name); + value v (root_ns, root_name, member_type); + map_.insert (std::pair (k, v)); + } + + void + erase (const C* member_ns, const C* member_name) + { + map_.erase (key (member_ns, member_name)); + } + + // Check and get the type set if found. + // + bool + check (const ro_string& ns, + const ro_string& name, + const C* root_ns, + const C* root_name, + const ro_string*& type) const + { + + return map_.empty () + ? false + : check_ (ns, name, root_ns, root_name, &type); + } + + // Check but don't care about the type. + // + bool + check (const ro_string& ns, + const ro_string& name, + const C* root_ns, + const C* root_name) const + { + + return map_.empty () + ? false + : check_ (ns, name, root_ns, root_name, 0); + } + + private: + bool + check_ (const ro_string& ns, + const ro_string& name, + const C* root_ns, + const C* root_name, + const ro_string** type) const; + + private: + typedef substitution_map_key key; + typedef substitution_map_value value; + typedef std::map map; + + map map_; + }; + + + // Translation unit initializer. + // + template + struct substitution_map_init + { + static substitution_map* map; + static std::size_t count; + + substitution_map_init (); + ~substitution_map_init (); + }; + + template + substitution_map* substitution_map_init::map = 0; + + template + std::size_t substitution_map_init::count = 0; + + template + inline substitution_map& + substitution_map_instance () + { + return *substitution_map_init::map; + } + + + // Map entry initializer. + // + template + struct substitution_map_entry + { + substitution_map_entry (const C* member_ns, + const C* member_name, + const C* root_ns, + const C* root_name, + const C* member_type); + + ~substitution_map_entry (); + + private: + const C* member_ns_; + const C* member_name_; + }; + } + } +} + +#include + +#endif // LIBXSD_CXX_PARSER_SUBSTITUTION_MAP_HXX diff --git a/libxsd/libxsd/cxx/parser/substitution-map.txx b/libxsd/libxsd/cxx/parser/substitution-map.txx new file mode 100644 index 0000000..1b7705b --- /dev/null +++ b/libxsd/libxsd/cxx/parser/substitution-map.txx @@ -0,0 +1,82 @@ +// file : libxsd/cxx/parser/substitution-map.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsd +{ + namespace cxx + { + namespace parser + { + template + bool substitution_map:: + check_ (const ro_string& ns, + const ro_string& name, + const C* root_ns, + const C* root_name, + const ro_string** type) const + { + key k (ns, name); + typename map::const_iterator i (map_.find (k)); + + if (i == map_.end ()) + return false; + + const value& v (i->second); + + bool r (false); + + if (v.name () == root_name && v.ns () == root_ns) + r = true; + else + r = check_ (v.ns (), v.name (), root_ns, root_name, 0); + + if (r && type != 0 && *type == 0) + *type = &v.type (); + + return r; + } + + // substitution_map_init + // + template + substitution_map_init:: + substitution_map_init () + { + if (count == 0) + map = new substitution_map; + + ++count; + } + + template + substitution_map_init:: + ~substitution_map_init () + { + if (--count == 0) + delete map; + } + + // substitution_map_entry + // + template + substitution_map_entry:: + substitution_map_entry (const C* member_ns, + const C* member_name, + const C* root_ns, + const C* root_name, + const C* member_type) + : member_ns_ (member_ns), member_name_ (member_name) + { + substitution_map_instance ().insert ( + member_ns, member_name, root_ns, root_name, member_type); + } + + template + substitution_map_entry:: + ~substitution_map_entry () + { + substitution_map_instance ().erase (member_ns_, member_name_); + } + } + } +} diff --git a/libxsd/libxsd/cxx/parser/validating/exceptions.hxx b/libxsd/libxsd/cxx/parser/validating/exceptions.hxx new file mode 100644 index 0000000..ca6de6c --- /dev/null +++ b/libxsd/libxsd/cxx/parser/validating/exceptions.hxx @@ -0,0 +1,151 @@ +// file : libxsd/cxx/parser/validating/exceptions.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_PARSER_VALIDATING_EXCEPTIONS_HXX +#define LIBXSD_CXX_PARSER_VALIDATING_EXCEPTIONS_HXX + +#include + +#include +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace validating + { + // + // + template + struct expected_attribute: schema_exception + { + virtual + ~expected_attribute (); + + expected_attribute (const std::basic_string& expected_namespace, + const std::basic_string& expected_name); + + const std::basic_string& + expected_namespace () const + { + return expected_namespace_; + } + + const std::basic_string& + expected_name () const + { + return expected_name_; + } + + virtual std::basic_string + message () const; + + private: + std::basic_string expected_namespace_; + std::basic_string expected_name_; + }; + + // + // + template + struct unexpected_attribute: schema_exception + { + virtual + ~unexpected_attribute (); + + unexpected_attribute ( + const std::basic_string& encountered_namespace, + const std::basic_string& encountered_name); + + + const std::basic_string& + encountered_namespace () const + { + return encountered_namespace_; + } + + const std::basic_string& + encountered_name () const + { + return encountered_name_; + } + + virtual std::basic_string + message () const; + + private: + std::basic_string encountered_namespace_; + std::basic_string encountered_name_; + }; + + + // + // + template + struct unexpected_characters: schema_exception + { + virtual + ~unexpected_characters (); + + unexpected_characters (const std::basic_string& s); + + const std::basic_string& + characters () const + { + return characters_; + } + + virtual std::basic_string + message () const; + + private: + std::basic_string characters_; + }; + + // + // + template + struct invalid_value: schema_exception + { + virtual + ~invalid_value (); + + invalid_value (const C* type, const std::basic_string& value); + + invalid_value (const C* type, const ro_string& value); + + invalid_value (const std::basic_string& type, + const std::basic_string& value); + + const std::basic_string& + type () const + { + return type_; + } + + const std::basic_string& + value () const + { + return value_; + } + + virtual std::basic_string + message () const; + + private: + std::basic_string type_; + std::basic_string value_; + }; + } + } + } +} + +#include + +#endif // LIBXSD_CXX_PARSER_VALIDATING_EXCEPTIONS_HXX + +#include diff --git a/libxsd/libxsd/cxx/parser/validating/exceptions.ixx b/libxsd/libxsd/cxx/parser/validating/exceptions.ixx new file mode 100644 index 0000000..b55fa31 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/validating/exceptions.ixx @@ -0,0 +1,161 @@ +// file : libxsd/cxx/parser/validating/exceptions.ixx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#if defined(XSD_CXX_PARSER_USE_CHAR) || !defined(XSD_CXX_PARSER_USE_WCHAR) + +#ifndef XSD_CXX_PARSER_VALIDATING_EXCEPTIONS_IXX_CHAR +#define XSD_CXX_PARSER_VALIDATING_EXCEPTIONS_IXX_CHAR + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace validating + { + // expected_attribute + // + template<> + inline + std::basic_string expected_attribute:: + message () const + { + std::basic_string r ("expected attribute '"); + r += expected_namespace_; + r += expected_namespace_.empty () ? "" : "#"; + r += expected_name_; + r += "'"; + return r; + } + + // unexpected_attribute + // + template<> + inline + std::basic_string unexpected_attribute:: + message () const + { + std::basic_string r ("unexpected attribute '"); + r += encountered_namespace_; + r += encountered_namespace_.empty () ? "" : "#"; + r += encountered_name_; + r += "'"; + return r; + } + + // unexpected_characters + // + template<> + inline + std::basic_string unexpected_characters:: + message () const + { + std::basic_string r ("unexpected characters '"); + r += characters_; + r += "'"; + return r; + } + + // invalid_value + // + template<> + inline + std::basic_string invalid_value:: + message () const + { + std::basic_string r ("'"); + r += value_; + r += "' is not a valid value representation "; + r += "for type '"; + r += type_; + r += "'"; + return r; + } + } + } + } +} + +#endif // XSD_CXX_PARSER_VALIDATING_EXCEPTIONS_IXX_CHAR +#endif // XSD_CXX_PARSER_USE_CHAR + + +#if defined(XSD_CXX_PARSER_USE_WCHAR) || !defined(XSD_CXX_PARSER_USE_CHAR) + +#ifndef XSD_CXX_PARSER_VALIDATING_EXCEPTIONS_IXX_WCHAR +#define XSD_CXX_PARSER_VALIDATING_EXCEPTIONS_IXX_WCHAR + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace validating + { + // expected_attribute + // + template<> + inline + std::basic_string expected_attribute:: + message () const + { + std::basic_string r (L"expected attribute '"); + r += expected_namespace_; + r += expected_namespace_.empty () ? L"" : L"#"; + r += expected_name_; + r += L"'"; + return r; + } + + // unexpected_attribute + // + template<> + inline + std::basic_string unexpected_attribute:: + message () const + { + std::basic_string r (L"unexpected attribute '"); + r += encountered_namespace_; + r += encountered_namespace_.empty () ? L"" : L"#"; + r += encountered_name_; + r += L"'"; + return r; + } + + // unexpected_characters + // + template<> + inline + std::basic_string unexpected_characters:: + message () const + { + std::basic_string r (L"unexpected characters '"); + r += characters_; + r += L"'"; + return r; + } + + // invalid_value + // + template<> + inline + std::basic_string invalid_value:: + message () const + { + std::basic_string r (L"'"); + r += value_; + r += L"' is not a valid value representation "; + r += L"for type '"; + r += type_; + r += L"'"; + return r; + } + } + } + } +} + +#endif // XSD_CXX_PARSER_VALIDATING_EXCEPTIONS_IXX_WCHAR +#endif // XSD_CXX_PARSER_USE_WCHAR diff --git a/libxsd/libxsd/cxx/parser/validating/exceptions.txx b/libxsd/libxsd/cxx/parser/validating/exceptions.txx new file mode 100644 index 0000000..509d795 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/validating/exceptions.txx @@ -0,0 +1,95 @@ +// file : libxsd/cxx/parser/validating/exceptions.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace validating + { + // expected_attribute + // + template + expected_attribute:: + ~expected_attribute () + { + } + + template + expected_attribute:: + expected_attribute (const std::basic_string& expected_namespace, + const std::basic_string& expected_name) + : expected_namespace_ (expected_namespace), + expected_name_ (expected_name) + { + } + + // unexpected_attribute + // + template + unexpected_attribute:: + ~unexpected_attribute () + { + } + + template + unexpected_attribute:: + unexpected_attribute (const std::basic_string& encountered_namespace, + const std::basic_string& encountered_name) + : encountered_namespace_ (encountered_namespace), + encountered_name_ (encountered_name) + { + } + + // unexpected_characters + // + template + unexpected_characters:: + ~unexpected_characters () + { + } + + template + unexpected_characters:: + unexpected_characters (const std::basic_string& s) + : characters_ (s) + { + } + + // invalid_value + // + template + invalid_value:: + ~invalid_value () + { + } + + template + invalid_value:: + invalid_value (const C* type, + const std::basic_string& value) + : type_ (type), value_ (value) + { + } + + template + invalid_value:: + invalid_value (const C* type, + const ro_string& value) + : type_ (type), value_ (value) + { + } + + template + invalid_value:: + invalid_value (const std::basic_string& type, + const std::basic_string& value) + : type_ (type), value_ (value) + { + } + } + } + } +} diff --git a/libxsd/libxsd/cxx/parser/validating/inheritance-map.hxx b/libxsd/libxsd/cxx/parser/validating/inheritance-map.hxx new file mode 100644 index 0000000..759e074 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/validating/inheritance-map.hxx @@ -0,0 +1,99 @@ +// file : libxsd/cxx/parser/validating/inheritance-map.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_PARSER_VALIDATING_INHERITANCE_MAP_HXX +#define LIBXSD_CXX_PARSER_VALIDATING_INHERITANCE_MAP_HXX + +#include +#include // std::size_t + +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace validating + { + template + struct string_comparison + { + bool + operator() (const C* x, const C* y) const + { + ro_string s (x); + return s.compare (y) < 0; + } + }; + + template + struct inheritance_map + { + void + insert (const C* derived, const C* base) + { + map_[derived] = base; + } + + void + erase (const C* derived) + { + map_.erase (derived); + } + + bool + check (const C* derived, const ro_string& base) const; + + private: + typedef std::map > map; + map map_; + }; + + + // Translation unit initializer. + // + template + struct inheritance_map_init + { + static inheritance_map* map; + static std::size_t count; + + inheritance_map_init (); + ~inheritance_map_init (); + }; + + template + inheritance_map* inheritance_map_init::map = 0; + + template + std::size_t inheritance_map_init::count = 0; + + template + inline inheritance_map& + inheritance_map_instance () + { + return *inheritance_map_init::map; + } + + + // Map entry initializer. + // + template + struct inheritance_map_entry + { + inheritance_map_entry (const C* derived, const C* base); + ~inheritance_map_entry (); + + private: + const C* derived_; + }; + } + } + } +} + +#include + +#endif // LIBXSD_CXX_PARSER_VALIDATING_INHERITANCE_MAP_HXX diff --git a/libxsd/libxsd/cxx/parser/validating/inheritance-map.txx b/libxsd/libxsd/cxx/parser/validating/inheritance-map.txx new file mode 100644 index 0000000..418d685 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/validating/inheritance-map.txx @@ -0,0 +1,71 @@ +// file : libxsd/cxx/parser/validating/inheritance-map.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace validating + { + template + bool inheritance_map:: + check (const C* derived, const ro_string& base) const + { + if (base == derived) + return true; + + typename map::const_iterator i (map_.find (derived)); + + if (i != map_.end ()) + { + if (base == i->second) + return true; + else + return check (i->second, base); + } + + return false; + } + + // inheritance_map_init + // + template + inheritance_map_init:: + inheritance_map_init () + { + if (count == 0) + map = new inheritance_map; + + ++count; + } + + template + inheritance_map_init:: + ~inheritance_map_init () + { + if (--count == 0) + delete map; + } + + // inheritance_map_entry + // + template + inheritance_map_entry:: + inheritance_map_entry (const C* derived, const C* base) + : derived_ (derived) + { + inheritance_map_instance ().insert (derived, base); + } + + template + inheritance_map_entry:: + ~inheritance_map_entry () + { + inheritance_map_instance ().erase (derived_); + } + } + } + } +} diff --git a/libxsd/libxsd/cxx/parser/validating/parser.hxx b/libxsd/libxsd/cxx/parser/validating/parser.hxx new file mode 100644 index 0000000..024bb95 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/validating/parser.hxx @@ -0,0 +1,469 @@ +// file : libxsd/cxx/parser/validating/parser.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_PARSER_VALIDATING_PARSER_HXX +#define LIBXSD_CXX_PARSER_VALIDATING_PARSER_HXX + +#include +#include // std::size_t +#include // std::memcpy + +#include +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace validating + { + // + // + template + struct empty_content: parser_base + { + // These functions are called when wildcard content + // is encountered. Use them to handle mixed content + // models, any/anyAttribute, and anyType/anySimpleType. + // By default these functions do nothing. + // + + // The type argument is a type name and namespace from the + // xsi:type attribute in the form " " with + // the space and namespace part absent if the type does not + // have a namespace or 0 if xsi:type is not present. + // + virtual void + _start_any_element (const ro_string& ns, + const ro_string& name, + const ro_string* type); + + virtual void + _end_any_element (const ro_string& ns, + const ro_string& name); + + virtual void + _any_attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value); + + virtual void + _any_characters (const ro_string&); + + + // + // + 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&); + + virtual bool + _attribute_impl (const ro_string&, + const ro_string&, + const ro_string&); + + virtual bool + _characters_impl (const ro_string&); + + + // + // + virtual void + _start_element (const ro_string&, + const ro_string&, + const ro_string*); + + virtual void + _end_element (const ro_string&, + const ro_string&); + + virtual void + _attribute (const ro_string&, + const ro_string&, + const ro_string&); + + virtual void + _characters (const ro_string&); + + + // + // + virtual void + _expected_element (const C* expected_ns, + const C* expected_name); + + virtual void + _expected_element (const C* expected_ns, + const C* expected_name, + const ro_string& encountered_ns, + const ro_string& encountered_name); + + virtual void + _unexpected_element (const ro_string& ns, + const ro_string& name); + + virtual void + _expected_attribute (const C* expected_ns, + const C* expected_name); + + virtual void + _unexpected_attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value); + + virtual void + _unexpected_characters (const ro_string&); + }; + + + // + // + template + struct simple_content: empty_content + { + // + // + virtual void + _attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value); + + virtual void + _characters (const ro_string&); + + // + // + virtual bool + _attribute_impl (const ro_string&, + const ro_string&, + const ro_string&); + + // + // + virtual void + _pre_impl (); + + virtual void + _post_impl (); + + + // Implementation callbacks. + // + virtual void + _pre_a_validate (); + + virtual void + _post_a_validate (); + + + // Attribute validation: during phase one we are searching for + // matching attributes (Structures, section 3.4.4, clause 2.1). + // During phase two we are searching for attribute wildcards + // (section 3.4.4, clause 2.2). Both phases run across + // inheritance hierarchy from derived to base for extension + // only. Both functions return true if the match was found and + // validation has been performed. + // + virtual bool + _attribute_impl_phase_one (const ro_string& ns, + const ro_string& name, + const ro_string& value); + + virtual bool + _attribute_impl_phase_two (const ro_string& ns, + const ro_string& name, + const ro_string& value); + }; + + + // + // + template + struct complex_content: empty_content + { + // + // + virtual void + _start_element (const ro_string& ns, + const ro_string& name, + const ro_string* type); + + virtual void + _end_element (const ro_string& ns, + const ro_string& name); + + virtual void + _attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value); + + virtual void + _characters (const ro_string&); + + // + // + virtual bool + _attribute_impl (const ro_string&, + const ro_string&, + const ro_string&); + + // + // + virtual void + _pre_impl (); + + virtual void + _post_impl (); + + + // Implementation callbacks. + // + virtual void + _pre_e_validate (); + + virtual void + _post_e_validate (); + + virtual void + _pre_a_validate (); + + virtual void + _post_a_validate (); + + + // Attribute validation: during phase one we are searching for + // matching attributes (Structures, section 3.4.4, clause 2.1). + // During phase two we are searching for attribute wildcards + // (section 3.4.4, clause 2.2). Both phases run across + // inheritance hierarchy from derived to base for extension + // only. Both functions return true if the match was found and + // validation has been performed. + // + virtual bool + _attribute_impl_phase_one (const ro_string& ns, + const ro_string& name, + const ro_string& value); + + virtual bool + _attribute_impl_phase_two (const ro_string& ns, + const ro_string& name, + const ro_string& value); + protected: + struct state + { + state () + : any_ (false), depth_ (0), parser_ (0) + { + } + + bool any_; + std::size_t depth_; + parser_base* parser_; + }; + + // Optimized state stack for non-recursive case (one element). + // + struct state_stack + { + state_stack () + : size_ (0) + { + } + + void + push (const state& s) + { + if (size_ > 0) + rest_.push (top_); + + top_ = s; + ++size_; + } + + void + pop () + { + if (size_ > 1) + { + top_ = rest_.top (); + rest_.pop (); + } + + --size_; + } + + const state& + top () const + { + return top_; + } + + state& + top () + { + return top_; + } + + state& + under_top () + { + return rest_.top (); + } + + private: + state top_; + std::stack rest_; + std::size_t size_; + }; + + state_stack context_; + }; + + // Base for xsd:list. + // + template + struct list_base: simple_content + { + virtual void + _xsd_parse_item (const ro_string&) = 0; + + virtual void + _pre_impl (); + + virtual void + _characters (const ro_string&); + + virtual void + _post_impl (); + + protected: + std::basic_string buf_; + }; + } + + // POD stack with pre-allocated first element. You may + // need to pad your elements to get the proper alignment. + // + struct pod_stack + { + ~pod_stack () + { + delete[] data_; + } + + pod_stack (std::size_t element_size, void* first_element) + : el_size_ (element_size), first_ (first_element), + data_ (0), size_ (0), capacity_ (0) + { + } + + public: + void + pop () + { + --size_; + } + + void + push () + { + if (size_ > capacity_) + grow (); + + ++size_; + } + + void* + top () + { + return size_ == 1 ? first_ : data_ + (size_ - 1) * el_size_; + } + + void* + under_top () + { + return size_ == 2 ? first_ : data_ + (size_ - 2) * el_size_; + } + + std::size_t + element_size () const + { + return el_size_; + } + + private: + void + grow () + { + std::size_t c (capacity_ ? capacity_ * 2 : 8); + char* d (new char[c * el_size_]); + + if (size_ > 1) + std::memcpy (d, data_, (size_ - 1) * el_size_); + + delete[] data_; + + data_ = d; + capacity_ = c; + } + + private: + std::size_t el_size_; + void* first_; + char* data_; + std::size_t size_; + std::size_t capacity_; + }; + + namespace validating + { + // Validation state stack for the 'all' particle. + // + struct all_stack + { + all_stack (std::size_t n, unsigned char* first) + : stack_ (n, first) + { + } + + void + push () + { + stack_.push (); + + unsigned char* p (static_cast (stack_.top ())); + + for (std::size_t i (0); i < stack_.element_size (); ++i) + p[i] = 0; + } + + void + pop () + { + stack_.pop (); + } + + unsigned char* + top () + { + return static_cast (stack_.top ()); + } + + private: + pod_stack stack_; + }; + } + } + } +} + +#include + +#endif // LIBXSD_CXX_PARSER_VALIDATING_PARSER_HXX diff --git a/libxsd/libxsd/cxx/parser/validating/parser.txx b/libxsd/libxsd/cxx/parser/validating/parser.txx new file mode 100644 index 0000000..2f108e3 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/validating/parser.txx @@ -0,0 +1,665 @@ +// file : libxsd/cxx/parser/validating/parser.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace validating + { + + // empty_content + // + + + template + void empty_content:: + _start_any_element (const ro_string&, + const ro_string&, + const ro_string*) + { + } + + template + void empty_content:: + _end_any_element (const ro_string&, + const ro_string&) + { + } + + template + void empty_content:: + _any_attribute (const ro_string&, + const ro_string&, + const ro_string&) + { + } + + template + void empty_content:: + _any_characters (const ro_string&) + { + } + + // + // + template + bool empty_content:: + _start_element_impl (const ro_string&, + const ro_string&, + const ro_string*) + { + return false; + } + + template + bool empty_content:: + _end_element_impl (const ro_string&, + const ro_string&) + { + return false; + } + + template + bool empty_content:: + _attribute_impl (const ro_string&, + const ro_string&, + const ro_string&) + { + return false; + } + + template + bool empty_content:: + _characters_impl (const ro_string&) + { + return false; + } + + // + // + template + void empty_content:: + _start_element (const ro_string& ns, + const ro_string& name, + const ro_string* type) + { + if (!this->_start_element_impl (ns, name, type)) + this->_unexpected_element (ns, name); + } + + template + void empty_content:: + _end_element (const ro_string& ns, + const ro_string& name) + { + if (!this->_end_element_impl (ns, name)) + this->_unexpected_element (ns, name); + } + + template + void empty_content:: + _attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value) + { + // Weed out special attributes: xsi:type, xsi:nil, + // xsi:schemaLocation and noNamespaceSchemaLocation. + // See section 3.2.7 in Structures for details. + // + if (ns == xml::bits::xsi_namespace () && + (name == xml::bits::type () || + name == xml::bits::nil_lit () || + name == xml::bits::schema_location () || + name == xml::bits::no_namespace_schema_location ())) + return; + + // Also some parsers (notably Xerces-C++) supplies us with + // namespace-prefix mapping attributes. + // + if (ns == xml::bits::xmlns_namespace ()) + return; + + if (!this->_attribute_impl (ns, name, value)) + this->_unexpected_attribute (ns, name, value); + } + + template + void empty_content:: + _characters (const ro_string& s) + { + if (!this->_characters_impl (s)) + this->_unexpected_characters (s); + } + + // + // + template + void empty_content:: + _expected_element (const C* ex_ns, const C* ex_name) + { + throw expected_element (ex_ns, ex_name); + } + + template + void empty_content:: + _expected_element (const C* ex_ns, + const C* ex_name, + const ro_string& en_ns, + const ro_string& en_name) + { + throw expected_element (ex_ns, ex_name, en_ns, en_name); + } + + template + void empty_content:: + _unexpected_element (const ro_string& ns, + const ro_string& name) + { + throw unexpected_element (ns, name); + } + + template + void empty_content:: + _expected_attribute (const C* ex_ns, const C* ex_name) + { + throw expected_attribute (ex_ns, ex_name); + } + + template + void empty_content:: + _unexpected_attribute (const ro_string& ns, + const ro_string& name, + const ro_string&) + { + throw unexpected_attribute (ns, name); + } + + template + void empty_content:: + _unexpected_characters (const ro_string& s) + { + throw unexpected_characters (s); + } + + + // simple_content + // + + template + void simple_content:: + _attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value) + { + // Weed out special attributes: xsi:type, xsi:nil, + // xsi:schemaLocation and xsi:noNamespaceSchemaLocation. + // See section 3.2.7 in Structures for details. + // + if (ns == xml::bits::xsi_namespace () && + (name == xml::bits::type () || + name == xml::bits::nil_lit () || + name == xml::bits::schema_location () || + name == xml::bits::no_namespace_schema_location ())) + return; + + // Also some parsers (notably Xerces-C++) supplies us with + // namespace-prefix mapping attributes. + // + if (ns == xml::bits::xmlns_namespace ()) + return; + + if (!this->_attribute_impl (ns, name, value)) + this->_unexpected_attribute (ns, name, value); + } + + template + void simple_content:: + _characters (const ro_string& str) + { + if (!this->_characters_impl (str)) + { + // Mixed content is implemented in the generated code + // by overriding _characters_impl and forwarding to + // _any_characters. + // + + // Scan the string for any non-whitespace characters + // (Structures, section 3.4.4, clause 1.3). + // + for (typename ro_string::size_type i (0), e (str.size ()); + i < e; ++i) + { + C c (str[i]); + + if (c != C (0x20) && // space + c != C (0x0D) && // carriage return + c != C (0x09) && // tab + c != C (0x0A)) + this->_unexpected_characters (str); + } + } + } + + template + void simple_content:: + _pre_impl () + { + this->_pre (); + _pre_a_validate (); + } + + template + void simple_content:: + _post_impl () + { + _post_a_validate (); + this->_post (); + } + + template + void simple_content:: + _pre_a_validate () + { + } + + template + void simple_content:: + _post_a_validate () + { + } + + template + bool simple_content:: + _attribute_impl (const ro_string& ns, + const ro_string& name, + const ro_string& value) + { + return _attribute_impl_phase_one (ns, name, value) || + _attribute_impl_phase_two (ns, name, value); + } + + template + bool simple_content:: + _attribute_impl_phase_one (const ro_string&, + const ro_string&, + const ro_string&) + { + return false; + } + + template + bool simple_content:: + _attribute_impl_phase_two (const ro_string&, + const ro_string&, + const ro_string&) + { + return false; + } + + + // complex_content + // + + + template + void complex_content:: + _start_element (const ro_string& ns, + const ro_string& name, + const ro_string* type) + { + state& s (context_.top ()); + + if (s.depth_++ > 0) + { + if (s.any_) + this->_start_any_element (ns, name, type); + else if (s.parser_) + s.parser_->_start_element (ns, name, type); + } + else + { + if (!this->_start_element_impl (ns, name, type)) + this->_unexpected_element (ns, name); + else if (s.parser_ != 0) + s.parser_->_pre_impl (); + } + } + + template + void complex_content:: + _end_element (const ro_string& ns, + const ro_string& name) + { + // To understand what's going on here it is helpful to think of + // a "total depth" as being the sum of individual depths over + // all elements. + // + + if (context_.top ().depth_ == 0) + { + state& s (context_.under_top ()); // One before last. + + if (--s.depth_ > 0) + { + // Indirect recursion. + // + if (s.parser_) + s.parser_->_end_element (ns, name); + } + else + { + // Direct recursion. + // + assert (this == s.parser_); + + this->_post_impl (); + + if (!this->_end_element_impl (ns, name)) + assert (false); + } + } + else + { + state& s (context_.top ()); + + if (--s.depth_ > 0) + { + if (s.any_) + this->_end_any_element (ns, name); + else if (s.parser_) + s.parser_->_end_element (ns, name); + } + else + { + if (s.parser_ != 0 && !s.any_) + s.parser_->_post_impl (); + + if (!this->_end_element_impl (ns, name)) + this->_unexpected_element (ns, name); + } + } + } + + template + void complex_content:: + _attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value) + { + // Weed out special attributes: xsi:type, xsi:nil, + // xsi:schemaLocation and xsi:noNamespaceSchemaLocation. + // See section 3.2.7 in Structures for details. + // + if (ns == xml::bits::xsi_namespace () && + (name == xml::bits::type () || + name == xml::bits::nil_lit () || + name == xml::bits::schema_location () || + name == xml::bits::no_namespace_schema_location ())) + return; + + // Also some parsers (notably Xerces-C++) supplies us with + // namespace-prefix mapping attributes. + // + if (ns == xml::bits::xmlns_namespace ()) + return; + + const state& s (context_.top ()); + + if (s.depth_ > 0) + { + if (s.any_) + this->_any_attribute (ns, name, value); + else if (s.parser_) + s.parser_->_attribute (ns, name, value); + } + else + { + if (!this->_attribute_impl (ns, name, value)) + this->_unexpected_attribute (ns, name, value); + } + } + + template + void complex_content:: + _characters (const ro_string& str) + { + const state& s (context_.top ()); + + if (s.depth_ > 0) + { + if (s.any_) + this->_any_characters (str); + else if (s.parser_) + s.parser_->_characters (str); + } + else + { + if (!this->_characters_impl (str)) + { + // Mixed content is implemented in the generated code + // by overriding _characters_impl and forwarding to + // _any_characters. + // + + // Scan the string for any non-whitespace characters + // (Structures, section 3.4.4, clause 1.3). + // + for (typename ro_string::size_type i (0), e (str.size ()); + i < e; ++i) + { + C c (str[i]); + + if (c != C (0x20) && // space + c != C (0x0D) && // carriage return + c != C (0x09) && // tab + c != C (0x0A)) + this->_unexpected_characters (str); + } + } + } + } + + template + void complex_content:: + _pre_impl () + { + context_.push (state ()); + this->_pre (); + _pre_a_validate (); + _pre_e_validate (); + } + + template + void complex_content:: + _post_impl () + { + _post_e_validate (); + _post_a_validate (); + this->_post (); + context_.pop (); + } + + template + void complex_content:: + _pre_e_validate () + { + } + + template + void complex_content:: + _post_e_validate () + { + } + + template + void complex_content:: + _pre_a_validate () + { + } + + template + void complex_content:: + _post_a_validate () + { + } + + template + bool complex_content:: + _attribute_impl (const ro_string& ns, + const ro_string& name, + const ro_string& value) + { + return _attribute_impl_phase_one (ns, name, value) || + _attribute_impl_phase_two (ns, name, value); + } + + template + bool complex_content:: + _attribute_impl_phase_one (const ro_string&, + const ro_string&, + const ro_string&) + { + return false; + } + + template + bool complex_content:: + _attribute_impl_phase_two (const ro_string&, + const ro_string&, + const ro_string&) + { + return false; + } + + + // list_base + // + namespace bits + { + // Find first non-space character. + // + template + typename ro_string::size_type + find_ns (const C* s, + typename ro_string::size_type size, + typename ro_string::size_type pos) + { + while (pos < size && + (s[pos] == C (0x20) || s[pos] == C (0x0A) || + s[pos] == C (0x0D) || s[pos] == C (0x09))) + ++pos; + + return pos < size ? pos : ro_string::npos; + } + + // Find first space character. + // + template + typename ro_string::size_type + find_s (const C* s, + typename ro_string::size_type size, + typename ro_string::size_type pos) + { + while (pos < size && + s[pos] != C (0x20) && s[pos] != C (0x0A) && + s[pos] != C (0x0D) && s[pos] != C (0x09)) + ++pos; + + return pos < size ? pos : ro_string::npos; + } + } + + // Relevant XML Schema Part 2: Datatypes sections: 4.2.1.2, 4.3.6. + // + + template + void list_base:: + _pre_impl () + { + simple_content::_pre_impl (); + buf_.clear (); + } + + template + void list_base:: + _characters (const ro_string& s) + { + typedef typename ro_string::size_type size_type; + + const C* data (s.data ()); + size_type size (s.size ()); + + // Handle the previous chunk if we start with a ws. + // + if (!buf_.empty () && + (data[0] == C (0x20) || data[0] == C (0x0A) || + data[0] == C (0x0D) || data[0] == C (0x09))) + { + ro_string tmp (buf_); // Private copy ctor. + _xsd_parse_item (tmp); + buf_.clear (); + } + + // Traverse the data while logically collapsing spaces. + // + for (size_type i (bits::find_ns (data, size, 0)); + i != ro_string::npos;) + { + size_type j (bits::find_s (data, size, i)); + + if (j != ro_string::npos) + { + if (buf_.empty ()) + { + ro_string tmp (data + i, j - i); // Private copy ctor. + _xsd_parse_item (tmp); + } + else + { + // Assemble the first item in str from buf_ and s. + // + std::basic_string str; + str.swap (buf_); + str.append (data + i, j - i); + ro_string tmp (str); // Private copy ctor. + _xsd_parse_item (tmp); + } + + i = bits::find_ns (data, size, j); + } + else + { + // Last fragment, append it to the buf_. + // + buf_.append (data + i, size - i); + break; + } + } + } + + template + void list_base:: + _post_impl () + { + // Handle the last item. + // + if (!buf_.empty ()) + { + ro_string tmp (buf_); // Private copy ctor. + _xsd_parse_item (tmp); + } + + simple_content::_post_impl (); + } + } + } + } +} diff --git a/libxsd/libxsd/cxx/parser/validating/xml-schema-pimpl.hxx b/libxsd/libxsd/cxx/parser/validating/xml-schema-pimpl.hxx new file mode 100644 index 0000000..9b84969 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/validating/xml-schema-pimpl.hxx @@ -0,0 +1,1121 @@ +// file : libxsd/cxx/parser/validating/xml-schema-pimpl.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PIMPL_HXX +#define LIBXSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PIMPL_HXX + +#include + +#include // XSD_AUTO_PTR + +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace validating + { + // any_type + // + template + struct any_type_pimpl: virtual any_type_pskel + { + virtual void + post_any_type (); + }; + + // any_simple_type + // + template + struct any_simple_type_pimpl: virtual any_simple_type_pskel + { + virtual void + post_any_simple_type (); + }; + + // boolean + // + template + struct boolean_pimpl: virtual boolean_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual bool + post_boolean (); + + protected: + std::basic_string str_; + bool value_; + }; + + + // 8-bit + // + template + struct byte_pimpl: virtual byte_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual signed char + post_byte (); + + protected: + std::basic_string str_; + signed char value_; + }; + + + template + struct unsigned_byte_pimpl: virtual unsigned_byte_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual unsigned char + post_unsigned_byte (); + + protected: + std::basic_string str_; + unsigned char value_; + }; + + + // 16-bit + // + template + struct short_pimpl: virtual short_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual short + post_short (); + + protected: + std::basic_string str_; + short value_; + }; + + + template + struct unsigned_short_pimpl: virtual unsigned_short_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual unsigned short + post_unsigned_short (); + + protected: + std::basic_string str_; + unsigned short value_; + }; + + + // 32-bit + // + template + struct int_pimpl: virtual int_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual int + post_int (); + + protected: + std::basic_string str_; + int value_; + }; + + + template + struct unsigned_int_pimpl: virtual unsigned_int_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual unsigned int + post_unsigned_int (); + + protected: + std::basic_string str_; + unsigned int value_; + }; + + + // 64-bit + // + template + struct long_pimpl: virtual long_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual long long + post_long (); + + protected: + std::basic_string str_; + long long value_; + }; + + + template + struct unsigned_long_pimpl: virtual unsigned_long_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual unsigned long long + post_unsigned_long (); + + protected: + std::basic_string str_; + unsigned long long value_; + }; + + + // Arbitrary-length integers. + // + template + struct integer_pimpl: virtual integer_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual long long + post_integer (); + + protected: + std::basic_string str_; + long long value_; + }; + + template + struct negative_integer_pimpl: virtual negative_integer_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual long long + post_negative_integer (); + + protected: + std::basic_string str_; + long long value_; + }; + + template + struct non_positive_integer_pimpl: virtual non_positive_integer_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual long long + post_non_positive_integer (); + + protected: + std::basic_string str_; + long long value_; + }; + + template + struct positive_integer_pimpl: virtual positive_integer_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual unsigned long long + post_positive_integer (); + + protected: + std::basic_string str_; + unsigned long long value_; + }; + + template + struct non_negative_integer_pimpl: virtual non_negative_integer_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual unsigned long long + post_non_negative_integer (); + + protected: + std::basic_string str_; + unsigned long long value_; + }; + + + // Floats. + // + template + struct float_pimpl: virtual float_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual float + post_float (); + + protected: + std::basic_string str_; + float value_; + }; + + + template + struct double_pimpl: virtual double_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual double + post_double (); + + protected: + std::basic_string str_; + double value_; + }; + + + template + struct decimal_pimpl: virtual decimal_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual double + post_decimal (); + + protected: + std::basic_string str_; + double value_; + }; + + + // Strings. + // + template + struct string_pimpl: virtual string_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::basic_string + post_string (); + + protected: + std::basic_string str_; + }; + + template + struct normalized_string_pimpl: virtual normalized_string_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::basic_string + post_normalized_string (); + + protected: + std::basic_string str_; + }; + + template + struct token_pimpl: virtual token_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::basic_string + post_token (); + + protected: + std::basic_string str_; + }; + + template + struct name_pimpl: virtual name_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual std::basic_string + post_name (); + + protected: + std::basic_string str_; + }; + + template + struct nmtoken_pimpl: virtual nmtoken_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual std::basic_string + post_nmtoken (); + + protected: + std::basic_string str_; + }; + + template + struct nmtokens_pimpl: virtual nmtokens_pskel + { + virtual void + _pre (); + + virtual void + _xsd_parse_item (const ro_string&); + + virtual void + _post (); + + virtual string_sequence + post_nmtokens (); + + protected: + string_sequence seq_; + nmtoken_pimpl parser_; + }; + + template + struct ncname_pimpl: virtual ncname_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual std::basic_string + post_ncname (); + + protected: + std::basic_string str_; + }; + + template + struct id_pimpl: virtual id_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual std::basic_string + post_id (); + + protected: + std::basic_string str_; + }; + + template + struct idref_pimpl: virtual idref_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual std::basic_string + post_idref (); + + protected: + std::basic_string str_; + }; + + template + struct idrefs_pimpl: virtual idrefs_pskel + { + virtual void + _pre (); + + virtual void + _xsd_parse_item (const ro_string&); + + virtual void + _post (); + + virtual string_sequence + post_idrefs (); + + protected: + string_sequence seq_; + idref_pimpl parser_; + }; + + // language + // + template + struct language_pimpl: virtual language_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual std::basic_string + post_language (); + + protected: + std::basic_string str_; + }; + + // anyURI + // + template + struct uri_pimpl: virtual uri_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::basic_string + post_uri (); + + protected: + std::basic_string str_; + }; + + // QName + // + template + struct qname_pimpl: virtual qname_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual qname + post_qname (); + + protected: + std::basic_string str_; + std::basic_string name_; + std::basic_string prefix_; + }; + + // base64Binary + // + template + struct base64_binary_pimpl: virtual base64_binary_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual XSD_AUTO_PTR + post_base64_binary (); + + protected: + std::basic_string str_; + XSD_AUTO_PTR buf_; + }; + + // hexBinary + // + template + struct hex_binary_pimpl: virtual hex_binary_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual XSD_AUTO_PTR + post_hex_binary (); + + protected: + std::basic_string str_; + XSD_AUTO_PTR buf_; + }; + + // gday + // + template + struct gday_pimpl: virtual gday_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual gday + post_gday (); + + protected: + std::basic_string str_; + unsigned short day_; + bool z_; + short zh_, zm_; + }; + + // gmonth + // + template + struct gmonth_pimpl: virtual gmonth_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual gmonth + post_gmonth (); + + protected: + std::basic_string str_; + unsigned short month_; + bool z_; + short zh_, zm_; + }; + + // gyear + // + template + struct gyear_pimpl: virtual gyear_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual gyear + post_gyear (); + + protected: + std::basic_string str_; + int year_; + bool z_; + short zh_, zm_; + }; + + // gmonth_day + // + template + struct gmonth_day_pimpl: virtual gmonth_day_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual gmonth_day + post_gmonth_day (); + + protected: + std::basic_string str_; + unsigned short month_; + unsigned short day_; + bool z_; + short zh_, zm_; + }; + + // gyear_month + // + template + struct gyear_month_pimpl: virtual gyear_month_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual gyear_month + post_gyear_month (); + + protected: + std::basic_string str_; + int year_; + unsigned short month_; + bool z_; + short zh_, zm_; + }; + + // date + // + template + struct date_pimpl: virtual date_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual date + post_date (); + + protected: + std::basic_string str_; + int year_; + unsigned short month_; + unsigned short day_; + bool z_; + short zh_, zm_; + }; + + // time + // + template + struct time_pimpl: virtual time_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual time + post_time (); + + protected: + std::basic_string str_; + unsigned short hours_; + unsigned short minutes_; + double seconds_; + bool z_; + short zh_, zm_; + }; + + // date_time + // + template + struct date_time_pimpl: virtual date_time_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual date_time + post_date_time (); + + protected: + std::basic_string str_; + int year_; + unsigned short month_; + unsigned short day_; + unsigned short hours_; + unsigned short minutes_; + double seconds_; + bool z_; + short zh_, zm_; + }; + + // duration + // + template + struct duration_pimpl: virtual duration_pskel + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual void + _post (); + + virtual duration + post_duration (); + + protected: + std::basic_string str_; + bool negative_; + unsigned int years_; + unsigned int months_; + unsigned int days_; + unsigned int hours_; + unsigned int minutes_; + double seconds_; + }; + + // Literals. + // + namespace bits + { + template + const C* + boolean (); + + template + const C* + byte (); + + template + const C* + unsigned_byte (); + + template + const C* + short_ (); + + template + const C* + unsigned_short (); + + template + const C* + int_ (); + + template + const C* + unsigned_int (); + + template + const C* + long_ (); + + template + const C* + unsigned_long (); + + template + const C* + integer (); + + template + const C* + negative_integer (); + + template + const C* + non_positive_integer (); + + template + const C* + non_negative_integer (); + + template + const C* + positive_integer (); + + template + const C* + float_ (); + + template + const C* + double_ (); + + template + const C* + decimal (); + + template + const C* + name (); + + template + const C* + nmtoken (); + + template + const C* + nmtokens (); + + template + const C* + ncname (); + + template + const C* + id (); + + template + const C* + idref (); + + template + const C* + idrefs (); + + template + const C* + language (); + + template + const C* + qname (); + + template + const C* + base64_binary (); + + template + const C* + hex_binary (); + + template + const C* + gday (); + + template + const C* + gmonth (); + + template + const C* + gyear (); + + template + const C* + gmonth_day (); + + template + const C* + gyear_month (); + + template + const C* + date (); + + template + const C* + time (); + + template + const C* + date_time (); + + template + const C* + duration (); + + // float literals: INF -INF NaN + // + template + const C* + positive_inf (); + + template + const C* + negative_inf (); + + template + const C* + nan (); + + // boolean literals + // + template + const C* + true_ (); + + template + const C* + false_ (); + + template + const C* + one (); + + template + const C* + zero (); + } + } + } + } +} + +#include + +#endif // LIBXSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PIMPL_HXX + +#include diff --git a/libxsd/libxsd/cxx/parser/validating/xml-schema-pimpl.ixx b/libxsd/libxsd/cxx/parser/validating/xml-schema-pimpl.ixx new file mode 100644 index 0000000..f06ea31 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/validating/xml-schema-pimpl.ixx @@ -0,0 +1,674 @@ +// file : libxsd/cxx/parser/validating/xml-schema-pimpl.ixx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#if defined(XSD_CXX_PARSER_USE_CHAR) || !defined(XSD_CXX_PARSER_USE_WCHAR) + +#ifndef XSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PIMPL_IXX_CHAR +#define XSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PIMPL_IXX_CHAR + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace validating + { + namespace bits + { + template<> + inline const char* + boolean () + { + return "boolean"; + } + + template<> + inline const char* + byte () + { + return "byte"; + } + + template<> + inline const char* + unsigned_byte () + { + return "unsignedByte"; + } + + template<> + inline const char* + short_ () + { + return "short"; + } + + template<> + inline const char* + unsigned_short () + { + return "unsignedShort"; + } + + template<> + inline const char* + int_ () + { + return "int"; + } + + template<> + inline const char* + unsigned_int () + { + return "unsignedInt"; + } + + template<> + inline const char* + long_ () + { + return "long"; + } + + template<> + inline const char* + unsigned_long () + { + return "unsignedLong"; + } + + template<> + inline const char* + integer () + { + return "integer"; + } + + template<> + inline const char* + negative_integer () + { + return "negativeInteger"; + } + + template<> + inline const char* + non_positive_integer () + { + return "nonPositiveInteger"; + } + + template<> + inline const char* + non_negative_integer () + { + return "nonNegativeInteger"; + } + + template<> + inline const char* + positive_integer () + { + return "positiveInteger"; + } + + template<> + inline const char* + float_ () + { + return "float"; + } + + template<> + inline const char* + double_ () + { + return "double"; + } + + template<> + inline const char* + decimal () + { + return "decimal"; + } + + template<> + inline const char* + name () + { + return "Name"; + } + + template<> + inline const char* + nmtoken () + { + return "NMTOKEN"; + } + + template<> + inline const char* + nmtokens () + { + return "NMTOKENS"; + } + + template<> + inline const char* + ncname () + { + return "NCName"; + } + + template<> + inline const char* + id () + { + return "ID"; + } + + template<> + inline const char* + idref () + { + return "IDREF"; + } + + template<> + inline const char* + idrefs () + { + return "IDREFS"; + } + + template<> + inline const char* + language () + { + return "language"; + } + + template<> + inline const char* + qname () + { + return "QName"; + } + + template<> + inline const char* + base64_binary () + { + return "base64Binary"; + } + + template<> + inline const char* + hex_binary () + { + return "hexBinary"; + } + + template<> + inline const char* + gday () + { + return "gDay"; + } + + template<> + inline const char* + gmonth () + { + return "gMonth"; + } + + template<> + inline const char* + gyear () + { + return "gYear"; + } + + template<> + inline const char* + gmonth_day () + { + return "gMonthDay"; + } + + template<> + inline const char* + gyear_month () + { + return "gYearMonth"; + } + + template<> + inline const char* + date () + { + return "date"; + } + + template<> + inline const char* + time () + { + return "time"; + } + + template<> + inline const char* + date_time () + { + return "dateTime"; + } + + template<> + inline const char* + duration () + { + return "duration"; + } + + // + // + template<> + inline const char* + positive_inf () + { + return "INF"; + } + + template<> + inline const char* + negative_inf () + { + return "-INF"; + } + + template<> + inline const char* + nan () + { + return "NaN"; + } + + // + // + template<> + inline const char* + true_ () + { + return "true"; + } + + template<> + inline const char* + false_ () + { + return "false"; + } + + template<> + inline const char* + one () + { + return "1"; + } + + template<> + inline const char* + zero () + { + return "0"; + } + } + } + } + } +} + +#endif // XSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PIMPL_IXX_CHAR +#endif // XSD_CXX_PARSER_USE_CHAR + + +#if defined(XSD_CXX_PARSER_USE_WCHAR) || !defined(XSD_CXX_PARSER_USE_CHAR) + +#ifndef XSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PIMPL_IXX_WCHAR +#define XSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PIMPL_IXX_WCHAR + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace validating + { + namespace bits + { + template<> + inline const wchar_t* + boolean () + { + return L"boolean"; + } + + template<> + inline const wchar_t* + byte () + { + return L"byte"; + } + + template<> + inline const wchar_t* + unsigned_byte () + { + return L"unsignedByte"; + } + + template<> + inline const wchar_t* + short_ () + { + return L"short"; + } + + template<> + inline const wchar_t* + unsigned_short () + { + return L"unsignedShort"; + } + + template<> + inline const wchar_t* + int_ () + { + return L"int"; + } + + template<> + inline const wchar_t* + unsigned_int () + { + return L"unsignedInt"; + } + + template<> + inline const wchar_t* + long_ () + { + return L"long"; + } + + template<> + inline const wchar_t* + unsigned_long () + { + return L"unsignedLong"; + } + + template<> + inline const wchar_t* + integer () + { + return L"integer"; + } + + template<> + inline const wchar_t* + negative_integer () + { + return L"negativeInteger"; + } + + template<> + inline const wchar_t* + non_positive_integer () + { + return L"nonPositiveInteger"; + } + + template<> + inline const wchar_t* + non_negative_integer () + { + return L"nonNegativeInteger"; + } + + template<> + inline const wchar_t* + positive_integer () + { + return L"positiveInteger"; + } + + template<> + inline const wchar_t* + float_ () + { + return L"float"; + } + + template<> + inline const wchar_t* + double_ () + { + return L"double"; + } + + template<> + inline const wchar_t* + decimal () + { + return L"decimal"; + } + + template<> + inline const wchar_t* + name () + { + return L"Name"; + } + + template<> + inline const wchar_t* + nmtoken () + { + return L"NMTOKEN"; + } + + template<> + inline const wchar_t* + nmtokens () + { + return L"NMTOKENS"; + } + + template<> + inline const wchar_t* + ncname () + { + return L"NCName"; + } + + template<> + inline const wchar_t* + id () + { + return L"ID"; + } + + template<> + inline const wchar_t* + idref () + { + return L"IDREF"; + } + + template<> + inline const wchar_t* + idrefs () + { + return L"IDREFS"; + } + + template<> + inline const wchar_t* + language () + { + return L"language"; + } + + template<> + inline const wchar_t* + qname () + { + return L"QName"; + } + + template<> + inline const wchar_t* + base64_binary () + { + return L"base64Binary"; + } + + template<> + inline const wchar_t* + hex_binary () + { + return L"hexBinary"; + } + + template<> + inline const wchar_t* + gday () + { + return L"gDay"; + } + + template<> + inline const wchar_t* + gmonth () + { + return L"gMonth"; + } + + template<> + inline const wchar_t* + gyear () + { + return L"gYear"; + } + + template<> + inline const wchar_t* + gmonth_day () + { + return L"gMonthDay"; + } + + template<> + inline const wchar_t* + gyear_month () + { + return L"gYearMonth"; + } + + template<> + inline const wchar_t* + date () + { + return L"date"; + } + + template<> + inline const wchar_t* + time () + { + return L"time"; + } + + template<> + inline const wchar_t* + date_time () + { + return L"dateTime"; + } + + template<> + inline const wchar_t* + duration () + { + return L"duration"; + } + + + // + // + template<> + inline const wchar_t* + positive_inf () + { + return L"INF"; + } + + template<> + inline const wchar_t* + negative_inf () + { + return L"-INF"; + } + + template<> + inline const wchar_t* + nan () + { + return L"NaN"; + } + + // + // + template<> + inline const wchar_t* + true_ () + { + return L"true"; + } + + template<> + inline const wchar_t* + false_ () + { + return L"false"; + } + + template<> + inline const wchar_t* + one () + { + return L"1"; + } + + template<> + inline const wchar_t* + zero () + { + return L"0"; + } + } + } + } + } +} + +#endif // XSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PIMPL_IXX_WCHAR +#endif // XSD_CXX_PARSER_USE_WCHAR diff --git a/libxsd/libxsd/cxx/parser/validating/xml-schema-pimpl.txx b/libxsd/libxsd/cxx/parser/validating/xml-schema-pimpl.txx new file mode 100644 index 0000000..0140a8a --- /dev/null +++ b/libxsd/libxsd/cxx/parser/validating/xml-schema-pimpl.txx @@ -0,0 +1,2756 @@ +// file : libxsd/cxx/parser/validating/xml-schema-pimpl.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include + +#ifdef XSD_CXX11 +# include // std::move +#endif + +#include +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace validating + { + // Note that most of the types implemented here cannot have + // whitespaces in the value. 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. + // + + // Character table. + // + namespace bits + { + const unsigned char ncname_mask = 0x1; + const unsigned char name_first_mask = 0x2; + const unsigned char name_mask = 0x4; + + template + struct char_table + { + static C table[0x80]; + }; + + template + C char_table::table[0x80] = + { + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD8, 0xD0, 0x00, 0x00, 0xD0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xD8, 0x48, 0x58, 0x48, 0x48, 0x48, 0x40, 0x58, 0x48, 0x48, 0x48, 0x48, 0x48, 0x4D, 0x4D, 0x58, + 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4E, 0x48, 0x50, 0x48, 0x58, 0x48, + 0x48, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, + 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x48, 0x48, 0x40, 0x48, 0x4F, + 0x48, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, + 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x48, 0x48, 0x48, 0x48, 0x48 + }; + } + + // any_type + // + + template + void any_type_pimpl:: + post_any_type () + { + } + + // any_simple_type + // + + template + void any_simple_type_pimpl:: + post_any_simple_type () + { + } + + // boolean + // + + template + void boolean_pimpl:: + _pre () + { + str_.clear (); + } + + template + void boolean_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + void boolean_pimpl:: + _post () + { + ro_string str (str_); + trim (str); + + if (str == bits::true_ () || str == bits::one ()) + value_ = true; + else if (str == bits::false_ () || str == bits::zero ()) + value_ = false; + else + throw invalid_value (bits::boolean (), str); + } + + template + bool boolean_pimpl:: + post_boolean () + { + return value_; + } + + // byte + // + + template + void byte_pimpl:: + _pre () + { + str_.clear (); + } + + template + void byte_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + void byte_pimpl:: + _post () + { + ro_string str (str_); + trim (str); + + short t; + zc_istream is (str); + + if (is >> t && is.exhausted () && t >= -128 && t <= 127) + value_ = static_cast (t); + else + throw invalid_value (bits::byte (), str); + } + + template + signed char byte_pimpl:: + post_byte () + { + return value_; + } + + // unsigned_byte + // + + template + void unsigned_byte_pimpl:: + _pre () + { + str_.clear (); + } + + template + void unsigned_byte_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + void unsigned_byte_pimpl:: + _post () + { + ro_string str (str_); + trim (str); + + unsigned short t; + zc_istream is (str); + + if (is >> t && is.exhausted () && t <= 255) + value_ = static_cast (t); + else + throw invalid_value (bits::unsigned_byte (), str); + } + + template + unsigned char unsigned_byte_pimpl:: + post_unsigned_byte () + { + return value_; + } + + // short + // + + template + void short_pimpl:: + _pre () + { + str_.clear (); + } + + template + void short_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + void short_pimpl:: + _post () + { + ro_string str (str_); + trim (str); + + zc_istream is (str); + + if (!(is >> value_ && is.exhausted ())) + throw invalid_value (bits::short_ (), str); + } + + template + short short_pimpl:: + post_short () + { + return value_; + } + + + // unsigned_short + // + + template + void unsigned_short_pimpl:: + _pre () + { + str_.clear (); + } + + template + void unsigned_short_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + void unsigned_short_pimpl:: + _post () + { + ro_string str (str_); + trim (str); + + zc_istream is (str); + + if (!(is >> value_ && is.exhausted ())) + throw invalid_value (bits::unsigned_short (), str); + } + + template + unsigned short unsigned_short_pimpl:: + post_unsigned_short () + { + return value_; + } + + // int + // + + template + void int_pimpl:: + _pre () + { + str_.clear (); + } + + template + void int_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + void int_pimpl:: + _post () + { + ro_string str (str_); + trim (str); + + zc_istream is (str); + + if (!(is >> value_ && is.exhausted ())) + throw invalid_value (bits::int_ (), str); + } + + template + int int_pimpl:: + post_int () + { + return value_; + } + + + // unsigned_int + // + + template + void unsigned_int_pimpl:: + _pre () + { + str_.clear (); + } + + template + void unsigned_int_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + void unsigned_int_pimpl:: + _post () + { + ro_string str (str_); + trim (str); + + zc_istream is (str); + + if (!(is >> value_ && is.exhausted ())) + throw invalid_value (bits::unsigned_int (), str); + } + + template + unsigned int unsigned_int_pimpl:: + post_unsigned_int () + { + return value_; + } + + + // long + // + template + void long_pimpl:: + _pre () + { + str_.clear (); + } + + template + void long_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + void long_pimpl:: + _post () + { + ro_string str (str_); + trim (str); + + zc_istream is (str); + + if (!(is >> value_ && is.exhausted ())) + throw invalid_value (bits::long_ (), str); + } + + template + long long long_pimpl:: + post_long () + { + return value_; + } + + // unsigned_long + // + template + void unsigned_long_pimpl:: + _pre () + { + str_.clear (); + } + + template + void unsigned_long_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + void unsigned_long_pimpl:: + _post () + { + ro_string str (str_); + trim (str); + + zc_istream is (str); + + if (!(is >> value_ && is.exhausted ())) + throw invalid_value (bits::unsigned_long (), str); + } + + template + unsigned long long unsigned_long_pimpl:: + post_unsigned_long () + { + return value_; + } + + + // integer + // + template + void integer_pimpl:: + _pre () + { + str_.clear (); + } + + template + void integer_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + void integer_pimpl:: + _post () + { + ro_string str (str_); + trim (str); + + zc_istream is (str); + + if (!(is >> value_ && is.exhausted ())) + throw invalid_value (bits::integer (), str); + } + + template + long long integer_pimpl:: + post_integer () + { + return value_; + } + + // negative_integer + // + template + void negative_integer_pimpl:: + _pre () + { + str_.clear (); + } + + template + void negative_integer_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + void negative_integer_pimpl:: + _post () + { + ro_string str (str_); + trim (str); + + zc_istream is (str); + + if (!(is >> value_ && is.exhausted () && value_ < 0)) + throw invalid_value (bits::negative_integer (), str); + } + + template + long long negative_integer_pimpl:: + post_negative_integer () + { + return value_; + } + + + // non_positive_integer + // + template + void non_positive_integer_pimpl:: + _pre () + { + str_.clear (); + } + + template + void non_positive_integer_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + void non_positive_integer_pimpl:: + _post () + { + ro_string str (str_); + trim (str); + + zc_istream is (str); + + if (!(is >> value_ && is.exhausted () && value_ <= 0)) + throw invalid_value (bits::non_positive_integer (), str); + } + + template + long long non_positive_integer_pimpl:: + post_non_positive_integer () + { + return value_; + } + + // positive_integer + // + template + void positive_integer_pimpl:: + _pre () + { + str_.clear (); + } + + template + void positive_integer_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + void positive_integer_pimpl:: + _post () + { + ro_string str (str_); + trim (str); + + zc_istream is (str); + + if (!(is >> value_ && is.exhausted () && value_ > 0)) + throw invalid_value (bits::positive_integer (), str); + } + + template + unsigned long long positive_integer_pimpl:: + post_positive_integer () + { + return value_; + } + + + // non_negative_integer + // + template + void non_negative_integer_pimpl:: + _pre () + { + str_.clear (); + } + + template + void non_negative_integer_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + void non_negative_integer_pimpl:: + _post () + { + ro_string str (str_); + trim (str); + + zc_istream is (str); + + if (!(is >> value_ && is.exhausted ())) + throw invalid_value (bits::non_negative_integer (), str); + } + + template + unsigned long long non_negative_integer_pimpl:: + post_non_negative_integer () + { + return value_; + } + + + // float + // + template + void float_pimpl:: + _pre () + { + str_.clear (); + } + + template + void float_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + void float_pimpl:: + _post () + { + ro_string str (str_); + trim (str); + + if (str == bits::positive_inf ()) + value_ = std::numeric_limits::infinity (); + else if (str == bits::negative_inf ()) + value_ = -std::numeric_limits::infinity (); + else if (str == bits::nan ()) + value_ = std::numeric_limits::quiet_NaN (); + else + { + zc_istream is (str); + is.imbue (std::locale::classic ()); + + if (!(is >> value_ && is.exhausted ())) + throw invalid_value (bits::float_ (), str); + } + } + + template + float float_pimpl:: + post_float () + { + return value_; + } + + + // double + // + template + void double_pimpl:: + _pre () + { + str_.clear (); + } + + template + void double_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + void double_pimpl:: + _post () + { + ro_string str (str_); + trim (str); + + if (str == bits::positive_inf ()) + value_ = std::numeric_limits::infinity (); + else if (str == bits::negative_inf ()) + value_ = -std::numeric_limits::infinity (); + else if (str == bits::nan ()) + value_ = std::numeric_limits::quiet_NaN (); + else + { + zc_istream is (str); + is.imbue (std::locale::classic ()); + + if (!(is >> value_ && is.exhausted ())) + throw invalid_value (bits::double_ (), str); + } + } + + template + double double_pimpl:: + post_double () + { + return value_; + } + + // decimal + // + template + void decimal_pimpl:: + _pre () + { + str_.clear (); + } + + template + void decimal_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + void decimal_pimpl:: + _post () + { + ro_string str (str_); + trim (str); + + zc_istream is (str); + is.imbue (std::locale::classic ()); + + //@@ TODO: now we accept scientific notations and INF/NaN. + // + if (!(is >> value_ && is.exhausted ())) + throw invalid_value (bits::decimal (), str); + } + + template + double decimal_pimpl:: + post_decimal () + { + return value_; + } + + // string + // + template + void string_pimpl:: + _pre () + { + str_.clear (); + } + + template + void string_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + std::basic_string string_pimpl:: + post_string () + { + std::basic_string r; + r.swap (str_); + return r; + } + + // normalized_string + // + template + void normalized_string_pimpl:: + _pre () + { + str_.clear (); + } + + template + void normalized_string_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + template + std::basic_string normalized_string_pimpl:: + post_normalized_string () + { + typedef typename std::basic_string::size_type size_type; + + size_type size (str_.size ()); + + for (size_type i (0); i < size; ++i) + { + C& c = str_[i]; + + if (c == C (0x0A) || c == C (0x0D) || c == C (0x09)) + c = C (0x20); + } + + std::basic_string r; + r.swap (str_); + return r; + } + + // token + // + template + void token_pimpl:: + _pre () + { + str_.clear (); + } + + template + void token_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + std::basic_string token_pimpl:: + post_token () + { + typedef typename std::basic_string::size_type size_type; + + size_type size (str_.size ()); + size_type j (0); + + bool subs (false); + + for (size_type i (0); i < size; ++i) + { + C c = str_[i]; + + if (c == C (0x20) || c == C (0x0A) || + c == C (0x0D) || c == C (0x09)) + { + subs = true; + } + else + { + if (subs) + { + subs = false; + str_[j++] = C (0x20); + } + + str_[j++] = c; + } + } + + str_.resize (j); + + std::basic_string r; + r.swap (str_); + return r; + } + + // name + // + template + void name_pimpl:: + _pre () + { + str_.clear (); + } + + template + void name_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + void name_pimpl:: + _post () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + + // For now we are only checking the US-ASCII characters. + // + + bool ok (size != 0); + + if (ok) + { + unsigned int c (static_cast (str_[0])); + + ok = c >= 0x80 || + (bits::char_table::table[c] & + bits::name_first_mask); + + if (ok) + { + for (size_type i (1); i < size; ++i) + { + c = static_cast (str_[i]); + + if (c < 0x80 && + !(bits::char_table::table[c] & + bits::name_mask)) + { + ok = false; + break; + } + } + } + } + + if (!ok) + throw invalid_value (bits::name (), tmp); + + str_.resize (size); + } + + template + std::basic_string name_pimpl:: + post_name () + { + std::basic_string r; + r.swap (str_); + return r; + } + + // nmtoken + // + template + void nmtoken_pimpl:: + _pre () + { + str_.clear (); + } + + template + void nmtoken_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + void nmtoken_pimpl:: + _post () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + + // For now we are only checking the US-ASCII characters. + // + + bool ok (size != 0); + + if (ok) + { + for (size_type i (0); i < size; ++i) + { + unsigned int c (static_cast (str_[i])); + + if (c < 0x80 && + !(bits::char_table::table[c] & + bits::name_mask)) + { + ok = false; + break; + } + } + } + + if (!ok) + throw invalid_value (bits::nmtoken (), tmp); + + str_.resize (size); + } + + template + std::basic_string nmtoken_pimpl:: + post_nmtoken () + { + std::basic_string r; + r.swap (str_); + return r; + } + + // nmtokens + // + template + void nmtokens_pimpl:: + _pre () + { + nmtokens_pskel::_pre (); + seq_.clear (); + } + + template + void nmtokens_pimpl:: + _post () + { + nmtokens_pskel::_post (); + + // Should have at least one element. + // + if (seq_.size () < 1) + { + ro_string tmp; + throw invalid_value (bits::nmtokens (), tmp); + } + } + + template + string_sequence nmtokens_pimpl:: + post_nmtokens () + { + string_sequence r; + r.swap (seq_); + return r; + } + + template + void nmtokens_pimpl:: + _xsd_parse_item (const ro_string& s) + { + parser_.pre (); + parser_._pre (); + parser_._characters (s); + parser_._post (); + seq_.push_back (parser_.post_nmtoken ()); + } + + // ncname + // + namespace bits + { + template + bool + valid_ncname (const C* s, typename ro_string::size_type size) + { + typedef typename ro_string::size_type size_type; + + // For now we are only checking the US-ASCII characters. + // + bool ok (size != 0); + + if (ok) + { + unsigned int c (static_cast (s[0])); + + ok = c >= 0x80 || + ((bits::char_table::table[c] & + bits::name_first_mask) && c != C (':')); + + if (ok) + { + for (size_type i (1); i < size; ++i) + { + c = static_cast (s[i]); + + if (c < 0x80 && + !(bits::char_table::table[c] & + bits::ncname_mask)) + { + ok = false; + break; + } + } + } + } + + return ok; + } + } + + template + void ncname_pimpl:: + _pre () + { + str_.clear (); + } + + template + void ncname_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + void ncname_pimpl:: + _post () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + + if (!bits::valid_ncname (tmp.data (), size)) + throw invalid_value (bits::ncname (), tmp); + + str_.resize (size); + } + + template + std::basic_string ncname_pimpl:: + post_ncname () + { + std::basic_string r; + r.swap (str_); + return r; + } + + // id + // + template + void id_pimpl:: + _pre () + { + str_.clear (); + } + + template + void id_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + void id_pimpl:: + _post () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + + if (!bits::valid_ncname (tmp.data (), size)) + throw invalid_value (bits::id (), tmp); + + str_.resize (size); + } + + template + std::basic_string id_pimpl:: + post_id () + { + std::basic_string r; + r.swap (str_); + return r; + } + + // idref + // + template + void idref_pimpl:: + _pre () + { + str_.clear (); + } + + template + void idref_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + void idref_pimpl:: + _post () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + + if (!bits::valid_ncname (tmp.data (), size)) + throw invalid_value (bits::idref (), tmp); + + str_.resize (size); + } + + template + std::basic_string idref_pimpl:: + post_idref () + { + std::basic_string r; + r.swap (str_); + return r; + } + + // idrefs + // + template + void idrefs_pimpl:: + _pre () + { + idrefs_pskel::_pre (); + seq_.clear (); + } + + template + void idrefs_pimpl:: + _post () + { + idrefs_pskel::_post (); + + // Should have at least one element. + // + if (seq_.size () < 1) + { + ro_string tmp; + throw invalid_value (bits::idrefs (), tmp); + } + } + + template + string_sequence idrefs_pimpl:: + post_idrefs () + { + string_sequence r; + r.swap (seq_); + return r; + } + + template + void idrefs_pimpl:: + _xsd_parse_item (const ro_string& s) + { + parser_.pre (); + parser_._pre (); + parser_._characters (s); + parser_._post (); + seq_.push_back (parser_.post_idref ()); + } + + // language + // + template + void language_pimpl:: + _pre () + { + str_.clear (); + } + + template + void language_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + void language_pimpl:: + _post () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + + // language := ALPHA{1,8} *(-(ALPHA | DIGIT){1,8}) + // + bool ok (true); + + for (size_type tag (0), i (0); ; ++tag) + { + size_type n (0); + + for (; i < size && n < 8; ++n, ++i) + { + C c (tmp[i]); + + if (!((c >= C ('a') && c <= C ('z')) || + (c >= C ('A') && c <= C ('Z')) || + (tag != 0 && c >= C ('0') && c <= C ('9')))) + break; + } + + if (n == 0) + { + ok = false; + break; + } + + if (i == size) + break; + + if (tmp[i++] != C ('-')) + { + ok = false; + break; + } + } + + if (!ok) + throw invalid_value (bits::language (), tmp); + + str_.resize (size); + } + + template + std::basic_string language_pimpl:: + post_language () + { + std::basic_string r; + r.swap (str_); + return r; + } + + // uri + // + template + void uri_pimpl:: + _pre () + { + str_.clear (); + } + + template + void uri_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + std::basic_string uri_pimpl:: + post_uri () + { + // According to Datatypes 3.2.17 and RFC2396 pretty much anything + // can be a URI and conforming processors do not need to figure + // out and verify particular URI schemes. + // + ro_string tmp (str_); + str_.resize (trim_right (tmp)); + + std::basic_string r; + r.swap (str_); + return r; + } + + // qname + // + template + void qname_pimpl:: + _pre () + { + str_.clear (); + } + + template + void qname_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + void qname_pimpl:: + _post () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + size_type pos (tmp.find (C (':'))); + + const C* s (tmp.data ()); + + if (pos != ro_string::npos) + { + if (!bits::valid_ncname (s, pos) || + !bits::valid_ncname (s + pos + 1, size - pos - 1)) + throw invalid_value (bits::qname (), tmp); + + prefix_.assign (s, pos); + name_.assign (s + pos + 1, size - pos - 1); + } + else + { + if (!bits::valid_ncname (s, size)) + throw invalid_value (bits::qname (), tmp); + + prefix_.clear (); + str_.resize (size); + name_.swap (str_); + } + } + + template + qname qname_pimpl:: + post_qname () + { + return prefix_.empty () + ? qname (name_) + : qname (prefix_, name_); + } + + // base64_binary + // + template + void base64_binary_pimpl:: + _pre () + { + str_.clear (); + } + + template + void base64_binary_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + namespace bits + { + template + inline unsigned char + base64_decode (C c) + { + unsigned char r (0xFF); + + if (c >= C('A') && c <= C ('Z')) + r = static_cast (c - C ('A')); + else if (c >= C('a') && c <= C ('z')) + r = static_cast (c - C ('a') + 26); + else if (c >= C('0') && c <= C ('9')) + r = static_cast (c - C ('0') + 52); + else if (c == C ('+')) + r = 62; + else if (c == C ('/')) + r = 63; + + return r; + } + } + + template + void base64_binary_pimpl:: + _post () + { + typedef typename std::basic_string::size_type size_type; + + size_type size (str_.size ()); + const C* src (str_.c_str ()); + + // Remove all whitespaces. + // + { + size_type j (0); + + bool subs (false); + + for (size_type i (0); i < size; ++i) + { + C c = str_[i]; + + if (c == C (0x20) || c == C (0x0A) || + c == C (0x0D) || c == C (0x09)) + { + subs = true; + } + else + { + if (subs) + subs = false; + + str_[j++] = c; + } + } + + size = j; + str_.resize (size); + } + + // Our length should be a multiple of four. + // + if (size == 0 || size % 4 != 0) + throw invalid_value (bits::base64_binary (), str_); + + size_type quad_count (size / 4); + size_type capacity (quad_count * 3 + 1); + + buf_.reset (new buffer (capacity, capacity)); + char* dst (buf_->data ()); + + size_type si (0), di (0); // Source and destination indexes. + + // Process all quads except the last one. + // + unsigned char b1, b2, b3, b4; + + for (size_type q (0); q < quad_count - 1; ++q) + { + b1 = bits::base64_decode (src[si++]); + b2 = bits::base64_decode (src[si++]); + b3 = bits::base64_decode (src[si++]); + b4 = bits::base64_decode (src[si++]); + + if (b1 == 0xFF || b2 == 0xFF || b3 == 0xFF || b4 == 0xFF) + throw invalid_value (bits::base64_binary (), str_); + + dst[di++] = (b1 << 2) | (b2 >> 4); + dst[di++] = (b2 << 4) | (b3 >> 2); + dst[di++] = (b3 << 6) | b4; + } + + // Process the last quad. The first two octets are always there. + // + b1 = bits::base64_decode (src[si++]); + b2 = bits::base64_decode (src[si++]); + + if (b1 == 0xFF || b2 == 0xFF) + throw invalid_value (bits::base64_binary (), str_); + + C e3 (src[si++]); + C e4 (src[si++]); + + if (e4 == C ('=')) + { + if (e3 == C ('=')) + { + // Two pads. Last 4 bits in b2 should be zero. + // + if ((b2 & 0x0F) != 0) + throw invalid_value (bits::base64_binary (), str_); + + dst[di++] = (b1 << 2) | (b2 >> 4); + } + else + { + // One pad. Last 2 bits in b3 should be zero. + // + b3 = bits::base64_decode (e3); + + if (b3 == 0xFF || (b3 & 0x03) != 0) + throw invalid_value (bits::base64_binary (), str_); + + dst[di++] = (b1 << 2) | (b2 >> 4); + dst[di++] = (b2 << 4) | (b3 >> 2); + } + } + else + { + // No pads. + // + b3 = bits::base64_decode (e3); + b4 = bits::base64_decode (e4); + + if (b3 == 0xFF || b4 == 0xFF) + throw invalid_value (bits::base64_binary (), str_); + + dst[di++] = (b1 << 2) | (b2 >> 4); + dst[di++] = (b2 << 4) | (b3 >> 2); + dst[di++] = (b3 << 6) | b4; + } + + // Set the real size. + // + buf_->size (di); + } + + template + XSD_AUTO_PTR base64_binary_pimpl:: + post_base64_binary () + { +#ifdef XSD_CXX11 + return std::move (buf_); +#else + return buf_; +#endif + } + + // hex_binary + // + template + void hex_binary_pimpl:: + _pre () + { + str_.clear (); + } + + template + void hex_binary_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + namespace bits + { + template + inline unsigned char + hex_decode (C c) + { + unsigned char r (0xFF); + + if (c >= C('0') && c <= C ('9')) + r = static_cast (c - C ('0')); + else if (c >= C ('A') && c <= C ('F')) + r = static_cast (10 + (c - C ('A'))); + else if (c >= C ('a') && c <= C ('f')) + r = static_cast (10 + (c - C ('a'))); + + return r; + } + } + + template + void hex_binary_pimpl:: + _post () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + + if (size % 2 != 0) + throw invalid_value (bits::hex_binary (), tmp); + + buffer::size_t n (size / 2); + buf_.reset (new buffer (n)); + + if (n != 0) + { + const C* src (tmp.data ()); + char* dst (buf_->data ()); + buffer::size_t i (0); + + for (; i < n; ++i) + { + unsigned char h (bits::hex_decode (src[2 * i])); + unsigned char l (bits::hex_decode (src[2 * i + 1])); + + if (h == 0xFF || l == 0xFF) + break; + + dst[i] = (h << 4) | l; + } + + if (i != n) + throw invalid_value (bits::hex_binary (), tmp); + } + } + + template + XSD_AUTO_PTR hex_binary_pimpl:: + post_hex_binary () + { +#ifdef XSD_CXX11 + return std::move (buf_); +#else + return buf_; +#endif + } + + // time_zone + // + namespace bits + { + // Datatypes 3.2.7.3. Return false if time zone is invalid. + // + template + bool + parse_tz (const C* s, + typename std::basic_string::size_type n, + short& h, short& m) + { + // time_zone := Z|(+|-)HH:MM + // + if (n == 0) + { + return false; + } + else if (s[0] == 'Z') + { + if (n != 1) + return false; + + h = 0; + m = 0; + } + else + { + if (n != 6 || (s[0] != '-' && s[0] != '+') || s[3] != ':') + return false; + + // Parse hours. + // + char d1 = s[1]; + char d2 = s[2]; + + if (d1 < '0' || d1 > '9' || d2 < '0' || d2 > '9') + return false; + + h = 10 * (d1 - '0') + (d2 - '0'); + + if (h > 14) + return false; + + // Parse minutes. + // + d1 = s[4]; + d2 = s[5]; + + if (d1 < '0' || d1 > '9' || d2 < '0' || d2 > '9') + return false; + + m = 10 * (d1 - '0') + (d2 - '0'); + + if (m > 59 || (h == 14 && m != 0)) + return false; + + if (s[0] == '-') + { + h = -h; + m = -m; + } + } + + return true; + } + } + + // gday + // + template + void gday_pimpl:: + _pre () + { + str_.clear (); + } + + template + void gday_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + void gday_pimpl:: + _post () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + const C* s (tmp.data ()); + + // gday := ---DD[Z|(+|-)HH:MM] + // + if (size < 5 || + s[0] != C ('-') || s[1] != C ('-') || s[2] != C ('-')) + throw invalid_value (bits::gday (), tmp); + + C d1 (s[3]), d2 (s[4]); + + if (d1 < '0' || d1 > '9' || d2 < '0' || d2 > '9') + throw invalid_value (bits::gday (), tmp); + + day_ = 10 * (d1 - '0') + (d2 - '0'); + + if (day_ < 1 || day_ > 31) + throw invalid_value (bits::gday (), tmp); + + if (size > 5) + { + if (!bits::parse_tz (s + 5, size - 5, zh_, zm_)) + throw invalid_value (bits::gday (), tmp); + + z_ = true; + } + else + z_ = false; + } + + template + gday gday_pimpl:: + post_gday () + { + return z_ ? gday (day_, zh_, zm_) : gday (day_); + } + + // gmonth + // + template + void gmonth_pimpl:: + _pre () + { + str_.clear (); + } + + template + void gmonth_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + void gmonth_pimpl:: + _post () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + const C* s (tmp.data ()); + + // gmonth := --MM[Z|(+|-)HH:MM] + // + if (size < 4 || s[0] != C ('-') || s[1] != C ('-')) + throw invalid_value (bits::gmonth (), tmp); + + C d1 (s[2]), d2 (s[3]); + + if (d1 < '0' || d1 > '9' || d2 < '0' || d2 > '9') + throw invalid_value (bits::gmonth (), tmp); + + month_ = 10 * (d1 - '0') + (d2 - '0'); + + if (month_ < 1 || month_ > 12) + throw invalid_value (bits::gmonth (), tmp); + + if (size > 4) + { + if (!bits::parse_tz (s + 4, size - 4, zh_, zm_)) + throw invalid_value (bits::gmonth (), tmp); + + z_ = true; + } + else + z_ = false; + } + + template + gmonth gmonth_pimpl:: + post_gmonth () + { + return z_ ? gmonth (month_, zh_, zm_) : gmonth (month_); + } + + // gyear + // + template + void gyear_pimpl:: + _pre () + { + str_.clear (); + } + + template + void gyear_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + void gyear_pimpl:: + _post () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + const C* s (tmp.data ()); + + // gyear := [-]CCYY[N]*[Z|(+|-)HH:MM] + // + + if (size < 4 || (s[0] == C ('-') && size < 5)) + throw invalid_value (bits::gyear (), tmp); + + // Find the end of the year token. + // + size_type pos (s[0] == C ('-') ? 5 : 4); + for (; pos < size; ++pos) + { + C c (s[pos]); + + if (c == C ('Z') || c == C ('+') || c == C ('-')) + break; + } + + ro_string year_fragment (s, pos); + zc_istream is (year_fragment); + + if (!(is >> year_ && is.exhausted () && year_ != 0)) + throw invalid_value (bits::gyear (), tmp); + + if (pos < size) + { + if (!bits::parse_tz (s + pos, size - pos, zh_, zm_)) + throw invalid_value (bits::gyear (), tmp); + + z_ = true; + } + else + z_ = false; + } + + template + gyear gyear_pimpl:: + post_gyear () + { + return z_ ? gyear (year_, zh_, zm_) : gyear (year_); + } + + // gmonth_day + // + template + void gmonth_day_pimpl:: + _pre () + { + str_.clear (); + } + + template + void gmonth_day_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + void gmonth_day_pimpl:: + _post () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + const C* s (tmp.data ()); + + // gmonth_day := --MM-DD[Z|(+|-)HH:MM] + // + if (size < 7 || + s[0] != C ('-') || s[1] != C ('-') || s[4] != C ('-')) + throw invalid_value (bits::gmonth_day (), tmp); + + // month + // + C d1 (s[2]), d2 (s[3]); + + if (d1 < '0' || d1 > '9' || d2 < '0' || d2 > '9') + throw invalid_value (bits::gmonth_day (), tmp); + + month_ = 10 * (d1 - '0') + (d2 - '0'); + + if (month_ < 1 || month_ > 12) + throw invalid_value (bits::gmonth_day (), tmp); + + // day + // + d1 = s[5]; + d2 = s[6]; + + if (d1 < '0' || d1 > '9' || d2 < '0' || d2 > '9') + throw invalid_value (bits::gmonth_day (), tmp); + + day_ = 10 * (d1 - '0') + (d2 - '0'); + + if (day_ < 1 || day_ > 31) + throw invalid_value (bits::gmonth_day (), tmp); + + // zone + // + if (size > 7) + { + if (!bits::parse_tz (s + 7, size - 7, zh_, zm_)) + throw invalid_value (bits::gmonth_day (), tmp); + + z_ = true; + } + else + z_ = false; + } + + template + gmonth_day gmonth_day_pimpl:: + post_gmonth_day () + { + return z_ + ? gmonth_day (month_, day_, zh_, zm_) + : gmonth_day (month_, day_); + } + + // gyear_month + // + template + void gyear_month_pimpl:: + _pre () + { + str_.clear (); + } + + template + void gyear_month_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + void gyear_month_pimpl:: + _post () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + const C* s (tmp.data ()); + + // gyear_month := [-]CCYY[N]*-MM[Z|(+|-)HH:MM] + // + + if (size < 7 || (s[0] == C ('-') && size < 8)) + throw invalid_value (bits::gyear_month (), tmp); + + // Find the end of the year token. + // + size_type pos (tmp.find (C ('-'), s[0] == C ('-') ? 5 : 4)); + + if (pos == ro_string::npos || (size - pos - 1) < 2) + throw invalid_value (bits::gyear_month (), tmp); + + ro_string year_fragment (s, pos); + zc_istream yis (year_fragment); + + if (!(yis >> year_ && yis.exhausted () && year_ != 0)) + throw invalid_value (bits::gyear_month (), tmp); + + // month + // + C d1 (s[pos + 1]), d2 (s[pos + 2]); + + if (d1 < '0' || d1 > '9' || d2 < '0' || d2 > '9') + throw invalid_value (bits::gyear_month (), tmp); + + month_ = 10 * (d1 - '0') + (d2 - '0'); + + if (month_ < 1 || month_ > 12) + throw invalid_value (bits::gyear_month (), tmp); + + // zone + // + pos += 3; + + if (pos < size) + { + if (!bits::parse_tz (s + pos, size - pos, zh_, zm_)) + throw invalid_value (bits::gyear_month (), tmp); + + z_ = true; + } + else + z_ = false; + } + + template + gyear_month gyear_month_pimpl:: + post_gyear_month () + { + return z_ + ? gyear_month (year_, month_, zh_, zm_) + : gyear_month (year_, month_); + } + + // date + // + template + void date_pimpl:: + _pre () + { + str_.clear (); + } + + template + void date_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + void date_pimpl:: + _post () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + const C* s (tmp.data ()); + + // date := [-]CCYY[N]*-MM-DD[Z|(+|-)HH:MM] + // + + if (size < 10 || (s[0] == C ('-') && size < 11)) + throw invalid_value (bits::date (), tmp); + + // Find the end of the year token. + // + size_type pos (tmp.find (C ('-'), s[0] == C ('-') ? 5 : 4)); + + if (pos == ro_string::npos + || (size - pos - 1) < 5 + || s[pos + 3] != C ('-')) + throw invalid_value (bits::date (), tmp); + + ro_string year_fragment (s, pos); + zc_istream yis (year_fragment); + + if (!(yis >> year_ && yis.exhausted () && year_ != 0)) + throw invalid_value (bits::date (), tmp); + + // month + // + C d1 (s[pos + 1]), d2 (s[pos + 2]); + + if (d1 < '0' || d1 > '9' || d2 < '0' || d2 > '9') + throw invalid_value (bits::date (), tmp); + + month_ = 10 * (d1 - '0') + (d2 - '0'); + + if (month_ < 1 || month_ > 12) + throw invalid_value (bits::date (), tmp); + + // day + // + d1 = s[pos + 4]; + d2 = s[pos + 5]; + + if (d1 < '0' || d1 > '9' || d2 < '0' || d2 > '9') + throw invalid_value (bits::date (), tmp); + + day_ = 10 * (d1 - '0') + (d2 - '0'); + + if (day_ < 1 || day_ > 31) + throw invalid_value (bits::date (), tmp); + + // zone + // + pos += 6; + + if (pos < size) + { + if (!bits::parse_tz (s + pos, size - pos, zh_, zm_)) + throw invalid_value (bits::date (), tmp); + + z_ = true; + } + else + z_ = false; + } + + template + date date_pimpl:: + post_date () + { + return z_ + ? date (year_, month_, day_, zh_, zm_) + : date (year_, month_, day_); + } + + // time + // + template + void time_pimpl:: + _pre () + { + str_.clear (); + } + + template + void time_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + void time_pimpl:: + _post () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + const C* s (tmp.data ()); + + // time := HH:MM:SS[.S+][Z|(+|-)HH:MM] + // + + if (size < 8 || s[2] != C (':') || s[5] != C (':')) + throw invalid_value (bits::time (), tmp); + + // hours + // + C d1 (s[0]), d2 (s[1]); + + if (d1 < '0' || d1 > '9' || d2 < '0' || d2 > '9') + throw invalid_value (bits::time (), tmp); + + hours_ = 10 * (d1 - '0') + (d2 - '0'); + + if (hours_ > 24) + throw invalid_value (bits::time (), tmp); + + // minutes + // + d1 = s[3]; + d2 = s[4]; + + if (d1 < '0' || d1 > '9' || d2 < '0' || d2 > '9') + throw invalid_value (bits::time (), tmp); + + minutes_ = 10 * (d1 - '0') + (d2 - '0'); + + if (minutes_ > 59) + throw invalid_value (bits::time (), tmp); + + // Find the end of the seconds fragment. + // + size_type pos (8); + for (; pos < size; ++pos) + { + C c (s[pos]); + + if (c == C ('Z') || c == C ('+') || c == C ('-')) + break; + } + + // At least one digit should follow the fraction point. + // + if ((pos - 6) == 3) + throw invalid_value (bits::time (), tmp); + + ro_string seconds_fragment (s + 6, pos - 6); + zc_istream sis (seconds_fragment); + + if (!(sis >> seconds_ && sis.exhausted () && seconds_ < 60.0)) + throw invalid_value (bits::time (), tmp); + + if (hours_ == 24 && (minutes_ != 0 || seconds_ != 0.0)) + throw invalid_value (bits::time (), tmp); + + // zone + // + if (pos < size) + { + if (!bits::parse_tz (s + pos, size - pos, zh_, zm_)) + throw invalid_value (bits::time (), tmp); + + z_ = true; + } + else + z_ = false; + } + + template + time time_pimpl:: + post_time () + { + return z_ + ? time (hours_, minutes_, seconds_, zh_, zm_) + : time (hours_, minutes_, seconds_); + } + + + // date_time + // + template + void date_time_pimpl:: + _pre () + { + str_.clear (); + } + + template + void date_time_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + template + void date_time_pimpl:: + _post () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + const C* s (tmp.data ()); + + // date_time := [-]CCYY[N]*-MM-DDTHH:MM:SS[.S+][Z|(+|-)HH:MM] + // + + if (size < 19 || (s[0] == C ('-') && size < 20)) + throw invalid_value (bits::date_time (), tmp); + + // Find the end of the year token. + // + size_type pos (tmp.find (C ('-'), s[0] == C ('-') ? 5 : 4)); + + if (pos == ro_string::npos || (size - pos - 1) < 14 + || s[pos + 3] != C ('-') || s[pos + 6] != C ('T') + || s[pos + 9] != C (':') || s[pos + 12] != C (':')) + throw invalid_value (bits::date_time (), tmp); + + // year + // + ro_string year_fragment (s, pos); + zc_istream yis (year_fragment); + + if (!(yis >> year_ && yis.exhausted () && year_ != 0)) + throw invalid_value (bits::date_time (), tmp); + + // month + // + C d1 (s[pos + 1]), d2 (s[pos + 2]); + + if (d1 < '0' || d1 > '9' || d2 < '0' || d2 > '9') + throw invalid_value (bits::date_time (), tmp); + + month_ = 10 * (d1 - '0') + (d2 - '0'); + + if (month_ < 1 || month_ > 12) + throw invalid_value (bits::date_time (), tmp); + + // day + // + d1 = s[pos + 4]; + d2 = s[pos + 5]; + + if (d1 < '0' || d1 > '9' || d2 < '0' || d2 > '9') + throw invalid_value (bits::date_time (), tmp); + + day_ = 10 * (d1 - '0') + (d2 - '0'); + + if (day_ < 1 || day_ > 31) + throw invalid_value (bits::date_time (), tmp); + + pos += 7; // Point to the first H. + + // hours + // + d1 = s[pos]; + d2 = s[pos + 1]; + + if (d1 < '0' || d1 > '9' || d2 < '0' || d2 > '9') + throw invalid_value (bits::date_time (), tmp); + + hours_ = 10 * (d1 - '0') + (d2 - '0'); + + if (hours_ > 24) + throw invalid_value (bits::date_time (), tmp); + + // minutes + // + d1 = s[pos + 3]; + d2 = s[pos + 4]; + + if (d1 < '0' || d1 > '9' || d2 < '0' || d2 > '9') + throw invalid_value (bits::date_time (), tmp); + + minutes_ = 10 * (d1 - '0') + (d2 - '0'); + + if (minutes_ > 59) + throw invalid_value (bits::date_time (), tmp); + + // Find the end of the seconds fragment. + // + pos += 6; // Point to the first S. + + size_type sec_end (pos + 2); + for (; sec_end < size; ++sec_end) + { + C c (s[sec_end]); + + if (c == C ('Z') || c == C ('+') || c == C ('-')) + break; + } + + // At least one digit should should follow the fraction point. + // + if ((sec_end - pos) == 3) + throw invalid_value (bits::date_time (), tmp); + + ro_string seconds_fragment (s + pos, sec_end - pos); + zc_istream sis (seconds_fragment); + + if (!(sis >> seconds_ && sis.exhausted () && seconds_ < 60.0)) + throw invalid_value (bits::date_time (), tmp); + + if (hours_ == 24 && (minutes_ != 0 || seconds_ != 0.0)) + throw invalid_value (bits::date_time (), tmp); + + // zone + // + if (sec_end < size) + { + if (!bits::parse_tz (s + sec_end, size - sec_end, zh_, zm_)) + throw invalid_value (bits::date_time (), tmp); + + z_ = true; + } + else + z_ = false; + } + + template + date_time date_time_pimpl:: + post_date_time () + { + return z_ + ? date_time (year_, month_, day_, hours_, minutes_, seconds_, + zh_, zm_) + : date_time (year_, month_, day_, hours_, minutes_, seconds_); + } + + // duration + // + template + void duration_pimpl:: + _pre () + { + str_.clear (); + } + + template + void duration_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + namespace bits + { + template + inline typename ro_string::size_type + duration_delim (const C* s, + typename ro_string::size_type pos, + typename ro_string::size_type size) + { + const C* p (s + pos); + for (; p < (s + size); ++p) + { + if (*p == C ('Y') || *p == C ('D') || *p == C ('M') || + *p == C ('H') || *p == C ('M') || *p == C ('S') || + *p == C ('T')) + break; + } + + return p - s; + } + } + + template + void duration_pimpl:: + _post () + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str_); + size_type size (trim_right (tmp)); + + negative_ = false; + years_ = 0; + months_ = 0; + days_ = 0; + hours_ = 0; + minutes_ = 0; + seconds_ = 0.0; + + // duration := [-]P[nY][nM][nD][TnHnMn[.n+]S] + // + const C* s (tmp.data ()); + + if (size < 3 || (s[0] == C ('-') && size < 4)) + throw invalid_value (bits::duration (), tmp); + + size_type pos (0); + + if (s[0] == C ('-')) + { + negative_ = true; + pos++; + } + + if (s[pos++] != C ('P')) + throw invalid_value (bits::duration (), tmp); + + size_type del (bits::duration_delim (s, pos, size)); + + // Duration should contain at least one component. + // + if (del == size) + throw invalid_value (bits::duration (), tmp); + + if (s[del] == C ('Y')) + { + ro_string fragment (s + pos, del - pos); + zc_istream is (fragment); + + if (!(is >> years_ && is.exhausted ())) + throw invalid_value (bits::duration (), tmp); + + pos = del + 1; + del = bits::duration_delim (s, pos, size); + } + + if (del != size && s[del] == C ('M')) + { + ro_string fragment (s + pos, del - pos); + zc_istream is (fragment); + + if (!(is >> months_ && is.exhausted ())) + throw invalid_value (bits::duration (), tmp); + + pos = del + 1; + del = bits::duration_delim (s, pos, size); + } + + if (del != size && s[del] == C ('D')) + { + ro_string fragment (s + pos, del - pos); + zc_istream is (fragment); + + if (!(is >> days_ && is.exhausted ())) + throw invalid_value (bits::duration (), tmp); + + pos = del + 1; + del = bits::duration_delim (s, pos, size); + } + + if (del != size && s[del] == C ('T')) + { + pos = del + 1; + del = bits::duration_delim (s, pos, size); + + // At least one time component should be present. + // + if (del == size) + throw invalid_value (bits::duration (), tmp); + + if (s[del] == C ('H')) + { + ro_string fragment (s + pos, del - pos); + zc_istream is (fragment); + + if (!(is >> hours_ && is.exhausted ())) + throw invalid_value (bits::duration (), tmp); + + pos = del + 1; + del = bits::duration_delim (s, pos, size); + } + + if (del != size && s[del] == C ('M')) + { + ro_string fragment (s + pos, del - pos); + zc_istream is (fragment); + + if (!(is >> minutes_ && is.exhausted ())) + throw invalid_value (bits::duration (), tmp); + + pos = del + 1; + del = bits::duration_delim (s, pos, size); + } + + if (del != size && s[del] == C ('S')) + { + ro_string fragment (s + pos, del - pos); + zc_istream is (fragment); + + if (!(is >> seconds_ && is.exhausted () && seconds_ >= 0.0)) + throw invalid_value (bits::duration (), tmp); + + pos = del + 1; + } + } + + // Something did not match or appeared in the wrong order. + // + if (pos != size) + throw invalid_value (bits::duration (), tmp); + } + + template + duration duration_pimpl:: + post_duration () + { + return duration ( + negative_, years_, months_, days_, hours_, minutes_, seconds_); + } + } + } + } +} diff --git a/libxsd/libxsd/cxx/parser/validating/xml-schema-pskel.hxx b/libxsd/libxsd/cxx/parser/validating/xml-schema-pskel.hxx new file mode 100644 index 0000000..9583d13 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/validating/xml-schema-pskel.hxx @@ -0,0 +1,647 @@ +// file : libxsd/cxx/parser/validating/xml-schema-pskel.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PSKEL_HXX +#define LIBXSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PSKEL_HXX + +#include +#include // std::auto_ptr/unique_ptr + +#include // XSD_AUTO_PTR + +#include +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace validating + { + // anyType and anySimpleType. All events are routed to the + // _any_* callbacks. + // + template + struct any_type_pskel: complex_content + { + 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&); + + virtual bool + _attribute_impl_phase_two (const ro_string&, + const ro_string&, + const ro_string&); + + virtual bool + _characters_impl (const ro_string&); + + virtual void + post_any_type () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct any_simple_type_pskel: simple_content + { + virtual bool + _characters_impl (const ro_string&); + + virtual void + post_any_simple_type () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + + // Boolean. + // + template + struct boolean_pskel: simple_content + { + virtual bool + post_boolean () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + + // 8-bit + // + template + struct byte_pskel: simple_content + { + virtual signed char + post_byte () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct unsigned_byte_pskel: simple_content + { + virtual unsigned char + post_unsigned_byte () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + + // 16-bit + // + template + struct short_pskel: simple_content + { + virtual short + post_short () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct unsigned_short_pskel: simple_content + { + virtual unsigned short + post_unsigned_short () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + + // 32-bit + // + template + struct int_pskel: simple_content + { + virtual int + post_int () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct unsigned_int_pskel: simple_content + { + virtual unsigned int + post_unsigned_int () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + + // 64-bit + // + template + struct long_pskel: simple_content + { + virtual long long + post_long () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct unsigned_long_pskel: simple_content + { + virtual unsigned long long + post_unsigned_long () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + + // Arbitrary-length integers. + // + template + struct integer_pskel: simple_content + { + virtual long long + post_integer () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct negative_integer_pskel: simple_content + { + virtual long long + post_negative_integer () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct non_positive_integer_pskel: simple_content + { + virtual long long + post_non_positive_integer () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct positive_integer_pskel: simple_content + { + virtual unsigned long long + post_positive_integer () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct non_negative_integer_pskel: simple_content + { + virtual unsigned long long + post_non_negative_integer () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + + // Floats. + // + template + struct float_pskel: simple_content + { + virtual float + post_float () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct double_pskel: simple_content + { + virtual double + post_double () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct decimal_pskel: simple_content + { + virtual double + post_decimal () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + + // Strings. + // + template + struct string_pskel: simple_content + { + virtual std::basic_string + post_string () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct normalized_string_pskel: simple_content + { + virtual std::basic_string + post_normalized_string () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct token_pskel: simple_content + { + virtual std::basic_string + post_token () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct name_pskel: simple_content + { + virtual std::basic_string + post_name () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct nmtoken_pskel: simple_content + { + virtual std::basic_string + post_nmtoken () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct nmtokens_pskel: list_base + { + virtual string_sequence + post_nmtokens () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct ncname_pskel: simple_content + { + virtual std::basic_string + post_ncname () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct id_pskel: simple_content + { + virtual std::basic_string + post_id () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct idref_pskel: simple_content + { + virtual std::basic_string + post_idref () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct idrefs_pskel: list_base + { + virtual string_sequence + post_idrefs () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + // Language. + // + template + struct language_pskel: simple_content + { + virtual std::basic_string + post_language () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + // URI. + // + template + struct uri_pskel: simple_content + { + virtual std::basic_string + post_uri () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + // QName. + // + template + struct qname_pskel: simple_content + { + virtual qname + post_qname () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + // Base64 and hex binaries. + // + template + struct base64_binary_pskel: simple_content + { + virtual XSD_AUTO_PTR + post_base64_binary () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct hex_binary_pskel: simple_content + { + virtual XSD_AUTO_PTR + post_hex_binary () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + // Time and date types. + // + template + struct gday_pskel: simple_content + { + virtual gday + post_gday () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct gmonth_pskel: simple_content + { + virtual gmonth + post_gmonth () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct gyear_pskel: simple_content + { + virtual gyear + post_gyear () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct gmonth_day_pskel: simple_content + { + virtual gmonth_day + post_gmonth_day () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct gyear_month_pskel: simple_content + { + virtual gyear_month + post_gyear_month () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct date_pskel: simple_content + { + virtual date + post_date () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct time_pskel: simple_content + { + virtual time + post_time () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct date_time_pskel: simple_content + { + virtual date_time + post_date_time () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + + template + struct duration_pskel: simple_content + { + virtual duration + post_duration () = 0; + + static const C* + _static_type (); + + virtual const C* + _dynamic_type () const; + }; + } + } + } +} + +#include + +#endif // LIBXSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PSKEL_HXX + +#include diff --git a/libxsd/libxsd/cxx/parser/validating/xml-schema-pskel.ixx b/libxsd/libxsd/cxx/parser/validating/xml-schema-pskel.ixx new file mode 100644 index 0000000..aeecab6 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/validating/xml-schema-pskel.ixx @@ -0,0 +1,1247 @@ +// file : libxsd/cxx/parser/validating/xml-schema-pskel.ixx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#if defined(XSD_CXX_PARSER_USE_CHAR) || !defined(XSD_CXX_PARSER_USE_WCHAR) + +#ifndef XSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PSKEL_IXX_CHAR +#define XSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PSKEL_IXX_CHAR + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace validating + { + template<> + inline const char* any_type_pskel:: + _static_type () + { + return "anyType http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* any_type_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* any_simple_type_pskel:: + _static_type () + { + return "anySimpleType http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* any_simple_type_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* boolean_pskel:: + _static_type () + { + return "boolean http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* boolean_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* byte_pskel:: + _static_type () + { + return "byte http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* byte_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* unsigned_byte_pskel:: + _static_type () + { + return "unsignedByte http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* unsigned_byte_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* short_pskel:: + _static_type () + { + return "short http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* short_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* unsigned_short_pskel:: + _static_type () + { + return "unsignedShort http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* unsigned_short_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* int_pskel:: + _static_type () + { + return "int http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* int_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* unsigned_int_pskel:: + _static_type () + { + return "unsignedInt http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* unsigned_int_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* long_pskel:: + _static_type () + { + return "long http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* long_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* unsigned_long_pskel:: + _static_type () + { + return "unsignedLong http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* unsigned_long_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* integer_pskel:: + _static_type () + { + return "integer http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* negative_integer_pskel:: + _static_type () + { + return "negativeInteger http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* negative_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* non_positive_integer_pskel:: + _static_type () + { + return "nonPositiveInteger http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* non_positive_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* positive_integer_pskel:: + _static_type () + { + return "positiveInteger http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* positive_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* non_negative_integer_pskel:: + _static_type () + { + return "nonNegativeInteger http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* non_negative_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* float_pskel:: + _static_type () + { + return "float http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* float_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* double_pskel:: + _static_type () + { + return "double http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* double_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* decimal_pskel:: + _static_type () + { + return "decimal http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* decimal_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* string_pskel:: + _static_type () + { + return "string http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* string_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* normalized_string_pskel:: + _static_type () + { + return "normalizedString http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* normalized_string_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* token_pskel:: + _static_type () + { + return "token http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* token_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* name_pskel:: + _static_type () + { + return "Name http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* name_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* nmtoken_pskel:: + _static_type () + { + return "NMTOKEN http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* nmtoken_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* nmtokens_pskel:: + _static_type () + { + return "NMTOKENS http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* nmtokens_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* ncname_pskel:: + _static_type () + { + return "NCName http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* ncname_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* id_pskel:: + _static_type () + { + return "ID http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* id_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* idref_pskel:: + _static_type () + { + return "IDREF http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* idref_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* idrefs_pskel:: + _static_type () + { + return "IDREFS http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* idrefs_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* language_pskel:: + _static_type () + { + return "language http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* language_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* uri_pskel:: + _static_type () + { + return "anyURI http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* uri_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* qname_pskel:: + _static_type () + { + return "QName http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* qname_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* base64_binary_pskel:: + _static_type () + { + return "base64Binary http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* base64_binary_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* hex_binary_pskel:: + _static_type () + { + return "hexBinary http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* hex_binary_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* gday_pskel:: + _static_type () + { + return "gDay http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* gday_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* gmonth_pskel:: + _static_type () + { + return "gMonth http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* gmonth_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* gyear_pskel:: + _static_type () + { + return "gYear http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* gyear_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* gmonth_day_pskel:: + _static_type () + { + return "gMonthDay http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* gmonth_day_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* gyear_month_pskel:: + _static_type () + { + return "gYearMonth http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* gyear_month_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* date_pskel:: + _static_type () + { + return "date http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* date_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* time_pskel:: + _static_type () + { + return "time http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* time_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* date_time_pskel:: + _static_type () + { + return "dateTime http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* date_time_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const char* duration_pskel:: + _static_type () + { + return "duration http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const char* duration_pskel:: + _dynamic_type () const + { + return _static_type (); + } + } + } + } +} + +#endif // XSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PSKEL_IXX_CHAR +#endif // XSD_CXX_PARSER_USE_CHAR + + +#if defined(XSD_CXX_PARSER_USE_WCHAR) || !defined(XSD_CXX_PARSER_USE_CHAR) + +#ifndef XSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PSKEL_IXX_WCHAR +#define XSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PSKEL_IXX_WCHAR + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace validating + { + template<> + inline const wchar_t* any_type_pskel:: + _static_type () + { + return L"anyType http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* any_type_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* any_simple_type_pskel:: + _static_type () + { + return L"anySimpleType http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* any_simple_type_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* boolean_pskel:: + _static_type () + { + return L"boolean http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* boolean_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* byte_pskel:: + _static_type () + { + return L"byte http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* byte_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* unsigned_byte_pskel:: + _static_type () + { + return L"unsignedByte http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* unsigned_byte_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* short_pskel:: + _static_type () + { + return L"short http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* short_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* unsigned_short_pskel:: + _static_type () + { + return L"unsignedShort http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* unsigned_short_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* int_pskel:: + _static_type () + { + return L"int http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* int_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* unsigned_int_pskel:: + _static_type () + { + return L"unsignedInt http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* unsigned_int_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* long_pskel:: + _static_type () + { + return L"long http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* long_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* unsigned_long_pskel:: + _static_type () + { + return L"unsignedLong http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* unsigned_long_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* integer_pskel:: + _static_type () + { + return L"integer http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* negative_integer_pskel:: + _static_type () + { + return L"negativeInteger http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* negative_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* non_positive_integer_pskel:: + _static_type () + { + return L"nonPositiveInteger http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* non_positive_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* positive_integer_pskel:: + _static_type () + { + return L"positiveInteger http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* positive_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* non_negative_integer_pskel:: + _static_type () + { + return L"nonNegativeInteger http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* non_negative_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* float_pskel:: + _static_type () + { + return L"float http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* float_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* double_pskel:: + _static_type () + { + return L"double http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* double_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* decimal_pskel:: + _static_type () + { + return L"decimal http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* decimal_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* string_pskel:: + _static_type () + { + return L"string http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* string_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* normalized_string_pskel:: + _static_type () + { + return L"normalizedString http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* normalized_string_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* token_pskel:: + _static_type () + { + return L"token http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* token_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* name_pskel:: + _static_type () + { + return L"Name http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* name_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* nmtoken_pskel:: + _static_type () + { + return L"NMTOKEN http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* nmtoken_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* nmtokens_pskel:: + _static_type () + { + return L"NMTOKENS http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* nmtokens_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* ncname_pskel:: + _static_type () + { + return L"NCName http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* ncname_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* id_pskel:: + _static_type () + { + return L"ID http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* id_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* idref_pskel:: + _static_type () + { + return L"IDREF http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* idref_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* idrefs_pskel:: + _static_type () + { + return L"IDREFS http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* idrefs_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* language_pskel:: + _static_type () + { + return L"language http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* language_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* uri_pskel:: + _static_type () + { + return L"anyURI http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* uri_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* qname_pskel:: + _static_type () + { + return L"QName http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* qname_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* base64_binary_pskel:: + _static_type () + { + return L"base64Binary http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* base64_binary_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* hex_binary_pskel:: + _static_type () + { + return L"hexBinary http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* hex_binary_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* gday_pskel:: + _static_type () + { + return L"gDay http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* gday_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* gmonth_pskel:: + _static_type () + { + return L"gMonth http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* gmonth_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* gyear_pskel:: + _static_type () + { + return L"gYear http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* gyear_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* gmonth_day_pskel:: + _static_type () + { + return L"gMonthDay http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* gmonth_day_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* gyear_month_pskel:: + _static_type () + { + return L"gYearMonth http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* gyear_month_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* date_pskel:: + _static_type () + { + return L"date http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* date_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* time_pskel:: + _static_type () + { + return L"time http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* time_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* date_time_pskel:: + _static_type () + { + return L"dateTime http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* date_time_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + template<> + inline const wchar_t* duration_pskel:: + _static_type () + { + return L"duration http://www.w3.org/2001/XMLSchema"; + } + + template<> + inline const wchar_t* duration_pskel:: + _dynamic_type () const + { + return _static_type (); + } + } + } + } +} + +#endif // XSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PSKEL_IXX_WCHAR +#endif // XSD_CXX_PARSER_USE_WCHAR diff --git a/libxsd/libxsd/cxx/parser/validating/xml-schema-pskel.txx b/libxsd/libxsd/cxx/parser/validating/xml-schema-pskel.txx new file mode 100644 index 0000000..de6f62f --- /dev/null +++ b/libxsd/libxsd/cxx/parser/validating/xml-schema-pskel.txx @@ -0,0 +1,67 @@ +// file : libxsd/cxx/parser/validating/xml-schema-pskel.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace validating + { + // any_type + // + + template + bool any_type_pskel:: + _start_element_impl (const ro_string& ns, + const ro_string& name, + const ro_string* type) + { + this->_start_any_element (ns, name, type); + this->complex_content::context_.top ().any_ = true; + return true; + } + + template + bool any_type_pskel:: + _end_element_impl (const ro_string& ns, const ro_string& name) + { + this->complex_content::context_.top ().any_ = false; + this->_end_any_element (ns, name); + return true; + } + + + template + bool any_type_pskel:: + _attribute_impl_phase_two (const ro_string& ns, + const ro_string& name, + const ro_string& value) + { + this->_any_attribute (ns, name, value); + return true; + } + + template + bool any_type_pskel:: + _characters_impl (const ro_string& s) + { + this->_any_characters (s); + return true; + } + + // any_simple_type + // + + template + bool any_simple_type_pskel:: + _characters_impl (const ro_string& s) + { + this->_any_characters (s); + return true; + } + } + } + } +} diff --git a/libxsd/libxsd/cxx/parser/xerces/elements.hxx b/libxsd/libxsd/cxx/parser/xerces/elements.hxx new file mode 100644 index 0000000..d250622 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/xerces/elements.hxx @@ -0,0 +1,463 @@ +// file : libxsd/cxx/parser/xerces/elements.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_PARSER_XERCES_ELEMENTS_HXX +#define LIBXSD_CXX_PARSER_XERCES_ELEMENTS_HXX + +#include // std::auto_ptr/unique_ptr +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include // XSD_AUTO_PTR + +#include +#include + +#include +#include +#include + +#if _XERCES_VERSION < 30000 +# error Xerces-C++ 2-series is not supported +#endif + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace xerces + { + // + // + struct flags + { + // Use the following flags to modify the default behavior + // of the parsing functions. + // + + // Do not try to validate instance documents. + // + static const unsigned long dont_validate = 0x00000001; + + // Do not initialize the Xerces-C++ runtime. + // + static const unsigned long dont_initialize = 0x00000002; + + // Disable handling of subsequent imports for the same namespace + // in Xerces-C++ 3.1.0 and later. + // + static const unsigned long no_multiple_imports = 0x00000004; + + public: + flags (unsigned long x = 0) + : x_ (x) + { + } + + operator unsigned long () const + { + return x_; + } + + private: + unsigned long x_; + }; + + + // Parsing properties. Refer to xsd/cxx/xml/elements.hxx for + // XML-related properties. + // + template + class properties: public xml::properties + { + }; + + // + // + template + struct document: cxx::parser::document // VC likes it qualified + { + public: + document (parser_base& root, + const C* root_element_name, + bool polymorphic = false); + + document (parser_base& root, + const std::basic_string& root_element_name, + bool polymorphic = false); + + document (parser_base& root, + const C* root_element_namespace, + const C* root_element_name, + bool polymorphic = false); + + document (parser_base& root, + const std::basic_string& root_element_namespace, + const std::basic_string& root_element_name, + bool polymorphic = false); + + protected: + explicit + document (bool polymorphic = false); + + public: + // Parse URI or a local file. We have to overload it for const C* + // bacause xercesc::InputSource has an implicit constructor that + // takes const char*. + // + void + parse (const std::basic_string& uri, + flags = 0, + const properties& = properties ()); + + void + parse (const C* uri, + flags = 0, + const properties& = properties ()); + + + // Parse URI or a local file with a user-provided error_handler + // object. + // + void + parse (const std::basic_string& uri, + xml::error_handler&, + flags = 0, + const properties& = properties ()); + + void + parse (const C* uri, + xml::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 these functions. + // + void + parse (const std::basic_string& uri, + xercesc::ErrorHandler&, + flags = 0, + const properties& = properties ()); + + void + parse (const C* 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 these functions. + // + void + parse (const std::basic_string& uri, + xercesc::SAX2XMLReader&, + flags = 0, + const properties& = properties ()); + + void + parse (const C* uri, + xercesc::SAX2XMLReader&, + flags = 0, + const properties& = properties ()); + + + public: + // System id is a "system" identifier of the resources (e.g., + // URI or a full file path). Public id is a "public" identifier + // of the resource (e.g., an application-specific name or a + // relative file path). System id is used to resolve relative + // paths. In diagnostics messages system id is used if public + // id is not available. Otherwise public id is used. + // + + // 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&, + xml::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::basic_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::basic_string& system_id, + xml::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::basic_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::basic_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::basic_string& system_id, + const std::basic_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::basic_string& system_id, + const std::basic_string& public_id, + xml::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::basic_string& system_id, + const std::basic_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::basic_string& system_id, + const std::basic_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&, + xml::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 ()); + + private: + void + parse (const std::basic_string& uri, + xercesc::ErrorHandler&, + xercesc::SAX2XMLReader&, + flags, + const properties&); + + void + parse (const xercesc::InputSource&, + xercesc::ErrorHandler&, + xercesc::SAX2XMLReader&, + flags, + const properties&); + + private: + XSD_AUTO_PTR + create_sax_ (flags, const properties&); + + private: + bool polymorphic_; + }; + + // + // + template + struct event_router: xercesc::DefaultHandler + { + event_router (cxx::parser::document&, bool polymorphic); + + // I know, some of those consts are stupid. But that's what + // Xerces folks put into their interfaces and VC thinks there + // are different signatures if one strips this fluff off. + // + virtual void + setDocumentLocator (const xercesc::Locator* const); + + virtual void + startElement (const XMLCh* const uri, + const XMLCh* const lname, + const XMLCh* const qname, + const xercesc::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); + + virtual void + startPrefixMapping (const XMLCh* const prefix, + const XMLCh* const uri); + + virtual void + endPrefixMapping (const XMLCh* const prefix); + + private: + void + set_location (schema_exception&); + + private: + const xercesc::Locator* loc_; + cxx::parser::document& consumer_; + bool polymorphic_; + + // Last element name cache. + // + bool last_valid_; + std::basic_string last_ns_; + std::basic_string last_name_; + + // Namespace-prefix mapping. Only maintained in the polymorphic + // case. + // + struct ns_decl + { + ns_decl (const std::basic_string& p, + const std::basic_string& n) + : prefix (p), ns (n) + { + } + + std::basic_string prefix; + std::basic_string ns; + }; + + typedef std::vector ns_decls; + + ns_decls ns_decls_; + }; + } + } + } +} + +#include + +#endif // LIBXSD_CXX_PARSER_XERCES_ELEMENTS_HXX diff --git a/libxsd/libxsd/cxx/parser/xerces/elements.txx b/libxsd/libxsd/cxx/parser/xerces/elements.txx new file mode 100644 index 0000000..1868b94 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/xerces/elements.txx @@ -0,0 +1,951 @@ +// file : libxsd/cxx/parser/xerces/elements.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include // std::size_t +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include // xml::bits::{xml_prefix, etc} + +#include +#include + +namespace xsd +{ + namespace cxx + { + namespace parser + { + namespace xerces + { + + // document + // + + template + document:: + document (parser_base& parser, + const C* name, + bool polymorphic) + : cxx::parser::document (parser, std::basic_string (), name), + polymorphic_ (polymorphic) + { + } + + template + document:: + document (parser_base& parser, + const std::basic_string& name, + bool polymorphic) + : cxx::parser::document (parser, std::basic_string (), name), + polymorphic_ (polymorphic) + { + } + + template + document:: + document (parser_base& parser, + const C* ns, + const C* name, + bool polymorphic) + : cxx::parser::document (parser, ns, name), + polymorphic_ (polymorphic) + { + } + + template + document:: + document (parser_base& parser, + const std::basic_string& ns, + const std::basic_string& name, + bool polymorphic) + : cxx::parser::document (parser, ns, name), + polymorphic_ (polymorphic) + { + } + + template + document:: + document (bool polymorphic) + : polymorphic_ (polymorphic) + { + } + + // parse (uri) + // + template + void document:: + parse (const std::basic_string& uri, + flags f, + const properties& p) + { + xml::auto_initializer init ((f & flags::dont_initialize) == 0); + + error_handler eh; + xml::sax::bits::error_handler_proxy eh_proxy (eh); + XSD_AUTO_PTR sax (create_sax_ (f, p)); + + parse (uri, eh_proxy, *sax, f, p); + + eh.throw_if_failed (); + } + + template + void document:: + parse (const C* uri, + flags f, + const properties& p) + { + parse (std::basic_string (uri), f, p); + } + + // error_handler + // + + template + void document:: + parse (const std::basic_string& uri, + xml::error_handler& eh, + flags f, + const properties& p) + { + xml::auto_initializer init ((f & flags::dont_initialize) == 0); + + xml::sax::bits::error_handler_proxy eh_proxy (eh); + XSD_AUTO_PTR sax (create_sax_ (f, p)); + + parse (uri, eh_proxy, *sax, f, p); + + if (eh_proxy.failed ()) + throw parsing (); + } + + template + void document:: + parse (const C* uri, + xml::error_handler& eh, + flags f, + const properties& p) + { + parse (std::basic_string (uri), eh, f, p); + } + + // ErrorHandler + // + + template + void document:: + parse (const std::basic_string& uri, + xercesc::ErrorHandler& eh, + flags f, + const properties& p) + { + xml::sax::bits::error_handler_proxy eh_proxy (eh); + XSD_AUTO_PTR sax (create_sax_ (f, p)); + + parse (uri, eh_proxy, *sax, f, p); + + if (eh_proxy.failed ()) + throw parsing (); + } + + template + void document:: + parse (const C* uri, + xercesc::ErrorHandler& eh, + flags f, + const properties& p) + { + parse (std::basic_string (uri), eh, f, p); + } + + // SAX2XMLReader + // + + template + void document:: + parse (const std::basic_string& uri, + xercesc::SAX2XMLReader& sax, + flags f, + const properties& p) + { + // If there is no error handler, then fall back on the default + // implementation. + // + xercesc::ErrorHandler* eh (sax.getErrorHandler ()); + + if (eh) + { + xml::sax::bits::error_handler_proxy eh_proxy (*eh); + + parse (uri, eh_proxy, sax, f, p); + + if (eh_proxy.failed ()) + throw parsing (); + } + else + { + error_handler fallback_eh; + xml::sax::bits::error_handler_proxy eh_proxy (fallback_eh); + + parse (uri, eh_proxy, sax, f, p); + + fallback_eh.throw_if_failed (); + } + } + + template + void document:: + parse (const C* uri, + xercesc::SAX2XMLReader& sax, + flags f, + const properties& p) + { + parse (std::basic_string (uri), sax, f, p); + } + + // parse (istream) + // + + template + void document:: + parse (std::istream& is, + flags f, + const properties& p) + { + xml::auto_initializer init ((f & flags::dont_initialize) == 0); + + xml::sax::std_input_source isrc (is); + + parse (isrc, f, p); + } + + template + void document:: + parse (std::istream& is, + xml::error_handler& eh, + flags f, + const properties& p) + { + xml::auto_initializer init ((f & flags::dont_initialize) == 0); + xml::sax::std_input_source isrc (is); + parse (isrc, eh, f, p); + } + + template + void document:: + parse (std::istream& is, + xercesc::ErrorHandler& eh, + flags f, + const properties& p) + { + xml::sax::std_input_source isrc (is); + parse (isrc, eh, f, p); + } + + template + void document:: + parse (std::istream& is, + xercesc::SAX2XMLReader& sax, + flags f, + const properties& p) + { + xml::sax::std_input_source isrc (is); + parse (isrc, sax, f, p); + } + + + // parse (istream, system_id) + // + + + template + void document:: + parse (std::istream& is, + const std::basic_string& system_id, + flags f, + const properties& p) + { + xml::auto_initializer init ((f & flags::dont_initialize) == 0); + xml::sax::std_input_source isrc (is, system_id); + parse (isrc, f, p); + } + + template + void document:: + parse (std::istream& is, + const std::basic_string& system_id, + xml::error_handler& eh, + flags f, + const properties& p) + { + xml::auto_initializer init ((f & flags::dont_initialize) == 0); + xml::sax::std_input_source isrc (is, system_id); + parse (isrc, eh, f, p); + } + + template + void document:: + parse (std::istream& is, + const std::basic_string& system_id, + xercesc::ErrorHandler& eh, + flags f, + const properties& p) + { + xml::sax::std_input_source isrc (is, system_id); + parse (isrc, eh, f, p); + } + + template + void document:: + parse (std::istream& is, + const std::basic_string& system_id, + xercesc::SAX2XMLReader& sax, + flags f, + const properties& p) + { + xml::sax::std_input_source isrc (is, system_id); + parse (isrc, sax, f, p); + } + + + // parse (istream, system_id, public_id) + // + + template + void document:: + parse (std::istream& is, + const std::basic_string& system_id, + const std::basic_string& public_id, + flags f, + const properties& p) + { + xml::auto_initializer init ((f & flags::dont_initialize) == 0); + xml::sax::std_input_source isrc (is, system_id, public_id); + parse (isrc, f, p); + } + + template + void document:: + parse (std::istream& is, + const std::basic_string& system_id, + const std::basic_string& public_id, + xml::error_handler& eh, + flags f, + const properties& p) + { + xml::auto_initializer init ((f & flags::dont_initialize) == 0); + xml::sax::std_input_source isrc (is, system_id, public_id); + parse (isrc, eh, f, p); + } + + template + void document:: + parse (std::istream& is, + const std::basic_string& system_id, + const std::basic_string& public_id, + xercesc::ErrorHandler& eh, + flags f, + const properties& p) + { + xml::sax::std_input_source isrc (is, system_id, public_id); + parse (isrc, eh, f, p); + } + + template + void document:: + parse (std::istream& is, + const std::basic_string& system_id, + const std::basic_string& public_id, + xercesc::SAX2XMLReader& sax, + flags f, + const properties& p) + { + xml::sax::std_input_source isrc (is, system_id, public_id); + parse (isrc, sax, f, p); + } + + + // parse (InputSource) + // + + + template + void document:: + parse (const xercesc::InputSource& is, + flags f, + const properties& p) + { + error_handler eh; + xml::sax::bits::error_handler_proxy eh_proxy (eh); + XSD_AUTO_PTR sax (create_sax_ (f, p)); + + parse (is, eh_proxy, *sax, f, p); + + eh.throw_if_failed (); + } + + template + void document:: + parse (const xercesc::InputSource& is, + xml::error_handler& eh, + flags f, + const properties& p) + { + xml::sax::bits::error_handler_proxy eh_proxy (eh); + XSD_AUTO_PTR sax (create_sax_ (f, p)); + + parse (is, eh_proxy, *sax, f, p); + + if (eh_proxy.failed ()) + throw parsing (); + } + + template + void document:: + parse (const xercesc::InputSource& is, + xercesc::ErrorHandler& eh, + flags f, + const properties& p) + { + xml::sax::bits::error_handler_proxy eh_proxy (eh); + XSD_AUTO_PTR sax (create_sax_ (f, p)); + + parse (is, eh_proxy, *sax, f, p); + + if (eh_proxy.failed ()) + throw parsing (); + } + + + template + void document:: + parse (const xercesc::InputSource& is, + xercesc::SAX2XMLReader& sax, + flags f, + const properties& p) + { + // If there is no error handler, then fall back on the default + // implementation. + // + xercesc::ErrorHandler* eh (sax.getErrorHandler ()); + + if (eh) + { + xml::sax::bits::error_handler_proxy eh_proxy (*eh); + + parse (is, eh_proxy, sax, f, p); + + if (eh_proxy.failed ()) + throw parsing (); + } + else + { + error_handler fallback_eh; + xml::sax::bits::error_handler_proxy eh_proxy (fallback_eh); + + parse (is, eh_proxy, sax, f, p); + + fallback_eh.throw_if_failed (); + } + } + + namespace Bits + { + struct ErrorHandlingController + { + ErrorHandlingController (xercesc::SAX2XMLReader& sax, + xercesc::ErrorHandler& eh) + : sax_ (sax), eh_ (sax_.getErrorHandler ()) + { + sax_.setErrorHandler (&eh); + } + + ~ErrorHandlingController () + { + sax_.setErrorHandler (eh_); + } + + private: + xercesc::SAX2XMLReader& sax_; + xercesc::ErrorHandler* eh_; + }; + + struct ContentHandlingController + { + ContentHandlingController (xercesc::SAX2XMLReader& sax, + xercesc::ContentHandler& ch) + : sax_ (sax), ch_ (sax_.getContentHandler ()) + { + sax_.setContentHandler (&ch); + } + + ~ContentHandlingController () + { + sax_.setContentHandler (ch_); + } + + private: + xercesc::SAX2XMLReader& sax_; + xercesc::ContentHandler* ch_; + }; + }; + + template + void document:: + parse (const std::basic_string& uri, + xercesc::ErrorHandler& eh, + xercesc::SAX2XMLReader& sax, + flags, + const properties&) + { + event_router router (*this, polymorphic_); + + Bits::ErrorHandlingController ehc (sax, eh); + Bits::ContentHandlingController chc (sax, router); + + try + { + sax.parse (xml::string (uri).c_str ()); + } + catch (const schema_exception& e) + { + xml::string id (e.id ()); + + xercesc::SAXParseException se ( + xml::string (e.message ()).c_str (), + id.c_str (), + id.c_str (), + static_cast (e.line ()), + static_cast (e.column ())); + + eh.fatalError (se); + } + } + + template + void document:: + parse (const xercesc::InputSource& is, + xercesc::ErrorHandler& eh, + xercesc::SAX2XMLReader& sax, + flags, + const properties&) + { + event_router router (*this, polymorphic_); + + Bits::ErrorHandlingController controller (sax, eh); + Bits::ContentHandlingController chc (sax, router); + + try + { + sax.parse (is); + } + catch (const schema_exception& e) + { + xml::string id (e.id ()); + + xercesc::SAXParseException se ( + xml::string (e.message ()).c_str (), + id.c_str (), + id.c_str (), + static_cast (e.line ()), + static_cast (e.column ())); + + eh.fatalError (se); + } + } + + + template + XSD_AUTO_PTR document:: + create_sax_ (flags f, const properties& p) + { + // Cannot use 'using namespace' because of MSXML conflict. + // + using xercesc::XMLUni; + using xercesc::SAX2XMLReader; + using xercesc::XMLReaderFactory; + + XSD_AUTO_PTR sax ( + XMLReaderFactory::createXMLReader ()); + + sax->setFeature (XMLUni::fgSAX2CoreNameSpaces, true); + sax->setFeature (XMLUni::fgSAX2CoreNameSpacePrefixes, true); + sax->setFeature (XMLUni::fgXercesValidationErrorAsFatal, true); + + if (f & flags::dont_validate) + { + sax->setFeature (XMLUni::fgSAX2CoreValidation, false); + sax->setFeature (XMLUni::fgXercesSchema, false); + sax->setFeature (XMLUni::fgXercesSchemaFullChecking, false); + } + else + { + sax->setFeature (XMLUni::fgSAX2CoreValidation, true); + sax->setFeature (XMLUni::fgXercesSchema, true); + + // Xerces-C++ 3.1.0 is the first version with working multi import + // support. + // +#if _XERCES_VERSION >= 30100 + if (!(f & flags::no_multiple_imports)) + sax->setFeature (XMLUni::fgXercesHandleMultipleImports, true); +#endif + // This feature checks the schema grammar for additional + // errors. We most likely do not need it when validating + // instances (assuming the schema is valid). + // + sax->setFeature (XMLUni::fgXercesSchemaFullChecking, false); + } + + // Transfer properies if any. + // + + if (!p.schema_location ().empty ()) + { + xml::string sl (p.schema_location ()); + const void* v (sl.c_str ()); + + sax->setProperty ( + XMLUni::fgXercesSchemaExternalSchemaLocation, + const_cast (v)); + } + + if (!p.no_namespace_schema_location ().empty ()) + { + xml::string sl (p.no_namespace_schema_location ()); + const void* v (sl.c_str ()); + + sax->setProperty ( + XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation, + const_cast (v)); + } + + return sax; + } + + // event_router + // + template + event_router:: + event_router (cxx::parser::document& consumer, bool polymorphic) + : loc_ (0), consumer_ (consumer), polymorphic_ (polymorphic) + { + } + + template + void event_router:: + setDocumentLocator (const xercesc::Locator* const loc) + { + loc_ = loc; + } + + template + void event_router:: + startElement(const XMLCh* const uri, + const XMLCh* const lname, + const XMLCh* const /*qname*/, + const xercesc::Attributes& attributes) + { + using xercesc::XMLUni; + using xercesc::XMLString; + + typedef std::basic_string string; + + { + last_valid_ = true; + last_ns_ = xml::transcode (uri); + last_name_ = xml::transcode (lname); + + // Without this explicit construction IBM XL C++ complains + // about ro_string's copy ctor being private even though the + // temporary has been eliminated. Note that we cannot + // eliminate ns, name and value since ro_string does not make + // a copy. + // + ro_string ro_ns (last_ns_); + ro_string ro_name (last_name_); + + if (!polymorphic_) + { + try + { + consumer_.start_element (ro_ns, ro_name, 0); + } + catch (schema_exception& e) + { + set_location (e); + throw; + } + } + else + { + // Search for the xsi:type attribute. + // + int i (attributes.getIndex ( + xercesc::SchemaSymbols::fgURI_XSI, + xercesc::SchemaSymbols::fgXSI_TYPE)); + + if (i == -1) + { + try + { + consumer_.start_element (ro_ns, ro_name, 0); + } + catch (schema_exception& e) + { + set_location (e); + throw; + } + } + else + { + try + { + // @@ Probably need proper QName validation. + // + // Get the qualified type name and try to resolve it. + // + string qn (xml::transcode (attributes.getValue (i))); + + ro_string tp, tn; + typename string::size_type pos (qn.find (C (':'))); + + if (pos != string::npos) + { + tp.assign (qn.c_str (), pos); + tn.assign (qn.c_str () + pos + 1); + + if (tp.empty ()) + throw dynamic_type (qn); + } + else + tn.assign (qn); + + if (tn.empty ()) + throw dynamic_type (qn); + + // Search our namespace declaration stack. Sun CC 5.7 + // blows if we use const_reverse_iterator. + // + ro_string tns; + for (typename ns_decls::reverse_iterator + it (ns_decls_.rbegin ()), e (ns_decls_.rend ()); + it != e; ++it) + { + if (it->prefix == tp) + { + tns.assign (it->ns); + break; + } + } + + if (!tp.empty () && tns.empty ()) + { + // The 'xml' prefix requires special handling. + // + if (tp == xml::bits::xml_prefix ()) + tns.assign (xml::bits::xml_namespace ()); + else + throw dynamic_type (qn); + } + + // Construct the compound type id. + // + string id (tn.data (), tn.size ()); + + if (!tns.empty ()) + { + id += C (' '); + id.append (tns.data (), tns.size ()); + } + + ro_string ro_id (id); + consumer_.start_element (ro_ns, ro_name, &ro_id); + } + catch (schema_exception& e) + { + set_location (e); + throw; + } + } + } + } + + for (XMLSize_t i (0), end (attributes.getLength()); i < end; ++i) + { + const XMLCh* xns (attributes.getURI (i)); + + // When SAX2 reports the xmlns attribute, it does not include + // the proper attribute namespace. So we have to detect and + // rectify this case. + // + if (XMLString::equals (attributes.getQName (i), + XMLUni::fgXMLNSString)) + xns = XMLUni::fgXMLNSURIName; + + string ns (xml::transcode (xns)); + string name (xml::transcode (attributes.getLocalName (i))); + string value (xml::transcode (attributes.getValue (i))); + + // Without this explicit construction IBM XL C++ complains + // about ro_string's copy ctor being private even though the + // temporary has been eliminated. Note that we cannot + // eliminate ns, name and value since ro_string does not make + // a copy. + // + ro_string ro_ns (ns); + ro_string ro_name (name); + ro_string ro_value (value); + + try + { + consumer_.attribute (ro_ns, ro_name, ro_value); + } + catch (schema_exception& e) + { + set_location (e); + throw; + } + } + } + + template + void event_router:: + endElement(const XMLCh* const uri, + const XMLCh* const lname, + const XMLCh* const /*qname*/) + { + typedef std::basic_string string; + + try + { + // Without this explicit construction IBM XL C++ complains + // about ro_string's copy ctor being private even though the + // temporary has been eliminated. Note that we cannot + // eliminate ns, name and value since ro_string does not make + // a copy. + // + if (last_valid_) + { + last_valid_ = false; + ro_string ro_ns (last_ns_); + ro_string ro_name (last_name_); + + consumer_.end_element (ro_ns, ro_name); + } + else + { + string ns (xml::transcode (uri)); + string name (xml::transcode (lname)); + + ro_string ro_ns (ns); + ro_string ro_name (name); + + consumer_.end_element (ro_ns, ro_name); + } + } + catch (schema_exception& e) + { + set_location (e); + throw; + } + } + + template + void event_router:: + characters (const XMLCh* const s, const XMLSize_t n) + { + typedef std::basic_string string; + + if (n != 0) + { + string str (xml::transcode (s, n)); + + // Without this explicit construction IBM XL C++ complains + // about ro_string's copy ctor being private even though the + // temporary has been eliminated. Note that we cannot + // eliminate str since ro_string does not make a copy. + // + ro_string ro_str (str); + + try + { + consumer_.characters (ro_str); + } + catch (schema_exception& e) + { + set_location (e); + throw; + } + } + } + + template + void event_router:: + startPrefixMapping (const XMLCh* const prefix, + const XMLCh* const uri) + { + if (polymorphic_) + { + typedef std::basic_string string; + + string p (xml::transcode (prefix)); + string ns (xml::transcode (uri)); + + ns_decls_.push_back (ns_decl (p, ns)); + } + } + + template + void event_router:: + endPrefixMapping (const XMLCh* const prefix) + { + if (polymorphic_) + { + typedef std::basic_string string; + + string p (xml::transcode (prefix)); + + // Here we assume the prefixes are removed in the reverse + // order of them being added. This appears to how every + // sensible implementation works. + // + assert (ns_decls_.back ().prefix == p); + + ns_decls_.pop_back (); + } + } + + template + void event_router:: + set_location (schema_exception& e) + { + if (loc_ != 0) + { + const XMLCh* id (loc_->getPublicId ()); + + if (id == 0) + id = loc_->getSystemId (); + + if (id != 0) + e.id (xml::transcode (id)); + + e.line (static_cast (loc_->getLineNumber ())); + e.column (static_cast (loc_->getColumnNumber ())); + } + } + } + } + } +} diff --git a/libxsd/libxsd/cxx/parser/xml-schema.hxx b/libxsd/libxsd/cxx/parser/xml-schema.hxx new file mode 100644 index 0000000..1fa218b --- /dev/null +++ b/libxsd/libxsd/cxx/parser/xml-schema.hxx @@ -0,0 +1,570 @@ +// file : libxsd/cxx/parser/xml-schema.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_PARSER_XML_SCHEMA_HXX +#define LIBXSD_CXX_PARSER_XML_SCHEMA_HXX + +#include +#include +#include // std::size_t + +namespace xsd +{ + namespace cxx + { + namespace parser + { + // String sequence. Used for the NMTOKENS and IDREFS types. + // + template + class string_sequence: public std::vector > + { + public: + typedef std::basic_string value_type; + typedef std::vector base; + typedef typename base::size_type size_type; + + string_sequence (); + + explicit + string_sequence (size_type n, const value_type& x = value_type ()); + + template + string_sequence (const I& begin, const I& end); + }; + + template + bool + operator== (const string_sequence&, const string_sequence&); + + template + bool + operator!= (const string_sequence&, const string_sequence&); + + + // QName + // + template + class qname + { + public: + explicit + qname (const std::basic_string& name); + + qname (const std::basic_string& prefix, + const std::basic_string& name); + + void + swap (qname&); + + const std::basic_string& + prefix () const; + + std::basic_string& + prefix (); + + void + prefix (const std::basic_string&); + + const std::basic_string& + name () const; + + std::basic_string& + name (); + + void + name (const std::basic_string&); + + private: + std::basic_string prefix_; + std::basic_string name_; + }; + + template + bool + operator== (const qname&, const qname&); + + template + bool + operator!= (const qname&, const qname&); + + + // Binary buffer. Used for the base64Binary and hexBinary types. + // + class buffer + { + public: + typedef std::size_t size_t; + + class bounds {}; // Out of bounds exception. + + public: + ~buffer (); + + 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); + + // If the assume_ownership argument is true, the buffer will + // assume the ownership of the data and will release the memory + // by calling operator delete (). + // + buffer (void* data, + size_t size, + size_t capacity, + bool assume_ownership); + + buffer (const buffer&); + + public: + buffer& + operator= (const buffer&); + + public: + size_t + capacity () const; + + // Returns true if the underlying buffer has moved. + // + bool + capacity (size_t); + + public: + size_t + size () const; + + // Returns true if the underlying buffer has moved. + // + bool + size (size_t); + + public: + const char* + data () const; + + char* + data (); + + const char* + begin () const; + + char* + begin (); + + const char* + end () const; + + char* + end (); + + public: + void + swap (buffer&); + + private: + bool + capacity (size_t capacity, bool copy); + + private: + char* data_; + size_t size_; + size_t capacity_; + }; + + bool + operator== (const buffer&, const buffer&); + + bool + operator!= (const buffer&, const buffer&); + + + // Time and date types. + // + + class time_zone + { + public: + time_zone (); + time_zone (short hours, short minutes); + + // Returns true if time zone is specified. + // + bool + zone_present () const; + + // Resets the time zone to the 'not specified' state. + // + void + zone_reset (); + + short + zone_hours () const; + + void + zone_hours (short); + + short + zone_minutes () const; + + void + zone_minutes (short); + + private: + bool present_; + short hours_; + short minutes_; + }; + + bool + operator== (const time_zone&, const time_zone&); + + bool + operator!= (const time_zone&, const time_zone&); + + + class gday: public time_zone + { + public: + explicit + gday (unsigned short day); + gday (unsigned short day, short zone_hours, short zone_minutes); + + unsigned short + day () const; + + void + day (unsigned short); + + private: + unsigned short day_; + }; + + bool + operator== (const gday&, const gday&); + + bool + operator!= (const gday&, const gday&); + + + class gmonth: public time_zone + { + public: + explicit + gmonth (unsigned short month); + gmonth (unsigned short month, short zone_hours, short zone_minutes); + + unsigned short + month () const; + + void + month (unsigned short); + + private: + unsigned short month_; + }; + + bool + operator== (const gmonth&, const gmonth&); + + bool + operator!= (const gmonth&, const gmonth&); + + + class gyear: public time_zone + { + public: + explicit + gyear (int year); + gyear (int year, short zone_hours, short zone_minutes); + + int + year () const; + + void + year (int); + + private: + int year_; + }; + + bool + operator== (const gyear&, const gyear&); + + bool + operator!= (const gyear&, const gyear&); + + + class gmonth_day: 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); + + unsigned short + month () const; + + void + month (unsigned short); + + unsigned short + day () const; + + void + day (unsigned short); + + private: + unsigned short month_; + unsigned short day_; + }; + + bool + operator== (const gmonth_day&, const gmonth_day&); + + bool + operator!= (const gmonth_day&, const gmonth_day&); + + + class gyear_month: public time_zone + { + 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); + + private: + int year_; + unsigned short month_; + }; + + bool + operator== (const gyear_month&, const gyear_month&); + + bool + operator!= (const gyear_month&, const gyear_month&); + + + class date: 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); + + int + year () const; + + void + year (int); + + unsigned short + month () const; + + void + month (unsigned short); + + unsigned short + day () const; + + void + day (unsigned short); + + private: + int year_; + unsigned short month_; + unsigned short day_; + }; + + bool + operator== (const date&, const date&); + + bool + operator!= (const date&, const date&); + + + class time: 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); + + unsigned short + hours () const; + + void + hours (unsigned short); + + unsigned short + minutes () const; + + void + minutes (unsigned short); + + double + seconds () const; + + void + seconds (double); + + private: + unsigned short hours_; + unsigned short minutes_; + double seconds_; + }; + + bool + operator== (const time&, const time&); + + bool + operator!= (const time&, const time&); + + + class date_time: 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); + + 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); + + private: + int year_; + unsigned short month_; + unsigned short day_; + unsigned short hours_; + unsigned short minutes_; + double seconds_; + }; + + bool + operator== (const date_time&, const date_time&); + + bool + operator!= (const date_time&, const date_time&); + + + 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); + + private: + bool negative_; + unsigned int years_; + unsigned int months_; + unsigned int days_; + unsigned int hours_; + unsigned int minutes_; + double seconds_; + }; + + bool + operator== (const duration&, const duration&); + + bool + operator!= (const duration&, const duration&); + } + } +} + +#include +#include + +#endif // LIBXSD_CXX_PARSER_XML_SCHEMA_HXX diff --git a/libxsd/libxsd/cxx/parser/xml-schema.ixx b/libxsd/libxsd/cxx/parser/xml-schema.ixx new file mode 100644 index 0000000..48c4165 --- /dev/null +++ b/libxsd/libxsd/cxx/parser/xml-schema.ixx @@ -0,0 +1,1020 @@ +// file : libxsd/cxx/parser/xml-schema.ixx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include // operator new/delete +#include // std::memcpy, std::memcmp + +namespace xsd +{ + namespace cxx + { + namespace parser + { + // string_sequence + // + template + string_sequence:: + string_sequence () + { + } + + template + string_sequence:: + string_sequence (size_type n, const value_type& x) + : base (n, x) + { + } + + template + template + string_sequence:: + string_sequence (const I& begin, const I& end) + : base (begin, end) + { + } + + template + inline bool + operator!= (const string_sequence& a, const string_sequence& b) + { + return !(a == b); + } + + // qname + // + template + inline qname:: + qname (const std::basic_string& name) + : name_ (name) + { + } + + template + inline qname:: + qname (const std::basic_string& prefix, + const std::basic_string& name) + : prefix_ (prefix), name_ (name) + { + } + + template + void qname:: + swap (qname& x) + { + prefix_.swap (x.prefix_); + name_.swap (x.name_); + } + + template + inline const std::basic_string& qname:: + prefix () const + { + return prefix_; + } + + template + inline std::basic_string& qname:: + prefix () + { + return prefix_; + } + + template + inline void qname:: + prefix (const std::basic_string& prefix) + { + prefix_ = prefix; + } + + template + inline const std::basic_string& qname:: + name () const + { + return name_; + } + + template + inline std::basic_string& qname:: + name () + { + return name_; + } + + template + inline void qname:: + name (const std::basic_string& name) + { + name_ = name; + } + + template + inline bool + operator== (const qname& a, const qname& b) + { + return a.prefix () == b.prefix () && a.name () == b.name (); + } + + template + inline bool + operator!= (const qname& a, const qname& b) + { + return !(a == b); + } + + // buffer + // + inline buffer:: + ~buffer () + { + if (data_) + operator delete (data_); + } + + inline buffer:: + buffer (size_t size) + : data_ (0), size_ (0), capacity_ (0) + { + capacity (size); + size_ = size; + } + + inline buffer:: + buffer (size_t size, size_t cap) + : data_ (0), size_ (0), capacity_ (0) + { + if (size > cap) + throw bounds (); + + capacity (cap); + size_ = size; + } + + inline buffer:: + buffer (const void* data, size_t size) + : data_ (0), size_ (0), capacity_ (0) + { + capacity (size); + size_ = size; + + if (size_) + std::memcpy (data_, data, size_); + } + + inline buffer:: + buffer (const void* data, size_t size, size_t cap) + : data_ (0), size_ (0), capacity_ (0) + { + if (size > cap) + throw bounds (); + + capacity (cap); + size_ = size; + + if (size_) + std::memcpy (data_, data, size_); + } + + inline buffer:: + buffer (void* data, size_t size, size_t cap, bool own) + : data_ (0), size_ (0), capacity_ (0) + { + if (size > cap) + throw bounds (); + + if (own) + { + data_ = reinterpret_cast (data); + size_ = size; + capacity_ = cap; + } + else + { + capacity (cap); + size_ = size; + + if (size_) + std::memcpy (data_, data, size_); + } + } + + inline buffer:: + buffer (const buffer& other) + : data_ (0), size_ (0), capacity_ (0) + { + capacity (other.capacity_); + size_ = other.size_; + + if (size_) + std::memcpy (data_, other.data_, size_); + } + + inline buffer& buffer:: + operator= (const buffer& other) + { + if (this != &other) + { + capacity (other.capacity_, false); + size_ = other.size_; + + if (size_) + std::memcpy (data_, other.data_, size_); + } + + return *this; + } + + inline size_t buffer:: + capacity () const + { + return capacity_; + } + + inline bool buffer:: + capacity (size_t cap) + { + return capacity (cap, true); + } + + inline size_t buffer:: + size () const + { + return size_; + } + + inline bool buffer:: + size (size_t size) + { + bool r (false); + + if (size > capacity_) + r = capacity (size); + + size_ = size; + + return r; + } + + inline const char* buffer:: + data () const + { + return data_; + } + + inline char* buffer:: + data () + { + return data_; + } + + inline const char* buffer:: + begin () const + { + return data_; + } + + inline char* buffer:: + begin () + { + return data_; + } + + inline const char* buffer:: + end () const + { + return data_ + size_; + } + + inline char* buffer:: + end () + { + return data_ + size_; + } + + inline void buffer:: + swap (buffer& other) + { + char* tmp_data (data_); + size_t tmp_size (size_); + size_t tmp_capacity (capacity_); + + data_ = other.data_; + size_ = other.size_; + capacity_ = other.capacity_; + + other.data_ = tmp_data; + other.size_ = tmp_size; + other.capacity_ = tmp_capacity; + } + + inline bool buffer:: + capacity (size_t capacity, bool copy) + { + if (size_ > capacity) + throw bounds (); + + if (capacity <= capacity_) + { + return false; // Do nothing if shrinking is requested. + } + else + { + char* data (reinterpret_cast (operator new (capacity))); + + if (copy && size_ > 0) + std::memcpy (data, data_, size_); + + if (data_) + operator delete (data_); + + data_ = data; + capacity_ = capacity; + + return true; + } + } + + inline bool + operator== (const buffer& a, const buffer& b) + { + return a.size () == b.size () && + std::memcmp (a.data (), b.data (), a.size ()) == 0; + } + + inline bool + operator!= (const buffer& a, const buffer& b) + { + return !(a == b); + } + + // time_zone + // + inline time_zone:: + time_zone () + : present_ (false) + { + } + + inline time_zone:: + time_zone (short h, short m) + : present_ (true), hours_ (h), minutes_ (m) + { + } + + inline bool time_zone:: + zone_present () const + { + return present_; + } + + inline void time_zone:: + zone_reset () + { + present_ = false; + } + + inline short time_zone:: + zone_hours () const + { + return hours_; + } + + inline void time_zone:: + zone_hours (short h) + { + hours_ = h; + present_ = true; + } + + inline short time_zone:: + zone_minutes () const + { + return minutes_; + } + + inline void time_zone:: + zone_minutes (short m) + { + minutes_ = m; + present_ = true; + } + + inline bool + operator== (const time_zone& x, const time_zone& y) + { + return x.zone_present () + ? y.zone_present () && + x.zone_hours () == y.zone_hours () && + x.zone_minutes () == y.zone_minutes () + : !y.zone_present (); + } + + inline bool + operator!= (const time_zone& x, const time_zone& y) + { + return !(x == y); + } + + // gday + // + inline gday:: + gday (unsigned short day) + : day_ (day) + { + } + + inline gday:: + gday (unsigned short day, short zh, short zm) + : time_zone (zh, zm), day_ (day) + { + } + + inline unsigned short gday:: + day () const + { + return day_; + } + + inline void gday:: + day (unsigned short day) + { + day_ = day; + } + + inline bool + operator== (const gday& a, const gday& b) + { + const time_zone& az = a; + const time_zone& bz = b; + + return a.day () == b.day () && az == bz; + } + + inline bool + operator!= (const gday& a, const gday& b) + { + return !(a == b); + } + + // gmonth + // + inline gmonth:: + gmonth (unsigned short month) + : month_ (month) + { + } + + inline gmonth:: + gmonth (unsigned short month, short zh, short zm) + : time_zone (zh, zm), month_ (month) + { + } + + inline unsigned short gmonth:: + month () const + { + return month_; + } + + inline void gmonth:: + month (unsigned short month) + { + month_ = month; + } + + inline bool + operator== (const gmonth& a, const gmonth& b) + { + const time_zone& az = a; + const time_zone& bz = b; + + return a.month () == b.month () && az == bz; + } + + inline bool + operator!= (const gmonth& a, const gmonth& b) + { + return !(a == b); + } + + // gyear + // + inline gyear:: + gyear (int year) + : year_ (year) + { + } + + inline gyear:: + gyear (int year, short zh, short zm) + : time_zone (zh, zm), year_ (year) + { + } + + inline int gyear:: + year () const + { + return year_; + } + + inline void gyear:: + year (int year) + { + year_ = year; + } + + inline bool + operator== (const gyear& a, const gyear& b) + { + const time_zone& az = a; + const time_zone& bz = b; + + return a.year () == b.year () && az == bz; + } + + inline bool + operator!= (const gyear& a, const gyear& b) + { + return !(a == b); + } + + // gmonth_day + // + inline gmonth_day:: + gmonth_day (unsigned short month, unsigned short day) + : month_ (month), day_ (day) + { + } + + inline gmonth_day:: + gmonth_day (unsigned short month, + unsigned short day, + short zh, short zm) + : time_zone (zh, zm), month_ (month), day_ (day) + { + } + + inline unsigned short gmonth_day:: + month () const + { + return month_; + } + + inline void gmonth_day:: + month (unsigned short month) + { + month_ = month; + } + + inline unsigned short gmonth_day:: + day () const + { + return day_; + } + + inline void gmonth_day:: + day (unsigned short day) + { + day_ = day; + } + + inline bool + operator== (const gmonth_day& a, const gmonth_day& b) + { + const time_zone& az = a; + const time_zone& bz = b; + + return a.month () == b.month () && + a.day () == b.day () && + az == bz; + } + + inline bool + operator!= (const gmonth_day& a, const gmonth_day& b) + { + return !(a == b); + } + + // gyear_month + // + inline gyear_month:: + gyear_month (int year, unsigned short month) + : year_ (year), month_ (month) + { + } + + inline gyear_month:: + gyear_month (int year, unsigned short month, + short zh, short zm) + : time_zone (zh, zm), year_ (year), month_ (month) + { + } + + inline int gyear_month:: + year () const + { + return year_; + } + + inline void gyear_month:: + year (int year) + { + year_ = year; + } + + inline unsigned short gyear_month:: + month () const + { + return month_; + } + + inline void gyear_month:: + month (unsigned short month) + { + month_ = month; + } + + inline bool + operator== (const gyear_month& a, const gyear_month& b) + { + const time_zone& az = a; + const time_zone& bz = b; + + return a.year () == b.year () && + a.month () == b.month () && + az == bz; + } + + inline bool + operator!= (const gyear_month& a, const gyear_month& b) + { + return !(a == b); + } + + // date + // + inline date:: + date (int year, unsigned short month, unsigned short day) + : year_ (year), month_ (month), day_ (day) + { + } + + inline date:: + date (int year, unsigned short month, unsigned short day, + short zh, short zm) + : time_zone (zh, zm), year_ (year), month_ (month), day_ (day) + { + } + + inline int date:: + year () const + { + return year_; + } + + inline void date:: + year (int year) + { + year_ = year; + } + + inline unsigned short date:: + month () const + { + return month_; + } + + inline void date:: + month (unsigned short month) + { + month_ = month; + } + + inline unsigned short date:: + day () const + { + return day_; + } + + inline void date:: + day (unsigned short day) + { + day_ = day; + } + + inline bool + operator== (const date& a, const date& b) + { + const time_zone& az = a; + const time_zone& bz = b; + + return a.year () == b.year () && + a.month () == b.month () && + a.day () == b.day () && + az == bz; + } + + inline bool + operator!= (const date& a, const date& b) + { + return !(a == b); + } + + // time + // + inline time:: + time (unsigned short hours, unsigned short minutes, double seconds) + : hours_ (hours), minutes_ (minutes), seconds_ (seconds) + { + } + + inline time:: + time (unsigned short hours, unsigned short minutes, double seconds, + short zh, short zm) + : time_zone (zh, zm), + hours_ (hours), minutes_ (minutes), seconds_ (seconds) + { + } + + inline unsigned short time:: + hours () const + { + return hours_; + } + + inline void time:: + hours (unsigned short hours) + { + hours_ = hours; + } + + inline unsigned short time:: + minutes () const + { + return minutes_; + } + + inline void time:: + minutes (unsigned short minutes) + { + minutes_ = minutes; + } + + inline double time:: + seconds () const + { + return seconds_; + } + + inline void time:: + seconds (double seconds) + { + seconds_ = seconds; + } + + inline bool + operator== (const time& a, const time& b) + { + const time_zone& az = a; + const time_zone& bz = b; + + return a.hours () == b.hours () && + a.minutes () == b.minutes () && + a.seconds () == b.seconds () && + az == bz; + } + + inline bool + operator!= (const time& a, const time& b) + { + return !(a == b); + } + + // date_time + // + inline date_time:: + date_time (int year, unsigned short month, unsigned short day, + unsigned short hours, unsigned short minutes, double seconds) + : year_ (year), month_ (month), day_ (day), + hours_ (hours), minutes_ (minutes), seconds_ (seconds) + { + } + + inline date_time:: + date_time (int year, unsigned short month, unsigned short day, + unsigned short hours, unsigned short minutes, double seconds, + short zh, short zm) + : time_zone (zh, zm), + year_ (year), month_ (month), day_ (day), + hours_ (hours), minutes_ (minutes), seconds_ (seconds) + { + } + + inline int date_time:: + year () const + { + return year_; + } + + inline void date_time:: + year (int year) + { + year_ = year; + } + + inline unsigned short date_time:: + month () const + { + return month_; + } + + inline void date_time:: + month (unsigned short month) + { + month_ = month; + } + + inline unsigned short date_time:: + day () const + { + return day_; + } + + inline void date_time:: + day (unsigned short day) + { + day_ = day; + } + + inline unsigned short date_time:: + hours () const + { + return hours_; + } + + inline void date_time:: + hours (unsigned short hours) + { + hours_ = hours; + } + + inline unsigned short date_time:: + minutes () const + { + return minutes_; + } + + inline void date_time:: + minutes (unsigned short minutes) + { + minutes_ = minutes; + } + + inline double date_time:: + seconds () const + { + return seconds_; + } + + inline void date_time:: + seconds (double seconds) + { + seconds_ = seconds; + } + + inline bool + operator== (const date_time& a, const date_time& b) + { + const time_zone& az = a; + const time_zone& bz = b; + + return a.year () == b.year () && + a.month () == b.month () && + a.day () == b.day () && + a.hours () == b.hours () && + a.minutes () == b.minutes () && + a.seconds () == b.seconds () && + az == bz; + } + + inline bool + operator!= (const date_time& a, const date_time& b) + { + return !(a == b); + } + + // duration + // + inline duration:: + duration (bool negative, + unsigned int years, unsigned int months, unsigned int days, + unsigned int hours, unsigned int minutes, double seconds) + : negative_ (negative), + years_ (years), months_ (months), days_ (days), + hours_ (hours), minutes_ (minutes), seconds_ (seconds) + { + } + + inline bool duration:: + negative () const + { + return negative_; + } + + inline void duration:: + negative (bool negative) + { + negative_ = negative; + } + + inline unsigned int duration:: + years () const + { + return years_; + } + + inline void duration:: + years (unsigned int years) + { + years_ = years; + } + + inline unsigned int duration:: + months () const + { + return months_; + } + + inline void duration:: + months (unsigned int months) + { + months_ = months; + } + + inline unsigned int duration:: + days () const + { + return days_; + } + + inline void duration:: + days (unsigned int days) + { + days_ = days; + } + + inline unsigned int duration:: + hours () const + { + return hours_; + } + + inline void duration:: + hours (unsigned int hours) + { + hours_ = hours; + } + + inline unsigned int duration:: + minutes () const + { + return minutes_; + } + + inline void duration:: + minutes (unsigned int minutes) + { + minutes_ = minutes; + } + + inline double duration:: + seconds () const + { + return seconds_; + } + + inline void duration:: + seconds (double seconds) + { + seconds_ = seconds; + } + + inline bool + operator== (const duration& a, const duration& b) + { + return a.negative () == b.negative () && + a.years () == b.years () && + a.months () == b.months () && + a.days () == b.days () && + a.hours () == b.hours () && + a.minutes () == b.minutes () && + a.seconds () == b.seconds (); + } + + inline bool + operator!= (const duration& a, const duration& b) + { + return !(a == b); + } + } + } +} diff --git a/libxsd/libxsd/cxx/parser/xml-schema.txx b/libxsd/libxsd/cxx/parser/xml-schema.txx new file mode 100644 index 0000000..47b952e --- /dev/null +++ b/libxsd/libxsd/cxx/parser/xml-schema.txx @@ -0,0 +1,32 @@ +// file : libxsd/cxx/parser/xml-schema.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsd +{ + namespace cxx + { + namespace parser + { + // string_sequence + // + template + bool + operator== (const string_sequence& a, const string_sequence& b) + { + if (a.size () != b.size ()) + return false; + + for (typename string_sequence::const_iterator + ai (a.begin ()), bi (b.begin ()), ae (a.end ()); + ai != ae; ++ai, ++bi) + { + if (*ai != *bi) + return false; + } + + return true; + } + } + } +} + diff --git a/libxsd/libxsd/cxx/post.hxx b/libxsd/libxsd/cxx/post.hxx new file mode 100644 index 0000000..32a4428 --- /dev/null +++ b/libxsd/libxsd/cxx/post.hxx @@ -0,0 +1,8 @@ +// file : libxsd/cxx/post.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifdef _MSC_VER +# if (_MSC_VER >= 1400) +# include +# endif +#endif diff --git a/libxsd/libxsd/cxx/pre.hxx b/libxsd/libxsd/cxx/pre.hxx new file mode 100644 index 0000000..2a1cb01 --- /dev/null +++ b/libxsd/libxsd/cxx/pre.hxx @@ -0,0 +1,10 @@ +// file : libxsd/cxx/pre.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifdef _MSC_VER +# if (_MSC_VER >= 1400) +# include +# else +# error Microsoft Visual C++ 7.1 and earlier are not supported +# endif +#endif diff --git a/libxsd/libxsd/cxx/ro-string.hxx b/libxsd/libxsd/cxx/ro-string.hxx new file mode 100644 index 0000000..3edb560 --- /dev/null +++ b/libxsd/libxsd/cxx/ro-string.hxx @@ -0,0 +1,428 @@ +// file : libxsd/cxx/ro-string.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_RO_STRING_HXX +#define LIBXSD_CXX_RO_STRING_HXX + +#include +#include // std::size_t +#include + +namespace xsd +{ + namespace cxx + { + // Read-only string class template. + // + template + class ro_string + { + public: + typedef std::char_traits traits_type; + typedef std::size_t size_type; + + static const size_type npos = ~(size_type (0)); + + public: + ro_string () + : data_ (0), size_ (0) + { + } + + ro_string (const C* s) + : data_ (s), size_ (traits_type::length (s)) + { + } + + ro_string (const C* s, size_type size) + : data_ (s), size_ (size) + { + } + + ro_string (const std::basic_string& s) + : data_ (s.data ()), size_ (s.size ()) + { + } + + operator std::basic_string () const + { + return std::basic_string (data (), size ()); + } + + private: + ro_string (const ro_string&); + + ro_string& + operator= (const ro_string&); + + public: + // The returned string is not necessarily terminated with '\0'. + // If size() returns 0, the returned pointer may be 0. + // + const C* + data () const + { + return data_; + } + + size_type + size () const + { + return size_; + } + + size_type + length () const + { + return size (); + } + + public: + bool + empty () const + { + return size () == 0; + } + + const C& + operator[] (size_type pos) const + { + return data ()[pos]; + } + + public: + void + assign (const C* s) + { + data_ = s; + size_ = traits_type::length (s); + } + + void + assign (const C* s, size_type size) + { + data_ = s; + size_ = size; + } + + void + assign (const std::basic_string& s) + { + data_ = s.c_str (); + size_ = s.size (); + } + + public: + int + compare (const ro_string& str) const + { + return compare (str.data (), str.size ()); + } + + int + compare (const std::basic_string& str) const + { + return compare (str.c_str (), str.size ()); + } + + int + compare (const C* str) const + { + return compare (str, traits_type::length (str)); + } + + int + compare (const C* str, size_type n) const + { + size_type s1 (size ()); + size_type s (s1 < n ? s1 : n); + + int r (s != 0 ? traits_type::compare (data (), str, s) : 0); + + if (!r && s1 != n) + r = s1 < n ? -1 : 1; + + return r; + } + + public: + size_type + find (C c, size_type pos = 0) const; + + private: + const C* data_; + size_type size_; + }; + + // operator== + // + template + inline bool + operator== (const ro_string& a, const ro_string& b) + { + return a.compare (b) == 0; + } + + template + inline bool + operator== (const ro_string& a, const std::basic_string& b) + { + return a.compare (b) == 0; + } + + template + inline bool + operator== (const std::basic_string& a, const ro_string& b) + { + return b.compare (a) == 0; + } + + template + inline bool + operator== (const ro_string& a, const C* b) + { + return a.compare (b) == 0; + } + + template + inline bool + operator== (const C* a, const ro_string& b) + { + return b.compare (a) == 0; + } + + // operator!= + // + template + inline bool + operator!= (const ro_string& a, const ro_string& b) + { + return a.compare (b) != 0; + } + + template + inline bool + operator!= (const ro_string& a, const std::basic_string& b) + { + return a.compare (b) != 0; + } + + template + inline bool + operator!= (const std::basic_string& a, const ro_string& b) + { + return b.compare (a) != 0; + } + + template + inline bool + operator!= (const ro_string& a, const C* b) + { + return a.compare (b) != 0; + } + + template + inline bool + operator!= (const C* a, const ro_string& b) + { + return b.compare (a) != 0; + } + + // operator< + // + template + inline bool + operator< (const ro_string& l, const ro_string& r) + { + return l.compare (r) < 0; + } + + template + inline bool + operator< (const ro_string& l, const std::basic_string& r) + { + return l.compare (r) < 0; + } + + template + inline bool + operator< (const std::basic_string& l, const ro_string& r) + { + return r.compare (l) > 0; + } + + template + inline bool + operator< (const ro_string& l, const C* r) + { + return l.compare (r) < 0; + } + + template + inline bool + operator< (const C* l, const ro_string& r) + { + return r.compare (l) > 0; + } + + + // operator> + // + template + inline bool + operator> (const ro_string& l, const ro_string& r) + { + return l.compare (r) > 0; + } + + template + inline bool + operator> (const ro_string& l, const std::basic_string& r) + { + return l.compare (r) > 0; + } + + template + inline bool + operator> (const std::basic_string& l, const ro_string& r) + { + return r.compare (l) < 0; + } + + template + inline bool + operator> (const ro_string& l, const C* r) + { + return l.compare (r) > 0; + } + + template + inline bool + operator> (const C* l, const ro_string& r) + { + return r.compare (l) < 0; + } + + // operator<= + // + template + inline bool + operator<= (const ro_string& l, const ro_string& r) + { + return l.compare (r) <= 0; + } + + template + inline bool + operator<= (const ro_string& l, const std::basic_string& r) + { + return l.compare (r) <= 0; + } + + template + inline bool + operator<= (const std::basic_string& l, const ro_string& r) + { + return r.compare (l) >= 0; + } + + template + inline bool + operator<= (const ro_string& l, const C* r) + { + return l.compare (r) <= 0; + } + + template + inline bool + operator<= (const C* l, const ro_string& r) + { + return r.compare (l) >= 0; + } + + + // operator>= + // + template + inline bool + operator>= (const ro_string& l, const ro_string& r) + { + return l.compare (r) >= 0; + } + + template + inline bool + operator>= (const ro_string& l, const std::basic_string& r) + { + return l.compare (r) >= 0; + } + + template + inline bool + operator>= (const std::basic_string& l, const ro_string& r) + { + return r.compare (l) <= 0; + } + + template + inline bool + operator>= (const ro_string& l, const C* r) + { + return l.compare (r) >= 0; + } + + template + inline bool + operator>= (const C* l, const ro_string& r) + { + return r.compare (l) <= 0; + } + + // operator<< + // + template + std::basic_ostream& + operator<< (std::basic_ostream& os, const ro_string& str) + { + if (str.size () != 0) + os.write (str.data (), static_cast (str.size ())); + + return os; + } + + // operator+= + // + template + std::basic_string& + operator+= (std::basic_string& l, const ro_string& r) + { + l.append (r.data (), r.size ()); + return l; + } + + // Trim leading and trailing XML whitespaces. Return the new + // string size. + // + template + typename ro_string::size_type + trim_left (ro_string&); + + template + typename ro_string::size_type + trim_right (ro_string&); + + template + typename ro_string::size_type + trim (ro_string&); + + // Trim leading and trailing XML whitespaces. + // + template + std::basic_string + trim (const std::basic_string&); + } +} + +#include + +#endif // LIBXSD_CXX_RO_STRING_HXX diff --git a/libxsd/libxsd/cxx/ro-string.txx b/libxsd/libxsd/cxx/ro-string.txx new file mode 100644 index 0000000..039565c --- /dev/null +++ b/libxsd/libxsd/cxx/ro-string.txx @@ -0,0 +1,131 @@ +// file : libxsd/cxx/ro-string.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsd +{ + namespace cxx + { + template + typename ro_string::size_type ro_string:: + find (C c, size_type pos) const + { + size_type r (npos); + + if (pos < size_) + { + if (const C* p = traits_type::find(data_ + pos, size_ - pos, c)) + r = p - data_; + } + + return r; + } + + template + typename ro_string::size_type + trim_left (ro_string& s) + { + typename ro_string::size_type size (s.size ()); + + if (size != 0) + { + const C* f (s.data ()); + const C* l (f + size); + const C* of (f); + + while (f < l && + (*f == C (0x20) || *f == C (0x0A) || + *f == C (0x0D) || *f == C (0x09))) + ++f; + + if (f != of) + { + size = f <= l ? l - f : 0; + s.assign ((f <= l ? f : 0), size); + } + } + + return size; + } + + template + typename ro_string::size_type + trim_right (ro_string& s) + { + typename ro_string::size_type size (s.size ()); + + if (size != 0) + { + const C* f (s.data ()); + const C* l (f + size - 1); + const C* ol (l); + + while (l > f && + (*l == C (0x20) || *l == C (0x0A) || + *l == C (0x0D) || *l == C (0x09))) + --l; + + if (l != ol) + { + size = f <= l ? l - f + 1 : 0; + s.assign ((f <= l ? f : 0), size); + } + } + + return size; + } + + template + typename ro_string::size_type + trim (ro_string& s) + { + typename ro_string::size_type size (s.size ()); + + if (size != 0) + { + const C* f (s.data ()); + const C* l (f + size); + + const C* of (f); + + while (f < l && + (*f == C (0x20) || *f == C (0x0A) || + *f == C (0x0D) || *f == C (0x09))) + ++f; + + --l; + + const C* ol (l); + + while (l > f && + (*l == C (0x20) || *l == C (0x0A) || + *l == C (0x0D) || *l == C (0x09))) + --l; + + if (f != of || l != ol) + { + size = f <= l ? l - f + 1 : 0; + s.assign ((f <= l ? f : 0), size); + } + } + + return size; + } + + template + std::basic_string + trim (const std::basic_string& s) + { + ro_string tmp (s); + typename ro_string::size_type size (tmp.size ()); + trim (tmp); + + // If we didn't change the string then return the original to help + // avoid copying for smart (ref counted) string implementations. + // + if (size == tmp.size ()) + return s; + else + return tmp; + } + } +} diff --git a/libxsd/libxsd/cxx/tree/ace-cdr-stream-common.hxx b/libxsd/libxsd/cxx/tree/ace-cdr-stream-common.hxx new file mode 100644 index 0000000..4bcc151 --- /dev/null +++ b/libxsd/libxsd/cxx/tree/ace-cdr-stream-common.hxx @@ -0,0 +1,24 @@ +// file : libxsd/cxx/tree/ace-cdr-stream-common.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_TREE_ACE_CDR_STREAM_COMMON_HXX +#define LIBXSD_CXX_TREE_ACE_CDR_STREAM_COMMON_HXX + +#include + +namespace xsd +{ + namespace cxx + { + namespace tree + { + // Base exception for ACE CDR insertion/extraction exceptions. + // + struct ace_cdr_stream_operation: xsd::cxx::exception + { + }; + } + } +} + +#endif // LIBXSD_CXX_TREE_ACE_CDR_STREAM_COMMON_HXX diff --git a/libxsd/libxsd/cxx/tree/ace-cdr-stream-extraction.hxx b/libxsd/libxsd/cxx/tree/ace-cdr-stream-extraction.hxx new file mode 100644 index 0000000..c6d4876 --- /dev/null +++ b/libxsd/libxsd/cxx/tree/ace-cdr-stream-extraction.hxx @@ -0,0 +1,346 @@ +// file : libxsd/cxx/tree/ace-cdr-stream-extraction.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_TREE_ACE_CDR_STREAM_EXTRACTION_HXX +#define LIBXSD_CXX_TREE_ACE_CDR_STREAM_EXTRACTION_HXX + +#include // std::size_t +#include + +#include // ACE::strdelete +#include + +#include // XSD_CXX11 + +#ifdef XSD_CXX11 +# include // std::unique_ptr +#else +# include +#endif + +#include +#include +#include + +namespace xsd +{ + namespace cxx + { + namespace tree + { + struct ace_cdr_stream_extraction: ace_cdr_stream_operation + { + virtual const char* + what () const throw () + { + return "ACE CDR stream extraction operation failed"; + } + }; + + + // as_size + // + +#ifdef XSD_CXX_TREE_USE_64_BIT_SIZE + template + inline istream& + operator>> (istream& s, + istream::as_size& x) + { + ACE_CDR::ULongLong r; + + if (!s.impl ().read_ulonglong (r) || + r > ~(T (0))) + throw ace_cdr_stream_extraction (); + + x.x_ = static_cast (r); + + return s; + } +#else + template + inline istream& + operator>> (istream& s, + istream::as_size& x) + { + ACE_CDR::ULong r; + + if (!s.impl ().read_ulong (r)) + throw ace_cdr_stream_extraction (); + + x.x_ = static_cast (r); + + return s; + } +#endif + + + // 8-bit + // + template + inline istream& + operator>> (istream& s, + istream::as_int8& x) + { + ACE_CDR::Octet r; + + if (!s.impl ().read_octet (r)) + throw ace_cdr_stream_extraction (); + + x.x_ = static_cast (r); + + return s; + } + + template + inline istream& + operator>> (istream& s, + istream::as_uint8& x) + { + ACE_CDR::Octet r; + + if (!s.impl ().read_octet (r)) + throw ace_cdr_stream_extraction (); + + x.x_ = static_cast (r); + + return s; + } + + + // 16-bit + // + template + inline istream& + operator>> (istream& s, + istream::as_int16& x) + { + ACE_CDR::Short r; + + if (!s.impl ().read_short (r)) + throw ace_cdr_stream_extraction (); + + x.x_ = static_cast (r); + + return s; + } + + template + inline istream& + operator>> (istream& s, + istream::as_uint16& x) + { + ACE_CDR::UShort r; + + if (!s.impl ().read_ushort (r)) + throw ace_cdr_stream_extraction (); + + x.x_ = static_cast (r); + + return s; + } + + + // 32-bit + // + template + inline istream& + operator>> (istream& s, + istream::as_int32& x) + { + ACE_CDR::Long r; + + if (!s.impl ().read_long (r)) + throw ace_cdr_stream_extraction (); + + x.x_ = static_cast (r); + + return s; + } + + template + inline istream& + operator>> (istream& s, + istream::as_uint32& x) + { + ACE_CDR::ULong r; + + if (!s.impl ().read_ulong (r)) + throw ace_cdr_stream_extraction (); + + x.x_ = static_cast (r); + + return s; + } + + + // 64-bit + // + template + inline istream& + operator>> (istream& s, + istream::as_int64& x) + { + ACE_CDR::LongLong r; + + if (!s.impl ().read_longlong (r)) + throw ace_cdr_stream_extraction (); + + x.x_ = static_cast (r); + + return s; + } + + template + inline istream& + operator>> (istream& s, + istream::as_uint64& x) + { + ACE_CDR::ULongLong r; + + if (!s.impl ().read_ulonglong (r)) + throw ace_cdr_stream_extraction (); + + x.x_ = static_cast (r); + + return s; + } + + + // Boolean + // + template + inline istream& + operator>> (istream& s, + istream::as_bool& x) + { + ACE_CDR::Boolean r; + + if (!s.impl ().read_boolean (r)) + throw ace_cdr_stream_extraction (); + + x.x_ = static_cast (r); + + return s; + } + + + // Floating-point + // + template + inline istream& + operator>> (istream& s, + istream::as_float32& x) + { + ACE_CDR::Float r; + + if (!s.impl ().read_float (r)) + throw ace_cdr_stream_extraction (); + + x.x_ = static_cast (r); + + return s; + } + + template + inline istream& + operator>> (istream& s, + istream::as_float64& x) + { + ACE_CDR::Double r; + + if (!s.impl ().read_double (r)) + throw ace_cdr_stream_extraction (); + + x.x_ = static_cast (r); + + return s; + } + + // Extraction of std::basic_string. + // + + namespace bits + { + template + struct ace_str_deleter + { + void + operator() (C* s) const + { + ACE::strdelete (s); + } + }; + } + + inline istream& + operator>> (istream& s, std::basic_string& x) + { + typedef bits::ace_str_deleter deleter; + + deleter d; + char* r; + + if (!s.impl ().read_string (r)) + throw ace_cdr_stream_extraction (); + +#ifdef XSD_CXX11 + std::unique_ptr ar ( +#else + auto_array ar ( +#endif + r, d); + + x = r; + return s; + } + +#ifdef ACE_HAS_WCHAR + inline istream& + operator>> (istream& s, std::basic_string& x) + { + typedef bits::ace_str_deleter deleter; + + deleter d; + wchar_t* r; + + if (!s.impl ().read_wstring (r)) + throw ace_cdr_stream_extraction (); + +#ifdef XSD_CXX11 + std::unique_ptr ar ( +#else + auto_array ar ( +#endif + r, d); + + x = r; + return s; + } +#endif + + + // Extraction of a binary buffer. + // + template + istream& + operator>> (istream& s, buffer& x) + { + ACE_CDR::ULong size; + + if (!s.impl ().read_ulong (size)) + throw ace_cdr_stream_extraction (); + + x.size (size); + + if (!s.impl ().read_octet_array ( + reinterpret_cast (x.data ()), size)) + throw ace_cdr_stream_extraction (); + + return s; + } + } + } +} + +#endif // LIBXSD_CXX_TREE_ACE_CDR_STREAM_EXTRACTION_HXX diff --git a/libxsd/libxsd/cxx/tree/ace-cdr-stream-insertion.hxx b/libxsd/libxsd/cxx/tree/ace-cdr-stream-insertion.hxx new file mode 100644 index 0000000..4be3fc5 --- /dev/null +++ b/libxsd/libxsd/cxx/tree/ace-cdr-stream-insertion.hxx @@ -0,0 +1,247 @@ +// file : libxsd/cxx/tree/ace-cdr-stream-insertion.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_TREE_ACE_CDR_STREAM_INSERTION_HXX +#define LIBXSD_CXX_TREE_ACE_CDR_STREAM_INSERTION_HXX + +#include // std::size_t +#include + +#include + +#include +#include +#include + +namespace xsd +{ + namespace cxx + { + namespace tree + { + struct ace_cdr_stream_insertion: ace_cdr_stream_operation + { + virtual const char* + what () const throw () + { + return "ACE CDR stream insertion operation failed"; + } + }; + + + // as_size + // + +#ifdef XSD_CXX_TREE_USE_64_BIT_SIZE + template + inline ostream& + operator<< (ostream& s, + ostream::as_size x) + { + if (!s.impl ().write_ulonglong ( + static_cast (x.x_))) + throw ace_cdr_stream_insertion (); + return s; + } +#else + template + inline ostream& + operator<< (ostream& s, + ostream::as_size x) + { + if (x.x_ > ~(ACE_CDR::ULong (0)) || + !s.impl ().write_ulong (static_cast (x.x_))) + throw ace_cdr_stream_insertion (); + + return s; + } +#endif + + + // 8-bit + // + template + inline ostream& + operator<< (ostream& s, + ostream::as_int8 x) + { + ACE_CDR::Octet r (static_cast (x.x_)); + + if (!s.impl ().write_octet (r)) + throw ace_cdr_stream_insertion (); + + return s; + } + + template + inline ostream& + operator<< (ostream& s, + ostream::as_uint8 x) + { + ACE_CDR::Octet r (static_cast (x.x_)); + + if (!s.impl ().write_octet (r)) + throw ace_cdr_stream_insertion (); + + return s; + } + + + // 16-bit + // + template + inline ostream& + operator<< (ostream& s, + ostream::as_int16 x) + { + if (!s.impl ().write_short (static_cast (x.x_))) + throw ace_cdr_stream_insertion (); + return s; + } + + template + inline ostream& + operator<< (ostream& s, + ostream::as_uint16 x) + { + if (!s.impl ().write_ushort (static_cast (x.x_))) + throw ace_cdr_stream_insertion (); + return s; + } + + + // 32-bit + // + template + inline ostream& + operator<< (ostream& s, + ostream::as_int32 x) + { + if (!s.impl ().write_long (static_cast (x.x_))) + throw ace_cdr_stream_insertion (); + return s; + } + + template + inline ostream& + operator<< (ostream& s, + ostream::as_uint32 x) + { + if (!s.impl ().write_ulong (static_cast (x.x_))) + throw ace_cdr_stream_insertion (); + return s; + } + + + // 64-bit + // + template + inline ostream& + operator<< (ostream& s, + ostream::as_int64 x) + { + if (!s.impl ().write_longlong (static_cast (x.x_))) + throw ace_cdr_stream_insertion (); + return s; + } + + template + inline ostream& + operator<< (ostream& s, + ostream::as_uint64 x) + { + if (!s.impl ().write_ulonglong ( + static_cast (x.x_))) + throw ace_cdr_stream_insertion (); + return s; + } + + + // Boolean + // + template + inline ostream& + operator<< (ostream& s, + ostream::as_bool x) + { + if (!s.impl ().write_boolean (static_cast (x.x_))) + throw ace_cdr_stream_insertion (); + return s; + } + + + // Floating-point + // + template + inline ostream& + operator<< (ostream& s, + ostream::as_float32 x) + { + if (!s.impl ().write_float (static_cast (x.x_))) + throw ace_cdr_stream_insertion (); + return s; + } + + template + inline ostream& + operator<< (ostream& s, + ostream::as_float64 x) + { + if (!s.impl ().write_double (static_cast (x.x_))) + throw ace_cdr_stream_insertion (); + return s; + } + + // Insertion of std::basic_string. + // + + inline ostream& + operator<< (ostream& s, const std::basic_string& x) + { + // ACE CDR strings are hard-wired with a 32 bit length. + // + if (x.length () > ~(ACE_CDR::ULong (0)) || + !s.impl ().write_string ( + static_cast (x.length ()), x.c_str ())) + throw ace_cdr_stream_insertion (); + return s; + } + +#ifdef ACE_HAS_WCHAR + inline ostream& + operator<< (ostream& s, + const std::basic_string& x) + { + // ACE CDR strings are hard-wired with a 32 bit length. + // + if (x.length () > ~(ACE_CDR::ULong (0)) || + !s.impl ().write_wstring ( + static_cast (x.length ()), x.c_str ())) + throw ace_cdr_stream_insertion (); + return s; + } +#endif + + // Insertion of a binary buffer. + // + template + ostream& + operator<< (ostream& s, const buffer& x) + { + std::size_t size (x.size ()); + + // It is not possible to write an array with a 64-bit size. + // + if (size > ~(ACE_CDR::ULong (0)) || + !s.impl ().write_ulong (static_cast (size)) || + !s.impl ().write_octet_array ( + reinterpret_cast (x.data ()), size)) + throw ace_cdr_stream_insertion (); + + return s; + } + } + } +} + +#endif // LIBXSD_CXX_TREE_ACE_CDR_STREAM_INSERTION_HXX diff --git a/libxsd/libxsd/cxx/tree/bits/literals.hxx b/libxsd/libxsd/cxx/tree/bits/literals.hxx new file mode 100644 index 0000000..672eab1 --- /dev/null +++ b/libxsd/libxsd/cxx/tree/bits/literals.hxx @@ -0,0 +1,259 @@ +// file : libxsd/cxx/tree/bits/literals.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_TREE_BITS_LITERALS_HXX +#define LIBXSD_CXX_TREE_BITS_LITERALS_HXX + +namespace xsd +{ + namespace cxx + { + namespace tree + { + namespace bits + { + // Boolean literals + // + template + const C* + true_ (); + + template + const C* + one (); + + // Float literals: INF -INF NaN. + // + template + const C* + positive_inf (); + + template + const C* + negative_inf (); + + template + const C* + nan (); + + // Optional "not present" literal. + // + template + const C* + not_present (); + + // XML Schema namespace + // + template + const C* + xml_schema (); + + // Built-in XML Schema type names. + // + template + const C* + any_type (); + + template + const C* + any_simple_type (); + + template + const C* + string (); + + template + const C* + normalized_string (); + + template + const C* + token (); + + template + const C* + name (); + + template + const C* + nmtoken (); + + template + const C* + nmtokens (); + + template + const C* + ncname (); + + template + const C* + language (); + + template + const C* + id (); + + template + const C* + idref (); + + template + const C* + idrefs (); + + template + const C* + any_uri (); + + template + const C* + qname (); + + template + const C* + base64_binary (); + + template + const C* + hex_binary (); + + template + const C* + date (); + + template + const C* + date_time (); + + template + const C* + duration (); + + template + const C* + gday (); + + template + const C* + gmonth (); + + template + const C* + gmonth_day (); + + template + const C* + gyear (); + + template + const C* + gyear_month (); + + template + const C* + time (); + + template + const C* + entity (); + + template + const C* + entities (); + + // gday ("---") and gmonth ("--") prefixes. + // + template + const C* + gday_prefix (); + + template + const C* + gmonth_prefix (); + + // Exception and diagnostics string literals. + // + template + const C* + ex_error_error (); // " error: " + + template + const C* + ex_error_warning (); // " warning: " + + template + const C* + ex_parsing_msg (); // "instance document parsing failed" + + template + const C* + ex_eel_expected (); // "expected element '" + + template + const C* + ex_uel_expected (); // "expected element '" + + template + const C* + ex_uel_instead (); // "' instead of '" + + template + const C* + ex_uel_unexpected (); // "unexpected element '" + + template + const C* + ex_eat_expected (); // "expected attribute '" + + template + const C* + ex_uen_unexpected (); // "unexpected enumerator '" + + template + const C* + ex_etc_msg (); // "expected text content" + + template + const C* + ex_nti_no_type_info (); // "no type information available for type '" + + template + const C* + ex_nei_no_element_info (); // "no parsing or serialization information + // available for element '" + template + const C* + ex_nd_type (); // "type '" + + template + const C* + ex_nd_not_derived (); // "' is not derived from '" + + template + const C* + ex_di_id (); // "ID '" + + template + const C* + ex_di_already_exist (); // "' already exist" + + template + const C* + ex_serialization_msg (); // "serialization failed" + + template + const C* + ex_npm_no_mapping (); // "no mapping provided for namespace prefix '" + + template + const C* + ex_bounds_msg (); // "buffer boundary rules have been violated" + } + } + } +} + +#endif // LIBXSD_CXX_TREE_BITS_LITERALS_HXX + +#include diff --git a/libxsd/libxsd/cxx/tree/bits/literals.ixx b/libxsd/libxsd/cxx/tree/bits/literals.ixx new file mode 100644 index 0000000..8c2434b --- /dev/null +++ b/libxsd/libxsd/cxx/tree/bits/literals.ixx @@ -0,0 +1,874 @@ +// file : libxsd/cxx/tree/bits/literals.ixx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_TREE_BITS_LITERALS_IXX +#define XSD_CXX_TREE_BITS_LITERALS_IXX + +// The char versions of the following literals are required even +// if we are using wchar_t as the character type. +// +namespace xsd +{ + namespace cxx + { + namespace tree + { + namespace bits + { + // + // + template<> + inline const char* + positive_inf () + { + return "INF"; + } + + template<> + inline const char* + negative_inf () + { + return "-INF"; + } + + template<> + inline const char* + nan () + { + return "NaN"; + } + } + } + } +} + +#endif // XSD_CXX_TREE_BITS_LITERALS_IXX + + +#if defined(XSD_CXX_TREE_USE_CHAR) || !defined(XSD_CXX_TREE_USE_WCHAR) + +#ifndef XSD_CXX_TREE_BITS_LITERALS_IXX_CHAR +#define XSD_CXX_TREE_BITS_LITERALS_IXX_CHAR + +namespace xsd +{ + namespace cxx + { + namespace tree + { + namespace bits + { + // + // + template<> + inline const char* + true_ () + { + return "true"; + } + + template<> + inline const char* + one () + { + return "1"; + } + + // + // + template<> + inline const char* + not_present () + { + return ""; + } + + // + // + template <> + inline const char* + xml_schema () + { + return "http://www.w3.org/2001/XMLSchema"; + } + + // + // + template <> + inline const char* + any_type () + { + return "anyType"; + } + + template <> + inline const char* + any_simple_type () + { + return "anySimpleType"; + } + + template <> + inline const char* + string () + { + return "string"; + } + + template <> + inline const char* + normalized_string () + { + return "normalizedString"; + } + + template <> + inline const char* + token () + { + return "token"; + } + + template <> + inline const char* + name () + { + return "Name"; + } + + template <> + inline const char* + nmtoken () + { + return "NMTOKEN"; + } + + template <> + inline const char* + nmtokens () + { + return "NMTOKENS"; + } + + template <> + inline const char* + ncname () + { + return "NCName"; + } + + template <> + inline const char* + language () + { + return "language"; + } + + + template <> + inline const char* + id () + { + return "ID"; + } + + template <> + inline const char* + idref () + { + return "IDREF"; + } + + template <> + inline const char* + idrefs () + { + return "IDREFS"; + } + + template <> + inline const char* + any_uri () + { + return "anyURI"; + } + + template <> + inline const char* + qname () + { + return "QName"; + } + + template <> + inline const char* + base64_binary () + { + return "base64Binary"; + } + + template <> + inline const char* + hex_binary () + { + return "hexBinary"; + } + + template <> + inline const char* + date () + { + return "date"; + } + + template <> + inline const char* + date_time () + { + return "dateTime"; + } + + template <> + inline const char* + duration () + { + return "duration"; + } + + template <> + inline const char* + gday () + { + return "gDay"; + } + + template <> + inline const char* + gmonth () + { + return "gMonth"; + } + + template <> + inline const char* + gmonth_day () + { + return "gMonthDay"; + } + + template <> + inline const char* + gyear () + { + return "gYear"; + } + + template <> + inline const char* + gyear_month () + { + return "gYearMonth"; + } + + template <> + inline const char* + time () + { + return "time"; + } + + template <> + inline const char* + entity () + { + return "ENTITY"; + } + + template <> + inline const char* + entities () + { + return "ENTITIES"; + } + + template <> + inline const char* + gday_prefix () + { + return "---"; + } + + template <> + inline const char* + gmonth_prefix () + { + return "--"; + } + + // + // + template <> + inline const char* + ex_error_error () + { + return " error: "; + } + + template <> + inline const char* + ex_error_warning () + { + return " warning: "; + } + + template <> + inline const char* + ex_parsing_msg () + { + return "instance document parsing failed"; + } + + template <> + inline const char* + ex_eel_expected () + { + return "expected element '"; + } + + template <> + inline const char* + ex_uel_expected () + { + return "expected element '"; + } + + template <> + inline const char* + ex_uel_instead () + { + return "' instead of '"; + } + + template <> + inline const char* + ex_uel_unexpected () + { + return "unexpected element '"; + } + + template <> + inline const char* + ex_eat_expected () + { + return "expected attribute '"; + } + + template <> + inline const char* + ex_uen_unexpected () + { + return "unexpected enumerator '"; + } + + template <> + inline const char* + ex_etc_msg () + { + return "expected text content"; + } + + template <> + inline const char* + ex_nti_no_type_info () + { + return "no type information available for type '"; + } + + template <> + inline const char* + ex_nei_no_element_info () + { + return "no parsing or serialization information available for " + "element '"; + } + template <> + inline const char* + ex_nd_type () + { + return "type '"; + } + + template <> + inline const char* + ex_nd_not_derived () + { + return "' is not derived from '"; + } + + template <> + inline const char* + ex_di_id () + { + return "ID '"; + } + + template <> + inline const char* + ex_di_already_exist () + { + return "' already exist"; + } + + template <> + inline const char* + ex_serialization_msg () + { + return "serialization failed"; + } + + template <> + inline const char* + ex_npm_no_mapping () + { + return "no mapping provided for namespace prefix '"; + } + + template <> + inline const char* + ex_bounds_msg () + { + return "buffer boundary rules have been violated"; + } + } + } + } +} + +#endif // XSD_CXX_TREE_BITS_LITERALS_IXX_CHAR +#endif // XSD_CXX_TREE_USE_CHAR + + +#if defined(XSD_CXX_TREE_USE_WCHAR) || !defined(XSD_CXX_TREE_USE_CHAR) + +#ifndef XSD_CXX_TREE_BITS_LITERALS_IXX_WCHAR +#define XSD_CXX_TREE_BITS_LITERALS_IXX_WCHAR + +namespace xsd +{ + namespace cxx + { + namespace tree + { + namespace bits + { + // + // + template<> + inline const wchar_t* + true_ () + { + return L"true"; + } + + template<> + inline const wchar_t* + one () + { + return L"1"; + } + + // + // + template<> + inline const wchar_t* + positive_inf () + { + return L"INF"; + } + + template<> + inline const wchar_t* + negative_inf () + { + return L"-INF"; + } + + template<> + inline const wchar_t* + nan () + { + return L"NaN"; + } + + // + // + template<> + inline const wchar_t* + not_present () + { + return L""; + } + + // + // + template <> + inline const wchar_t* + xml_schema () + { + return L"http://www.w3.org/2001/XMLSchema"; + } + + // + // + template <> + inline const wchar_t* + any_type () + { + return L"anyType"; + } + + template <> + inline const wchar_t* + any_simple_type () + { + return L"anySimpleType"; + } + + template <> + inline const wchar_t* + string () + { + return L"string"; + } + + template <> + inline const wchar_t* + normalized_string () + { + return L"normalizedString"; + } + + template <> + inline const wchar_t* + token () + { + return L"token"; + } + + template <> + inline const wchar_t* + name () + { + return L"Name"; + } + + template <> + inline const wchar_t* + nmtoken () + { + return L"NMTOKEN"; + } + + template <> + inline const wchar_t* + nmtokens () + { + return L"NMTOKENS"; + } + + template <> + inline const wchar_t* + ncname () + { + return L"NCName"; + } + + template <> + inline const wchar_t* + language () + { + return L"language"; + } + + + template <> + inline const wchar_t* + id () + { + return L"ID"; + } + + template <> + inline const wchar_t* + idref () + { + return L"IDREF"; + } + + template <> + inline const wchar_t* + idrefs () + { + return L"IDREFS"; + } + + template <> + inline const wchar_t* + any_uri () + { + return L"anyURI"; + } + + template <> + inline const wchar_t* + qname () + { + return L"QName"; + } + + template <> + inline const wchar_t* + base64_binary () + { + return L"base64Binary"; + } + + template <> + inline const wchar_t* + hex_binary () + { + return L"hexBinary"; + } + + template <> + inline const wchar_t* + date () + { + return L"date"; + } + + template <> + inline const wchar_t* + date_time () + { + return L"dateTime"; + } + + template <> + inline const wchar_t* + duration () + { + return L"duration"; + } + + template <> + inline const wchar_t* + gday () + { + return L"gDay"; + } + + template <> + inline const wchar_t* + gmonth () + { + return L"gMonth"; + } + + template <> + inline const wchar_t* + gmonth_day () + { + return L"gMonthDay"; + } + + template <> + inline const wchar_t* + gyear () + { + return L"gYear"; + } + + template <> + inline const wchar_t* + gyear_month () + { + return L"gYearMonth"; + } + + template <> + inline const wchar_t* + time () + { + return L"time"; + } + + template <> + inline const wchar_t* + entity () + { + return L"ENTITY"; + } + + template <> + inline const wchar_t* + entities () + { + return L"ENTITIES"; + } + + template <> + inline const wchar_t* + gday_prefix () + { + return L"---"; + } + + template <> + inline const wchar_t* + gmonth_prefix () + { + return L"--"; + } + + // + // + template <> + inline const wchar_t* + ex_error_error () + { + return L" error: "; + } + + template <> + inline const wchar_t* + ex_error_warning () + { + return L" warning: "; + } + + template <> + inline const wchar_t* + ex_parsing_msg () + { + return L"instance document parsing failed"; + } + + template <> + inline const wchar_t* + ex_eel_expected () + { + return L"expected element '"; + } + + template <> + inline const wchar_t* + ex_uel_expected () + { + return L"expected element '"; + } + + template <> + inline const wchar_t* + ex_uel_instead () + { + return L"' instead of '"; + } + + template <> + inline const wchar_t* + ex_uel_unexpected () + { + return L"unexpected element '"; + } + + template <> + inline const wchar_t* + ex_eat_expected () + { + return L"expected attribute '"; + } + + template <> + inline const wchar_t* + ex_uen_unexpected () + { + return L"unexpected enumerator '"; + } + + template <> + inline const wchar_t* + ex_etc_msg () + { + return L"expected text content"; + } + + template <> + inline const wchar_t* + ex_nti_no_type_info () + { + return L"no type information available for type '"; + } + + template <> + inline const wchar_t* + ex_nei_no_element_info () + { + return L"no parsing or serialization information available for " + L"element '"; + } + template <> + inline const wchar_t* + ex_nd_type () + { + return L"type '"; + } + + template <> + inline const wchar_t* + ex_nd_not_derived () + { + return L"' is not derived from '"; + } + + template <> + inline const wchar_t* + ex_di_id () + { + return L"ID '"; + } + + template <> + inline const wchar_t* + ex_di_already_exist () + { + return L"' already exist"; + } + + template <> + inline const wchar_t* + ex_serialization_msg () + { + return L"serialization failed"; + } + + template <> + inline const wchar_t* + ex_npm_no_mapping () + { + return L"no mapping provided for namespace prefix '"; + } + + template <> + inline const wchar_t* + ex_bounds_msg () + { + return L"buffer boundary rules have been violated"; + } + } + } + } +} + +#endif // XSD_CXX_TREE_BITS_LITERALS_IXX_WCHAR +#endif // XSD_CXX_TREE_USE_WCHAR diff --git a/libxsd/libxsd/cxx/tree/buffer.hxx b/libxsd/libxsd/cxx/tree/buffer.hxx new file mode 100644 index 0000000..36e83b8 --- /dev/null +++ b/libxsd/libxsd/cxx/tree/buffer.hxx @@ -0,0 +1,335 @@ +// file : libxsd/cxx/tree/buffer.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +/** + * @file + * + * @brief Contains a simple binary buffer abstraction that is used to + * implement the base64Binary and hexBinary XML Schema built-in types. + * + * This is an internal header and is included by the generated code. You + * normally should not include it directly. + * + */ + +#ifndef LIBXSD_CXX_TREE_BUFFER_HXX +#define LIBXSD_CXX_TREE_BUFFER_HXX + +#include // operator new/delete +#include // std::size_t +#include // std::memcpy, std::memcmp + +#include + +namespace xsd +{ + namespace cxx + { + /** + * @brief C++/Tree mapping runtime namespace. + * + * This is an internal namespace and normally should not be referenced + * directly. Instead you should use the aliases for types in this + * namespaces that are created in the generated code. + * + */ + namespace tree + { + //@cond + + class buffer_base + { + protected: + virtual + ~buffer_base () + { + if (free_ && data_) + operator delete (data_); + } + + buffer_base () + : data_ (0), size_ (0), capacity_ (0), free_ (true) + { + } + + protected: + char* data_; + size_t size_; + size_t capacity_; + bool free_; + }; + + //@endcond + + /** + * @brief Simple binary %buffer abstraction + * + * The %buffer class manages a continuous binary %buffer. The base + * concepts are data (actual memory region), size (the portion of + * the %buffer that contains useful information), and capacity (the + * actual size of the underlying memory region). The bounds + * %exception is thrown from the constructors and modifier functions + * if the (size <= capacity) constraint is violated. + * + * Note that the template parameter is only used to instantiate + * %exception types. The underlying %buffer type is always @c char. + * + * @nosubgrouping + */ + template + class buffer: protected buffer_base + { + public: + /** + * @brief Size type + */ + typedef std::size_t size_t; + + public: + /** + * @name Constructors + */ + //@{ + + /** + * @brief Allocate a %buffer of the specified size. + * + * The resulting %buffer has the same size and capacity. + * + * @param size A %buffer size in bytes. + */ + explicit + buffer (size_t size = 0); + + /** + * @brief Allocate a %buffer of the specified size and capacity. + * + * @param size A %buffer size in bytes. + * @param capacity A %buffer capacity in bytes. + * @throw bounds If @a size exceeds @a capacity + */ + buffer (size_t size, size_t capacity); + + /** + * @brief Allocate a %buffer of the specified size and copy + * the data. + * + * The resulting %buffer has the same size and capacity with + * @a size bytes copied from @a data. + * + * @param data A %buffer to copy the data from. + * @param size A %buffer size in bytes. + */ + buffer (const void* data, size_t size); + + /** + * @brief Allocate a %buffer of the specified size and capacity + * and copy the data. + * + * @a size bytes are copied from @a data to the resulting + * %buffer. + * + * @param data A %buffer to copy the data from. + * @param size A %buffer size in bytes. + * @param capacity A %buffer capacity in bytes. + * @throw bounds If @a size exceeds @a capacity + */ + buffer (const void* data, size_t size, size_t capacity); + + /** + * @brief Reuse an existing %buffer. + * + * If the @a assume_ownership argument is true, the %buffer will + * assume ownership of @a data and will release the memory + * by calling @c operator @c delete(). + * + * @param data A %buffer to reuse. + * @param size A %buffer size in bytes. + * @param capacity A %buffer capacity in bytes. + * @param assume_ownership A boolean value indication whether to + * assume ownership. + * @throw bounds If @a size exceeds @a capacity + */ + buffer (void* data, + size_t size, + size_t capacity, + bool assume_ownership); + + /** + * @brief Copy constructor. + * + * The copy constructor performs a deep copy of the underlying + * memory %buffer. + * + * @param x An instance to make a copy of. + */ + buffer (const buffer& x); + + //@} + + public: + /** + * @brief Copy assignment operator. + * + * The copy assignment operator changes the buffer's capacity + * to @c x.capacity() and copies @c x.size() bytes from @a x. + * + * @param x An instance to assign. + * @return A reference to the instance. + */ + buffer& + operator= (const buffer& x); + + public: + /** + * @brief Get buffer's capacity. + * + * @return A number of bytes that the %buffer can hold without + * reallocation. + */ + size_t + capacity () const + { + return capacity_; + } + + /** + * @brief Set buffer's capacity. + * + * @param c The new capacity in bytes. + * @return True if the underlying %buffer has moved, false otherwise. + */ + bool + capacity (size_t c) + { + return this->capacity (c, true); + } + + public: + /** + * @brief Get buffer's size. + * + * @return A number of bytes that the %buffer holds. + */ + size_t + size () const {return size_;} + + /** + * @brief Set buffer's size. + * + * @param s The new size in bytes. + * @return True if the underlying %buffer has moved, false otherwise. + */ + bool + size (size_t s) + { + bool r (false); + + if (s > capacity_) + r = capacity (s); + + size_ = s; + + return r; + } + + public: + /** + * @brief Get the underlying memory region. + * + * @return A constant pointer to the underlying memory region. + */ + const char* + data () const {return data_;} + + /** + * @brief Get the underlying memory region. + * + * @return A pointer to the underlying memory region. + */ + char* + data () {return data_;} + + /** + * @brief Get the beginning of the underlying memory region. + * + * @return A constant pointer to the first byte of the underlying + * memory region. + */ + const char* + begin () const {return data_;} + + /** + * @brief Get the beginning of the underlying memory region. + * + * @return A pointer to the first byte of the underlying memory + * region. + */ + char* + begin () {return data_;} + + /** + * @brief Get the end of the underlying memory region. + * + * @return A constant pointer to the one past last byte of the + * underlying memory region (that is @c %begin() @c + @c %size() ). + */ + const char* + end () const {return data_ + size_;} + + /** + * @brief Get the end of the underlying memory region. + * + * @return A pointer to the one past last byte of the underlying + * memory region (that is @c %begin() @c + @c %size() ). + */ + char* + end () {return data_ + size_;} + + public: + /** + * @brief Swap data with another %buffer. + * + * @param x A %buffer to swap with. + */ + void + swap (buffer& x); + + private: + bool + capacity (size_t capacity, bool copy); + }; + + /** + * @brief %buffer comparison operator. + * + * @return True if the buffers have the same sizes and the same + * data. + */ + template + inline bool + operator== (const buffer& a, const buffer& b) + { + return a.size () == b.size () && + std::memcmp (a.data (), b.data (), a.size ()) == 0; + } + + /** + * @brief %buffer comparison operator. + * + * @return True if the buffers have different sizes or different + * data. + */ + template + inline bool + operator!= (const buffer& a, const buffer& b) + { + return !(a == b); + } + } + } +} + +#include + +#endif // LIBXSD_CXX_TREE_BUFFER_HXX diff --git a/libxsd/libxsd/cxx/tree/buffer.txx b/libxsd/libxsd/cxx/tree/buffer.txx new file mode 100644 index 0000000..e8c2340 --- /dev/null +++ b/libxsd/libxsd/cxx/tree/buffer.txx @@ -0,0 +1,145 @@ +// file : libxsd/cxx/tree/buffer.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsd +{ + namespace cxx + { + namespace tree + { + template + buffer:: + buffer (size_t size) + { + capacity (size); + size_ = size; + } + + template + buffer:: + buffer (size_t size, size_t capacity) + { + if (size > capacity) + throw bounds (); + + this->capacity (capacity); + size_ = size; + } + + template + buffer:: + buffer (const void* data, size_t size) + { + capacity (size); + size_ = size; + + if (size_) + std::memcpy (data_, data, size_); + } + + template + buffer:: + buffer (const void* data, size_t size, size_t capacity) + { + if (size > capacity) + throw bounds (); + + this->capacity (capacity); + size_ = size; + + if (size_) + std::memcpy (data_, data, size_); + } + + template + buffer:: + buffer (void* data, size_t size, size_t capacity, bool own) + { + if (size > capacity) + throw bounds (); + + data_ = reinterpret_cast (data); + size_ = size; + capacity_ = capacity; + free_ = own; + } + + template + buffer:: + buffer (const buffer& other) + : buffer_base () + { + capacity (other.capacity_); + size_ = other.size_; + + if (size_) + std::memcpy (data_, other.data_, size_); + } + + template + buffer& buffer:: + operator= (const buffer& other) + { + if (this != &other) + { + capacity (other.capacity_, false); + size_ = other.size_; + + if (size_) + std::memcpy (data_, other.data_, size_); + } + + return *this; + } + + template + void buffer:: + swap (buffer& other) + { + char* tmp_data (data_); + size_t tmp_size (size_); + size_t tmp_capacity (capacity_); + bool tmp_free (free_); + + data_ = other.data_; + size_ = other.size_; + capacity_ = other.capacity_; + free_ = other.free_; + + other.data_ = tmp_data; + other.size_ = tmp_size; + other.capacity_ = tmp_capacity; + other.free_ = tmp_free; + } + + template + bool buffer:: + capacity (size_t capacity, bool copy) + { + if (size_ > capacity) + throw bounds (); + + if (capacity <= capacity_) + { + return false; // Do nothing if shrinking is requested. + } + else + { + char* data (reinterpret_cast (operator new (capacity))); + + if (copy && size_ > 0) + std::memcpy (data, data_, size_); + + if (free_ && data_) + operator delete (data_); + + data_ = data; + capacity_ = capacity; + free_ = true; + + return true; + } + } + } + } +} diff --git a/libxsd/libxsd/cxx/tree/comparison-map.hxx b/libxsd/libxsd/cxx/tree/comparison-map.hxx new file mode 100644 index 0000000..e133c6c --- /dev/null +++ b/libxsd/libxsd/cxx/tree/comparison-map.hxx @@ -0,0 +1,111 @@ +// file : libxsd/cxx/tree/comparison-map.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef LIBXSD_CXX_TREE_COMPARISON_MAP_HXX +#define LIBXSD_CXX_TREE_COMPARISON_MAP_HXX + +#include +#include // std::size_t +#include + +#include + +namespace xsd +{ + namespace cxx + { + namespace tree + { + template + struct comparison_map + { + typedef std::type_info type_id; + typedef bool (*comparator) (const type&, const type&); + + comparison_map (); + + void + register_type (const type_id&, comparator, bool replace = true); + + void + unregister_type (const type_id&); + + bool + compare (const type&, const type&); + + public: + comparator + find (const type_id&) const; + + private: + struct type_id_comparator + { + bool + operator() (const type_id* x, const type_id* y) const + { + // XL C++ on AIX has buggy type_info::before() in that + // it returns true for two different type_info objects + // that happened to be for the same type. + // +#if defined(__xlC__) && defined(_AIX) + return *x != *y && x->before (*y); +#else + return x->before (*y); +#endif + } + }; + + typedef + std::map + type_map; + + type_map type_map_; + }; + + // + // + template + struct comparison_plate + { + static comparison_map* map; + static std::size_t count; + + comparison_plate (); + ~comparison_plate (); + }; + + template + comparison_map* comparison_plate::map = 0; + + template + std::size_t comparison_plate::count = 0; + + + // + // + template + inline comparison_map& + comparison_map_instance () + { + return *comparison_plate::map; + } + + // + // + template + bool + comparator_impl (const type&, const type&); + + template + struct comparison_initializer + { + comparison_initializer (); + ~comparison_initializer (); + }; + } + } +} + +#include + +#endif // LIBXSD_CXX_TREE_COMPARISON_MAP_HXX diff --git a/libxsd/libxsd/cxx/tree/comparison-map.txx b/libxsd/libxsd/cxx/tree/comparison-map.txx new file mode 100644 index 0000000..e18d12e --- /dev/null +++ b/libxsd/libxsd/cxx/tree/comparison-map.txx @@ -0,0 +1,298 @@ +// file : libxsd/cxx/tree/comparison-map.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +namespace xsd +{ + namespace cxx + { + namespace tree + { + // comparison_map + // + template + comparison_map:: + comparison_map () + { + // anyType and anySimpleType. + // + + register_type ( + typeid (type), + &comparator_impl, + false); + + typedef simple_type simple_type; + + register_type ( + typeid (simple_type), + &comparator_impl, + false); + + // Strings + // + typedef string string; + register_type ( + typeid (string), + &comparator_impl, + false); + + typedef normalized_string normalized_string; + register_type ( + typeid (normalized_string), + &comparator_impl, + false); + + typedef token token; + register_type ( + typeid (token), + &comparator_impl, + false); + + typedef name name; + register_type ( + typeid (name), + &comparator_impl, + false); + + typedef nmtoken nmtoken; + register_type ( + typeid (nmtoken), + &comparator_impl, + false); + + typedef nmtokens nmtokens; + register_type ( + typeid (nmtokens), + &comparator_impl, + false); + + typedef ncname ncname; + register_type ( + typeid (ncname), + &comparator_impl, + false); + + typedef language language; + register_type ( + typeid (language), + &comparator_impl, + false); + + + // ID/IDREF. + // + typedef id id; + register_type ( + typeid (id), + &comparator_impl, + false); + + typedef idref idref; + register_type ( + typeid (idref), + &comparator_impl, + false); + + typedef idrefs idrefs; + register_type ( + typeid (idrefs), + &comparator_impl, + false); + + + // URI. + // + typedef uri uri; + register_type ( + typeid (uri), + &comparator_impl, + false); + + + // Qualified name. + // + typedef qname qname; + register_type ( + typeid (qname), + &comparator_impl, + false); + + + // Binary. + // + typedef base64_binary base64_binary; + register_type ( + typeid (base64_binary), + &comparator_impl, + false); + + typedef hex_binary hex_binary; + register_type ( + typeid (hex_binary), + &comparator_impl, + false); + + + // Date/time. + // + typedef gday gday; + register_type ( + typeid (gday), + &comparator_impl, + false); + + typedef gmonth gmonth; + register_type ( + typeid (gmonth), + &comparator_impl, + false); + + typedef gyear gyear; + register_type ( + typeid (gyear), + &comparator_impl, + false); + + typedef gmonth_day gmonth_day; + register_type ( + typeid (gmonth_day), + &comparator_impl, + false); + + typedef gyear_month gyear_month; + register_type ( + typeid (gyear_month), + &comparator_impl, + false); + + typedef date date; + register_type ( + typeid (date), + &comparator_impl, + false); + + typedef time time; + register_type ( + typeid (time), + &comparator_impl