mirror of
https://github.com/nlohmann/json.git
synced 2026-07-12 21:45:10 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a27065bd12 | |||
| 3940f4b730 | |||
| 0663907b68 | |||
| f23b3c63a2 |
@@ -0,0 +1,81 @@
|
|||||||
|
name: "Check API documentation"
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check_api_docs:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Harden Runner
|
||||||
|
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
|
||||||
|
with:
|
||||||
|
egress-policy: audit
|
||||||
|
|
||||||
|
- name: Checkout pull request
|
||||||
|
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||||
|
|
||||||
|
- name: Install clang
|
||||||
|
# Used only as a subprocess for `clang++ -E -v` system-include-path discovery in
|
||||||
|
# extract_api.py; it does not need to version-match the pinned libclang pip wheel
|
||||||
|
# below, which does the actual AST parsing. Do not "fix" this to be version-matched.
|
||||||
|
run: sudo apt-get update && sudo apt-get install -y clang
|
||||||
|
|
||||||
|
- name: Install Python dependencies
|
||||||
|
run: pip install -r tools/api_checker/requirements.txt
|
||||||
|
|
||||||
|
- name: Extract API and regenerate the committed surface file
|
||||||
|
run: |
|
||||||
|
python3 tools/api_checker/extract_api.py \
|
||||||
|
--header include/nlohmann/json.hpp \
|
||||||
|
--include include \
|
||||||
|
--output /tmp/api_snapshot.json \
|
||||||
|
--surface-output tools/api_checker/api_surface.json
|
||||||
|
|
||||||
|
- name: "Check API documentation (Phase 1: advisory)"
|
||||||
|
# Surfaces missing/broken @sa links without failing the job while the backlog from the
|
||||||
|
# initial AST-based rollout is burned down. See tools/api_checker/POLICY.md and the PR
|
||||||
|
# that introduced this workflow for the two-phase rollout plan.
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
python3 tools/api_checker/check_docs.py \
|
||||||
|
--snapshot /tmp/api_snapshot.json
|
||||||
|
|
||||||
|
- name: Check macro documentation (advisory only)
|
||||||
|
# Cross-checks docs/mkdocs/docs/api/macros/ pages against #define sites. Only checks the
|
||||||
|
# documented-macro-still-exists direction; never blocks CI. See POLICY.md.
|
||||||
|
run: python3 tools/api_checker/check_macros.py
|
||||||
|
|
||||||
|
- name: Check for uncommitted API surface changes
|
||||||
|
id: diff
|
||||||
|
run: |
|
||||||
|
mkdir -p ${{ github.workspace }}/patch
|
||||||
|
git diff --patch --no-color -- tools/api_checker/api_surface.json > ${{ github.workspace }}/patch/api_surface.patch
|
||||||
|
if [ -s ${{ github.workspace }}/patch/api_surface.patch ]; then
|
||||||
|
echo "tools/api_checker/api_surface.json is out of date. Diff:"
|
||||||
|
cat ${{ github.workspace }}/patch/api_surface.patch
|
||||||
|
echo "has_diff=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "has_diff=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Uploaded so contributors can fix their PR with `git apply api_surface.patch`
|
||||||
|
# instead of installing libclang locally.
|
||||||
|
- name: Upload patch
|
||||||
|
if: steps.diff.outputs.has_diff == 'true'
|
||||||
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||||
|
with:
|
||||||
|
name: api-surface-patch
|
||||||
|
path: patch/api_surface.patch
|
||||||
|
|
||||||
|
- name: Fail if API surface file is not up to date
|
||||||
|
# Unlike the doc-backlog check above, this is purely mechanical regeneration with no
|
||||||
|
# backlog to phase in -- blocking from the start, matching check_amalgamation.yml's
|
||||||
|
# precedent. Contributors who add/remove/rename public API must regenerate and commit
|
||||||
|
# tools/api_checker/api_surface.json as part of their PR.
|
||||||
|
if: steps.diff.outputs.has_diff == 'true'
|
||||||
|
run: exit 1
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
*.gcno
|
*.gcno
|
||||||
*.gcda
|
*.gcda
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
__pycache__/
|
||||||
|
|
||||||
/.idea
|
/.idea
|
||||||
/cmake-build-*
|
/cmake-build-*
|
||||||
@@ -43,5 +44,9 @@ venv
|
|||||||
|
|
||||||
nlohmann_json.spdx
|
nlohmann_json.spdx
|
||||||
|
|
||||||
|
# api_checker: ephemeral, location/doc-status-sensitive working file (not the committed
|
||||||
|
# release-tracking artifact -- see tools/api_checker/api_surface.json for that)
|
||||||
|
/tools/api_checker/api_snapshot.json
|
||||||
|
|
||||||
# Bazel-related
|
# Bazel-related
|
||||||
MODULE.bazel.lock
|
MODULE.bazel.lock
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ Thanks everyone!
|
|||||||
|
|
||||||
:books: If you want to **learn more** about how to use the library, check out the rest of the [**README**](#examples), have a look at [**code examples**](https://github.com/nlohmann/json/tree/develop/docs/mkdocs/docs/examples), or browse through the [**help pages**](https://json.nlohmann.me).
|
:books: If you want to **learn more** about how to use the library, check out the rest of the [**README**](#examples), have a look at [**code examples**](https://github.com/nlohmann/json/tree/develop/docs/mkdocs/docs/examples), or browse through the [**help pages**](https://json.nlohmann.me).
|
||||||
|
|
||||||
:construction: If you want to understand the **API** better, check out the [**API Reference**](https://json.nlohmann.me/api/basic_json/) or have a look at the [quick reference](#quick-reference) below.
|
:construction: If you want to understand the **API** better, check out the [**API Reference**](https://json.nlohmann.me/api/basic_json/) or have a look at the [quick reference](#quick-reference) below. The public API surface is derived mechanically and checked for documentation coverage by the tooling in [`tools/api_checker/`](tools/api_checker/), whose [POLICY.md](tools/api_checker/POLICY.md) defines what counts as public API and what stability is guaranteed.
|
||||||
|
|
||||||
:bug: If you found a **bug**, please check the [**FAQ**](https://json.nlohmann.me/home/faq/) if it is a known issue or the result of a design decision. Please also have a look at the [**issue list**](https://github.com/nlohmann/json/issues) before you [**create a new issue**](https://github.com/nlohmann/json/issues/new/choose). Please provide as much information as possible to help us understand and reproduce your issue.
|
:bug: If you found a **bug**, please check the [**FAQ**](https://json.nlohmann.me/home/faq/) if it is a known issue or the result of a design decision. Please also have a look at the [**issue list**](https://github.com/nlohmann/json/issues) before you [**create a new issue**](https://github.com/nlohmann/json/issues/new/choose). Please provide as much information as possible to help us understand and reproduce your issue.
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ Unlike the [`parse()`](parse.md) function, this function neither throws an excep
|
|||||||
: defaults to `IteratorType`; may be a different type comparable to `IteratorType` via `operator!=`, for instance.
|
: defaults to `IteratorType`; may be a different type comparable to `IteratorType` via `operator!=`, for instance.
|
||||||
|
|
||||||
- a custom sentinel type for C++20 ranges
|
- a custom sentinel type for C++20 ranges
|
||||||
- `std::default_sentinel_t`, when `IteratorType` is `std::counted_iterator`
|
- `std::counted_iterator` with a different sentinel type
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
|
||||||
|
|||||||
@@ -420,7 +420,9 @@ basic_json(basic_json&& other) noexcept;
|
|||||||
1. Since version 1.0.0.
|
1. Since version 1.0.0.
|
||||||
2. Since version 1.0.0.
|
2. Since version 1.0.0.
|
||||||
3. Since version 2.1.0.
|
3. Since version 2.1.0.
|
||||||
4. Since version 3.2.0.
|
4. Since version 3.2.0. Also initializes the position reported by
|
||||||
|
[`start_pos()`](start_pos.md)/[`end_pos()`](end_pos.md) from `val` when
|
||||||
|
[`JSON_DIAGNOSTIC_POSITIONS`](../macros/json_diagnostic_positions.md) is enabled, since version 3.12.0.
|
||||||
5. Since version 1.0.0.
|
5. Since version 1.0.0.
|
||||||
6. Since version 1.0.0.
|
6. Since version 1.0.0.
|
||||||
7. Since version 1.0.0.
|
7. Since version 1.0.0.
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
# <small>nlohmann::basic_json::</small>bjdata_version_t
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
enum class bjdata_version_t
|
||||||
|
{
|
||||||
|
draft2,
|
||||||
|
draft3,
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
This enumeration is used in the [`to_bjdata`](to_bjdata.md) function to choose which draft version of
|
||||||
|
the BJData specification to encode ND-array extensions for:
|
||||||
|
|
||||||
|
draft2
|
||||||
|
: encode using the BJData Draft 2 ND-array format
|
||||||
|
|
||||||
|
draft3
|
||||||
|
: encode using the BJData Draft 3 ND-array format
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example shows how `bjdata_version_t` selects the BJData draft used by `to_bjdata`.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/bjdata_version_t.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/bjdata_version_t.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.12.0.
|
||||||
@@ -36,10 +36,8 @@ The exact mapping and its limitations are described on a [dedicated page](../../
|
|||||||
: a compatible iterator type
|
: a compatible iterator type
|
||||||
|
|
||||||
`SentinelType`
|
`SentinelType`
|
||||||
: defaults to `IteratorType`; may be a different type comparable to `IteratorType` via `operator!=`, for instance.
|
: defaults to `IteratorType`; may be a different type comparable to `IteratorType` via `operator!=`, for instance a
|
||||||
|
custom sentinel type for C++20 ranges
|
||||||
- a custom sentinel type for C++20 ranges
|
|
||||||
- `std::default_sentinel_t`, when `IteratorType` is `std::counted_iterator`
|
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
|
||||||
|
|||||||
@@ -36,10 +36,8 @@ The exact mapping and its limitations are described on a [dedicated page](../../
|
|||||||
: a compatible iterator type
|
: a compatible iterator type
|
||||||
|
|
||||||
`SentinelType`
|
`SentinelType`
|
||||||
: defaults to `IteratorType`; may be a different type comparable to `IteratorType` via `operator!=`, for instance.
|
: defaults to `IteratorType`; may be a different type comparable to `IteratorType` via `operator!=`, for instance a
|
||||||
|
custom sentinel type for C++20 ranges
|
||||||
- a custom sentinel type for C++20 ranges
|
|
||||||
- `std::default_sentinel_t`, when `IteratorType` is `std::counted_iterator`
|
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
|
||||||
|
|||||||
@@ -39,10 +39,8 @@ The exact mapping and its limitations are described on a [dedicated page](../../
|
|||||||
: a compatible iterator type
|
: a compatible iterator type
|
||||||
|
|
||||||
`SentinelType`
|
`SentinelType`
|
||||||
: defaults to `IteratorType`; may be a different type comparable to `IteratorType` via `operator!=`, for instance.
|
: defaults to `IteratorType`; may be a different type comparable to `IteratorType` via `operator!=`, for instance a
|
||||||
|
custom sentinel type for C++20 ranges
|
||||||
- a custom sentinel type for C++20 ranges
|
|
||||||
- `std::default_sentinel_t`, when `IteratorType` is `std::counted_iterator`
|
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
|
||||||
|
|||||||
@@ -36,10 +36,8 @@ The exact mapping and its limitations are described on a [dedicated page](../../
|
|||||||
: a compatible iterator type
|
: a compatible iterator type
|
||||||
|
|
||||||
`SentinelType`
|
`SentinelType`
|
||||||
: defaults to `IteratorType`; may be a different type comparable to `IteratorType` via `operator!=`, for instance.
|
: defaults to `IteratorType`; may be a different type comparable to `IteratorType` via `operator!=`, for instance a
|
||||||
|
custom sentinel type for C++20 ranges
|
||||||
- a custom sentinel type for C++20 ranges
|
|
||||||
- `std::default_sentinel_t`, when `IteratorType` is `std::counted_iterator`
|
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
|
||||||
|
|||||||
@@ -36,10 +36,8 @@ The exact mapping and its limitations are described on a [dedicated page](../../
|
|||||||
: a compatible iterator type
|
: a compatible iterator type
|
||||||
|
|
||||||
`SentinelType`
|
`SentinelType`
|
||||||
: defaults to `IteratorType`; may be a different type comparable to `IteratorType` via `operator!=`, for instance.
|
: defaults to `IteratorType`; may be a different type comparable to `IteratorType` via `operator!=`, for instance a
|
||||||
|
custom sentinel type for C++20 ranges
|
||||||
- a custom sentinel type for C++20 ranges
|
|
||||||
- `std::default_sentinel_t`, when `IteratorType` is `std::counted_iterator`
|
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# <small>nlohmann::basic_json::</small>initializer_list_t
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
using initializer_list_t = std::initializer_list<detail::json_ref<basic_json>>;
|
||||||
|
```
|
||||||
|
|
||||||
|
The type used for the initializer-list [constructor](basic_json.md) (overload 5) and for functions
|
||||||
|
such as [`operator=`](operator=.md) that accept a braced-init-list of JSON values. Each element wraps a
|
||||||
|
`basic_json` value or something convertible to one, deferring the decision of whether the list should be
|
||||||
|
parsed as a JSON array or a JSON object to the constructor itself.
|
||||||
|
|
||||||
|
See the [constructor](basic_json.md) documentation for how `initializer_list_t` values are interpreted.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example shows how an `initializer_list_t` is used to construct a JSON value.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/initializer_list_t.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/initializer_list_t.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Since version 1.0.0.
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# <small>nlohmann::basic_json::</small>json_sax_t
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
using json_sax_t = json_sax<basic_json>;
|
||||||
|
```
|
||||||
|
|
||||||
|
The [`json_sax`](../json_sax/index.md) interface bound to this `basic_json` specialization, i.e. with
|
||||||
|
`BasicJsonType` fixed to `basic_json`. Used as the SAX interface type by [`sax_parse`](sax_parse.md) and
|
||||||
|
other SAX-based parsing functions.
|
||||||
|
|
||||||
|
See [`nlohmann::json_sax`](../json_sax/index.md) for more information.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example shows the type `json_sax_t`.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/json_sax_t.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/json_sax_t.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.2.0.
|
||||||
@@ -51,3 +51,5 @@ Linear.
|
|||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
- Added in version 1.0.0.
|
- Added in version 1.0.0.
|
||||||
|
- The `noexcept` specification was extended to also depend on
|
||||||
|
[`json_base_class_t`](json_base_class_t.md)'s move-assignment in version 3.11.3.
|
||||||
|
|||||||
@@ -85,3 +85,8 @@ Linear in the size of the JSON value.
|
|||||||
- Since version 1.0.0.
|
- Since version 1.0.0.
|
||||||
- Macros `JSON_EXPLICIT`/[`JSON_USE_IMPLICIT_CONVERSIONS`](../macros/json_use_implicit_conversions.md) added
|
- Macros `JSON_EXPLICIT`/[`JSON_USE_IMPLICIT_CONVERSIONS`](../macros/json_use_implicit_conversions.md) added
|
||||||
in version 3.9.0.
|
in version 3.9.0.
|
||||||
|
- The exclusion of `std::any` from this conversion became conditional on
|
||||||
|
[`JSON_HAS_STATIC_RTTI`](../macros/json_has_static_rtti.md) in version 3.11.3.
|
||||||
|
- `std::optional<T>` excluded from this conversion in version 3.13.0; use
|
||||||
|
[`get<std::optional<T>>()`](get.md)/[`get_to()`](get_to.md) instead (see
|
||||||
|
[Converting values](../../features/conversions.md)).
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ static basic_json parse(IteratorType first, SentinelType last,
|
|||||||
: defaults to `IteratorType`; may be a different type comparable to `IteratorType` via `operator!=`, for instance.
|
: defaults to `IteratorType`; may be a different type comparable to `IteratorType` via `operator!=`, for instance.
|
||||||
|
|
||||||
- a custom sentinel type for C++20 ranges
|
- a custom sentinel type for C++20 ranges
|
||||||
- `std::default_sentinel_t`, when `IteratorType` is `std::counted_iterator`
|
- `std::counted_iterator` with a different sentinel type
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
|
||||||
|
|||||||
@@ -48,10 +48,7 @@ The SAX event lister must follow the interface of [`json_sax`](../json_sax/index
|
|||||||
with a size of 1, 2, or 4 bytes (interpreted respectively as UTF-8, UTF-16, and UTF-32)
|
with a size of 1, 2, or 4 bytes (interpreted respectively as UTF-8, UTF-16, and UTF-32)
|
||||||
|
|
||||||
`SentinelType`
|
`SentinelType`
|
||||||
: defaults to `IteratorType`; may be a different type comparable to `IteratorType` via `operator!=`, for overload (2), for instance.
|
: defaults to `IteratorType`; may be a different type comparable to `IteratorType` via `operator!=`, for overload (2)
|
||||||
|
|
||||||
- a custom sentinel type for C++20 ranges
|
|
||||||
- `std::default_sentinel_t`, when `IteratorType` is `std::counted_iterator`
|
|
||||||
|
|
||||||
`SAX`
|
`SAX`
|
||||||
: a class fulfilling the SAX event listener interface; see [`json_sax`](../json_sax/index.md)
|
: a class fulfilling the SAX event listener interface; see [`json_sax`](../json_sax/index.md)
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# <small>nlohmann::byte_container_with_subtype::</small>container_type
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
using container_type = BinaryType;
|
||||||
|
```
|
||||||
|
|
||||||
|
The type of the underlying binary container, forwarded from the `BinaryType` template parameter that
|
||||||
|
`byte_container_with_subtype` is instantiated with. `byte_container_with_subtype` publicly inherits from
|
||||||
|
`container_type`.
|
||||||
|
|
||||||
|
See [`basic_json::binary_t`](../basic_json/binary_t.md) for the type typically used to instantiate
|
||||||
|
`BinaryType`.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example shows the type `container_type`.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/byte_container_with_subtype__container_type.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/byte_container_with_subtype__container_type.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Since version 3.8.0.
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# <small>nlohmann::byte_container_with_subtype::</small>operator==
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
bool operator==(const byte_container_with_subtype& rhs) const;
|
||||||
|
```
|
||||||
|
|
||||||
|
Compares two `byte_container_with_subtype` values for equality by comparing the underlying binary
|
||||||
|
container, the subtype, and whether a subtype is set.
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
`rhs` (in)
|
||||||
|
: value to compare `*this` against
|
||||||
|
|
||||||
|
## Return value
|
||||||
|
|
||||||
|
whether `*this` and `rhs` are equal
|
||||||
|
|
||||||
|
## Exception safety
|
||||||
|
|
||||||
|
No-throw guarantee: this function never throws exceptions.
|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
Linear in the size of the underlying binary container.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example demonstrates comparing `byte_container_with_subtype` values.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/byte_container_with_subtype__operator_eq.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/byte_container_with_subtype__operator_eq.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Since version 3.8.0.
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# <small>nlohmann::byte_container_with_subtype::</small>operator!=
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
bool operator!=(const byte_container_with_subtype& rhs) const;
|
||||||
|
```
|
||||||
|
|
||||||
|
Compares two `byte_container_with_subtype` values for inequality. Implemented as the negation of
|
||||||
|
[`operator==`](operator_eq.md).
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
`rhs` (in)
|
||||||
|
: value to compare `*this` against
|
||||||
|
|
||||||
|
## Return value
|
||||||
|
|
||||||
|
whether `*this` and `rhs` are not equal
|
||||||
|
|
||||||
|
## Exception safety
|
||||||
|
|
||||||
|
No-throw guarantee: this function never throws exceptions.
|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
Linear in the size of the underlying binary container.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example demonstrates comparing `byte_container_with_subtype` values.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/byte_container_with_subtype__operator_ne.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/byte_container_with_subtype__operator_ne.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Since version 3.8.0.
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# <small>nlohmann::byte_container_with_subtype::</small>subtype_type
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
using subtype_type = std::uint64_t;
|
||||||
|
```
|
||||||
|
|
||||||
|
The type used to store the optional binary subtype tag. See [`subtype`](subtype.md) and
|
||||||
|
[`set_subtype`](set_subtype.md).
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example shows the type `subtype_type`.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/byte_container_with_subtype__subtype_type.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/byte_container_with_subtype__subtype_type.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Since version 3.8.0.
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# <small>nlohmann::json_sax::</small>binary_t
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
using binary_t = typename BasicJsonType::binary_t;
|
||||||
|
```
|
||||||
|
|
||||||
|
The type used by the [`binary`](binary.md) callback for JSON binary values, forwarded from the
|
||||||
|
`BasicJsonType` template parameter.
|
||||||
|
|
||||||
|
See [`basic_json::binary_t`](../basic_json/binary_t.md) for more information.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example shows the type `binary_t` and its relation to `basic_json::binary_t`.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/json_sax__binary_t.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/json_sax__binary_t.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.8.0.
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# <small>nlohmann::json_sax::</small>json_sax
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
// (1)
|
||||||
|
json_sax() = default;
|
||||||
|
|
||||||
|
// (2)
|
||||||
|
json_sax(const json_sax&) = default;
|
||||||
|
|
||||||
|
// (3)
|
||||||
|
json_sax(json_sax&&) noexcept = default;
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Default constructor.
|
||||||
|
2. Copy constructor.
|
||||||
|
3. Move constructor.
|
||||||
|
|
||||||
|
`json_sax` is a pure abstract base class with no data members of its own, so all three constructors are
|
||||||
|
defaulted and only exist to make derived SAX consumers explicitly copyable/movable.
|
||||||
|
|
||||||
|
## Exception safety
|
||||||
|
|
||||||
|
No-throw guarantee: none of these constructors throw exceptions.
|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
Constant.
|
||||||
|
|
||||||
|
<!-- NOLINT Examples -->
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.2.0.
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# <small>nlohmann::json_sax::</small>number_float_t
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
using number_float_t = typename BasicJsonType::number_float_t;
|
||||||
|
```
|
||||||
|
|
||||||
|
The type used by the [`number_float`](number_float.md) callback for JSON floating-point numbers,
|
||||||
|
forwarded from the `BasicJsonType` template parameter.
|
||||||
|
|
||||||
|
See [`basic_json::number_float_t`](../basic_json/number_float_t.md) for more information.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example shows the type `number_float_t` and its relation to `basic_json::number_float_t`.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/json_sax__number_float_t.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/json_sax__number_float_t.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.2.0.
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# <small>nlohmann::json_sax::</small>number_integer_t
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
using number_integer_t = typename BasicJsonType::number_integer_t;
|
||||||
|
```
|
||||||
|
|
||||||
|
The type used by the [`number_integer`](number_integer.md) callback for JSON integer numbers, forwarded
|
||||||
|
from the `BasicJsonType` template parameter.
|
||||||
|
|
||||||
|
See [`basic_json::number_integer_t`](../basic_json/number_integer_t.md) for more information.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example shows the type `number_integer_t` and its relation to `basic_json::number_integer_t`.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/json_sax__number_integer_t.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/json_sax__number_integer_t.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.2.0.
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# <small>nlohmann::json_sax::</small>number_unsigned_t
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
|
||||||
|
```
|
||||||
|
|
||||||
|
The type used by the [`number_unsigned`](number_unsigned.md) callback for JSON unsigned integer numbers,
|
||||||
|
forwarded from the `BasicJsonType` template parameter.
|
||||||
|
|
||||||
|
See [`basic_json::number_unsigned_t`](../basic_json/number_unsigned_t.md) for more information.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example shows the type `number_unsigned_t` and its relation to `basic_json::number_unsigned_t`.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/json_sax__number_unsigned_t.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/json_sax__number_unsigned_t.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.2.0.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# <small>nlohmann::json_sax::</small>operator=
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
// (1)
|
||||||
|
json_sax& operator=(const json_sax&) = default;
|
||||||
|
|
||||||
|
// (2)
|
||||||
|
json_sax& operator=(json_sax&&) noexcept = default;
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Copy assignment operator.
|
||||||
|
2. Move assignment operator.
|
||||||
|
|
||||||
|
`json_sax` is a pure abstract base class with no data members of its own, so both assignment operators
|
||||||
|
are defaulted and only exist to make derived SAX consumers explicitly copy-/move-assignable.
|
||||||
|
|
||||||
|
## Exception safety
|
||||||
|
|
||||||
|
No-throw guarantee: neither operator throws exceptions.
|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
Constant.
|
||||||
|
|
||||||
|
<!-- NOLINT Examples -->
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.2.0.
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# <small>nlohmann::json_sax::</small>string_t
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
using string_t = typename BasicJsonType::string_t;
|
||||||
|
```
|
||||||
|
|
||||||
|
The type used by the [`string`](string.md) and [`key`](key.md) callbacks for JSON strings and object
|
||||||
|
keys, forwarded from the `BasicJsonType` template parameter.
|
||||||
|
|
||||||
|
See [`basic_json::string_t`](../basic_json/string_t.md) for more information.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example shows the type `string_t` and its relation to `basic_json::string_t`.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/json_sax__string_t.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/json_sax__string_t.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.2.0.
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# <small>nlohmann::json_sax::</small>~json_sax
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
virtual ~json_sax() = default;
|
||||||
|
```
|
||||||
|
|
||||||
|
Destructor. Virtual to allow proper destruction of derived SAX consumer classes through a
|
||||||
|
pointer/reference to `json_sax`.
|
||||||
|
|
||||||
|
## Exception safety
|
||||||
|
|
||||||
|
No-throw guarantee: this destructor never throws exceptions.
|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
Constant.
|
||||||
|
|
||||||
|
<!-- NOLINT Examples -->
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.2.0.
|
||||||
@@ -38,8 +38,7 @@ When the macro is not defined, the library will define it to its default value.
|
|||||||
|
|
||||||
Diagnostic messages can also be controlled with the CMake option
|
Diagnostic messages can also be controlled with the CMake option
|
||||||
[`JSON_Diagnostics`](../../integration/cmake.md#json_diagnostics) (`OFF` by default)
|
[`JSON_Diagnostics`](../../integration/cmake.md#json_diagnostics) (`OFF` by default)
|
||||||
which defines `JSON_DIAGNOSTICS` accordingly. Note this only applies when building the
|
which defines `JSON_DIAGNOSTICS` accordingly.
|
||||||
library from source — see the pre-installed-package caveat on that page.
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ This type preserves the insertion order of object keys.
|
|||||||
|
|
||||||
## Iterator invalidation
|
## Iterator invalidation
|
||||||
|
|
||||||
The type is based on [`ordered_map`](ordered_map.md) which in turn uses a `std::vector` to store object elements.
|
The type is based on [`ordered_map`](ordered_map/index.md) which in turn uses a `std::vector` to store object elements.
|
||||||
Therefore, adding object elements can yield a reallocation in which case all iterators (including the
|
Therefore, adding object elements can yield a reallocation in which case all iterators (including the
|
||||||
[`end()`](basic_json/end.md) iterator) and all references to the elements are invalidated. Also, any iterator or
|
[`end()`](basic_json/end.md) iterator) and all references to the elements are invalidated. Also, any iterator or
|
||||||
reference after the insertion point will point to the same index, which is now a different value.
|
reference after the insertion point will point to the same index, which is now a different value.
|
||||||
@@ -31,7 +31,7 @@ reference after the insertion point will point to the same index, which is now a
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [ordered_map](ordered_map.md)
|
- [ordered_map](ordered_map/index.md)
|
||||||
- [Object Order](../features/object_order.md)
|
- [Object Order](../features/object_order.md)
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# <small>nlohmann::ordered_map::</small>Container
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
using Container = std::vector<std::pair<const Key, T>, Allocator>;
|
||||||
|
```
|
||||||
|
|
||||||
|
The base container type that `ordered_map` publicly inherits from. Elements are stored in insertion
|
||||||
|
order as `#!cpp std::pair<const Key, T>` entries in a `std::vector`.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example shows the type `Container`.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/ordered_map__Container.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/ordered_map__Container.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.9.0 to implement [`nlohmann::ordered_json`](../ordered_json.md).
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
# <small>nlohmann::ordered_map::</small>at
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
// (1)
|
||||||
|
T& at(const key_type& key);
|
||||||
|
const T& at(const key_type& key) const;
|
||||||
|
|
||||||
|
// (2)
|
||||||
|
template<class KeyType>
|
||||||
|
T& at(KeyType&& key);
|
||||||
|
template<class KeyType>
|
||||||
|
const T& at(KeyType&& key) const;
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Returns a reference to the value mapped to `key`.
|
||||||
|
2. Same as (1), but for any `KeyType` comparable to `key_type` via [`key_compare`](key_compare.md)
|
||||||
|
(heterogeneous lookup, e.g. looking up by a `#!cpp const char*` without constructing a temporary
|
||||||
|
`key_type`). Only participates in overload resolution if `KeyType` is usable as a key type.
|
||||||
|
|
||||||
|
## Template parameters
|
||||||
|
|
||||||
|
`KeyType`
|
||||||
|
: a type comparable to `key_type` via [`key_compare`](key_compare.md)
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
`key` (in)
|
||||||
|
: key of the element to find
|
||||||
|
|
||||||
|
## Return value
|
||||||
|
|
||||||
|
reference to the mapped value of the element with key equal to `key`
|
||||||
|
|
||||||
|
## Exceptions
|
||||||
|
|
||||||
|
Throws `std::out_of_range` if no element with key `key` exists.
|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
Linear in the number of elements.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example shows how `at` is used.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/ordered_map__at.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/ordered_map__at.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.9.1 to implement [`nlohmann::ordered_json`](../ordered_json.md).
|
||||||
|
- Overload (2) added in version 3.11.0.
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
# <small>nlohmann::ordered_map::</small>count
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
// (1)
|
||||||
|
size_type count(const key_type& key) const;
|
||||||
|
|
||||||
|
// (2)
|
||||||
|
template<class KeyType>
|
||||||
|
size_type count(KeyType&& key) const;
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Returns the number of elements with key equal to `key` (0 or 1, since keys are unique).
|
||||||
|
2. Same as (1), but for any `KeyType` comparable to `key_type` via [`key_compare`](key_compare.md)
|
||||||
|
(heterogeneous lookup). Only participates in overload resolution if `KeyType` is usable as a key type.
|
||||||
|
|
||||||
|
## Template parameters
|
||||||
|
|
||||||
|
`KeyType`
|
||||||
|
: a type comparable to `key_type` via [`key_compare`](key_compare.md)
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
`key` (in)
|
||||||
|
: key of the elements to count
|
||||||
|
|
||||||
|
## Return value
|
||||||
|
|
||||||
|
number of elements with key equal to `key` (0 or 1)
|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
Linear in the number of elements.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example shows how `count` is used.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/ordered_map__count.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/ordered_map__count.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.9.1 to implement [`nlohmann::ordered_json`](../ordered_json.md).
|
||||||
|
- Overload (2) added in version 3.11.0.
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
# <small>nlohmann::ordered_map::</small>emplace
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
// (1)
|
||||||
|
std::pair<iterator, bool> emplace(const key_type& key, T&& t);
|
||||||
|
|
||||||
|
// (2)
|
||||||
|
template<class KeyType>
|
||||||
|
std::pair<iterator, bool> emplace(KeyType&& key, T&& t);
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Inserts `#!cpp {key, t}` if no element with an equal key already exists (per [`key_compare`](key_compare.md)),
|
||||||
|
appending it at the end to preserve insertion order. If an equal key already exists, does nothing.
|
||||||
|
2. Same as (1), but for any `KeyType` comparable to `key_type` via [`key_compare`](key_compare.md)
|
||||||
|
(heterogeneous lookup). Only participates in overload resolution if `KeyType` is usable as a key type.
|
||||||
|
|
||||||
|
## Template parameters
|
||||||
|
|
||||||
|
`KeyType`
|
||||||
|
: a type comparable to `key_type` via [`key_compare`](key_compare.md)
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
`key` (in)
|
||||||
|
: key of the element to insert
|
||||||
|
|
||||||
|
`t` (in)
|
||||||
|
: value of the element to insert
|
||||||
|
|
||||||
|
## Return value
|
||||||
|
|
||||||
|
pair of an iterator to the (possibly newly inserted) element, and a `bool` that is `true` if insertion
|
||||||
|
took place and `false` if an element with an equal key already existed
|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
Linear in the number of elements.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example shows how `emplace` is used.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/ordered_map__emplace.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/ordered_map__emplace.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.9.0 to implement [`nlohmann::ordered_json`](../ordered_json.md).
|
||||||
|
- Overload (2) added in version 3.11.0.
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
# <small>nlohmann::ordered_map::</small>erase
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
// (1)
|
||||||
|
size_type erase(const key_type& key);
|
||||||
|
|
||||||
|
// (2)
|
||||||
|
template<class KeyType>
|
||||||
|
size_type erase(KeyType&& key);
|
||||||
|
|
||||||
|
// (3)
|
||||||
|
iterator erase(iterator pos);
|
||||||
|
|
||||||
|
// (4)
|
||||||
|
iterator erase(iterator first, iterator last);
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Removes the element with key equal to `key`, if any, preserving the relative order of the remaining
|
||||||
|
elements.
|
||||||
|
2. Same as (1), but for any `KeyType` comparable to `key_type` via [`key_compare`](key_compare.md)
|
||||||
|
(heterogeneous lookup). Only participates in overload resolution if `KeyType` is usable as a key type.
|
||||||
|
3. Removes the element at `pos`.
|
||||||
|
4. Removes the elements in range `[first, last)`.
|
||||||
|
|
||||||
|
## Template parameters
|
||||||
|
|
||||||
|
`KeyType`
|
||||||
|
: a type comparable to `key_type` via [`key_compare`](key_compare.md)
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
`key` (in)
|
||||||
|
: key of the element to remove
|
||||||
|
|
||||||
|
`pos` (in)
|
||||||
|
: iterator to the element to remove
|
||||||
|
|
||||||
|
`first` (in)
|
||||||
|
: iterator to the first element to remove
|
||||||
|
|
||||||
|
`last` (in)
|
||||||
|
: iterator one past the last element to remove
|
||||||
|
|
||||||
|
## Return value
|
||||||
|
|
||||||
|
1. number of elements removed (0 or 1)
|
||||||
|
2. number of elements removed (0 or 1)
|
||||||
|
3. iterator following the removed element
|
||||||
|
4. iterator following the last removed element
|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
Linear in the number of elements (elements after the removed one(s) are shifted to keep storage
|
||||||
|
contiguous).
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example shows how `erase` is used.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/ordered_map__erase.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/ordered_map__erase.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.9.0 to implement [`nlohmann::ordered_json`](../ordered_json.md).
|
||||||
|
- Overload (2) added in version 3.11.0.
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
# <small>nlohmann::ordered_map::</small>find
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
// (1)
|
||||||
|
iterator find(const key_type& key);
|
||||||
|
const_iterator find(const key_type& key) const;
|
||||||
|
|
||||||
|
// (2)
|
||||||
|
template<class KeyType>
|
||||||
|
iterator find(KeyType&& key);
|
||||||
|
template<class KeyType>
|
||||||
|
const_iterator find(KeyType&& key) const;
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Returns an iterator to the element with key equal to `key`, or `end()` if no such element exists.
|
||||||
|
2. Same as (1), but for any `KeyType` comparable to `key_type` via [`key_compare`](key_compare.md)
|
||||||
|
(heterogeneous lookup). Only participates in overload resolution if `KeyType` is usable as a key type.
|
||||||
|
|
||||||
|
## Template parameters
|
||||||
|
|
||||||
|
`KeyType`
|
||||||
|
: a type comparable to `key_type` via [`key_compare`](key_compare.md)
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
`key` (in)
|
||||||
|
: key of the element to find
|
||||||
|
|
||||||
|
## Return value
|
||||||
|
|
||||||
|
iterator to the element with key equal to `key`, or `end()` if not found
|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
Linear in the number of elements.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example shows how `find` is used.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/ordered_map__find.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/ordered_map__find.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.9.1 to implement [`nlohmann::ordered_json`](../ordered_json.md).
|
||||||
|
- Overload (2) added in version 3.11.0.
|
||||||
@@ -6,7 +6,7 @@ template<class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>;
|
struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>;
|
||||||
```
|
```
|
||||||
|
|
||||||
A minimal map-like container that preserves insertion order for use within [`nlohmann::ordered_json`](ordered_json.md)
|
A minimal map-like container that preserves insertion order for use within [`nlohmann::ordered_json`](../ordered_json.md)
|
||||||
(`nlohmann::basic_json<ordered_map>`).
|
(`nlohmann::basic_json<ordered_map>`).
|
||||||
|
|
||||||
## Template parameters
|
## Template parameters
|
||||||
@@ -32,12 +32,12 @@ case all iterators (including the `end()` iterator) and all references to the el
|
|||||||
|
|
||||||
- **key_type** - key type (`Key`)
|
- **key_type** - key type (`Key`)
|
||||||
- **mapped_type** - mapped type (`T`)
|
- **mapped_type** - mapped type (`T`)
|
||||||
- **Container** - base container type (`#!cpp std::vector<std::pair<const Key, T>, Allocator>`)
|
- [**Container**](Container.md) - base container type (`#!cpp std::vector<std::pair<const Key, T>, Allocator>`)
|
||||||
- **iterator**
|
- **iterator**
|
||||||
- **const_iterator**
|
- **const_iterator**
|
||||||
- **size_type**
|
- **size_type**
|
||||||
- **value_type**
|
- **value_type**
|
||||||
- **key_compare** - key comparison function
|
- [**key_compare**](key_compare.md) - key comparison function
|
||||||
```cpp
|
```cpp
|
||||||
std::equal_to<Key> // until C++14
|
std::equal_to<Key> // until C++14
|
||||||
|
|
||||||
@@ -46,15 +46,16 @@ std::equal_to<> // since C++14
|
|||||||
|
|
||||||
## Member functions
|
## Member functions
|
||||||
|
|
||||||
- (constructor)
|
- [(constructor)](ordered_map.md)
|
||||||
- (destructor)
|
- [(destructor)](~ordered_map.md)
|
||||||
- **emplace**
|
- [**operator=**](operator=.md)
|
||||||
- **operator\[\]**
|
- [**emplace**](emplace.md)
|
||||||
- **at**
|
- [**operator\[\]**](operator[].md)
|
||||||
- **erase**
|
- [**at**](at.md)
|
||||||
- **count**
|
- [**erase**](erase.md)
|
||||||
- **find**
|
- [**count**](count.md)
|
||||||
- **insert**
|
- [**find**](find.md)
|
||||||
|
- [**insert**](insert.md)
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
@@ -74,9 +75,9 @@ std::equal_to<> // since C++14
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [ordered_json](ordered_json.md)
|
- [ordered_json](../ordered_json.md)
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
- Added in version 3.9.0 to implement [`nlohmann::ordered_json`](ordered_json.md).
|
- Added in version 3.9.0 to implement [`nlohmann::ordered_json`](../ordered_json.md).
|
||||||
- Added **key_compare** member in version 3.11.0.
|
- Added **key_compare** member in version 3.11.0.
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
# <small>nlohmann::ordered_map::</small>insert
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
// (1)
|
||||||
|
std::pair<iterator, bool> insert(value_type&& value);
|
||||||
|
std::pair<iterator, bool> insert(const value_type& value);
|
||||||
|
|
||||||
|
// (2)
|
||||||
|
template<typename InputIt>
|
||||||
|
void insert(InputIt first, InputIt last);
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Inserts `value` if no element with an equal key already exists (per [`key_compare`](key_compare.md)),
|
||||||
|
appending it at the end to preserve insertion order. If an equal key already exists, does nothing.
|
||||||
|
2. Inserts the elements from range `[first, last)`, in iteration order, applying the same equal-key rule
|
||||||
|
as (1) to each element.
|
||||||
|
|
||||||
|
## Template parameters
|
||||||
|
|
||||||
|
`InputIt`
|
||||||
|
: an input iterator type
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
`value` (in)
|
||||||
|
: value to insert
|
||||||
|
|
||||||
|
`first` (in)
|
||||||
|
: iterator to the first element to insert
|
||||||
|
|
||||||
|
`last` (in)
|
||||||
|
: iterator one past the last element to insert
|
||||||
|
|
||||||
|
## Return value
|
||||||
|
|
||||||
|
1. pair of an iterator to the (possibly newly inserted) element, and a `bool` that is `true` if insertion
|
||||||
|
took place and `false` if an element with an equal key already existed
|
||||||
|
2. (none)
|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
1. Linear in the number of elements.
|
||||||
|
2. Linear in the distance between `first` and `last`, times linear in the number of elements.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example shows how `insert` is used.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/ordered_map__insert.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/ordered_map__insert.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.9.1 to implement [`nlohmann::ordered_json`](../ordered_json.md).
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
# <small>nlohmann::ordered_map::</small>key_compare
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
using key_compare = std::equal_to<Key>; // until C++14
|
||||||
|
|
||||||
|
using key_compare = std::equal_to<>; // since C++14
|
||||||
|
```
|
||||||
|
|
||||||
|
The comparator used to determine key equality when looking up elements. Unlike `std::map`, `ordered_map`
|
||||||
|
uses linear search with `key_compare` rather than an ordering relation, since element order reflects
|
||||||
|
insertion order rather than key order.
|
||||||
|
|
||||||
|
Since C++14, the transparent `#!cpp std::equal_to<>` is used, which enables heterogeneous lookup (e.g.
|
||||||
|
looking up by a `#!cpp const char*` key without constructing a temporary `Key`).
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example shows how `key_compare` is used.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/ordered_map__key_compare.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/ordered_map__key_compare.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.11.0.
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# <small>nlohmann::ordered_map::</small>operator=
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
// (1)
|
||||||
|
ordered_map& operator=(const ordered_map& other);
|
||||||
|
|
||||||
|
// (2)
|
||||||
|
ordered_map& operator=(ordered_map&& other) noexcept(std::is_nothrow_move_assignable<Container>::value);
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Copy assignment operator.
|
||||||
|
2. Move assignment operator.
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
`other` (in)
|
||||||
|
: value to assign from
|
||||||
|
|
||||||
|
## Return value
|
||||||
|
|
||||||
|
`*this`
|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
1. Linear in the size of `other`.
|
||||||
|
2. Constant.
|
||||||
|
|
||||||
|
<!-- NOLINT Examples -->
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.9.0 to implement [`nlohmann::ordered_json`](../ordered_json.md).
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
# <small>nlohmann::ordered_map::</small>operator[]
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
// (1)
|
||||||
|
T& operator[](const key_type& key);
|
||||||
|
const T& operator[](const key_type& key) const;
|
||||||
|
|
||||||
|
// (2)
|
||||||
|
template<class KeyType>
|
||||||
|
T& operator[](KeyType&& key);
|
||||||
|
template<class KeyType>
|
||||||
|
const T& operator[](KeyType&& key) const;
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Returns a reference to the value mapped to `key`, inserting a default-constructed `T` (non-`const`
|
||||||
|
overload only) if no such element exists yet.
|
||||||
|
2. Same as (1), but for any `KeyType` comparable to `key_type` via [`key_compare`](key_compare.md)
|
||||||
|
(heterogeneous lookup). Only participates in overload resolution if `KeyType` is usable as a key type.
|
||||||
|
|
||||||
|
## Template parameters
|
||||||
|
|
||||||
|
`KeyType`
|
||||||
|
: a type comparable to `key_type` via [`key_compare`](key_compare.md)
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
`key` (in)
|
||||||
|
: key of the element to find or insert
|
||||||
|
|
||||||
|
## Return value
|
||||||
|
|
||||||
|
reference to the mapped value of the element with key equal to `key`
|
||||||
|
|
||||||
|
## Exceptions
|
||||||
|
|
||||||
|
The `const` overloads throw `std::out_of_range` if no element with key `key` exists (they delegate to
|
||||||
|
[`at`](at.md)).
|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
Linear in the number of elements.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example shows how `operator[]` is used.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/ordered_map__operator_idx.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/ordered_map__operator_idx.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.9.0 to implement [`nlohmann::ordered_json`](../ordered_json.md).
|
||||||
|
- Overload (2) added in version 3.11.0.
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
# <small>nlohmann::ordered_map::</small>ordered_map
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
// (1)
|
||||||
|
ordered_map() noexcept(noexcept(Container()));
|
||||||
|
|
||||||
|
// (2)
|
||||||
|
explicit ordered_map(const Allocator& alloc) noexcept(noexcept(Container(alloc)));
|
||||||
|
|
||||||
|
// (3)
|
||||||
|
template <class It>
|
||||||
|
ordered_map(It first, It last, const Allocator& alloc = Allocator());
|
||||||
|
|
||||||
|
// (4)
|
||||||
|
ordered_map(std::initializer_list<value_type> init, const Allocator& alloc = Allocator());
|
||||||
|
|
||||||
|
// (5)
|
||||||
|
ordered_map(const ordered_map&) = default;
|
||||||
|
|
||||||
|
// (6)
|
||||||
|
ordered_map(ordered_map&&) noexcept(std::is_nothrow_move_constructible<Container>::value) = default;
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Default constructor. Creates an empty `ordered_map`.
|
||||||
|
2. Creates an empty `ordered_map` using the given allocator.
|
||||||
|
3. Creates an `ordered_map` from the elements in range `[first, last)`, inserted in iteration order.
|
||||||
|
4. Creates an `ordered_map` from an initializer list of key/value pairs, inserted in list order.
|
||||||
|
5. Copy constructor.
|
||||||
|
6. Move constructor.
|
||||||
|
|
||||||
|
These constructors are declared explicitly (rather than inherited via `#!cpp using Container::Container`)
|
||||||
|
because older compilers (GCC <= 5.5, Xcode <= 9.4) do not handle the inherited constructors correctly.
|
||||||
|
|
||||||
|
## Template parameters
|
||||||
|
|
||||||
|
`It`
|
||||||
|
: an input iterator type
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
`alloc` (in)
|
||||||
|
: allocator to use for the underlying container
|
||||||
|
|
||||||
|
`first` (in)
|
||||||
|
: iterator to the first element to insert
|
||||||
|
|
||||||
|
`last` (in)
|
||||||
|
: iterator one past the last element to insert
|
||||||
|
|
||||||
|
`init` (in)
|
||||||
|
: initializer list of key/value pairs to insert
|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
1. Constant.
|
||||||
|
2. Constant.
|
||||||
|
3. Linear in the distance between `first` and `last`.
|
||||||
|
4. Linear in the size of `init`.
|
||||||
|
5. Linear in the size of `other`.
|
||||||
|
6. Constant.
|
||||||
|
|
||||||
|
<!-- NOLINT Examples -->
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.9.0 to implement [`nlohmann::ordered_json`](../ordered_json.md).
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# <small>nlohmann::ordered_map::</small>~ordered_map
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
~ordered_map() = default;
|
||||||
|
```
|
||||||
|
|
||||||
|
Destroys the `ordered_map` and frees all allocated memory.
|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
Linear in the number of elements.
|
||||||
|
|
||||||
|
<!-- NOLINT Examples -->
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
- Added in version 3.9.0 to implement [`nlohmann::ordered_json`](../ordered_json.md).
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// an empty binary value is encoded differently by the two drafts:
|
||||||
|
// draft2 omits the optimized type marker for an empty byte array,
|
||||||
|
// while draft3 always writes it
|
||||||
|
json j = json::binary({});
|
||||||
|
|
||||||
|
// encode using BJData draft2 (the default)
|
||||||
|
auto v_draft2 = json::to_bjdata(j, true, true, json::bjdata_version_t::draft2);
|
||||||
|
|
||||||
|
// encode using BJData draft3
|
||||||
|
auto v_draft3 = json::to_bjdata(j, true, true, json::bjdata_version_t::draft3);
|
||||||
|
|
||||||
|
std::cout << "draft2 size: " << v_draft2.size() << '\n'
|
||||||
|
<< "draft3 size: " << v_draft3.size() << std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
draft2 size: 4
|
||||||
|
draft3 size: 6
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::cout << std::boolalpha
|
||||||
|
<< std::is_same<byte_container_with_subtype::container_type, std::vector<std::uint8_t>>::value
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
true
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
byte_container_with_subtype c1({0xca, 0xfe});
|
||||||
|
byte_container_with_subtype c2({0xca, 0xfe});
|
||||||
|
byte_container_with_subtype c3({0xca, 0xfe}, 42);
|
||||||
|
|
||||||
|
std::cout << std::boolalpha
|
||||||
|
<< "c1 == c2: " << (c1 == c2) << '\n'
|
||||||
|
<< "c1 == c3: " << (c1 == c3) << std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
c1 == c2: true
|
||||||
|
c1 == c3: false
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
byte_container_with_subtype c1({0xca, 0xfe});
|
||||||
|
byte_container_with_subtype c2({0xca, 0xfe});
|
||||||
|
byte_container_with_subtype c3({0xca, 0xfe}, 42);
|
||||||
|
|
||||||
|
std::cout << std::boolalpha
|
||||||
|
<< "c1 != c2: " << (c1 != c2) << '\n'
|
||||||
|
<< "c1 != c3: " << (c1 != c3) << std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
c1 != c2: false
|
||||||
|
c1 != c3: true
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::cout << std::boolalpha
|
||||||
|
<< std::is_same<byte_container_with_subtype::subtype_type, std::uint64_t>::value << std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
true
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// an initializer_list_t is what a braced-init-list of JSON values is deduced as
|
||||||
|
json::initializer_list_t init = {"a", 1, 2.0, false};
|
||||||
|
|
||||||
|
json j(init);
|
||||||
|
std::cout << j.dump() << std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
["a",1,2.0,false]
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::cout << std::boolalpha
|
||||||
|
<< std::is_same<json::json_sax_t::binary_t, json::binary_t>::value << std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
true
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::cout << std::boolalpha
|
||||||
|
<< std::is_same<json::json_sax_t::number_float_t, json::number_float_t>::value << std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
true
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::cout << std::boolalpha
|
||||||
|
<< std::is_same<json::json_sax_t::number_integer_t, json::number_integer_t>::value << std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
true
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::cout << std::boolalpha
|
||||||
|
<< std::is_same<json::json_sax_t::number_unsigned_t, json::number_unsigned_t>::value << std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
true
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::cout << std::boolalpha
|
||||||
|
<< std::is_same<json::json_sax_t::string_t, json::string_t>::value << std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
true
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::cout << std::boolalpha
|
||||||
|
<< std::is_same<json::json_sax_t, nlohmann::json_sax<json>>::value << std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
true
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
using Map = nlohmann::ordered_map<std::string, int>;
|
||||||
|
|
||||||
|
std::cout << std::boolalpha
|
||||||
|
<< "Container is std::vector<std::pair<const Key, T>>: "
|
||||||
|
<< std::is_same<Map::Container, std::vector<std::pair<const std::string, int>>>::value
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Container is std::vector<std::pair<const Key, T>>: true
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
nlohmann::ordered_map<std::string, int> m;
|
||||||
|
m["one"] = 1;
|
||||||
|
m["two"] = 2;
|
||||||
|
|
||||||
|
// access an existing element
|
||||||
|
std::cout << "m.at(\"one\") = " << m.at("one") << std::endl;
|
||||||
|
|
||||||
|
// modify through the reference returned by at()
|
||||||
|
m.at("two") = 22;
|
||||||
|
std::cout << "m.at(\"two\") = " << m.at("two") << std::endl;
|
||||||
|
|
||||||
|
// accessing a missing key throws
|
||||||
|
try
|
||||||
|
{
|
||||||
|
m.at("three");
|
||||||
|
}
|
||||||
|
catch (const std::out_of_range& e)
|
||||||
|
{
|
||||||
|
std::cout << "exception: " << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
m.at("one") = 1
|
||||||
|
m.at("two") = 22
|
||||||
|
exception: key not found
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
nlohmann::ordered_map<std::string, int> m;
|
||||||
|
m["one"] = 1;
|
||||||
|
|
||||||
|
std::cout << std::boolalpha
|
||||||
|
<< "m.count(\"one\") = " << m.count("one") << '\n'
|
||||||
|
<< "m.count(\"two\") = " << m.count("two") << std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
m.count("one") = 1
|
||||||
|
m.count("two") = 0
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
nlohmann::ordered_map<std::string, std::string> m;
|
||||||
|
|
||||||
|
// emplace a new element
|
||||||
|
auto res1 = m.emplace("one", "eins");
|
||||||
|
std::cout << std::boolalpha << "inserted: " << res1.second << ", value: " << res1.first->second << std::endl;
|
||||||
|
|
||||||
|
// emplace with an already-existing key: no-op, returns the existing element
|
||||||
|
auto res2 = m.emplace("one", "uno");
|
||||||
|
std::cout << std::boolalpha << "inserted: " << res2.second << ", value: " << res2.first->second << std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
inserted: true, value: eins
|
||||||
|
inserted: false, value: eins
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
nlohmann::ordered_map<std::string, int> m;
|
||||||
|
m["one"] = 1;
|
||||||
|
m["two"] = 2;
|
||||||
|
m["three"] = 3;
|
||||||
|
|
||||||
|
// erase by key
|
||||||
|
std::size_t removed = m.erase("two");
|
||||||
|
std::cout << "removed by key: " << removed << std::endl;
|
||||||
|
|
||||||
|
// erase by iterator
|
||||||
|
m.erase(m.begin());
|
||||||
|
|
||||||
|
std::cout << "remaining: ";
|
||||||
|
for (const auto& element : m)
|
||||||
|
{
|
||||||
|
std::cout << element.first << ' ';
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
removed by key: 1
|
||||||
|
remaining: three
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
nlohmann::ordered_map<std::string, int> m;
|
||||||
|
m["one"] = 1;
|
||||||
|
|
||||||
|
auto it = m.find("one");
|
||||||
|
if (it != m.end())
|
||||||
|
{
|
||||||
|
std::cout << "found: " << it->first << " = " << it->second << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m.find("two") == m.end())
|
||||||
|
{
|
||||||
|
std::cout << "\"two\" not found" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
found: one = 1
|
||||||
|
"two" not found
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
nlohmann::ordered_map<std::string, int> m;
|
||||||
|
|
||||||
|
// insert a single value
|
||||||
|
auto res = m.insert({"one", 1});
|
||||||
|
std::cout << std::boolalpha << "inserted: " << res.second << std::endl;
|
||||||
|
|
||||||
|
// insert a range from another container
|
||||||
|
std::vector<std::pair<const std::string, int>> more = {{"two", 2}, {"three", 3}};
|
||||||
|
m.insert(more.begin(), more.end());
|
||||||
|
|
||||||
|
for (const auto& element : m)
|
||||||
|
{
|
||||||
|
std::cout << element.first << ':' << element.second << ' ';
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
inserted: true
|
||||||
|
one:1 two:2 three:3
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
using Map = nlohmann::ordered_map<std::string, int>;
|
||||||
|
Map::key_compare compare{};
|
||||||
|
|
||||||
|
std::cout << std::boolalpha
|
||||||
|
<< "compare(\"a\", \"a\") = " << compare("a", "a") << '\n'
|
||||||
|
<< "compare(\"a\", \"b\") = " << compare("a", "b") << std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
compare("a", "a") = true
|
||||||
|
compare("a", "b") = false
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
nlohmann::ordered_map<std::string, int> m;
|
||||||
|
|
||||||
|
// operator[] inserts a default-constructed value if the key doesn't exist yet
|
||||||
|
m["one"] = 1;
|
||||||
|
std::cout << "m[\"one\"] = " << m["one"] << std::endl;
|
||||||
|
|
||||||
|
// accessing again just returns the existing value
|
||||||
|
std::cout << "m[\"one\"] = " << m["one"] << std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
m["one"] = 1
|
||||||
|
m["one"] = 1
|
||||||
@@ -47,28 +47,6 @@ json j = {{"one", 1}, {"two", 2}};
|
|||||||
auto m = j.get<std::map<std::string, int>>(); // {{"one", 1}, {"two", 2}}
|
auto m = j.get<std::map<std::string, int>>(); // {{"one", 1}, {"two", 2}}
|
||||||
```
|
```
|
||||||
|
|
||||||
`#!cpp std::pair` and `#!cpp std::tuple` are also supported, converting positionally to and from a JSON array:
|
|
||||||
|
|
||||||
```cpp
|
|
||||||
json j = {1.0, "hello", 42};
|
|
||||||
auto t = j.get<std::tuple<double, std::string, int>>(); // {1.0, "hello", 42}
|
|
||||||
```
|
|
||||||
|
|
||||||
!!! info "Extracting references into a tuple"
|
|
||||||
|
|
||||||
A tuple type may also hold references (e.g. `#!cpp std::tuple<double&, std::string&>`) to avoid copying: `get`
|
|
||||||
then returns a tuple of references pointing directly at the elements stored inside the `basic_json` array,
|
|
||||||
rather than a tuple of copies:
|
|
||||||
|
|
||||||
```cpp
|
|
||||||
json j = {1.0, "hello"};
|
|
||||||
auto refs = j.get<std::tuple<double&, std::string&>>();
|
|
||||||
std::get<1>(refs) = "world"; // modifies j[1] in place
|
|
||||||
```
|
|
||||||
|
|
||||||
A referenced type must be one the library actually stores (or an arithmetic type it can convert to/from);
|
|
||||||
otherwise this is a compile error.
|
|
||||||
|
|
||||||
## Implicit conversions
|
## Implicit conversions
|
||||||
|
|
||||||
By default, a JSON value implicitly converts to a compatible C++ type, so the explicit `get` call can often be omitted:
|
By default, a JSON value implicitly converts to a compatible C++ type, so the explicit `get` call can often be omitted:
|
||||||
@@ -158,20 +136,6 @@ std::vector<int> numbers = {1, 2, 3};
|
|||||||
json j = numbers; // [1,2,3]
|
json j = numbers; // [1,2,3]
|
||||||
```
|
```
|
||||||
|
|
||||||
!!! info "Constructing from a C++20 range view"
|
|
||||||
|
|
||||||
A `json` array can also be constructed directly from a C++20 range view (`std::ranges::view`), such as the result
|
|
||||||
of `std::views::filter` or `std::views::transform` -- no intermediate container is needed:
|
|
||||||
|
|
||||||
```cpp
|
|
||||||
std::vector<int> nums{1, 2, 37, 42, 21};
|
|
||||||
auto filtered = nums | std::views::filter([](int i) { return i > 10; });
|
|
||||||
json j(filtered); // [37,42,21]
|
|
||||||
```
|
|
||||||
|
|
||||||
This requires [`JSON_HAS_RANGES`](../api/macros/json_has_ranges.md) to be enabled and is unavailable on MinGW due
|
|
||||||
to incomplete C++20 ranges support there.
|
|
||||||
|
|
||||||
## Your own types
|
## Your own types
|
||||||
|
|
||||||
The conversions above are built in for standard types. To make the same syntax work for **your own** types, provide
|
The conversions above are built in for standard types. To make the same syntax work for **your own** types, provide
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@ The main structure is class [nlohmann::basic_json](../api/basic_json/index.md).
|
|||||||
|
|
||||||
- describe template parameters of `basic_json`
|
- describe template parameters of `basic_json`
|
||||||
- [`json`](../api/json.md)
|
- [`json`](../api/json.md)
|
||||||
- [`ordered_json`](../api/ordered_json.md) via [`ordered_map`](../api/ordered_map.md)
|
- [`ordered_json`](../api/ordered_json.md) via [`ordered_map`](../api/ordered_map/index.md)
|
||||||
|
|
||||||
## Value storage
|
## Value storage
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
This page summarizes the notable changes of every release and links to the relevant documentation.
|
This page summarizes the notable changes of every release and links to the relevant documentation.
|
||||||
The **complete release notes** — including all changes, the download files, and their checksums — are
|
The **complete release notes** — including all changes, the download files, and their checksums — are
|
||||||
published on the [GitHub releases page](https://github.com/nlohmann/json/releases).
|
published on the [GitHub releases page](https://github.com/nlohmann/json/releases). For a raw,
|
||||||
|
signature-level diff of the public API between releases, see [API Changes](api_changes.md).
|
||||||
|
|
||||||
## v3.12.0 (2025-04-11)
|
## v3.12.0 (2025-04-11)
|
||||||
|
|
||||||
|
|||||||
@@ -135,31 +135,6 @@ Enable CI build targets. The exact targets are used during the several CI steps
|
|||||||
|
|
||||||
Enable [extended diagnostic messages](../home/exceptions.md#extended-diagnostic-messages) by defining macro [`JSON_DIAGNOSTICS`](../api/macros/json_diagnostics.md). This option is `OFF` by default.
|
Enable [extended diagnostic messages](../home/exceptions.md#extended-diagnostic-messages) by defining macro [`JSON_DIAGNOSTICS`](../api/macros/json_diagnostics.md). This option is `OFF` by default.
|
||||||
|
|
||||||
!!! warning "Does not apply to a pre-installed package"
|
|
||||||
|
|
||||||
This option only takes effect when building nlohmann/json from source as part of your own
|
|
||||||
CMake project (e.g. via [`FetchContent`](#fetchcontent) or [`add_subdirectory`](#external)).
|
|
||||||
It has **no effect** on a package that was already built and installed elsewhere (Homebrew,
|
|
||||||
vcpkg, a system package, etc.) — the resulting compile definition is baked into the exported
|
|
||||||
`nlohmann_jsonTargets.cmake` at install time, and `set(JSON_Diagnostics ON)` before
|
|
||||||
`find_package()` does not change it (verified against the Homebrew-installed package: the
|
|
||||||
exported target still carries a fixed `$<$<BOOL:OFF>:JSON_DIAGNOSTICS=1>`, regardless of any
|
|
||||||
variable set in the consuming project).
|
|
||||||
|
|
||||||
To enable extended diagnostics for a pre-installed package, override the imported target's
|
|
||||||
property directly after `find_package()`:
|
|
||||||
|
|
||||||
```cmake
|
|
||||||
find_package(nlohmann_json REQUIRED)
|
|
||||||
set_target_properties(nlohmann_json::nlohmann_json PROPERTIES
|
|
||||||
INTERFACE_COMPILE_DEFINITIONS "JSON_DIAGNOSTICS=1")
|
|
||||||
```
|
|
||||||
|
|
||||||
This only works cleanly when your project is the sole consumer of that imported target. If
|
|
||||||
nlohmann_json is pulled in from more than one place in your dependency graph with different
|
|
||||||
`JSON_DIAGNOSTICS` values, you may see a `"JSON_DIAGNOSTICS" redefined` compiler error, since
|
|
||||||
conflicting `-D` flags can end up on the same compile command line.
|
|
||||||
|
|
||||||
### `JSON_Diagnostic_Positions`
|
### `JSON_Diagnostic_Positions`
|
||||||
|
|
||||||
Enable position diagnostics by defining macro [`JSON_DIAGNOSTIC_POSITIONS`](../api/macros/json_diagnostic_positions.md). This option is `OFF` by default.
|
Enable position diagnostics by defining macro [`JSON_DIAGNOSTIC_POSITIONS`](../api/macros/json_diagnostic_positions.md). This option is `OFF` by default.
|
||||||
|
|||||||
+30
-1
@@ -52,6 +52,7 @@ nav:
|
|||||||
- "FAQ": home/faq.md
|
- "FAQ": home/faq.md
|
||||||
- home/exceptions.md
|
- home/exceptions.md
|
||||||
- home/releases.md
|
- home/releases.md
|
||||||
|
- home/api_changes.md
|
||||||
- home/design_goals.md
|
- home/design_goals.md
|
||||||
- home/architecture.md
|
- home/architecture.md
|
||||||
- home/customers.md
|
- home/customers.md
|
||||||
@@ -117,6 +118,7 @@ nav:
|
|||||||
- 'begin': api/basic_json/begin.md
|
- 'begin': api/basic_json/begin.md
|
||||||
- 'binary': api/basic_json/binary.md
|
- 'binary': api/basic_json/binary.md
|
||||||
- 'binary_t': api/basic_json/binary_t.md
|
- 'binary_t': api/basic_json/binary_t.md
|
||||||
|
- 'bjdata_version_t': api/basic_json/bjdata_version_t.md
|
||||||
- 'boolean_t': api/basic_json/boolean_t.md
|
- 'boolean_t': api/basic_json/boolean_t.md
|
||||||
- 'cbegin': api/basic_json/cbegin.md
|
- 'cbegin': api/basic_json/cbegin.md
|
||||||
- 'cbor_tag_handler_t': api/basic_json/cbor_tag_handler_t.md
|
- 'cbor_tag_handler_t': api/basic_json/cbor_tag_handler_t.md
|
||||||
@@ -154,6 +156,7 @@ nav:
|
|||||||
- 'get_to': api/basic_json/get_to.md
|
- 'get_to': api/basic_json/get_to.md
|
||||||
- 'std::formatter<basic_json>': api/basic_json/std_formatter.md
|
- 'std::formatter<basic_json>': api/basic_json/std_formatter.md
|
||||||
- 'std::hash<basic_json>': api/basic_json/std_hash.md
|
- 'std::hash<basic_json>': api/basic_json/std_hash.md
|
||||||
|
- 'initializer_list_t': api/basic_json/initializer_list_t.md
|
||||||
- 'input_format_t': api/basic_json/input_format_t.md
|
- 'input_format_t': api/basic_json/input_format_t.md
|
||||||
- 'insert': api/basic_json/insert.md
|
- 'insert': api/basic_json/insert.md
|
||||||
- 'invalid_iterator': api/basic_json/invalid_iterator.md
|
- 'invalid_iterator': api/basic_json/invalid_iterator.md
|
||||||
@@ -172,6 +175,7 @@ nav:
|
|||||||
- 'is_structured': api/basic_json/is_structured.md
|
- 'is_structured': api/basic_json/is_structured.md
|
||||||
- 'items': api/basic_json/items.md
|
- 'items': api/basic_json/items.md
|
||||||
- 'json_base_class_t': api/basic_json/json_base_class_t.md
|
- 'json_base_class_t': api/basic_json/json_base_class_t.md
|
||||||
|
- 'json_sax_t': api/basic_json/json_sax_t.md
|
||||||
- 'json_serializer': api/basic_json/json_serializer.md
|
- 'json_serializer': api/basic_json/json_serializer.md
|
||||||
- 'max_size': api/basic_json/max_size.md
|
- 'max_size': api/basic_json/max_size.md
|
||||||
- 'meta': api/basic_json/meta.md
|
- 'meta': api/basic_json/meta.md
|
||||||
@@ -228,9 +232,13 @@ nav:
|
|||||||
- 'Overview': api/byte_container_with_subtype/index.md
|
- 'Overview': api/byte_container_with_subtype/index.md
|
||||||
- '(constructor)': api/byte_container_with_subtype/byte_container_with_subtype.md
|
- '(constructor)': api/byte_container_with_subtype/byte_container_with_subtype.md
|
||||||
- 'clear_subtype': api/byte_container_with_subtype/clear_subtype.md
|
- 'clear_subtype': api/byte_container_with_subtype/clear_subtype.md
|
||||||
|
- 'container_type': api/byte_container_with_subtype/container_type.md
|
||||||
- 'has_subtype': api/byte_container_with_subtype/has_subtype.md
|
- 'has_subtype': api/byte_container_with_subtype/has_subtype.md
|
||||||
|
- 'operator==': api/byte_container_with_subtype/operator_eq.md
|
||||||
|
- 'operator!=': api/byte_container_with_subtype/operator_ne.md
|
||||||
- 'set_subtype': api/byte_container_with_subtype/set_subtype.md
|
- 'set_subtype': api/byte_container_with_subtype/set_subtype.md
|
||||||
- 'subtype': api/byte_container_with_subtype/subtype.md
|
- 'subtype': api/byte_container_with_subtype/subtype.md
|
||||||
|
- 'subtype_type': api/byte_container_with_subtype/subtype_type.md
|
||||||
- adl_serializer:
|
- adl_serializer:
|
||||||
- 'Overview': api/adl_serializer/index.md
|
- 'Overview': api/adl_serializer/index.md
|
||||||
- 'from_json': api/adl_serializer/from_json.md
|
- 'from_json': api/adl_serializer/from_json.md
|
||||||
@@ -256,25 +264,46 @@ nav:
|
|||||||
- 'to_string': api/json_pointer/to_string.md
|
- 'to_string': api/json_pointer/to_string.md
|
||||||
- json_sax:
|
- json_sax:
|
||||||
- 'Overview': api/json_sax/index.md
|
- 'Overview': api/json_sax/index.md
|
||||||
|
- '(Constructor)': api/json_sax/json_sax.md
|
||||||
|
- '(Destructor)': api/json_sax/~json_sax.md
|
||||||
|
- 'operator=': api/json_sax/operator=.md
|
||||||
- 'binary': api/json_sax/binary.md
|
- 'binary': api/json_sax/binary.md
|
||||||
|
- 'binary_t': api/json_sax/binary_t.md
|
||||||
- 'boolean': api/json_sax/boolean.md
|
- 'boolean': api/json_sax/boolean.md
|
||||||
- 'end_array': api/json_sax/end_array.md
|
- 'end_array': api/json_sax/end_array.md
|
||||||
- 'end_object': api/json_sax/end_object.md
|
- 'end_object': api/json_sax/end_object.md
|
||||||
- 'key': api/json_sax/key.md
|
- 'key': api/json_sax/key.md
|
||||||
- 'null': api/json_sax/null.md
|
- 'null': api/json_sax/null.md
|
||||||
- 'number_float': api/json_sax/number_float.md
|
- 'number_float': api/json_sax/number_float.md
|
||||||
|
- 'number_float_t': api/json_sax/number_float_t.md
|
||||||
- 'number_integer': api/json_sax/number_integer.md
|
- 'number_integer': api/json_sax/number_integer.md
|
||||||
|
- 'number_integer_t': api/json_sax/number_integer_t.md
|
||||||
- 'number_unsigned': api/json_sax/number_unsigned.md
|
- 'number_unsigned': api/json_sax/number_unsigned.md
|
||||||
|
- 'number_unsigned_t': api/json_sax/number_unsigned_t.md
|
||||||
- 'parse_error': api/json_sax/parse_error.md
|
- 'parse_error': api/json_sax/parse_error.md
|
||||||
- 'start_array': api/json_sax/start_array.md
|
- 'start_array': api/json_sax/start_array.md
|
||||||
- 'start_object': api/json_sax/start_object.md
|
- 'start_object': api/json_sax/start_object.md
|
||||||
- 'string': api/json_sax/string.md
|
- 'string': api/json_sax/string.md
|
||||||
|
- 'string_t': api/json_sax/string_t.md
|
||||||
- 'operator<<(basic_json), operator<<(json_pointer)': api/operator_ltlt.md
|
- 'operator<<(basic_json), operator<<(json_pointer)': api/operator_ltlt.md
|
||||||
- 'operator>>(basic_json)': api/operator_gtgt.md
|
- 'operator>>(basic_json)': api/operator_gtgt.md
|
||||||
- 'operator""_json': api/operator_literal_json.md
|
- 'operator""_json': api/operator_literal_json.md
|
||||||
- 'operator""_json_pointer': api/operator_literal_json_pointer.md
|
- 'operator""_json_pointer': api/operator_literal_json_pointer.md
|
||||||
- 'ordered_json': api/ordered_json.md
|
- 'ordered_json': api/ordered_json.md
|
||||||
- 'ordered_map': api/ordered_map.md
|
- ordered_map:
|
||||||
|
- 'Overview': api/ordered_map/index.md
|
||||||
|
- '(Constructor)': api/ordered_map/ordered_map.md
|
||||||
|
- '(Destructor)': api/ordered_map/~ordered_map.md
|
||||||
|
- 'operator=': api/ordered_map/operator=.md
|
||||||
|
- 'at': api/ordered_map/at.md
|
||||||
|
- 'Container': api/ordered_map/Container.md
|
||||||
|
- 'count': api/ordered_map/count.md
|
||||||
|
- 'emplace': api/ordered_map/emplace.md
|
||||||
|
- 'erase': api/ordered_map/erase.md
|
||||||
|
- 'find': api/ordered_map/find.md
|
||||||
|
- 'insert': api/ordered_map/insert.md
|
||||||
|
- 'key_compare': api/ordered_map/key_compare.md
|
||||||
|
- 'operator[]': api/ordered_map/operator[].md
|
||||||
- macros:
|
- macros:
|
||||||
- 'Overview': api/macros/index.md
|
- 'Overview': api/macros/index.md
|
||||||
- 'JSON_ASSERT': api/macros/json_assert.md
|
- 'JSON_ASSERT': api/macros/json_assert.md
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ template<typename BinaryType>
|
|||||||
class byte_container_with_subtype : public BinaryType
|
class byte_container_with_subtype : public BinaryType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/container_type/
|
||||||
using container_type = BinaryType;
|
using container_type = BinaryType;
|
||||||
|
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/subtype_type/
|
||||||
using subtype_type = std::uint64_t;
|
using subtype_type = std::uint64_t;
|
||||||
|
|
||||||
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/
|
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/
|
||||||
@@ -54,12 +56,14 @@ class byte_container_with_subtype : public BinaryType
|
|||||||
, m_has_subtype(true)
|
, m_has_subtype(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/operator_eq/
|
||||||
bool operator==(const byte_container_with_subtype& rhs) const
|
bool operator==(const byte_container_with_subtype& rhs) const
|
||||||
{
|
{
|
||||||
return std::tie(static_cast<const BinaryType&>(*this), m_subtype, m_has_subtype) ==
|
return std::tie(static_cast<const BinaryType&>(*this), m_subtype, m_has_subtype) ==
|
||||||
std::tie(static_cast<const BinaryType&>(rhs), rhs.m_subtype, rhs.m_has_subtype);
|
std::tie(static_cast<const BinaryType&>(rhs), rhs.m_subtype, rhs.m_has_subtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/operator_ne/
|
||||||
bool operator!=(const byte_container_with_subtype& rhs) const
|
bool operator!=(const byte_container_with_subtype& rhs) const
|
||||||
{
|
{
|
||||||
return !(rhs == *this);
|
return !(rhs == *this);
|
||||||
|
|||||||
@@ -220,29 +220,20 @@ class iterator_input_adapter
|
|||||||
// whether IteratorType refers to a contiguous range and therefore supports
|
// whether IteratorType refers to a contiguous range and therefore supports
|
||||||
// a std::memcpy fast path (pointers always do; in C++20 we can also detect
|
// a std::memcpy fast path (pointers always do; in C++20 we can also detect
|
||||||
// library iterators such as those of std::vector and std::string).
|
// library iterators such as those of std::vector and std::string).
|
||||||
// Computing the available element count needs either same-type iterators
|
// The fast path also requires SentinelType == IteratorType so std::distance works.
|
||||||
// (plain std::distance) or, in C++20, a sized sentinel (std::ranges::distance),
|
|
||||||
// e.g. std::counted_iterator paired with std::default_sentinel_t.
|
|
||||||
static constexpr bool iterator_is_contiguous =
|
static constexpr bool iterator_is_contiguous =
|
||||||
|
std::is_same<IteratorType, SentinelType>::value && (
|
||||||
#if defined(__cpp_lib_concepts) && defined(JSON_HAS_CPP_20)
|
#if defined(__cpp_lib_concepts) && defined(JSON_HAS_CPP_20)
|
||||||
(std::is_same<IteratorType, SentinelType>::value || std::sized_sentinel_for<SentinelType, IteratorType>)
|
std::contiguous_iterator<IteratorType> ||
|
||||||
&& (std::contiguous_iterator<IteratorType> || std::is_pointer<IteratorType>::value);
|
|
||||||
#else
|
|
||||||
std::is_same<IteratorType, SentinelType>::value && std::is_pointer<IteratorType>::value;
|
|
||||||
#endif
|
#endif
|
||||||
|
std::is_pointer<IteratorType>::value);
|
||||||
|
|
||||||
// contiguous fast path: bulk copy the remaining range with std::memcpy
|
// contiguous fast path: bulk copy the remaining range with std::memcpy
|
||||||
template<class T>
|
template<class T>
|
||||||
std::size_t get_elements_impl(T* dest, std::size_t count, std::true_type /*contiguous*/)
|
std::size_t get_elements_impl(T* dest, std::size_t count, std::true_type /*contiguous*/)
|
||||||
{
|
{
|
||||||
const std::size_t wanted = count * sizeof(T);
|
const std::size_t wanted = count * sizeof(T);
|
||||||
#if defined(__cpp_lib_concepts) && defined(JSON_HAS_CPP_20)
|
|
||||||
// std::ranges::distance also supports sized sentinels of a different
|
|
||||||
// type (e.g. std::counted_iterator + std::default_sentinel_t)
|
|
||||||
const std::size_t available = static_cast<std::size_t>(std::ranges::distance(current, end)) * sizeof(char_type);
|
|
||||||
#else
|
|
||||||
const std::size_t available = static_cast<std::size_t>(std::distance(current, end)) * sizeof(char_type);
|
const std::size_t available = static_cast<std::size_t>(std::distance(current, end)) * sizeof(char_type);
|
||||||
#endif
|
|
||||||
const std::size_t copied = (std::min)(wanted, available);
|
const std::size_t copied = (std::min)(wanted, available);
|
||||||
if (JSON_HEDLEY_LIKELY(copied != 0))
|
if (JSON_HEDLEY_LIKELY(copied != 0))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,15 +31,21 @@ input.
|
|||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
struct json_sax
|
struct json_sax
|
||||||
{
|
{
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/number_integer_t/
|
||||||
using number_integer_t = typename BasicJsonType::number_integer_t;
|
using number_integer_t = typename BasicJsonType::number_integer_t;
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/number_unsigned_t/
|
||||||
using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
|
using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/number_float_t/
|
||||||
using number_float_t = typename BasicJsonType::number_float_t;
|
using number_float_t = typename BasicJsonType::number_float_t;
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/string_t/
|
||||||
using string_t = typename BasicJsonType::string_t;
|
using string_t = typename BasicJsonType::string_t;
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/binary_t/
|
||||||
using binary_t = typename BasicJsonType::binary_t;
|
using binary_t = typename BasicJsonType::binary_t;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief a null value was read
|
@brief a null value was read
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/null/
|
||||||
*/
|
*/
|
||||||
virtual bool null() = 0;
|
virtual bool null() = 0;
|
||||||
|
|
||||||
@@ -47,6 +53,7 @@ struct json_sax
|
|||||||
@brief a boolean value was read
|
@brief a boolean value was read
|
||||||
@param[in] val boolean value
|
@param[in] val boolean value
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/boolean/
|
||||||
*/
|
*/
|
||||||
virtual bool boolean(bool val) = 0;
|
virtual bool boolean(bool val) = 0;
|
||||||
|
|
||||||
@@ -54,6 +61,7 @@ struct json_sax
|
|||||||
@brief an integer number was read
|
@brief an integer number was read
|
||||||
@param[in] val integer value
|
@param[in] val integer value
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/number_integer/
|
||||||
*/
|
*/
|
||||||
virtual bool number_integer(number_integer_t val) = 0;
|
virtual bool number_integer(number_integer_t val) = 0;
|
||||||
|
|
||||||
@@ -61,6 +69,7 @@ struct json_sax
|
|||||||
@brief an unsigned integer number was read
|
@brief an unsigned integer number was read
|
||||||
@param[in] val unsigned integer value
|
@param[in] val unsigned integer value
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/number_unsigned/
|
||||||
*/
|
*/
|
||||||
virtual bool number_unsigned(number_unsigned_t val) = 0;
|
virtual bool number_unsigned(number_unsigned_t val) = 0;
|
||||||
|
|
||||||
@@ -69,6 +78,7 @@ struct json_sax
|
|||||||
@param[in] val floating-point value
|
@param[in] val floating-point value
|
||||||
@param[in] s raw token value
|
@param[in] s raw token value
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/number_float/
|
||||||
*/
|
*/
|
||||||
virtual bool number_float(number_float_t val, const string_t& s) = 0;
|
virtual bool number_float(number_float_t val, const string_t& s) = 0;
|
||||||
|
|
||||||
@@ -77,6 +87,7 @@ struct json_sax
|
|||||||
@param[in] val string value
|
@param[in] val string value
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
@note It is safe to move the passed string value.
|
@note It is safe to move the passed string value.
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/string/
|
||||||
*/
|
*/
|
||||||
virtual bool string(string_t& val) = 0;
|
virtual bool string(string_t& val) = 0;
|
||||||
|
|
||||||
@@ -85,6 +96,7 @@ struct json_sax
|
|||||||
@param[in] val binary value
|
@param[in] val binary value
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
@note It is safe to move the passed binary value.
|
@note It is safe to move the passed binary value.
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/binary/
|
||||||
*/
|
*/
|
||||||
virtual bool binary(binary_t& val) = 0;
|
virtual bool binary(binary_t& val) = 0;
|
||||||
|
|
||||||
@@ -93,6 +105,7 @@ struct json_sax
|
|||||||
@param[in] elements number of object elements or -1 if unknown
|
@param[in] elements number of object elements or -1 if unknown
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
@note binary formats may report the number of elements
|
@note binary formats may report the number of elements
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/start_object/
|
||||||
*/
|
*/
|
||||||
virtual bool start_object(std::size_t elements) = 0;
|
virtual bool start_object(std::size_t elements) = 0;
|
||||||
|
|
||||||
@@ -101,12 +114,14 @@ struct json_sax
|
|||||||
@param[in] val object key
|
@param[in] val object key
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
@note It is safe to move the passed string.
|
@note It is safe to move the passed string.
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/key/
|
||||||
*/
|
*/
|
||||||
virtual bool key(string_t& val) = 0;
|
virtual bool key(string_t& val) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief the end of an object was read
|
@brief the end of an object was read
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/end_object/
|
||||||
*/
|
*/
|
||||||
virtual bool end_object() = 0;
|
virtual bool end_object() = 0;
|
||||||
|
|
||||||
@@ -115,12 +130,14 @@ struct json_sax
|
|||||||
@param[in] elements number of array elements or -1 if unknown
|
@param[in] elements number of array elements or -1 if unknown
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
@note binary formats may report the number of elements
|
@note binary formats may report the number of elements
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/start_array/
|
||||||
*/
|
*/
|
||||||
virtual bool start_array(std::size_t elements) = 0;
|
virtual bool start_array(std::size_t elements) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief the end of an array was read
|
@brief the end of an array was read
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/end_array/
|
||||||
*/
|
*/
|
||||||
virtual bool end_array() = 0;
|
virtual bool end_array() = 0;
|
||||||
|
|
||||||
@@ -130,16 +147,23 @@ struct json_sax
|
|||||||
@param[in] last_token the last read token
|
@param[in] last_token the last read token
|
||||||
@param[in] ex an exception object describing the error
|
@param[in] ex an exception object describing the error
|
||||||
@return whether parsing should proceed (must return false)
|
@return whether parsing should proceed (must return false)
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/parse_error/
|
||||||
*/
|
*/
|
||||||
virtual bool parse_error(std::size_t position,
|
virtual bool parse_error(std::size_t position,
|
||||||
const std::string& last_token,
|
const std::string& last_token,
|
||||||
const detail::exception& ex) = 0;
|
const detail::exception& ex) = 0;
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/json_sax/
|
||||||
json_sax() = default;
|
json_sax() = default;
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/json_sax/
|
||||||
json_sax(const json_sax&) = default;
|
json_sax(const json_sax&) = default;
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/json_sax/
|
||||||
json_sax(json_sax&&) noexcept = default;
|
json_sax(json_sax&&) noexcept = default;
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/operator=/
|
||||||
json_sax& operator=(const json_sax&) = default;
|
json_sax& operator=(const json_sax&) = default;
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/operator=/
|
||||||
json_sax& operator=(json_sax&&) noexcept = default;
|
json_sax& operator=(json_sax&&) noexcept = default;
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/~json_sax/
|
||||||
virtual ~json_sax() = default;
|
virtual ~json_sax() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ class json_pointer
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// for backwards compatibility accept BasicJsonType
|
// for backwards compatibility accept BasicJsonType
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_pointer/string_t/
|
||||||
using string_t = typename string_t_helper<RefStringType>::type;
|
using string_t = typename string_t_helper<RefStringType>::type;
|
||||||
|
|
||||||
/// @brief create JSON pointer
|
/// @brief create JSON pointer
|
||||||
|
|||||||
@@ -192,22 +192,31 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
using serializer = ::nlohmann::detail::serializer<basic_json>;
|
using serializer = ::nlohmann::detail::serializer<basic_json>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/// @brief the type of the JSON value
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/value_t/
|
||||||
using value_t = detail::value_t;
|
using value_t = detail::value_t;
|
||||||
/// JSON Pointer, see @ref nlohmann::json_pointer
|
/// JSON Pointer, see @ref nlohmann::json_pointer
|
||||||
using json_pointer = ::nlohmann::json_pointer<StringType>;
|
using json_pointer = ::nlohmann::json_pointer<StringType>;
|
||||||
template<typename T, typename SFINAE>
|
template<typename T, typename SFINAE>
|
||||||
using json_serializer = JSONSerializer<T, SFINAE>;
|
using json_serializer = JSONSerializer<T, SFINAE>;
|
||||||
/// how to treat decoding errors
|
/// how to treat decoding errors
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/error_handler_t/
|
||||||
using error_handler_t = detail::error_handler_t;
|
using error_handler_t = detail::error_handler_t;
|
||||||
/// how to treat CBOR tags
|
/// how to treat CBOR tags
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/cbor_tag_handler_t/
|
||||||
using cbor_tag_handler_t = detail::cbor_tag_handler_t;
|
using cbor_tag_handler_t = detail::cbor_tag_handler_t;
|
||||||
/// how to encode BJData
|
/// how to encode BJData
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/bjdata_version_t/
|
||||||
using bjdata_version_t = detail::bjdata_version_t;
|
using bjdata_version_t = detail::bjdata_version_t;
|
||||||
/// helper type for initializer lists of basic_json values
|
/// helper type for initializer lists of basic_json values
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/initializer_list_t/
|
||||||
using initializer_list_t = std::initializer_list<detail::json_ref<basic_json>>;
|
using initializer_list_t = std::initializer_list<detail::json_ref<basic_json>>;
|
||||||
|
|
||||||
|
/// @brief the type of the SAX interface used to parse and serialize the JSON value
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/input_format_t/
|
||||||
using input_format_t = detail::input_format_t;
|
using input_format_t = detail::input_format_t;
|
||||||
/// SAX interface type, see @ref nlohmann::json_sax
|
/// SAX interface type, see @ref nlohmann::json_sax
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/json_sax_t/
|
||||||
using json_sax_t = json_sax<basic_json>;
|
using json_sax_t = json_sax<basic_json>;
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
@@ -349,15 +358,19 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
/// the template arguments passed to class @ref basic_json.
|
/// the template arguments passed to class @ref basic_json.
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
|
#if defined(JSON_HAS_CPP_14)
|
||||||
/// @brief default object key comparator type
|
/// @brief default object key comparator type
|
||||||
/// The actual object key comparator type (@ref object_comparator_t) may be
|
/// The actual object key comparator type (@ref object_comparator_t) may be
|
||||||
/// different.
|
/// different.
|
||||||
/// @sa https://json.nlohmann.me/api/basic_json/default_object_comparator_t/
|
/// @sa https://json.nlohmann.me/api/basic_json/default_object_comparator_t/
|
||||||
#if defined(JSON_HAS_CPP_14)
|
|
||||||
// use of transparent comparator avoids unnecessary repeated construction of temporaries
|
// use of transparent comparator avoids unnecessary repeated construction of temporaries
|
||||||
// in functions involving lookup by key with types other than object_t::key_type (aka. StringType)
|
// in functions involving lookup by key with types other than object_t::key_type (aka. StringType)
|
||||||
using default_object_comparator_t = std::less<>;
|
using default_object_comparator_t = std::less<>;
|
||||||
#else
|
#else
|
||||||
|
/// @brief default object key comparator type
|
||||||
|
/// The actual object key comparator type (@ref object_comparator_t) may be
|
||||||
|
/// different.
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/default_object_comparator_t/
|
||||||
using default_object_comparator_t = std::less<StringType>;
|
using default_object_comparator_t = std::less<StringType>;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1182,6 +1195,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
// other constructors and destructor //
|
// other constructors and destructor //
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/basic_json/
|
||||||
template<typename JsonRef,
|
template<typename JsonRef,
|
||||||
detail::enable_if_t<detail::conjunction<detail::is_json_ref<JsonRef>,
|
detail::enable_if_t<detail::conjunction<detail::is_json_ref<JsonRef>,
|
||||||
std::is_same<typename JsonRef::value_type, basic_json>>::value, int> = 0 >
|
std::is_same<typename JsonRef::value_type, basic_json>>::value, int> = 0 >
|
||||||
@@ -1802,6 +1816,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
@throw what @ref json_serializer<ValueType> `from_json()` method throws if conversion is required
|
@throw what @ref json_serializer<ValueType> `from_json()` method throws if conversion is required
|
||||||
|
|
||||||
@since version 2.1.0
|
@since version 2.1.0
|
||||||
|
|
||||||
|
@sa https://json.nlohmann.me/api/basic_json/get/
|
||||||
*/
|
*/
|
||||||
template < typename ValueTypeCV, typename ValueType = detail::uncvref_t<ValueTypeCV>>
|
template < typename ValueTypeCV, typename ValueType = detail::uncvref_t<ValueTypeCV>>
|
||||||
#if defined(JSON_HAS_CPP_14)
|
#if defined(JSON_HAS_CPP_14)
|
||||||
@@ -1845,6 +1861,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
@sa see @ref get_ptr() for explicit pointer-member access
|
@sa see @ref get_ptr() for explicit pointer-member access
|
||||||
|
|
||||||
@since version 1.0.0
|
@since version 1.0.0
|
||||||
|
|
||||||
|
@sa https://json.nlohmann.me/api/basic_json/get/
|
||||||
*/
|
*/
|
||||||
template<typename PointerType, typename std::enable_if<
|
template<typename PointerType, typename std::enable_if<
|
||||||
std::is_pointer<PointerType>::value, int>::type = 0>
|
std::is_pointer<PointerType>::value, int>::type = 0>
|
||||||
@@ -1870,6 +1888,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
|
|
||||||
// specialization to allow calling get_to with a basic_json value
|
// specialization to allow calling get_to with a basic_json value
|
||||||
// see https://github.com/nlohmann/json/issues/2175
|
// see https://github.com/nlohmann/json/issues/2175
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/get_to/
|
||||||
template<typename ValueType,
|
template<typename ValueType,
|
||||||
detail::enable_if_t <
|
detail::enable_if_t <
|
||||||
detail::is_basic_json<ValueType>::value,
|
detail::is_basic_json<ValueType>::value,
|
||||||
@@ -1880,6 +1899,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/get_to/
|
||||||
template <
|
template <
|
||||||
typename T, std::size_t N,
|
typename T, std::size_t N,
|
||||||
typename Array = T (&)[N], // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
typename Array = T (&)[N], // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||||
@@ -1943,6 +1963,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
|
|
||||||
@since version 1.0.0
|
@since version 1.0.0
|
||||||
*/
|
*/
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_ValueType/
|
||||||
template < typename ValueType, typename std::enable_if <
|
template < typename ValueType, typename std::enable_if <
|
||||||
detail::conjunction <
|
detail::conjunction <
|
||||||
detail::negation<std::is_pointer<ValueType>>,
|
detail::negation<std::is_pointer<ValueType>>,
|
||||||
@@ -2224,12 +2245,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
|
|
||||||
// these two functions resolve a (const) char * ambiguity affecting Clang and MSVC
|
// these two functions resolve a (const) char * ambiguity affecting Clang and MSVC
|
||||||
// (they seemingly cannot be constrained to resolve the ambiguity)
|
// (they seemingly cannot be constrained to resolve the ambiguity)
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/operator[]/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
reference operator[](T* key)
|
reference operator[](T* key)
|
||||||
{
|
{
|
||||||
return operator[](typename object_t::key_type(key));
|
return operator[](typename object_t::key_type(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/operator[]/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
const_reference operator[](T* key) const
|
const_reference operator[](T* key) const
|
||||||
{
|
{
|
||||||
@@ -2439,6 +2462,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
JSON_THROW(type_error::create(306, detail::concat("cannot use value() with ", type_name()), this));
|
JSON_THROW(type_error::create(306, detail::concat("cannot use value() with ", type_name()), this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/value/
|
||||||
template < class ValueType, class BasicJsonType, detail::enable_if_t <
|
template < class ValueType, class BasicJsonType, detail::enable_if_t <
|
||||||
detail::is_basic_json<BasicJsonType>::value
|
detail::is_basic_json<BasicJsonType>::value
|
||||||
&& detail::is_getable<basic_json_t, ValueType>::value
|
&& detail::is_getable<basic_json_t, ValueType>::value
|
||||||
@@ -2449,6 +2473,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return value(ptr.convert(), default_value);
|
return value(ptr.convert(), default_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/value/
|
||||||
template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
|
template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
|
||||||
detail::enable_if_t <
|
detail::enable_if_t <
|
||||||
detail::is_basic_json<BasicJsonType>::value
|
detail::is_basic_json<BasicJsonType>::value
|
||||||
@@ -2818,6 +2843,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return ptr.contains(this);
|
return ptr.contains(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/contains/
|
||||||
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
||||||
bool contains(const typename ::nlohmann::json_pointer<BasicJsonType>& ptr) const
|
bool contains(const typename ::nlohmann::json_pointer<BasicJsonType>& ptr) const
|
||||||
@@ -4100,6 +4126,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/parse/
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, parse(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, parse(ptr, ptr + len))
|
||||||
static basic_json parse(detail::span_input_adapter&& i,
|
static basic_json parse(detail::span_input_adapter&& i,
|
||||||
@@ -4134,6 +4161,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return parser(detail::input_adapter(std::move(first), std::move(last)), nullptr, false, ignore_comments, ignore_trailing_commas).accept(true);
|
return parser(detail::input_adapter(std::move(first), std::move(last)), nullptr, false, ignore_comments, ignore_trailing_commas).accept(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/accept/
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, accept(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, accept(ptr, ptr + len))
|
||||||
static bool accept(detail::span_input_adapter&& i,
|
static bool accept(detail::span_input_adapter&& i,
|
||||||
@@ -4481,6 +4509,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return res ? result : basic_json(value_t::discarded);
|
return res ? result : basic_json(value_t::discarded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/from_cbor/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len))
|
||||||
@@ -4492,6 +4521,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
|
return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/from_cbor/
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len))
|
||||||
static basic_json from_cbor(detail::span_input_adapter&& i,
|
static basic_json from_cbor(detail::span_input_adapter&& i,
|
||||||
@@ -4538,6 +4568,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return res ? result : basic_json(value_t::discarded);
|
return res ? result : basic_json(value_t::discarded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/from_msgpack/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len))
|
||||||
@@ -4548,6 +4579,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
|
return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/from_msgpack/
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len))
|
||||||
static basic_json from_msgpack(detail::span_input_adapter&& i,
|
static basic_json from_msgpack(detail::span_input_adapter&& i,
|
||||||
@@ -4593,6 +4625,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return res ? result : basic_json(value_t::discarded);
|
return res ? result : basic_json(value_t::discarded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/from_ubjson/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len))
|
||||||
@@ -4603,6 +4636,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
|
return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/from_ubjson/
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len))
|
||||||
static basic_json from_ubjson(detail::span_input_adapter&& i,
|
static basic_json from_ubjson(detail::span_input_adapter&& i,
|
||||||
@@ -4679,6 +4713,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return res ? result : basic_json(value_t::discarded);
|
return res ? result : basic_json(value_t::discarded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/from_bson/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len))
|
||||||
@@ -4689,6 +4724,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return from_bson(ptr, ptr + len, strict, allow_exceptions);
|
return from_bson(ptr, ptr + len, strict, allow_exceptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/from_bson/
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len))
|
||||||
static basic_json from_bson(detail::span_input_adapter&& i,
|
static basic_json from_bson(detail::span_input_adapter&& i,
|
||||||
@@ -4718,6 +4754,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return ptr.get_unchecked(this);
|
return ptr.get_unchecked(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/operator%5B%5D/
|
||||||
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
||||||
reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr)
|
reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr)
|
||||||
@@ -4732,6 +4769,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return ptr.get_unchecked(this);
|
return ptr.get_unchecked(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/operator%5B%5D/
|
||||||
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
||||||
const_reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr) const
|
const_reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr) const
|
||||||
@@ -4746,6 +4784,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return ptr.get_checked(this);
|
return ptr.get_checked(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/at/
|
||||||
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
||||||
reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr)
|
reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr)
|
||||||
@@ -4760,6 +4799,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return ptr.get_checked(this);
|
return ptr.get_checked(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/at/
|
||||||
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
||||||
const_reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr) const
|
const_reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr) const
|
||||||
|
|||||||
@@ -30,30 +30,41 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
{
|
{
|
||||||
using key_type = Key;
|
using key_type = Key;
|
||||||
using mapped_type = T;
|
using mapped_type = T;
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/Container/
|
||||||
using Container = std::vector<std::pair<const Key, T>, Allocator>;
|
using Container = std::vector<std::pair<const Key, T>, Allocator>;
|
||||||
using iterator = typename Container::iterator;
|
using iterator = typename Container::iterator;
|
||||||
using const_iterator = typename Container::const_iterator;
|
using const_iterator = typename Container::const_iterator;
|
||||||
using size_type = typename Container::size_type;
|
using size_type = typename Container::size_type;
|
||||||
using value_type = typename Container::value_type;
|
using value_type = typename Container::value_type;
|
||||||
#ifdef JSON_HAS_CPP_14
|
#ifdef JSON_HAS_CPP_14
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/key_compare/
|
||||||
using key_compare = std::equal_to<>;
|
using key_compare = std::equal_to<>;
|
||||||
#else
|
#else
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/key_compare/
|
||||||
using key_compare = std::equal_to<Key>;
|
using key_compare = std::equal_to<Key>;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Explicit constructors instead of `using Container::Container`
|
// Explicit constructors instead of `using Container::Container`
|
||||||
// otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4)
|
// otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4)
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/ordered_map/
|
||||||
ordered_map() noexcept(noexcept(Container())) : Container{} {}
|
ordered_map() noexcept(noexcept(Container())) : Container{} {}
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/ordered_map/
|
||||||
explicit ordered_map(const Allocator& alloc) noexcept(noexcept(Container(alloc))) : Container{alloc} {}
|
explicit ordered_map(const Allocator& alloc) noexcept(noexcept(Container(alloc))) : Container{alloc} {}
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/ordered_map/
|
||||||
template <class It>
|
template <class It>
|
||||||
ordered_map(It first, It last, const Allocator& alloc = Allocator())
|
ordered_map(It first, It last, const Allocator& alloc = Allocator())
|
||||||
: Container{first, last, alloc} {}
|
: Container{first, last, alloc} {}
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/ordered_map/
|
||||||
ordered_map(std::initializer_list<value_type> init, const Allocator& alloc = Allocator() )
|
ordered_map(std::initializer_list<value_type> init, const Allocator& alloc = Allocator() )
|
||||||
: Container{init, alloc} {}
|
: Container{init, alloc} {}
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/ordered_map/
|
||||||
ordered_map(const ordered_map&) = default;
|
ordered_map(const ordered_map&) = default;
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/ordered_map/
|
||||||
ordered_map(ordered_map&&) noexcept(std::is_nothrow_move_constructible<Container>::value) = default;
|
ordered_map(ordered_map&&) noexcept(std::is_nothrow_move_constructible<Container>::value) = default;
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/~ordered_map/
|
||||||
~ordered_map() = default;
|
~ordered_map() = default;
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/operator=/
|
||||||
ordered_map& operator=(const ordered_map& other)
|
ordered_map& operator=(const ordered_map& other)
|
||||||
{
|
{
|
||||||
if (this != &other)
|
if (this != &other)
|
||||||
@@ -64,12 +75,14 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/operator=/
|
||||||
ordered_map& operator=(ordered_map&& other) noexcept(std::is_nothrow_move_assignable<Container>::value)
|
ordered_map& operator=(ordered_map&& other) noexcept(std::is_nothrow_move_assignable<Container>::value)
|
||||||
{
|
{
|
||||||
Container::operator=(std::move(static_cast<Container&>(other)));
|
Container::operator=(std::move(static_cast<Container&>(other)));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/emplace/
|
||||||
std::pair<iterator, bool> emplace(const key_type& key, T&& t)
|
std::pair<iterator, bool> emplace(const key_type& key, T&& t)
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
@@ -83,6 +96,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return {std::prev(this->end()), true};
|
return {std::prev(this->end()), true};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/emplace/
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
std::pair<iterator, bool> emplace(KeyType && key, T && t)
|
std::pair<iterator, bool> emplace(KeyType && key, T && t)
|
||||||
@@ -98,11 +112,13 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return {std::prev(this->end()), true};
|
return {std::prev(this->end()), true};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/operator[]/
|
||||||
T& operator[](const key_type& key)
|
T& operator[](const key_type& key)
|
||||||
{
|
{
|
||||||
return emplace(key, T{}).first->second;
|
return emplace(key, T{}).first->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/operator[]/
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
T & operator[](KeyType && key)
|
T & operator[](KeyType && key)
|
||||||
@@ -110,11 +126,13 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return emplace(std::forward<KeyType>(key), T{}).first->second;
|
return emplace(std::forward<KeyType>(key), T{}).first->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/operator[]/
|
||||||
const T& operator[](const key_type& key) const
|
const T& operator[](const key_type& key) const
|
||||||
{
|
{
|
||||||
return at(key);
|
return at(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/operator[]/
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
const T & operator[](KeyType && key) const
|
const T & operator[](KeyType && key) const
|
||||||
@@ -122,6 +140,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return at(std::forward<KeyType>(key));
|
return at(std::forward<KeyType>(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/at/
|
||||||
T& at(const key_type& key)
|
T& at(const key_type& key)
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
@@ -135,6 +154,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
JSON_THROW(std::out_of_range("key not found"));
|
JSON_THROW(std::out_of_range("key not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/at/
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
T & at(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
|
T & at(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
|
||||||
@@ -150,6 +170,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
JSON_THROW(std::out_of_range("key not found"));
|
JSON_THROW(std::out_of_range("key not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/at/
|
||||||
const T& at(const key_type& key) const
|
const T& at(const key_type& key) const
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
@@ -163,6 +184,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
JSON_THROW(std::out_of_range("key not found"));
|
JSON_THROW(std::out_of_range("key not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/at/
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
const T & at(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
|
const T & at(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
|
||||||
@@ -178,6 +200,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
JSON_THROW(std::out_of_range("key not found"));
|
JSON_THROW(std::out_of_range("key not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/erase/
|
||||||
size_type erase(const key_type& key)
|
size_type erase(const key_type& key)
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
@@ -197,6 +220,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/erase/
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
size_type erase(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
|
size_type erase(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
|
||||||
@@ -218,11 +242,13 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/erase/
|
||||||
iterator erase(iterator pos)
|
iterator erase(iterator pos)
|
||||||
{
|
{
|
||||||
return erase(pos, std::next(pos));
|
return erase(pos, std::next(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/erase/
|
||||||
iterator erase(iterator first, iterator last)
|
iterator erase(iterator first, iterator last)
|
||||||
{
|
{
|
||||||
if (first == last)
|
if (first == last)
|
||||||
@@ -276,6 +302,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return Container::begin() + offset;
|
return Container::begin() + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/count/
|
||||||
size_type count(const key_type& key) const
|
size_type count(const key_type& key) const
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
@@ -288,6 +315,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/count/
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
size_type count(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
|
size_type count(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
|
||||||
@@ -302,6 +330,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/find/
|
||||||
iterator find(const key_type& key)
|
iterator find(const key_type& key)
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
@@ -314,6 +343,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return Container::end();
|
return Container::end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/find/
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
iterator find(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
|
iterator find(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
|
||||||
@@ -328,6 +358,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return Container::end();
|
return Container::end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/find/
|
||||||
const_iterator find(const key_type& key) const
|
const_iterator find(const key_type& key) const
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
@@ -340,6 +371,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return Container::end();
|
return Container::end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/find/
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
const_iterator find(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
|
const_iterator find(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
|
||||||
@@ -354,11 +386,13 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return Container::end();
|
return Container::end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/insert/
|
||||||
std::pair<iterator, bool> insert( value_type&& value )
|
std::pair<iterator, bool> insert( value_type&& value )
|
||||||
{
|
{
|
||||||
return emplace(value.first, std::move(value.second));
|
return emplace(value.first, std::move(value.second));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/insert/
|
||||||
std::pair<iterator, bool> insert( const value_type& value )
|
std::pair<iterator, bool> insert( const value_type& value )
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
@@ -376,6 +410,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
using require_input_iter = typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
|
using require_input_iter = typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
|
||||||
std::input_iterator_tag>::value>::type;
|
std::input_iterator_tag>::value>::type;
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/insert/
|
||||||
template<typename InputIt, typename = require_input_iter<InputIt>>
|
template<typename InputIt, typename = require_input_iter<InputIt>>
|
||||||
void insert(InputIt first, InputIt last)
|
void insert(InputIt first, InputIt last)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6732,7 +6732,9 @@ template<typename BinaryType>
|
|||||||
class byte_container_with_subtype : public BinaryType
|
class byte_container_with_subtype : public BinaryType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/container_type/
|
||||||
using container_type = BinaryType;
|
using container_type = BinaryType;
|
||||||
|
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/subtype_type/
|
||||||
using subtype_type = std::uint64_t;
|
using subtype_type = std::uint64_t;
|
||||||
|
|
||||||
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/
|
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/
|
||||||
@@ -6764,12 +6766,14 @@ class byte_container_with_subtype : public BinaryType
|
|||||||
, m_has_subtype(true)
|
, m_has_subtype(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/operator_eq/
|
||||||
bool operator==(const byte_container_with_subtype& rhs) const
|
bool operator==(const byte_container_with_subtype& rhs) const
|
||||||
{
|
{
|
||||||
return std::tie(static_cast<const BinaryType&>(*this), m_subtype, m_has_subtype) ==
|
return std::tie(static_cast<const BinaryType&>(*this), m_subtype, m_has_subtype) ==
|
||||||
std::tie(static_cast<const BinaryType&>(rhs), rhs.m_subtype, rhs.m_has_subtype);
|
std::tie(static_cast<const BinaryType&>(rhs), rhs.m_subtype, rhs.m_has_subtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/operator_ne/
|
||||||
bool operator!=(const byte_container_with_subtype& rhs) const
|
bool operator!=(const byte_container_with_subtype& rhs) const
|
||||||
{
|
{
|
||||||
return !(rhs == *this);
|
return !(rhs == *this);
|
||||||
@@ -7207,29 +7211,20 @@ class iterator_input_adapter
|
|||||||
// whether IteratorType refers to a contiguous range and therefore supports
|
// whether IteratorType refers to a contiguous range and therefore supports
|
||||||
// a std::memcpy fast path (pointers always do; in C++20 we can also detect
|
// a std::memcpy fast path (pointers always do; in C++20 we can also detect
|
||||||
// library iterators such as those of std::vector and std::string).
|
// library iterators such as those of std::vector and std::string).
|
||||||
// Computing the available element count needs either same-type iterators
|
// The fast path also requires SentinelType == IteratorType so std::distance works.
|
||||||
// (plain std::distance) or, in C++20, a sized sentinel (std::ranges::distance),
|
|
||||||
// e.g. std::counted_iterator paired with std::default_sentinel_t.
|
|
||||||
static constexpr bool iterator_is_contiguous =
|
static constexpr bool iterator_is_contiguous =
|
||||||
|
std::is_same<IteratorType, SentinelType>::value && (
|
||||||
#if defined(__cpp_lib_concepts) && defined(JSON_HAS_CPP_20)
|
#if defined(__cpp_lib_concepts) && defined(JSON_HAS_CPP_20)
|
||||||
(std::is_same<IteratorType, SentinelType>::value || std::sized_sentinel_for<SentinelType, IteratorType>)
|
std::contiguous_iterator<IteratorType> ||
|
||||||
&& (std::contiguous_iterator<IteratorType> || std::is_pointer<IteratorType>::value);
|
|
||||||
#else
|
|
||||||
std::is_same<IteratorType, SentinelType>::value && std::is_pointer<IteratorType>::value;
|
|
||||||
#endif
|
#endif
|
||||||
|
std::is_pointer<IteratorType>::value);
|
||||||
|
|
||||||
// contiguous fast path: bulk copy the remaining range with std::memcpy
|
// contiguous fast path: bulk copy the remaining range with std::memcpy
|
||||||
template<class T>
|
template<class T>
|
||||||
std::size_t get_elements_impl(T* dest, std::size_t count, std::true_type /*contiguous*/)
|
std::size_t get_elements_impl(T* dest, std::size_t count, std::true_type /*contiguous*/)
|
||||||
{
|
{
|
||||||
const std::size_t wanted = count * sizeof(T);
|
const std::size_t wanted = count * sizeof(T);
|
||||||
#if defined(__cpp_lib_concepts) && defined(JSON_HAS_CPP_20)
|
|
||||||
// std::ranges::distance also supports sized sentinels of a different
|
|
||||||
// type (e.g. std::counted_iterator + std::default_sentinel_t)
|
|
||||||
const std::size_t available = static_cast<std::size_t>(std::ranges::distance(current, end)) * sizeof(char_type);
|
|
||||||
#else
|
|
||||||
const std::size_t available = static_cast<std::size_t>(std::distance(current, end)) * sizeof(char_type);
|
const std::size_t available = static_cast<std::size_t>(std::distance(current, end)) * sizeof(char_type);
|
||||||
#endif
|
|
||||||
const std::size_t copied = (std::min)(wanted, available);
|
const std::size_t copied = (std::min)(wanted, available);
|
||||||
if (JSON_HEDLEY_LIKELY(copied != 0))
|
if (JSON_HEDLEY_LIKELY(copied != 0))
|
||||||
{
|
{
|
||||||
@@ -9441,15 +9436,21 @@ input.
|
|||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
struct json_sax
|
struct json_sax
|
||||||
{
|
{
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/number_integer_t/
|
||||||
using number_integer_t = typename BasicJsonType::number_integer_t;
|
using number_integer_t = typename BasicJsonType::number_integer_t;
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/number_unsigned_t/
|
||||||
using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
|
using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/number_float_t/
|
||||||
using number_float_t = typename BasicJsonType::number_float_t;
|
using number_float_t = typename BasicJsonType::number_float_t;
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/string_t/
|
||||||
using string_t = typename BasicJsonType::string_t;
|
using string_t = typename BasicJsonType::string_t;
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/binary_t/
|
||||||
using binary_t = typename BasicJsonType::binary_t;
|
using binary_t = typename BasicJsonType::binary_t;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief a null value was read
|
@brief a null value was read
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/null/
|
||||||
*/
|
*/
|
||||||
virtual bool null() = 0;
|
virtual bool null() = 0;
|
||||||
|
|
||||||
@@ -9457,6 +9458,7 @@ struct json_sax
|
|||||||
@brief a boolean value was read
|
@brief a boolean value was read
|
||||||
@param[in] val boolean value
|
@param[in] val boolean value
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/boolean/
|
||||||
*/
|
*/
|
||||||
virtual bool boolean(bool val) = 0;
|
virtual bool boolean(bool val) = 0;
|
||||||
|
|
||||||
@@ -9464,6 +9466,7 @@ struct json_sax
|
|||||||
@brief an integer number was read
|
@brief an integer number was read
|
||||||
@param[in] val integer value
|
@param[in] val integer value
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/number_integer/
|
||||||
*/
|
*/
|
||||||
virtual bool number_integer(number_integer_t val) = 0;
|
virtual bool number_integer(number_integer_t val) = 0;
|
||||||
|
|
||||||
@@ -9471,6 +9474,7 @@ struct json_sax
|
|||||||
@brief an unsigned integer number was read
|
@brief an unsigned integer number was read
|
||||||
@param[in] val unsigned integer value
|
@param[in] val unsigned integer value
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/number_unsigned/
|
||||||
*/
|
*/
|
||||||
virtual bool number_unsigned(number_unsigned_t val) = 0;
|
virtual bool number_unsigned(number_unsigned_t val) = 0;
|
||||||
|
|
||||||
@@ -9479,6 +9483,7 @@ struct json_sax
|
|||||||
@param[in] val floating-point value
|
@param[in] val floating-point value
|
||||||
@param[in] s raw token value
|
@param[in] s raw token value
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/number_float/
|
||||||
*/
|
*/
|
||||||
virtual bool number_float(number_float_t val, const string_t& s) = 0;
|
virtual bool number_float(number_float_t val, const string_t& s) = 0;
|
||||||
|
|
||||||
@@ -9487,6 +9492,7 @@ struct json_sax
|
|||||||
@param[in] val string value
|
@param[in] val string value
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
@note It is safe to move the passed string value.
|
@note It is safe to move the passed string value.
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/string/
|
||||||
*/
|
*/
|
||||||
virtual bool string(string_t& val) = 0;
|
virtual bool string(string_t& val) = 0;
|
||||||
|
|
||||||
@@ -9495,6 +9501,7 @@ struct json_sax
|
|||||||
@param[in] val binary value
|
@param[in] val binary value
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
@note It is safe to move the passed binary value.
|
@note It is safe to move the passed binary value.
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/binary/
|
||||||
*/
|
*/
|
||||||
virtual bool binary(binary_t& val) = 0;
|
virtual bool binary(binary_t& val) = 0;
|
||||||
|
|
||||||
@@ -9503,6 +9510,7 @@ struct json_sax
|
|||||||
@param[in] elements number of object elements or -1 if unknown
|
@param[in] elements number of object elements or -1 if unknown
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
@note binary formats may report the number of elements
|
@note binary formats may report the number of elements
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/start_object/
|
||||||
*/
|
*/
|
||||||
virtual bool start_object(std::size_t elements) = 0;
|
virtual bool start_object(std::size_t elements) = 0;
|
||||||
|
|
||||||
@@ -9511,12 +9519,14 @@ struct json_sax
|
|||||||
@param[in] val object key
|
@param[in] val object key
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
@note It is safe to move the passed string.
|
@note It is safe to move the passed string.
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/key/
|
||||||
*/
|
*/
|
||||||
virtual bool key(string_t& val) = 0;
|
virtual bool key(string_t& val) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief the end of an object was read
|
@brief the end of an object was read
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/end_object/
|
||||||
*/
|
*/
|
||||||
virtual bool end_object() = 0;
|
virtual bool end_object() = 0;
|
||||||
|
|
||||||
@@ -9525,12 +9535,14 @@ struct json_sax
|
|||||||
@param[in] elements number of array elements or -1 if unknown
|
@param[in] elements number of array elements or -1 if unknown
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
@note binary formats may report the number of elements
|
@note binary formats may report the number of elements
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/start_array/
|
||||||
*/
|
*/
|
||||||
virtual bool start_array(std::size_t elements) = 0;
|
virtual bool start_array(std::size_t elements) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief the end of an array was read
|
@brief the end of an array was read
|
||||||
@return whether parsing should proceed
|
@return whether parsing should proceed
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/end_array/
|
||||||
*/
|
*/
|
||||||
virtual bool end_array() = 0;
|
virtual bool end_array() = 0;
|
||||||
|
|
||||||
@@ -9540,16 +9552,23 @@ struct json_sax
|
|||||||
@param[in] last_token the last read token
|
@param[in] last_token the last read token
|
||||||
@param[in] ex an exception object describing the error
|
@param[in] ex an exception object describing the error
|
||||||
@return whether parsing should proceed (must return false)
|
@return whether parsing should proceed (must return false)
|
||||||
|
@sa https://json.nlohmann.me/api/json_sax/parse_error/
|
||||||
*/
|
*/
|
||||||
virtual bool parse_error(std::size_t position,
|
virtual bool parse_error(std::size_t position,
|
||||||
const std::string& last_token,
|
const std::string& last_token,
|
||||||
const detail::exception& ex) = 0;
|
const detail::exception& ex) = 0;
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/json_sax/
|
||||||
json_sax() = default;
|
json_sax() = default;
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/json_sax/
|
||||||
json_sax(const json_sax&) = default;
|
json_sax(const json_sax&) = default;
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/json_sax/
|
||||||
json_sax(json_sax&&) noexcept = default;
|
json_sax(json_sax&&) noexcept = default;
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/operator=/
|
||||||
json_sax& operator=(const json_sax&) = default;
|
json_sax& operator=(const json_sax&) = default;
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/operator=/
|
||||||
json_sax& operator=(json_sax&&) noexcept = default;
|
json_sax& operator=(json_sax&&) noexcept = default;
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_sax/~json_sax/
|
||||||
virtual ~json_sax() = default;
|
virtual ~json_sax() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -15404,6 +15423,7 @@ class json_pointer
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// for backwards compatibility accept BasicJsonType
|
// for backwards compatibility accept BasicJsonType
|
||||||
|
/// @sa https://json.nlohmann.me/api/json_pointer/string_t/
|
||||||
using string_t = typename string_t_helper<RefStringType>::type;
|
using string_t = typename string_t_helper<RefStringType>::type;
|
||||||
|
|
||||||
/// @brief create JSON pointer
|
/// @brief create JSON pointer
|
||||||
@@ -20766,30 +20786,41 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
{
|
{
|
||||||
using key_type = Key;
|
using key_type = Key;
|
||||||
using mapped_type = T;
|
using mapped_type = T;
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/Container/
|
||||||
using Container = std::vector<std::pair<const Key, T>, Allocator>;
|
using Container = std::vector<std::pair<const Key, T>, Allocator>;
|
||||||
using iterator = typename Container::iterator;
|
using iterator = typename Container::iterator;
|
||||||
using const_iterator = typename Container::const_iterator;
|
using const_iterator = typename Container::const_iterator;
|
||||||
using size_type = typename Container::size_type;
|
using size_type = typename Container::size_type;
|
||||||
using value_type = typename Container::value_type;
|
using value_type = typename Container::value_type;
|
||||||
#ifdef JSON_HAS_CPP_14
|
#ifdef JSON_HAS_CPP_14
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/key_compare/
|
||||||
using key_compare = std::equal_to<>;
|
using key_compare = std::equal_to<>;
|
||||||
#else
|
#else
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/key_compare/
|
||||||
using key_compare = std::equal_to<Key>;
|
using key_compare = std::equal_to<Key>;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Explicit constructors instead of `using Container::Container`
|
// Explicit constructors instead of `using Container::Container`
|
||||||
// otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4)
|
// otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4)
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/ordered_map/
|
||||||
ordered_map() noexcept(noexcept(Container())) : Container{} {}
|
ordered_map() noexcept(noexcept(Container())) : Container{} {}
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/ordered_map/
|
||||||
explicit ordered_map(const Allocator& alloc) noexcept(noexcept(Container(alloc))) : Container{alloc} {}
|
explicit ordered_map(const Allocator& alloc) noexcept(noexcept(Container(alloc))) : Container{alloc} {}
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/ordered_map/
|
||||||
template <class It>
|
template <class It>
|
||||||
ordered_map(It first, It last, const Allocator& alloc = Allocator())
|
ordered_map(It first, It last, const Allocator& alloc = Allocator())
|
||||||
: Container{first, last, alloc} {}
|
: Container{first, last, alloc} {}
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/ordered_map/
|
||||||
ordered_map(std::initializer_list<value_type> init, const Allocator& alloc = Allocator() )
|
ordered_map(std::initializer_list<value_type> init, const Allocator& alloc = Allocator() )
|
||||||
: Container{init, alloc} {}
|
: Container{init, alloc} {}
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/ordered_map/
|
||||||
ordered_map(const ordered_map&) = default;
|
ordered_map(const ordered_map&) = default;
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/ordered_map/
|
||||||
ordered_map(ordered_map&&) noexcept(std::is_nothrow_move_constructible<Container>::value) = default;
|
ordered_map(ordered_map&&) noexcept(std::is_nothrow_move_constructible<Container>::value) = default;
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/~ordered_map/
|
||||||
~ordered_map() = default;
|
~ordered_map() = default;
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/operator=/
|
||||||
ordered_map& operator=(const ordered_map& other)
|
ordered_map& operator=(const ordered_map& other)
|
||||||
{
|
{
|
||||||
if (this != &other)
|
if (this != &other)
|
||||||
@@ -20800,12 +20831,14 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/operator=/
|
||||||
ordered_map& operator=(ordered_map&& other) noexcept(std::is_nothrow_move_assignable<Container>::value)
|
ordered_map& operator=(ordered_map&& other) noexcept(std::is_nothrow_move_assignable<Container>::value)
|
||||||
{
|
{
|
||||||
Container::operator=(std::move(static_cast<Container&>(other)));
|
Container::operator=(std::move(static_cast<Container&>(other)));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/emplace/
|
||||||
std::pair<iterator, bool> emplace(const key_type& key, T&& t)
|
std::pair<iterator, bool> emplace(const key_type& key, T&& t)
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
@@ -20819,6 +20852,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return {std::prev(this->end()), true};
|
return {std::prev(this->end()), true};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/emplace/
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
std::pair<iterator, bool> emplace(KeyType && key, T && t)
|
std::pair<iterator, bool> emplace(KeyType && key, T && t)
|
||||||
@@ -20834,11 +20868,13 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return {std::prev(this->end()), true};
|
return {std::prev(this->end()), true};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/operator[]/
|
||||||
T& operator[](const key_type& key)
|
T& operator[](const key_type& key)
|
||||||
{
|
{
|
||||||
return emplace(key, T{}).first->second;
|
return emplace(key, T{}).first->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/operator[]/
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
T & operator[](KeyType && key)
|
T & operator[](KeyType && key)
|
||||||
@@ -20846,11 +20882,13 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return emplace(std::forward<KeyType>(key), T{}).first->second;
|
return emplace(std::forward<KeyType>(key), T{}).first->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/operator[]/
|
||||||
const T& operator[](const key_type& key) const
|
const T& operator[](const key_type& key) const
|
||||||
{
|
{
|
||||||
return at(key);
|
return at(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/operator[]/
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
const T & operator[](KeyType && key) const
|
const T & operator[](KeyType && key) const
|
||||||
@@ -20858,6 +20896,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return at(std::forward<KeyType>(key));
|
return at(std::forward<KeyType>(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/at/
|
||||||
T& at(const key_type& key)
|
T& at(const key_type& key)
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
@@ -20871,6 +20910,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
JSON_THROW(std::out_of_range("key not found"));
|
JSON_THROW(std::out_of_range("key not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/at/
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
T & at(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
|
T & at(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
|
||||||
@@ -20886,6 +20926,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
JSON_THROW(std::out_of_range("key not found"));
|
JSON_THROW(std::out_of_range("key not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/at/
|
||||||
const T& at(const key_type& key) const
|
const T& at(const key_type& key) const
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
@@ -20899,6 +20940,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
JSON_THROW(std::out_of_range("key not found"));
|
JSON_THROW(std::out_of_range("key not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/at/
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
const T & at(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
|
const T & at(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
|
||||||
@@ -20914,6 +20956,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
JSON_THROW(std::out_of_range("key not found"));
|
JSON_THROW(std::out_of_range("key not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/erase/
|
||||||
size_type erase(const key_type& key)
|
size_type erase(const key_type& key)
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
@@ -20933,6 +20976,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/erase/
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
size_type erase(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
|
size_type erase(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
|
||||||
@@ -20954,11 +20998,13 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/erase/
|
||||||
iterator erase(iterator pos)
|
iterator erase(iterator pos)
|
||||||
{
|
{
|
||||||
return erase(pos, std::next(pos));
|
return erase(pos, std::next(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/erase/
|
||||||
iterator erase(iterator first, iterator last)
|
iterator erase(iterator first, iterator last)
|
||||||
{
|
{
|
||||||
if (first == last)
|
if (first == last)
|
||||||
@@ -21012,6 +21058,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return Container::begin() + offset;
|
return Container::begin() + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/count/
|
||||||
size_type count(const key_type& key) const
|
size_type count(const key_type& key) const
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
@@ -21024,6 +21071,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/count/
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
size_type count(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
|
size_type count(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
|
||||||
@@ -21038,6 +21086,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/find/
|
||||||
iterator find(const key_type& key)
|
iterator find(const key_type& key)
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
@@ -21050,6 +21099,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return Container::end();
|
return Container::end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/find/
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
iterator find(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
|
iterator find(KeyType && key) // NOLINT(cppcoreguidelines-missing-std-forward)
|
||||||
@@ -21064,6 +21114,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return Container::end();
|
return Container::end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/find/
|
||||||
const_iterator find(const key_type& key) const
|
const_iterator find(const key_type& key) const
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
@@ -21076,6 +21127,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return Container::end();
|
return Container::end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/find/
|
||||||
template<class KeyType, detail::enable_if_t<
|
template<class KeyType, detail::enable_if_t<
|
||||||
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
const_iterator find(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
|
const_iterator find(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
|
||||||
@@ -21090,11 +21142,13 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return Container::end();
|
return Container::end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/insert/
|
||||||
std::pair<iterator, bool> insert( value_type&& value )
|
std::pair<iterator, bool> insert( value_type&& value )
|
||||||
{
|
{
|
||||||
return emplace(value.first, std::move(value.second));
|
return emplace(value.first, std::move(value.second));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/insert/
|
||||||
std::pair<iterator, bool> insert( const value_type& value )
|
std::pair<iterator, bool> insert( const value_type& value )
|
||||||
{
|
{
|
||||||
for (auto it = this->begin(); it != this->end(); ++it)
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
@@ -21112,6 +21166,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
using require_input_iter = typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
|
using require_input_iter = typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
|
||||||
std::input_iterator_tag>::value>::type;
|
std::input_iterator_tag>::value>::type;
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/ordered_map/insert/
|
||||||
template<typename InputIt, typename = require_input_iter<InputIt>>
|
template<typename InputIt, typename = require_input_iter<InputIt>>
|
||||||
void insert(InputIt first, InputIt last)
|
void insert(InputIt first, InputIt last)
|
||||||
{
|
{
|
||||||
@@ -21248,22 +21303,31 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
using serializer = ::nlohmann::detail::serializer<basic_json>;
|
using serializer = ::nlohmann::detail::serializer<basic_json>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/// @brief the type of the JSON value
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/value_t/
|
||||||
using value_t = detail::value_t;
|
using value_t = detail::value_t;
|
||||||
/// JSON Pointer, see @ref nlohmann::json_pointer
|
/// JSON Pointer, see @ref nlohmann::json_pointer
|
||||||
using json_pointer = ::nlohmann::json_pointer<StringType>;
|
using json_pointer = ::nlohmann::json_pointer<StringType>;
|
||||||
template<typename T, typename SFINAE>
|
template<typename T, typename SFINAE>
|
||||||
using json_serializer = JSONSerializer<T, SFINAE>;
|
using json_serializer = JSONSerializer<T, SFINAE>;
|
||||||
/// how to treat decoding errors
|
/// how to treat decoding errors
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/error_handler_t/
|
||||||
using error_handler_t = detail::error_handler_t;
|
using error_handler_t = detail::error_handler_t;
|
||||||
/// how to treat CBOR tags
|
/// how to treat CBOR tags
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/cbor_tag_handler_t/
|
||||||
using cbor_tag_handler_t = detail::cbor_tag_handler_t;
|
using cbor_tag_handler_t = detail::cbor_tag_handler_t;
|
||||||
/// how to encode BJData
|
/// how to encode BJData
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/bjdata_version_t/
|
||||||
using bjdata_version_t = detail::bjdata_version_t;
|
using bjdata_version_t = detail::bjdata_version_t;
|
||||||
/// helper type for initializer lists of basic_json values
|
/// helper type for initializer lists of basic_json values
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/initializer_list_t/
|
||||||
using initializer_list_t = std::initializer_list<detail::json_ref<basic_json>>;
|
using initializer_list_t = std::initializer_list<detail::json_ref<basic_json>>;
|
||||||
|
|
||||||
|
/// @brief the type of the SAX interface used to parse and serialize the JSON value
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/input_format_t/
|
||||||
using input_format_t = detail::input_format_t;
|
using input_format_t = detail::input_format_t;
|
||||||
/// SAX interface type, see @ref nlohmann::json_sax
|
/// SAX interface type, see @ref nlohmann::json_sax
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/json_sax_t/
|
||||||
using json_sax_t = json_sax<basic_json>;
|
using json_sax_t = json_sax<basic_json>;
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
@@ -21405,15 +21469,19 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
/// the template arguments passed to class @ref basic_json.
|
/// the template arguments passed to class @ref basic_json.
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
|
#if defined(JSON_HAS_CPP_14)
|
||||||
/// @brief default object key comparator type
|
/// @brief default object key comparator type
|
||||||
/// The actual object key comparator type (@ref object_comparator_t) may be
|
/// The actual object key comparator type (@ref object_comparator_t) may be
|
||||||
/// different.
|
/// different.
|
||||||
/// @sa https://json.nlohmann.me/api/basic_json/default_object_comparator_t/
|
/// @sa https://json.nlohmann.me/api/basic_json/default_object_comparator_t/
|
||||||
#if defined(JSON_HAS_CPP_14)
|
|
||||||
// use of transparent comparator avoids unnecessary repeated construction of temporaries
|
// use of transparent comparator avoids unnecessary repeated construction of temporaries
|
||||||
// in functions involving lookup by key with types other than object_t::key_type (aka. StringType)
|
// in functions involving lookup by key with types other than object_t::key_type (aka. StringType)
|
||||||
using default_object_comparator_t = std::less<>;
|
using default_object_comparator_t = std::less<>;
|
||||||
#else
|
#else
|
||||||
|
/// @brief default object key comparator type
|
||||||
|
/// The actual object key comparator type (@ref object_comparator_t) may be
|
||||||
|
/// different.
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/default_object_comparator_t/
|
||||||
using default_object_comparator_t = std::less<StringType>;
|
using default_object_comparator_t = std::less<StringType>;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -22238,6 +22306,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
// other constructors and destructor //
|
// other constructors and destructor //
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/basic_json/
|
||||||
template<typename JsonRef,
|
template<typename JsonRef,
|
||||||
detail::enable_if_t<detail::conjunction<detail::is_json_ref<JsonRef>,
|
detail::enable_if_t<detail::conjunction<detail::is_json_ref<JsonRef>,
|
||||||
std::is_same<typename JsonRef::value_type, basic_json>>::value, int> = 0 >
|
std::is_same<typename JsonRef::value_type, basic_json>>::value, int> = 0 >
|
||||||
@@ -22858,6 +22927,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
@throw what @ref json_serializer<ValueType> `from_json()` method throws if conversion is required
|
@throw what @ref json_serializer<ValueType> `from_json()` method throws if conversion is required
|
||||||
|
|
||||||
@since version 2.1.0
|
@since version 2.1.0
|
||||||
|
|
||||||
|
@sa https://json.nlohmann.me/api/basic_json/get/
|
||||||
*/
|
*/
|
||||||
template < typename ValueTypeCV, typename ValueType = detail::uncvref_t<ValueTypeCV>>
|
template < typename ValueTypeCV, typename ValueType = detail::uncvref_t<ValueTypeCV>>
|
||||||
#if defined(JSON_HAS_CPP_14)
|
#if defined(JSON_HAS_CPP_14)
|
||||||
@@ -22901,6 +22972,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
@sa see @ref get_ptr() for explicit pointer-member access
|
@sa see @ref get_ptr() for explicit pointer-member access
|
||||||
|
|
||||||
@since version 1.0.0
|
@since version 1.0.0
|
||||||
|
|
||||||
|
@sa https://json.nlohmann.me/api/basic_json/get/
|
||||||
*/
|
*/
|
||||||
template<typename PointerType, typename std::enable_if<
|
template<typename PointerType, typename std::enable_if<
|
||||||
std::is_pointer<PointerType>::value, int>::type = 0>
|
std::is_pointer<PointerType>::value, int>::type = 0>
|
||||||
@@ -22926,6 +22999,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
|
|
||||||
// specialization to allow calling get_to with a basic_json value
|
// specialization to allow calling get_to with a basic_json value
|
||||||
// see https://github.com/nlohmann/json/issues/2175
|
// see https://github.com/nlohmann/json/issues/2175
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/get_to/
|
||||||
template<typename ValueType,
|
template<typename ValueType,
|
||||||
detail::enable_if_t <
|
detail::enable_if_t <
|
||||||
detail::is_basic_json<ValueType>::value,
|
detail::is_basic_json<ValueType>::value,
|
||||||
@@ -22936,6 +23010,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/get_to/
|
||||||
template <
|
template <
|
||||||
typename T, std::size_t N,
|
typename T, std::size_t N,
|
||||||
typename Array = T (&)[N], // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
typename Array = T (&)[N], // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||||
@@ -22999,6 +23074,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
|
|
||||||
@since version 1.0.0
|
@since version 1.0.0
|
||||||
*/
|
*/
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_ValueType/
|
||||||
template < typename ValueType, typename std::enable_if <
|
template < typename ValueType, typename std::enable_if <
|
||||||
detail::conjunction <
|
detail::conjunction <
|
||||||
detail::negation<std::is_pointer<ValueType>>,
|
detail::negation<std::is_pointer<ValueType>>,
|
||||||
@@ -23280,12 +23356,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
|
|
||||||
// these two functions resolve a (const) char * ambiguity affecting Clang and MSVC
|
// these two functions resolve a (const) char * ambiguity affecting Clang and MSVC
|
||||||
// (they seemingly cannot be constrained to resolve the ambiguity)
|
// (they seemingly cannot be constrained to resolve the ambiguity)
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/operator[]/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
reference operator[](T* key)
|
reference operator[](T* key)
|
||||||
{
|
{
|
||||||
return operator[](typename object_t::key_type(key));
|
return operator[](typename object_t::key_type(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/operator[]/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
const_reference operator[](T* key) const
|
const_reference operator[](T* key) const
|
||||||
{
|
{
|
||||||
@@ -23495,6 +23573,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
JSON_THROW(type_error::create(306, detail::concat("cannot use value() with ", type_name()), this));
|
JSON_THROW(type_error::create(306, detail::concat("cannot use value() with ", type_name()), this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/value/
|
||||||
template < class ValueType, class BasicJsonType, detail::enable_if_t <
|
template < class ValueType, class BasicJsonType, detail::enable_if_t <
|
||||||
detail::is_basic_json<BasicJsonType>::value
|
detail::is_basic_json<BasicJsonType>::value
|
||||||
&& detail::is_getable<basic_json_t, ValueType>::value
|
&& detail::is_getable<basic_json_t, ValueType>::value
|
||||||
@@ -23505,6 +23584,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return value(ptr.convert(), default_value);
|
return value(ptr.convert(), default_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/value/
|
||||||
template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
|
template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
|
||||||
detail::enable_if_t <
|
detail::enable_if_t <
|
||||||
detail::is_basic_json<BasicJsonType>::value
|
detail::is_basic_json<BasicJsonType>::value
|
||||||
@@ -23874,6 +23954,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return ptr.contains(this);
|
return ptr.contains(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/contains/
|
||||||
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
||||||
bool contains(const typename ::nlohmann::json_pointer<BasicJsonType>& ptr) const
|
bool contains(const typename ::nlohmann::json_pointer<BasicJsonType>& ptr) const
|
||||||
@@ -25156,6 +25237,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/parse/
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, parse(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, parse(ptr, ptr + len))
|
||||||
static basic_json parse(detail::span_input_adapter&& i,
|
static basic_json parse(detail::span_input_adapter&& i,
|
||||||
@@ -25190,6 +25272,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return parser(detail::input_adapter(std::move(first), std::move(last)), nullptr, false, ignore_comments, ignore_trailing_commas).accept(true);
|
return parser(detail::input_adapter(std::move(first), std::move(last)), nullptr, false, ignore_comments, ignore_trailing_commas).accept(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/accept/
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, accept(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, accept(ptr, ptr + len))
|
||||||
static bool accept(detail::span_input_adapter&& i,
|
static bool accept(detail::span_input_adapter&& i,
|
||||||
@@ -25537,6 +25620,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return res ? result : basic_json(value_t::discarded);
|
return res ? result : basic_json(value_t::discarded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/from_cbor/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len))
|
||||||
@@ -25548,6 +25632,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
|
return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/from_cbor/
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len))
|
||||||
static basic_json from_cbor(detail::span_input_adapter&& i,
|
static basic_json from_cbor(detail::span_input_adapter&& i,
|
||||||
@@ -25594,6 +25679,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return res ? result : basic_json(value_t::discarded);
|
return res ? result : basic_json(value_t::discarded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/from_msgpack/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len))
|
||||||
@@ -25604,6 +25690,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
|
return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/from_msgpack/
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len))
|
||||||
static basic_json from_msgpack(detail::span_input_adapter&& i,
|
static basic_json from_msgpack(detail::span_input_adapter&& i,
|
||||||
@@ -25649,6 +25736,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return res ? result : basic_json(value_t::discarded);
|
return res ? result : basic_json(value_t::discarded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/from_ubjson/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len))
|
||||||
@@ -25659,6 +25747,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
|
return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/from_ubjson/
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len))
|
||||||
static basic_json from_ubjson(detail::span_input_adapter&& i,
|
static basic_json from_ubjson(detail::span_input_adapter&& i,
|
||||||
@@ -25735,6 +25824,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return res ? result : basic_json(value_t::discarded);
|
return res ? result : basic_json(value_t::discarded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/from_bson/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len))
|
||||||
@@ -25745,6 +25835,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return from_bson(ptr, ptr + len, strict, allow_exceptions);
|
return from_bson(ptr, ptr + len, strict, allow_exceptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/from_bson/
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len))
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len))
|
||||||
static basic_json from_bson(detail::span_input_adapter&& i,
|
static basic_json from_bson(detail::span_input_adapter&& i,
|
||||||
@@ -25774,6 +25865,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return ptr.get_unchecked(this);
|
return ptr.get_unchecked(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/operator%5B%5D/
|
||||||
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
||||||
reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr)
|
reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr)
|
||||||
@@ -25788,6 +25880,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return ptr.get_unchecked(this);
|
return ptr.get_unchecked(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/operator%5B%5D/
|
||||||
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
||||||
const_reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr) const
|
const_reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr) const
|
||||||
@@ -25802,6 +25895,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return ptr.get_checked(this);
|
return ptr.get_checked(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/at/
|
||||||
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
||||||
reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr)
|
reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr)
|
||||||
@@ -25816,6 +25910,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
return ptr.get_checked(this);
|
return ptr.get_checked(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @sa https://json.nlohmann.me/api/basic_json/at/
|
||||||
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
||||||
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
||||||
const_reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr) const
|
const_reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr) const
|
||||||
|
|||||||
@@ -1782,21 +1782,6 @@ TEST_CASE("std::optional")
|
|||||||
"[json.exception.type_error.302] type must be string, but is null", json::type_error&);
|
"[json.exception.type_error.302] type must be string, but is null", json::type_error&);
|
||||||
CHECK_THROWS_WITH_AS(std::optional<int>(j_null),
|
CHECK_THROWS_WITH_AS(std::optional<int>(j_null),
|
||||||
"[json.exception.type_error.302] type must be number, but is null", json::type_error&);
|
"[json.exception.type_error.302] type must be number, but is null", json::type_error&);
|
||||||
|
|
||||||
// Assignment goes through the same overload resolution as direct
|
|
||||||
// construction, so it throws for the same reason. This relies on
|
|
||||||
// basic_json's implicit conversion operator, so it only applies
|
|
||||||
// when JSON_USE_IMPLICIT_CONVERSIONS is enabled (the default).
|
|
||||||
#if JSON_USE_IMPLICIT_CONVERSIONS
|
|
||||||
std::optional<std::string> opt_assign;
|
|
||||||
CHECK_THROWS_WITH_AS(opt_assign = j_null,
|
|
||||||
"[json.exception.type_error.302] type must be string, but is null", json::type_error&);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// get_to() is the correct way to obtain std::nullopt from a JSON null.
|
|
||||||
std::optional<std::string> opt_get_to = "placeholder";
|
|
||||||
j_null.get_to(opt_get_to);
|
|
||||||
CHECK(opt_get_to == std::nullopt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("string")
|
SECTION("string")
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user