From e60c55ea433a38fdcb4ae9272be452d2d7efc6be Mon Sep 17 00:00:00 2001 From: DockedFerret800 Date: Wed, 18 Mar 2026 18:33:46 +0000 Subject: [PATCH 01/62] Early progress on modules --- .gitignore | 1 + CMakeLists.txt | 36 +- CMakePresets.json | 266 ++--- README.md | 22 +- benchmarks/lazy_benchmark.cpp | 12 +- benchmarks/simple_float_benchmark.cpp | 42 +- benchmarks/skip_ws_benchmark.cpp | 90 +- benchmarks/string_write_benchmark.cpp | 52 +- cmake/install-rules.cmake | 4 + cmake/modules-files.cmake | 272 +++++ docs/advanced-api-usage.md | 28 +- docs/binary.md | 34 +- docs/cbor.md | 6 +- docs/custom-serialization.md | 2 +- docs/design/json_merge_patch_rfc7386.md | 4 +- docs/design/json_patch_rfc6902.md | 8 +- docs/generic-json.md | 10 +- docs/glaze-interfaces.md | 4 +- docs/index.md | 2 +- docs/json-pointer-syntax.md | 2 +- docs/json.md | 2 +- docs/lazy-beve.md | 12 +- docs/lazy-json.md | 10 +- docs/modify-reflection.md | 2 +- docs/networking/advanced-networking.md | 4 +- docs/networking/http-router.md | 2 +- docs/networking/http-server.md | 4 +- docs/networking/websocket-client.md | 6 +- docs/options.md | 10 +- docs/partial-read.md | 2 +- docs/partial-write.md | 4 +- docs/reading.md | 4 +- docs/rename-keys.md | 12 +- docs/rpc/repe-buffer.md | 6 +- docs/rpc/repe-jsonrpc-conversion.md | 2 +- docs/rpc/repe-plugin.md | 26 +- docs/security.md | 14 +- docs/stencil-mustache.md | 4 +- docs/thread-pool.md | 4 +- docs/toml.md | 8 +- docs/variant-handling.md | 4 +- docs/volatile-support.md | 4 +- docs/wrappers.md | 18 +- docs/writing.md | 14 +- docs/yaml.md | 2 +- examples/wrapping_middleware_example.cpp | 10 +- fuzzing/CMakeLists.txt | 2 +- fuzzing/binary_reflection.cpp | 4 +- fuzzing/cbor_reflection.cpp | 4 +- fuzzing/cbor_roundtrip_floating.cpp | 4 +- fuzzing/cbor_roundtrip_int.cpp | 4 +- fuzzing/cbor_roundtrip_string.cpp | 4 +- fuzzing/csv_parsing.cpp | 2 +- fuzzing/json_exhaustive_roundtrip_float.cpp | 2 +- fuzzing/json_exhaustive_roundtrip_int.cpp | 2 +- fuzzing/json_generic.cpp | 2 +- fuzzing/json_jmespath.cpp | 4 +- fuzzing/json_minify.cpp | 2 +- fuzzing/json_prettify.cpp | 2 +- fuzzing/json_reflection.cpp | 4 +- fuzzing/json_roundtrip_floating.cpp | 4 +- fuzzing/json_roundtrip_int.cpp | 4 +- fuzzing/json_roundtrip_string.cpp | 4 +- fuzzing/json_with_comments.cpp | 4 +- fuzzing/main.cpp | 2 +- fuzzing/msgpack_reflection.cpp | 4 +- fuzzing/msgpack_roundtrip_floating.cpp | 4 +- fuzzing/msgpack_roundtrip_int.cpp | 4 +- fuzzing/msgpack_roundtrip_string.cpp | 4 +- include/glaze/api/std/deque.hpp | 17 - include/glaze/api/std/list.hpp | 17 - include/glaze/api/std/map.hpp | 18 - include/glaze/api/std/optional.hpp | 17 - include/glaze/api/std/set.hpp | 17 - include/glaze/api/std/shared_ptr.hpp | 17 - include/glaze/api/std/string.hpp | 18 - include/glaze/api/std/tuple.hpp | 20 - include/glaze/api/std/unique_ptr.hpp | 17 - include/glaze/api/std/unordered_set.hpp | 17 - include/glaze/api/std/vector.hpp | 17 - include/glaze/api/xxh64.hpp | 99 -- include/glaze/cbor.hpp | 11 - include/glaze/core/wrapper_traits.hpp | 7 - include/glaze/csv.hpp | 11 - include/glaze/json.hpp | 29 - include/glaze/util/convert.hpp | 21 - .../api/api.hpp => modules/glaze/api/api.ixx | 30 +- .../hash.hpp => modules/glaze/api/hash.ixx | 42 +- .../impl.hpp => modules/glaze/api/impl.ixx | 76 +- {include => modules}/glaze/api/lib.hpp | 0 .../glaze/api/std/array.ixx | 14 +- modules/glaze/api/std/deque.ixx | 17 + .../glaze/api/std/functional.ixx | 22 +- modules/glaze/api/std/list.ixx | 17 + modules/glaze/api/std/map.ixx | 18 + modules/glaze/api/std/optional.ixx | 17 + modules/glaze/api/std/set.ixx | 17 + modules/glaze/api/std/shared_ptr.ixx | 17 + .../glaze/api/std/span.ixx | 21 +- modules/glaze/api/std/string.ixx | 16 + modules/glaze/api/std/tuple.ixx | 20 + modules/glaze/api/std/unique_ptr.ixx | 17 + .../glaze/api/std/unordered_map.ixx | 14 +- modules/glaze/api/std/unordered_set.ixx | 17 + .../glaze/api/std/variant.ixx | 18 +- modules/glaze/api/std/vector.ixx | 17 + .../trait.hpp => modules/glaze/api/trait.ixx | 32 +- .../glaze/api/tuplet.ixx | 14 +- .../glaze/api/type_support.ixx | 33 +- modules/glaze/api/xxh64.ixx | 98 ++ {include => modules}/glaze/base64/base64.hpp | 0 {include => modules}/glaze/beve.hpp | 0 .../glaze/beve/beve_to_json.hpp | 67 +- .../glaze/beve/header.ixx | 107 +- .../glaze/beve/key_traits.ixx | 28 +- {include => modules}/glaze/beve/lazy.hpp | 211 ++-- .../glaze/beve/peek_header.hpp | 81 +- {include => modules}/glaze/beve/ptr.hpp | 0 .../read.hpp => modules/glaze/beve/read.ixx | 346 +++--- {include => modules}/glaze/beve/size.hpp | 154 +-- .../skip.hpp => modules/glaze/beve/skip.ixx | 63 +- {include => modules}/glaze/beve/wrappers.hpp | 11 +- .../write.hpp => modules/glaze/beve/write.ixx | 260 ++--- modules/glaze/cbor.ixx | 10 + .../glaze/cbor/cbor_to_json.ixx | 170 +-- .../glaze/cbor/header.ixx | 209 ++-- .../read.hpp => modules/glaze/cbor/read.ixx | 451 ++++---- .../skip.hpp => modules/glaze/cbor/skip.ixx | 60 +- .../glaze/cbor/wrappers.ixx | 32 +- .../write.hpp => modules/glaze/cbor/write.ixx | 236 +++-- {include => modules}/glaze/chrono.hpp | 0 {include => modules}/glaze/compare/approx.hpp | 0 .../glaze/compare/compare.hpp | 0 .../glaze/concepts/container_concepts.ixx | 32 +- .../glaze/containers/flat_map.ixx | 26 +- .../glaze/containers/inplace_vector.ixx | 53 +- .../glaze/core/array_apply.ixx | 17 +- .../glaze/core/as_array_wrapper.ixx | 23 +- .../glaze/core/buffer_traits.ixx | 58 +- .../cast.hpp => modules/glaze/core/cast.ixx | 24 +- .../glaze/core/chrono.ixx | 10 +- .../glaze/core/common.ixx | 217 ++-- .../glaze/core/constraint.ixx | 35 +- .../glaze/core/context.ixx | 46 +- .../glaze/core/convert_struct.ixx | 15 +- .../glaze/core/custom.ixx | 27 +- .../glaze/core/custom_meta.ixx | 25 +- .../glaze/core/error_category.ixx | 11 +- .../glaze/core/feature_test.hpp | 10 +- .../glaze/core/istream_buffer.ixx | 59 +- .../glaze/core/manage.ixx | 20 +- .../meta.hpp => modules/glaze/core/meta.ixx | 139 ++- modules/glaze/core/meta_fwd.ixx | 9 + .../glaze/core/optimization_level.ixx | 9 +- .../opts.hpp => modules/glaze/core/opts.ixx | 160 +-- .../glaze/core/ostream_buffer.ixx | 62 +- .../ptr.hpp => modules/glaze/core/ptr.ixx | 26 +- .../read.hpp => modules/glaze/core/read.ixx | 44 +- .../glaze/core/reflect.ixx | 991 +++++++++--------- .../seek.hpp => modules/glaze/core/seek.ixx | 92 +- .../glaze/core/std_error_code.ixx | 17 +- .../glaze/core/streaming_state.ixx | 26 +- .../core/to.hpp => modules/glaze/core/to.ixx | 18 +- modules/glaze/core/wrapper_traits.ixx | 8 + .../glaze/core/wrappers.ixx | 61 +- .../write.hpp => modules/glaze/core/write.ixx | 40 +- .../glaze/core/write_chars.ixx | 115 +- modules/glaze/csv.ixx | 12 + .../read.hpp => modules/glaze/csv/read.ixx | 125 ++- .../skip.hpp => modules/glaze/csv/skip.ixx | 10 +- .../write.hpp => modules/glaze/csv/write.ixx | 89 +- {include => modules}/glaze/eetf.hpp | 0 {include => modules}/glaze/eetf/cmp.hpp | 0 {include => modules}/glaze/eetf/defs.hpp | 0 {include => modules}/glaze/eetf/ei.hpp | 0 {include => modules}/glaze/eetf/opts.hpp | 11 +- {include => modules}/glaze/eetf/read.hpp | 11 +- {include => modules}/glaze/eetf/types.hpp | 0 {include => modules}/glaze/eetf/wrappers.hpp | 0 {include => modules}/glaze/eetf/write.hpp | 19 +- .../glaze/exceptions/binary_exceptions.hpp | 0 .../glaze/exceptions/cbor_exceptions.hpp | 0 .../glaze/exceptions/core_exceptions.hpp | 2 +- .../glaze/exceptions/csv_exceptions.hpp | 8 +- .../glaze/exceptions/json_exceptions.hpp | 0 .../exceptions/json_schema_exceptions.hpp | 0 .../glaze/exceptions/msgpack_exceptions.hpp | 0 {include => modules}/glaze/ext/README.md | 0 {include => modules}/glaze/ext/cli_menu.hpp | 16 +- {include => modules}/glaze/ext/eigen.hpp | 33 +- {include => modules}/glaze/ext/glaze_asio.hpp | 33 +- {include => modules}/glaze/ext/jsonrpc.hpp | 2 +- .../glaze/file/file_ops.ixx | 13 +- .../glaze/file/file_watch.hpp | 0 .../glaze/file/hostname_include.ixx | 38 +- .../glaze/file/raw_or_file.ixx | 25 +- .../glaze/file/read_directory.ixx | 17 +- .../glaze/file/write_directory.ixx | 19 +- .../glaze/format/format_to.hpp | 2 +- .../glaze.hpp => modules/glaze/glaze.ixx | 30 +- .../glaze/glaze_exceptions.hpp | 2 +- .../glaze/hardware/volatile_array.ixx | 27 +- modules/glaze/json.ixx | 31 + .../glaze/json/escape_unicode.ixx | 47 +- .../glaze/json/float_format.ixx | 44 +- .../glaze/json/generic.ixx | 218 ++-- .../glaze/json/invoke.ixx | 41 +- .../glaze/json/jmespath.ixx | 130 +-- .../glaze/json/json_concepts.ixx | 10 +- .../glaze/json/json_format.ixx | 63 +- .../glaze/json/json_ptr.ixx | 92 +- .../glaze/json/json_stream.ixx | 26 +- .../lazy.hpp => modules/glaze/json/lazy.ixx | 147 +-- .../glaze/json/max_write_precision.ixx | 19 +- .../glaze/json/minify.ixx | 42 +- .../glaze/json/ndjson.ixx | 42 +- .../patch.hpp => modules/glaze/json/patch.ixx | 180 +++- .../glaze/json/prettify.ixx | 34 +- .../ptr.hpp => modules/glaze/json/ptr.ixx | 13 +- .../glaze/json/raw_string.ixx | 17 +- .../read.hpp => modules/glaze/json/read.ixx | 458 ++++---- .../glaze/json/schema.ixx | 114 +- .../skip.hpp => modules/glaze/json/skip.ixx | 16 +- .../study.hpp => modules/glaze/json/study.ixx | 58 +- .../glaze/json/wrappers.ixx | 54 +- .../write.hpp => modules/glaze/json/write.ixx | 232 ++-- {include => modules}/glaze/msgpack.hpp | 0 {include => modules}/glaze/msgpack/common.hpp | 219 ++-- {include => modules}/glaze/msgpack/read.hpp | 227 ++-- {include => modules}/glaze/msgpack/skip.hpp | 21 +- {include => modules}/glaze/msgpack/write.hpp | 251 ++--- {include => modules}/glaze/net/cors.hpp | 2 +- {include => modules}/glaze/net/http.hpp | 8 +- .../glaze/net/http_client.hpp | 67 +- .../glaze/net/http_router.hpp | 21 +- .../glaze/net/http_server.hpp | 69 +- {include => modules}/glaze/net/openapi.hpp | 0 .../glaze/net/rest_registry_impl.hpp | 2 +- {include => modules}/glaze/net/url.hpp | 10 +- .../glaze/net/websocket_client.hpp | 9 +- .../glaze/net/websocket_connection.hpp | 116 +- .../glaze/record/recorder.ixx | 58 +- .../glaze/reflection/get_name.ixx | 48 +- .../glaze/reflection/requires_key.ixx | 14 +- .../glaze/reflection/to_tuple.ixx | 25 +- .../glaze/rpc/jsonrpc_registry_impl.hpp | 2 +- {include => modules}/glaze/rpc/registry.hpp | 29 +- .../glaze/rpc/repe/buffer.hpp | 27 +- .../glaze/rpc/repe/header.hpp | 25 +- {include => modules}/glaze/rpc/repe/plugin.h | 6 +- .../glaze/rpc/repe/plugin_helper.hpp | 6 +- {include => modules}/glaze/rpc/repe/repe.hpp | 34 +- .../glaze/rpc/repe/repe_registry_impl.hpp | 2 +- .../glaze/rpc/repe/repe_to_jsonrpc.hpp | 4 +- .../avx.hpp => modules/glaze/simd/avx.ixx | 20 +- .../neon.hpp => modules/glaze/simd/neon.ixx | 36 +- {include => modules}/glaze/simd/simd.hpp | 2 +- .../sse.hpp => modules/glaze/simd/sse.ixx | 27 +- .../glaze/stencil/stencil.hpp | 35 +- .../glaze/stencil/stencilcount.hpp | 21 +- {include => modules}/glaze/thread/async.hpp | 0 .../glaze/thread/async_string.hpp | 216 ++-- .../glaze/thread/async_vector.hpp | 4 +- .../glaze/thread/atomic.ixx | 16 +- {include => modules}/glaze/thread/guard.hpp | 0 .../glaze/thread/shared_async_map.hpp | 4 +- .../glaze/thread/shared_async_vector.hpp | 0 .../glaze/thread/threadpool.ixx | 44 +- .../glaze/thread/value_proxy.hpp | 2 +- {include => modules}/glaze/toml.hpp | 0 {include => modules}/glaze/toml/common.hpp | 0 {include => modules}/glaze/toml/opts.hpp | 10 +- {include => modules}/glaze/toml/read.hpp | 65 +- {include => modules}/glaze/toml/skip.hpp | 0 {include => modules}/glaze/toml/write.hpp | 83 +- .../glaze/trace/trace.ixx | 37 +- .../glaze/tuplet/tuple.ixx | 95 +- .../atoi.hpp => modules/glaze/util/atoi.ixx | 158 +-- .../bit.hpp => modules/glaze/util/bit.ixx | 22 +- .../glaze/util/bit_array.ixx | 21 +- .../glaze/util/buffer_pool.hpp | 14 +- .../glaze/util/compare.ixx | 97 +- modules/glaze/util/convert.ixx | 19 + .../glaze/util/dragonbox.ixx | 56 +- .../dtoa.hpp => modules/glaze/util/dtoa.ixx | 120 +-- .../dump.hpp => modules/glaze/util/dump.ixx | 65 +- .../glaze/util/expected.ixx | 22 +- .../glaze/util/fast_float.ixx | 837 ++++++++------- .../glaze/util/for_each.ixx | 35 +- .../glaze/util/glaze_fast_float.ixx | 37 +- .../help.hpp => modules/glaze/util/help.ixx | 14 +- {include => modules}/glaze/util/inline.hpp | 0 .../itoa.hpp => modules/glaze/util/itoa.ixx | 176 ++-- .../glaze/util/itoa_40kb.ixx | 209 ++-- .../glaze/util/key_transformers.hpp | 12 +- .../glaze/util/memory_pool.hpp | 14 +- {include => modules}/glaze/util/murmur.hpp | 24 +- .../parse.hpp => modules/glaze/util/parse.ixx | 235 ++--- .../glaze/util/primes_64.ixx | 10 +- .../glaze/util/progress_bar.hpp | 18 +- .../glaze/util/simple_float.ixx | 299 +++--- .../glaze/util/string_literal.ixx | 38 +- .../tuple.hpp => modules/glaze/util/tuple.ixx | 17 +- .../glaze/util/type_traits.ixx | 12 +- .../glaze/util/utility.ixx | 9 +- .../glaze/util/validate.ixx | 49 +- .../glaze/util/variant.ixx | 26 +- .../version.hpp => modules/glaze/version.ixx | 17 +- {include => modules}/glaze/yaml.hpp | 0 {include => modules}/glaze/yaml/common.hpp | 55 +- {include => modules}/glaze/yaml/opts.hpp | 17 +- {include => modules}/glaze/yaml/read.hpp | 207 ++-- {include => modules}/glaze/yaml/skip.hpp | 10 +- {include => modules}/glaze/yaml/write.hpp | 83 +- src/main.cpp | 2 +- tests/CMakeLists.txt | 5 +- tests/api_test/api_test.cpp | 22 +- tests/beve_test/beve_test.cpp | 324 +++--- tests/beve_test/lazy_beve_test.cpp | 18 +- tests/beve_test/skip_null_on_read_test.cpp | 2 +- tests/buffer_pool_test/buffer_pool_test.cpp | 2 +- tests/cbor_test/cbor_test.cpp | 82 +- tests/csv_test/csv_test.cpp | 52 +- tests/eetf_test/eetf_test.cpp | 6 +- tests/example_json/example_json.cpp | 8 +- tests/exceptions_test/exceptions_test.cpp | 14 +- tests/find_package/include/example.hpp | 2 +- tests/inplace_vector/inplace_vector_test.cpp | 12 +- tests/int_parsing/int_parsing.cpp | 82 +- .../istream_buffer_test.cpp | 62 +- .../json_performance/json_perf_benchmark.cpp | 50 +- tests/json_performance/json_perf_common.hpp | 8 +- tests/json_performance/json_perf_discord.cpp | 18 +- tests/json_performance/json_perf_numbers.cpp | 36 +- tests/json_performance/json_perf_objects.cpp | 16 +- tests/json_performance/json_perf_strings.cpp | 24 +- tests/json_performance/json_performance.cpp | 154 +-- .../json_reflection_test/front_hash_test.cpp | 2 +- .../json_reflection_test.cpp | 46 +- tests/json_test/CMakeLists.txt | 6 + .../json_test/allocate_raw_pointers_test.cpp | 19 +- tests/json_test/byte_array_test.cpp | 12 +- tests/json_test/generic_int_test.cpp | 30 +- tests/json_test/generic_test.cpp | 10 +- tests/json_test/indexed_rename_key_test.cpp | 15 +- tests/json_test/json_merge_patch_test.cpp | 11 +- tests/json_test/json_patch_test.cpp | 12 +- tests/json_test/json_test.cpp | 402 +++---- tests/json_test/json_test_shared_types.ixx | 37 + tests/json_test/json_variant_support_test.cpp | 49 +- tests/json_test/jsonschema_test.cpp | 20 +- tests/json_test/lazy_test.cpp | 15 +- tests/json_test/linear_search_test.cpp | 8 +- tests/json_test/nullable_lambda_test.cpp | 8 +- tests/json_test/skip_null_on_read_test.cpp | 8 +- tests/json_test/snprintf_fallback_test.cpp | 2 +- tests/mock_json_test/mock_json_test.cpp | 54 +- tests/msgpack_test/msgpack_test.cpp | 8 +- .../networking_tests/asio_repe/asio_repe.cpp | 4 +- .../http_examples/http_examples.cpp | 10 +- .../http_server_api_tests.cpp | 16 +- .../http_server_post_test.cpp | 2 +- .../registry_view_test/registry_view_test.cpp | 2 +- .../repe_plugin_test/repe_plugin_test.cpp | 6 +- .../networking_tests/repe_test/repe_test.cpp | 34 +- .../repe_to_jsonrpc_test.cpp | 8 +- .../websocket_test/websocket_client_test.cpp | 6 +- .../websocket_test/websocket_close_test.cpp | 6 +- .../websocket_test/wss_test.cpp | 6 +- .../ostream_buffer_test.cpp | 60 +- tests/reflection/enum_test.cpp | 18 +- tests/reflection/reflection.cpp | 4 +- tests/roundtrip/roundtrip.cpp | 2 +- tests/simple_float_test/simple_float_test.cpp | 104 +- tests/stencil/stencil_test.cpp | 20 +- tests/threading_test/threading_test.cpp | 68 +- tests/toml_test/toml_test.cpp | 34 +- tests/yaml_test/yaml_test.cpp | 8 +- 378 files changed, 9024 insertions(+), 8072 deletions(-) create mode 100644 cmake/modules-files.cmake delete mode 100644 include/glaze/api/std/deque.hpp delete mode 100644 include/glaze/api/std/list.hpp delete mode 100644 include/glaze/api/std/map.hpp delete mode 100644 include/glaze/api/std/optional.hpp delete mode 100644 include/glaze/api/std/set.hpp delete mode 100644 include/glaze/api/std/shared_ptr.hpp delete mode 100644 include/glaze/api/std/string.hpp delete mode 100644 include/glaze/api/std/tuple.hpp delete mode 100644 include/glaze/api/std/unique_ptr.hpp delete mode 100644 include/glaze/api/std/unordered_set.hpp delete mode 100644 include/glaze/api/std/vector.hpp delete mode 100644 include/glaze/api/xxh64.hpp delete mode 100644 include/glaze/cbor.hpp delete mode 100644 include/glaze/core/wrapper_traits.hpp delete mode 100644 include/glaze/csv.hpp delete mode 100644 include/glaze/json.hpp delete mode 100644 include/glaze/util/convert.hpp rename include/glaze/api/api.hpp => modules/glaze/api/api.ixx (88%) rename include/glaze/api/hash.hpp => modules/glaze/api/hash.ixx (74%) rename include/glaze/api/impl.hpp => modules/glaze/api/impl.ixx (89%) rename {include => modules}/glaze/api/lib.hpp (100%) rename include/glaze/api/std/array.hpp => modules/glaze/api/std/array.ixx (76%) create mode 100644 modules/glaze/api/std/deque.ixx rename include/glaze/api/std/functional.hpp => modules/glaze/api/std/functional.ixx (81%) create mode 100644 modules/glaze/api/std/list.ixx create mode 100644 modules/glaze/api/std/map.ixx create mode 100644 modules/glaze/api/std/optional.ixx create mode 100644 modules/glaze/api/std/set.ixx create mode 100644 modules/glaze/api/std/shared_ptr.ixx rename include/glaze/api/std/span.hpp => modules/glaze/api/std/span.ixx (53%) create mode 100644 modules/glaze/api/std/string.ixx create mode 100644 modules/glaze/api/std/tuple.ixx create mode 100644 modules/glaze/api/std/unique_ptr.ixx rename include/glaze/api/std/unordered_map.hpp => modules/glaze/api/std/unordered_map.ixx (50%) create mode 100644 modules/glaze/api/std/unordered_set.ixx rename include/glaze/api/std/variant.hpp => modules/glaze/api/std/variant.ixx (55%) create mode 100644 modules/glaze/api/std/vector.ixx rename include/glaze/api/trait.hpp => modules/glaze/api/trait.ixx (84%) rename include/glaze/api/tuplet.hpp => modules/glaze/api/tuplet.ixx (51%) rename include/glaze/api/type_support.hpp => modules/glaze/api/type_support.ixx (66%) create mode 100644 modules/glaze/api/xxh64.ixx rename {include => modules}/glaze/base64/base64.hpp (100%) rename {include => modules}/glaze/beve.hpp (100%) rename {include => modules}/glaze/beve/beve_to_json.hpp (91%) rename include/glaze/beve/header.hpp => modules/glaze/beve/header.ixx (62%) rename include/glaze/beve/key_traits.hpp => modules/glaze/beve/key_traits.ixx (66%) rename {include => modules}/glaze/beve/lazy.hpp (85%) rename {include => modules}/glaze/beve/peek_header.hpp (76%) rename {include => modules}/glaze/beve/ptr.hpp (100%) rename include/glaze/beve/read.hpp => modules/glaze/beve/read.ixx (85%) rename {include => modules}/glaze/beve/size.hpp (81%) rename include/glaze/beve/skip.hpp => modules/glaze/beve/skip.ixx (80%) rename {include => modules}/glaze/beve/wrappers.hpp (89%) rename include/glaze/beve/write.hpp => modules/glaze/beve/write.ixx (86%) create mode 100644 modules/glaze/cbor.ixx rename include/glaze/cbor/cbor_to_json.hpp => modules/glaze/cbor/cbor_to_json.ixx (79%) rename include/glaze/cbor/header.hpp => modules/glaze/cbor/header.ixx (53%) rename include/glaze/cbor/read.hpp => modules/glaze/cbor/read.ixx (80%) rename include/glaze/cbor/skip.hpp => modules/glaze/cbor/skip.ixx (84%) rename include/glaze/cbor/wrappers.hpp => modules/glaze/cbor/wrappers.ixx (78%) rename include/glaze/cbor/write.hpp => modules/glaze/cbor/write.ixx (85%) rename {include => modules}/glaze/chrono.hpp (100%) rename {include => modules}/glaze/compare/approx.hpp (100%) rename {include => modules}/glaze/compare/compare.hpp (100%) rename include/glaze/concepts/container_concepts.hpp => modules/glaze/concepts/container_concepts.ixx (95%) rename include/glaze/containers/flat_map.hpp => modules/glaze/containers/flat_map.ixx (94%) rename include/glaze/containers/inplace_vector.hpp => modules/glaze/containers/inplace_vector.ixx (97%) rename include/glaze/core/array_apply.hpp => modules/glaze/core/array_apply.ixx (78%) rename include/glaze/core/as_array_wrapper.hpp => modules/glaze/core/as_array_wrapper.ixx (63%) rename include/glaze/core/buffer_traits.hpp => modules/glaze/core/buffer_traits.ixx (77%) rename include/glaze/core/cast.hpp => modules/glaze/core/cast.ixx (91%) rename include/glaze/core/chrono.hpp => modules/glaze/core/chrono.ixx (97%) rename include/glaze/core/common.hpp => modules/glaze/core/common.ixx (85%) rename include/glaze/core/constraint.hpp => modules/glaze/core/constraint.ixx (92%) rename include/glaze/core/context.hpp => modules/glaze/core/context.ixx (82%) rename include/glaze/core/convert_struct.hpp => modules/glaze/core/convert_struct.ixx (82%) rename include/glaze/core/custom.hpp => modules/glaze/core/custom.ixx (92%) rename include/glaze/core/custom_meta.hpp => modules/glaze/core/custom_meta.ixx (85%) rename include/glaze/core/error_category.hpp => modules/glaze/core/error_category.ixx (97%) rename {include => modules}/glaze/core/feature_test.hpp (96%) rename include/glaze/core/istream_buffer.hpp => modules/glaze/core/istream_buffer.ixx (81%) rename include/glaze/core/manage.hpp => modules/glaze/core/manage.ixx (88%) rename include/glaze/core/meta.hpp => modules/glaze/core/meta.ixx (86%) create mode 100644 modules/glaze/core/meta_fwd.ixx rename include/glaze/core/optimization_level.hpp => modules/glaze/core/optimization_level.ixx (92%) rename include/glaze/core/opts.hpp => modules/glaze/core/opts.ixx (90%) rename include/glaze/core/ostream_buffer.hpp => modules/glaze/core/ostream_buffer.ixx (78%) rename include/glaze/core/ptr.hpp => modules/glaze/core/ptr.ixx (67%) rename include/glaze/core/read.hpp => modules/glaze/core/read.ixx (85%) rename include/glaze/core/reflect.hpp => modules/glaze/core/reflect.ixx (73%) rename include/glaze/core/seek.hpp => modules/glaze/core/seek.ixx (90%) rename include/glaze/core/std_error_code.hpp => modules/glaze/core/std_error_code.ixx (78%) rename include/glaze/core/streaming_state.hpp => modules/glaze/core/streaming_state.ixx (81%) rename include/glaze/core/to.hpp => modules/glaze/core/to.ixx (69%) create mode 100644 modules/glaze/core/wrapper_traits.ixx rename include/glaze/core/wrappers.hpp => modules/glaze/core/wrappers.ixx (75%) rename include/glaze/core/write.hpp => modules/glaze/core/write.ixx (79%) rename include/glaze/core/write_chars.hpp => modules/glaze/core/write_chars.ixx (83%) create mode 100644 modules/glaze/csv.ixx rename include/glaze/csv/read.hpp => modules/glaze/csv/read.ixx (94%) rename include/glaze/csv/skip.hpp => modules/glaze/csv/skip.ixx (88%) rename include/glaze/csv/write.hpp => modules/glaze/csv/write.ixx (92%) rename {include => modules}/glaze/eetf.hpp (100%) rename {include => modules}/glaze/eetf/cmp.hpp (100%) rename {include => modules}/glaze/eetf/defs.hpp (100%) rename {include => modules}/glaze/eetf/ei.hpp (100%) rename {include => modules}/glaze/eetf/opts.hpp (52%) rename {include => modules}/glaze/eetf/read.hpp (96%) rename {include => modules}/glaze/eetf/types.hpp (100%) rename {include => modules}/glaze/eetf/wrappers.hpp (100%) rename {include => modules}/glaze/eetf/write.hpp (94%) rename {include => modules}/glaze/exceptions/binary_exceptions.hpp (100%) rename {include => modules}/glaze/exceptions/cbor_exceptions.hpp (100%) rename {include => modules}/glaze/exceptions/core_exceptions.hpp (97%) rename {include => modules}/glaze/exceptions/csv_exceptions.hpp (86%) rename {include => modules}/glaze/exceptions/json_exceptions.hpp (100%) rename {include => modules}/glaze/exceptions/json_schema_exceptions.hpp (100%) rename {include => modules}/glaze/exceptions/msgpack_exceptions.hpp (100%) rename {include => modules}/glaze/ext/README.md (100%) rename {include => modules}/glaze/ext/cli_menu.hpp (95%) rename {include => modules}/glaze/ext/eigen.hpp (93%) rename {include => modules}/glaze/ext/glaze_asio.hpp (96%) rename {include => modules}/glaze/ext/jsonrpc.hpp (99%) rename include/glaze/file/file_ops.hpp => modules/glaze/file/file_ops.ixx (90%) rename {include => modules}/glaze/file/file_watch.hpp (100%) rename include/glaze/file/hostname_include.hpp => modules/glaze/file/hostname_include.ixx (81%) rename include/glaze/file/raw_or_file.hpp => modules/glaze/file/raw_or_file.ixx (84%) rename include/glaze/file/read_directory.hpp => modules/glaze/file/read_directory.ixx (83%) rename include/glaze/file/write_directory.hpp => modules/glaze/file/write_directory.ixx (79%) rename {include => modules}/glaze/format/format_to.hpp (93%) rename include/glaze/glaze.hpp => modules/glaze/glaze.ixx (74%) rename {include => modules}/glaze/glaze_exceptions.hpp (95%) rename include/glaze/hardware/volatile_array.hpp => modules/glaze/hardware/volatile_array.ixx (89%) create mode 100644 modules/glaze/json.ixx rename include/glaze/json/escape_unicode.hpp => modules/glaze/json/escape_unicode.ixx (86%) rename include/glaze/json/float_format.hpp => modules/glaze/json/float_format.ixx (83%) rename include/glaze/json/generic.hpp => modules/glaze/json/generic.ixx (84%) rename include/glaze/json/invoke.hpp => modules/glaze/json/invoke.ixx (90%) rename include/glaze/json/jmespath.hpp => modules/glaze/json/jmespath.ixx (91%) rename include/glaze/json/json_concepts.hpp => modules/glaze/json/json_concepts.ixx (73%) rename include/glaze/json/json_format.hpp => modules/glaze/json/json_format.ixx (74%) rename include/glaze/json/json_ptr.hpp => modules/glaze/json/json_ptr.ixx (78%) rename include/glaze/json/json_stream.hpp => modules/glaze/json/json_stream.ixx (92%) rename include/glaze/json/lazy.hpp => modules/glaze/json/lazy.ixx (90%) rename include/glaze/json/max_write_precision.hpp => modules/glaze/json/max_write_precision.ixx (91%) rename include/glaze/json/minify.hpp => modules/glaze/json/minify.ixx (85%) rename include/glaze/json/ndjson.hpp => modules/glaze/json/ndjson.ixx (90%) rename include/glaze/json/patch.hpp => modules/glaze/json/patch.ixx (85%) rename include/glaze/json/prettify.hpp => modules/glaze/json/prettify.ixx (91%) rename include/glaze/json/ptr.hpp => modules/glaze/json/ptr.ixx (58%) rename include/glaze/json/raw_string.hpp => modules/glaze/json/raw_string.ixx (89%) rename include/glaze/json/read.hpp => modules/glaze/json/read.ixx (92%) rename include/glaze/json/schema.hpp => modules/glaze/json/schema.ixx (92%) rename include/glaze/json/skip.hpp => modules/glaze/json/skip.ixx (97%) rename include/glaze/json/study.hpp => modules/glaze/json/study.ixx (94%) rename include/glaze/json/wrappers.hpp => modules/glaze/json/wrappers.ixx (68%) rename include/glaze/json/write.hpp => modules/glaze/json/write.ixx (93%) rename {include => modules}/glaze/msgpack.hpp (100%) rename {include => modules}/glaze/msgpack/common.hpp (57%) rename {include => modules}/glaze/msgpack/read.hpp (81%) rename {include => modules}/glaze/msgpack/skip.hpp (87%) rename {include => modules}/glaze/msgpack/write.hpp (80%) rename {include => modules}/glaze/net/cors.hpp (99%) rename {include => modules}/glaze/net/http.hpp (97%) rename {include => modules}/glaze/net/http_client.hpp (96%) rename {include => modules}/glaze/net/http_router.hpp (98%) rename {include => modules}/glaze/net/http_server.hpp (97%) rename {include => modules}/glaze/net/openapi.hpp (100%) rename {include => modules}/glaze/net/rest_registry_impl.hpp (99%) rename {include => modules}/glaze/net/url.hpp (96%) rename {include => modules}/glaze/net/websocket_client.hpp (98%) rename {include => modules}/glaze/net/websocket_connection.hpp (92%) rename include/glaze/record/recorder.hpp => modules/glaze/record/recorder.ixx (85%) rename include/glaze/reflection/get_name.hpp => modules/glaze/reflection/get_name.ixx (92%) rename include/glaze/reflection/requires_key.hpp => modules/glaze/reflection/requires_key.ixx (63%) rename include/glaze/reflection/to_tuple.hpp => modules/glaze/reflection/to_tuple.ixx (99%) rename {include => modules}/glaze/rpc/jsonrpc_registry_impl.hpp (99%) rename {include => modules}/glaze/rpc/registry.hpp (96%) rename {include => modules}/glaze/rpc/repe/buffer.hpp (93%) rename {include => modules}/glaze/rpc/repe/header.hpp (63%) rename {include => modules}/glaze/rpc/repe/plugin.h (96%) rename {include => modules}/glaze/rpc/repe/plugin_helper.hpp (92%) rename {include => modules}/glaze/rpc/repe/repe.hpp (94%) rename {include => modules}/glaze/rpc/repe/repe_registry_impl.hpp (99%) rename {include => modules}/glaze/rpc/repe/repe_to_jsonrpc.hpp (97%) rename include/glaze/simd/avx.hpp => modules/glaze/simd/avx.ixx (77%) rename include/glaze/simd/neon.hpp => modules/glaze/simd/neon.ixx (74%) rename {include => modules}/glaze/simd/simd.hpp (88%) rename include/glaze/simd/sse.hpp => modules/glaze/simd/sse.ixx (65%) rename {include => modules}/glaze/stencil/stencil.hpp (92%) rename {include => modules}/glaze/stencil/stencilcount.hpp (89%) rename {include => modules}/glaze/thread/async.hpp (100%) rename {include => modules}/glaze/thread/async_string.hpp (65%) rename {include => modules}/glaze/thread/async_vector.hpp (99%) rename include/glaze/thread/atomic.hpp => modules/glaze/thread/atomic.ixx (81%) rename {include => modules}/glaze/thread/guard.hpp (100%) rename {include => modules}/glaze/thread/shared_async_map.hpp (99%) rename {include => modules}/glaze/thread/shared_async_vector.hpp (100%) rename include/glaze/thread/threadpool.hpp => modules/glaze/thread/threadpool.ixx (81%) rename {include => modules}/glaze/thread/value_proxy.hpp (89%) rename {include => modules}/glaze/toml.hpp (100%) rename {include => modules}/glaze/toml/common.hpp (100%) rename {include => modules}/glaze/toml/opts.hpp (63%) rename {include => modules}/glaze/toml/read.hpp (98%) rename {include => modules}/glaze/toml/skip.hpp (100%) rename {include => modules}/glaze/toml/write.hpp (93%) rename include/glaze/trace/trace.hpp => modules/glaze/trace/trace.ixx (89%) rename include/glaze/tuplet/tuple.hpp => modules/glaze/tuplet/tuple.ixx (90%) rename include/glaze/util/atoi.hpp => modules/glaze/util/atoi.ixx (82%) rename include/glaze/util/bit.hpp => modules/glaze/util/bit.ixx (67%) rename include/glaze/util/bit_array.hpp => modules/glaze/util/bit_array.ixx (86%) rename {include => modules}/glaze/util/buffer_pool.hpp (90%) rename include/glaze/util/compare.hpp => modules/glaze/util/compare.ixx (80%) create mode 100644 modules/glaze/util/convert.ixx rename include/glaze/util/dragonbox.hpp => modules/glaze/util/dragonbox.ixx (99%) rename include/glaze/util/dtoa.hpp => modules/glaze/util/dtoa.ixx (69%) rename include/glaze/util/dump.hpp => modules/glaze/util/dump.ixx (77%) rename include/glaze/util/expected.hpp => modules/glaze/util/expected.ixx (61%) rename include/glaze/util/fast_float.hpp => modules/glaze/util/fast_float.ixx (85%) rename include/glaze/util/for_each.hpp => modules/glaze/util/for_each.ixx (91%) rename include/glaze/util/glaze_fast_float.hpp => modules/glaze/util/glaze_fast_float.ixx (91%) rename include/glaze/util/help.hpp => modules/glaze/util/help.ixx (79%) rename {include => modules}/glaze/util/inline.hpp (100%) rename include/glaze/util/itoa.hpp => modules/glaze/util/itoa.ixx (56%) rename include/glaze/util/itoa_40kb.hpp => modules/glaze/util/itoa_40kb.ixx (53%) rename {include => modules}/glaze/util/key_transformers.hpp (96%) rename {include => modules}/glaze/util/memory_pool.hpp (82%) rename {include => modules}/glaze/util/murmur.hpp (73%) rename include/glaze/util/parse.hpp => modules/glaze/util/parse.ixx (85%) rename include/glaze/util/primes_64.hpp => modules/glaze/util/primes_64.ixx (95%) rename {include => modules}/glaze/util/progress_bar.hpp (78%) rename include/glaze/util/simple_float.hpp => modules/glaze/util/simple_float.ixx (86%) rename include/glaze/util/string_literal.hpp => modules/glaze/util/string_literal.ixx (79%) rename include/glaze/util/tuple.hpp => modules/glaze/util/tuple.ixx (52%) rename include/glaze/util/type_traits.hpp => modules/glaze/util/type_traits.ixx (98%) rename include/glaze/util/utility.hpp => modules/glaze/util/utility.ixx (73%) rename include/glaze/util/validate.hpp => modules/glaze/util/validate.ixx (77%) rename include/glaze/util/variant.hpp => modules/glaze/util/variant.ixx (59%) rename include/glaze/version.hpp => modules/glaze/version.ixx (72%) rename {include => modules}/glaze/yaml.hpp (100%) rename {include => modules}/glaze/yaml/common.hpp (94%) rename {include => modules}/glaze/yaml/opts.hpp (71%) rename {include => modules}/glaze/yaml/read.hpp (97%) rename {include => modules}/glaze/yaml/skip.hpp (95%) rename {include => modules}/glaze/yaml/write.hpp (93%) create mode 100644 tests/json_test/json_test_shared_types.ixx diff --git a/.gitignore b/.gitignore index 1efe86f612..58575f9d6c 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,4 @@ pr_description.md /size_tests /tmp_benchmark /exterior +/vc140.pdb diff --git a/CMakeLists.txt b/CMakeLists.txt index fe08d246b1..5c96465017 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,6 @@ -cmake_minimum_required(VERSION 3.21) +cmake_minimum_required(VERSION 3.31) + +set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "451f2fe2-a8a2-47c3-bc32-94786d8fc91b") include(cmake/prelude.cmake) @@ -6,18 +8,29 @@ project( glaze VERSION 7.0.2 LANGUAGES CXX -) +) + +option(GLAZE_ENABLE_MODULES "Enable modules with import std" ON) # or GLAZE_GENERATE_HEADERS ?? + +if (GLAZE_ENABLE_MODULES) + set(CMAKE_CXX_MODULE_STD 1) +endif() include(cmake/project-is-top-level.cmake) include(cmake/variables.cmake) if (PROJECT_IS_TOP_LEVEL) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +endif() + +if(GLAZE_ENABLE_MODULES) + add_library(glaze_glaze STATIC) + set(GLAZE_LIB_TYPE PUBLIC) +else() + add_library(glaze_glaze INTERFACE) + set(GLAZE_LIB_TYPE INTERFACE) endif() - -add_library(glaze_glaze INTERFACE) -add_library(glaze::glaze ALIAS glaze_glaze) - +add_library(glaze::glaze ALIAS glaze_glaze) if (MSVC) string(REGEX MATCH "\/cl(.exe)?$" matched_cl ${CMAKE_CXX_COMPILER}) @@ -42,11 +55,14 @@ endif() set_property(TARGET ${PROJECT_NAME}_${PROJECT_NAME} PROPERTY EXPORT_NAME glaze) -target_compile_features(${PROJECT_NAME}_${PROJECT_NAME} INTERFACE cxx_std_23) +target_compile_features(glaze_glaze ${GLAZE_LIB_TYPE} cxx_std_23) target_include_directories( - ${PROJECT_NAME}_${PROJECT_NAME} ${warning_guard} - INTERFACE "$" -) + glaze_glaze ${warning_guard} + PUBLIC + "$" +) + +include(cmake/modules-files.cmake) if(NOT CMAKE_SKIP_INSTALL_RULES) include(cmake/install-rules.cmake) diff --git a/CMakePresets.json b/CMakePresets.json index 40415b6d58..17b67431d0 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,120 +1,152 @@ { - "version": 3, - "cmakeMinimumRequired": { - "major": 3, - "minor": 23, - "patch": 0 + "version": 3, + "cmakeMinimumRequired": { + "major": 3, + "minor": 23, + "patch": 0 + }, + "configurePresets": [ + { + "name": "clang-debug", + "displayName": "Clang Debug", + "description": "Debug build using Clang compiler", + "binaryDir": "${sourceDir}/build/debug", + "generator": "Ninja", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_C_COMPILER": "/usr/bin/clang", + "CMAKE_CXX_COMPILER": "/usr/bin/clang++", + "CMAKE_EXPORT_COMPILE_COMMANDS": true, + "glaze_DEVELOPER_MODE": true, + "BUILD_TESTING": true, + "glaze_BUILD_INTEROP": true, + "CMAKE_CXX_FLAGS": "-stdlib=libc++", + "CMAKE_EXE_LINKER_FLAGS": "-stdlib=libc++", + "CMAKE_SHARED_LINKER_FLAGS": "-stdlib=libc++", + "CMAKE_MODULE_LINKER_FLAGS": "-stdlib=libc++" + } }, - "configurePresets": [ - { - "name": "clang-debug", - "displayName": "Clang Debug", - "description": "Debug build using Clang compiler", - "binaryDir": "${sourceDir}/build/debug", - "generator": "Ninja", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_C_COMPILER": "/usr/bin/clang", - "CMAKE_CXX_COMPILER": "/usr/bin/clang++", - "CMAKE_EXPORT_COMPILE_COMMANDS": true, - "glaze_DEVELOPER_MODE": true, - "BUILD_TESTING": true, - "glaze_BUILD_INTEROP": true, - "CMAKE_CXX_FLAGS": "-stdlib=libc++", - "CMAKE_EXE_LINKER_FLAGS": "-stdlib=libc++", - "CMAKE_SHARED_LINKER_FLAGS": "-stdlib=libc++", - "CMAKE_MODULE_LINKER_FLAGS": "-stdlib=libc++" - } - }, - { - "name": "clang-release", - "displayName": "Clang Release", - "description": "Release build using Clang compiler", - "binaryDir": "${sourceDir}/build/release", - "generator": "Ninja", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release", - "CMAKE_C_COMPILER": "/usr/bin/clang", - "CMAKE_CXX_COMPILER": "/usr/bin/clang++", - "CMAKE_EXPORT_COMPILE_COMMANDS": true, - "glaze_DEVELOPER_MODE": true, - "BUILD_TESTING": true, - "glaze_BUILD_INTEROP": true, - "CMAKE_CXX_FLAGS": "-stdlib=libc++", - "CMAKE_EXE_LINKER_FLAGS": "-stdlib=libc++", - "CMAKE_SHARED_LINKER_FLAGS": "-stdlib=libc++", - "CMAKE_MODULE_LINKER_FLAGS": "-stdlib=libc++" - } - }, - { - "name": "gcc-debug", - "displayName": "GCC Debug", - "description": "Debug build using GCC compiler", - "binaryDir": "${sourceDir}/build/debug-gcc", - "generator": "Ninja", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_C_COMPILER": "/usr/bin/gcc", - "CMAKE_CXX_COMPILER": "/usr/bin/g++", - "CMAKE_EXPORT_COMPILE_COMMANDS": true, - "glaze_DEVELOPER_MODE": true, - "BUILD_TESTING": true, - "glaze_BUILD_INTEROP": true - } - }, - { - "name": "gcc-release", - "displayName": "GCC Release", - "description": "Release build using GCC compiler", - "binaryDir": "${sourceDir}/build/release-gcc", - "generator": "Ninja", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release", - "CMAKE_C_COMPILER": "/usr/bin/gcc", - "CMAKE_CXX_COMPILER": "/usr/bin/g++", - "CMAKE_EXPORT_COMPILE_COMMANDS": true, - "glaze_DEVELOPER_MODE": true, - "BUILD_TESTING": true, - "glaze_BUILD_INTEROP": true - } - } - ], - "buildPresets": [ - { - "name": "clang-debug", - "configurePreset": "clang-debug" - }, - { - "name": "clang-release", - "configurePreset": "clang-release" - }, - { - "name": "gcc-debug", - "configurePreset": "gcc-debug" - }, - { - "name": "gcc-release", - "configurePreset": "gcc-release" - } - ], - "testPresets": [ - { - "name": "clang-debug", - "displayName": "Test Clang Debug", - "configurePreset": "clang-debug", - "output": { - "verbosity": "verbose", - "outputOnFailure": true - } - }, - { - "name": "gcc-debug", - "displayName": "Test GCC Debug", - "configurePreset": "gcc-debug", - "output": { - "verbosity": "verbose", - "outputOnFailure": true - } - } - ] + { + "name": "clang-release", + "displayName": "Clang Release", + "description": "Release build using Clang compiler", + "binaryDir": "${sourceDir}/build/release", + "generator": "Ninja", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "CMAKE_C_COMPILER": "/usr/bin/clang", + "CMAKE_CXX_COMPILER": "/usr/bin/clang++", + "CMAKE_EXPORT_COMPILE_COMMANDS": true, + "glaze_DEVELOPER_MODE": true, + "BUILD_TESTING": true, + "glaze_BUILD_INTEROP": true, + "CMAKE_CXX_FLAGS": "-stdlib=libc++", + "CMAKE_EXE_LINKER_FLAGS": "-stdlib=libc++", + "CMAKE_SHARED_LINKER_FLAGS": "-stdlib=libc++", + "CMAKE_MODULE_LINKER_FLAGS": "-stdlib=libc++" + } + }, + { + "name": "gcc-debug", + "displayName": "GCC Debug", + "description": "Debug build using GCC compiler", + "binaryDir": "${sourceDir}/build/debug-gcc", + "generator": "Ninja", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_C_COMPILER": "/usr/bin/gcc", + "CMAKE_CXX_COMPILER": "/usr/bin/g++", + "CMAKE_EXPORT_COMPILE_COMMANDS": true, + "glaze_DEVELOPER_MODE": true, + "BUILD_TESTING": true, + "glaze_BUILD_INTEROP": true + } + }, + { + "name": "gcc-release", + "displayName": "GCC Release", + "description": "Release build using GCC compiler", + "binaryDir": "${sourceDir}/build/release-gcc", + "generator": "Ninja", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "CMAKE_C_COMPILER": "/usr/bin/gcc", + "CMAKE_CXX_COMPILER": "/usr/bin/g++", + "CMAKE_EXPORT_COMPILE_COMMANDS": true, + "glaze_DEVELOPER_MODE": true, + "BUILD_TESTING": true, + "glaze_BUILD_INTEROP": true + } + }, + { + "name": "windows-base", + "description": "Base preset for MSVC v14.51", + "hidden": true, + "generator": "Ninja", + "binaryDir": "${sourceDir}/out/build/${presetName}", + "installDir": "${sourceDir}/out/install/${presetName}", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + }, + "toolset": { + "value": "v145,host=x64,version=14.51" + } + }, + { + "name": "x64", + "displayName": "x64 Debug (MSVC v14.51 Preview)", + "inherits": "windows-base", + "architecture": { + "value": "x64", + "strategy": "external" + } + } + ], + "buildPresets": [ + { + "name": "clang-debug", + "configurePreset": "clang-debug" + }, + { + "name": "clang-release", + "configurePreset": "clang-release" + }, + { + "name": "gcc-debug", + "configurePreset": "gcc-debug" + }, + { + "name": "gcc-release", + "configurePreset": "gcc-release" + }, + { + "name": "x64-build", + "configurePreset": "x64", + "targets": [ + "json_test" + ] + } + ], + "testPresets": [ + { + "name": "clang-debug", + "displayName": "Test Clang Debug", + "configurePreset": "clang-debug", + "output": { + "verbosity": "verbose", + "outputOnFailure": true + } + }, + { + "name": "gcc-debug", + "displayName": "Test GCC Debug", + "configurePreset": "gcc-debug", + "output": { + "verbosity": "verbose", + "outputOnFailure": true + } + } + ] } diff --git a/README.md b/README.md index a74b01d9f7..0401b4c084 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ struct my_struct int i = 287; double d = 3.14; std::string hello = "Hello World"; - std::array arr = { 1, 2, 3 }; + std::array arr = { 1, 2, 3 }; std::map map{{"one", 1}, {"two", 2}}; }; ``` @@ -361,7 +361,7 @@ struct my_struct int i = 287; double d = 3.14; std::string hello = "Hello World"; - std::array arr = { 1, 2, 3 }; + std::array arr = { 1, 2, 3 }; std::map map{{"one", 1}, {"two", 2}}; struct glaze { @@ -416,7 +416,7 @@ struct server_status { std::string name; std::string region; - uint64_t active_sessions{}; + std::uint64_t active_sessions{}; std::optional maintenance; double cpu_percent{}; }; @@ -475,7 +475,7 @@ static_assert(glz::reflect::keys[0] == "i"); // Access keys ```c++ struct test_type { - int32_t int1{}; + std::int32_t int1{}; int64_t int2{}; }; @@ -500,15 +500,15 @@ For common use cases or cases where a specific member variable should have speci ```c++ struct custom_encoding { - uint64_t x{}; + std::uint64_t x{}; std::string y{}; - std::array z{}; + std::array z{}; void read_x(const std::string& s) { x = std::stoi(s); } - uint64_t write_x() { + std::uint64_t write_x() { return x; } @@ -538,7 +538,7 @@ suite custom_encoding_test = [] { expect(!glz::read_json(obj, s)); expect(obj.x == 3); expect(obj.y == "helloworld"); - expect(obj.z == std::array{1, 2, 3}); + expect(obj.z == std::array{1, 2, 3}); }; "custom_writing"_test = [] { @@ -802,7 +802,7 @@ my_struct obj{}; auto ec = glz::read_json(obj, buffer); if (!ec) { // Success: ec.count contains bytes consumed - size_t bytes_consumed = ec.count; + std::size_t bytes_consumed = ec.count; // bytes_consumed == 13 (entire JSON object) } ``` @@ -1241,7 +1241,7 @@ You can parse quoted JSON numbers directly to types like `double`, `int`, etc. b ```c++ struct A { double x; - std::vector y; + std::vector y; }; template <> @@ -1257,7 +1257,7 @@ struct glz::meta { } ``` -The quoted JSON numbers will be parsed directly into the `double` and `std::vector`. The `glz::quoted` function works for nested objects and arrays as well. +The quoted JSON numbers will be parsed directly into the `double` and `std::vector`. The `glz::quoted` function works for nested objects and arrays as well. ## JSON Lines (NDJSON) Support diff --git a/benchmarks/lazy_benchmark.cpp b/benchmarks/lazy_benchmark.cpp index 0b9f1fa7ef..dd897b860e 100644 --- a/benchmarks/lazy_benchmark.cpp +++ b/benchmarks/lazy_benchmark.cpp @@ -53,10 +53,10 @@ inline const std::string array_json = R"({ })"; // Generate a larger JSON for throughput testing -inline std::string generate_large_json(size_t count) +inline std::string generate_large_json(std::size_t count) { std::string json = R"({"users":[)"; - for (size_t i = 0; i < count; ++i) { + for (std::size_t i = 0; i < count; ++i) { if (i > 0) json += ","; json += R"({"id":)"; json += std::to_string(i); @@ -79,10 +79,10 @@ inline std::string generate_large_json(size_t count) } // Generate JSON with whitespace (pretty-printed style) -inline std::string generate_large_json_with_whitespace(size_t count) +inline std::string generate_large_json_with_whitespace(std::size_t count) { std::string json = "{\n \"users\": [\n"; - for (size_t i = 0; i < count; ++i) { + for (std::size_t i = 0; i < count; ++i) { if (i > 0) json += ",\n"; json += " { \"id\": "; json += std::to_string(i); @@ -423,7 +423,7 @@ int main() auto result = glz::lazy_json(large_json); auto users = (*result)["users"]; int64_t sum = 0; - size_t count = 0; + std::size_t count = 0; for (auto& user : users) { BenchUser u{}; // raw_json() scans to find value end, then read_json parses again @@ -441,7 +441,7 @@ int main() auto result = glz::lazy_json(large_json); auto users = (*result)["users"]; int64_t sum = 0; - size_t count = 0; + std::size_t count = 0; for (auto& user : users) { BenchUser u{}; // read_into directly parses from value start to doc end - no pre-scan diff --git a/benchmarks/simple_float_benchmark.cpp b/benchmarks/simple_float_benchmark.cpp index 10770fcd28..4df772f577 100644 --- a/benchmarks/simple_float_benchmark.cpp +++ b/benchmarks/simple_float_benchmark.cpp @@ -9,16 +9,16 @@ #include "glaze/util/simple_float.hpp" // Generate test data -std::vector generate_random_floats(size_t count, uint32_t seed = 12345) +std::vector generate_random_floats(std::size_t count, std::uint32_t seed = 12345) { std::mt19937 rng(seed); - std::uniform_int_distribution dist; + std::uniform_int_distribution dist; std::vector result; result.reserve(count); - for (size_t i = 0; i < count; ++i) { - uint32_t bits = dist(rng); + for (std::size_t i = 0; i < count; ++i) { + std::uint32_t bits = dist(rng); float value; std::memcpy(&value, &bits, sizeof(float)); @@ -33,16 +33,16 @@ std::vector generate_random_floats(size_t count, uint32_t seed = 12345) return result; } -std::vector generate_random_doubles(size_t count, uint32_t seed = 12345) +std::vector generate_random_doubles(std::size_t count, std::uint32_t seed = 12345) { std::mt19937_64 rng(seed); - std::uniform_int_distribution dist; + std::uniform_int_distribution dist; std::vector result; result.reserve(count); - for (size_t i = 0; i < count; ++i) { - uint64_t bits = dist(rng); + for (std::size_t i = 0; i < count; ++i) { + std::uint64_t bits = dist(rng); double value; std::memcpy(&value, &bits, sizeof(double)); @@ -82,7 +82,7 @@ std::vector serialize_doubles(const std::vector& doubles) int main() { - constexpr size_t N = 100000; + constexpr std::size_t N = 100000; // Pre-generate test data auto floats = generate_random_floats(N); @@ -97,7 +97,7 @@ int main() stage.run("simple_float::to_chars (float)", [&] { char buf[32]; - size_t total_bytes = 0; + std::size_t total_bytes = 0; for (float f : floats) { char* end = glz::simple_float::to_chars(buf, f); total_bytes += (end - buf); @@ -108,7 +108,7 @@ int main() stage.run("std::to_chars (float)", [&] { char buf[32]; - size_t total_bytes = 0; + std::size_t total_bytes = 0; for (float f : floats) { auto [ptr, ec] = std::to_chars(buf, buf + 32, f); total_bytes += (ptr - buf); @@ -127,7 +127,7 @@ int main() stage.run("simple_float::from_chars (float)", [&] { float value; - size_t total_bytes = 0; + std::size_t total_bytes = 0; for (const auto& s : float_strings) { glz::simple_float::from_chars(s.data(), s.data() + s.size(), value); total_bytes += s.size(); @@ -138,7 +138,7 @@ int main() stage.run("glz::from_chars/fast_float (float)", [&] { float value; - size_t total_bytes = 0; + std::size_t total_bytes = 0; for (const auto& s : float_strings) { glz::from_chars(s.data(), s.data() + s.size(), value); total_bytes += s.size(); @@ -149,7 +149,7 @@ int main() stage.run("std::from_chars (float)", [&] { float value; - size_t total_bytes = 0; + std::size_t total_bytes = 0; for (const auto& s : float_strings) { std::from_chars(s.data(), s.data() + s.size(), value); total_bytes += s.size(); @@ -168,7 +168,7 @@ int main() stage.run("simple_float::to_chars (double)", [&] { char buf[32]; - size_t total_bytes = 0; + std::size_t total_bytes = 0; for (double d : doubles) { char* end = glz::simple_float::to_chars(buf, d); total_bytes += (end - buf); @@ -179,7 +179,7 @@ int main() stage.run("std::to_chars (double)", [&] { char buf[32]; - size_t total_bytes = 0; + std::size_t total_bytes = 0; for (double d : doubles) { auto [ptr, ec] = std::to_chars(buf, buf + 32, d); total_bytes += (ptr - buf); @@ -198,7 +198,7 @@ int main() stage.run("simple_float::from_chars (double)", [&] { double value; - size_t total_bytes = 0; + std::size_t total_bytes = 0; for (const auto& s : double_strings) { glz::simple_float::from_chars(s.data(), s.data() + s.size(), value); total_bytes += s.size(); @@ -209,7 +209,7 @@ int main() stage.run("glz::from_chars/fast_float (double)", [&] { double value; - size_t total_bytes = 0; + std::size_t total_bytes = 0; for (const auto& s : double_strings) { glz::from_chars(s.data(), s.data() + s.size(), value); total_bytes += s.size(); @@ -220,7 +220,7 @@ int main() stage.run("std::from_chars (double)", [&] { double value; - size_t total_bytes = 0; + std::size_t total_bytes = 0; for (const auto& s : double_strings) { std::from_chars(s.data(), s.data() + s.size(), value); total_bytes += s.size(); @@ -240,7 +240,7 @@ int main() // Just decimal parsing stage.run("parse_decimal_strict only", [&] { - size_t total = 0; + std::size_t total = 0; for (const auto& s : float_strings) { glz::simple_float::detail::decimal_number dec{}; const char* end = @@ -253,7 +253,7 @@ int main() // Full parsing stage.run("full from_chars", [&] { - size_t total = 0; + std::size_t total = 0; float value; for (const auto& s : float_strings) { auto [ptr, ec] = glz::simple_float::from_chars(s.data(), s.data() + s.size(), value); diff --git a/benchmarks/skip_ws_benchmark.cpp b/benchmarks/skip_ws_benchmark.cpp index 037c5b0b39..43e8dfeaa2 100644 --- a/benchmarks/skip_ws_benchmark.cpp +++ b/benchmarks/skip_ws_benchmark.cpp @@ -50,10 +50,10 @@ namespace scalar // ============================================================================ namespace matching { - BENCH_ALWAYS_INLINE void skip_matching_ws(const char* ws, const char*& it, uint64_t length) noexcept + BENCH_ALWAYS_INLINE void skip_matching_ws(const char* ws, const char*& it, std::uint64_t length) noexcept { if (length > 7) { - uint64_t v[2]; + std::uint64_t v[2]; while (length > 8) { std::memcpy(v, ws, 8); std::memcpy(v + 1, it, 8); @@ -78,9 +78,9 @@ namespace matching return; } { - constexpr uint64_t n{sizeof(uint32_t)}; + constexpr std::uint64_t n{sizeof(std::uint32_t)}; if (length >= n) { - uint32_t v[2]; + std::uint32_t v[2]; std::memcpy(v, ws, n); std::memcpy(v + 1, it, n); if (v[0] != v[1]) { @@ -92,7 +92,7 @@ namespace matching } } { - constexpr uint64_t n{sizeof(uint16_t)}; + constexpr std::uint64_t n{sizeof(uint16_t)}; if (length >= n) { uint16_t v[2]; std::memcpy(v, ws, n); @@ -111,9 +111,9 @@ namespace matching // ============================================================================ namespace combined { - BENCH_ALWAYS_INLINE void skip(const char* ws_pattern, const char*& it, const char* end, size_t ws_size) noexcept + BENCH_ALWAYS_INLINE void skip(const char* ws_pattern, const char*& it, const char* end, std::size_t ws_size) noexcept { - if (ws_size && ws_size < size_t(end - it)) { + if (ws_size && ws_size < std::size_t(end - it)) { matching::skip_matching_ws(ws_pattern, it, ws_size); } scalar::skip_ws(it); @@ -125,12 +125,12 @@ namespace combined // ============================================================================ // Build a buffer of repeated [ws + delimiter] tokens -static std::string build_repeated(const std::string& ws, char delim, size_t count) +static std::string build_repeated(const std::string& ws, char delim, std::size_t count) { std::string buf; - const size_t token_size = ws.size() + 1; + const std::size_t token_size = ws.size() + 1; buf.reserve(token_size * count); - for (size_t i = 0; i < count; ++i) { + for (std::size_t i = 0; i < count; ++i) { buf += ws; buf += delim; } @@ -138,12 +138,12 @@ static std::string build_repeated(const std::string& ws, char delim, size_t coun } // Verify both approaches produce identical results on a buffer -static bool verify_correctness(const std::string& buf, const char* ws_pattern, size_t ws_size, const char* test_name) +static bool verify_correctness(const std::string& buf, const char* ws_pattern, std::size_t ws_size, const char* test_name) { // Scalar-only const char* it_a = buf.data(); const char* end = buf.data() + buf.size(); - size_t skips_a = 0; + std::size_t skips_a = 0; while (it_a < end) { scalar::skip_ws(it_a); if (it_a < end) ++it_a; @@ -152,7 +152,7 @@ static bool verify_correctness(const std::string& buf, const char* ws_pattern, s // Combined (matching + scalar) const char* it_b = buf.data(); - size_t skips_b = 0; + std::size_t skips_b = 0; while (it_b < end) { combined::skip(ws_pattern, it_b, end, ws_size); if (it_b < end) ++it_b; @@ -172,9 +172,9 @@ static bool verify_correctness(const std::string& buf, const char* ws_pattern, s // Benchmark runner // ============================================================================ -static void bench_fixed_pattern(const char* name, const std::string& ws, size_t count) +static void bench_fixed_pattern(const char* name, const std::string& ws, std::size_t count) { - const size_t ws_size = ws.size(); + const std::size_t ws_size = ws.size(); const std::string buf = build_repeated(ws, '{', count); // Verify correctness first @@ -213,7 +213,7 @@ static void bench_fixed_pattern(const char* name, const std::string& ws, size_t int main() { - constexpr size_t N = 500000; + constexpr std::size_t N = 500000; // ======================================================================== // Part 1: Fixed-size patterns (best case for skip_matching_ws — always matches) @@ -254,7 +254,7 @@ int main() std::string buf; buf.reserve((ws_a.size() + 1 + ws_b.size() + 1) * (N / 2)); - for (size_t i = 0; i < N / 2; ++i) { + for (std::size_t i = 0; i < N / 2; ++i) { buf += ws_a; buf += '{'; buf += ws_b; @@ -284,7 +284,7 @@ int main() const char* it = buf.data(); const char* end = buf.data() + buf.size(); const char* ws_ptr = ws_a.data(); - size_t ws_size = ws_a.size(); + std::size_t ws_size = ws_a.size(); while (it < end) { combined::skip(ws_ptr, it, end, ws_size); if (it < end) ++it; @@ -303,7 +303,7 @@ int main() std::string buf; buf.reserve((ws_a.size() + 1 + ws_b.size() + 1) * (N / 2)); - for (size_t i = 0; i < N / 2; ++i) { + for (std::size_t i = 0; i < N / 2; ++i) { buf += ws_a; buf += '{'; buf += ws_b; @@ -332,7 +332,7 @@ int main() const char* it = buf.data(); const char* end = buf.data() + buf.size(); const char* ws_ptr = ws_a.data(); - size_t ws_size = ws_a.size(); + std::size_t ws_size = ws_a.size(); while (it < end) { combined::skip(ws_ptr, it, end, ws_size); if (it < end) ++it; @@ -358,8 +358,8 @@ int main() std::string buf; buf.reserve(N * 6); // rough estimate - for (size_t i = 0; i < N; ++i) { - size_t mod = i % 10; + for (std::size_t i = 0; i < N; ++i) { + std::size_t mod = i % 10; if (mod < 8) { buf += ws_primary; } @@ -376,7 +376,7 @@ int main() std::abort(); } - size_t total_ws = buf.size() - N; // total ws bytes (buf minus N delimiters) + std::size_t total_ws = buf.size() - N; // total ws bytes (buf minus N delimiters) bencher::stage stage; stage.name = "Realistic nesting: 80% \\n+4sp, 10% \\n+6sp, 10% \\n+2sp"; @@ -396,7 +396,7 @@ int main() const char* it = buf.data(); const char* end = buf.data() + buf.size(); const char* ws_ptr = ws_primary.data(); - size_t ws_size = ws_primary.size(); + std::size_t ws_size = ws_primary.size(); while (it < end) { combined::skip(ws_ptr, it, end, ws_size); if (it < end) ++it; @@ -443,16 +443,16 @@ int main() // Extract whitespace gaps: sequences of ws chars between non-ws chars struct ws_gap { - size_t offset; - size_t length; + std::size_t offset; + std::size_t length; }; std::vector gaps; - size_t total_ws = 0; + std::size_t total_ws = 0; { - size_t i = 0; + std::size_t i = 0; while (i < json.size()) { if (scalar::whitespace_table[uint8_t(json[i])]) { - size_t start = i; + std::size_t start = i; while (i < json.size() && scalar::whitespace_table[uint8_t(json[i])]) { ++i; } @@ -469,13 +469,13 @@ int main() total_ws); // Print gap size distribution - std::array size_dist{}; + std::array size_dist{}; for (const auto& g : gaps) { - size_t bucket = g.length < 32 ? g.length : 31; + std::size_t bucket = g.length < 32 ? g.length : 31; ++size_dist[bucket]; } std::printf("Gap size distribution:\n"); - for (size_t s = 1; s < 32; ++s) { + for (std::size_t s = 1; s < 32; ++s) { if (size_dist[s] > 0) { std::printf(" %2zu bytes: %zu gaps\n", s, size_dist[s]); } @@ -490,7 +490,7 @@ int main() struct pattern_count { std::string pat; - size_t count; + std::size_t count; }; std::vector pats; for (const auto& g : gaps) { @@ -506,8 +506,8 @@ int main() if (!found) pats.push_back({p, 1}); } // Find most frequent - size_t best = 0; - for (size_t i = 1; i < pats.size(); ++i) { + std::size_t best = 0; + for (std::size_t i = 1; i < pats.size(); ++i) { if (pats[i].count > pats[best].count) best = i; } most_common_ws = pats[best].pat; @@ -517,10 +517,10 @@ int main() // Benchmark: iterate through the actual JSON, skipping ws gaps // Repeat the JSON multiple times for stable timing - constexpr size_t repeats = 100; + constexpr std::size_t repeats = 100; std::string big_json; big_json.reserve(json.size() * repeats); - for (size_t r = 0; r < repeats; ++r) { + for (std::size_t r = 0; r < repeats; ++r) { big_json += json; } @@ -530,11 +530,11 @@ int main() stage.run("scalar skip_ws only", [&] { const char* it = big_json.data(); const char* end = big_json.data() + big_json.size(); - size_t ws_bytes = 0; + std::size_t ws_bytes = 0; while (it < end) { const char* before = it; scalar::skip_ws(it); - ws_bytes += size_t(it - before); + ws_bytes += std::size_t(it - before); if (it < end) ++it; // advance past non-ws char } bencher::do_not_optimize(it); @@ -545,12 +545,12 @@ int main() const char* it = big_json.data(); const char* end = big_json.data() + big_json.size(); const char* ws_ptr = most_common_ws.data(); - size_t ws_size = most_common_ws.size(); - size_t ws_bytes = 0; + std::size_t ws_size = most_common_ws.size(); + std::size_t ws_bytes = 0; while (it < end) { const char* before = it; combined::skip(ws_ptr, it, end, ws_size); - ws_bytes += size_t(it - before); + ws_bytes += std::size_t(it - before); if (it < end) ++it; } bencher::do_not_optimize(it); @@ -568,15 +568,15 @@ int main() std::printf("\n=== Part 5: Contiguous whitespace throughput ===\n\n"); { - size_t sizes[] = {16, 64, 256, 1024, 4096}; - for (size_t sz : sizes) { + std::size_t sizes[] = {16, 64, 256, 1024, 4096}; + for (std::size_t sz : sizes) { // All spaces followed by a terminator std::string ws(sz, ' '); ws += 'x'; // For matching: record first 8 bytes (or fewer) as the pattern // In reality the pattern would be the first line's indent - std::string pattern(std::min(sz, size_t(8)), ' '); + std::string pattern(std::min(sz, std::size_t(8)), ' '); char label[64]; std::snprintf(label, sizeof(label), "Contiguous spaces (%zu B)", sz); diff --git a/benchmarks/string_write_benchmark.cpp b/benchmarks/string_write_benchmark.cpp index a8f3b01f5d..eae01c06ee 100644 --- a/benchmarks/string_write_benchmark.cpp +++ b/benchmarks/string_write_benchmark.cpp @@ -19,26 +19,26 @@ // ============================================================================ // Pure ASCII lowercase, no escaping needed -static std::string gen_ascii(size_t len, uint64_t seed = 42) +static std::string gen_ascii(std::size_t len, std::uint64_t seed = 42) { std::mt19937 rng(seed); std::uniform_int_distribution dist('a', 'z'); std::string s; s.reserve(len); - for (size_t i = 0; i < len; ++i) { + for (std::size_t i = 0; i < len; ++i) { s += static_cast(dist(rng)); } return s; } // ASCII with ~15% characters that need escaping -static std::string gen_escaped(size_t len, uint64_t seed = 42) +static std::string gen_escaped(std::size_t len, std::uint64_t seed = 42) { std::mt19937 rng(seed); std::uniform_int_distribution dist(0, 99); std::string s; s.reserve(len); - for (size_t i = 0; i < len; ++i) { + for (std::size_t i = 0; i < len; ++i) { int r = dist(rng); if (r < 5) s += '"'; @@ -55,7 +55,7 @@ static std::string gen_escaped(size_t len, uint64_t seed = 42) } // UTF-8 multibyte strings (2-4 byte sequences, no escaping needed) -static std::string gen_utf8(size_t approx_len, uint64_t seed = 42) +static std::string gen_utf8(std::size_t approx_len, std::uint64_t seed = 42) { std::mt19937 rng(seed); std::uniform_int_distribution dist(0, 3); @@ -102,35 +102,35 @@ static std::string gen_all_control_chars() } // Edge case: string with byte 0x1F (unit separator) — boundary of control char range -static std::string gen_boundary_0x1f(size_t len) +static std::string gen_boundary_0x1f(std::size_t len) { std::string s(len, 'x'); // Place 0x1F at various positions - for (size_t i = 0; i < len; i += 7) { + for (std::size_t i = 0; i < len; i += 7) { s[i] = 0x1F; } return s; } // Edge case: string with bytes at 0x20 boundary (0x1F and 0x20 alternating) -static std::string gen_boundary_alternating(size_t len) +static std::string gen_boundary_alternating(std::size_t len) { std::string s; s.reserve(len); - for (size_t i = 0; i < len; ++i) { + for (std::size_t i = 0; i < len; ++i) { s += (i % 2 == 0) ? char(0x1F) : char(0x20); } return s; } // High bytes (0x80-0xFF) — should NOT be escaped -static std::string gen_high_bytes(size_t len, uint64_t seed = 42) +static std::string gen_high_bytes(std::size_t len, std::uint64_t seed = 42) { std::mt19937 rng(seed); std::uniform_int_distribution dist(0x80, 0xFF); std::string s; s.reserve(len); - for (size_t i = 0; i < len; ++i) { + for (std::size_t i = 0; i < len; ++i) { s += static_cast(dist(rng)); } return s; @@ -162,7 +162,7 @@ static void verify(const char* name, const std::string& input) simd_result.size() > 200 ? "..." : ""); // Find first difference - for (size_t i = 0; i < std::min(swar_result.size(), simd_result.size()); ++i) { + for (std::size_t i = 0; i < std::min(swar_result.size(), simd_result.size()); ++i) { if (swar_result[i] != simd_result[i]) { std::fprintf(stderr, " First diff at byte %zu: SWAR=0x%02X SIMD=0x%02X\n", i, (unsigned char)swar_result[i], (unsigned char)simd_result[i]); @@ -199,21 +199,21 @@ static void run_correctness_checks() verify("single 0xFF", std::string(1, '\xFF')); // Pure ASCII, various sizes (tests SWAR, SSE2/NEON, AVX2 paths) - for (size_t len : {1, 2, 3, 7, 8, 9, 15, 16, 17, 31, 32, 33, 63, 64, 100, 255, 256, 1000, 4096, 16384}) { + for (std::size_t len : {1, 2, 3, 7, 8, 9, 15, 16, 17, 31, 32, 33, 63, 64, 100, 255, 256, 1000, 4096, 16384}) { char label[64]; std::snprintf(label, sizeof(label), "ASCII %zu", len); verify(label, gen_ascii(len)); } // Escaped strings, various sizes - for (size_t len : {1, 7, 8, 15, 16, 31, 32, 64, 256, 1000, 4096}) { + for (std::size_t len : {1, 7, 8, 15, 16, 31, 32, 64, 256, 1000, 4096}) { char label[64]; std::snprintf(label, sizeof(label), "escaped %zu", len); verify(label, gen_escaped(len)); } // UTF-8 multibyte (bytes >= 0x80 must NOT be escaped) - for (size_t len : {16, 64, 256, 1024, 4096}) { + for (std::size_t len : {16, 64, 256, 1024, 4096}) { char label[64]; std::snprintf(label, sizeof(label), "utf8 %zu", len); verify(label, gen_utf8(len)); @@ -223,30 +223,30 @@ static void run_correctness_checks() verify("all_control_chars", gen_all_control_chars()); // Boundary 0x1F at various positions - for (size_t len : {7, 8, 15, 16, 31, 32, 64, 256}) { + for (std::size_t len : {7, 8, 15, 16, 31, 32, 64, 256}) { char label[64]; std::snprintf(label, sizeof(label), "boundary_0x1F %zu", len); verify(label, gen_boundary_0x1f(len)); } // Alternating 0x1F/0x20 - for (size_t len : {8, 16, 32, 64, 256}) { + for (std::size_t len : {8, 16, 32, 64, 256}) { char label[64]; std::snprintf(label, sizeof(label), "alternating_0x1F_0x20 %zu", len); verify(label, gen_boundary_alternating(len)); } // High bytes (0x80-0xFF) — must NOT be escaped - for (size_t len : {8, 16, 32, 64, 256, 1024}) { + for (std::size_t len : {8, 16, 32, 64, 256, 1024}) { char label[64]; std::snprintf(label, sizeof(label), "high_bytes %zu", len); verify(label, gen_high_bytes(len)); } // String with escapes at exact SIMD boundary positions - for (size_t boundary : {8, 16, 32}) { + for (std::size_t boundary : {8, 16, 32}) { for (int offset = -1; offset <= 1; ++offset) { - size_t pos = boundary + offset; + std::size_t pos = boundary + offset; if (pos == 0) continue; std::string s(pos + 10, 'a'); s[pos] = '"'; // Place escapable char at boundary @@ -332,7 +332,7 @@ int main() // --- Pure ASCII (no escaping) --- std::printf("=== Pure ASCII (no escaping needed) ===\n\n"); - for (size_t len : {16, 64, 256, 1024, 4096, 16384}) { + for (std::size_t len : {16, 64, 256, 1024, 4096, 16384}) { char label[128]; std::snprintf(label, sizeof(label), "ASCII %zu bytes", len); bench_string(label, gen_ascii(len)); @@ -340,7 +340,7 @@ int main() // --- ASCII with ~15% escapable characters --- std::printf("\n=== ~15%% escapable characters ===\n\n"); - for (size_t len : {16, 64, 256, 1024, 4096, 16384}) { + for (std::size_t len : {16, 64, 256, 1024, 4096, 16384}) { char label[128]; std::snprintf(label, sizeof(label), "Escaped %zu bytes", len); bench_string(label, gen_escaped(len)); @@ -348,7 +348,7 @@ int main() // --- UTF-8 multibyte (no escaping needed, but high bytes) --- std::printf("\n=== UTF-8 multibyte (no escaping, bytes >= 0x80) ===\n\n"); - for (size_t len : {64, 256, 1024, 4096}) { + for (std::size_t len : {64, 256, 1024, 4096}) { char label[128]; std::snprintf(label, sizeof(label), "UTF-8 ~%zu bytes", len); bench_string(label, gen_utf8(len)); @@ -356,7 +356,7 @@ int main() // --- High bytes only (0x80-0xFF, no escaping) --- std::printf("\n=== High bytes only (0x80-0xFF, no escaping) ===\n\n"); - for (size_t len : {64, 256, 1024, 4096}) { + for (std::size_t len : {64, 256, 1024, 4096}) { char label[128]; std::snprintf(label, sizeof(label), "High bytes %zu", len); bench_string(label, gen_high_bytes(len)); @@ -368,14 +368,14 @@ int main() // --- Boundary cases --- std::printf("\n=== Boundary 0x1F (every 7th byte) ===\n\n"); - for (size_t len : {64, 256, 1024}) { + for (std::size_t len : {64, 256, 1024}) { char label[128]; std::snprintf(label, sizeof(label), "0x1F boundary %zu bytes", len); bench_string(label, gen_boundary_0x1f(len)); } std::printf("\n=== Alternating 0x1F/0x20 ===\n\n"); - for (size_t len : {64, 256, 1024}) { + for (std::size_t len : {64, 256, 1024}) { char label[128]; std::snprintf(label, sizeof(label), "Alt 0x1F/0x20 %zu bytes", len); bench_string(label, gen_boundary_alternating(len)); diff --git a/cmake/install-rules.cmake b/cmake/install-rules.cmake index 2e007a2434..96fd572a31 100644 --- a/cmake/install-rules.cmake +++ b/cmake/install-rules.cmake @@ -1,6 +1,8 @@ # Project is configured with no languages, so tell GNUInstallDirs the lib dir set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "") +set(CMAKE_INSTALL_INCLUDEDIR "modules" CACHE PATH "") + include(CMakePackageConfigHelpers) include(GNUInstallDirs) @@ -16,7 +18,9 @@ install( install( TARGETS glaze_glaze EXPORT glazeTargets + FILE_SET CXX_MODULES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + COMPONENT glaze_Development ) write_basic_package_version_file( diff --git a/cmake/modules-files.cmake b/cmake/modules-files.cmake new file mode 100644 index 0000000000..a468165c31 --- /dev/null +++ b/cmake/modules-files.cmake @@ -0,0 +1,272 @@ +# Top-level +target_sources(glaze_glaze + PUBLIC + FILE_SET CXX_MODULES + FILES + modules/glaze/glaze.ixx + modules/glaze/json.ixx + modules/glaze/cbor.ixx + modules/glaze/csv.ixx + modules/glaze/version.ixx +) + +# core +target_sources(glaze_glaze + PUBLIC + FILE_SET CXX_MODULES + FILES + modules/glaze/core/array_apply.ixx + modules/glaze/core/as_array_wrapper.ixx + modules/glaze/core/buffer_traits.ixx + modules/glaze/core/cast.ixx + modules/glaze/core/chrono.ixx + modules/glaze/core/common.ixx + modules/glaze/core/constraint.ixx + modules/glaze/core/context.ixx + modules/glaze/core/convert_struct.ixx + modules/glaze/core/custom.ixx + modules/glaze/core/custom_meta.ixx + modules/glaze/core/error_category.ixx + modules/glaze/core/istream_buffer.ixx + modules/glaze/core/manage.ixx + modules/glaze/core/meta.ixx + modules/glaze/core/meta_fwd.ixx + modules/glaze/core/optimization_level.ixx + modules/glaze/core/opts.ixx + modules/glaze/core/ostream_buffer.ixx + modules/glaze/core/ptr.ixx + modules/glaze/core/read.ixx + modules/glaze/core/reflect.ixx + modules/glaze/core/seek.ixx + modules/glaze/core/std_error_code.ixx + modules/glaze/core/streaming_state.ixx + modules/glaze/core/to.ixx + modules/glaze/core/wrappers.ixx + modules/glaze/core/wrapper_traits.ixx + modules/glaze/core/write.ixx + modules/glaze/core/write_chars.ixx +) + +# json +target_sources(glaze_glaze + PUBLIC + FILE_SET CXX_MODULES + FILES + modules/glaze/json/escape_unicode.ixx + modules/glaze/json/float_format.ixx + modules/glaze/json/generic.ixx + modules/glaze/json/invoke.ixx + modules/glaze/json/jmespath.ixx + modules/glaze/json/json_concepts.ixx + modules/glaze/json/json_format.ixx + modules/glaze/json/json_ptr.ixx + modules/glaze/json/json_stream.ixx + modules/glaze/json/lazy.ixx + modules/glaze/json/max_write_precision.ixx + modules/glaze/json/minify.ixx + modules/glaze/json/ndjson.ixx + modules/glaze/json/patch.ixx + modules/glaze/json/prettify.ixx + modules/glaze/json/ptr.ixx + modules/glaze/json/raw_string.ixx + modules/glaze/json/read.ixx + modules/glaze/json/schema.ixx + modules/glaze/json/skip.ixx + modules/glaze/json/study.ixx + modules/glaze/json/wrappers.ixx + modules/glaze/json/write.ixx + +) + +# utils +target_sources(glaze_glaze + PUBLIC + FILE_SET CXX_MODULES + FILES + modules/glaze/util/string_literal.ixx + modules/glaze/util/expected.ixx + modules/glaze/util/dump.ixx + modules/glaze/util/convert.ixx + modules/glaze/util/parse.ixx + modules/glaze/util/atoi.ixx + modules/glaze/util/for_each.ixx + modules/glaze/util/utility.ixx + modules/glaze/util/type_traits.ixx + modules/glaze/util/bit.ixx + modules/glaze/util/compare.ixx + modules/glaze/util/glaze_fast_float.ixx + modules/glaze/util/simple_float.ixx + modules/glaze/util/fast_float.ixx + modules/glaze/util/variant.ixx + modules/glaze/util/itoa.ixx + modules/glaze/util/bit_array.ixx + modules/glaze/util/help.ixx + modules/glaze/util/tuple.ixx + modules/glaze/util/validate.ixx + modules/glaze/util/primes_64.ixx + modules/glaze/util/dtoa.ixx + modules/glaze/util/itoa_40kb.ixx + modules/glaze/util/dragonbox.ixx +) + +# concepts +target_sources(glaze_glaze + PUBLIC + FILE_SET CXX_MODULES + FILES + modules/glaze/concepts/container_concepts.ixx +) + +# api/std +target_sources(glaze_glaze + PUBLIC + FILE_SET CXX_MODULES + FILES + modules/glaze/api/std/array.ixx + modules/glaze/api/std/deque.ixx + modules/glaze/api/std/functional.ixx + modules/glaze/api/std/list.ixx + modules/glaze/api/std/map.ixx + modules/glaze/api/std/optional.ixx + modules/glaze/api/std/set.ixx + modules/glaze/api/std/shared_ptr.ixx + modules/glaze/api/std/span.ixx + modules/glaze/api/std/string.ixx + modules/glaze/api/std/tuple.ixx + modules/glaze/api/std/unique_ptr.ixx + modules/glaze/api/std/unordered_map.ixx + modules/glaze/api/std/unordered_set.ixx + modules/glaze/api/std/variant.ixx + modules/glaze/api/std/vector.ixx +) + +# api +target_sources(glaze_glaze + PUBLIC + FILE_SET CXX_MODULES + FILES + modules/glaze/api/hash.ixx + modules/glaze/api/tuplet.ixx + modules/glaze/api/type_support.ixx + modules/glaze/api/xxh64.ixx + modules/glaze/api/impl.ixx + modules/glaze/api/api.ixx + modules/glaze/api/trait.ixx +) + +# tuplet +target_sources(glaze_glaze + PUBLIC + FILE_SET CXX_MODULES + FILES + modules/glaze/tuplet/tuple.ixx +) + +# thread +target_sources(glaze_glaze + PUBLIC + FILE_SET CXX_MODULES + FILES + modules/glaze/thread/threadpool.ixx + modules/glaze/thread/atomic.ixx +) + +# simd +target_sources(glaze_glaze + PUBLIC + FILE_SET CXX_MODULES + FILES + modules/glaze/simd/avx.ixx + modules/glaze/simd/neon.ixx + modules/glaze/simd/sse.ixx +) + +# reflection +target_sources(glaze_glaze + PUBLIC + FILE_SET CXX_MODULES + FILES + modules/glaze/reflection/to_tuple.ixx + modules/glaze/reflection/get_name.ixx + modules/glaze/reflection/requires_key.ixx +) + +# beve +target_sources(glaze_glaze + PUBLIC + FILE_SET CXX_MODULES + FILES + modules/glaze/beve/header.ixx + modules/glaze/beve/read.ixx + modules/glaze/beve/key_traits.ixx + modules/glaze/beve/skip.ixx + modules/glaze/beve/write.ixx +) + +# file +target_sources(glaze_glaze + PUBLIC + FILE_SET CXX_MODULES + FILES + modules/glaze/file/file_ops.ixx + modules/glaze/file/hostname_include.ixx + modules/glaze/file/raw_or_file.ixx + modules/glaze/file/read_directory.ixx + modules/glaze/file/write_directory.ixx +) + +# cbor +target_sources(glaze_glaze + PUBLIC + FILE_SET CXX_MODULES + FILES + modules/glaze/cbor/cbor_to_json.ixx + modules/glaze/cbor/header.ixx + modules/glaze/cbor/read.ixx + modules/glaze/cbor/skip.ixx + modules/glaze/cbor/wrappers.ixx + modules/glaze/cbor/write.ixx +) + +# containers +target_sources(glaze_glaze + PUBLIC + FILE_SET CXX_MODULES + FILES + modules/glaze/containers/flat_map.ixx + modules/glaze/containers/inplace_vector.ixx +) + +# hardware +target_sources(glaze_glaze + PUBLIC + FILE_SET CXX_MODULES + FILES + modules/glaze/hardware/volatile_array.ixx +) + +# record +target_sources(glaze_glaze + PUBLIC + FILE_SET CXX_MODULES + FILES + modules/glaze/record/recorder.ixx +) + +# trace +target_sources(glaze_glaze + PUBLIC + FILE_SET CXX_MODULES + FILES + modules/glaze/trace/trace.ixx +) + +# csv +target_sources(glaze_glaze + PUBLIC + FILE_SET CXX_MODULES + FILES + modules/glaze/csv/read.ixx + modules/glaze/csv/skip.ixx + modules/glaze/csv/write.ixx +) diff --git a/docs/advanced-api-usage.md b/docs/advanced-api-usage.md index 2c748a1b17..70ea8b4136 100644 --- a/docs/advanced-api-usage.md +++ b/docs/advanced-api-usage.md @@ -36,12 +36,12 @@ struct custom_api : glz::api { return path == "/count"; } - bool read(const uint32_t format, const sv path, const sv data) noexcept override { + bool read(const std::uint32_t format, const sv path, const sv data) noexcept override { // Custom deserialization logic return true; } - bool write(const uint32_t format, const sv path, std::string& data) noexcept override { + bool write(const std::uint32_t format, const sv path, std::string& data) noexcept override { // Custom serialization logic return true; } @@ -454,30 +454,30 @@ Glaze generates type names following these rules: ```c++ // Fundamental types -glz::name_v // "int32_t" +glz::name_v // "std::int32_t" glz::name_v // "double" glz::name_v // "bool" // CV-qualifiers and references -glz::name_v // "const int32_t" -glz::name_v // "int32_t&" -glz::name_v // "const int32_t&" -glz::name_v // "int32_t&&" +glz::name_v // "const std::int32_t" +glz::name_v // "std::int32_t&" +glz::name_v // "const std::int32_t&" +glz::name_v // "std::int32_t&&" // Pointers -glz::name_v // "int32_t*" -glz::name_v // "const int32_t*" +glz::name_v // "std::int32_t*" +glz::name_v // "const std::int32_t*" // Containers -glz::name_v> // "std::vector" -glz::name_v> // "std::map" -glz::name_v> // "std::unordered_map" +glz::name_v> // "std::vector" +glz::name_v> // "std::map" +glz::name_v> // "std::unordered_map" // Functions -glz::name_v> // "std::function" +glz::name_v> // "std::function" glz::name_v> // "std::function" glz::name_v> - // "std::function" + // "std::function" ``` ### Debugging Type Mismatches diff --git a/docs/binary.md b/docs/binary.md index ea21c176b4..7f5c54e88b 100644 --- a/docs/binary.md +++ b/docs/binary.md @@ -37,7 +37,7 @@ The `glz::beve_size` function calculates the exact number of bytes needed to ser ```c++ my_struct s{}; -size_t size = glz::beve_size(s); +std::size_t size = glz::beve_size(s); // size contains the exact number of bytes needed to serialize s ``` @@ -47,14 +47,14 @@ size_t size = glz::beve_size(s); #include "glaze/beve.hpp" struct SensorData { - uint64_t timestamp; + std::uint64_t timestamp; double temperature; std::vector readings; }; // Calculate size before allocation SensorData data{12345, 98.6, {1.0, 2.0, 3.0}}; -size_t size = glz::beve_size(data); +std::size_t size = glz::beve_size(data); // Allocate shared memory with exact size void* shm = mmap(nullptr, size, PROT_READ | PROT_WRITE, @@ -71,8 +71,8 @@ For untagged serialization (structs written as arrays without keys), use `glz::b ```c++ my_struct s{}; -size_t tagged_size = glz::beve_size(s); // with keys -size_t untagged_size = glz::beve_size_untagged(s); // without keys (smaller) +std::size_t tagged_size = glz::beve_size(s); // with keys +std::size_t untagged_size = glz::beve_size_untagged(s); // without keys (smaller) ``` **Compressed Integer Size Helper** @@ -138,8 +138,8 @@ struct beve_header { uint8_t tag{}; // Raw tag byte uint8_t type{}; // Base type (see below) uint8_t ext_type{}; // For extensions: subtype (variant, complex, etc.) - size_t count{}; // Element count, string length, variant index, etc. - size_t header_size{}; // Bytes consumed by tag + count encoding + std::size_t count{}; // Element count, string length, variant index, etc. + std::size_t header_size{}; // Bytes consumed by tag + count encoding }; ``` @@ -196,7 +196,7 @@ if (!header) { } // Reject oversized arrays -constexpr size_t max_elements = 10000; +constexpr std::size_t max_elements = 10000; if (header->type == glz::tag::typed_array && header->count > max_elements) { return unexpected(error_code::invalid_length); } @@ -233,7 +233,7 @@ For C-style buffers: ```c++ const void* data = /* ... */; -size_t size = /* ... */; +std::size_t size = /* ... */; auto result = glz::beve_peek_header(data, size); ``` @@ -244,7 +244,7 @@ Use `glz::beve_peek_header_at` to peek at headers at arbitrary byte offsets with ```c++ std::string buffer = /* BEVE data */; -size_t offset = /* position to inspect */; +std::size_t offset = /* position to inspect */; auto header = glz::beve_peek_header_at(buffer, offset); if (header) { @@ -275,7 +275,7 @@ if (header) { ```c++ // Example: Multiple values in one buffer -int32_t val1 = 42; +std::int32_t val1 = 42; std::string val2 = "hello"; auto buffer1 = glz::write_beve(val1).value(); @@ -325,7 +325,7 @@ BEVE can serialize map-like containers whose key types expose a value through Gl ```c++ struct ModuleID { - uint64_t value{}; + std::uint64_t value{}; auto operator<=>(const ModuleID&) const = default; }; @@ -340,14 +340,14 @@ std::string beve{}; glz::write_beve(modules, beve); ``` -Glaze inspects the metadata, reuses the underlying `uint64_t`, and emits the numeric BEVE map header so the payload decodes as a regular number key. The same behaviour works for `std::unordered_map` and concatenated ranges such as `std::vector>`. +Glaze inspects the metadata, reuses the underlying `std::uint64_t`, and emits the numeric BEVE map header so the payload decodes as a regular number key. The same behaviour works for `std::unordered_map` and concatenated ranges such as `std::vector>`. If you prefer to keep a custom conversion in your metadata, `glz::cast` works as well: ```c++ template <> struct glz::meta { - static constexpr auto value = glz::cast<&ModuleID::value, uint64_t>; + static constexpr auto value = glz::cast<&ModuleID::value, std::uint64_t>; }; ``` @@ -474,7 +474,7 @@ For manual control over reading, use `read_beve_at` which returns the number of ```c++ std::string buffer = /* delimited BEVE data */; -size_t offset = 0; +std::size_t offset = 0; while (offset < buffer.size()) { my_struct obj{}; @@ -499,7 +499,7 @@ The standard `read_beve` function tracks bytes consumed via `ec.count`: my_struct obj{}; auto ec = glz::read_beve(obj, buffer); if (!ec) { - size_t bytes_consumed = ec.count; // Number of bytes read on success + std::size_t bytes_consumed = ec.count; // Number of bytes read on success } ``` @@ -549,7 +549,7 @@ if (result) { auto age = (*result)["user"]["age"].get(); // Check container size without parsing elements - size_t count = (*result)["items"].size(); + std::size_t count = (*result)["items"].size(); } ``` diff --git a/docs/cbor.md b/docs/cbor.md index b912b92240..1e761d6a9f 100644 --- a/docs/cbor.md +++ b/docs/cbor.md @@ -73,11 +73,11 @@ glz::write_cbor(values, buffer); // Uses typed array with bulk memcpy |------|-------------------|----------------| | `uint8_t` | 64 | 64 | | `uint16_t` | 69 | 65 | -| `uint32_t` | 70 | 66 | -| `uint64_t` | 71 | 67 | +| `std::uint32_t` | 70 | 66 | +| `std::uint64_t` | 71 | 67 | | `int8_t` | 72 | 72 | | `int16_t` | 77 | 73 | -| `int32_t` | 78 | 74 | +| `std::int32_t` | 78 | 74 | | `int64_t` | 79 | 75 | | `float` | 85 | 81 | | `double` | 86 | 82 | diff --git a/docs/custom-serialization.md b/docs/custom-serialization.md index 37f2ebdae2..b82e242316 100644 --- a/docs/custom-serialization.md +++ b/docs/custom-serialization.md @@ -12,7 +12,7 @@ Example: ```c++ struct date { - uint64_t data; + std::uint64_t data; std::string human_readable; }; diff --git a/docs/design/json_merge_patch_rfc7386.md b/docs/design/json_merge_patch_rfc7386.md index 711d742374..4e766d3693 100644 --- a/docs/design/json_merge_patch_rfc7386.md +++ b/docs/design/json_merge_patch_rfc7386.md @@ -163,7 +163,7 @@ namespace glz::detail inline error_ctx apply_merge_patch_impl( generic& target, const generic& patch, - uint32_t depth = 0 + std::uint32_t depth = 0 ) { if (depth >= max_recursive_depth_limit) [[unlikely]] { @@ -462,7 +462,7 @@ If the patch is not an object, it replaces the entire document: patch.data = glz::generic::object_t{}; glz::generic* current = &patch; - for (size_t i = 0; i < glz::max_recursive_depth_limit + 10; ++i) { + for (std::size_t i = 0; i < glz::max_recursive_depth_limit + 10; ++i) { current->get_object()["nested"].data = glz::generic::object_t{}; current = ¤t->get_object()["nested"]; } diff --git a/docs/design/json_patch_rfc6902.md b/docs/design/json_patch_rfc6902.md index 0e3f353c65..f69c51f09c 100644 --- a/docs/design/json_patch_rfc6902.md +++ b/docs/design/json_patch_rfc6902.md @@ -239,7 +239,7 @@ inline expected unescape_json_ptr(std::string_view token { std::string result; result.reserve(token.size()); - for (size_t i = 0; i < token.size(); ++i) { + for (std::size_t i = 0; i < token.size(); ++i) { if (token[i] == '~') { if (i + 1 >= token.size()) { return unexpected(error_ctx{error_code::invalid_json_pointer}); @@ -311,7 +311,7 @@ error_ctx patch(generic& document, const patch_document& ops, patch_opts opts) // Deep copy for rollback - requires O(n) space generic backup = document; - for (size_t i = 0; i < ops.size(); ++i) { + for (std::size_t i = 0; i < ops.size(); ++i) { auto ec = apply_operation(document, ops[i], opts); if (ec) { document = std::move(backup); // Rollback @@ -321,7 +321,7 @@ error_ctx patch(generic& document, const patch_document& ops, patch_opts opts) } } else { - for (size_t i = 0; i < ops.size(); ++i) { + for (std::size_t i = 0; i < ops.size(); ++i) { auto ec = apply_operation(document, ops[i], opts); if (ec) { ec.operation_index = i; @@ -367,7 +367,7 @@ namespace glz New error codes to add to `error_code` enum: ```cpp -enum struct error_code : uint32_t { +enum struct error_code : std::uint32_t { // ... existing codes ... // JSON Pointer errors diff --git a/docs/generic-json.md b/docs/generic-json.md index d01986d589..5e6d30b204 100644 --- a/docs/generic-json.md +++ b/docs/generic-json.md @@ -12,7 +12,7 @@ Glaze provides three generic JSON types with different number storage strategies |------|---------------|----------| | `glz::generic` | `double` | Fast, JavaScript-compatible (default) | | `glz::generic_i64` | `int64_t` then `double` | Signed integer precision | -| `glz::generic_u64` | `uint64_t` then `int64_t` then `double` | Full integer range | +| `glz::generic_u64` | `std::uint64_t` then `int64_t` then `double` | Full integer range | ### glz::generic (Default) @@ -51,16 +51,16 @@ assert(json["id"].as() == 9007199254740993.0); ### glz::generic_u64 -Provides full integer range support. Positive integers are stored as `uint64_t`, negative integers as `int64_t`, and floating-point numbers as `double`. This handles the complete unsigned 64-bit range (0 to 18.4 quintillion). +Provides full integer range support. Positive integers are stored as `std::uint64_t`, negative integers as `int64_t`, and floating-point numbers as `double`. This handles the complete unsigned 64-bit range (0 to 18.4 quintillion). ```c++ glz::generic_u64 json{}; std::string buffer = R"({"big_id": 18446744073709551615, "neg": -100, "pi": 3.14})"; glz::read_json(json, buffer); -// Maximum uint64_t value preserved exactly +// Maximum std::uint64_t value preserved exactly assert(json["big_id"].is_uint64()); -assert(json["big_id"].get() == 18446744073709551615ULL); +assert(json["big_id"].get() == 18446744073709551615ULL); // Negative integers stored as int64_t assert(json["neg"].is_int64()); @@ -149,7 +149,7 @@ There are also free functions of these, such as `glz::is_object(...)` - `.is_int64()` - true if stored as `int64_t` - `.is_double()` - true if stored as `double` -- `.is_uint64()` - true if stored as `uint64_t` (only `generic_u64`) +- `.is_uint64()` - true if stored as `std::uint64_t` (only `generic_u64`) - `.as_number()` - returns the value as `double`, converting if necessary ```c++ diff --git a/docs/glaze-interfaces.md b/docs/glaze-interfaces.md index 05c722128a..0b619ca8c1 100644 --- a/docs/glaze-interfaces.md +++ b/docs/glaze-interfaces.md @@ -47,10 +47,10 @@ namespace glz { [[nodiscard]] virtual bool contains(const sv path) noexcept = 0; // Read data into the API object from JSON or BEVE - virtual bool read(const uint32_t format, const sv path, const sv data) noexcept = 0; + virtual bool read(const std::uint32_t format, const sv path, const sv data) noexcept = 0; // Write data from the API object to JSON or BEVE - virtual bool write(const uint32_t format, const sv path, std::string& data) noexcept = 0; + virtual bool write(const std::uint32_t format, const sv path, std::string& data) noexcept = 0; // Get the last error message [[nodiscard]] virtual const sv last_error() const noexcept { return error; } diff --git a/docs/index.md b/docs/index.md index 1a7412aaba..9a9c2aa4ba 100644 --- a/docs/index.md +++ b/docs/index.md @@ -23,7 +23,7 @@ struct my_struct { int i = 287; double d = 3.14; std::string hello = "Hello World"; - std::array arr = {1, 2, 3}; + std::array arr = {1, 2, 3}; }; // Write JSON diff --git a/docs/json-pointer-syntax.md b/docs/json-pointer-syntax.md index 7003f6de15..9dae8e8676 100644 --- a/docs/json-pointer-syntax.md +++ b/docs/json-pointer-syntax.md @@ -108,7 +108,7 @@ This is useful for dynamic path construction: std::string buffer = R"({"users":[{"name":"Alice"},{"name":"Bob"}]})"; // Update user at runtime-determined index -size_t user_index = 1; +std::size_t user_index = 1; std::string path = "/users/" + std::to_string(user_index) + "/name"; glz::write_at(path, R"("Charlie")", buffer); // buffer is now: {"users":[{"name":"Alice"},{"name":"Charlie"}]} diff --git a/docs/json.md b/docs/json.md index 4979cbd739..3172255ca7 100644 --- a/docs/json.md +++ b/docs/json.md @@ -204,7 +204,7 @@ Person person{}; auto ec = glz::read_json(person, buffer); if (!ec) { // Success: ec.count contains bytes consumed - size_t bytes_read = ec.count; + std::size_t bytes_read = ec.count; // Useful for reading multiple values from one buffer: std::string_view remaining = std::string_view(buffer).substr(bytes_read); diff --git a/docs/lazy-beve.md b/docs/lazy-beve.md index eccb192062..0e18be0280 100644 --- a/docs/lazy-beve.md +++ b/docs/lazy-beve.md @@ -187,7 +187,7 @@ if (result) { auto indexed = result->root().index(); // Now enjoy O(1) operations: - size_t count = indexed.size(); // O(1) - no scanning + std::size_t count = indexed.size(); // O(1) - no scanning auto key500 = indexed["key500"]; // Linear search in indexed keys auto first = indexed[0]; // O(1) - direct access by position @@ -214,7 +214,7 @@ if (result) { auto indexed = doc["items"].index(); // O(1) size query -size_t count = indexed.size(); +std::size_t count = indexed.size(); // O(1) empty check if (!indexed.empty()) { /* ... */ } @@ -317,8 +317,8 @@ if (value) { | Type | Description | |------|-------------| | `bool` | Boolean values | -| `int32_t`, `int64_t` | Signed integers | -| `uint32_t`, `uint64_t` | Unsigned integers | +| `std::int32_t`, `int64_t` | Signed integers | +| `std::uint32_t`, `std::uint64_t` | Unsigned integers | | `float`, `double` | Floating-point numbers | | `std::string` | String value | | `std::string_view` | String view (zero-copy) | @@ -364,7 +364,7 @@ auto arr = doc["items"]; if (arr.empty()) { /* ... */ } // Get number of elements (O(1) in BEVE - count is stored) -size_t count = arr.size(); +std::size_t count = arr.size(); // Check if object contains a key if (doc.root().contains("name")) { /* ... */ } @@ -389,7 +389,7 @@ if (result) { } // Also works with index access - size_t first_name_len = result->size[0]; // For arrays + std::size_t first_name_len = result->size[0]; // For arrays } ``` diff --git a/docs/lazy-json.md b/docs/lazy-json.md index 44fcd2a86c..b3a8e838a5 100644 --- a/docs/lazy-json.md +++ b/docs/lazy-json.md @@ -160,7 +160,7 @@ if (result) { auto users = (*result)["users"].index(); // Now enjoy O(1) operations: - size_t count = users.size(); // O(1) - no scanning + std::size_t count = users.size(); // O(1) - no scanning auto user500 = users[500]; // O(1) - direct access auto user999 = users[999]; // O(1) - no matter the position @@ -187,7 +187,7 @@ if (result) { auto indexed = doc["items"].index(); // O(1) size query -size_t count = indexed.size(); +std::size_t count = indexed.size(); // O(1) empty check if (!indexed.empty()) { /* ... */ } @@ -361,8 +361,8 @@ if (value) { | Type | Description | |------|-------------| | `bool` | Boolean values | -| `int32_t`, `int64_t` | Signed integers | -| `uint32_t`, `uint64_t` | Unsigned integers | +| `std::int32_t`, `int64_t` | Signed integers | +| `std::uint32_t`, `std::uint64_t` | Unsigned integers | | `float`, `double` | Floating-point numbers | | `std::string` | String with escape processing | | `std::string_view` | Raw string view (no escape processing) | @@ -408,7 +408,7 @@ auto arr = doc["items"]; if (arr.empty()) { /* ... */ } // Get number of elements (requires scanning) -size_t count = arr.size(); +std::size_t count = arr.size(); // Check if object contains a key if (doc.root().contains("name")) { /* ... */ } diff --git a/docs/modify-reflection.md b/docs/modify-reflection.md index bbb50cb00c..31b65f4e99 100644 --- a/docs/modify-reflection.md +++ b/docs/modify-reflection.md @@ -53,7 +53,7 @@ struct server_status { std::string name; // pure reflection keeps this key std::string region; // …and this one - uint64_t active_sessions; // and all the others + std::uint64_t active_sessions; // and all the others std::optional maintenance; double cpu_percent{}; }; diff --git a/docs/networking/advanced-networking.md b/docs/networking/advanced-networking.md index caa391135d..1a0f4b25d8 100644 --- a/docs/networking/advanced-networking.md +++ b/docs/networking/advanced-networking.md @@ -326,10 +326,10 @@ void run_multiple_servers_shared_context() { // Run the shared io_context in a thread pool std::vector threads; - const size_t num_threads = std::thread::hardware_concurrency(); + const std::size_t num_threads = std::thread::hardware_concurrency(); threads.reserve(num_threads); - for (size_t i = 0; i < num_threads; ++i) { + for (std::size_t i = 0; i < num_threads; ++i) { threads.emplace_back([io_ctx]() { io_ctx->run(); }); diff --git a/docs/networking/http-router.md b/docs/networking/http-router.md index fdecd15498..f9d3156e97 100644 --- a/docs/networking/http-router.md +++ b/docs/networking/http-router.md @@ -176,7 +176,7 @@ glz::param_constraint hex_color{ .description = "Valid hex color code", .validation = [](std::string_view value) { if (value.size() != 7 || value[0] != '#') return false; - for (size_t i = 1; i < value.size(); ++i) { + for (std::size_t i = 1; i < value.size(); ++i) { if (!std::isxdigit(value[i])) return false; } return true; diff --git a/docs/networking/http-server.md b/docs/networking/http-server.md index 7426b30cae..71ef90c341 100644 --- a/docs/networking/http-server.md +++ b/docs/networking/http-server.md @@ -423,8 +423,8 @@ server.wrap([](const glz::request& req, glz::response& res, const auto& next) { **Request/Response Timing:** ```cpp struct Metrics { - std::atomic total_requests{0}; - std::atomic total_responses{0}; + std::atomic total_requests{0}; + std::atomic total_responses{0}; std::atomic response_time_sum{0.0}; }; diff --git a/docs/networking/websocket-client.md b/docs/networking/websocket-client.md index 9acf5f4bb8..429d63847a 100644 --- a/docs/networking/websocket-client.md +++ b/docs/networking/websocket-client.md @@ -171,7 +171,7 @@ if (client.context()->stopped()) { Sets the maximum allowed message size in bytes. ```cpp -void set_max_message_size(size_t size); +void set_max_message_size(std::size_t size); ``` Default is 16 MB (16 * 1024 * 1024 bytes). @@ -476,7 +476,7 @@ int main() { // Process binary data const uint8_t* data = reinterpret_cast(message.data()); - for (size_t i = 0; i < std::min(size_t(16), message.size()); ++i) { + for (std::size_t i = 0; i < std::min(std::size_t(16), message.size()); ++i) { printf("%02X ", data[i]); } std::cout << std::endl; @@ -543,7 +543,7 @@ int main() { // Run the shared io_context in a thread pool std::vector threads; - for (size_t i = 0; i < std::thread::hardware_concurrency(); ++i) { + for (std::size_t i = 0; i < std::thread::hardware_concurrency(); ++i) { threads.emplace_back([io_ctx]() { io_ctx->run(); }); diff --git a/docs/options.md b/docs/options.md index 8c7f5008b8..47d4c13a96 100644 --- a/docs/options.md +++ b/docs/options.md @@ -14,7 +14,7 @@ The tables below list **all** compile time options, organized by category: | Option | Default | Description | |--------|---------|-------------| -| `uint32_t format` | `JSON` | Format selector (`JSON`, `BEVE`, `CSV`, `TOML`, etc.) | +| `std::uint32_t format` | `JSON` | Format selector (`JSON`, `BEVE`, `CSV`, `TOML`, etc.) | | `bool null_terminated` | `true` | Whether the input buffer is null terminated | | `bool comments` | `false` | Support reading JSONC style comments | | `bool error_on_unknown_keys` | `true` | Error when an unknown key is encountered | @@ -57,9 +57,9 @@ These options are **not** in `glz::opts` by default. Add them to a custom option | `bool assume_sufficient_buffer` | `false` | Skip bounds checking for fixed-size buffers (caller guarantees space) | | `bool linear_search` | `false` | Use linear key search instead of hash tables for smaller binary size | | `optimization_level optimization_level` | `normal` | Controls speed vs binary size tradeoff. See [Optimization Levels](optimization-levels.md) | -| `size_t max_string_length` | `0` | Maximum string length when reading (0 = no limit). See also [Runtime Constraints](security.md#runtime-limits-via-custom-context). | -| `size_t max_array_size` | `0` | Maximum array size when reading (0 = no limit). See also [Runtime Constraints](security.md#runtime-limits-via-custom-context). | -| `size_t max_map_size` | `0` | Maximum map size when reading (0 = no limit). See also [Runtime Constraints](security.md#runtime-limits-via-custom-context). | +| `std::size_t max_string_length` | `0` | Maximum string length when reading (0 = no limit). See also [Runtime Constraints](security.md#runtime-limits-via-custom-context). | +| `std::size_t max_array_size` | `0` | Maximum array size when reading (0 = no limit). See also [Runtime Constraints](security.md#runtime-limits-via-custom-context). | +| `std::size_t max_map_size` | `0` | Maximum map size when reading (0 = no limit). See also [Runtime Constraints](security.md#runtime-limits-via-custom-context). | | `bool allocate_raw_pointers` | `false` | Allocate memory for null raw pointers during deserialization. See also [Runtime Control](security.md#runtime-raw-pointer-allocation-control). | ### CSV Options (`glz::opts_csv`) @@ -68,7 +68,7 @@ For CSV format, use `glz::opts_csv` which provides CSV-specific defaults. | Option | Default | Description | |--------|---------|-------------| -| `uint32_t format` | `CSV` | Format selector (fixed to CSV) | +| `std::uint32_t format` | `CSV` | Format selector (fixed to CSV) | | `bool null_terminated` | `true` | Whether the input buffer is null terminated | | `uint8_t layout` | `rowwise` | Data layout: `rowwise` or `colwise` | | `bool use_headers` | `true` | Read/write with column headers | diff --git a/docs/partial-read.md b/docs/partial-read.md index 65cd62c700..1a69a7e4ad 100644 --- a/docs/partial-read.md +++ b/docs/partial-read.md @@ -53,7 +53,7 @@ Example: read only the fields present in a struct and then short circuit the par struct partial_struct { std::string string{}; - int32_t integer{}; + std::int32_t integer{}; }; ``` diff --git a/docs/partial-write.md b/docs/partial-write.md index d80e9133ba..782b8da0f4 100644 --- a/docs/partial-write.md +++ b/docs/partial-write.md @@ -151,7 +151,7 @@ Three overloads are available: error_ctx write_json_partial(T&& value, const Keys& keys, Buffer&& buffer); // 2. Write to raw buffer (char*) -expected write_json_partial(T&& value, const Keys& keys, Buffer&& buffer); +expected write_json_partial(T&& value, const Keys& keys, Buffer&& buffer); // 3. Return a new string expected write_json_partial(T&& value, const Keys& keys); @@ -293,7 +293,7 @@ Three overloads are available: error_ctx write_json_exclude(T&& value, const Keys& exclude_keys, Buffer&& buffer); // 2. Write to raw buffer (char*) -expected write_json_exclude(T&& value, const Keys& exclude_keys, Buffer&& buffer); +expected write_json_exclude(T&& value, const Keys& exclude_keys, Buffer&& buffer); // 3. Return a new string expected write_json_exclude(T&& value, const Keys& exclude_keys); diff --git a/docs/reading.md b/docs/reading.md index 6b035c6e1b..97a8286a94 100644 --- a/docs/reading.md +++ b/docs/reading.md @@ -8,7 +8,7 @@ All read functions return `glz::error_ctx`: ```cpp struct error_ctx { - size_t count{}; // Bytes consumed from input + std::size_t count{}; // Bytes consumed from input error_code ec{}; // Error code (none on success) std::string_view custom_error_message{}; // Optional error details @@ -59,7 +59,7 @@ my_struct obj1{}, obj2{}; auto ec = glz::read_json(obj1, input); if (!ec) { - size_t consumed = ec.count; // Bytes consumed by first read + std::size_t consumed = ec.count; // Bytes consumed by first read // Read second object from remaining buffer ec = glz::read_json(obj2, std::string_view(input).substr(consumed)); diff --git a/docs/rename-keys.md b/docs/rename-keys.md index e4cfdca764..fb562fa879 100644 --- a/docs/rename-keys.md +++ b/docs/rename-keys.md @@ -220,7 +220,7 @@ struct AppContext { template <> struct glz::meta { - template + template static constexpr auto rename_key() { using MemberType = glz::member_type_t; @@ -248,13 +248,13 @@ You can customize how type names are formatted by manipulating them at compile t ```cpp template <> struct glz::meta { - template + template static constexpr auto rename_key() { using MemberType = glz::member_type_t; if constexpr (std::is_enum_v) { constexpr auto full_name = glz::name_v; - constexpr size_t pos = full_name.rfind("::"); + constexpr std::size_t pos = full_name.rfind("::"); return (pos == std::string_view::npos) ? full_name : full_name.substr(pos + 2); @@ -286,7 +286,7 @@ struct MixedTypes { template <> struct glz::meta { - template + template static constexpr auto rename_key() { using MemberType = glz::member_type_t; constexpr auto name = glz::member_nameof; @@ -314,7 +314,7 @@ struct Point { template <> struct glz::meta { - template + template static constexpr auto rename_key() { constexpr auto name = glz::member_nameof; @@ -346,7 +346,7 @@ std::string json = glz::write_json(p).value(); | Variant | Use When | |---------|----------| | `rename_key(const std::string_view key)` | You need to transform keys based on their string values | -| `template rename_key()` | You need access to member types or index information | +| `template rename_key()` | You need access to member types or index information | | Built-in transformers (e.g., `glz::camel_case`) | You want simple naming convention conversions | ### Implementation Notes diff --git a/docs/rpc/repe-buffer.md b/docs/rpc/repe-buffer.md index b2feae2c35..da1ac0b93b 100644 --- a/docs/rpc/repe-buffer.md +++ b/docs/rpc/repe-buffer.md @@ -145,7 +145,7 @@ The function validates: Overloads: ```cpp // From raw pointer + size -glz::error_code from_buffer(const char* data, size_t size, message& msg); +glz::error_code from_buffer(const char* data, std::size_t size, message& msg); // From string_view glz::error_code from_buffer(std::string_view data, message& msg); @@ -165,7 +165,7 @@ struct request_view { std::string_view query; // View into original buffer std::string_view body; // View into original buffer - [[nodiscard]] uint64_t id() const noexcept; + [[nodiscard]] std::uint64_t id() const noexcept; [[nodiscard]] bool is_notify() const noexcept; [[nodiscard]] error_code error() const noexcept; }; @@ -322,7 +322,7 @@ Returns an empty `string_view` on error (invalid header, truncated data). ```cpp #include "glaze/rpc/repe/buffer.hpp" -void route_message(const char* data, size_t size) { +void route_message(const char* data, std::size_t size) { // Extract query without full deserialization auto query = glz::repe::extract_query(data, size); diff --git a/docs/rpc/repe-jsonrpc-conversion.md b/docs/rpc/repe-jsonrpc-conversion.md index 6b323cec39..0c622c7fdc 100644 --- a/docs/rpc/repe-jsonrpc-conversion.md +++ b/docs/rpc/repe-jsonrpc-conversion.md @@ -146,7 +146,7 @@ std::string jsonrpc = repe::to_jsonrpc_request(notification); ### ID Handling -REPE uses `uint64_t` for IDs, while JSON-RPC supports strings, numbers, or null: +REPE uses `std::uint64_t` for IDs, while JSON-RPC supports strings, numbers, or null: - Numeric IDs are directly mapped between protocols - Numeric strings (e.g., `"123"`) are parsed as numbers diff --git a/docs/rpc/repe-plugin.md b/docs/rpc/repe-plugin.md index 6c60c24040..5956d271e3 100644 --- a/docs/rpc/repe-plugin.md +++ b/docs/rpc/repe-plugin.md @@ -42,7 +42,7 @@ Plugins and hosts should check version compatibility before use. When the plugin // ABI-stable buffer for request/response data typedef struct repe_buffer { const char* data; - uint64_t size; + std::uint64_t size; } repe_buffer; // Result codes for plugin operations @@ -66,13 +66,13 @@ Plugins must export these symbols with C linkage: ```c // Interface version for compatibility checking (standalone for ABI safety) -uint32_t repe_plugin_interface_version(void); +std::uint32_t repe_plugin_interface_version(void); // Plugin metadata (returns pointer to static struct) const repe_plugin_data* repe_plugin_info(void); // Request processing -repe_buffer repe_plugin_call(const char* request, uint64_t request_size); +repe_buffer repe_plugin_call(const char* request, std::uint64_t request_size); ``` The `repe_plugin_info()` function must return a pointer that remains valid for the plugin's entire lifetime. The recommended pattern is to use a file-scope static: @@ -124,7 +124,7 @@ namespace glz::repe { void plugin_error_response( error_code ec, std::string_view error_msg, - uint64_t id = 0 + std::uint64_t id = 0 ); } ``` @@ -146,7 +146,7 @@ namespace glz::repe { repe_buffer plugin_call( Registry& registry, const char* request, - uint64_t request_size + std::uint64_t request_size ); } ``` @@ -217,7 +217,7 @@ static const repe_plugin_data plugin_info = { // Plugin exports with C linkage extern "C" { // Required: Interface version for ABI compatibility - uint32_t repe_plugin_interface_version() { + std::uint32_t repe_plugin_interface_version() { return REPE_PLUGIN_INTERFACE_VERSION; } @@ -243,7 +243,7 @@ extern "C" { } // Required: Request processing - repe_buffer repe_plugin_call(const char* request, uint64_t request_size) { + repe_buffer repe_plugin_call(const char* request, std::uint64_t request_size) { ensure_initialized(); // Plugin ensures initialization before dispatch return glz::repe::plugin_call(internal_registry, request, request_size); } @@ -267,11 +267,11 @@ struct loaded_plugin { void* handle = nullptr; // Function pointers - uint32_t (*interface_version_fn)(void) = nullptr; + std::uint32_t (*interface_version_fn)(void) = nullptr; const repe_plugin_data* (*info_fn)(void) = nullptr; repe_result (*init_fn)(void) = nullptr; void (*shutdown_fn)(void) = nullptr; - repe_buffer (*call_fn)(const char*, uint64_t) = nullptr; + repe_buffer (*call_fn)(const char*, std::uint64_t) = nullptr; ~loaded_plugin() { if (handle) { @@ -280,7 +280,7 @@ struct loaded_plugin { } } - repe_buffer call(const char* req, uint64_t size) const { + repe_buffer call(const char* req, std::uint64_t size) const { return call_fn(req, size); } }; @@ -295,11 +295,11 @@ std::optional load_plugin(const std::string& path) { // Load required symbols plugin.interface_version_fn = - (uint32_t(*)(void))dlsym(plugin.handle, "repe_plugin_interface_version"); + (std::uint32_t(*)(void))dlsym(plugin.handle, "repe_plugin_interface_version"); plugin.info_fn = (const repe_plugin_data*(*)(void))dlsym(plugin.handle, "repe_plugin_info"); plugin.call_fn = - (repe_buffer(*)(const char*, uint64_t))dlsym(plugin.handle, "repe_plugin_call"); + (repe_buffer(*)(const char*, std::uint64_t))dlsym(plugin.handle, "repe_plugin_call"); // Load optional symbols (may be NULL) plugin.init_fn = @@ -437,7 +437,7 @@ See [REPE RPC](repe-rpc.md) for more details on thread-safe classes. | Symbol | Required | Description | |--------|----------|-------------| | `REPE_PLUGIN_INTERFACE_VERSION` | - | Macro defining current interface version (3) | -| `repe_buffer` | - | POD struct: `{const char* data, uint64_t size}` | +| `repe_buffer` | - | POD struct: `{const char* data, std::uint64_t size}` | | `repe_result` | - | Enum: `REPE_OK`, `REPE_ERROR_*` | | `repe_plugin_data` | - | Struct: `{name, version, root_path}` | | `repe_plugin_interface_version()` | Yes | Returns interface version (standalone for ABI safety) | diff --git a/docs/security.md b/docs/security.md index 9e7e89c894..8c0a534adc 100644 --- a/docs/security.md +++ b/docs/security.md @@ -57,9 +57,9 @@ Apply limits to all strings/arrays in a parse operation: // Define custom options with allocation limits struct secure_opts : glz::opts { - uint32_t format = glz::BEVE; - size_t max_string_length = 1024; // Max 1KB per string - size_t max_array_size = 10000; // Max 10,000 elements per array + std::uint32_t format = glz::BEVE; + std::size_t max_string_length = 1024; // Max 1KB per string + std::size_t max_array_size = 10000; // Max 10,000 elements per array }; std::vector data; @@ -107,9 +107,9 @@ For applications that need to set limits dynamically at runtime (e.g., based on ```cpp struct secure_context : glz::context { - size_t max_string_length = 0; // 0 = no limit - size_t max_array_size = 0; - size_t max_map_size = 0; + std::size_t max_string_length = 0; // 0 = no limit + std::size_t max_array_size = 0; + std::size_t max_map_size = 0; }; // Set limits dynamically based on user tier @@ -143,7 +143,7 @@ Both mechanisms can be used together—either can reject a value that exceeds it 1. **Limit input buffer size**: Control the maximum message size your application accepts at the network layer, before passing data to Glaze. ```cpp -constexpr size_t MAX_MESSAGE_SIZE = 1024 * 1024; // 1 MB limit +constexpr std::size_t MAX_MESSAGE_SIZE = 1024 * 1024; // 1 MB limit void handle_message(const std::span data) { if (data.size() > MAX_MESSAGE_SIZE) { diff --git a/docs/stencil-mustache.md b/docs/stencil-mustache.md index e546202a91..b251cd29ed 100644 --- a/docs/stencil-mustache.md +++ b/docs/stencil-mustache.md @@ -9,7 +9,7 @@ struct person { std::string first_name{}; std::string last_name{}; - uint32_t age{}; + std::uint32_t age{}; bool hungry{}; bool employed{}; }; @@ -69,7 +69,7 @@ struct TodoItem { std::string text; bool completed; std::string priority; - size_t id; + std::size_t id; }; struct TodoList { diff --git a/docs/thread-pool.md b/docs/thread-pool.md index afa2298ed2..d9f0cf40fe 100644 --- a/docs/thread-pool.md +++ b/docs/thread-pool.md @@ -22,11 +22,11 @@ The example below shows how results can be returned from a worker function and s glz::pool pool; auto f = [] { std::mt19937_64 generator{}; - std::uniform_int_distribution dist{ 0, 100 }; + std::uniform_int_distribution dist{ 0, 100 }; return dist(generator); }; -std::vector> numbers; +std::vector> numbers; for (auto i = 0; i < 1000; ++i) { numbers.emplace_back(pool.emplace_back(f)); } diff --git a/docs/toml.md b/docs/toml.md index 301faca1bb..0e293ab04e 100644 --- a/docs/toml.md +++ b/docs/toml.md @@ -546,7 +546,7 @@ The generic JSON types provide a convenient way to parse arbitrary TOML data: |------|-----------------|----------| | `glz::generic` | `double` | General purpose, preserves floating-point precision | | `glz::generic_i64` | `int64_t` | When integers must be preserved exactly | -| `glz::generic_u64` | `uint64_t` for positive, `int64_t` for negative | When large positive integers are needed | +| `glz::generic_u64` | `std::uint64_t` for positive, `int64_t` for negative | When large positive integers are needed | #### Using glz::generic @@ -591,10 +591,10 @@ Use `glz::generic_u64` when working with large unsigned integers: ```cpp glz::generic_u64 data; -glz::read_toml(data, "big = 18446744073709551615"); // Max uint64_t +glz::read_toml(data, "big = 18446744073709551615"); // Max std::uint64_t auto& obj = std::get(data); -auto& big = std::get(obj["big"]); // 18446744073709551615 +auto& big = std::get(obj["big"]); // 18446744073709551615 ``` Negative integers are stored as `int64_t` even in u64 mode: @@ -621,7 +621,7 @@ When reading into a variant or generic type, Glaze uses these rules to determine For integers in `glz::generic_u64` mode: - Numbers starting with `-` are stored as `int64_t` -- Positive numbers are stored as `uint64_t` +- Positive numbers are stored as `std::uint64_t` ### Writing Generic Types diff --git a/docs/variant-handling.md b/docs/variant-handling.md index 4af53778ff..35982acacf 100644 --- a/docs/variant-handling.md +++ b/docs/variant-handling.md @@ -18,9 +18,9 @@ expect(s == R"("not_a_fish")"); Read example: ```c++ -std::variant x = 44; +std::variant x = 44; glz::read_json(x, "33"); -expect(std::get(x) == 33); +expect(std::get(x) == 33); ``` ### Multiple Types of Same Category diff --git a/docs/volatile-support.md b/docs/volatile-support.md index 6eb5b3bd45..de64d5772d 100644 --- a/docs/volatile-support.md +++ b/docs/volatile-support.md @@ -11,9 +11,9 @@ struct my_struct { glz::volatile_array a{}; bool b{}; - int32_t c{}; + std::int32_t c{}; double d{}; - uint32_t e{}; + std::uint32_t e{}; }; ``` diff --git a/docs/wrappers.md b/docs/wrappers.md index 13f5ca0d9f..2481b1f49e 100644 --- a/docs/wrappers.md +++ b/docs/wrappers.md @@ -202,7 +202,7 @@ When reading, first reads a value as a string, which unescapes, and then reads t ```c++ struct client_state { - uint64_t id{}; + std::uint64_t id{}; std::map> layouts{}; }; @@ -690,9 +690,9 @@ For global limits (applying to all strings/arrays), use custom options instead: ```c++ struct secure_opts : glz::opts { - uint32_t format = glz::BEVE; - size_t max_string_length = 1024; // Max 1KB per string - size_t max_array_size = 10000; // Max 10,000 elements per array + std::uint32_t format = glz::BEVE; + std::size_t max_string_length = 1024; // Max 1KB per string + std::size_t max_array_size = 10000; // Max 10,000 elements per array }; auto ec = glz::read(obj, buffer); @@ -919,13 +919,13 @@ Calls custom read and write std::functions, lambdas, or member functions. ```c++ struct custom_encoding { - uint64_t x{}; + std::uint64_t x{}; std::string y{}; - std::array z{}; + std::array z{}; void read_x(const std::string& s) { x = std::stoi(s); } - uint64_t write_x() { return x; } + std::uint64_t write_x() { return x; } void read_y(const std::string& s) { y = "hello" + s; } @@ -955,7 +955,7 @@ In use: expect(!glz::read_json(obj, s)); expect(obj.x == 3); expect(obj.y == "helloworld"); - expect(obj.z == std::array{1, 2, 3}); + expect(obj.z == std::array{1, 2, 3}); }; "custom_writing"_test = [] { @@ -1159,7 +1159,7 @@ struct opts_skip_null_json : glz::opts { **BEVE:** ```c++ struct opts_skip_null_beve : glz::opts { - uint32_t format = glz::BEVE; + std::uint32_t format = glz::BEVE; bool skip_null_members_on_read = true; }; ``` diff --git a/docs/writing.md b/docs/writing.md index 1ba4ab6dc3..33bef8a61f 100644 --- a/docs/writing.md +++ b/docs/writing.md @@ -8,7 +8,7 @@ All write functions return `glz::error_ctx`: ```cpp struct error_ctx { - size_t count{}; // Bytes written to output + std::size_t count{}; // Bytes written to output error_code ec{}; // Error code (none on success) std::string_view custom_error_message{}; // Optional error details @@ -55,7 +55,7 @@ if (ec) { // Use a larger buffer or the string-returning overload: auto result = glz::write_json(obj); if (result) { - size_t required_size = result->size(); + std::size_t required_size = result->size(); } } return; @@ -116,7 +116,7 @@ if (ec.ec == glz::error_code::buffer_overflow) { // To get actual required size, use the string-returning overload: auto full = glz::write_json(large_object); if (full) { - size_t required = full->size(); + std::size_t required = full->size(); } } ``` @@ -188,20 +188,20 @@ Glaze uses a traits system that can be specialized for custom buffer types: ```cpp namespace glz { - template + template struct buffer_traits> { static constexpr bool is_resizable = false; static constexpr bool has_bounded_capacity = true; - static size_t capacity(const my_lib::ring_buffer& b) noexcept { + static std::size_t capacity(const my_lib::ring_buffer& b) noexcept { return b.available_write_space(); } - static bool ensure_capacity(my_lib::ring_buffer& b, size_t needed) noexcept { + static bool ensure_capacity(my_lib::ring_buffer& b, std::size_t needed) noexcept { return b.available_write_space() >= needed; } - static void finalize(my_lib::ring_buffer& b, size_t written) noexcept { + static void finalize(my_lib::ring_buffer& b, std::size_t written) noexcept { b.commit(written); } }; diff --git a/docs/yaml.md b/docs/yaml.md index c332d6dd31..01b70888fb 100644 --- a/docs/yaml.md +++ b/docs/yaml.md @@ -284,7 +284,7 @@ Glaze supports YAML Core Schema tags and validates them against the C++ types be | Tag | Verbatim Form | Valid C++ Types | |-----|---------------|-----------------| | `!!str` | `!` | `std::string`, `std::string_view` | -| `!!int` | `!` | `int`, `int64_t`, `uint32_t`, etc. | +| `!!int` | `!` | `int`, `int64_t`, `std::uint32_t`, etc. | | `!!float` | `!` | `float`, `double` | | `!!bool` | `!` | `bool` | | `!!null` | `!` | `std::optional`, `std::unique_ptr`, pointers | diff --git a/examples/wrapping_middleware_example.cpp b/examples/wrapping_middleware_example.cpp index 9da6d7fc07..4a879c6be2 100644 --- a/examples/wrapping_middleware_example.cpp +++ b/examples/wrapping_middleware_example.cpp @@ -13,12 +13,12 @@ // Thread-safe metrics structure struct ServerMetrics { - std::atomic total_requests{0}; - std::atomic total_responses{0}; + std::atomic total_requests{0}; + std::atomic total_responses{0}; std::atomic response_time_sum{0.0}; - std::atomic status_2xx{0}; - std::atomic status_4xx{0}; - std::atomic status_5xx{0}; + std::atomic status_2xx{0}; + std::atomic status_4xx{0}; + std::atomic status_5xx{0}; void print_stats() const { diff --git a/fuzzing/CMakeLists.txt b/fuzzing/CMakeLists.txt index fd9ceff0da..685af89b7d 100644 --- a/fuzzing/CMakeLists.txt +++ b/fuzzing/CMakeLists.txt @@ -15,7 +15,7 @@ set(CMAKE_REQUIRED_LINK_OPTIONS -fsanitize=fuzzer) check_source_compiles(CXX " #include #include - extern \"C\" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) + extern \"C\" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { return 0;} " haslibfuzzer) diff --git a/fuzzing/binary_reflection.cpp b/fuzzing/binary_reflection.cpp index 18ce8be20f..99f48fb72d 100644 --- a/fuzzing/binary_reflection.cpp +++ b/fuzzing/binary_reflection.cpp @@ -9,10 +9,10 @@ struct my_struct int i = 287; double d = 3.14; std::string hello = "Hello World"; - std::array arr = {1, 2, 3}; + std::array arr = {1, 2, 3}; }; -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { // use a vector with null termination instead of a std::string to avoid // small string optimization to hide bounds problems diff --git a/fuzzing/cbor_reflection.cpp b/fuzzing/cbor_reflection.cpp index 7a658ab5bb..931142a1ce 100644 --- a/fuzzing/cbor_reflection.cpp +++ b/fuzzing/cbor_reflection.cpp @@ -10,10 +10,10 @@ struct my_struct int i = 287; double d = 3.14; std::string hello = "Hello World"; - std::array arr = {1, 2, 3}; + std::array arr = {1, 2, 3}; }; -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { // use a vector with null termination instead of a std::string to avoid // small string optimization to hide bounds problems diff --git a/fuzzing/cbor_roundtrip_floating.cpp b/fuzzing/cbor_roundtrip_floating.cpp index 276e353431..e1184d876b 100644 --- a/fuzzing/cbor_roundtrip_floating.cpp +++ b/fuzzing/cbor_roundtrip_floating.cpp @@ -15,7 +15,7 @@ struct Value }; template -void test(const uint8_t* Data, size_t Size) +void test(const uint8_t* Data, std::size_t Size) { using S = Value; S s{}; @@ -48,7 +48,7 @@ void test(const uint8_t* Data, size_t Size) } } -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { if (Size < 1 + sizeof(float)) { return 0; diff --git a/fuzzing/cbor_roundtrip_int.cpp b/fuzzing/cbor_roundtrip_int.cpp index 0b7618a7f4..e7fe6dbc55 100644 --- a/fuzzing/cbor_roundtrip_int.cpp +++ b/fuzzing/cbor_roundtrip_int.cpp @@ -14,7 +14,7 @@ struct Value }; template -void test(const uint8_t* Data, size_t Size) +void test(const uint8_t* Data, std::size_t Size) { using S = Value; S s{}; @@ -35,7 +35,7 @@ void test(const uint8_t* Data, size_t Size) assert(restored.value().value == s.value); } -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { if (Size < 2) { return 0; diff --git a/fuzzing/cbor_roundtrip_string.cpp b/fuzzing/cbor_roundtrip_string.cpp index 1e02b5e695..325c0fd11d 100644 --- a/fuzzing/cbor_roundtrip_string.cpp +++ b/fuzzing/cbor_roundtrip_string.cpp @@ -11,7 +11,7 @@ struct S std::string value{}; }; -void test(const uint8_t* Data, size_t Size) +void test(const uint8_t* Data, std::size_t Size) { S s{{Data, Data + Size}}; @@ -26,7 +26,7 @@ void test(const uint8_t* Data, size_t Size) assert(restored.value().value == s.value); } -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { test(Data, Size); return 0; diff --git a/fuzzing/csv_parsing.cpp b/fuzzing/csv_parsing.cpp index b9318ed92c..91a2777ebd 100644 --- a/fuzzing/csv_parsing.cpp +++ b/fuzzing/csv_parsing.cpp @@ -12,7 +12,7 @@ struct my_struct std::vector> v3s{}; }; -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { if (Size < 1) return 0; diff --git a/fuzzing/json_exhaustive_roundtrip_float.cpp b/fuzzing/json_exhaustive_roundtrip_float.cpp index 2ba4f84304..0ca78a6a57 100644 --- a/fuzzing/json_exhaustive_roundtrip_float.cpp +++ b/fuzzing/json_exhaustive_roundtrip_float.cpp @@ -61,7 +61,7 @@ void test() std::vector threads; threads.reserve(nthreads); - for (size_t threadi = 0; threadi < nthreads; ++threadi) { + for (std::size_t threadi = 0; threadi < nthreads; ++threadi) { const UT start = threadi * step; const UT stop = (threadi == nthreads - 1) ? (std::numeric_limits::max)() : start + step; // std::cout << "thread i=" << threadi << " goes from " << start << " to " << stop << '\n'; diff --git a/fuzzing/json_exhaustive_roundtrip_int.cpp b/fuzzing/json_exhaustive_roundtrip_int.cpp index 1ddc7d41d1..8cf661c682 100644 --- a/fuzzing/json_exhaustive_roundtrip_int.cpp +++ b/fuzzing/json_exhaustive_roundtrip_int.cpp @@ -89,7 +89,7 @@ void test() // can't use jthread, does not exist in all stdlibs. std::vector threads; threads.reserve(nthreads); - for (size_t threadi = 0; threadi < nthreads; ++threadi) { + for (std::size_t threadi = 0; threadi < nthreads; ++threadi) { const UT start = threadi * step; const UT stop = (threadi == nthreads - 1) ? (std::numeric_limits::max)() : start + step; // std::cout << "thread i=" << threadi << " goes from " << start << " to " << stop << '\n'; diff --git a/fuzzing/json_generic.cpp b/fuzzing/json_generic.cpp index 696949ae0e..0ce0d22caa 100644 --- a/fuzzing/json_generic.cpp +++ b/fuzzing/json_generic.cpp @@ -3,7 +3,7 @@ #include #include -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { // non-null terminated { diff --git a/fuzzing/json_jmespath.cpp b/fuzzing/json_jmespath.cpp index efe874ec96..34147ef568 100644 --- a/fuzzing/json_jmespath.cpp +++ b/fuzzing/json_jmespath.cpp @@ -34,7 +34,7 @@ namespace } } -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { constexpr auto bytes_used_for_nullterm = 1; constexpr auto bytes_used_for_size = 2; @@ -44,7 +44,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) Data += bytes_used_for_nullterm; Size -= bytes_used_for_nullterm; - const auto pathsize = std::min(Size - bytes_used_for_size, size_t{Data[0]} + (Data[1] << 8)); + const auto pathsize = std::min(Size - bytes_used_for_size, std::size_t{Data[0]} + (Data[1] << 8)); Data += bytes_used_for_size; Size -= bytes_used_for_size; diff --git a/fuzzing/json_minify.cpp b/fuzzing/json_minify.cpp index 2fd454165b..8eaf17db1d 100644 --- a/fuzzing/json_minify.cpp +++ b/fuzzing/json_minify.cpp @@ -3,7 +3,7 @@ #include #include -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { // use a vector with null termination instead of a std::string to avoid // small string optimization to hide bounds problems diff --git a/fuzzing/json_prettify.cpp b/fuzzing/json_prettify.cpp index a53c6a4627..1eb515e891 100644 --- a/fuzzing/json_prettify.cpp +++ b/fuzzing/json_prettify.cpp @@ -3,7 +3,7 @@ #include #include -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { // use a vector with null termination instead of a std::string to avoid // small string optimization to hide bounds problems diff --git a/fuzzing/json_reflection.cpp b/fuzzing/json_reflection.cpp index d9bc66c9a0..948fe54593 100644 --- a/fuzzing/json_reflection.cpp +++ b/fuzzing/json_reflection.cpp @@ -9,10 +9,10 @@ struct my_struct int i = 287; double d = 3.14; std::string hello = "Hello World"; - std::array arr = {1, 2, 3}; + std::array arr = {1, 2, 3}; }; -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { // use a vector with null termination instead of a std::string to avoid // small string optimization to hide bounds problems diff --git a/fuzzing/json_roundtrip_floating.cpp b/fuzzing/json_roundtrip_floating.cpp index 540abe5632..dc793da75e 100644 --- a/fuzzing/json_roundtrip_floating.cpp +++ b/fuzzing/json_roundtrip_floating.cpp @@ -14,7 +14,7 @@ struct Value }; template -void test(const uint8_t* Data, size_t Size) +void test(const uint8_t* Data, std::size_t Size) { using S = Value; S s{}; @@ -33,7 +33,7 @@ void test(const uint8_t* Data, size_t Size) } } -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { if (Size < 1 + sizeof(float)) { return 0; diff --git a/fuzzing/json_roundtrip_int.cpp b/fuzzing/json_roundtrip_int.cpp index 64f4a55c73..5c2ad07352 100644 --- a/fuzzing/json_roundtrip_int.cpp +++ b/fuzzing/json_roundtrip_int.cpp @@ -13,7 +13,7 @@ struct Value }; template -void test(const uint8_t* Data, size_t Size) +void test(const uint8_t* Data, std::size_t Size) { using S = Value; S s{}; @@ -43,7 +43,7 @@ void test(const uint8_t* Data, size_t Size) } } -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { if (Size < 2) { return 0; diff --git a/fuzzing/json_roundtrip_string.cpp b/fuzzing/json_roundtrip_string.cpp index bc99495aea..cf62a10fdf 100644 --- a/fuzzing/json_roundtrip_string.cpp +++ b/fuzzing/json_roundtrip_string.cpp @@ -11,7 +11,7 @@ struct S std::string value{}; }; -void test(const uint8_t* Data, size_t Size) +void test(const uint8_t* Data, std::size_t Size) { S s{{Data, Data + Size}}; @@ -31,7 +31,7 @@ void test(const uint8_t* Data, size_t Size) assert(restored.value().value == s.value); } -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { test(Data, Size); return 0; diff --git a/fuzzing/json_with_comments.cpp b/fuzzing/json_with_comments.cpp index 03563a8bc2..e4159ee253 100644 --- a/fuzzing/json_with_comments.cpp +++ b/fuzzing/json_with_comments.cpp @@ -9,10 +9,10 @@ struct my_struct int i = 287; double d = 3.14; std::string hello = "Hello World"; - std::array arr = {1, 2, 3}; + std::array arr = {1, 2, 3}; }; -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { // use a vector with null termination instead of a std::string to avoid // small string optimization to hide bounds problems diff --git a/fuzzing/main.cpp b/fuzzing/main.cpp index 82ec8c0386..47ce7703ff 100644 --- a/fuzzing/main.cpp +++ b/fuzzing/main.cpp @@ -11,7 +11,7 @@ * and feeding it to a program with this main function. */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size); +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size); void handle_file(std::filesystem::path file) { diff --git a/fuzzing/msgpack_reflection.cpp b/fuzzing/msgpack_reflection.cpp index 9cfa203c19..75bddfbce2 100644 --- a/fuzzing/msgpack_reflection.cpp +++ b/fuzzing/msgpack_reflection.cpp @@ -10,10 +10,10 @@ struct my_struct int i = 287; double d = 3.14; std::string hello = "Hello World"; - std::array arr = {1, 2, 3}; + std::array arr = {1, 2, 3}; }; -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { // use a vector with null termination instead of a std::string to avoid // small string optimization to hide bounds problems diff --git a/fuzzing/msgpack_roundtrip_floating.cpp b/fuzzing/msgpack_roundtrip_floating.cpp index 7f532f6296..d166947edd 100644 --- a/fuzzing/msgpack_roundtrip_floating.cpp +++ b/fuzzing/msgpack_roundtrip_floating.cpp @@ -15,7 +15,7 @@ struct Value }; template -void test(const uint8_t* Data, size_t Size) +void test(const uint8_t* Data, std::size_t Size) { using S = Value; S s{}; @@ -48,7 +48,7 @@ void test(const uint8_t* Data, size_t Size) } } -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { if (Size < 1 + sizeof(float)) { return 0; diff --git a/fuzzing/msgpack_roundtrip_int.cpp b/fuzzing/msgpack_roundtrip_int.cpp index 6bbd26b139..84a0bac2e5 100644 --- a/fuzzing/msgpack_roundtrip_int.cpp +++ b/fuzzing/msgpack_roundtrip_int.cpp @@ -14,7 +14,7 @@ struct Value }; template -void test(const uint8_t* Data, size_t Size) +void test(const uint8_t* Data, std::size_t Size) { using S = Value; S s{}; @@ -35,7 +35,7 @@ void test(const uint8_t* Data, size_t Size) assert(restored.value().value == s.value); } -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { if (Size < 2) { return 0; diff --git a/fuzzing/msgpack_roundtrip_string.cpp b/fuzzing/msgpack_roundtrip_string.cpp index c06d9616e5..968cb1e12b 100644 --- a/fuzzing/msgpack_roundtrip_string.cpp +++ b/fuzzing/msgpack_roundtrip_string.cpp @@ -11,7 +11,7 @@ struct S std::string value{}; }; -void test(const uint8_t* Data, size_t Size) +void test(const uint8_t* Data, std::size_t Size) { S s{{Data, Data + Size}}; @@ -26,7 +26,7 @@ void test(const uint8_t* Data, size_t Size) assert(restored.value().value == s.value); } -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size) { test(Data, Size); return 0; diff --git a/include/glaze/api/std/deque.hpp b/include/glaze/api/std/deque.hpp deleted file mode 100644 index 5d30132ca2..0000000000 --- a/include/glaze/api/std/deque.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// Glaze Library -// For the license information refer to glaze.hpp - -#pragma once - -#include - -#include "glaze/core/meta.hpp" - -namespace glz -{ - template - struct meta> - { - static constexpr std::string_view name = join_v, name_v, chars<">">>; - }; -} diff --git a/include/glaze/api/std/list.hpp b/include/glaze/api/std/list.hpp deleted file mode 100644 index 842bb25b91..0000000000 --- a/include/glaze/api/std/list.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// Glaze Library -// For the license information refer to glaze.hpp - -#pragma once - -#include - -#include "glaze/core/meta.hpp" - -namespace glz -{ - template - struct meta> - { - static constexpr std::string_view name = join_v, name_v, chars<">">>; - }; -} diff --git a/include/glaze/api/std/map.hpp b/include/glaze/api/std/map.hpp deleted file mode 100644 index fe643e3fb8..0000000000 --- a/include/glaze/api/std/map.hpp +++ /dev/null @@ -1,18 +0,0 @@ -// Glaze Library -// For the license information refer to glaze.hpp - -#pragma once - -#include - -#include "glaze/core/meta.hpp" - -namespace glz -{ - template - struct meta> - { - static constexpr std::string_view name = - join_v, name_v, chars<",">, name_v, chars<">">>; - }; -} diff --git a/include/glaze/api/std/optional.hpp b/include/glaze/api/std/optional.hpp deleted file mode 100644 index 219acba3ea..0000000000 --- a/include/glaze/api/std/optional.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// Glaze Library -// For the license information refer to glaze.hpp - -#pragma once - -#include - -#include "glaze/core/meta.hpp" - -namespace glz -{ - template - struct meta> - { - static constexpr std::string_view name = join_v, name_v, chars<">">>; - }; -} diff --git a/include/glaze/api/std/set.hpp b/include/glaze/api/std/set.hpp deleted file mode 100644 index 7a1fef65cf..0000000000 --- a/include/glaze/api/std/set.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// Glaze Library -// For the license information refer to glaze.hpp - -#pragma once - -#include - -#include "glaze/core/meta.hpp" - -namespace glz -{ - template - struct meta> - { - static constexpr std::string_view name = join_v, name_v, chars<">">>; - }; -} diff --git a/include/glaze/api/std/shared_ptr.hpp b/include/glaze/api/std/shared_ptr.hpp deleted file mode 100644 index 0029dfc46d..0000000000 --- a/include/glaze/api/std/shared_ptr.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// Glaze Library -// For the license information refer to glaze.hpp - -#pragma once - -#include - -#include "glaze/core/meta.hpp" - -namespace glz -{ - template - struct meta> - { - static constexpr std::string_view name = join_v, name_v, chars<">">>; - }; -} diff --git a/include/glaze/api/std/string.hpp b/include/glaze/api/std/string.hpp deleted file mode 100644 index 6dab83f468..0000000000 --- a/include/glaze/api/std/string.hpp +++ /dev/null @@ -1,18 +0,0 @@ -// Glaze Library -// For the license information refer to glaze.hpp - -#pragma once - -#include -#include - -#include "glaze/core/meta.hpp" - -namespace glz -{ - template <> - struct meta - { - static constexpr std::string_view name = "std::string"; - }; -} diff --git a/include/glaze/api/std/tuple.hpp b/include/glaze/api/std/tuple.hpp deleted file mode 100644 index 28c3140a2c..0000000000 --- a/include/glaze/api/std/tuple.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// Glaze Library -// For the license information refer to glaze.hpp - -#pragma once - -#include - -#include "glaze/core/meta.hpp" - -namespace glz -{ - template - struct meta> - { - static constexpr std::string_view name = [](std::index_sequence) { - return join_v, - ((I != sizeof...(T) - 1) ? join_v, chars<",">> : join_v>)..., chars<">">>; - }(std::make_index_sequence{}); - }; -} diff --git a/include/glaze/api/std/unique_ptr.hpp b/include/glaze/api/std/unique_ptr.hpp deleted file mode 100644 index 616feb693f..0000000000 --- a/include/glaze/api/std/unique_ptr.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// Glaze Library -// For the license information refer to glaze.hpp - -#pragma once - -#include - -#include "glaze/core/meta.hpp" - -namespace glz -{ - template - struct meta> - { - static constexpr std::string_view name = join_v, name_v, chars<">">>; - }; -} diff --git a/include/glaze/api/std/unordered_set.hpp b/include/glaze/api/std/unordered_set.hpp deleted file mode 100644 index 13b4bf6e7f..0000000000 --- a/include/glaze/api/std/unordered_set.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// Glaze Library -// For the license information refer to glaze.hpp - -#pragma once - -#include - -#include "glaze/core/meta.hpp" - -namespace glz -{ - template - struct meta> - { - static constexpr std::string_view name = join_v, name_v, chars<">">>; - }; -} diff --git a/include/glaze/api/std/vector.hpp b/include/glaze/api/std/vector.hpp deleted file mode 100644 index 1d5463655d..0000000000 --- a/include/glaze/api/std/vector.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// Glaze Library -// For the license information refer to glaze.hpp - -#pragma once - -#include - -#include "glaze/core/meta.hpp" - -namespace glz -{ - template - struct meta> - { - static constexpr std::string_view name = join_v, name_v, chars<">">>; - }; -} diff --git a/include/glaze/api/xxh64.hpp b/include/glaze/api/xxh64.hpp deleted file mode 100644 index 80555e5508..0000000000 --- a/include/glaze/api/xxh64.hpp +++ /dev/null @@ -1,99 +0,0 @@ -// Glaze Library -// For the license information refer to glaze.hpp - -// Copyright (c) 2015 Daniel Kirchner -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#pragma once - -#include - -// https://github.com/Cyan4973/xxHash -// http://cyan4973.github.io/xxHash/ - -struct xxh64 -{ - static constexpr uint64_t hash(const char* p, uint64_t len, uint64_t seed) - { - return finalize((len >= 32 ? h32bytes(p, len, seed) : seed + PRIME5) + len, p + (len & ~0x1F), len & 0x1F); - } - - private: - static constexpr uint64_t PRIME1 = 11400714785074694791ULL; - static constexpr uint64_t PRIME2 = 14029467366897019727ULL; - static constexpr uint64_t PRIME3 = 1609587929392839161ULL; - static constexpr uint64_t PRIME4 = 9650029242287828579ULL; - static constexpr uint64_t PRIME5 = 2870177450012600261ULL; - - static constexpr uint64_t rotl(uint64_t x, int r) { return ((x << r) | (x >> (64 - r))); } - static constexpr uint64_t mix1(const uint64_t h, const uint64_t prime, int rshift) - { - return (h ^ (h >> rshift)) * prime; - } - static constexpr uint64_t mix2(const uint64_t p, const uint64_t v = 0) { return rotl(v + p * PRIME2, 31) * PRIME1; } - static constexpr uint64_t mix3(const uint64_t h, const uint64_t v) { return (h ^ mix2(v)) * PRIME1 + PRIME4; } -#ifdef XXH64_BIG_ENDIAN - static constexpr uint32_t endian32(const char* v) - { - return uint32_t(uint8_t(v[3])) | (uint32_t(uint8_t(v[2])) << 8) | (uint32_t(uint8_t(v[1])) << 16) | - (uint32_t(uint8_t(v[0])) << 24); - } - static constexpr uint64_t endian64(const char* v) - { - return uint64_t(uint8_t(v[7])) | (uint64_t(uint8_t(v[6])) << 8) | (uint64_t(uint8_t(v[5])) << 16) | - (uint64_t(uint8_t(v[4])) << 24) | (uint64_t(uint8_t(v[3])) << 32) | (uint64_t(uint8_t(v[2])) << 40) | - (uint64_t(uint8_t(v[1])) << 48) | (uint64_t(uint8_t(v[0])) << 56); - } -#else - static constexpr uint32_t endian32(const char* v) - { - return uint32_t(uint8_t(v[0])) | (uint32_t(uint8_t(v[1])) << 8) | (uint32_t(uint8_t(v[2])) << 16) | - (uint32_t(uint8_t(v[3])) << 24); - } - static constexpr uint64_t endian64(const char* v) - { - return uint64_t(uint8_t(v[0])) | (uint64_t(uint8_t(v[1])) << 8) | (uint64_t(uint8_t(v[2])) << 16) | - (uint64_t(uint8_t(v[3])) << 24) | (uint64_t(uint8_t(v[4])) << 32) | (uint64_t(uint8_t(v[5])) << 40) | - (uint64_t(uint8_t(v[6])) << 48) | (uint64_t(uint8_t(v[7])) << 56); - } -#endif - static constexpr uint64_t fetch64(const char* p, const uint64_t v = 0) { return mix2(endian64(p), v); } - static constexpr uint64_t fetch32(const char* p) { return uint64_t(endian32(p)) * PRIME1; } - static constexpr uint64_t fetch8(const char* p) { return uint8_t(*p) * PRIME5; } - static constexpr uint64_t finalize(const uint64_t h, const char* p, uint64_t len) - { - return (len >= 8) ? (finalize(rotl(h ^ fetch64(p), 27) * PRIME1 + PRIME4, p + 8, len - 8)) - : ((len >= 4) ? (finalize(rotl(h ^ fetch32(p), 23) * PRIME2 + PRIME3, p + 4, len - 4)) - : ((len > 0) ? (finalize(rotl(h ^ fetch8(p), 11) * PRIME1, p + 1, len - 1)) - : (mix1(mix1(mix1(h, PRIME2, 33), PRIME3, 29), 1, 32)))); - } - static constexpr uint64_t h32bytes(const char* p, uint64_t len, const uint64_t v1, const uint64_t v2, - const uint64_t v3, const uint64_t v4) - { - return (len >= 32) - ? h32bytes(p + 32, len - 32, fetch64(p, v1), fetch64(p + 8, v2), fetch64(p + 16, v3), - fetch64(p + 24, v4)) - : mix3(mix3(mix3(mix3(rotl(v1, 1) + rotl(v2, 7) + rotl(v3, 12) + rotl(v4, 18), v1), v2), v3), v4); - } - static constexpr uint64_t h32bytes(const char* p, uint64_t len, const uint64_t seed) - { - return h32bytes(p, len, seed + PRIME1 + PRIME2, seed + PRIME2, seed, seed - PRIME1); - } -}; diff --git a/include/glaze/cbor.hpp b/include/glaze/cbor.hpp deleted file mode 100644 index edfabc0425..0000000000 --- a/include/glaze/cbor.hpp +++ /dev/null @@ -1,11 +0,0 @@ -// Glaze Library -// For the license information refer to glaze.hpp - -#pragma once - -#include "glaze/cbor/cbor_to_json.hpp" -#include "glaze/cbor/header.hpp" -#include "glaze/cbor/read.hpp" -#include "glaze/cbor/wrappers.hpp" -#include "glaze/cbor/write.hpp" -#include "glaze/core/wrapper_traits.hpp" diff --git a/include/glaze/core/wrapper_traits.hpp b/include/glaze/core/wrapper_traits.hpp deleted file mode 100644 index d11b5759ed..0000000000 --- a/include/glaze/core/wrapper_traits.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -// Glaze Library -// For the license information refer to glaze.hpp - -#include "glaze/core/constraint.hpp" -#include "glaze/core/wrappers.hpp" diff --git a/include/glaze/csv.hpp b/include/glaze/csv.hpp deleted file mode 100644 index bd92a5d402..0000000000 --- a/include/glaze/csv.hpp +++ /dev/null @@ -1,11 +0,0 @@ -// Glaze Library -// For the license information refer to glaze.hpp - -#pragma once - -#include "glaze/core/as_array_wrapper.hpp" -#include "glaze/core/wrapper_traits.hpp" -#include "glaze/csv/read.hpp" -#include "glaze/csv/skip.hpp" -#include "glaze/csv/write.hpp" -#include "glaze/thread/atomic.hpp" diff --git a/include/glaze/json.hpp b/include/glaze/json.hpp deleted file mode 100644 index 5967ecfac2..0000000000 --- a/include/glaze/json.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// Glaze Library -// For the license information refer to glaze.hpp - -#pragma once - -#include "glaze/core/as_array_wrapper.hpp" -#include "glaze/core/istream_buffer.hpp" -#include "glaze/core/manage.hpp" -#include "glaze/core/wrapper_traits.hpp" -#include "glaze/json/escape_unicode.hpp" -#include "glaze/json/float_format.hpp" -#include "glaze/json/generic.hpp" -#include "glaze/json/invoke.hpp" -#include "glaze/json/jmespath.hpp" -#include "glaze/json/json_concepts.hpp" -#include "glaze/json/json_ptr.hpp" -#include "glaze/json/json_stream.hpp" -#include "glaze/json/lazy.hpp" -#include "glaze/json/max_write_precision.hpp" -#include "glaze/json/minify.hpp" -#include "glaze/json/ndjson.hpp" -#include "glaze/json/prettify.hpp" -#include "glaze/json/ptr.hpp" -#include "glaze/json/raw_string.hpp" -#include "glaze/json/read.hpp" -#include "glaze/json/schema.hpp" -#include "glaze/json/wrappers.hpp" -#include "glaze/json/write.hpp" -#include "glaze/thread/atomic.hpp" diff --git a/include/glaze/util/convert.hpp b/include/glaze/util/convert.hpp deleted file mode 100644 index bc4dbff346..0000000000 --- a/include/glaze/util/convert.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Glaze Library -// For the license information refer to glaze.hpp - -#pragma once - -#include -#include - -namespace glz -{ - // Creates a uint16_t from two chars that matches memcpy behavior on any endianness - consteval uint16_t to_uint16_t(const char chars[2]) - { - if constexpr (std::endian::native == std::endian::little) { - return uint16_t(chars[0]) | (uint16_t(chars[1]) << 8); - } - else { - return (uint16_t(chars[0]) << 8) | uint16_t(chars[1]); - } - } -} diff --git a/include/glaze/api/api.hpp b/modules/glaze/api/api.ixx similarity index 88% rename from include/glaze/api/api.hpp rename to modules/glaze/api/api.ixx index 1e6690f67f..ecf878d437 100644 --- a/include/glaze/api/api.hpp +++ b/modules/glaze/api/api.ixx @@ -1,21 +1,21 @@ // Glaze Library -// For the license information refer to glaze.hpp +// For the license information refer to glaze.ixx +export module glaze.api.api; -#pragma once +import glaze.api.trait; -#include -#include -#include -#include -#include +import std; -#include "glaze/api/std/string.hpp" -#include "glaze/api/trait.hpp" -#include "glaze/core/context.hpp" -#include "glaze/core/opts.hpp" -#include "glaze/util/expected.hpp" +import glaze.api.std.string; -namespace glz +import glaze.core.context; +import glaze.core.opts; + +import glaze.util.expected; +import glaze.util.for_each; +import glaze.util.string_literal; + +export namespace glz { inline namespace v0_0_3 { @@ -44,9 +44,9 @@ namespace glz [[nodiscard]] virtual bool contains(const sv path) noexcept = 0; - virtual bool read(const uint32_t /*format*/, const sv /*path*/, const sv /*data*/) noexcept = 0; + virtual bool read(const std::uint32_t /*format*/, const sv /*path*/, const sv /*data*/) noexcept = 0; - virtual bool write(const uint32_t /*format*/, const sv /*path*/, std::string& /*data*/) noexcept = 0; + virtual bool write(const std::uint32_t /*format*/, const sv /*path*/, std::string& /*data*/) noexcept = 0; [[nodiscard]] virtual const sv last_error() const noexcept { return error; } diff --git a/include/glaze/api/hash.hpp b/modules/glaze/api/hash.ixx similarity index 74% rename from include/glaze/api/hash.hpp rename to modules/glaze/api/hash.ixx index 09c220c95f..b2d25590a3 100644 --- a/include/glaze/api/hash.hpp +++ b/modules/glaze/api/hash.ixx @@ -1,12 +1,14 @@ // Glaze Library -// For the license information refer to glaze.hpp +// For the license information refer to glaze.ixx +export module glaze.api.hash; -#pragma once +import std; -#include +import glaze.api.xxh64; -#include "glaze/api/xxh64.hpp" -#include "glaze/core/meta.hpp" +import glaze.core.meta; + +import glaze.util.string_literal; // Collision calculations done with the formula: e^((-k * (k - 1)/(2 * N))) // The approximation error tends to zero as N increases, and we are dealing with a large N @@ -20,13 +22,13 @@ // bit: 1220 times 128 bit: 2.2494655e22 times (or 22 sextillion times) 256 bit: 7.6545351e60 times From these // calculations it is apparent that a 128 bit hash is more than sufficient -namespace glz +export namespace glz { template consteval auto make_array() { - return [](std::index_sequence) { - return std::array{static_cast(((Value >> (CHAR_BIT * I)) & 0xff))...}; + return [](std::index_sequence) { + return std::array{static_cast(((Value >> (std::numeric_limits::digits * I)) & 0xff))...}; }(std::make_index_sequence{}); } @@ -34,7 +36,7 @@ namespace glz { // convert an integer to a string_view at compile time - constexpr uint64_t num_digits(auto x) noexcept // number of digits needed, including minus sign + constexpr std::uint64_t num_digits(auto x) noexcept // number of digits needed, including minus sign { return x < 10 ? 1 : 1 + num_digits(x / 10); } @@ -46,28 +48,28 @@ namespace glz }; // recursive number-printing template, general case (for three or more digits) - template + template struct numeric_builder { using type = typename numeric_builder::type; }; // special case for two digits; minus sign is handled here - template + template struct numeric_builder<2, x, args...> { using type = metastring<'0' + x / 10, '0' + x % 10, args...>; }; // special case for one digit (positive numbers only) - template + template struct numeric_builder<1, x, args...> { using type = metastring<'0' + x, args...>; }; // convenience wrapper for numeric_builder - template + template struct numeric_string { // generate a unique string type representing this number @@ -89,29 +91,29 @@ namespace glz template inline constexpr std::string_view int_to_sv_v = int_to_sv{}.get(); - template + template inline consteval auto to_sv() { return detail::numeric_string::get(); } - template + template struct hash128_i { static constexpr sv str = to_sv(); - static constexpr sv h0 = int_to_sv_v; - static constexpr sv h1 = int_to_sv_v; + static constexpr sv h0 = int_to_sv_v; + static constexpr sv h1 = int_to_sv_v; static constexpr sv value = join_v; }; - template + template inline constexpr std::string_view hash128_i_v = hash128_i::value; template struct hash128 { - static constexpr sv h0 = int_to_sv_v; - static constexpr sv h1 = int_to_sv_v; + static constexpr sv h0 = int_to_sv_v; + static constexpr sv h1 = int_to_sv_v; static constexpr sv value = join_v; }; diff --git a/include/glaze/api/impl.hpp b/modules/glaze/api/impl.ixx similarity index 89% rename from include/glaze/api/impl.hpp rename to modules/glaze/api/impl.ixx index 1422f17f71..c1482ce361 100644 --- a/include/glaze/api/impl.hpp +++ b/modules/glaze/api/impl.ixx @@ -1,29 +1,49 @@ // Glaze Library -// For the license information refer to glaze.hpp - -#pragma once - -#include "glaze/api/api.hpp" -#include "glaze/api/std/array.hpp" -#include "glaze/api/std/deque.hpp" -#include "glaze/api/std/functional.hpp" -#include "glaze/api/std/list.hpp" -#include "glaze/api/std/map.hpp" -#include "glaze/api/std/optional.hpp" -#include "glaze/api/std/shared_ptr.hpp" -#include "glaze/api/std/string.hpp" -#include "glaze/api/std/tuple.hpp" -#include "glaze/api/std/unique_ptr.hpp" -#include "glaze/api/std/unordered_map.hpp" -#include "glaze/api/std/variant.hpp" -#include "glaze/api/std/vector.hpp" -#include "glaze/api/tuplet.hpp" -#include "glaze/api/type_support.hpp" -#include "glaze/beve/read.hpp" -#include "glaze/beve/write.hpp" -#include "glaze/glaze.hpp" -#include "glaze/json/read.hpp" -#include "glaze/json/write.hpp" +// For the license information refer to glaze.ixx +export module glaze.api.impl; + +import std; + +import glaze.api.api; +import glaze.api.tuplet; +import glaze.api.type_support; +import glaze.api.trait; + +import glaze.api.std.array; +import glaze.api.std.deque; +import glaze.api.std.functional; +import glaze.api.std.list; +import glaze.api.std.map; +import glaze.api.std.optional; +import glaze.api.std.shared_ptr; +import glaze.api.std.string; +import glaze.api.std.tuple; +import glaze.api.std.unique_ptr; +import glaze.api.std.unordered_map; +import glaze.api.std.variant; +import glaze.api.std.vector; + +import glaze.beve.read; +import glaze.beve.write; + +import glaze.json.read; +import glaze.json.write; + +import glaze.core.read; +import glaze.core.seek; +import glaze.core.common; +import glaze.core.context; +import glaze.core.opts; +import glaze.core.meta; + +import glaze.util.type_traits; +import glaze.util.tuple; + +import glaze.tuplet; + +import glaze; + +import glaze.util.string_literal; namespace glz { @@ -39,7 +59,7 @@ namespace glz return seek([&](auto&&) {}, user, path); } - bool read(const uint32_t format, const sv path, const sv data) noexcept override + bool read(const std::uint32_t format, const sv path, const sv data) noexcept override { error_ctx pe{}; bool success; @@ -60,7 +80,7 @@ namespace glz return false; } - bool write(const uint32_t format, const sv path, std::string& data) noexcept override + bool write(const std::uint32_t format, const sv path, std::string& data) noexcept override { // TODO: Support write errors when seeking if (format == JSON) { @@ -89,7 +109,7 @@ namespace glz return static_cast(*reinterpret_cast>>(t)); } - template + template requires std::invocable>...> decltype(auto) call_args(F&& f, Parent&& parent, [[maybe_unused]] std::span args, std::index_sequence) diff --git a/include/glaze/api/lib.hpp b/modules/glaze/api/lib.hpp similarity index 100% rename from include/glaze/api/lib.hpp rename to modules/glaze/api/lib.hpp diff --git a/include/glaze/api/std/array.hpp b/modules/glaze/api/std/array.ixx similarity index 76% rename from include/glaze/api/std/array.hpp rename to modules/glaze/api/std/array.ixx index 0409491062..8d0d0d6de0 100644 --- a/include/glaze/api/std/array.hpp +++ b/modules/glaze/api/std/array.ixx @@ -1,13 +1,13 @@ // Glaze Library -// For the license information refer to glaze.hpp +// For the license information refer to glaze.ixx +export module glaze.api.std.array; -#pragma once +import std; -#include +import glaze.core.meta; +import glaze.util.string_literal; -#include "glaze/core/meta.hpp" - -namespace glz +export namespace glz { namespace detail { @@ -30,7 +30,7 @@ namespace glz struct num_to_string : detail::explode {}; - template + template struct meta> { static constexpr std::string_view name = diff --git a/modules/glaze/api/std/deque.ixx b/modules/glaze/api/std/deque.ixx new file mode 100644 index 0000000000..9c6563f8a9 --- /dev/null +++ b/modules/glaze/api/std/deque.ixx @@ -0,0 +1,17 @@ +// Glaze Library +// For the license information refer to glaze.ixx +export module glaze.api.std.deque; + +import std; + +import glaze.core.meta; +import glaze.util.string_literal; + +export namespace glz +{ + template + struct meta> + { + static constexpr std::string_view name = join_v, name_v, chars<">">>; + }; +} diff --git a/include/glaze/api/std/functional.hpp b/modules/glaze/api/std/functional.ixx similarity index 81% rename from include/glaze/api/std/functional.hpp rename to modules/glaze/api/std/functional.ixx index adf3046b01..7713507d80 100644 --- a/include/glaze/api/std/functional.hpp +++ b/modules/glaze/api/std/functional.ixx @@ -1,18 +1,20 @@ // Glaze Library -// For the license information refer to glaze.hpp +// For the license information refer to glaze.ixx +export module glaze.api.std.functional; -#pragma once +import std; -#include +import glaze.core.common; +import glaze.core.meta; +import glaze.tuplet; +import glaze.util.string_literal; +import glaze.util.type_traits; -#include "glaze/core/common.hpp" -#include "glaze/core/meta.hpp" - -namespace glz +export namespace glz { namespace detail { - template + template struct expander { static constexpr auto impl() noexcept @@ -36,10 +38,10 @@ namespace glz constexpr std::string_view expander_v = expander::value; } - template + template concept function = is_specialization_v; - template + template struct meta { static constexpr auto impl() noexcept diff --git a/modules/glaze/api/std/list.ixx b/modules/glaze/api/std/list.ixx new file mode 100644 index 0000000000..dd024dfe2f --- /dev/null +++ b/modules/glaze/api/std/list.ixx @@ -0,0 +1,17 @@ +// Glaze Library +// For the license information refer to glaze.ixx +export module glaze.api.std.list; + +import std; + +import glaze.core.meta; +import glaze.util.string_literal; + +export namespace glz +{ + template + struct meta> + { + static constexpr std::string_view name = join_v, name_v, chars<">">>; + }; +} diff --git a/modules/glaze/api/std/map.ixx b/modules/glaze/api/std/map.ixx new file mode 100644 index 0000000000..75630516de --- /dev/null +++ b/modules/glaze/api/std/map.ixx @@ -0,0 +1,18 @@ +// Glaze Library +// For the license information refer to glaze.ixx +export module glaze.api.std.map; + +import std; + +import glaze.core.meta; +import glaze.util.string_literal; + +export namespace glz +{ + template + struct meta> + { + static constexpr std::string_view name = + join_v, name_v, chars<",">, name_v, chars<">">>; + }; +} diff --git a/modules/glaze/api/std/optional.ixx b/modules/glaze/api/std/optional.ixx new file mode 100644 index 0000000000..faf6a44c9f --- /dev/null +++ b/modules/glaze/api/std/optional.ixx @@ -0,0 +1,17 @@ +// Glaze Library +// For the license information refer to glaze.ixx +export module glaze.api.std.optional; + +import std; + +import glaze.core.meta; +import glaze.util.string_literal; + +export namespace glz +{ + template + struct meta> + { + static constexpr std::string_view name = join_v, name_v, chars<">">>; + }; +} diff --git a/modules/glaze/api/std/set.ixx b/modules/glaze/api/std/set.ixx new file mode 100644 index 0000000000..6d50dea630 --- /dev/null +++ b/modules/glaze/api/std/set.ixx @@ -0,0 +1,17 @@ +// Glaze Library +// For the license information refer to glaze.ixx +export module glaze.api.std.set; + +import std; + +import glaze.core.meta; +import glaze.util.string_literal; + +export namespace glz +{ + template + struct meta> + { + static constexpr std::string_view name = join_v, name_v, chars<">">>; + }; +} diff --git a/modules/glaze/api/std/shared_ptr.ixx b/modules/glaze/api/std/shared_ptr.ixx new file mode 100644 index 0000000000..e42fb61dc2 --- /dev/null +++ b/modules/glaze/api/std/shared_ptr.ixx @@ -0,0 +1,17 @@ +// Glaze Library +// For the license information refer to glaze.ixx +export module glaze.api.std.shared_ptr; + +import std; + +import glaze.core.meta; +import glaze.util.string_literal; + +export namespace glz +{ + template + struct meta> + { + static constexpr std::string_view name = join_v, name_v, chars<">">>; + }; +} diff --git a/include/glaze/api/std/span.hpp b/modules/glaze/api/std/span.ixx similarity index 53% rename from include/glaze/api/std/span.hpp rename to modules/glaze/api/std/span.ixx index 5fc5866262..91509bc447 100644 --- a/include/glaze/api/std/span.hpp +++ b/modules/glaze/api/std/span.ixx @@ -1,24 +1,25 @@ // Glaze Library -// For the license information refer to glaze.hpp +// For the license information refer to glaze.ixx +export module glaze.api.std.span; -#pragma once +import std; -#include +import glaze.api.hash; -#include "glaze/api/hash.hpp" -#include "glaze/core/meta.hpp" +import glaze.core.meta; +import glaze.util.string_literal; -namespace glz +export namespace glz { - template class> + template class> inline constexpr bool is_span_v = false; - template