From c4821c8e6bf1f81c6ea31e11ebc0fc1666e9337b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 25 Feb 2021 10:27:59 -0500 Subject: Add exess from git@gitlab.com:drobilla/exess.git 4638b1f --- subprojects/exess/.clang-format | 30 + subprojects/exess/.clang-tidy | 7 + subprojects/exess/.clant.json | 4 + subprojects/exess/.gitignore | 1 + subprojects/exess/.gitlab-ci.yml | 168 ++ subprojects/exess/.includes.imp | 10 + subprojects/exess/NEWS | 5 + subprojects/exess/README.md | 83 + .../exess/bindings/cpp/include/exess/exess.hpp | 707 +++++++++ subprojects/exess/bindings/cpp/meson.build | 54 + subprojects/exess/bindings/cpp/test/.clang-tidy | 17 + subprojects/exess/bindings/cpp/test/meson.build | 8 + .../exess/bindings/cpp/test/test_exess_hpp.cpp | 221 +++ subprojects/exess/doc/c/Doxyfile.in | 39 + subprojects/exess/doc/c/api/meson.build | 5 + subprojects/exess/doc/c/index.rst | 10 + subprojects/exess/doc/c/man/manlink.in | 1 + subprojects/exess/doc/c/man/meson.build | 122 ++ subprojects/exess/doc/c/meson.build | 53 + subprojects/exess/doc/c/overview.rst | 151 ++ subprojects/exess/doc/c/xml/meson.build | 12 + subprojects/exess/doc/conf.py.in | 112 ++ subprojects/exess/doc/cpp/Doxyfile.in | 44 + subprojects/exess/doc/cpp/api/meson.build | 5 + subprojects/exess/doc/cpp/index.rst | 11 + subprojects/exess/doc/cpp/meson.build | 42 + subprojects/exess/doc/cpp/overview.rst | 151 ++ subprojects/exess/doc/cpp/xml/meson.build | 14 + subprojects/exess/doc/meson.build | 17 + subprojects/exess/doc/summary.rst | 3 + subprojects/exess/include/exess/exess.h | 1633 ++++++++++++++++++++ subprojects/exess/meson.build | 236 +++ subprojects/exess/meson/meson.build | 204 +++ subprojects/exess/meson_options.txt | 17 + subprojects/exess/scripts/dox_to_sphinx.py | 675 ++++++++ subprojects/exess/src/.clang-tidy | 12 + subprojects/exess/src/attributes.h | 30 + subprojects/exess/src/base64.c | 163 ++ subprojects/exess/src/bigint.c | 605 ++++++++ subprojects/exess/src/bigint.h | 118 ++ subprojects/exess/src/boolean.c | 69 + subprojects/exess/src/byte.c | 45 + subprojects/exess/src/canonical.c | 309 ++++ subprojects/exess/src/coerce.c | 422 +++++ subprojects/exess/src/datatype.c | 79 + subprojects/exess/src/date.c | 112 ++ subprojects/exess/src/date_utils.h | 65 + subprojects/exess/src/datetime.c | 265 ++++ subprojects/exess/src/decimal.c | 267 ++++ subprojects/exess/src/decimal.h | 63 + subprojects/exess/src/digits.c | 243 +++ subprojects/exess/src/digits.h | 38 + subprojects/exess/src/double.c | 53 + subprojects/exess/src/duration.c | 322 ++++ subprojects/exess/src/exess_config.h | 79 + subprojects/exess/src/float.c | 44 + subprojects/exess/src/hex.c | 131 ++ subprojects/exess/src/ieee_float.h | 63 + subprojects/exess/src/int.c | 45 + subprojects/exess/src/int_math.c | 78 + subprojects/exess/src/int_math.h | 72 + subprojects/exess/src/long.c | 110 ++ subprojects/exess/src/macros.h | 31 + subprojects/exess/src/read_utils.c | 51 + subprojects/exess/src/read_utils.h | 77 + subprojects/exess/src/scientific.c | 125 ++ subprojects/exess/src/scientific.h | 35 + subprojects/exess/src/short.c | 45 + subprojects/exess/src/soft_float.c | 161 ++ subprojects/exess/src/soft_float.h | 71 + subprojects/exess/src/strerror.c | 70 + subprojects/exess/src/string_utils.h | 74 + subprojects/exess/src/strtod.c | 405 +++++ subprojects/exess/src/strtod.h | 33 + subprojects/exess/src/time.c | 172 +++ subprojects/exess/src/time_utils.h | 35 + subprojects/exess/src/timezone.c | 150 ++ subprojects/exess/src/timezone.h | 59 + subprojects/exess/src/ubyte.c | 45 + subprojects/exess/src/uint.c | 45 + subprojects/exess/src/ulong.c | 94 ++ subprojects/exess/src/ushort.c | 45 + subprojects/exess/src/variant.c | 431 ++++++ subprojects/exess/src/warnings.h | 46 + subprojects/exess/src/write_utils.c | 50 + subprojects/exess/src/write_utils.h | 85 + subprojects/exess/src/year.c | 98 ++ subprojects/exess/test/.clang-tidy | 11 + subprojects/exess/test/float_test_data.h | 130 ++ subprojects/exess/test/int_test_data.h | 42 + subprojects/exess/test/meson.build | 76 + subprojects/exess/test/num_test_utils.h | 85 + subprojects/exess/test/test_base64.c | 196 +++ subprojects/exess/test/test_bigint.c | 841 ++++++++++ subprojects/exess/test/test_boolean.c | 114 ++ subprojects/exess/test/test_byte.c | 98 ++ subprojects/exess/test/test_canonical.c | 412 +++++ subprojects/exess/test/test_coerce.c | 519 +++++++ subprojects/exess/test/test_datatype.c | 81 + subprojects/exess/test/test_date.c | 257 +++ subprojects/exess/test/test_datetime.c | 459 ++++++ subprojects/exess/test/test_decimal.c | 260 ++++ subprojects/exess/test/test_double.c | 246 +++ subprojects/exess/test/test_duration.c | 310 ++++ subprojects/exess/test/test_float.c | 240 +++ subprojects/exess/test/test_hex.c | 180 +++ subprojects/exess/test/test_int.c | 129 ++ subprojects/exess/test/test_int_math.c | 97 ++ subprojects/exess/test/test_long.c | 144 ++ subprojects/exess/test/test_short.c | 100 ++ subprojects/exess/test/test_strerror.c | 35 + subprojects/exess/test/test_time.c | 222 +++ subprojects/exess/test/test_timezone.c | 178 +++ subprojects/exess/test/test_ubyte.c | 100 ++ subprojects/exess/test/test_uint.c | 128 ++ subprojects/exess/test/test_ulong.c | 126 ++ subprojects/exess/test/test_ushort.c | 100 ++ subprojects/exess/test/test_variant.c | 301 ++++ subprojects/exess/test/time_test_utils.h | 52 + 119 files changed, 17576 insertions(+) create mode 100644 subprojects/exess/.clang-format create mode 100644 subprojects/exess/.clang-tidy create mode 100644 subprojects/exess/.clant.json create mode 100644 subprojects/exess/.gitignore create mode 100644 subprojects/exess/.gitlab-ci.yml create mode 100644 subprojects/exess/.includes.imp create mode 100644 subprojects/exess/NEWS create mode 100644 subprojects/exess/README.md create mode 100644 subprojects/exess/bindings/cpp/include/exess/exess.hpp create mode 100644 subprojects/exess/bindings/cpp/meson.build create mode 100644 subprojects/exess/bindings/cpp/test/.clang-tidy create mode 100644 subprojects/exess/bindings/cpp/test/meson.build create mode 100644 subprojects/exess/bindings/cpp/test/test_exess_hpp.cpp create mode 100644 subprojects/exess/doc/c/Doxyfile.in create mode 100644 subprojects/exess/doc/c/api/meson.build create mode 100644 subprojects/exess/doc/c/index.rst create mode 100644 subprojects/exess/doc/c/man/manlink.in create mode 100644 subprojects/exess/doc/c/man/meson.build create mode 100644 subprojects/exess/doc/c/meson.build create mode 100644 subprojects/exess/doc/c/overview.rst create mode 100644 subprojects/exess/doc/c/xml/meson.build create mode 100644 subprojects/exess/doc/conf.py.in create mode 100644 subprojects/exess/doc/cpp/Doxyfile.in create mode 100644 subprojects/exess/doc/cpp/api/meson.build create mode 100644 subprojects/exess/doc/cpp/index.rst create mode 100644 subprojects/exess/doc/cpp/meson.build create mode 100644 subprojects/exess/doc/cpp/overview.rst create mode 100644 subprojects/exess/doc/cpp/xml/meson.build create mode 100644 subprojects/exess/doc/meson.build create mode 100644 subprojects/exess/doc/summary.rst create mode 100644 subprojects/exess/include/exess/exess.h create mode 100644 subprojects/exess/meson.build create mode 100644 subprojects/exess/meson/meson.build create mode 100644 subprojects/exess/meson_options.txt create mode 100755 subprojects/exess/scripts/dox_to_sphinx.py create mode 100644 subprojects/exess/src/.clang-tidy create mode 100644 subprojects/exess/src/attributes.h create mode 100644 subprojects/exess/src/base64.c create mode 100644 subprojects/exess/src/bigint.c create mode 100644 subprojects/exess/src/bigint.h create mode 100644 subprojects/exess/src/boolean.c create mode 100644 subprojects/exess/src/byte.c create mode 100644 subprojects/exess/src/canonical.c create mode 100644 subprojects/exess/src/coerce.c create mode 100644 subprojects/exess/src/datatype.c create mode 100644 subprojects/exess/src/date.c create mode 100644 subprojects/exess/src/date_utils.h create mode 100644 subprojects/exess/src/datetime.c create mode 100644 subprojects/exess/src/decimal.c create mode 100644 subprojects/exess/src/decimal.h create mode 100644 subprojects/exess/src/digits.c create mode 100644 subprojects/exess/src/digits.h create mode 100644 subprojects/exess/src/double.c create mode 100644 subprojects/exess/src/duration.c create mode 100644 subprojects/exess/src/exess_config.h create mode 100644 subprojects/exess/src/float.c create mode 100644 subprojects/exess/src/hex.c create mode 100644 subprojects/exess/src/ieee_float.h create mode 100644 subprojects/exess/src/int.c create mode 100644 subprojects/exess/src/int_math.c create mode 100644 subprojects/exess/src/int_math.h create mode 100644 subprojects/exess/src/long.c create mode 100644 subprojects/exess/src/macros.h create mode 100644 subprojects/exess/src/read_utils.c create mode 100644 subprojects/exess/src/read_utils.h create mode 100644 subprojects/exess/src/scientific.c create mode 100644 subprojects/exess/src/scientific.h create mode 100644 subprojects/exess/src/short.c create mode 100644 subprojects/exess/src/soft_float.c create mode 100644 subprojects/exess/src/soft_float.h create mode 100644 subprojects/exess/src/strerror.c create mode 100644 subprojects/exess/src/string_utils.h create mode 100644 subprojects/exess/src/strtod.c create mode 100644 subprojects/exess/src/strtod.h create mode 100644 subprojects/exess/src/time.c create mode 100644 subprojects/exess/src/time_utils.h create mode 100644 subprojects/exess/src/timezone.c create mode 100644 subprojects/exess/src/timezone.h create mode 100644 subprojects/exess/src/ubyte.c create mode 100644 subprojects/exess/src/uint.c create mode 100644 subprojects/exess/src/ulong.c create mode 100644 subprojects/exess/src/ushort.c create mode 100644 subprojects/exess/src/variant.c create mode 100644 subprojects/exess/src/warnings.h create mode 100644 subprojects/exess/src/write_utils.c create mode 100644 subprojects/exess/src/write_utils.h create mode 100644 subprojects/exess/src/year.c create mode 100644 subprojects/exess/test/.clang-tidy create mode 100644 subprojects/exess/test/float_test_data.h create mode 100644 subprojects/exess/test/int_test_data.h create mode 100644 subprojects/exess/test/meson.build create mode 100644 subprojects/exess/test/num_test_utils.h create mode 100644 subprojects/exess/test/test_base64.c create mode 100644 subprojects/exess/test/test_bigint.c create mode 100644 subprojects/exess/test/test_boolean.c create mode 100644 subprojects/exess/test/test_byte.c create mode 100644 subprojects/exess/test/test_canonical.c create mode 100644 subprojects/exess/test/test_coerce.c create mode 100644 subprojects/exess/test/test_datatype.c create mode 100644 subprojects/exess/test/test_date.c create mode 100644 subprojects/exess/test/test_datetime.c create mode 100644 subprojects/exess/test/test_decimal.c create mode 100644 subprojects/exess/test/test_double.c create mode 100644 subprojects/exess/test/test_duration.c create mode 100644 subprojects/exess/test/test_float.c create mode 100644 subprojects/exess/test/test_hex.c create mode 100644 subprojects/exess/test/test_int.c create mode 100644 subprojects/exess/test/test_int_math.c create mode 100644 subprojects/exess/test/test_long.c create mode 100644 subprojects/exess/test/test_short.c create mode 100644 subprojects/exess/test/test_strerror.c create mode 100644 subprojects/exess/test/test_time.c create mode 100644 subprojects/exess/test/test_timezone.c create mode 100644 subprojects/exess/test/test_ubyte.c create mode 100644 subprojects/exess/test/test_uint.c create mode 100644 subprojects/exess/test/test_ulong.c create mode 100644 subprojects/exess/test/test_ushort.c create mode 100644 subprojects/exess/test/test_variant.c create mode 100644 subprojects/exess/test/time_test_utils.h (limited to 'subprojects/exess') diff --git a/subprojects/exess/.clang-format b/subprojects/exess/.clang-format new file mode 100644 index 00000000..466ffccf --- /dev/null +++ b/subprojects/exess/.clang-format @@ -0,0 +1,30 @@ +--- +AlignConsecutiveAssignments: true +AlignConsecutiveDeclarations: true +AlignEscapedNewlinesLeft: true +BasedOnStyle: Mozilla +BraceWrapping: + AfterNamespace: false + AfterClass: true + AfterEnum: false + AfterExternBlock: false + AfterFunction: true + AfterStruct: false + SplitEmptyFunction: false + SplitEmptyRecord: false +BinPackArguments: false +BinPackParameters: false +BreakBeforeBraces: Custom +Cpp11BracedListStyle: true +FixNamespaceComments: true +IndentCaseLabels: false +IndentPPDirectives: AfterHash +KeepEmptyLinesAtTheStartOfBlocks: false +SpacesInContainerLiterals: false +StatementMacros: + - EXESS_API + - EXESS_CONST_FUNC + - EXESS_PURE_FUNC + - _Generic + - _Pragma +... diff --git a/subprojects/exess/.clang-tidy b/subprojects/exess/.clang-tidy new file mode 100644 index 00000000..d3e82197 --- /dev/null +++ b/subprojects/exess/.clang-tidy @@ -0,0 +1,7 @@ +Checks: > + *, + -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, + -llvmlibc-*, +WarningsAsErrors: '*' +HeaderFilterRegex: '.*' +FormatStyle: file diff --git a/subprojects/exess/.clant.json b/subprojects/exess/.clant.json new file mode 100644 index 00000000..76cae6d3 --- /dev/null +++ b/subprojects/exess/.clant.json @@ -0,0 +1,4 @@ +{ + "version": "1.0.0", + "mapping_files": [".includes.imp"] +} diff --git a/subprojects/exess/.gitignore b/subprojects/exess/.gitignore new file mode 100644 index 00000000..84c048a7 --- /dev/null +++ b/subprojects/exess/.gitignore @@ -0,0 +1 @@ +/build/ diff --git a/subprojects/exess/.gitlab-ci.yml b/subprojects/exess/.gitlab-ci.yml new file mode 100644 index 00000000..52426131 --- /dev/null +++ b/subprojects/exess/.gitlab-ci.yml @@ -0,0 +1,168 @@ +stages: + - build + - deploy + +.build_template: &build_definition + stage: build + + +arm32_dbg: + <<: *build_definition + image: lv2plugin/debian-arm32 + script: + - meson . build --cross-file=/usr/share/meson/cross/arm-linux-gnueabihf.ini -Dbuildtype=debug -Dstrict=true -Dwerror=true + - ninja -C build test + +arm32_rel: + <<: *build_definition + image: lv2plugin/debian-arm32 + script: + - meson . build --cross-file=/usr/share/meson/cross/arm-linux-gnueabihf.ini -Dbuildtype=release -Dstrict=true -Dwerror=true + - ninja -C build test + + +arm64_dbg: + <<: *build_definition + image: lv2plugin/debian-arm64 + script: + - meson . build --cross-file=/usr/share/meson/cross/aarch64-linux-gnu.ini -Dbuildtype=debug -Dstrict=true -Dwerror=true + - ninja -C build test + +arm64_rel: + <<: *build_definition + image: lv2plugin/debian-arm64 + script: + - meson . build --cross-file=/usr/share/meson/cross/aarch64-linux-gnu.ini -Dbuildtype=release -Dstrict=true -Dwerror=true + - ninja -C build test + + +x32_dbg: + <<: *build_definition + image: lv2plugin/debian-x32 + script: + - meson . build --cross-file=/usr/share/meson/cross/i686-linux-gnu.ini -Dbuildtype=debug -Dstrict=true -Dwerror=true + - ninja -C build test + +x32_rel: + <<: *build_definition + image: lv2plugin/debian-x32 + script: + - meson . build --cross-file=/usr/share/meson/cross/i686-linux-gnu.ini -Dbuildtype=release -Dstrict=true -Dwerror=true + - ninja -C build test + + +x64_dbg: + <<: *build_definition + image: lv2plugin/debian-x64 + script: + - meson . build -Dbuildtype=debug -Dstrict=true -Dwerror=true -Db_coverage=true + - ninja -C build test + - ninja -C build coverage-html + artifacts: + paths: + - build/meson-logs/coveragereport + +x64_rel: + <<: *build_definition + image: lv2plugin/debian-x64 + script: + - meson . build -Dbuildtype=release -Dstrict=true -Dwerror=true + - ninja -C build test + + +x64_static: + <<: *build_definition + image: lv2plugin/debian-x64 + script: + - meson . build -Ddefault_library=static -Dstrict=true -Dwerror=true + - ninja -C build test + + +x64_sanitize: + <<: *build_definition + image: lv2plugin/debian-x64-clang + script: + - meson . build -Db_lundef=false -Dbuildtype=plain -Dstrict=true -Dwerror=true + - ninja -C build test + variables: + CC: "clang" + CFLAGS: "-fno-sanitize-recover=all -fsanitize=address -fsanitize=undefined -fsanitize=float-divide-by-zero -fsanitize=implicit-conversion -fsanitize=local-bounds -fsanitize=nullability" + LDFLAGS: "-fno-sanitize-recover=all -fsanitize=address -fsanitize=undefined -fsanitize=float-divide-by-zero -fsanitize=implicit-conversion -fsanitize=local-bounds -fsanitize=nullability" + + +mingw32_dbg: + <<: *build_definition + image: lv2plugin/debian-mingw32 + script: + - meson . build --cross-file=/usr/share/meson/cross/i686-w64-mingw32.ini -Dbuildtype=debug -Dstrict=true -Dwerror=true + - ninja -C build test + +mingw32_rel: + <<: *build_definition + image: lv2plugin/debian-mingw32 + script: + - meson . build --cross-file=/usr/share/meson/cross/i686-w64-mingw32.ini -Dbuildtype=release -Dstrict=true -Dwerror=true + - ninja -C build test + + +mingw64_dbg: + <<: *build_definition + image: lv2plugin/debian-mingw64 + script: + - meson . build --cross-file=/usr/share/meson/cross/x86_64-w64-mingw32.ini -Dbuildtype=debug -Dstrict=true -Dwerror=true + - ninja -C build test + +mingw64_rel: + <<: *build_definition + image: lv2plugin/debian-mingw64 + script: + - meson . build --cross-file=/usr/share/meson/cross/x86_64-w64-mingw32.ini -Dbuildtype=release -Dstrict=true -Dwerror=true + - ninja -C build test + + +mac_dbg: + <<: *build_definition + tags: [macos] + script: + - meson . build -Dbuildtype=debug -Dstrict=true -Dwerror=true + - ninja -C build test + +mac_rel: + <<: *build_definition + tags: [macos] + script: + - meson . build -Dbuildtype=release -Dstrict=true -Dwerror=true + - ninja -C build test + + +win_dbg: + <<: *build_definition + tags: [windows,meson] + script: + - meson . build -Dbuildtype=debug -Dstrict=true -Dwerror=true + - ninja -C build test + +win_rel: + <<: *build_definition + tags: [windows,meson] + script: + - meson . build -Dbuildtype=release -Dstrict=true -Dwerror=true + - ninja -C build test + + +pages: + stage: deploy + script: + - mkdir -p .public/doc + - mkdir -p .public/c + - mv build/meson-logs/coveragereport/ .public/coverage + - mv build/doc/c/singlehtml .public/c/singlehtml + - mv build/doc/c/html .public/c/html + - mv .public public + dependencies: + - x64_dbg + artifacts: + paths: + - public + only: + - master diff --git a/subprojects/exess/.includes.imp b/subprojects/exess/.includes.imp new file mode 100644 index 00000000..bf54f24d --- /dev/null +++ b/subprojects/exess/.includes.imp @@ -0,0 +1,10 @@ +[ + { "symbol": [ "int16_t", "private", "", "public" ] }, + { "symbol": [ "int32_t", "private", "", "public" ] }, + { "symbol": [ "int64_t", "private", "", "public" ] }, + { "symbol": [ "int8_t", "private", "", "public" ] }, + { "symbol": [ "uint16_t", "private", "", "public" ] }, + { "symbol": [ "uint32_t", "private", "", "public" ] }, + { "symbol": [ "uint64_t", "private", "", "public" ] }, + { "symbol": [ "uint8_t", "private", "", "public" ] } +] diff --git a/subprojects/exess/NEWS b/subprojects/exess/NEWS new file mode 100644 index 00000000..26c425ff --- /dev/null +++ b/subprojects/exess/NEWS @@ -0,0 +1,5 @@ +exess (0.0.1) unstable; + + * Initial release + + -- David Robillard Thu, 14 Jan 2021 09:14:34 +0000 diff --git a/subprojects/exess/README.md b/subprojects/exess/README.md new file mode 100644 index 00000000..c655ace7 --- /dev/null +++ b/subprojects/exess/README.md @@ -0,0 +1,83 @@ +Exess +===== + +Exess is a simple library for reading and writing [XSD][] datatypes. + +Exess is useful for applications that need to read/write common datatypes +from/to strings, in a standard and locale-independent format. It supports +reading any valid syntax, and writing in canonical form. The implementation is +not complete, but includes support for all of the common datatypes that are +generally useful (the XML-specific and partial Gregorian calendar datatypes are +omitted). + +Conversion to a string and back is lossless for all supported values. For +example, writing a `float` number to a string then reading it back will yield +the exact same `float` as the original value. + +The API consists mainly of simple read and write functions for each datatype. +A variant type is also included which allows generic code to work with values +of any type. For flexibility, allocation is handled by the caller, making it +possible to work on the stack, or read and write values to fields in some +structure. Syntax errors are reported with a descriptive error code and +character offset, allowing friendly error messages to be produced. + +Supported Datatypes +------------------- + +Exess supports reading and writing: + + * `boolean`, like "false", "true", "0", or "1". + + * `decimal`, like "1.234" (stored as `double`). + + * `float` and `double`, like "4.2E1" or "4.2e1". + + * The unbounded integer types `integer`, `nonPositiveInteger`, + `negativeInteger`, `nonNegativeInteger`, and `nonPositiveInteger` (stored + as `int64_t` or `uint64_t`). + + * The fixed size integer types `long`, `int`, `short`, `byte`, + `unsignedLong`, `unsignedInt`, `unsignedShort`, and `unsignedByte`. + + * `duration`, like "P1Y6M". + + * `time`, like "12:30:00.00". + + * `date`, like "2001-12-31". + + * `hex`, like "EC5355". + + * `base64`,like "Zm9vYmFy". + +Dependencies +------------ + +None, except the C standard library. + +Building +-------- + +A [Meson][] build definition is included which can be used to do a proper +system installation with a `pkg-config` file, generate IDE projects, run the +tests, and so on. For example, the library and tests can be built and run like +so: + + meson setup build + cd build + ninja test + +Documentation +------------- + + * [API reference (single page)](https://drobilla.gitlab.io/exess/c/singlehtml) + * [API reference (paginated)](https://drobilla.gitlab.io/exess/c/html) + +See the [Meson documentation][] for more details on using Meson. + + -- David Robillard + +[XSD]: https://www.w3.org/TR/xmlschema-2/ + +[Meson]: https://mesonbuild.com/ + +[Meson documentation]: https://mesonbuild.com/Quick-guide.html diff --git a/subprojects/exess/bindings/cpp/include/exess/exess.hpp b/subprojects/exess/bindings/cpp/include/exess/exess.hpp new file mode 100644 index 00000000..7aa6fc5b --- /dev/null +++ b/subprojects/exess/bindings/cpp/include/exess/exess.hpp @@ -0,0 +1,707 @@ +/* + Copyright 2021 David Robillard + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#ifndef EXESS_EXESS_HPP +#define EXESS_EXESS_HPP + +#include "exess/exess.h" + +#include +#include +#include +#include +#include +#include +#include + +namespace exess { + +/** + @defgroup exesspp Exess C++ API + This is the C++ wrapper for the exess API. + @{ +*/ + +constexpr const char* EXESS_NONNULL const xsd_uri = + "http://www.w3.org/2001/XMLSchema#"; + +// FIXME: Reorganize +using Datatype = ExessDatatype; +using Result = ExessResult; + +using Duration = ExessDuration; +using DateTime = ExessDateTime; +using Time = ExessTime; +using Date = ExessDate; + +/** + @defgroup exesspp_status Status + @copydoc exess_status + @{ +*/ + +/// @copydoc ExessStatus +enum class Status { + success, ///< @copydoc EXESS_SUCCESS + expected_end, ///< @copydoc EXESS_EXPECTED_END + expected_boolean, ///< @copydoc EXESS_EXPECTED_BOOLEAN + expected_integer, ///< @copydoc EXESS_EXPECTED_INTEGER + expected_duration, ///< @copydoc EXESS_EXPECTED_DURATION + expected_sign, ///< @copydoc EXESS_EXPECTED_SIGN + expected_digit, ///< @copydoc EXESS_EXPECTED_DIGIT + expected_colon, ///< @copydoc EXESS_EXPECTED_COLON + expected_dash, ///< @copydoc EXESS_EXPECTED_DASH + expected_time_sep, ///< @copydoc EXESS_EXPECTED_TIME_SEP + expected_time_tag, ///< @copydoc EXESS_EXPECTED_TIME_TAG + expected_date_tag, ///< @copydoc EXESS_EXPECTED_DATE_TAG + expected_hex, ///< @copydoc EXESS_EXPECTED_HEX + expected_base64, ///< @copydoc EXESS_EXPECTED_BASE64 + bad_order, ///< @copydoc EXESS_BAD_ORDER + bad_value, ///< @copydoc EXESS_BAD_VALUE + out_of_range, ///< @copydoc EXESS_OUT_OF_RANGE + no_space, ///< @copydoc EXESS_NO_SPACE + would_reduce_precision, ///< @copydoc EXESS_WOULD_REDUCE_PRECISION + would_round, ///< @copydoc EXESS_WOULD_ROUND + would_truncate, ///< @copydoc EXESS_WOULD_TRUNCATE + unsupported, ///< @copydoc EXESS_UNSUPPORTED +}; + +/// @copydoc exess_strerror +inline const char* EXESS_NONNULL +strerror(const Status status) +{ + return exess_strerror(static_cast(status)); +} + +inline std::ostream& +operator<<(std::ostream& stream, const Status status) +{ + return stream << strerror(status); +} + +/** + @} + + Datatype Traits +*/ + +namespace detail { + +template +struct DatatypeTraits {}; + +template<> +struct DatatypeTraits { + static constexpr auto datatype = EXESS_BOOLEAN; + static constexpr auto read_function = exess_read_boolean; + static constexpr auto write_function = exess_write_boolean; +}; + +template<> +struct DatatypeTraits { + static constexpr auto datatype = EXESS_DOUBLE; + static constexpr auto read_function = exess_read_double; + static constexpr auto write_function = exess_write_double; +}; + +template<> +struct DatatypeTraits { + static constexpr auto datatype = EXESS_FLOAT; + static constexpr auto read_function = exess_read_float; + static constexpr auto write_function = exess_write_float; +}; + +template<> +struct DatatypeTraits { + static constexpr auto datatype = EXESS_LONG; + static constexpr auto read_function = exess_read_long; + static constexpr auto write_function = exess_write_long; +}; + +template<> +struct DatatypeTraits { + static constexpr auto datatype = EXESS_INT; + static constexpr auto read_function = exess_read_int; + static constexpr auto write_function = exess_write_int; +}; + +template<> +struct DatatypeTraits { + static constexpr auto datatype = EXESS_SHORT; + static constexpr auto read_function = exess_read_short; + static constexpr auto write_function = exess_write_short; +}; + +template<> +struct DatatypeTraits { + static constexpr auto datatype = EXESS_BYTE; + static constexpr auto read_function = exess_read_byte; + static constexpr auto write_function = exess_write_byte; +}; + +template<> +struct DatatypeTraits { + static constexpr auto datatype = EXESS_ULONG; + static constexpr auto read_function = exess_read_ulong; + static constexpr auto write_function = exess_write_ulong; +}; + +template<> +struct DatatypeTraits { + static constexpr auto datatype = EXESS_UINT; + static constexpr auto read_function = exess_read_uint; + static constexpr auto write_function = exess_write_uint; +}; + +template<> +struct DatatypeTraits { + static constexpr auto datatype = EXESS_USHORT; + static constexpr auto read_function = exess_read_ushort; + static constexpr auto write_function = exess_write_ushort; +}; + +template<> +struct DatatypeTraits { + static constexpr auto datatype = EXESS_UBYTE; + static constexpr auto read_function = exess_read_ubyte; + static constexpr auto write_function = exess_write_ubyte; +}; + +template<> +struct DatatypeTraits { + static constexpr auto datatype = EXESS_DURATION; + static constexpr auto read_function = exess_read_duration; + static constexpr auto write_function = exess_write_duration; +}; + +template<> +struct DatatypeTraits { + static constexpr auto datatype = EXESS_DATETIME; + static constexpr auto read_function = exess_read_datetime; + static constexpr auto write_function = exess_write_datetime; +}; + +template<> +struct DatatypeTraits