keyword
stringclasses
7 values
repo_name
stringlengths
8
98
file_path
stringlengths
4
244
file_extension
stringclasses
29 values
file_size
int64
0
84.1M
line_count
int64
0
1.6M
content
stringlengths
1
84.1M
language
stringclasses
14 values
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/macros/json_noexception.md
.md
1,085
46
# JSON_NOEXCEPTION ```cpp #define JSON_NOEXCEPTION ``` Exceptions can be switched off by defining the symbol `JSON_NOEXCEPTION`. When defining `JSON_NOEXCEPTION`, `#!cpp try` is replaced by `#!cpp if (true)`, `#!cpp catch` is replaced by `#!cpp if (false)`, and `#!cpp throw` is replaced by `#!cpp std::abort()`. The same effect is achieved by setting the compiler flag `-fno-exceptions`. ## Default definition By default, the macro is not defined. ```cpp #undef JSON_NOEXCEPTION ``` ## Notes The explanatory [`what()`](https://en.cppreference.com/w/cpp/error/exception/what) string of exceptions is not available for MSVC if exceptions are disabled, see [#2824](https://github.com/nlohmann/json/discussions/2824). ## Examples ??? example The code below switches off exceptions in the library. ```cpp #define JSON_NOEXCEPTION 1 #include <nlohmann/json.hpp> ... ``` ## See also - [Switch off exceptions](../../home/exceptions.md#switch-off-exceptions) for more information how to switch off exceptions ## Version history Added in version 2.1.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/macros/json_has_three_way_comparison.md
.md
744
33
# JSON_HAS_THREE_WAY_COMPARISON ```cpp #define JSON_HAS_THREE_WAY_COMPARISON /* value */ ``` This macro indicates whether the compiler and standard library support 3-way comparison. Possible values are `1` when supported or `0` when unsupported. ## Default definition The default value is detected based on the preprocessor macros `#!cpp __cpp_impl_three_way_comparison` and `#!cpp __cpp_lib_three_way_comparison`. When the macro is not defined, the library will define it to its default value. ## Examples ??? example The code below forces the library to use 3-way comparison: ```cpp #define JSON_HAS_THREE_WAY_COMPARISON 1 #include <nlohmann/json.hpp> ... ``` ## Version history - Added in version 3.11.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/macros/json_skip_unsupported_compiler_check.md
.md
716
34
# JSON_SKIP_UNSUPPORTED_COMPILER_CHECK ```cpp #define JSON_SKIP_UNSUPPORTED_COMPILER_CHECK ``` When defined, the library will not create a compile error when a known unsupported compiler is detected. This allows to use the library with compilers that do not fully support C++11 and may only work if unsupported features are not used. ## Default definition By default, the macro is not defined. ```cpp #undef JSON_SKIP_UNSUPPORTED_COMPILER_CHECK ``` ## Examples ??? example The code below switches off the check whether the compiler is supported. ```cpp #define JSON_SKIP_UNSUPPORTED_COMPILER_CHECK 1 #include <nlohmann/json.hpp> ... ``` ## Version history Added in version 3.2.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/macros/json_throw_user.md
.md
2,609
76
# JSON_CATCH_USER, JSON_THROW_USER, JSON_TRY_USER ```cpp // (1) #define JSON_CATCH_USER(exception) /* value */ // (2) #define JSON_THROW_USER(exception) /* value */ // (3) #define JSON_TRY_USER /* value */ ``` Controls how exceptions are handled by the library. 1. This macro overrides [`#!cpp catch`](https://en.cppreference.com/w/cpp/language/try_catch) calls inside the library. The argument is the type of the exception to catch. As of version 3.8.0, the library only catches `std::out_of_range` exceptions internally to rethrow them as [`json::out_of_range`](../../home/exceptions.md#out-of-range) exceptions. The macro is always followed by a scope. 2. This macro overrides `#!cpp throw` calls inside the library. The argument is the exception to be thrown. Note that `JSON_THROW_USER` should leave the current scope (e.g., by throwing or aborting), as continuing after it may yield undefined behavior. 3. This macro overrides `#!cpp try` calls inside the library. It has no arguments and is always followed by a scope. ## Parameters `exception` (in) : an exception type ## Default definition By default, the macros map to their respective C++ keywords: ```cpp #define JSON_CATCH_USER(exception) catch(exception) #define JSON_THROW_USER(exception) throw exception #define JSON_TRY_USER try ``` When exceptions are switched off, the `#!cpp try` block is executed unconditionally, and throwing exceptions is replaced by calling [`std::abort`](https://en.cppreference.com/w/cpp/utility/program/abort) to make reaching the `#!cpp throw` branch abort the process. ```cpp #define JSON_THROW_USER(exception) std::abort() #define JSON_TRY_USER if (true) #define JSON_CATCH_USER(exception) if (false) ``` ## Examples ??? example The code below switches off exceptions and creates a log entry with a detailed error message in case of errors. ```cpp #include <iostream> #define JSON_TRY_USER if(true) #define JSON_CATCH_USER(exception) if(false) #define JSON_THROW_USER(exception) \ {std::clog << "Error in " << __FILE__ << ":" << __LINE__ \ << " (function " << __FUNCTION__ << ") - " \ << (exception).what() << std::endl; \ std::abort();} #include <nlohmann/json.hpp> ``` ## See also - [Switch off exceptions](../../home/exceptions.md#switch-off-exceptions) for more information how to switch off exceptions - [JSON_NOEXCEPTION](JSON_NOEXCEPTION) - switch off exceptions ## Version history - Added in version 3.1.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/macros/json_has_filesystem.md
.md
1,514
44
# JSON_HAS_FILESYSTEM / JSON_HAS_EXPERIMENTAL_FILESYSTEM ```cpp #define JSON_HAS_FILESYSTEM /* value */ #define JSON_HAS_EXPERIMENTAL_FILESYSTEM /* value */ ``` When compiling with C++17, the library provides conversions from and to [`std::filesystem::path`](https://en.cppreference.com/w/cpp/filesystem/path). As compiler support for filesystem is limited, the library tries to detect whether [`<filesystem>`/`std::filesystem`](https://en.cppreference.com/w/cpp/header/filesystem) (`JSON_HAS_FILESYSTEM`) or [`<experimental/filesystem>`/`std::experimental::filesystem`](https://en.cppreference.com/w/cpp/header/experimental/filesystem) (`JSON_HAS_EXPERIMENTAL_FILESYSTEM`) should be used. To override the built-in check, define `JSON_HAS_FILESYSTEM` or `JSON_HAS_EXPERIMENTAL_FILESYSTEM` to `1`. ## Default definition The default value is detected based on the preprocessor macros `#!cpp __cpp_lib_filesystem`, `#!cpp __cpp_lib_experimental_filesystem`, `#!cpp __has_include(<filesystem>)`, or `#!cpp __has_include(<experimental/filesystem>)`. ## Notes - Note that older compilers or older versions of libstd++ also require the library `stdc++fs` to be linked to for filesystem support. - Both macros are undefined outside the library. ## Examples ??? example The code below forces the library to use the header `<experimental/filesystem>`. ```cpp #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 #include <nlohmann/json.hpp> ... ``` ## Version history - Added in version 3.10.5.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/macros/nlohmann_json_namespace.md
.md
1,115
42
# NLOHMANN_JSON_NAMESPACE ```cpp #define NLOHMANN_JSON_NAMESPACE /* value */ ``` This macro evaluates to the full name of the `nlohmann` namespace. ## Default definition The default value consists of the root namespace (`nlohmann`) and an inline ABI namespace. See [`nlohmann` Namespace](../../features/namespace.md#structure) for details. When the macro is not defined, the library will define it to its default value. Overriding this value has no effect on the library. ## Examples ??? example The example shows how to use `NLOHMANN_JSON_NAMESPACE` instead of just `nlohmann`, as well as how to output the value of `NLOHMANN_JSON_NAMESPACE`. ```cpp --8<-- "examples/nlohmann_json_namespace.cpp" ``` Output: ```json --8<-- "examples/nlohmann_json_namespace.output" ``` ## See also - [`NLOHMANN_JSON_NAMESPACE_BEGIN, NLOHMANN_JSON_NAMESPACE_END`](nlohmann_json_namespace_begin.md) - [`NLOHMANN_JSON_NAMESPACE_NO_VERSION`](nlohmann_json_namespace_no_version.md) ## Version history - Added in version 3.11.0. Changed inline namespace name in version 3.11.2.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/macros/nlohmann_define_type_non_intrusive.md
.md
5,228
128
# NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE, NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT ```cpp #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(type, member...) // (1) #define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(type, member...) // (2) ``` These macros can be used to simplify the serialization/deserialization of types if you want to use a JSON object as serialization and want to use the member variable names as object keys in that object. The macro is to be defined **outside** the class/struct to create code for, but **inside** its namespace. Unlike [`NLOHMANN_DEFINE_TYPE_INTRUSIVE`](nlohmann_define_type_intrusive.md), it **cannot** access private members. The first parameter is the name of the class/struct, and all remaining parameters name the members. 1. Will use [`at`](../basic_json/at.md) during deserialization and will throw [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if a key is missing in the JSON object. 2. Will use [`value`](../basic_json/value.md) during deserialization and fall back to the default value for the respective type of the member variable if a key in the JSON object is missing. The generated `from_json()` function default constructs an object and uses its values as the defaults when calling the `value` function. ## Parameters `type` (in) : name of the type (class, struct) to serialize/deserialize `member` (in) : name of the (public) member variable to serialize/deserialize; up to 64 members can be given as comma-separated list ## Default definition The macros add two functions to the namespace which take care of the serialization and deserialization: ```cpp void to_json(nlohmann::json&, const type&); void from_json(const nlohmann::json&, type&); ``` See examples below for the concrete generated code. ## Notes !!! info "Prerequisites" 1. The type `type` must be default constructible. See [How can I use `get()` for non-default constructible/non-copyable types?][GetNonDefNonCopy] for how to overcome this limitation. 2. The macro must be used outside the type (class/struct). 3. The passed members must be public. [GetNonDefNonCopy]: ../../features/arbitrary_types.md#how-can-i-use-get-for-non-default-constructiblenon-copyable-types !!! warning "Implementation limits" - The current implementation is limited to at most 64 member variables. If you want to serialize/deserialize types with more than 64 member variables, you need to define the `to_json`/`from_json` functions manually. - The macros only work for the [`nlohmann::json`](../json.md) type; other specializations such as [`nlohmann::ordered_json`](../ordered_json.md) are currently unsupported. ## Examples ??? example "Example (1): NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE" Consider the following complete example: ```cpp hl_lines="15" --8<-- "examples/nlohmann_define_type_non_intrusive_macro.cpp" ``` Output: ```json --8<-- "examples/nlohmann_define_type_non_intrusive_macro.output" ``` Notes: - `ns::person` is default-constructible. This is a requirement for using the macro. - `ns::person` has only public member variables. This makes `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE` applicable. - The macro `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE` is used _outside_ the class, but _inside_ its namespace `ns`. - A missing key "age" in the deserialization yields an exception. To fall back to the default value, `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT` can be used. The macro is equivalent to: ```cpp hl_lines="15 16 17 18 19 20 21 22 23 24 25 26 27" --8<-- "examples/nlohmann_define_type_non_intrusive_explicit.cpp" ``` ??? example "Example (2): NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT" Consider the following complete example: ```cpp hl_lines="20" --8<-- "examples/nlohmann_define_type_non_intrusive_with_default_macro.cpp" ``` Output: ```json --8<-- "examples/nlohmann_define_type_non_intrusive_with_default_macro.output" ``` Notes: - `ns::person` is default-constructible. This is a requirement for using the macro. - `ns::person` has only public member variables. This makes `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT` applicable. - The macro `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT` is used _outside_ the class, but _inside_ its namespace `ns`. - A missing key "age" in the deserialization does not yield an exception. Instead, the default value `-1` is used. The macro is equivalent to: ```cpp hl_lines="20 21 22 23 24 25 26 27 28 29 30 31 32 33" --8<-- "examples/nlohmann_define_type_non_intrusive_with_default_explicit.cpp" ``` Note how a default-initialized `person` object is used in the `from_json` to fill missing values. ## See also - [NLOHMANN_DEFINE_TYPE_INTRUSIVE / NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT](nlohmann_define_type_intrusive.md) for a similar macro that can be defined _inside_ the type. - [Arbitrary Type Conversions](../../features/arbitrary_types.md) for an overview. ## Version history 1. Added in version 3.9.0. 2. Added in version 3.11.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/macros/nlohmann_json_namespace_no_version.md
.md
1,074
46
# NLOHMANN_JSON_NAMESPACE_NO_VERSION ```cpp #define NLOHMANN_JSON_NAMESPACE_NO_VERSION /* value */ ``` If defined to `1`, the version component is omitted from the inline namespace. See [`nlohmann` Namespace](../../features/namespace.md#structure) for details. ## Default definition The default value is `0`. ```cpp #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0 ``` When the macro is not defined, the library will define it to its default value. ## Examples ??? example The example shows how to use `NLOHMANN_JSON_NAMESPACE_NO_VERSION` to disable the version component of the inline namespace. ```cpp --8<-- "examples/nlohmann_json_namespace_no_version.cpp" ``` Output: ```json --8<-- "examples/nlohmann_json_namespace_no_version.output" ``` ## See also - [`nlohmann` Namespace](../../features/namespace.md) - [`NLOHMANN_JSON_NAMESPACE`](nlohmann_json_namespace.md) - [`NLOHMANN_JSON_NAMESPACE_BEGIN, NLOHMANN_JSON_NAMESPACE_END`](nlohmann_json_namespace_begin.md) ## Version history - Added in version 3.11.2.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/macros/json_has_cpp_11.md
.md
1,145
42
# JSON_HAS_CPP_11, JSON_HAS_CPP_14, JSON_HAS_CPP_17, JSON_HAS_CPP_20 ```cpp #define JSON_HAS_CPP_11 #define JSON_HAS_CPP_14 #define JSON_HAS_CPP_17 #define JSON_HAS_CPP_20 ``` The library targets C++11, but also supports some features introduced in later C++ versions (e.g., `std::string_view` support for C++17). For these new features, the library implements some preprocessor checks to determine the C++ standard. By defining any of these symbols, the internal check is overridden and the provided C++ version is unconditionally assumed. This can be helpful for compilers that only implement parts of the standard and would be detected incorrectly. ## Default definition The default value is detected based on preprocessor macros such as `#!cpp __cplusplus`, `#!cpp _HAS_CXX17`, or `#!cpp _MSVC_LANG`. ## Notes - `#!cpp JSON_HAS_CPP_11` is always defined. - All macros are undefined outside the library. ## Examples ??? example The code below forces the library to use the C++14 standard: ```cpp #define JSON_HAS_CPP_14 1 #include <nlohmann/json.hpp> ... ``` ## Version history - Added in version 3.10.5.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/adl_serializer/to_json.md
.md
986
44
# <small>nlohmann::adl_serializer::</small>to_json ```cpp template<typename BasicJsonType, typename TargetType = ValueType> static auto to_json(BasicJsonType& j, TargetType && val) noexcept( noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val)))) -> decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void()) ``` This function is usually called by the constructors of the [basic_json](../basic_json) class. ## Parameters `j` (out) : JSON value to write to `val` (in) : value to read from ## Examples ??? example The example below shows how a `to_json` function can be implemented for a user-defined type. This function is called by the `adl_serializer` when the constructor `basic_json(ns::person)` is called. ```cpp --8<-- "examples/to_json.cpp" ``` Output: ```json --8<-- "examples/to_json.output" ``` ## See also - [from_json](from_json.md) ## Version history - Added in version 2.1.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/adl_serializer/index.md
.md
908
36
# <small>nlohmann::</small>adl_serializer ```cpp template<typename, typename> struct adl_serializer; ``` Serializer that uses ADL ([Argument-Dependent Lookup](https://en.cppreference.com/w/cpp/language/adl)) to choose `to_json`/`from_json` functions from the types' namespaces. It is implemented similar to ```cpp template<typename ValueType> struct adl_serializer { template<typename BasicJsonType> static void to_json(BasicJsonType& j, const T& value) { // calls the "to_json" method in T's namespace } template<typename BasicJsonType> static void from_json(const BasicJsonType& j, T& value) { // same thing, but with the "from_json" method } }; ``` ## Member functions - [**from_json**](from_json.md) - convert a JSON value to any value type - [**to_json**](to_json.md) - convert any value type to a JSON value ## Version history - Added in version 2.1.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/adl_serializer/from_json.md
.md
2,150
74
# <small>nlohmann::adl_serializer::</small>from_json ```cpp // (1) template<typename BasicJsonType, typename TargetType = ValueType> static auto from_json(BasicJsonType && j, TargetType& val) noexcept( noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val))) -> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void()) // (2) template<typename BasicJsonType, typename TargetType = ValueType> static auto from_json(BasicJsonType && j) noexcept( noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))) -> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {})) ``` This function is usually called by the [`get()`](../basic_json/get.md) function of the [basic_json](../basic_json) class (either explicitly or via the conversion operators). 1. This function is chosen for default-constructible value types. 2. This function is chosen for value types which are not default-constructible. ## Parameters `j` (in) : JSON value to read from `val` (out) : value to write to ## Return value Copy of the JSON value, converted to `ValueType` ## Examples ??? example "Example: (1) Default-constructible type" The example below shows how a `from_json` function can be implemented for a user-defined type. This function is called by the `adl_serializer` when `template get<ns::person>()` is called. ```cpp --8<-- "examples/from_json__default_constructible.cpp" ``` Output: ```json --8<-- "examples/from_json__default_constructible.output" ``` ??? example "Example: (2) Non-default-constructible type" The example below shows how a `from_json` is implemented as part of a specialization of the `adl_serializer` to realize the conversion of a non-default-constructible type. ```cpp --8<-- "examples/from_json__non_default_constructible.cpp" ``` Output: ```json --8<-- "examples/from_json__non_default_constructible.output" ``` ## See also - [to_json](to_json.md) ## Version history - Added in version 2.1.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/byte_container_with_subtype/byte_container_with_subtype.md
.md
1,021
47
# <small>nlohmann::byte_container_with_subtype::</small>byte_container_with_subtype ```cpp // (1) byte_container_with_subtype(); // (2) byte_container_with_subtype(const container_type& container); byte_container_with_subtype(container_type&& container); // (3) byte_container_with_subtype(const container_type& container, subtype_type subtype); byte_container_with_subtype(container_type&& container, subtype_type subtype); ``` 1. Create empty binary container without subtype. 2. Create binary container without subtype. 3. Create binary container with subtype. ## Parameters `container` (in) : binary container `subtype` (in) : subtype ## Examples ??? example The example below demonstrates how byte containers can be created. ```cpp --8<-- "examples/byte_container_with_subtype__byte_container_with_subtype.cpp" ``` Output: ```json --8<-- "examples/byte_container_with_subtype__byte_container_with_subtype.output" ``` ## Version history Since version 3.8.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/byte_container_with_subtype/set_subtype.md
.md
767
42
# <small>nlohmann::byte_container_with_subtype::</small>set_subtype ```cpp void set_subtype(subtype_type subtype) noexcept; ``` Sets the binary subtype of the value, also flags a binary JSON value as having a subtype, which has implications for serialization. ## Parameters `subtype` (in) : subtype to set ## Exception safety No-throw guarantee: this function never throws exceptions. ## Complexity Constant. ## Examples ??? example The example below demonstrates how a subtype can be set with `set_subtype`. ```cpp --8<-- "examples/byte_container_with_subtype__set_subtype.cpp" ``` Output: ```json --8<-- "examples/byte_container_with_subtype__set_subtype.output" ``` ## Version history Since version 3.8.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/byte_container_with_subtype/clear_subtype.md
.md
755
37
# <small>nlohmann::byte_container_with_subtype::</small>clear_subtype ```cpp void clear_subtype() noexcept; ``` Clears the binary subtype and flags the value as not having a subtype, which has implications for serialization; for instance MessagePack will prefer the bin family over the ext family. ## Exception safety No-throw guarantee: this function never throws exceptions. ## Complexity Constant. ## Examples ??? example The example below demonstrates how `clear_subtype` can remove subtypes. ```cpp --8<-- "examples/byte_container_with_subtype__clear_subtype.cpp" ``` Output: ```json --8<-- "examples/byte_container_with_subtype__clear_subtype.output" ``` ## Version history Since version 3.8.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/byte_container_with_subtype/index.md
.md
1,244
36
# <small>nlohmann::</small>byte_container_with_subtype ```cpp template<typename BinaryType> class byte_container_with_subtype : public BinaryType; ``` This type extends the template parameter `BinaryType` provided to [`basic_json`](../basic_json/index.md) with a subtype used by BSON and MessagePack. This type exists so that the user does not have to specify a type themselves with a specific naming scheme in order to override the binary type. ## Template parameters `BinaryType` : container to store bytes (`#!cpp std::vector<std::uint8_t>` by default) ## Member types - **container_type** - the type of the underlying container (`BinaryType`) - **subtype_type** - the type of the subtype (`#!cpp std::uint64_t`) ## Member functions - [(constructor)](byte_container_with_subtype.md) - **operator==** - comparison: equal - **operator!=** - comparison: not equal - [**set_subtype**](subtype.md) - sets the binary subtype - [**subtype**](subtype.md) - return the binary subtype - [**has_subtype**](has_subtype.md) - return whether the value has a subtype - [**clear_subtype**](clear_subtype.md) - clears the binary subtype ## Version history - Added in version 3.8.0. - Changed type of subtypes to `#!cpp std::uint64_t` in 3.10.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/byte_container_with_subtype/subtype.md
.md
1,002
43
# <small>nlohmann::byte_container_with_subtype::</small>subtype ```cpp constexpr subtype_type subtype() const noexcept; ``` Returns the numerical subtype of the value if it has a subtype. If it does not have a subtype, this function will return `subtype_type(-1)` as a sentinel value. ## Return value the numerical subtype of the binary value, or `subtype_type(-1)` if no subtype is set ## Exception safety No-throw guarantee: this function never throws exceptions. ## Complexity Constant. ## Examples ??? example The example below demonstrates how the subtype can be retrieved with `subtype`. Note how `subtype_type(-1)` is returned for container `c1`. ```cpp --8<-- "examples/byte_container_with_subtype__subtype.cpp" ``` Output: ```json --8<-- "examples/byte_container_with_subtype__subtype.output" ``` ## Version history - Added in version 3.8.0 - Fixed return value to properly return `subtype_type(-1)` as documented in version 3.10.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/byte_container_with_subtype/has_subtype.md
.md
682
40
# <small>nlohmann::byte_container_with_subtype::</small>has_subtype ```cpp constexpr bool has_subtype() const noexcept; ``` Returns whether the value has a subtype. ## Return value whether the value has a subtype ## Exception safety No-throw guarantee: this function never throws exceptions. ## Complexity Constant. ## Examples ??? example The example below demonstrates how `has_subtype` can check whether a subtype was set. ```cpp --8<-- "examples/byte_container_with_subtype__has_subtype.cpp" ``` Output: ```json --8<-- "examples/byte_container_with_subtype__has_subtype.output" ``` ## Version history Since version 3.8.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/operator_ValueType.md
.md
2,404
83
# <small>nlohmann::basic_json::</small>operator ValueType ```cpp template<typename ValueType> JSON_EXPLICIT operator ValueType() const; ``` Implicit type conversion between the JSON value and a compatible value. The call is realized by calling [`get()`](get.md). See [Notes](#notes) for the meaning of `JSON_EXPLICIT`. ## Template parameters `ValueType` : the value type to return ## Return value copy of the JSON value, converted to `ValueType` ## Exceptions Depends on what `json_serializer<ValueType>` `from_json()` method throws ## Complexity Linear in the size of the JSON value. ## Notes !!! note "Definition of `JSON_EXPLICIT`" By default `JSON_EXPLICIT` is defined to the empty string, so the signature is: ```cpp template<typename ValueType> operator ValueType() const; ``` If [`JSON_USE_IMPLICIT_CONVERSIONS`](../macros/json_use_implicit_conversions.md) is set to `0`, `JSON_EXPLICIT` is defined to `#!cpp explicit`: ```cpp template<typename ValueType> explicit operator ValueType() const; ``` That is, implicit conversions can be switched off by defining [`JSON_USE_IMPLICIT_CONVERSIONS`](../macros/json_use_implicit_conversions.md) to `0`. !!! info "Future behavior change" Implicit conversions will be switched off by default in the next major release of the library. That is, `JSON_EXPLICIT` will be set to `#!cpp explicit` by default. You can prepare existing code by already defining [`JSON_USE_IMPLICIT_CONVERSIONS`](../macros/json_use_implicit_conversions.md) to `0` and replace any implicit conversions with calls to [`get`](../basic_json/get.md). ## Examples ??? example The example below shows several conversions from JSON values to other types. There are a few things to note: (1) Floating-point numbers can be converted to integers, (2) A JSON array can be converted to a standard `std::vector<short>`, (3) A JSON object can be converted to C++ associative containers such as `std::unordered_map<std::string, json>`. ```cpp --8<-- "examples/operator__ValueType.cpp" ``` Output: ```json --8<-- "examples/operator__ValueType.output" ``` ## Version history - Since version 1.0.0. - Macros `JSON_EXPLICIT`/[`JSON_USE_IMPLICIT_CONVERSIONS`](../macros/json_use_implicit_conversions.md) added in version 3.9.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/swap.md
.md
4,902
157
# <small>nlohmann::basic_json::</small>swap ```cpp // (1) void swap(reference other) noexcept; // (2) void swap(reference left, reference right) noexcept; // (3) void swap(array_t& other); // (4) void swap(object_t& other); // (5) void swap(string_t& other); // (6) void swap(binary_t& other); // (7) void swap(typename binary_t::container_type& other); ``` 1. Exchanges the contents of the JSON value with those of `other`. Does not invoke any move, copy, or swap operations on individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. 2. Exchanges the contents of the JSON value from `left` with those of `right`. Does not invoke any move, copy, or swap operations on individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. Implemented as a friend function callable via ADL. 3. Exchanges the contents of a JSON array with those of `other`. Does not invoke any move, copy, or swap operations on individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. 4. Exchanges the contents of a JSON object with those of `other`. Does not invoke any move, copy, or swap operations on individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. 5. Exchanges the contents of a JSON string with those of `other`. Does not invoke any move, copy, or swap operations on individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. 6. Exchanges the contents of a binary value with those of `other`. Does not invoke any move, copy, or swap operations on individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. 7. Exchanges the contents of a binary value with those of `other`. Does not invoke any move, copy, or swap operations on individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. Unlike version (6), no binary subtype is involved. ## Parameters `other` (in, out) : value to exchange the contents with `left` (in, out) : value to exchange the contents with `right` (in, out) : value to exchange the contents with ## Exceptions 1. No-throw guarantee: this function never throws exceptions. 2. No-throw guarantee: this function never throws exceptions. 3. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than arrays; example: `"cannot use swap() with boolean"` 4. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than objects; example: `"cannot use swap() with boolean"` 5. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than strings; example: `"cannot use swap() with boolean"` 6. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than binaries; example: `"cannot use swap() with boolean"` 7. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than binaries; example: `"cannot use swap() with boolean"` ## Complexity Constant. ## Examples ??? example "Example: Swap JSON value (1, 2)" The example below shows how JSON values can be swapped with `swap()`. ```cpp --8<-- "examples/swap__reference.cpp" ``` Output: ```json --8<-- "examples/swap__reference.output" ``` ??? example "Example: Swap array (3)" The example below shows how arrays can be swapped with `swap()`. ```cpp --8<-- "examples/swap__array_t.cpp" ``` Output: ```json --8<-- "examples/swap__array_t.output" ``` ??? example "Example: Swap object (4)" The example below shows how objects can be swapped with `swap()`. ```cpp --8<-- "examples/swap__object_t.cpp" ``` Output: ```json --8<-- "examples/swap__object_t.output" ``` ??? example "Example: Swap string (5)" The example below shows how strings can be swapped with `swap()`. ```cpp --8<-- "examples/swap__string_t.cpp" ``` Output: ```json --8<-- "examples/swap__string_t.output" ``` ??? example "Example: Swap string (6)" The example below shows how binary values can be swapped with `swap()`. ```cpp --8<-- "examples/swap__binary_t.cpp" ``` Output: ```json --8<-- "examples/swap__binary_t.output" ``` ## See also - [std::swap<basic_json\>](std_swap.md) ## Version history 1. Since version 1.0.0. 2. Since version 1.0.0. 3. Since version 1.0.0. 4. Since version 1.0.0. 5. Since version 1.0.0. 6. Since version 3.8.0. 7. Since version 3.8.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/operator_gt.md
.md
2,290
87
# <small>nlohmann::basic_json::</small>operator> ```cpp // until C++20 bool operator>(const_reference lhs, const_reference rhs) noexcept; // (1) template<typename ScalarType> bool operator>(const_reference lhs, const ScalarType rhs) noexcept; // (2) template<typename ScalarType> bool operator>(ScalarType lhs, const const_reference rhs) noexcept; // (2) ``` 1. Compares whether one JSON value `lhs` is greater than another JSON value `rhs` according to the following rules: - The comparison always yields `#!cpp false` if (1) either operand is discarded, or (2) either operand is `NaN` and the other operand is either `NaN` or any other number. - Otherwise, returns the result of `#!cpp !(lhs <= rhs)` (see [**operator<=**](operator_le.md)). 2. Compares wether a JSON value is greater than a scalar or a scalar is greater than a JSON value by converting the scalar to a JSON value and comparing both JSON values according to 1. ## Template parameters `ScalarType` : a scalar type according to `std::is_scalar<ScalarType>::value` ## Parameters `lhs` (in) : first value to consider `rhs` (in) : second value to consider ## Return value whether `lhs` is greater than `rhs` ## Exception safety No-throw guarantee: this function never throws exceptions. ## Complexity Linear. ## Notes !!! note "Comparing `NaN`" `NaN` values are unordered within the domain of numbers. The following comparisons all yield `#!cpp false`: 1. Comparing a `NaN` with itself. 2. Comparing a `NaN` with another `NaN`. 3. Comparing a `NaN` and any other number. !!! note "Operator overload resolution" Since C++20 overload resolution will consider the _rewritten candidate_ generated from [`operator<=>`](operator_spaceship.md). ## Examples ??? example The example demonstrates comparing several JSON types. ```cpp --8<-- "examples/operator__greater.cpp" ``` Output: ```json --8<-- "examples/operator__greater.output" ``` ## See also - [**operator<=>**](operator_spaceship.md) comparison: 3-way ## Version history 1. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0. 2. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/json_base_class_t.md
.md
1,165
46
# <small>nlohmann::basic_json::</small>json_base_class_t ```cpp using json_base_class_t = detail::json_base_class<CustomBaseClass>; ``` The base class used to inject custom functionality into each instance of `basic_json`. Examples of such functionality might be metadata, additional member functions (e.g., visitors), or other application-specific code. ## Template parameters `CustomBaseClass` : the base class to be added to `basic_json` ## Notes #### Default type The default value for `CustomBaseClass` is `void`. In this case an [empty base class](https://en.cppreference.com/w/cpp/language/ebo) is used and no additional functionality is injected. #### Limitations The type `CustomBaseClass` has to be a default-constructible class. `basic_json` only supports copy/move construction/assignment if `CustomBaseClass` does so as well. ## Examples ??? example The following code shows how to inject custom data and methods for each node. ```cpp --8<-- "examples/json_base_class_t.cpp" ``` Output: ```json --8<-- "examples/json_base_class_t.output" ``` ## Version history - Added in version 3.12.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/is_number_unsigned.md
.md
1,056
47
# <small>nlohmann::basic_json::</small>is_number_unsigned ```cpp constexpr bool is_number_unsigned() const noexcept; ``` This function returns `#!cpp true` if and only if the JSON value is an unsigned integer number. This excludes floating-point and signed integer values. ## Return value `#!cpp true` if type is an unsigned integer number, `#!cpp false` otherwise. ## Exception safety No-throw guarantee: this member function never throws exceptions. ## Complexity Constant. ## Examples ??? example The following code exemplifies `is_number_unsigned()` for all JSON types. ```cpp --8<-- "examples/is_number_unsigned.cpp" ``` Output: ```json --8<-- "examples/is_number_unsigned.output" ``` ## See also - [is_number()](is_number.md) check if value is a number - [is_number_integer()](is_number_integer.md) check if value is an integer or unsigned integer number - [is_number_float()](is_number_float.md) check if value is a floating-point number ## Version history - Added in version 2.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/begin.md
.md
663
43
# <small>nlohmann::basic_json::</small>begin ```cpp iterator begin() noexcept; const_iterator begin() const noexcept; ``` Returns an iterator to the first element. ![Illustration from cppreference.com](../../images/range-begin-end.svg) ## Return value iterator to the first element ## Exception safety No-throw guarantee: this member function never throws exceptions. ## Complexity Constant. ## Examples ??? example The following code shows an example for `begin()`. ```cpp --8<-- "examples/begin.cpp" ``` Output: ```json --8<-- "examples/begin.output" ``` ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/default_object_comparator_t.md
.md
863
36
# <small>nlohmann::basic_json::</small>default_object_comparator_t ```cpp using default_object_comparator_t = std::less<StringType>; // until C++14 using default_object_comparator_t = std::less<>; // since C++14 ``` The default comparator used by [`object_t`](object_t.md). Since C++14 a transparent comparator is used which prevents unnecessary string construction when looking up a key in an object. The actual comparator used depends on [`object_t`](object_t.md) and can be obtained via [`object_comparator_t`](object_comparator_t.md). ## Examples ??? example The example below demonstrates the default comparator. ```cpp --8<-- "examples/default_object_comparator_t.cpp" ``` Output: ```json --8<-- "examples/default_object_comparator_t.output" ``` ## Version history - Added in version 3.11.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/patch_inplace.md
.md
2,575
71
# <small>nlohmann::basic_json::</small>patch_inplace ```cpp void patch_inplace(const basic_json& json_patch) const; ``` [JSON Patch](http://jsonpatch.com) defines a JSON document structure for expressing a sequence of operations to apply to a JSON document. With this function, a JSON Patch is applied to the current JSON value by executing all operations from the patch. This function applies a JSON patch in place and returns void. ## Parameters `json_patch` (in) : JSON patch document ## Exception safety No guarantees, value may be corrupted by an unsuccessful patch operation. ## Exceptions - Throws [`parse_error.104`](../../home/exceptions.md#jsonexceptionparse_error104) if the JSON patch does not consist of an array of objects. - Throws [`parse_error.105`](../../home/exceptions.md#jsonexceptionparse_error105) if the JSON patch is malformed (e.g., mandatory attributes are missing); example: `"operation add must have member path"`. - Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) if an array index is out of range. - Throws [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if a JSON pointer inside the patch could not be resolved successfully in the current JSON value; example: `"key baz not found"`. - Throws [`out_of_range.405`](../../home/exceptions.md#jsonexceptionout_of_range405) if JSON pointer has no parent ("add", "remove", "move") - Throws [`out_of_range.501`](../../home/exceptions.md#jsonexceptionother_error501) if "test" operation was unsuccessful. ## Complexity Linear in the size of the JSON value and the length of the JSON patch. As usually only a fraction of the JSON value is affected by the patch, the complexity can usually be neglected. ## Notes Unlike [`patch`](patch.md), `patch_inplace` applies the operation "in place" and no copy of the JSON value is created. That makes it faster for large documents by avoiding the copy. However, the JSON value might be corrupted if the function throws an exception. ## Examples ??? example The following code shows how a JSON patch is applied to a value. ```cpp --8<-- "examples/patch_inplace.cpp" ``` Output: ```json --8<-- "examples/patch_inplace.output" ``` ## See also - [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) - [RFC 6901 (JSON Pointer)](https://tools.ietf.org/html/rfc6901) - [patch](patch.md) applies a JSON Merge Patch - [merge_patch](merge_patch.md) applies a JSON Merge Patch ## Version history - Added in version 3.11.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/is_number_integer.md
.md
1,114
48
# <small>nlohmann::basic_json::</small>is_number_integer ```cpp constexpr bool is_number_integer() const noexcept; ``` This function returns `#!cpp true` if and only if the JSON value is a signed or unsigned integer number. This excludes floating-point values. ## Return value `#!cpp true` if type is an integer or unsigned integer number, `#!cpp false` otherwise. ## Exception safety No-throw guarantee: this member function never throws exceptions. ## Complexity Constant. ## Examples ??? example The following code exemplifies `is_number_integer()` for all JSON types. ```cpp --8<-- "examples/is_number_integer.cpp" ``` Output: ```json --8<-- "examples/is_number_integer.output" ``` ## See also - [is_number()](is_number.md) check if value is a number - [is_number_unsigned()](is_number_unsigned.md) check if value is an unsigned integer number - [is_number_float()](is_number_float.md) check if value is a floating-point number ## Version history - Added in version 1.0.0. - Extended to also return `#!cpp true` for unsigned integers in 2.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/is_string.md
.md
662
40
# <small>nlohmann::basic_json::</small>is_string ```cpp constexpr bool is_string() const noexcept; ``` This function returns `#!cpp true` if and only if the JSON value is a string. ## Return value `#!cpp true` if type is a string, `#!cpp false` otherwise. ## Exception safety No-throw guarantee: this member function never throws exceptions. ## Complexity Constant. ## Examples ??? example The following code exemplifies `is_string()` for all JSON types. ```cpp --8<-- "examples/is_string.cpp" ``` Output: ```json --8<-- "examples/is_string.output" ``` ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/insert.md
.md
6,528
180
# <small>nlohmann::basic_json::</small>insert ```cpp // (1) iterator insert(const_iterator pos, const basic_json& val); iterator insert(const_iterator pos, basic_json&& val); // (2) iterator insert(const_iterator pos, size_type cnt, const basic_json& val); // (3) iterator insert(const_iterator pos, const_iterator first, const_iterator last); // (4) iterator insert(const_iterator pos, initializer_list_t ilist); // (5) void insert(const_iterator first, const_iterator last); ``` 1. Inserts element `val` into array before iterator `pos`. 2. Inserts `cnt` copies of `val` into array before iterator `pos`. 3. Inserts elements from range `[first, last)` into array before iterator `pos`. 4. Inserts elements from initializer list `ilist` into array before iterator `pos`. 5. Inserts elements from range `[first, last)` into object. ## Parameters `pos` (in) : iterator before which the content will be inserted; may be the `end()` iterator `val` (in) : value to insert `cnt` (in) : number of copies of `val` to insert `first` (in) : begin of the range of elements to insert `last` (in) : end of the range of elements to insert `ilist` (in) : initializer list to insert the values from ## Return value 1. iterator pointing to the inserted `val`. 2. iterator pointing to the first element inserted, or `pos` if `#!cpp cnt==0` 3. iterator pointing to the first element inserted, or `pos` if `#!cpp first==last` 4. iterator pointing to the first element inserted, or `pos` if `ilist` is empty 5. (none) ## Exception safety Strong exception safety: if an exception occurs, the original value stays intact. ## Exceptions 1. The function can throw the following exceptions: - Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than arrays; example: `"cannot use insert() with string"` - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` 2. The function can throw the following exceptions: - Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than arrays; example: `"cannot use insert() with string"` - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` 3. The function can throw the following exceptions: - Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than arrays; example: `"cannot use insert() with string"` - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` - Throws [`invalid_iterator.210`](../../home/exceptions.md#jsonexceptioninvalid_iterator210) if `first` and `last` do not belong to the same JSON value; example: `"iterators do not fit"` - Throws [`invalid_iterator.211`](../../home/exceptions.md#jsonexceptioninvalid_iterator211) if `first` or `last` are iterators into container for which insert is called; example: `"passed iterators may not belong to container"` 4. The function can throw the following exceptions: - Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than arrays; example: `"cannot use insert() with string"` - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` 5. The function can throw the following exceptions: - Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than objects; example: `"cannot use insert() with string"` - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` - Throws [`invalid_iterator.210`](../../home/exceptions.md#jsonexceptioninvalid_iterator210) if `first` and `last` do not belong to the same JSON value; example: `"iterators do not fit"` ## Complexity 1. Constant plus linear in the distance between `pos` and end of the container. 2. Linear in `cnt` plus linear in the distance between `pos` and end of the container. 3. Linear in `#!cpp std::distance(first, last)` plus linear in the distance between `pos` and end of the container. 4. Linear in `ilist.size()` plus linear in the distance between `pos` and end of the container. 5. Logarithmic: `O(N*log(size() + N))`, where `N` is the number of elements to insert. ## Examples ??? example "Example (1): insert element into array" The example shows how `insert()` is used. ```cpp --8<-- "examples/insert.cpp" ``` Output: ```json --8<-- "examples/insert.output" ``` ??? example "Example (2): insert copies of element into array" The example shows how `insert()` is used. ```cpp --8<-- "examples/insert__count.cpp" ``` Output: ```json --8<-- "examples/insert__count.output" ``` ??? example "Example (3): insert range of elements into array" The example shows how `insert()` is used. ```cpp --8<-- "examples/insert__range.cpp" ``` Output: ```json --8<-- "examples/insert__range.output" ``` ??? example "Example (4): insert elements from initializer list into array" The example shows how `insert()` is used. ```cpp --8<-- "examples/insert__ilist.cpp" ``` Output: ```json --8<-- "examples/insert__ilist.output" ``` ??? example "Example (5): insert range of elements into object" The example shows how `insert()` is used. ```cpp --8<-- "examples/insert__range_object.cpp" ``` Output: ```json --8<-- "examples/insert__range_object.output" ``` ## Version history 1. Added in version 1.0.0. 2. Added in version 1.0.0. 3. Added in version 1.0.0. 4. Added in version 1.0.0. 5. Added in version 3.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/other_error.md
.md
1,697
68
# <small>nlohmann::basic_json::</small>other_error ```cpp class other_error : public exception; ``` This exception is thrown in case of errors that cannot be classified with the other exception types. Exceptions have ids 5xx (see [list of other errors](../../home/exceptions.md#further-exceptions)). ```plantuml std::exception <|-- basic_json::exception basic_json::exception <|-- basic_json::parse_error basic_json::exception <|-- basic_json::invalid_iterator basic_json::exception <|-- basic_json::type_error basic_json::exception <|-- basic_json::out_of_range basic_json::exception <|-- basic_json::other_error interface std::exception {} class basic_json::exception { + const int id + const char* what() const } class basic_json::parse_error { + const std::size_t byte } class basic_json::other_error #FFFF00 {} ``` ## Member functions - **what** - returns explanatory string ## Member variables - **id** - the id of the exception ## Examples ??? example The following code shows how a `other_error` exception can be caught. ```cpp --8<-- "examples/other_error.cpp" ``` Output: ```json --8<-- "examples/other_error.output" ``` ## See also - [List of other errors](../../home/exceptions.md#further-exceptions) - [`parse_error`](parse_error.md) for exceptions indicating a parse error - [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators - [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type - [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range ## Version history - Since version 3.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/find.md
.md
2,220
87
# <small>nlohmann::basic_json::</small>find ```cpp // (1) iterator find(const typename object_t::key_type& key); const_iterator find(const typename object_t::key_type& key) const; // (2) template<typename KeyType> iterator find(KeyType&& key); template<typename KeyType> const_iterator find(KeyType&& key) const; ``` 1. Finds an element in a JSON object with a key equivalent to `key`. If the element is not found or the JSON value is not an object, `end()` is returned. 2. See 1. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and `#!cpp typename object_comparator_t::is_transparent` denotes a type. ## Template parameters `KeyType` : A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). This can also be a string view (C++17). ## Parameters `key` (in) : key value of the element to search for. ## Return value Iterator to an element with a key equivalent to `key`. If no such element is found or the JSON value is not an object, a past-the-end iterator (see `end()`) is returned. ## Exception safety Strong exception safety: if an exception occurs, the original value stays intact. ## Complexity Logarithmic in the size of the JSON object. ## Notes This method always returns `end()` when executed on a JSON type that is not an object. ## Examples ??? example "Example: (1) find object element by key" The example shows how `find()` is used. ```cpp --8<-- "examples/find__object_t_key_type.cpp" ``` Output: ```json --8<-- "examples/find__object_t_key_type.output" ``` ??? example "Example: (2) find object element by key using string_view" The example shows how `find()` is used. ```cpp --8<-- "examples/find__keytype.c++17.cpp" ``` Output: ```json --8<-- "examples/find__keytype.c++17.output" ``` ## See also - [contains](contains.md) checks whether a key exists ## Version history 1. Added in version 3.11.0. 2. Added in version 1.0.0. Changed to support comparable types in version 3.11.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/is_structured.md
.md
1,384
64
# <small>nlohmann::basic_json::</small>is_structured ```cpp constexpr bool is_structured() const noexcept; ``` This function returns `#!cpp true` if and only if the JSON type is structured (array or object). ## Return value `#!cpp true` if type is structured (array or object), `#!cpp false` otherwise. ## Exception safety No-throw guarantee: this member function never throws exceptions. ## Complexity Constant. ## Possible implementation ```cpp constexpr bool is_primitive() const noexcept { return is_array() || is_object(); } ``` ## Notes The term *structured* stems from [RFC 8259](https://tools.ietf.org/html/rfc8259): > JSON can represent four primitive types (strings, numbers, booleans, and null) and two structured types (objects and > arrays). Note that though strings are containers in C++, they are treated as primitive values in JSON. ## Examples ??? example The following code exemplifies `is_structured()` for all JSON types. ```cpp --8<-- "examples/is_structured.cpp" ``` Output: ```json --8<-- "examples/is_structured.output" ``` ## See also - [is_primitive()](is_primitive.md) returns whether JSON value is primitive - [is_array()](is_array.md) returns whether value is an array - [is_object()](is_object.md) returns whether value is an object ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/invalid_iterator.md
.md
1,719
68
# <small>nlohmann::basic_json::</small>invalid_iterator ```cpp class invalid_iterator : public exception; ``` This exception is thrown if iterators passed to a library function do not match the expected semantics. Exceptions have ids 2xx (see [list of iterator errors](../../home/exceptions.md#iterator-errors)). ```plantuml std::exception <|-- basic_json::exception basic_json::exception <|-- basic_json::parse_error basic_json::exception <|-- basic_json::invalid_iterator basic_json::exception <|-- basic_json::type_error basic_json::exception <|-- basic_json::out_of_range basic_json::exception <|-- basic_json::other_error interface std::exception {} class basic_json::exception { + const int id + const char* what() const } class basic_json::parse_error { + const std::size_t byte } class basic_json::invalid_iterator #FFFF00 {} ``` ## Member functions - **what** - returns explanatory string ## Member variables - **id** - the id of the exception ## Examples ??? example The following code shows how a `invalid_iterator` exception can be caught. ```cpp --8<-- "examples/invalid_iterator.cpp" ``` Output: ```json --8<-- "examples/invalid_iterator.output" ``` ## See also - [List of iterator errors](../../home/exceptions.md#iterator-errors) - [`parse_error`](parse_error.md) for exceptions indicating a parse error - [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type - [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range - [`other_error`](other_error.md) for exceptions indicating other library errors ## Version history - Since version 3.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/to_cbor.md
.md
1,480
62
# <small>nlohmann::basic_json::</small>to_cbor ```cpp // (1) static std::vector<std::uint8_t> to_cbor(const basic_json& j); // (2) static void to_cbor(const basic_json& j, detail::output_adapter<std::uint8_t> o); static void to_cbor(const basic_json& j, detail::output_adapter<char> o); ``` Serializes a given JSON value `j` to a byte vector using the CBOR (Concise Binary Object Representation) serialization format. CBOR is a binary serialization format which aims to be more compact than JSON itself, yet more efficient to parse. 1. Returns a byte vector containing the CBOR serialization. 2. Writes the CBOR serialization to an output adapter. The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/cbor.md). ## Parameters `j` (in) : JSON value to serialize `o` (in) : output adapter to write serialization to ## Return value 1. CBOR serialization as byte vector 2. (none) ## Exception safety Strong guarantee: if an exception is thrown, there are no changes in the JSON value. ## Complexity Linear in the size of the JSON value `j`. ## Examples ??? example The example shows the serialization of a JSON value to a byte vector in CBOR format. ```cpp --8<-- "examples/to_cbor.cpp" ``` Output: ```json --8<-- "examples/to_cbor.output" ``` ## Version history - Added in version 2.0.9. - Compact representation of floating-point numbers added in version 3.8.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/array.md
.md
1,614
61
# <small>nlohmann::basic_json::</small>array ```cpp static basic_json array(initializer_list_t init = {}); ``` Creates a JSON array value from a given initializer list. That is, given a list of values `a, b, c`, creates the JSON value `#!json [a, b, c]`. If the initializer list is empty, the empty array `#!json []` is created. ## Parameters `init` (in) : initializer list with JSON values to create an array from (optional) ## Return value JSON array value ## Exception safety Strong guarantee: if an exception is thrown, there are no changes in the JSON value. ## Complexity Linear in the size of `init`. ## Notes This function is only needed to express two edge cases that cannot be realized with the initializer list constructor ([`basic_json(initializer_list_t, bool, value_t)`](basic_json.md)). These cases are: 1. creating an array whose elements are all pairs whose first element is a string -- in this case, the initializer list constructor would create an object, taking the first elements as keys 2. creating an empty array -- passing the empty initializer list to the initializer list constructor yields an empty object ## Examples ??? example The following code shows an example for the `array` function. ```cpp --8<-- "examples/array.cpp" ``` Output: ```json --8<-- "examples/array.output" ``` ## See also - [`basic_json(initializer_list_t)`](basic_json.md) - create a JSON value from an initializer list - [`object`](object.md) - create a JSON object value from an initializer list ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/cbegin.md
.md
641
42
# <small>nlohmann::basic_json::</small>cbegin ```cpp const_iterator cbegin() const noexcept; ``` Returns an iterator to the first element. ![Illustration from cppreference.com](../../images/range-begin-end.svg) ## Return value iterator to the first element ## Exception safety No-throw guarantee: this member function never throws exceptions. ## Complexity Constant. ## Examples ??? example The following code shows an example for `cbegin()`. ```cpp --8<-- "examples/cbegin.cpp" ``` Output: ```json --8<-- "examples/cbegin.output" ``` ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/size.md
.md
1,544
58
# <small>nlohmann::basic_json::</small>size ```cpp size_type size() const noexcept; ``` Returns the number of elements in a JSON value. ## Return value The return value depends on the different types and is defined as follows: | Value type | return value | |------------|-------------------------------------| | null | `0` | | boolean | `1` | | string | `1` | | number | `1` | | binary | `1` | | object | result of function object_t::size() | | array | result of function array_t::size() | ## Exception safety No-throw guarantee: this function never throws exceptions. ## Complexity Constant, as long as [`array_t`](array_t.md) and [`object_t`](object_t.md) satisfy the [Container](https://en.cppreference.com/w/cpp/named_req/Container) concept; that is, their `size()` functions have constant complexity. ## Notes This function does not return the length of a string stored as JSON value -- it returns the number of elements in the JSON value which is `1` in the case of a string. ## Examples ??? example The following code calls `size()` on the different value types. ```cpp --8<-- "examples/size.cpp" ``` Output: ```json --8<-- "examples/size.output" ``` ## Version history - Added in version 1.0.0. - Extended to return `1` for binary types in version 3.8.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/operator_value_t.md
.md
1,470
55
# <small>nlohmann::basic_json::</small>operator value_t ```cpp constexpr operator value_t() const noexcept; ``` Return the type of the JSON value as a value from the [`value_t`](value_t.md) enumeration. ## Return value the type of the JSON value | Value type | return value | |---------------------------|----------------------------| | `#!json null` | `value_t::null` | | boolean | `value_t::boolean` | | string | `value_t::string` | | number (integer) | `value_t::number_integer` | | number (unsigned integer) | `value_t::number_unsigned` | | number (floating-point) | `value_t::number_float` | | object | `value_t::object` | | array | `value_t::array` | | binary | `value_t::binary` | | discarded | `value_t::discarded` | ## Exception safety No-throw guarantee: this member function never throws exceptions. ## Complexity Constant. ## Examples ??? example The following code exemplifies `operator value_t()` for all JSON types. ```cpp --8<-- "examples/operator__value_t.cpp" ``` Output: ```json --8<-- "examples/operator__value_t.output" ``` ## Version history - Added in version 1.0.0. - Added unsigned integer type in version 2.0.0. - Added binary type in version 3.8.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/operator_spaceship.md
.md
3,045
101
# <small>nlohmann::basic_json::</small>operator<=> ```cpp // since C++20 class basic_json { std::partial_ordering operator<=>(const_reference rhs) const noexcept; // (1) template<typename ScalarType> std::partial_ordering operator<=>(const ScalarType rhs) const noexcept; // (2) }; ``` 1. 3-way compares two JSON values producing a result of type `std::partial_ordering` according to the following rules: - Two JSON values compare with a result of `std::partial_ordering::unordered` if either value is discarded. - If both JSON values are of the same type, the result is produced by 3-way comparing their stored values using their respective `operator<=>`. - Integer and floating-point numbers are converted to their common type and then 3-way compared using their respective `operator<=>`. For instance, comparing an integer and a floating-point value will 3-way compare the first value converted to floating-point with the second value. - Otherwise, yields a result by comparing the type (see [`value_t`](value_t.md)). 2. 3-way compares a JSON value and a scalar or a scalar and a JSON value by converting the scalar to a JSON value and 3-way comparing both JSON values (see 1). ## Template parameters `ScalarType` : a scalar type according to `std::is_scalar<ScalarType>::value` ## Parameters `rhs` (in) : second value to consider ## Return value the `std::partial_ordering` of the 3-way comparison of `*this` and `rhs` ## Exception safety No-throw guarantee: this function never throws exceptions. ## Complexity Linear. ## Notes !!! note "Comparing `NaN`" - `NaN` values are unordered within the domain of numbers. The following comparisons all yield `std::partial_ordering::unordered`: 1. Comparing a `NaN` with itself. 2. Comparing a `NaN` with another `NaN`. 3. Comparing a `NaN` and any other number. ## Examples ??? example "Example: (1) comparing JSON values" The example demonstrates comparing several JSON values. ```cpp --8<-- "examples/operator_spaceship__const_reference.c++20.cpp" ``` Output: ```json --8<-- "examples/operator_spaceship__const_reference.c++20.output" ``` ??? example "Example: (2) comparing JSON values and scalars" The example demonstrates comparing several JSON values and scalars. ```cpp --8<-- "examples/operator_spaceship__scalartype.c++20.cpp" ``` Output: ```json --8<-- "examples/operator_spaceship__scalartype.c++20.output" ``` ## See also - [**operator==**](operator_eq.md) - comparison: equal - [**operator!=**](operator_ne.md) - comparison: not equal - [**operator<**](operator_lt.md) - comparison: less than - [**operator<=**](operator_le.md) - comparison: less than or equal - [**operator>**](operator_gt.md) - comparison: greater than - [**operator>=**](operator_ge.md) - comparison: greater than or equal ## Version history 1. Added in version 3.11.0. 2. Added in version 3.11.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/object.md
.md
1,799
64
# <small>nlohmann::basic_json::</small>object ```cpp static basic_json object(initializer_list_t init = {}); ``` Creates a JSON object value from a given initializer list. The initializer lists elements must be pairs, and their first elements must be strings. If the initializer list is empty, the empty object `#!json {}` is created. ## Parameters `init` (in) : initializer list with JSON values to create an object from (optional) ## Return value JSON object value ## Exception safety Strong guarantee: if an exception is thrown, there are no changes in the JSON value. ## Exceptions Throws [`type_error.301`](../../home/exceptions.md#jsonexceptiontype_error301) if `init` is not a list of pairs whose first elements are strings. In this case, no object can be created. When such a value is passed to `basic_json(initializer_list_t, bool, value_t)`, an array would have been created from the passed initializer list `init`. See example below. ## Complexity Linear in the size of `init`. ## Notes This function is only added for symmetry reasons. In contrast to the related function `array(initializer_list_t)`, there are no cases which can only be expressed by this function. That is, any initializer list `init` can also be passed to the initializer list constructor `basic_json(initializer_list_t, bool, value_t)`. ## Examples ??? example The following code shows an example for the `object` function. ```cpp --8<-- "examples/object.cpp" ``` Output: ```json --8<-- "examples/object.output" ``` ## See also - [`basic_json(initializer_list_t)`](basic_json.md) - create a JSON value from an initializer list - [`array`](array.md) - create a JSON array value from an initializer list ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/emplace_back.md
.md
1,226
55
# <small>nlohmann::basic_json::</small>emplace_back ```cpp template<class... Args> reference emplace_back(Args&& ... args); ``` Creates a JSON value from the passed parameters `args` to the end of the JSON value. If the function is called on a JSON `#!json null` value, an empty array is created before appending the value created from `args`. ## Template parameters `Args` : compatible types to create a `basic_json` object ## Parameters `args` (in) : arguments to forward to a constructor of `basic_json` ## Return value reference to the inserted element ## Exceptions Throws [`type_error.311`](../../home/exceptions.md#jsonexceptiontype_error311) when called on a type other than JSON array or `#!json null`; example: `"cannot use emplace_back() with number"` ## Complexity Amortized constant. ## Examples ??? example The example shows how `emplace_back()` can be used to add elements to a JSON array. Note how the `null` value was silently converted to a JSON array. ```cpp --8<-- "examples/emplace_back.cpp" ``` Output: ```json --8<-- "examples/emplace_back.output" ``` ## Version history - Since version 2.0.8. - Returns reference since 3.7.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/value.md
.md
5,167
160
# <small>nlohmann::basic_json::</small>value ```cpp // (1) template<class ValueType> ValueType value(const typename object_t::key_type& key, ValueType&& default_value) const; // (2) template<class ValueType, class KeyType> ValueType value(KeyType&& key, ValueType&& default_value) const; // (3) template<class ValueType> ValueType value(const json_pointer& ptr, const ValueType& default_value) const; ``` 1. Returns either a copy of an object's element at the specified key `key` or a given default value if no element with key `key` exists. The function is basically equivalent to executing ```cpp try { return at(key); } catch(out_of_range) { return default_value; } ``` 2. See 1. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and `#!cpp typename object_comparator_t::is_transparent` denotes a type. 3. Returns either a copy of an object's element at the specified JSON pointer `ptr` or a given default value if no value at `ptr` exists. The function is basically equivalent to executing ```cpp try { return at(ptr); } catch(out_of_range) { return default_value; } ``` !!! note "Differences to `at` and `operator[]`" - Unlike [`at`](at.md), this function does not throw if the given `key`/`ptr` was not found. - Unlike [`operator[]`](operator[].md), this function does not implicitly add an element to the position defined by `key`/`ptr` key. This function is furthermore also applicable to const objects. ## Template parameters `KeyType` : A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). This can also be a string view (C++17). `ValueType` : type compatible to JSON values, for instance `#!cpp int` for JSON integer numbers, `#!cpp bool` for JSON booleans, or `#!cpp std::vector` types for JSON arrays. Note the type of the expected value at `key`/`ptr` and the default value `default_value` must be compatible. ## Parameters `key` (in) : key of the element to access `default_value` (in) : the value to return if `key`/`ptr` found no value `ptr` (in) : a JSON pointer to the element to access ## Return value 1. copy of the element at key `key` or `default_value` if `key` is not found 2. copy of the element at key `key` or `default_value` if `key` is not found 3. copy of the element at JSON Pointer `ptr` or `default_value` if no value for `ptr` is found ## Exception safety Strong guarantee: if an exception is thrown, there are no changes to any JSON value. ## Exceptions 1. The function can throw the following exceptions: - Throws [`type_error.302`](../../home/exceptions.md#jsonexceptiontype_error302) if `default_value` does not match the type of the value at `key` - Throws [`type_error.306`](../../home/exceptions.md#jsonexceptiontype_error306) if the JSON value is not an object; in that case, using `value()` with a key makes no sense. 2. See 1. 3. The function can throw the following exceptions: - Throws [`type_error.302`](../../home/exceptions.md#jsonexceptiontype_error302) if `default_value` does not match the type of the value at `ptr` - Throws [`type_error.306`](../../home/exceptions.md#jsonexceptiontype_error306) if the JSON value is not an object; in that case, using `value()` with a key makes no sense. ## Complexity 1. Logarithmic in the size of the container. 2. Logarithmic in the size of the container. 3. Logarithmic in the size of the container. ## Examples ??? example "Example: (1) access specified object element with default value" The example below shows how object elements can be queried with a default value. ```cpp --8<-- "examples/value__object_t_key_type.cpp" ``` Output: ```json --8<-- "examples/value__object_t_key_type.output" ``` ??? example "Example: (2) access specified object element using string_view with default value" The example below shows how object elements can be queried with a default value. ```cpp --8<-- "examples/value__keytype.c++17.cpp" ``` Output: ```json --8<-- "examples/value__keytype.c++17.output" ``` ??? example "Example: (3) access specified object element via JSON Pointer with default value" The example below shows how object elements can be queried with a default value. ```cpp --8<-- "examples/value__json_ptr.cpp" ``` Output: ```json --8<-- "examples/value__json_ptr.output" ``` ## See also - see [`at`](at.md) for access by reference with range checking - see [`operator[]`](operator%5B%5D.md) for unchecked access by reference ## Version history 1. Added in version 1.0.0. Changed parameter `default_value` type from `const ValueType&` to `ValueType&&` in version 3.11.0. 2. Added in version 3.11.0. Made `ValueType` the first template parameter in version 3.11.2. 3. Added in version 2.0.2.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/is_primitive.md
.md
1,860
70
# <small>nlohmann::basic_json::</small>is_primitive ```cpp constexpr bool is_primitive() const noexcept; ``` This function returns `#!cpp true` if and only if the JSON type is primitive (string, number, boolean, `#!json null`, binary). ## Return value `#!cpp true` if type is primitive (string, number, boolean, `#!json null`, or binary), `#!cpp false` otherwise. ## Exception safety No-throw guarantee: this member function never throws exceptions. ## Complexity Constant. ## Possible implementation ```cpp constexpr bool is_primitive() const noexcept { return is_null() || is_string() || is_boolean() || is_number() || is_binary(); } ``` ## Notes The term *primitive* stems from [RFC 8259](https://tools.ietf.org/html/rfc8259): > JSON can represent four primitive types (strings, numbers, booleans, and null) and two structured types (objects and > arrays). This library extends primitive types to binary types, because binary types are roughly comparable to strings. Hence, `is_primitive()` returns `#!cpp true` for binary values. ## Examples ??? example The following code exemplifies `is_primitive()` for all JSON types. ```cpp --8<-- "examples/is_primitive.cpp" ``` Output: ```json --8<-- "examples/is_primitive.output" ``` ## See also - [is_structured()](is_structured.md) returns whether JSON value is structured - [is_null()](is_null.md) returns whether JSON value is `null` - [is_string()](is_string.md) returns whether JSON value is a string - [is_boolean()](is_boolean.md) returns whether JSON value is a boolean - [is_number()](is_number.md) returns whether JSON value is a number - [is_binary()](is_binary.md) returns whether JSON value is a binary array ## Version history - Added in version 1.0.0. - Extended to return `#!cpp true` for binary types in version 3.8.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/operator_le.md
.md
2,336
88
# <small>nlohmann::basic_json::</small>operator<= ```cpp // until C++20 bool operator<=(const_reference lhs, const_reference rhs) noexcept; // (1) template<typename ScalarType> bool operator<=(const_reference lhs, const ScalarType rhs) noexcept; // (2) template<typename ScalarType> bool operator<=(ScalarType lhs, const const_reference rhs) noexcept; // (2) ``` 1. Compares whether one JSON value `lhs` is less than or equal to another JSON value `rhs` according to the following rules: - The comparison always yields `#!cpp false` if (1) either operand is discarded, or (2) either operand is `NaN` and the other operand is either `NaN` or any other number. - Otherwise, returns the result of `#!cpp !(rhs < lhs)` (see [**operator<**](operator_lt.md)). 1. Compares wether a JSON value is less than or equal to a scalar or a scalar is less than or equal to a JSON value by converting the scalar to a JSON value and comparing both JSON values according to 1. ## Template parameters `ScalarType` : a scalar type according to `std::is_scalar<ScalarType>::value` ## Parameters `lhs` (in) : first value to consider `rhs` (in) : second value to consider ## Return value whether `lhs` is less than or equal to `rhs` ## Exception safety No-throw guarantee: this function never throws exceptions. ## Complexity Linear. ## Notes !!! note "Comparing `NaN`" `NaN` values are unordered within the domain of numbers. The following comparisons all yield `#!cpp false`: 1. Comparing a `NaN` with itself. 2. Comparing a `NaN` with another `NaN`. 3. Comparing a `NaN` and any other number. !!! note "Operator overload resolution" Since C++20 overload resolution will consider the _rewritten candidate_ generated from [`operator<=>`](operator_spaceship.md). ## Examples ??? example The example demonstrates comparing several JSON types. ```cpp --8<-- "examples/operator__lessequal.cpp" ``` Output: ```json --8<-- "examples/operator__lessequal.output" ``` ## See also - [**operator<=>**](operator_spaceship.md) comparison: 3-way ## Version history 1. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0. 2. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/erase.md
.md
7,465
212
# <small>nlohmann::basic_json::</small>erase ```cpp // (1) iterator erase(iterator pos); const_iterator erase(const_iterator pos); // (2) iterator erase(iterator first, iterator last); const_iterator erase(const_iterator first, const_iterator last); // (3) size_type erase(const typename object_t::key_type& key); // (4) template<typename KeyType> size_type erase(KeyType&& key); // (5) void erase(const size_type idx); ``` 1. Removes an element from a JSON value specified by iterator `pos`. The iterator `pos` must be valid and dereferenceable. Thus, the `end()` iterator (which is valid, but is not dereferenceable) cannot be used as a value for `pos`. If called on a primitive type other than `#!json null`, the resulting JSON value will be `#!json null`. 2. Remove an element range specified by `[first; last)` from a JSON value. The iterator `first` does not need to be dereferenceable if `first == last`: erasing an empty range is a no-op. If called on a primitive type other than `#!json null`, the resulting JSON value will be `#!json null`. 3. Removes an element from a JSON object by key. 4. See 3. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and `#!cpp typename object_comparator_t::is_transparent` denotes a type. 5. Removes an element from a JSON array by index. ## Template parameters `KeyType` : A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). This can also be a string view (C++17). ## Parameters `pos` (in) : iterator to the element to remove `first` (in) : iterator to the beginning of the range to remove `last` (in) : iterator past the end of the range to remove `key` (in) : object key of the elements to remove `idx` (in) : array index of the element to remove ## Return value 1. Iterator following the last removed element. If the iterator `pos` refers to the last element, the `end()` iterator is returned. 2. Iterator following the last removed element. If the iterator `last` refers to the last element, the `end()` iterator is returned. 3. Number of elements removed. If `ObjectType` is the default `std::map` type, the return value will always be `0` (`key` was not found) or `1` (`key` was found). 4. See 3. 5. (none) ## Exception safety Strong exception safety: if an exception occurs, the original value stays intact. ## Exceptions 1. The function can throw the following exceptions: - Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) if called on a `null` value; example: `"cannot use erase() with null"` - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` - Throws [`invalid_iterator.205`](../../home/exceptions.md#jsonexceptioninvalid_iterator205) if called on a primitive type with invalid iterator (i.e., any iterator which is not `begin()`); example: `"iterator out of range"` 2. The function can throw the following exceptions: - Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) if called on a `null` value; example: `"cannot use erase() with null"` - Throws [`invalid_iterator.203`](../../home/exceptions.md#jsonexceptioninvalid_iterator203) if called on iterators which does not belong to the current JSON value; example: `"iterators do not fit current value"` - Throws [`invalid_iterator.204`](../../home/exceptions.md#jsonexceptioninvalid_iterator204) if called on a primitive type with invalid iterators (i.e., if `first != begin()` and `last != end()`); example: `"iterators out of range"` 3. The function can throw the following exceptions: - Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) when called on a type other than JSON object; example: `"cannot use erase() with null"` 4. See 3. 5. The function can throw the following exceptions: - Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) when called on a type other than JSON object; example: `"cannot use erase() with null"` - Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) when `idx >= size()`; example: `"array index 17 is out of range"` ## Complexity 1. The complexity depends on the type: - objects: amortized constant - arrays: linear in distance between `pos` and the end of the container - strings and binary: linear in the length of the member - other types: constant 2. The complexity depends on the type: - objects: `log(size()) + std::distance(first, last)` - arrays: linear in the distance between `first` and `last`, plus linear in the distance between `last` and end of the container - strings and binary: linear in the length of the member - other types: constant 3. `log(size()) + count(key)` 4. `log(size()) + count(key)` 5. Linear in distance between `idx` and the end of the container. ## Notes 1. Invalidates iterators and references at or after the point of the `erase`, including the `end()` iterator. 2. (none) 3. References and iterators to the erased elements are invalidated. Other references and iterators are not affected. 4. See 3. 5. (none) ## Examples ??? example "Example: (1) remove element given an iterator" The example shows the effect of `erase()` for different JSON types using an iterator. ```cpp --8<-- "examples/erase__IteratorType.cpp" ``` Output: ```json --8<-- "examples/erase__IteratorType.output" ``` ??? example "Example: (2) remove elements given an iterator range" The example shows the effect of `erase()` for different JSON types using an iterator range. ```cpp --8<-- "examples/erase__IteratorType_IteratorType.cpp" ``` Output: ```json --8<-- "examples/erase__IteratorType_IteratorType.output" ``` ??? example "Example: (3) remove element from a JSON object given a key" The example shows the effect of `erase()` for different JSON types using an object key. ```cpp --8<-- "examples/erase__object_t_key_type.cpp" ``` Output: ```json --8<-- "examples/erase__object_t_key_type.output" ``` ??? example "Example: (4) remove element from a JSON object given a key using string_view" The example shows the effect of `erase()` for different JSON types using an object key. ```cpp --8<-- "examples/erase__keytype.c++17.cpp" ``` Output: ```json --8<-- "examples/erase__keytype.c++17.output" ``` ??? example "Example: (5) remove element from a JSON array given an index" The example shows the effect of `erase()` using an array index. ```cpp --8<-- "examples/erase__size_type.cpp" ``` Output: ```json --8<-- "examples/erase__size_type.output" ``` ## Version history 1. Added in version 1.0.0. Added support for binary types in version 3.8.0. 2. Added in version 1.0.0. Added support for binary types in version 3.8.0. 3. Added in version 1.0.0. 4. Added in version 3.11.0. 5. Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/count.md
.md
1,993
79
# <small>nlohmann::basic_json::</small>count ```cpp // (1) size_type count(const typename object_t::key_type& key) const; // (2) template<typename KeyType> size_type count(KeyType&& key) const; ``` 1. Returns the number of elements with key `key`. If `ObjectType` is the default `std::map` type, the return value will always be `0` (`key` was not found) or `1` (`key` was found). 2. See 1. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and `#!cpp typename object_comparator_t::is_transparent` denotes a type. ## Template parameters `KeyType` : A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). This can also be a string view (C++17). ## Parameters `key` (in) : key value of the element to count. ## Return value Number of elements with key `key`. If the JSON value is not an object, the return value will be `0`. ## Exception safety Strong exception safety: if an exception occurs, the original value stays intact. ## Complexity Logarithmic in the size of the JSON object. ## Notes This method always returns `0` when executed on a JSON type that is not an object. ## Examples ??? example "Example: (1) count number of elements" The example shows how `count()` is used. ```cpp --8<-- "examples/count__object_t_key_type.cpp" ``` Output: ```json --8<-- "examples/count__object_t_key_type.output" ``` ??? example "Example: (2) count number of elements using string_view" The example shows how `count()` is used. ```cpp --8<-- "examples/count__keytype.c++17.cpp" ``` Output: ```json --8<-- "examples/count__keytype.c++17.output" ``` ## Version history 1. Added in version 3.11.0. 2. Added in version 1.0.0. Changed parameter `key` type to `KeyType&&` in version 3.11.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/to_bjdata.md
.md
1,939
71
# <small>nlohmann::basic_json::</small>to_bjdata ```cpp // (1) static std::vector<std::uint8_t> to_bjdata(const basic_json& j, const bool use_size = false, const bool use_type = false); // (2) static void to_bjdata(const basic_json& j, detail::output_adapter<std::uint8_t> o, const bool use_size = false, const bool use_type = false); static void to_bjdata(const basic_json& j, detail::output_adapter<char> o, const bool use_size = false, const bool use_type = false); ``` Serializes a given JSON value `j` to a byte vector using the BJData (Binary JData) serialization format. BJData aims to be more compact than JSON itself, yet more efficient to parse. 1. Returns a byte vector containing the BJData serialization. 2. Writes the BJData serialization to an output adapter. The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/bjdata.md). ## Parameters `j` (in) : JSON value to serialize `o` (in) : output adapter to write serialization to `use_size` (in) : whether to add size annotations to container types; optional, `#!cpp false` by default. `use_type` (in) : whether to add type annotations to container types (must be combined with `#!cpp use_size = true`); optional, `#!cpp false` by default. ## Return value 1. BJData serialization as byte vector 2. (none) ## Exception safety Strong guarantee: if an exception is thrown, there are no changes in the JSON value. ## Complexity Linear in the size of the JSON value `j`. ## Examples ??? example The example shows the serialization of a JSON value to a byte vector in BJData format. ```cpp --8<-- "examples/to_bjdata.cpp" ``` Output: ```json --8<-- "examples/to_bjdata.output" ``` ## Version history - Added in version 3.11.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/is_number_float.md
.md
1,038
47
# <small>nlohmann::basic_json::</small>is_number_float ```cpp constexpr bool is_number_float() const noexcept; ``` This function returns `#!cpp true` if and only if the JSON value is a floating-point number. This excludes signed and unsigned integer values. ## Return value `#!cpp true` if type is a floating-point number, `#!cpp false` otherwise. ## Exception safety No-throw guarantee: this member function never throws exceptions. ## Complexity Constant. ## Examples ??? example The following code exemplifies `is_number_float()` for all JSON types. ```cpp --8<-- "examples/is_number_float.cpp" ``` Output: ```json --8<-- "examples/is_number_float.output" ``` ## See also - [is_number()](is_number.md) check if value is a number - [is_number_integer()](is_number_integer.md) check if value is an integer or unsigned integer number - [is_number_unsigned()](is_number_unsigned.md) check if value is an unsigned integer number ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/operator[].md
.md
8,075
242
# <small>nlohmann::basic_json::</small>operator[] ```cpp // (1) reference operator[](size_type idx); const_reference operator[](size_type idx) const; // (2) reference operator[](typename object_t::key_type key); const_reference operator[](const typename object_t::key_type& key) const; // (3) template<typename KeyType> reference operator[](KeyType&& key); template<typename KeyType> const_reference operator[](KeyType&& key) const; // (4) reference operator[](const json_pointer& ptr); const_reference operator[](const json_pointer& ptr) const; ``` 1. Returns a reference to the array element at specified location `idx`. 2. Returns a reference to the object element with specified key `key`. The non-const qualified overload takes the key by value. 3. See 2. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and `#!cpp typename object_comparator_t::is_transparent` denotes a type. 4. Returns a reference to the element with specified JSON pointer `ptr`. ## Template parameters `KeyType` : A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). This can also be a string view (C++17). ## Parameters `idx` (in) : index of the element to access `key` (in) : object key of the element to access `ptr` (in) : JSON pointer to the desired element ## Return value 1. (const) reference to the element at index `idx` 2. (const) reference to the element at key `key` 3. (const) reference to the element at key `key` 4. (const) reference to the element pointed to by `ptr` ## Exception safety Strong exception safety: if an exception occurs, the original value stays intact. ## Exceptions 1. The function can throw the following exceptions: - Throws [`type_error.305`](../../home/exceptions.md#jsonexceptiontype_error305) if the JSON value is not an array or null; in that case, using the `[]` operator with an index makes no sense. 2. The function can throw the following exceptions: - Throws [`type_error.305`](../../home/exceptions.md#jsonexceptiontype_error305) if the JSON value is not an object or null; in that case, using the `[]` operator with a key makes no sense. 3. See 2. 4. The function can throw the following exceptions: - Throws [`parse_error.106`](../../home/exceptions.md#jsonexceptionparse_error106) if an array index in the passed JSON pointer `ptr` begins with '0'. - Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) if an array index in the passed JSON pointer `ptr` is not a number. - Throws [`out_of_range.402`](../../home/exceptions.md#jsonexceptionout_of_range402) if the array index '-' is used in the passed JSON pointer `ptr` for the const version. - Throws [`out_of_range.404`](../../home/exceptions.md#jsonexceptionout_of_range404) if the JSON pointer `ptr` can not be resolved. ## Complexity 1. Constant if `idx` is in the range of the array. Otherwise, linear in `idx - size()`. 2. Logarithmic in the size of the container. 3. Logarithmic in the size of the container. 4. Logarithmic in the size of the container. ## Notes !!! danger "Undefined behavior and runtime assertions" 1. If the element with key `idx` does not exist, the behavior is undefined. 2. If the element with key `key` does not exist, the behavior is undefined and is **guarded by a [runtime assertion](../../features/assertions.md)**! 1. The non-const version may add values: If `idx` is beyond the range of the array (i.e., `idx >= size()`), then the array is silently filled up with `#!json null` values to make `idx` a valid reference to the last stored element. In case the value was `#!json null` before, it is converted to an array. 2. If `key` is not found in the object, then it is silently added to the object and filled with a `#!json null` value to make `key` a valid reference. In case the value was `#!json null` before, it is converted to an object. 3. See 2. 4. `null` values are created in arrays and objects if necessary. In particular: - If the JSON pointer points to an object key that does not exist, it is created and filled with a `#!json null` value before a reference to it is returned. - If the JSON pointer points to an array index that does not exist, it is created and filled with a `#!json null` value before a reference to it is returned. All indices between the current maximum and the given index are also filled with `#!json null`. - The special value `-` is treated as a synonym for the index past the end. ## Examples ??? example "Example: (1) access specified array element" The example below shows how array elements can be read and written using `[]` operator. Note the addition of `#!json null` values. ```cpp --8<-- "examples/operator_array__size_type.cpp" ``` Output: ```json --8<-- "examples/operator_array__size_type.output" ``` ??? example "Example: (1) access specified array element (const)" The example below shows how array elements can be read using the `[]` operator. ```cpp --8<-- "examples/operator_array__size_type_const.cpp" ``` Output: ```json --8<-- "examples/operator_array__size_type_const.output" ``` ??? example "Example: (2) access specified object element" The example below shows how object elements can be read and written using the `[]` operator. ```cpp --8<-- "examples/operator_array__object_t_key_type.cpp" ``` Output: ```json --8<-- "examples/operator_array__object_t_key_type.output" ``` ??? example "Example: (2) access specified object element (const)" The example below shows how object elements can be read using the `[]` operator. ```cpp --8<-- "examples/operator_array__object_t_key_type_const.cpp" ``` Output: ```json --8<-- "examples/operator_array__object_t_key_type_const.output" ``` ??? example "Example: (3) access specified object element using string_view" The example below shows how object elements can be read using the `[]` operator. ```cpp --8<-- "examples/operator_array__keytype.c++17.cpp" ``` Output: ```json --8<-- "examples/operator_array__keytype.c++17.output" ``` ??? example "Example: (3) access specified object element using string_view (const)" The example below shows how object elements can be read using the `[]` operator. ```cpp --8<-- "examples/operator_array__keytype_const.c++17.cpp" ``` Output: ```json --8<-- "examples/operator_array__keytype_const.c++17.output" ``` ??? example "Example: (4) access specified element via JSON Pointer" The example below shows how values can be read and written using JSON Pointers. ```cpp --8<-- "examples/operator_array__json_pointer.cpp" ``` Output: ```json --8<-- "examples/operator_array__json_pointer.output" ``` ??? example "Example: (4) access specified element via JSON Pointer (const)" The example below shows how values can be read using JSON Pointers. ```cpp --8<-- "examples/operator_array__json_pointer_const.cpp" ``` Output: ```json --8<-- "examples/operator_array__json_pointer_const.output" ``` ## See also - documentation on [unchecked access](../../features/element_access/unchecked_access.md) - documentation on [runtime assertions](../../features/assertions.md) - see [`at`](at.md) for access by reference with range checking - see [`value`](value.md) for access with default value ## Version history 1. Added in version 1.0.0. 2. Added in version 1.0.0. Added overloads for `T* key` in version 1.1.0. Removed overloads for `T* key` (replaced by 3) in version 3.11.0. 3. Added in version 3.11.0. 4. Added in version 2.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/rbegin.md
.md
726
43
# <small>nlohmann::basic_json::</small>rbegin ```cpp reverse_iterator rbegin() noexcept; const_reverse_iterator rbegin() const noexcept; ``` Returns an iterator to the reverse-beginning; that is, the last element. ![Illustration from cppreference.com](../../images/range-rbegin-rend.svg) ## Return value reverse iterator to the first element ## Exception safety No-throw guarantee: this member function never throws exceptions. ## Complexity Constant. ## Examples ??? example The following code shows an example for `rbegin()`. ```cpp --8<-- "examples/rbegin.cpp" ``` Output: ```json --8<-- "examples/rbegin.output" ``` ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/meta.md
.md
3,249
57
# <small>nlohmann::basic_json::</small>meta ```cpp static basic_json meta(); ``` This function returns a JSON object with information about the library, including the version number and information on the platform and compiler. ## Return value JSON object holding version information | key | description | |-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `compiler` | Information on the used compiler. It is an object with the following keys: `c++` (the used C++ standard), `family` (the compiler family; possible values are `clang`, `icc`, `gcc`, `ilecpp`, `msvc`, `pgcpp`, `sunpro`, and `unknown`), and `version` (the compiler version). | | `copyright` | The copyright line for the library as string. | | `name` | The name of the library as string. | | `platform` | The used platform as string. Possible values are `win32`, `linux`, `apple`, `unix`, and `unknown`. | | `url` | The URL of the project as string. | | `version` | The version of the library. It is an object with the following keys: `major`, `minor`, and `patch` as defined by [Semantic Versioning](http://semver.org), and `string` (the version string). | ## Exception safety Strong guarantee: if an exception is thrown, there are no changes to any JSON value. ## Complexity Constant. ## Examples ??? example The following code shows an example output of the `meta()` function. ```cpp --8<-- "examples/meta.cpp" ``` Output: ```json --8<-- "examples/meta.output" ``` Note the output is platform-dependent. ## See also - [**NLOHMANN_JSON_VERSION_MAJOR**/**NLOHMANN_JSON_VERSION_MINOR**/**NLOHMANN_JSON_VERSION_PATCH**](../macros/nlohmann_json_version_major.md) \- library version information ## Version history - Added in version 2.1.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/out_of_range.md
.md
1,774
69
# <small>nlohmann::basic_json::</small>out_of_range ```cpp class out_of_range : public exception; ``` This exception is thrown in case a library function is called on an input parameter that exceeds the expected range, for instance in case of array indices or nonexisting object keys. Exceptions have ids 4xx (see [list of out-of-range errors](../../home/exceptions.md#out-of-range)). ```plantuml std::exception <|-- basic_json::exception basic_json::exception <|-- basic_json::parse_error basic_json::exception <|-- basic_json::invalid_iterator basic_json::exception <|-- basic_json::type_error basic_json::exception <|-- basic_json::out_of_range basic_json::exception <|-- basic_json::other_error interface std::exception {} class basic_json::exception { + const int id + const char* what() const } class basic_json::parse_error { + const std::size_t byte } class basic_json::out_of_range #FFFF00 {} ``` ## Member functions - **what** - returns explanatory string ## Member variables - **id** - the id of the exception ## Examples ??? example The following code shows how a `out_of_range` exception can be caught. ```cpp --8<-- "examples/out_of_range.cpp" ``` Output: ```json --8<-- "examples/out_of_range.output" ``` ## See also - [List of out-of-range errors](../../home/exceptions.md#out-of-range) - [`parse_error`](parse_error.md) for exceptions indicating a parse error - [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators - [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type - [`other_error`](other_error.md) for exceptions indicating other library errors ## Version history - Since version 3.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/number_unsigned_t.md
.md
3,250
77
# <small>nlohmann::basic_json::</small>number_unsigned_t ```cpp using number_unsigned_t = NumberUnsignedType; ``` The type used to store JSON numbers (unsigned). [RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows: > The representation of numbers is similar to that used in most programming languages. A number is represented in base > 10 using decimal digits. It contains an integer component that may be prefixed with an optional minus sign, which may > be followed by a fraction part and/or an exponent part. Leading zeros are not allowed. (...) Numeric values that > cannot be represented in the grammar below (such as Infinity and NaN) are not permitted. This description includes both integer and floating-point numbers. However, C++ allows more precise storage if it is known whether the number is a signed integer, an unsigned integer or a floating-point number. Therefore, three different types, [`number_integer_t`](number_integer_t.md), `number_unsigned_t` and [`number_float_t`](number_float_t.md) are used. To store unsigned integer numbers in C++, a type is defined by the template parameter `NumberUnsignedType` which chooses the type to use. ## Notes #### Default type With the default values for `NumberUnsignedType` (`std::uint64_t`), the default value for `number_unsigned_t` is `#!cpp std::uint64_t`. #### Default behavior - The restrictions about leading zeros is not enforced in C++. Instead, leading zeros in integer literals lead to an interpretation as octal number. Internally, the value will be stored as decimal number. For instance, the C++ integer literal `010` will be serialized to `8`. During deserialization, leading zeros yield an error. - Not-a-number (NaN) values will be serialized to `null`. #### Limits [RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: > An implementation may set limits on the range and precision of numbers. When the default type is used, the maximal integer number that can be stored is `18446744073709551615` (UINT64_MAX) and the minimal integer number that can be stored is `0`. Integer numbers that are out of range will yield over/underflow when used in a constructor. During deserialization, too large or small integer numbers will be automatically be stored as [`number_integer_t`](number_integer_t.md) or [`number_float_t`](number_float_t.md). [RFC 8259](https://tools.ietf.org/html/rfc8259) further states: > Note that when such software is used, numbers that are integers and are in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are > interoperable in the sense that implementations will agree exactly on their numeric values. As this range is a subrange (when considered in conjunction with the `number_integer_t` type) of the exactly supported range [0, UINT64_MAX], this class's integer type is interoperable. #### Storage Integer number values are stored directly inside a `basic_json` type. ## Examples ??? example The following code shows that `number_unsigned_t` is by default, a typedef to `#!cpp std::uint64_t`. ```cpp --8<-- "examples/number_unsigned_t.cpp" ``` Output: ```json --8<-- "examples/number_unsigned_t.output" ``` ## Version history - Added in version 2.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/sax_parse.md
.md
3,195
116
# <small>nlohmann::basic_json::</small>sax_parse ```cpp // (1) template <typename InputType, typename SAX> static bool sax_parse(InputType&& i, SAX* sax, input_format_t format = input_format_t::json, const bool strict = true, const bool ignore_comments = false); // (2) template<class IteratorType, class SAX> static bool sax_parse(IteratorType first, IteratorType last, SAX* sax, input_format_t format = input_format_t::json, const bool strict = true, const bool ignore_comments = false); ``` Read from input and generate SAX events 1. Read from a compatible input. 2. Read from a pair of character iterators The value_type of the iterator must be an integral type with size of 1, 2 or 4 bytes, which will be interpreted respectively as UTF-8, UTF-16 and UTF-32. The SAX event lister must follow the interface of [`json_sax`](../json_sax/index.md). ## Template parameters `InputType` : A compatible input, for instance: - an `std::istream` object - a `FILE` pointer - a C-style array of characters - a pointer to a null-terminated string of single byte characters - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. `IteratorType` : Description `SAX` : Description ## Parameters `i` (in) : Input to parse from. `sax` (in) : SAX event listener `format` (in) : the format to parse (JSON, CBOR, MessagePack, or UBJSON) (optional, `input_format_t::json` by default), see [`input_format_t`](input_format_t.md) for more information `strict` (in) : whether the input has to be consumed completely (optional, `#!cpp true` by default) `ignore_comments` (in) : whether comments should be ignored and treated like whitespace (`#!cpp true`) or yield a parse error (`#!cpp false`); (optional, `#!cpp false` by default) `first` (in) : iterator to start of character range `last` (in) : iterator to end of character range ## Return value return value of the last processed SAX event ## Exception safety ## Complexity Linear in the length of the input. The parser is a predictive LL(1) parser. The complexity can be higher if the SAX consumer `sax` has a super-linear complexity. ## Notes A UTF-8 byte order mark is silently ignored. ## Examples ??? example The example below demonstrates the `sax_parse()` function reading from string and processing the events with a user-defined SAX event consumer. ```cpp --8<-- "examples/sax_parse.cpp" ``` Output: ```json --8<-- "examples/sax_parse.output" ``` ## Version history - Added in version 3.2.0. - Ignoring comments via `ignore_comments` added in version 3.9.0. !!! warning "Deprecation" Overload (2) replaces calls to `sax_parse` with a pair of iterators as their first parameter which has been deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like `#!cpp sax_parse({ptr, ptr+len});` with `#!cpp sax_parse(ptr, ptr+len);`.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/get_binary.md
.md
745
46
# <small>nlohmann::basic_json::</small>get_binary ```cpp binary_t& get_binary(); const binary_t& get_binary() const; ``` Returns a reference to the stored binary value. ## Return value Reference to binary value. ## Exception safety Strong exception safety: if an exception occurs, the original value stays intact. ## Exceptions Throws [`type_error.302`](../../home/exceptions.md#jsonexceptiontype_error302) if the value is not binary ## Complexity Constant. ## Examples ??? example The following code shows how to query a binary value. ```cpp --8<-- "examples/get_binary.cpp" ``` Output: ```json --8<-- "examples/get_binary.output" ``` ## Version history - Added in version 3.8.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/to_ubjson.md
.md
1,951
71
# <small>nlohmann::basic_json::</small>to_ubjson ```cpp // (1) static std::vector<std::uint8_t> to_ubjson(const basic_json& j, const bool use_size = false, const bool use_type = false); // (2) static void to_ubjson(const basic_json& j, detail::output_adapter<std::uint8_t> o, const bool use_size = false, const bool use_type = false); static void to_ubjson(const basic_json& j, detail::output_adapter<char> o, const bool use_size = false, const bool use_type = false); ``` Serializes a given JSON value `j` to a byte vector using the UBJSON (Universal Binary JSON) serialization format. UBJSON aims to be more compact than JSON itself, yet more efficient to parse. 1. Returns a byte vector containing the UBJSON serialization. 2. Writes the UBJSON serialization to an output adapter. The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/ubjson.md). ## Parameters `j` (in) : JSON value to serialize `o` (in) : output adapter to write serialization to `use_size` (in) : whether to add size annotations to container types; optional, `#!cpp false` by default. `use_type` (in) : whether to add type annotations to container types (must be combined with `#!cpp use_size = true`); optional, `#!cpp false` by default. ## Return value 1. UBJSON serialization as byte vector 2. (none) ## Exception safety Strong guarantee: if an exception is thrown, there are no changes in the JSON value. ## Complexity Linear in the size of the JSON value `j`. ## Examples ??? example The example shows the serialization of a JSON value to a byte vector in UBJSON format. ```cpp --8<-- "examples/to_ubjson.cpp" ``` Output: ```json --8<-- "examples/to_ubjson.output" ``` ## Version history - Added in version 3.1.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/cend.md
.md
644
42
# <small>nlohmann::basic_json::</small>cend ```cpp const_iterator cend() const noexcept; ``` Returns an iterator to one past the last element. ![Illustration from cppreference.com](../../images/range-begin-end.svg) ## Return value iterator one past the last element ## Exception safety No-throw guarantee: this member function never throws exceptions. ## Complexity Constant. ## Examples ??? example The following code shows an example for `cend()`. ```cpp --8<-- "examples/cend.cpp" ``` Output: ```json --8<-- "examples/cend.output" ``` ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/emplace.md
.md
1,518
57
# <small>nlohmann::basic_json::</small>emplace ```cpp template<class... Args> std::pair<iterator, bool> emplace(Args&& ... args); ``` Inserts a new element into a JSON object constructed in-place with the given `args` if there is no element with the key in the container. If the function is called on a JSON null value, an empty object is created before appending the value created from `args`. ## Template parameters `Args` : compatible types to create a `basic_json` object ## Parameters `args` (in) : arguments to forward to a constructor of `basic_json` ## Return value a pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `#!cpp bool` denoting whether the insertion took place. ## Exceptions Throws [`type_error.311`](../../home/exceptions.md#jsonexceptiontype_error311) when called on a type other than JSON object or `#!json null`; example: `"cannot use emplace() with number"` ## Complexity Logarithmic in the size of the container, O(log(`size()`)). ## Examples ??? example The example shows how `emplace()` can be used to add elements to a JSON object. Note how the `#!json null` value was silently converted to a JSON object. Further note how no value is added if there was already one value stored with the same key. ```cpp --8<-- "examples/emplace.cpp" ``` Output: ```json --8<-- "examples/emplace.output" ``` ## Version history - Since version 2.0.8.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/rend.md
.md
832
44
# <small>nlohmann::basic_json::</small>rend ```cpp reverse_iterator rend() noexcept; const_reverse_iterator rend() const noexcept; ``` Returns an iterator to the reverse-end; that is, one before the first element. This element acts as a placeholder, attempting to access it results in undefined behavior. ![Illustration from cppreference.com](../../images/range-rbegin-rend.svg) ## Return value reverse iterator to the element following the last element ## Exception safety No-throw guarantee: this member function never throws exceptions. ## Complexity Constant. ## Examples ??? example The following code shows an example for `eend()`. ```cpp --8<-- "examples/rend.cpp" ``` Output: ```json --8<-- "examples/rend.output" ``` ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/object_t.md
.md
4,225
115
# <small>nlohmann::basic_json::</small>object_t ```cpp using object_t = ObjectType<StringType, basic_json, default_object_comparator_t, AllocatorType<std::pair<const StringType, basic_json>>>; ``` The type used to store JSON objects. [RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON objects as follows: > An object is an unordered collection of zero or more name/value pairs, where a name is a string and a value is a > string, number, boolean, null, object, or array. To store objects in C++, a type is defined by the template parameters described below. ## Template parameters `ObjectType` : the container to store objects (e.g., `std::map` or `std::unordered_map`) `StringType` : the type of the keys or names (e.g., `std::string`). The comparison function `std::less<StringType>` is used to order elements inside the container. `AllocatorType` : the allocator to use for objects (e.g., `std::allocator`) ## Notes #### Default type With the default values for `ObjectType` (`std::map`), `StringType` (`std::string`), and `AllocatorType` (`std::allocator`), the default value for `object_t` is: ```cpp // until C++14 std::map< std::string, // key_type basic_json, // value_type std::less<std::string>, // key_compare std::allocator<std::pair<const std::string, basic_json>> // allocator_type > // since C++14 std::map< std::string, // key_type basic_json, // value_type std::less<>, // key_compare std::allocator<std::pair<const std::string, basic_json>> // allocator_type > ``` See [`default_object_comparator_t`](default_object_comparator_t.md) for more information. #### Behavior The choice of `object_t` influences the behavior of the JSON class. With the default type, objects have the following behavior: - When all names are unique, objects will be interoperable in the sense that all software implementations receiving that object will agree on the name-value mappings. - When the names within an object are not unique, it is unspecified which one of the values for a given key will be chosen. For instance, `#!json {"key": 2, "key": 1}` could be equal to either `#!json {"key": 1}` or `#!json {"key": 2}`. - Internally, name/value pairs are stored in lexicographical order of the names. Objects will also be serialized (see [`dump`](dump.md)) in this order. For instance, `#!json {"b": 1, "a": 2}` and `#!json {"a": 2, "b": 1}` will be stored and serialized as `#!json {"a": 2, "b": 1}`. - When comparing objects, the order of the name/value pairs is irrelevant. This makes objects interoperable in the sense that they will not be affected by these differences. For instance, `#!json {"b": 1, "a": 2}` and `#!json {"a": 2, "b": 1}` will be treated as equal. #### Limits [RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: > An implementation may set limits on the maximum depth of nesting. In this class, the object's limit of nesting is not explicitly constrained. However, a maximum depth of nesting may be introduced by the compiler or runtime environment. A theoretical limit can be queried by calling the [`max_size`](max_size.md) function of a JSON object. #### Storage Objects are stored as pointers in a `basic_json` type. That is, for any access to object values, a pointer of type `object_t*` must be dereferenced. #### Object key order The order name/value pairs are added to the object is *not* preserved by the library. Therefore, iterating an object may return name/value pairs in a different order than they were originally stored. In fact, keys will be traversed in alphabetical order as `std::map` with `std::less` is used by default. Please note this behavior conforms to [RFC 8259](https://tools.ietf.org/html/rfc8259), because any order implements the specified "unordered" nature of JSON objects. ## Examples ??? example The following code shows that `object_t` is by default, a typedef to `#!cpp std::map<json::string_t, json>`. ```cpp --8<-- "examples/object_t.cpp" ``` Output: ```json --8<-- "examples/object_t.output" ``` ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/from_msgpack.md
.md
3,824
110
# <small>nlohmann::basic_json::</small>from_msgpack ```cpp // (1) template<typename InputType> static basic_json from_msgpack(InputType&& i, const bool strict = true, const bool allow_exceptions = true); // (2) template<typename IteratorType> static basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true); ``` Deserializes a given input to a JSON value using the MessagePack serialization format. 1. Reads from a compatible input. 2. Reads from an iterator range. The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/messagepack.md). ## Template parameters `InputType` : A compatible input, for instance: - an `std::istream` object - a `FILE` pointer - a C-style array of characters - a pointer to a null-terminated string of single byte characters - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. `IteratorType` : a compatible iterator type ## Parameters `i` (in) : an input in MessagePack format convertible to an input adapter `first` (in) : iterator to start of the input `last` (in) : iterator to end of the input `strict` (in) : whether to expect the input to be consumed until EOF (`#!cpp true` by default) `allow_exceptions` (in) : whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) ## Return value deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be `value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). ## Exception safety Strong guarantee: if an exception is thrown, there are no changes in the JSON value. ## Exceptions - Throws [parse_error.110](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or the end of file was not reached when `strict` was set to true - Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if unsupported features from MessagePack were used in the given input or if the input is not valid MessagePack - Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string was expected as map key, but not found ## Complexity Linear in the size of the input. ## Examples ??? example The example shows the deserialization of a byte vector in MessagePack format to a JSON value. ```cpp --8<-- "examples/from_msgpack.cpp" ``` Output: ```json --8<-- "examples/from_msgpack.output" ``` ## Version history - Added in version 2.0.9. - Parameter `start_index` since version 2.1.1. - Changed to consume input adapters, removed `start_index` parameter, and added `strict` parameter in version 3.0.0. - Added `allow_exceptions` parameter in version 3.2.0. !!! warning "Deprecation" - Overload (2) replaces calls to `from_msgpack` with a pointer and a length as first two parameters, which has been deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like `#!cpp from_msgpack(ptr, len, ...);` with `#!cpp from_msgpack(ptr, ptr+len, ...);`. - Overload (2) replaces calls to `from_cbor` with a pair of iterators as their first parameter, which has been deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like `#!cpp from_msgpack({ptr, ptr+len}, ...);` with `#!cpp from_msgpack(ptr, ptr+len, ...);`. You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated function.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/get.md
.md
4,371
137
# <small>nlohmann::basic_json::</small>get ```cpp // (1) template<typename ValueType> ValueType get() const noexcept( noexcept(JSONSerializer<ValueType>::from_json( std::declval<const basic_json_t&>(), std::declval<ValueType&>()))); // (2) template<typename BasicJsonType> BasicJsonType get() const; // (3) template<typename PointerType> PointerType get_ptr(); template<typename PointerType> constexpr const PointerType get_ptr() const noexcept; ``` 1. Explicit type conversion between the JSON value and a compatible value which is [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible) and [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). The value is converted by calling the `json_serializer<ValueType>` `from_json()` method. The function is equivalent to executing ```cpp ValueType ret; JSONSerializer<ValueType>::from_json(*this, ret); return ret; ``` This overload is chosen if: - `ValueType` is not `basic_json`, - `json_serializer<ValueType>` has a `from_json()` method of the form `void from_json(const basic_json&, ValueType&)`, and - `json_serializer<ValueType>` does not have a `from_json()` method of the form `ValueType from_json(const basic_json&)` If the type is **not** [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible) and **not** [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible), the value is converted by calling the `json_serializer<ValueType>` `from_json()` method. The function is then equivalent to executing ```cpp return JSONSerializer<ValueTypeCV>::from_json(*this); ``` This overload is chosen if: - `ValueType` is not `basic_json` and - `json_serializer<ValueType>` has a `from_json()` method of the form `ValueType from_json(const basic_json&)` If `json_serializer<ValueType>` has both overloads of `from_json()`, the latter one is chosen. 2. Overload for `basic_json` specializations. The function is equivalent to executing ```cpp return *this; ``` 3. Explicit pointer access to the internally stored JSON value. No copies are made. ## Template parameters `ValueType` : the value type to return `BasicJsonType` : a specialization of `basic_json` `PointerType` : pointer type; must be a pointer to [`array_t`](array_t.md), [`object_t`](object_t.md), [`string_t`](string_t.md), [`boolean_t`](boolean_t.md), [`number_integer_t`](number_integer_t.md), or [`number_unsigned_t`](number_unsigned_t.md), [`number_float_t`](number_float_t.md), or [`binary_t`](binary_t.md). Other types will not compile. ## Return value 1. copy of the JSON value, converted to `ValueType` 2. a copy of `#!cpp *this`, converted into `BasicJsonType` 3. pointer to the internally stored JSON value if the requested pointer type fits to the JSON value; `#!cpp nullptr` otherwise ## Exceptions Depends on what `json_serializer<ValueType>` `from_json()` method throws ## Notes !!! danger "Undefined behavior" Writing data to the pointee (overload 3) of the result yields an undefined state. ## Examples ??? example The example below shows several conversions from JSON values to other types. There a few things to note: (1) Floating-point numbers can be converted to integers, (2) A JSON array can be converted to a standard `std::vector<short>`, (3) A JSON object can be converted to C++ associative containers such as `std::unordered_map<std::string, json>`. ```cpp --8<-- "examples/get__ValueType_const.cpp" ``` Output: ```json --8<-- "examples/get__ValueType_const.output" ``` ??? example The example below shows how pointers to internal values of a JSON value can be requested. Note that no type conversions are made and a `#cpp nullptr` is returned if the value and the requested pointer type does not match. ```cpp --8<-- "examples/get__PointerType.cpp" ``` Output: ```json --8<-- "examples/get__PointerType.output" ``` ## Version history 1. Since version 2.1.0. 2. Since version 2.1.0. Extended to work with other specializations of `basic_json` in version 3.2.0. 3. Since version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/front.md
.md
1,310
59
# <small>nlohmann::basic_json::</small>front ```cpp reference front(); const_reference front() const; ``` Returns a reference to the first element in the container. For a JSON container `#!cpp c`, the expression `#!cpp c.front()` is equivalent to `#!cpp *c.begin()`. ## Return value In case of a structured type (array or object), a reference to the first element is returned. In case of number, string, boolean, or binary values, a reference to the value is returned. ## Exception safety Strong guarantee: if an exception is thrown, there are no changes in the JSON value. ## Exceptions If the JSON value is `#!json null`, exception [`invalid_iterator.214`](../../home/exceptions.md#jsonexceptioninvalid_iterator214) is thrown. ## Complexity Constant. ## Notes !!! info "Precondition" The array or object must not be empty. Calling `front` on an empty array or object yields undefined behavior. ## Examples ??? example The following code shows an example for `front()`. ```cpp --8<-- "examples/front.cpp" ``` Output: ```json --8<-- "examples/front.output" ``` ## See also - [back](back.md) to access the last element ## Version history - Added in version 1.0.0. - Adjusted code to return reference to binary values in version 3.8.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/is_array.md
.md
657
40
# <small>nlohmann::basic_json::</small>is_array ```cpp constexpr bool is_array() const noexcept; ``` This function returns `#!cpp true` if and only if the JSON value is an array. ## Return value `#!cpp true` if type is an array, `#!cpp false` otherwise. ## Exception safety No-throw guarantee: this member function never throws exceptions. ## Complexity Constant. ## Examples ??? example The following code exemplifies `is_array()` for all JSON types. ```cpp --8<-- "examples/is_array.cpp" ``` Output: ```json --8<-- "examples/is_array.output" ``` ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/type.md
.md
1,412
55
# <small>nlohmann::basic_json::</small>type ```cpp constexpr value_t type() const noexcept; ``` Return the type of the JSON value as a value from the [`value_t`](value_t.md) enumeration. ## Return value the type of the JSON value | Value type | return value | |---------------------------|----------------------------| | `#!json null` | `value_t::null` | | boolean | `value_t::boolean` | | string | `value_t::string` | | number (integer) | `value_t::number_integer` | | number (unsigned integer) | `value_t::number_unsigned` | | number (floating-point) | `value_t::number_float` | | object | `value_t::object` | | array | `value_t::array` | | binary | `value_t::binary` | | discarded | `value_t::discarded` | ## Exception safety No-throw guarantee: this member function never throws exceptions. ## Complexity Constant. ## Examples ??? example The following code exemplifies `type()` for all JSON types. ```cpp --8<-- "examples/type.cpp" ``` Output: ```json --8<-- "examples/type.output" ``` ## Version history - Added in version 1.0.0. - Added unsigned integer type in version 2.0.0. - Added binary type in version 3.8.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/empty.md
.md
1,749
67
# <small>nlohmann::basic_json::</small>empty ```cpp bool empty() const noexcept; ``` Checks if a JSON value has no elements (i.e. whether its [`size()`](size.md) is `0`). ## Return value The return value depends on the different types and is defined as follows: | Value type | return value | |------------|----------------------------------------| | null | `#!cpp true` | | boolean | `#!cpp false` | | string | `#!cpp false` | | number | `#!cpp false` | | binary | `#!cpp false` | | object | result of function `object_t::empty()` | | array | result of function `array_t::empty()` | ## Exception safety No-throw guarantee: this function never throws exceptions. ## Complexity Constant, as long as [`array_t`](array_t.md) and [`object_t`](object_t.md) satisfy the [Container](https://en.cppreference.com/w/cpp/named_req/Container) concept; that is, their `empty()` functions have constant complexity. ## Possible implementation ```cpp bool empty() const noexcept { return size() == 0; } ``` ## Notes This function does not return whether a string stored as JSON value is empty -- it returns whether the JSON container itself is empty which is `#!cpp false` in the case of a string. ## Examples ??? example The following code uses `empty()` to check if a JSON object contains any elements. ```cpp --8<-- "examples/empty.cpp" ``` Output: ```json --8<-- "examples/empty.output" ``` ## Version history - Added in version 1.0.0. - Extended to return `#!cpp false` for binary types in version 3.8.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/get_allocator.md
.md
502
32
# <small>nlohmann::basic_json::</small>get_allocator ```cpp static allocator_type get_allocator(); ``` Returns the allocator associated with the container. ## Return value associated allocator ## Examples ??? example The example shows how `get_allocator()` is used to created `json` values. ```cpp --8<-- "examples/get_allocator.cpp" ``` Output: ```json --8<-- "examples/get_allocator.output" ``` ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/std_swap.md
.md
782
52
# std::swap<basic_json\> ```cpp namespace std { void swap(nlohmann::basic_json& j1, nlohmann::basic_json& j2); } ``` Exchanges the values of two JSON objects. ## Parameters `j1` (in, out) : value to be replaced by `j2` `j2` (in, out) : value to be replaced by `j1` ## Possible implementation ```cpp void swap(nlohmann::basic_json& j1, nlohmann::basic_json& j2) { j1.swap(j2); } ``` ## Examples ??? example The following code shows how two values are swapped with `std::swap`. ```cpp --8<-- "examples/std_swap.cpp" ``` Output: ```json --8<-- "examples/std_swap.output" ``` ## See also - [swap](swap.md) ## Version history - Added in version 1.0.0. - Extended for arbitrary basic_json types in version 3.10.5.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/error_handler_t.md
.md
950
43
# <small>nlohmann::basic_json::</small>error_handler_t ```cpp enum class error_handler_t { strict, replace, ignore }; ``` This enumeration is used in the [`dump`](dump.md) function to choose how to treat decoding errors while serializing a `basic_json` value. Three values are differentiated: strict : throw a `type_error` exception in case of invalid UTF-8 replace : replace invalid UTF-8 sequences with U+FFFD (� REPLACEMENT CHARACTER) ignore : ignore invalid UTF-8 sequences; all bytes are copied to the output unchanged ## Examples ??? example The example below shows how the different values of the `error_handler_t` influence the behavior of [`dump`](dump.md) when reading serializing an invalid UTF-8 sequence. ```cpp --8<-- "examples/error_handler_t.cpp" ``` Output: ```json --8<-- "examples/error_handler_t.output" ``` ## Version history - Added in version 3.4.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/operator_eq.md
.md
4,589
169
# <small>nlohmann::basic_json::</small>operator== ```cpp // until C++20 bool operator==(const_reference lhs, const_reference rhs) noexcept; // (1) template<typename ScalarType> bool operator==(const_reference lhs, const ScalarType rhs) noexcept; // (2) template<typename ScalarType> bool operator==(ScalarType lhs, const const_reference rhs) noexcept; // (2) // since C++20 class basic_json { bool operator==(const_reference rhs) const noexcept; // (1) template<typename ScalarType> bool operator==(ScalarType rhs) const noexcept; // (2) }; ``` 1. Compares two JSON values for equality according to the following rules: - Two JSON values are equal if (1) neither value is discarded, or (2) they are of the same type and their stored values are the same according to their respective `operator==`. - Integer and floating-point numbers are automatically converted before comparison. 2. Compares a JSON value and a scalar or a scalar and a JSON value for equality by converting the scalar to a JSON value and comparing both JSON values according to 1. ## Template parameters `ScalarType` : a scalar type according to `std::is_scalar<ScalarType>::value` ## Parameters `lhs` (in) : first value to consider `rhs` (in) : second value to consider ## Return value whether the values `lhs`/`*this` and `rhs` are equal ## Exception safety No-throw guarantee: this function never throws exceptions. ## Complexity Linear. ## Notes !!! note "Comparing special values" - `NaN` values are unordered within the domain of numbers. The following comparisons all yield `#!cpp false`: 1. Comparing a `NaN` with itself. 2. Comparing a `NaN` with another `NaN`. 3. Comparing a `NaN` and any other number. - JSON `#!cpp null` values are all equal. - Discarded values never compare equal to themselves. !!! note "Comparing floating-point numbers" Floating-point numbers inside JSON values numbers are compared with `json::number_float_t::operator==` which is `double::operator==` by default. To compare floating-point while respecting an epsilon, an alternative [comparison function](https://github.com/mariokonrad/marnav/blob/master/include/marnav/math/floatingpoint.hpp#L34-#L39) could be used, for instance ```cpp template<typename T, typename = typename std::enable_if<std::is_floating_point<T>::value, T>::type> inline bool is_same(T a, T b, T epsilon = std::numeric_limits<T>::epsilon()) noexcept { return std::abs(a - b) <= epsilon; } ``` Or you can self-defined operator equal function like this: ```cpp bool my_equal(const_reference lhs, const_reference rhs) { const auto lhs_type lhs.type(); const auto rhs_type rhs.type(); if (lhs_type == rhs_type) { switch(lhs_type) // self_defined case case value_t::number_float: return std::abs(lhs - rhs) <= std::numeric_limits<float>::epsilon(); // other cases remain the same with the original ... } ... } ``` !!! note "Comparing different `basic_json` specializations" Comparing different `basic_json` specializations can have surprising effects. For instance, the result of comparing the JSON objects ```json { "version": 1, "type": "integer" } ``` and ```json { "type": "integer", "version": 1 } ``` depends on whether [`nlohmann::json`](../json.md) or [`nlohmann::ordered_json`](../ordered_json.md) is used: ```cpp --8<-- "examples/operator__equal__specializations.cpp" ``` Output: ```json --8<-- "examples/operator__equal__specializations.output" ``` ## Examples ??? example The example demonstrates comparing several JSON types. ```cpp --8<-- "examples/operator__equal.cpp" ``` Output: ```json --8<-- "examples/operator__equal.output" ``` ??? example The example demonstrates comparing several JSON types against the null pointer (JSON `#!json null`). ```cpp --8<-- "examples/operator__equal__nullptr_t.cpp" ``` Output: ```json --8<-- "examples/operator__equal__nullptr_t.output" ``` ## Version history 1. Added in version 1.0.0. Added C++20 member functions in version 3.11.0. 2. Added in version 1.0.0. Added C++20 member functions in version 3.11.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/json_serializer.md
.md
866
42
# <small>nlohmann::basic_json::</small>json_serializer ```cpp template<typename T, typename SFINAE> using json_serializer = JSONSerializer<T, SFINAE>; ``` ## Template parameters `T` : type to convert; will be used in the `to_json`/`from_json` functions `SFINAE` : type to add compile type checks via SFINAE; usually `#!cpp void` ## Notes #### Default type The default values for `json_serializer` is [`adl_serializer`](../adl_serializer). ## Examples ??? example The example below shows how a conversion of a non-default-constructible type is implemented via a specialization of the `adl_serializer`. ```cpp --8<-- "examples/from_json__non_default_constructible.cpp" ``` Output: ```json --8<-- "examples/from_json__non_default_constructible.output" ``` ## Version history - Since version 2.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/value_t.md
.md
2,632
82
# <small>nlohmann::basic_json::</small>value_t ```cpp enum class value_t : std::uint8_t { null, object, array, string, boolean, number_integer, number_unsigned, number_float, binary, discarded }; ``` This enumeration collects the different JSON types. It is internally used to distinguish the stored values, and the functions [`is_null`](is_null.md), [`is_object`](is_object.md), [`is_array`](is_array.md), [`is_string`](is_string.md), [`is_boolean`](is_boolean.md), [`is_number`](is_number.md) (with [`is_number_integer`](is_number_integer.md), [`is_number_unsigned`](is_number_unsigned.md), and [`is_number_float`](is_number_float.md)), [`is_discarded`](is_discarded.md), [`is_binary`](is_binary.md), [`is_primitive`](is_primitive.md), and [`is_structured`](is_structured.md) rely on it. ## Notes !!! note "Ordering" The order of types is as follows: 1. `null` 2. `boolean` 3. `number_integer`, `number_unsigned`, `number_float` 4. `object` 5. `array` 6. `string` 7. `binary` `discarded` is unordered. !!! note "Types of numbers" There are three enumerators for numbers (`number_integer`, `number_unsigned`, and `number_float`) to distinguish between different types of numbers: - [`number_unsigned_t`](number_unsigned_t.md) for unsigned integers - [`number_integer_t`](number_integer_t.md) for signed integers - [`number_float_t`](number_float_t.md) for floating-point numbers or to approximate integers which do not fit into the limits of their respective type !!! warning "Comparison operators" `operator<` and `operator<=>` (since C++20) are overloaded and compare according to the ordering described above. Until C++20 all other relational and equality operators yield results according to the integer value of each enumerator. Since C++20 some compilers consider the _rewritten candidates_ generated from `operator<=>` during overload resolution, while others do not. For predictable and portable behavior use: - `operator<` or `operator<=>` when wanting to compare according to the order described above - `operator==` or `operator!=` when wanting to compare according to each enumerators integer value ## Examples ??? example The following code how `type()` queries the `value_t` for all JSON types. ```cpp --8<-- "examples/type.cpp" ``` Output: ```json --8<-- "examples/type.output" ``` ## Version history - Added in version 1.0.0. - Added unsigned integer type in version 2.0.0. - Added binary type in version 3.8.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/patch.md
.md
2,545
74
# <small>nlohmann::basic_json::</small>patch ```cpp basic_json patch(const basic_json& json_patch) const; ``` [JSON Patch](http://jsonpatch.com) defines a JSON document structure for expressing a sequence of operations to apply to a JSON document. With this function, a JSON Patch is applied to the current JSON value by executing all operations from the patch. ## Parameters `json_patch` (in) : JSON patch document ## Return value patched document ## Exception safety Strong guarantee: if an exception is thrown, there are no changes in the JSON value. ## Exceptions - Throws [`parse_error.104`](../../home/exceptions.md#jsonexceptionparse_error104) if the JSON patch does not consist of an array of objects. - Throws [`parse_error.105`](../../home/exceptions.md#jsonexceptionparse_error105) if the JSON patch is malformed (e.g., mandatory attributes are missing); example: `"operation add must have member path"`. - Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) if an array index is out of range. - Throws [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if a JSON pointer inside the patch could not be resolved successfully in the current JSON value; example: `"key baz not found"`. - Throws [`out_of_range.405`](../../home/exceptions.md#jsonexceptionout_of_range405) if JSON pointer has no parent ("add", "remove", "move") - Throws [`out_of_range.501`](../../home/exceptions.md#jsonexceptionother_error501) if "test" operation was unsuccessful. ## Complexity Linear in the size of the JSON value and the length of the JSON patch. As usually only a fraction of the JSON value is affected by the patch, the complexity can usually be neglected. ## Notes The application of a patch is atomic: Either all operations succeed and the patched document is returned or an exception is thrown. In any case, the original value is not changed: the patch is applied to a copy of the value. ## Examples ??? example The following code shows how a JSON patch is applied to a value. ```cpp --8<-- "examples/patch.cpp" ``` Output: ```json --8<-- "examples/patch.output" ``` ## See also - [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) - [RFC 6901 (JSON Pointer)](https://tools.ietf.org/html/rfc6901) - [patch_inplace](patch_inplace.md) applies a JSON Patch without creating a copy of the document - [merge_patch](merge_patch.md) applies a JSON Merge Patch ## Version history - Added in version 2.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/update.md
.md
3,853
143
# <small>nlohmann::basic_json::</small>update ```cpp // (1) void update(const_reference j, bool merge_objects = false); // (2) void update(const_iterator first, const_iterator last, bool merge_objects = false); ``` 1. Inserts all values from JSON object `j`. 2. Inserts all values from range `[first, last)` When `merge_objects` is `#!c false` (default), existing keys are overwritten. When `merge_objects` is `#!c true`, recursively merges objects with common keys. The function is motivated by Python's [dict.update](https://docs.python.org/3.6/library/stdtypes.html#dict.update) function. ## Parameters `j` (in) : JSON object to read values from `merge_objects` (in) : when `#!c true`, existing keys are not overwritten, but contents of objects are merged recursively (default: `#!c false`) `first` (in) : begin of the range of elements to insert `last` (in) : end of the range of elements to insert ## Exceptions 1. The function can throw the following exceptions: - Throws [`type_error.312`](../../home/exceptions.md#jsonexceptiontype_error312) if called on JSON values other than objects; example: `"cannot use update() with string"` 2. The function can throw the following exceptions: - Throws [`type_error.312`](../../home/exceptions.md#jsonexceptiontype_error312) if called on JSON values other than objects; example: `"cannot use update() with string"` - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` - Throws [`invalid_iterator.210`](../../home/exceptions.md#jsonexceptioninvalid_iterator210) if `first` and `last` do not belong to the same JSON value; example: `"iterators do not fit"` ## Complexity 1. O(N*log(size() + N)), where N is the number of elements to insert. 2. O(N*log(size() + N)), where N is the number of elements to insert. ## Examples ??? example The example shows how `update()` is used. ```cpp --8<-- "examples/update.cpp" ``` Output: ```json --8<-- "examples/update.output" ``` ??? example The example shows how `update()` is used. ```cpp --8<-- "examples/update__range.cpp" ``` Output: ```json --8<-- "examples/update__range.output" ``` ??? example One common use case for this function is the handling of user settings. Assume your application can be configured in some aspects: ```json { "color": "red", "active": true, "name": {"de": "Maus", "en": "mouse"} } ``` The user may override the default settings selectively: ```json { "color": "blue", "name": {"es": "ratón"}, } ``` Then `update` manages the merging of default settings and user settings: ```cpp auto user_settings = json::parse("config.json"); auto effective_settings = get_default_settings(); effective_settings.update(user_settings); ``` Now `effective_settings` contains the default settings, but those keys set by the user are overwritten: ```json { "color": "blue", "active": true, "name": {"es": "ratón"} } ``` Note existing keys were just overwritten. To merge objects, `merge_objects` setting should be set to `#!c true`: ```cpp auto user_settings = json::parse("config.json"); auto effective_settings = get_default_settings(); effective_settings.update(user_settings, true); ``` ```json { "color": "blue", "active": true, "name": {"de": "Maus", "en": "mouse", "es": "ratón"} } ``` ## Version history - Added in version 3.0.0. - Added `merge_objects` parameter in 3.10.4.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/from_cbor.md
.md
4,172
118
# <small>nlohmann::basic_json::</small>from_cbor ```cpp // (1) template<typename InputType> static basic_json from_cbor(InputType&& i, const bool strict = true, const bool allow_exceptions = true, const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error); // (2) template<typename IteratorType> static basic_json from_cbor(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true, const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error); ``` Deserializes a given input to a JSON value using the CBOR (Concise Binary Object Representation) serialization format. 1. Reads from a compatible input. 2. Reads from an iterator range. The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/cbor.md). ## Template parameters `InputType` : A compatible input, for instance: - an `std::istream` object - a `FILE` pointer - a C-style array of characters - a pointer to a null-terminated string of single byte characters - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. `IteratorType` : a compatible iterator type ## Parameters `i` (in) : an input in CBOR format convertible to an input adapter `first` (in) : iterator to start of the input `last` (in) : iterator to end of the input `strict` (in) : whether to expect the input to be consumed until EOF (`#!cpp true` by default) `allow_exceptions` (in) : whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) `tag_handler` (in) : how to treat CBOR tags (optional, `error` by default); see [`cbor_tag_handler_t`](cbor_tag_handler_t.md) for more information ## Return value deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be `value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). ## Exception safety Strong guarantee: if an exception is thrown, there are no changes in the JSON value. ## Exceptions - Throws [parse_error.110](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or the end of file was not reached when `strict` was set to true - Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if unsupported features from CBOR were used in the given input or if the input is not valid CBOR - Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string was expected as map key, but not found ## Complexity Linear in the size of the input. ## Examples ??? example The example shows the deserialization of a byte vector in CBOR format to a JSON value. ```cpp --8<-- "examples/from_cbor.cpp" ``` Output: ```json --8<-- "examples/from_cbor.output" ``` ## Version history - Added in version 2.0.9. - Parameter `start_index` since version 2.1.1. - Changed to consume input adapters, removed `start_index` parameter, and added `strict` parameter in version 3.0.0. - Added `allow_exceptions` parameter in version 3.2.0. - Added `tag_handler` parameter in version 3.9.0. !!! warning "Deprecation" - Overload (2) replaces calls to `from_cbor` with a pointer and a length as first two parameters, which has been deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like `#!cpp from_cbor(ptr, len, ...);` with `#!cpp from_cbor(ptr, ptr+len, ...);`. - Overload (2) replaces calls to `from_cbor` with a pair of iterators as their first parameter, which has been deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like `#!cpp from_cbor({ptr, ptr+len}, ...);` with `#!cpp from_cbor(ptr, ptr+len, ...);`. You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated function.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/index.md
.md
16,874
324
# <small>nlohmann::</small>basic_json <small>Defined in header `<nlohmann/json.hpp>`</small> ```cpp template< template<typename U, typename V, typename... Args> class ObjectType = std::map, template<typename U, typename... Args> class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template<typename U> class AllocatorType = std::allocator, template<typename T, typename SFINAE = void> class JSONSerializer = adl_serializer, class BinaryType = std::vector<std::uint8_t, class CustomBaseClass = void> > class basic_json; ``` ## Template parameters | Template parameter | Description | Derived type | |----------------------|---------------------------------------------------------------------------|---------------------------------------------| | `ObjectType` | type for JSON objects | [`object_t`](object_t.md) | | `ArrayType` | type for JSON arrays | [`array_t`](array_t.md) | | `StringType` | type for JSON strings and object keys | [`string_t`](string_t.md) | | `BooleanType` | type for JSON booleans | [`boolean_t`](boolean_t.md) | | `NumberIntegerType` | type for JSON integer numbers | [`number_integer_t`](number_integer_t.md) | | `NumberUnsignedType` | type for JSON unsigned integer numbers | [`number_unsigned_t`](number_unsigned_t.md) | | `NumberFloatType` | type for JSON floating-point numbers | [`number_float_t`](number_float_t.md) | | `AllocatorType` | type of the allocator to use | | | `JSONSerializer` | the serializer to resolve internal calls to `to_json()` and `from_json()` | [`json_serializer`](json_serializer.md) | | `BinaryType` | type for binary arrays | [`binary_t`](binary_t.md) | | `CustomBaseClass` | extension point for user code | [`json_base_class_t`](json_base_class_t.md) | ## Specializations - [**json**](../json.md) - default specialization - [**ordered_json**](../ordered_json.md) - specialization that maintains the insertion order of object keys ## Iterator invalidation Todo ## Requirements The class satisfies the following concept requirements: ### Basic - [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible): JSON values can be default constructed. The result will be a JSON null value. - [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible): A JSON value can be constructed from an rvalue argument. - [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible): A JSON value can be copy-constructed from an lvalue expression. - [MoveAssignable](https://en.cppreference.com/w/cpp/named_req/MoveAssignable): A JSON value can be assigned from an rvalue argument. - [CopyAssignable](https://en.cppreference.com/w/cpp/named_req/CopyAssignable): A JSON value can be copy-assigned from an lvalue expression. - [Destructible](https://en.cppreference.com/w/cpp/named_req/Destructible): JSON values can be destructed. ### Layout - [StandardLayoutType](https://en.cppreference.com/w/cpp/named_req/StandardLayoutType): JSON values have [standard layout](https://en.cppreference.com/w/cpp/language/data_members#Standard_layout): All non-static data members are private and standard layout types, the class has no virtual functions or (virtual) base classes. ### Library-wide - [EqualityComparable](https://en.cppreference.com/w/cpp/named_req/EqualityComparable): JSON values can be compared with `==`, see [`operator==`](operator_eq.md). - [LessThanComparable](https://en.cppreference.com/w/cpp/named_req/LessThanComparable): JSON values can be compared with `<`, see [`operator<`](operator_le). - [Swappable](https://en.cppreference.com/w/cpp/named_req/Swappable): Any JSON lvalue or rvalue of can be swapped with any lvalue or rvalue of other compatible types, using unqualified function `swap`. - [NullablePointer](https://en.cppreference.com/w/cpp/named_req/NullablePointer): JSON values can be compared against `std::nullptr_t` objects which are used to model the `null` value. ### Container - [Container](https://en.cppreference.com/w/cpp/named_req/Container): JSON values can be used like STL containers and provide iterator access. - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer): JSON values can be used like STL containers and provide reverse iterator access. ## Member types - [**adl_serializer**](../adl_serializer) - the default serializer - [**value_t**](value_t.md) - the JSON type enumeration - [**json_pointer**](../json_pointer/index.md) - JSON Pointer implementation - [**json_serializer**](json_serializer.md) - type of the serializer to for conversions from/to JSON - [**error_handler_t**](error_handler_t.md) - type to choose behavior on decoding errors - [**cbor_tag_handler_t**](cbor_tag_handler_t.md) - type to choose how to handle CBOR tags - **initializer_list_t** - type for initializer lists of `basic_json` values - [**input_format_t**](input_format_t.md) - type to choose the format to parse - [**json_sax_t**](../json_sax/index.md) - type for SAX events ### Exceptions - [**exception**](exception.md) - general exception of the `basic_json` class - [**parse_error**](parse_error.md) - exception indicating a parse error - [**invalid_iterator**](invalid_iterator.md) - exception indicating errors with iterators - [**type_error**](type_error.md) - exception indicating executing a member function with a wrong type - [**out_of_range**](out_of_range.md) - exception indicating access out of the defined range - [**other_error**](other_error.md) - exception indicating other library errors ### Container types | Type | Definition | |--------------------------|-----------------------------------------------------------------------------------------------------------| | `value_type` | `#!cpp basic_json` | | `reference` | `#!cpp value_type&` | | `const_reference` | `#!cpp const value_type&` | | `difference_type` | `#!cpp std::ptrdiff_t` | | `size_type` | `#!cpp std::size_t` | | `allocator_type` | `#!cpp AllocatorType<basic_json>` | | `pointer` | `#!cpp std::allocator_traits<allocator_type>::pointer` | | `const_pointer` | `#!cpp std::allocator_traits<allocator_type>::const_pointer` | | `iterator` | [LegacyBidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator) | | `const_iterator` | constant [LegacyBidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator) | | `reverse_iterator` | reverse iterator, derived from `iterator` | | `const_reverse_iterator` | reverse iterator, derived from `const_iterator` | | `iteration_proxy` | helper type for [`items`](items.md) function | ### JSON value data types - [**array_t**](array_t.md) - type for arrays - [**binary_t**](binary_t.md) - type for binary arrays - [**boolean_t**](boolean_t.md) - type for booleans - [**default_object_comparator_t**](default_object_comparator_t.md) - default comparator for objects - [**number_float_t**](number_float_t.md) - type for numbers (floating-point) - [**number_integer_t**](number_integer_t.md) - type for numbers (integer) - [**number_unsigned_t**](number_unsigned_t.md) - type for numbers (unsigned) - [**object_comparator_t**](object_comparator_t.md) - comparator for objects - [**object_t**](object_t.md) - type for objects - [**string_t**](string_t.md) - type for strings ### Parser callback - [**parse_event_t**](parse_event_t.md) - parser event types - [**parser_callback_t**](parser_callback_t.md) - per-element parser callback type ## Member functions - [(constructor)](basic_json.md) - [(destructor)](~basic_json.md) - [**operator=**](operator=.md) - copy assignment - [**array**](array_t.md) (_static_) - explicitly create an array - [**binary**](binary.md) (_static_) - explicitly create a binary array - [**object**](object_t.md) (_static_) - explicitly create an object ### Object inspection Functions to inspect the type of a JSON value. - [**type**](type.md) - return the type of the JSON value - [**operator value_t**](operator_value_t.md) - return the type of the JSON value - [**type_name**](type_name.md) - return the type as string - [**is_primitive**](is_primitive.md) - return whether type is primitive - [**is_structured**](is_structured.md) - return whether type is structured - [**is_null**](is_null.md) - return whether value is null - [**is_boolean**](is_boolean.md) - return whether value is a boolean - [**is_number**](is_number.md) - return whether value is a number - [**is_number_integer**](is_number_integer.md) - return whether value is an integer number - [**is_number_unsigned**](is_number_unsigned.md) - return whether value is an unsigned integer number - [**is_number_float**](is_number_float.md) - return whether value is a floating-point number - [**is_object**](is_object.md) - return whether value is an object - [**is_array**](is_array.md) - return whether value is an array - [**is_string**](is_string.md) - return whether value is a string - [**is_binary**](is_binary.md) - return whether value is a binary array - [**is_discarded**](is_discarded.md) - return whether value is discarded ### Value access Direct access to the stored value of a JSON value. - [**get**](get.md) - get a value - [**get_to**](get_to.md) - get a value and write it to a destination - [**get_ptr**](get_ptr.md) - get a pointer value - [**get_ref**](get_ref.md) - get a reference value - [**operator ValueType**](operator_ValueType.md) - get a value - [**get_binary**](get_binary.md) - get a binary value ### Element access Access to the JSON value - [**at**](at.md) - access specified element with bounds checking - [**operator[]**](operator[].md) - access specified element - [**value**](value.md) - access specified object element with default value - [**front**](front.md) - access the first element - [**back**](back.md) - access the last element ### Lookup - [**find**](find.md) - find an element in a JSON object - [**count**](count.md) - returns the number of occurrences of a key in a JSON object - [**contains**](contains.md) - check the existence of an element in a JSON object ### Iterators - [**begin**](begin.md) - returns an iterator to the first element - [**cbegin**](cbegin.md) - returns a const iterator to the first element - [**end**](end.md) - returns an iterator to one past the last element - [**cend**](cend.md) - returns a const iterator to one past the last element - [**rbegin**](rbegin.md) - returns an iterator to the reverse-beginning - [**rend**](rend.md) - returns an iterator to the reverse-end - [**crbegin**](crbegin.md) - returns a const iterator to the reverse-beginning - [**crend**](crend.md) - returns a const iterator to the reverse-end - [**items**](items.md) - wrapper to access iterator member functions in range-based for ### Capacity - [**empty**](empty.md) - checks whether the container is empty - [**size**](size.md) - returns the number of elements - [**max_size**](max_size.md) - returns the maximum possible number of elements ### Modifiers - [**clear**](clear.md) - clears the contents - [**push_back**](push_back.md) - add a value to an array/object - [**operator+=**](operator+=.md) - add a value to an array/object - [**emplace_back**](emplace_back.md) - add a value to an array - [**emplace**](emplace.md) - add a value to an object if key does not exist - [**erase**](erase.md) - remove elements - [**insert**](insert.md) - inserts elements - [**update**](update.md) - updates a JSON object from another object, overwriting existing keys - [**swap**](swap.md) - exchanges the values ### Lexicographical comparison operators - [**operator==**](operator_eq.md) - comparison: equal - [**operator!=**](operator_ne.md) - comparison: not equal - [**operator<**](operator_lt.md) - comparison: less than - [**operator>**](operator_gt.md) - comparison: greater than - [**operator<=**](operator_le.md) - comparison: less than or equal - [**operator>=**](operator_ge.md) - comparison: greater than or equal - [**operator<=>**](operator_spaceship.md) - comparison: 3-way ### Serialization / Dumping - [**dump**](dump.md) - serialization ### Deserialization / Parsing - [**parse**](parse.md) (_static_) - deserialize from a compatible input - [**accept**](accept.md) (_static_) - check if the input is valid JSON - [**sax_parse**](sax_parse.md) (_static_) - generate SAX events ### JSON Pointer functions - [**flatten**](flatten.md) - return flattened JSON value - [**unflatten**](unflatten.md) - unflatten a previously flattened JSON value ### JSON Patch functions - [**patch**](patch.md) - applies a JSON patch - [**patch_inplace**](patch_inplace.md) - applies a JSON patch in place - [**diff**](diff.md) (_static_) - creates a diff as a JSON patch ### JSON Merge Patch functions - [**merge_patch**](merge_patch.md) - applies a JSON Merge Patch ## Static functions - [**meta**](meta.md) - returns version information on the library - [**get_allocator**](get_allocator.md) - returns the allocator associated with the container ### Binary formats - [**from_bjdata**](from_bjdata.md) (_static_) - create a JSON value from an input in BJData format - [**from_bson**](from_bson.md) (_static_) - create a JSON value from an input in BSON format - [**from_cbor**](from_cbor.md) (_static_) - create a JSON value from an input in CBOR format - [**from_msgpack**](from_msgpack.md) (_static_) - create a JSON value from an input in MessagePack format - [**from_ubjson**](from_ubjson.md) (_static_) - create a JSON value from an input in UBJSON format - [**to_bjdata**](to_bjdata.md) (_static_) - create a BJData serialization of a given JSON value - [**to_bson**](to_bson.md) (_static_) - create a BSON serialization of a given JSON value - [**to_cbor**](to_cbor.md) (_static_) - create a CBOR serialization of a given JSON value - [**to_msgpack**](to_msgpack.md) (_static_) - create a MessagePack serialization of a given JSON value - [**to_ubjson**](to_ubjson.md) (_static_) - create a UBJSON serialization of a given JSON value ## Non-member functions - [**operator<<(std::ostream&)**](../operator_ltlt.md) - serialize to stream - [**operator>>(std::istream&)**](../operator_gtgt.md) - deserialize from stream - [**to_string**](to_string.md) - user-defined `to_string` function for JSON values ## Literals - [**operator""_json**](../operator_literal_json.md) - user-defined string literal for JSON values ## Helper classes - [**std::hash&lt;basic_json&gt;**](std_hash.md) - return a hash value for a JSON object - [**std::swap&lt;basic_json&gt;**](std_swap.md) - exchanges the values of two JSON objects ## Examples ??? example The example shows how the library is used. ```cpp --8<-- "examples/README.cpp" ``` Output: ```json --8<-- "examples/README.output" ``` ## See also - [RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format](https://tools.ietf.org/html/rfc8259) ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/object_comparator_t.md
.md
816
33
# <small>nlohmann::basic_json::</small>object_comparator_t ```cpp using object_comparator_t = typename object_t::key_compare; // or using object_comparator_t = default_object_comparator_t; ``` The comparator used by [`object_t`](object_t.md). Defined as `#!cpp typename object_t::key_compare` if available, and [`default_object_comparator_t`](default_object_comparator_t.md) otherwise. ## Examples ??? example The example below demonstrates the used object comparator. ```cpp --8<-- "examples/object_comparator_t.cpp" ``` Output: ```json --8<-- "examples/object_comparator_t.output" ``` ## Version history - Added in version 3.0.0. - Changed to be conditionally defined as `#!cpp typename object_t::key_compare` or `default_object_comparator_t` in version 3.11.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/at.md
.md
7,555
227
# <small>nlohmann::basic_json::</small>at ```cpp // (1) reference at(size_type idx); const_reference at(size_type idx) const; // (2) reference at(const typename object_t::key_type& key); const_reference at(const typename object_t::key_type& key) const; // (3) template<typename KeyType> reference at(KeyType&& key); template<typename KeyType> const_reference at(KeyType&& key) const; // (4) reference at(const json_pointer& ptr); const_reference at(const json_pointer& ptr) const; ``` 1. Returns a reference to the array element at specified location `idx`, with bounds checking. 2. Returns a reference to the object element with specified key `key`, with bounds checking. 3. See 2. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and `#!cpp typename object_comparator_t::is_transparent` denotes a type. 4. Returns a reference to the element at specified JSON pointer `ptr`, with bounds checking. ## Template parameters `KeyType` : A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). This can also be a string view (C++17). ## Parameters `idx` (in) : index of the element to access `key` (in) : object key of the elements to access `ptr` (in) : JSON pointer to the desired element ## Return value 1. reference to the element at index `idx` 2. reference to the element at key `key` 3. reference to the element at key `key` 4. reference to the element pointed to by `ptr` ## Exception safety Strong exception safety: if an exception occurs, the original value stays intact. ## Exceptions 1. The function can throw the following exceptions: - Throws [`type_error.304`](../../home/exceptions.md#jsonexceptiontype_error304) if the JSON value is not an array; in this case, calling `at` with an index makes no sense. See example below. - Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) if the index `idx` is out of range of the array; that is, `idx >= size()`. See example below. 2. The function can throw the following exceptions: - Throws [`type_error.304`](../../home/exceptions.md#jsonexceptiontype_error304) if the JSON value is not an object; in this case, calling `at` with a key makes no sense. See example below. - Throws [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if the key `key` is not stored in the object; that is, `find(key) == end()`. See example below. 3. See 2. 4. The function can throw the following exceptions: - Throws [`parse_error.106`](../../home/exceptions.md#jsonexceptionparse_error106) if an array index in the passed JSON pointer `ptr` begins with '0'. See example below. - Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) if an array index in the passed JSON pointer `ptr` is not a number. See example below. - Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) if an array index in the passed JSON pointer `ptr` is out of range. See example below. - Throws [`out_of_range.402`](../../home/exceptions.md#jsonexceptionout_of_range402) if the array index '-' is used in the passed JSON pointer `ptr`. As `at` provides checked access (and no elements are implicitly inserted), the index '-' is always invalid. See example below. - Throws [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if the JSON pointer describes a key of an object which cannot be found. See example below. - Throws [`out_of_range.404`](../../home/exceptions.md#jsonexceptionout_of_range404) if the JSON pointer `ptr` can not be resolved. See example below. ## Complexity 1. Constant. 2. Logarithmic in the size of the container. 3. Logarithmic in the size of the container. 4. Logarithmic in the size of the container. ## Examples ??? example "Example: (1) access specified array element with bounds checking" The example below shows how array elements can be read and written using `at()`. It also demonstrates the different exceptions that can be thrown. ```cpp --8<-- "examples/at__size_type.cpp" ``` Output: ```json --8<-- "examples/at__size_type.output" ``` ??? example "Example: (1) access specified array element with bounds checking" The example below shows how array elements can be read using `at()`. It also demonstrates the different exceptions that can be thrown. ```cpp --8<-- "examples/at__size_type_const.cpp" ``` Output: ```json --8<-- "examples/at__size_type_const.output" ``` ??? example "Example: (2) access specified object element with bounds checking" The example below shows how object elements can be read and written using `at()`. It also demonstrates the different exceptions that can be thrown. ```cpp --8<-- "examples/at__object_t_key_type.cpp" ``` Output: ```json --8<-- "examples/at__object_t_key_type.output" ``` ??? example "Example: (2) access specified object element with bounds checking" The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions that can be thrown. ```cpp --8<-- "examples/at__object_t_key_type_const.cpp" ``` Output: ```json --8<-- "examples/at__object_t_key_type_const.output" ``` ??? example "Example: (3) access specified object element using string_view with bounds checking" The example below shows how object elements can be read and written using `at()`. It also demonstrates the different exceptions that can be thrown. ```cpp --8<-- "examples/at__keytype.c++17.cpp" ``` Output: ```json --8<-- "examples/at__keytype.c++17.output" ``` ??? example "Example: (3) access specified object element using string_view with bounds checking" The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions that can be thrown. ```cpp --8<-- "examples/at__keytype_const.c++17.cpp" ``` Output: ```json --8<-- "examples/at__keytype_const.c++17.output" ``` ??? example "Example: (4) access specified element via JSON Pointer" The example below shows how object elements can be read and written using `at()`. It also demonstrates the different exceptions that can be thrown. ```cpp --8<-- "examples/at__json_pointer.cpp" ``` Output: ```json --8<-- "examples/at__json_pointer.output" ``` ??? example "Example: (4) access specified element via JSON Pointer" The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions that can be thrown. ```cpp --8<-- "examples/at__json_pointer_const.cpp" ``` Output: ```json --8<-- "examples/at__json_pointer_const.output" ``` ## See also - documentation on [checked access](../../features/element_access/checked_access.md) - see [`operator[]`](operator%5B%5D.md) for unchecked access by reference - see [`value`](value.md) for access with default value ## Version history 1. Added in version 1.0.0. 2. Added in version 1.0.0. 3. Added in version 3.11.0. 4. Added in version 2.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/std_hash.md
.md
777
35
# <small>std::</small>hash<nlohmann::basic_json\> ```cpp namespace std { struct hash<nlohmann::basic_json>; } ``` Return a hash value for a JSON object. The hash function tries to rely on `std::hash` where possible. Furthermore, the type of the JSON value is taken into account to have different hash values for `#!json null`, `#!cpp 0`, `#!cpp 0U`, and `#!cpp false`, etc. ## Examples ??? example The example shows how to calculate hash values for different JSON values. ```cpp --8<-- "examples/std_hash.cpp" ``` Output: ```json --8<-- "examples/std_hash.output" ``` Note the output is platform-dependent. ## Version history - Added in version 1.0.0. - Extended for arbitrary basic_json types in version 3.10.5.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/to_bson.md
.md
1,301
60
# <small>nlohmann::basic_json::</small>to_bson ```cpp // (1) static std::vector<std::uint8_t> to_bson(const basic_json& j); // (2) static void to_bson(const basic_json& j, detail::output_adapter<std::uint8_t> o); static void to_bson(const basic_json& j, detail::output_adapter<char> o); ``` BSON (Binary JSON) is a binary format in which zero or more ordered key/value pairs are stored as a single entity (a so-called document). 1. Returns a byte vector containing the BSON serialization. 2. Writes the BSON serialization to an output adapter. The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/bson.md). ## Parameters `j` (in) : JSON value to serialize `o` (in) : output adapter to write serialization to ## Return value 1. BSON serialization as byte vector 2. (none) ## Exception safety Strong guarantee: if an exception is thrown, there are no changes in the JSON value. ## Complexity Linear in the size of the JSON value `j`. ## Examples ??? example The example shows the serialization of a JSON value to a byte vector in BSON format. ```cpp --8<-- "examples/to_bson.cpp" ``` Output: ```json --8<-- "examples/to_bson.output" ``` ## Version history - Added in version 3.4.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/accept.md
.md
3,174
114
# <small>nlohmann::basic_json::</small>accept ```cpp // (1) template<typename InputType> static bool accept(InputType&& i, const bool ignore_comments = false); // (2) template<typename IteratorType> static bool accept(IteratorType first, IteratorType last, const bool ignore_comments = false); ``` Checks whether the input is valid JSON. 1. Reads from a compatible input. 2. Reads from a pair of character iterators The value_type of the iterator must be an integral type with size of 1, 2 or 4 bytes, which will be interpreted respectively as UTF-8, UTF-16 and UTF-32. Unlike the [`parse`](parse.md) function, this function neither throws an exception in case of invalid JSON input (i.e., a parse error) nor creates diagnostic information. ## Template parameters `InputType` : A compatible input, for instance: - an `std::istream` object - a `FILE` pointer (must not be null) - a C-style array of characters - a pointer to a null-terminated string of single byte characters - a `std::string` - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. `IteratorType` : a compatible iterator type, for instance. - a pair of `std::string::iterator` or `std::vector<std::uint8_t>::iterator` - a pair of pointers such as `ptr` and `ptr + len` ## Parameters `i` (in) : Input to parse from. `ignore_comments` (in) : whether comments should be ignored and treated like whitespace (`#!cpp true`) or yield a parse error (`#!cpp false`); (optional, `#!cpp false` by default) `first` (in) : iterator to start of character range `last` (in) : iterator to end of character range ## Return value Whether the input is valid JSON. ## Exception safety Strong guarantee: if an exception is thrown, there are no changes in the JSON value. ## Complexity Linear in the length of the input. The parser is a predictive LL(1) parser. ## Notes (1) A UTF-8 byte order mark is silently ignored. !!! danger "Runtime assertion" The precondition that a passed `#!cpp FILE` pointer must not be null is enforced with a [runtime assertion](../../features/assertions.md). ## Examples ??? example The example below demonstrates the `accept()` function reading from a string. ```cpp --8<-- "examples/accept__string.cpp" ``` Output: ```json --8<-- "examples/accept__string.output" ``` ## See also - [parse](parse.md) - deserialize from a compatible input - [operator>>](../operator_gtgt.md) - deserialize from stream ## Version history - Added in version 3.0.0. - Ignoring comments via `ignore_comments` added in version 3.9.0. !!! warning "Deprecation" Overload (2) replaces calls to `accept` with a pair of iterators as their first parameter which has been deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like `#!cpp accept({ptr, ptr+len}, ...);` with `#!cpp accept(ptr, ptr+len, ...);`. You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated function.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/dump.md
.md
2,609
80
# <small>nlohmann::basic_json::</small>dump ```cpp string_t dump(const int indent = -1, const char indent_char = ' ', const bool ensure_ascii = false, const error_handler_t error_handler = error_handler_t::strict) const; ``` Serialization function for JSON values. The function tries to mimic Python's [`json.dumps()` function](https://docs.python.org/2/library/json.html#json.dump), and currently supports its `indent` and `ensure_ascii` parameters. ## Parameters `indent` (in) : If `indent` is nonnegative, then array elements and object members will be pretty-printed with that indent level. An indent level of `0` will only insert newlines. `-1` (the default) selects the most compact representation. `indent_char` (in) : The character to use for indentation if `indent` is greater than `0`. The default is ` ` (space). `ensure_ascii` (in) : If `ensure_ascii` is true, all non-ASCII characters in the output are escaped with `\uXXXX` sequences, and the result consists of ASCII characters only. `error_handler` (in) : how to react on decoding errors; there are three possible values (see [`error_handler_t`](error_handler_t.md): `strict` (throws and exception in case a decoding error occurs; default), `replace` (replace invalid UTF-8 sequences with U+FFFD), and `ignore` (ignore invalid UTF-8 sequences during serialization; all bytes are copied to the output unchanged)). ## Return value string containing the serialization of the JSON value ## Exception safety Strong guarantee: if an exception is thrown, there are no changes to any JSON value. ## Exceptions Throws [`type_error.316`](../../home/exceptions.md#jsonexceptiontype_error316) if a string stored inside the JSON value is not UTF-8 encoded and `error_handler` is set to `strict` ## Complexity Linear. ## Notes Binary values are serialized as object containing two keys: - "bytes": an array of bytes as integers - "subtype": the subtype as integer or `#!json null` if the binary has no subtype ## Examples ??? example The following example shows the effect of different `indent`, `indent_char`, and `ensure_ascii` parameters to the result of the serialization. ```cpp --8<-- "examples/dump.cpp" ``` Output: ```json --8<-- "examples/dump.output" ``` ## Version history - Added in version 1.0.0. - Indentation character `indent_char`, option `ensure_ascii` and exceptions added in version 3.0.0. - Error handlers added in version 3.4.0. - Serialization of binary values added in version 3.8.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/parse_error.md
.md
2,115
75
# <small>nlohmann::basic_json::</small>parse_error ```cpp class parse_error : public exception; ``` This exception is thrown by the library when a parse error occurs. Parse errors can occur during the deserialization of JSON text, BSON, CBOR, MessagePack, UBJSON, as well as when using JSON Patch. Member `byte` holds the byte index of the last read character in the input file (see note below). Exceptions have ids 1xx (see [list of parse errors](../../home/exceptions.md#parse-errors)). ```plantuml std::exception <|-- basic_json::exception basic_json::exception <|-- basic_json::parse_error basic_json::exception <|-- basic_json::invalid_iterator basic_json::exception <|-- basic_json::type_error basic_json::exception <|-- basic_json::out_of_range basic_json::exception <|-- basic_json::other_error interface std::exception {} class basic_json::exception { + const int id + const char* what() const } class basic_json::parse_error #FFFF00 { + const std::size_t byte } ``` ## Member functions - **what** - returns explanatory string ## Member variables - **id** - the id of the exception - **byte** - byte index of the parse error ## Notes For an input with $n$ bytes, 1 is the index of the first character and $n+1$ is the index of the terminating null byte or the end of file. This also holds true when reading a byte vector for binary formats. ## Examples ??? example The following code shows how a `parse_error` exception can be caught. ```cpp --8<-- "examples/parse_error.cpp" ``` Output: ```json --8<-- "examples/parse_error.output" ``` ## See also - [List of parse errors](../../home/exceptions.md#parse-errors) - [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators - [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type - [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range - [`other_error`](other_error.md) for exceptions indicating other library errors ## Version history - Since version 3.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/operator+=.md
.md
3,058
111
# <small>nlohmann::basic_json::</small>operator+= ```cpp // (1) reference operator+=(basic_json&& val); reference operator+=(const basic_json& val); // (2) reference operator+=(const typename object_t::value_type& val); // (3) reference operator+=(initializer_list_t init); ``` 1. Appends the given element `val` to the end of the JSON array. If the function is called on a JSON null value, an empty array is created before appending `val`. 2. Inserts the given element `val` to the JSON object. If the function is called on a JSON null value, an empty object is created before inserting `val`. 3. This function allows using `operator+=` with an initializer list. In case 1. the current value is an object, 2. the initializer list `init` contains only two elements, and 3. the first element of `init` is a string, `init` is converted into an object element and added using `operator+=(const typename object_t::value_type&)`. Otherwise, `init` is converted to a JSON value and added using `operator+=(basic_json&&)`. ## Parameters `val` (in) : the value to add to the JSON array/object `init` (in) : an initializer list ## Return value `#!cpp *this` ## Exceptions All functions can throw the following exception: - Throws [`type_error.308`](../../home/exceptions.md#jsonexceptiontype_error308) when called on a type other than JSON array or null; example: `"cannot use operator+=() with number"` ## Complexity 1. Amortized constant. 2. Logarithmic in the size of the container, O(log(`size()`)). 3. Linear in the size of the initializer list `init`. ## Notes (3) This function is required to resolve an ambiguous overload error, because pairs like `{"key", "value"}` can be both interpreted as `object_t::value_type` or `std::initializer_list<basic_json>`, see [#235](https://github.com/nlohmann/json/issues/235) for more information. ## Examples ??? example "Example: (1) add element to array" The example shows how `push_back()` and `+=` can be used to add elements to a JSON array. Note how the `null` value was silently converted to a JSON array. ```cpp --8<-- "examples/push_back.cpp" ``` Output: ```json --8<-- "examples/push_back.output" ``` ??? example "Example: (2) add element to object" The example shows how `push_back()` and `+=` can be used to add elements to a JSON object. Note how the `null` value was silently converted to a JSON object. ```cpp --8<-- "examples/push_back__object_t__value.cpp" ``` Output: ```json --8<-- "examples/push_back__object_t__value.output" ``` ??? example "Example: (3) add to object from initializer list" The example shows how initializer lists are treated as objects when possible. ```cpp --8<-- "examples/push_back__initializer_list.cpp" ``` Output: ```json --8<-- "examples/push_back__initializer_list.output" ``` ## Version history 1. Since version 1.0.0. 2. Since version 1.0.0. 2. Since version 2.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/string_t.md
.md
2,187
67
# <small>nlohmann::basic_json::</small>string_t ```cpp using string_t = StringType; ``` The type used to store JSON strings. [RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON strings as follows: > A string is a sequence of zero or more Unicode characters. To store objects in C++, a type is defined by the template parameter described below. Unicode values are split by the JSON class into byte-sized characters during deserialization. ## Template parameters `StringType` : the container to store strings (e.g., `std::string`). Note this container is used for keys/names in objects, see [object_t](object_t.md). ## Notes #### Default type With the default values for `StringType` (`std::string`), the default value for `string_t` is `#!cpp std::string`. #### Encoding Strings are stored in UTF-8 encoding. Therefore, functions like `std::string::size()` or `std::string::length()` return the number of bytes in the string rather than the number of characters or glyphs. #### String comparison [RFC 8259](https://tools.ietf.org/html/rfc8259) states: > Software implementations are typically required to test names of object members for equality. Implementations that > transform the textual representation into sequences of Unicode code units and then perform the comparison numerically, > code unit by code unit, are interoperable in the sense that implementations will agree in all cases on equality or > inequality of two strings. For example, implementations that compare strings with escaped characters unconverted may > incorrectly find that `"a\\b"` and `"a\u005Cb"` are not equal. This implementation is interoperable as it does compare strings code unit by code unit. #### Storage String values are stored as pointers in a `basic_json` type. That is, for any access to string values, a pointer of type `string_t*` must be dereferenced. ## Examples ??? example The following code shows that `string_t` is by default, a typedef to `#!cpp std::string`. ```cpp --8<-- "examples/string_t.cpp" ``` Output: ```json --8<-- "examples/string_t.output" ``` ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/parse.md
.md
6,308
215
# <small>nlohmann::basic_json::</small>parse ```cpp // (1) template<typename InputType> static basic_json parse(InputType&& i, const parser_callback_t cb = nullptr, const bool allow_exceptions = true, const bool ignore_comments = false); // (2) template<typename IteratorType> static basic_json parse(IteratorType first, IteratorType last, const parser_callback_t cb = nullptr, const bool allow_exceptions = true, const bool ignore_comments = false); ``` 1. Deserialize from a compatible input. 2. Deserialize from a pair of character iterators The `value_type` of the iterator must be an integral type with size of 1, 2 or 4 bytes, which will be interpreted respectively as UTF-8, UTF-16 and UTF-32. ## Template parameters `InputType` : A compatible input, for instance: - an `std::istream` object - a `FILE` pointer (must not be null) - a C-style array of characters - a pointer to a null-terminated string of single byte characters - a `std::string` - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. `IteratorType` : a compatible iterator type, for instance. - a pair of `std::string::iterator` or `std::vector<std::uint8_t>::iterator` - a pair of pointers such as `ptr` and `ptr + len` ## Parameters `i` (in) : Input to parse from. `cb` (in) : a parser callback function of type [`parser_callback_t`](parser_callback_t.md) which is used to control the deserialization by filtering unwanted values (optional) `allow_exceptions` (in) : whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) `ignore_comments` (in) : whether comments should be ignored and treated like whitespace (`#!cpp true`) or yield a parse error (`#!cpp false`); (optional, `#!cpp false` by default) `first` (in) : iterator to start of character range `last` (in) : iterator to end of character range ## Return value Deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be `value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). ## Exception safety Strong guarantee: if an exception is thrown, there are no changes in the JSON value. ## Exceptions - Throws [`parse_error.101`](../../home/exceptions.md#jsonexceptionparse_error101) in case of an unexpected token. - Throws [`parse_error.102`](../../home/exceptions.md#jsonexceptionparse_error102) if to_unicode fails or surrogate error. - Throws [`parse_error.103`](../../home/exceptions.md#jsonexceptionparse_error103) if to_unicode fails. ## Complexity Linear in the length of the input. The parser is a predictive LL(1) parser. The complexity can be higher if the parser callback function `cb` or reading from (1) the input `i` or (2) the iterator range [`first`, `last`] has a super-linear complexity. ## Notes (1) A UTF-8 byte order mark is silently ignored. !!! danger "Runtime assertion" The precondition that a passed `#!cpp FILE` pointer must not be null is enforced with a [runtime assertion](../../features/assertions.md). ## Examples ??? example "Parsing from a character array" The example below demonstrates the `parse()` function reading from an array. ```cpp --8<-- "examples/parse__array__parser_callback_t.cpp" ``` Output: ```json --8<-- "examples/parse__array__parser_callback_t.output" ``` ??? example "Parsing from a string" The example below demonstrates the `parse()` function with and without callback function. ```cpp --8<-- "examples/parse__string__parser_callback_t.cpp" ``` Output: ```json --8<-- "examples/parse__string__parser_callback_t.output" ``` ??? example "Parsing from an input stream" The example below demonstrates the `parse()` function with and without callback function. ```cpp --8<-- "examples/parse__istream__parser_callback_t.cpp" ``` Output: ```json --8<-- "examples/parse__istream__parser_callback_t.output" ``` ??? example "Parsing from a contiguous container" The example below demonstrates the `parse()` function reading from a contiguous container. ```cpp --8<-- "examples/parse__contiguouscontainer__parser_callback_t.cpp" ``` Output: ```json --8<-- "examples/parse__contiguouscontainer__parser_callback_t.output" ``` ??? example "Parsing from a non null-terminated string" The example below demonstrates the `parse()` function reading from a string that is not null-terminated. ```cpp --8<-- "examples/parse__pointers.cpp" ``` Output: ```json --8<-- "examples/parse__pointers.output" ``` ??? example "Parsing from an iterator pair" The example below demonstrates the `parse()` function reading from an iterator pair. ```cpp --8<-- "examples/parse__iterator_pair.cpp" ``` Output: ```json --8<-- "examples/parse__iterator_pair.output" ``` ??? example "Effect of `allow_exceptions` parameter" The example below demonstrates the effect of the `allow_exceptions` parameter in the ´parse()` function. ```cpp --8<-- "examples/parse__allow_exceptions.cpp" ``` Output: ```json --8<-- "examples/parse__allow_exceptions.output" ``` ## See also - [accept](accept.md) - check if the input is valid JSON - [operator>>](../operator_gtgt.md) - deserialize from stream ## Version history - Added in version 1.0.0. - Overload for contiguous containers (1) added in version 2.0.3. - Ignoring comments via `ignore_comments` added in version 3.9.0. !!! warning "Deprecation" Overload (2) replaces calls to `parse` with a pair of iterators as their first parameter which has been deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like `#!cpp parse({ptr, ptr+len}, ...);` with `#!cpp parse(ptr, ptr+len, ...);`. You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated function.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/type_name.md
.md
1,604
55
# <small>nlohmann::basic_json::</small>type_name ```cpp const char* type_name() const noexcept; ``` Returns the type name as string to be used in error messages -- usually to indicate that a function was called on a wrong JSON type. ## Return value a string representation of the type ([`value_t`](value_t.md)): | Value type | return value | |----------------------------------------------------|---------------| | `#!json null` | `"null"` | | boolean | `"boolean"` | | string | `"string"` | | number (integer, unsigned integer, floating-point) | `"number"` | | object | `"object"` | | array | `"array"` | | binary | `"binary"` | | discarded | `"discarded"` | ## Exception safety No-throw guarantee: this member function never throws exceptions. ## Complexity Constant. ## Examples ??? example The following code exemplifies `type_name()` for all JSON types. ```cpp --8<-- "examples/type_name.cpp" ``` Output: ```json --8<-- "examples/type_name.output" ``` ## Version history - Added in version 1.0.0. - Part of the public API version since 2.1.0. - Changed return value to `const char*` and added `noexcept` in version 3.0.0. - Added support for binary type in version 3.8.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/number_integer_t.md
.md
3,198
77
# <small>nlohmann::basic_json::</small>number_integer_t ```cpp using number_integer_t = NumberIntegerType; ``` The type used to store JSON numbers (integers). [RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows: > The representation of numbers is similar to that used in most programming languages. A number is represented in base > 10 using decimal digits. It contains an integer component that may be prefixed with an optional minus sign, which may > be followed by a fraction part and/or an exponent part. Leading zeros are not allowed. (...) Numeric values that > cannot be represented in the grammar below (such as Infinity and NaN) are not permitted. This description includes both integer and floating-point numbers. However, C++ allows more precise storage if it is known whether the number is a signed integer, an unsigned integer or a floating-point number. Therefore, three different types, `number_integer_t`, [`number_unsigned_t`](number_unsigned_t.md) and [`number_float_t`](number_float_t.md) are used. To store integer numbers in C++, a type is defined by the template parameter `NumberIntegerType` which chooses the type to use. ## Notes #### Default type With the default values for `NumberIntegerType` (`std::int64_t`), the default value for `number_integer_t` is `#!cpp std::int64_t`. #### Default behavior - The restrictions about leading zeros is not enforced in C++. Instead, leading zeros in integer literals lead to an interpretation as octal number. Internally, the value will be stored as decimal number. For instance, the C++ integer literal `010` will be serialized to `8`. During deserialization, leading zeros yield an error. - Not-a-number (NaN) values will be serialized to `null`. #### Limits [RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: > An implementation may set limits on the range and precision of numbers. When the default type is used, the maximal integer number that can be stored is `9223372036854775807` (INT64_MAX) and the minimal integer number that can be stored is `-9223372036854775808` (INT64_MIN). Integer numbers that are out of range will yield over/underflow when used in a constructor. During deserialization, too large or small integer numbers will be automatically be stored as [`number_unsigned_t`](number_unsigned_t.md) or [`number_float_t`](number_float_t.md). [RFC 8259](https://tools.ietf.org/html/rfc8259) further states: > Note that when such software is used, numbers that are integers and are in the range $[-2^{53}+1, 2^{53}-1]$ are > interoperable in the sense that implementations will agree exactly on their numeric values. As this range is a subrange of the exactly supported range [INT64_MIN, INT64_MAX], this class's integer type is interoperable. #### Storage Integer number values are stored directly inside a `basic_json` type. ## Examples ??? example The following code shows that `number_integer_t` is by default, a typedef to `#!cpp std::int64_t`. ```cpp --8<-- "examples/number_integer_t.cpp" ``` Output: ```json --8<-- "examples/number_integer_t.output" ``` ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/crend.md
.md
802
43
# <small>nlohmann::basic_json::</small>crend ```cpp const_reverse_iterator crend() const noexcept; ``` Returns an iterator to the reverse-end; that is, one before the first element. This element acts as a placeholder, attempting to access it results in undefined behavior. ![Illustration from cppreference.com](../../images/range-rbegin-rend.svg) ## Return value reverse iterator to the element following the last element ## Exception safety No-throw guarantee: this member function never throws exceptions. ## Complexity Constant. ## Examples ??? example The following code shows an example for `eend()`. ```cpp --8<-- "examples/crend.cpp" ``` Output: ```json --8<-- "examples/crend.output" ``` ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/to_string.md
.md
1,161
66
# to_string(basic_json) ```cpp template <typename BasicJsonType> std::string to_string(const BasicJsonType& j); ``` This function implements a user-defined to_string for JSON objects. ## Template parameters `BasicJsonType` : a specialization of [`basic_json`](index.md) ## Return value string containing the serialization of the JSON value ## Exception safety Strong guarantee: if an exception is thrown, there are no changes to any JSON value. ## Exceptions Throws [`type_error.316`](../../home/exceptions.md#jsonexceptiontype_error316) if a string stored inside the JSON value is not UTF-8 encoded ## Complexity Linear. ## Possible implementation ```cpp template <typename BasicJsonType> std::string to_string(const BasicJsonType& j) { return j.dump(); } ``` ## Examples ??? example The following code shows how the library's `to_string()` function integrates with others, allowing argument-dependent lookup. ```cpp --8<-- "examples/to_string.cpp" ``` Output: ```json --8<-- "examples/to_string.output" ``` ## See also - [dump](dump.md) ## Version history Added in version 3.7.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/array_t.md
.md
1,744
69
# <small>nlohmann::basic_json::</small>array_t ```cpp using array_t = ArrayType<basic_json, AllocatorType<basic_json>>; ``` The type used to store JSON arrays. [RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON arrays as follows: > An array is an ordered sequence of zero or more values. To store objects in C++, a type is defined by the template parameters explained below. ## Template parameters `ArrayType` : container type to store arrays (e.g., `std::vector` or `std::list`) `AllocatorType` : the allocator to use for objects (e.g., `std::allocator`) ## Notes #### Default type With the default values for `ArrayType` (`std::vector`) and `AllocatorType` (`std::allocator`), the default value for `array_t` is: ```cpp std::vector< basic_json, // value_type std::allocator<basic_json> // allocator_type > ``` #### Limits [RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: > An implementation may set limits on the maximum depth of nesting. In this class, the array's limit of nesting is not explicitly constrained. However, a maximum depth of nesting may be introduced by the compiler or runtime environment. A theoretical limit can be queried by calling the [`max_size`](max_size.md) function of a JSON array. #### Storage Arrays are stored as pointers in a `basic_json` type. That is, for any access to array values, a pointer of type `#!cpp array_t*` must be dereferenced. ## Examples ??? example The following code shows that `array_t` is by default, a typedef to `#!cpp std::vector<nlohmann::json>`. ```cpp --8<-- "examples/array_t.cpp" ``` Output: ```json --8<-- "examples/array_t.output" ``` ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/boolean_t.md
.md
930
43
# <small>nlohmann::basic_json::</small>boolean_t ```cpp using boolean_t = BooleanType; ``` The type used to store JSON booleans. [RFC 8259](https://tools.ietf.org/html/rfc8259) implicitly describes a boolean as a type which differentiates the two literals `#!json true` and `#!json false`. To store objects in C++, a type is defined by the template parameter `BooleanType` which chooses the type to use. ## Notes #### Default type With the default values for `BooleanType` (`#!cpp bool`), the default value for `boolean_t` is `#!cpp bool`. #### Storage Boolean values are stored directly inside a `basic_json` type. ## Examples ??? example The following code shows that `boolean_t` is by default, a typedef to `#!cpp bool`. ```cpp --8<-- "examples/boolean_t.cpp" ``` Output: ```json --8<-- "examples/boolean_t.output" ``` ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/operator_ge.md
.md
2,349
87
# <small>nlohmann::basic_json::</small>operator>= ```cpp // until C++20 bool operator>=(const_reference lhs, const_reference rhs) noexcept; // (1) template<typename ScalarType> bool operator>=(const_reference lhs, const ScalarType rhs) noexcept; // (2) template<typename ScalarType> bool operator>=(ScalarType lhs, const const_reference rhs) noexcept; // (2) ``` 1. Compares whether one JSON value `lhs` is greater than or equal to another JSON value `rhs` according to the following rules: - The comparison always yields `#!cpp false` if (1) either operand is discarded, or (2) either operand is `NaN` and the other operand is either `NaN` or any other number. - Otherwise, returns the result of `#!cpp !(lhs < rhs)` (see [**operator<**](operator_lt.md)). 2. Compares whether a JSON value is greater than or equal to a scalar or a scalar is greater than or equal to a JSON value by converting the scalar to a JSON value and comparing both JSON values according to 1. ## Template parameters `ScalarType` : a scalar type according to `std::is_scalar<ScalarType>::value` ## Parameters `lhs` (in) : first value to consider `rhs` (in) : second value to consider ## Return value whether `lhs` is less than or equal to `rhs` ## Exception safety No-throw guarantee: this function never throws exceptions. ## Complexity Linear. ## Notes !!! note "Comparing `NaN`" `NaN` values are unordered within the domain of numbers. The following comparisons all yield `#!cpp false`: 1. Comparing a `NaN` with itself. 2. Comparing a `NaN` with another `NaN`. 3. Comparing a `NaN` and any other number. !!! note "Operator overload resolution" Since C++20 overload resolution will consider the _rewritten candidate_ generated from [`operator<=>`](operator_spaceship.md). ## Examples ??? example The example demonstrates comparing several JSON types. ```cpp --8<-- "examples/operator__greaterequal.cpp" ``` Output: ```json --8<-- "examples/operator__greaterequal.output" ``` ## See also - [**operator<=>**](operator_spaceship.md) comparison: 3-way ## Version history 1. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0. 2. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/parse_event_t.md
.md
800
30
# <small>nlohmann::basic_json::</small>parse_event_t ```cpp enum class parse_event_t : std::uint8_t { object_start, object_end, array_start, array_end, key, value }; ``` The parser callback distinguishes the following events: - `object_start`: the parser read `{` and started to process a JSON object - `key`: the parser read a key of a value in an object - `object_end`: the parser read `}` and finished processing a JSON object - `array_start`: the parser read `[` and started to process a JSON array - `array_end`: the parser read `]` and finished processing a JSON array - `value`: the parser finished reading a JSON value ## Examples ![Example when certain parse events are triggered](../../images/callback_events.png) ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/is_boolean.md
.md
689
40
# <small>nlohmann::basic_json::</small>is_boolean ```cpp constexpr bool is_boolean() const noexcept; ``` This function returns `#!cpp true` if and only if the JSON value is `#!json true` or `#!json false`. ## Return value `#!cpp true` if type is boolean, `#!cpp false` otherwise. ## Exception safety No-throw guarantee: this member function never throws exceptions. ## Complexity Constant. ## Examples ??? example The following code exemplifies `is_boolean()` for all JSON types. ```cpp --8<-- "examples/is_boolean.cpp" ``` Output: ```json --8<-- "examples/is_boolean.output" ``` ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/from_bjdata.md
.md
2,686
94
# <small>nlohmann::basic_json::</small>from_bjdata ```cpp // (1) template<typename InputType> static basic_json from_bjdata(InputType&& i, const bool strict = true, const bool allow_exceptions = true); // (2) template<typename IteratorType> static basic_json from_bjdata(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true); ``` Deserializes a given input to a JSON value using the BJData (Binary JData) serialization format. 1. Reads from a compatible input. 2. Reads from an iterator range. The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/bjdata.md). ## Template parameters `InputType` : A compatible input, for instance: - an `std::istream` object - a `FILE` pointer - a C-style array of characters - a pointer to a null-terminated string of single byte characters - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. `IteratorType` : a compatible iterator type ## Parameters `i` (in) : an input in BJData format convertible to an input adapter `first` (in) : iterator to start of the input `last` (in) : iterator to end of the input `strict` (in) : whether to expect the input to be consumed until EOF (`#!cpp true` by default) `allow_exceptions` (in) : whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) ## Return value deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be `value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). ## Exception safety Strong guarantee: if an exception is thrown, there are no changes in the JSON value. ## Exceptions - Throws [parse_error.110](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or the end of file was not reached when `strict` was set to true - Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs - Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string could not be parsed successfully ## Complexity Linear in the size of the input. ## Examples ??? example The example shows the deserialization of a byte vector in BJData format to a JSON value. ```cpp --8<-- "examples/from_bjdata.cpp" ``` Output: ```json --8<-- "examples/from_bjdata.output" ``` ## Version history - Added in version 3.11.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/is_null.md
.md
662
40
# <small>nlohmann::basic_json::</small>is_null ```cpp constexpr bool is_null() const noexcept; ``` This function returns `#!cpp true` if and only if the JSON value is `#!json null`. ## Return value `#!cpp true` if type is `#!json null`, `#!cpp false` otherwise. ## Exception safety No-throw guarantee: this member function never throws exceptions. ## Complexity Constant. ## Examples ??? example The following code exemplifies `is_null()` for all JSON types. ```cpp --8<-- "examples/is_null.cpp" ``` Output: ```json --8<-- "examples/is_null.output" ``` ## Version history - Added in version 1.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/max_size.md
.md
1,806
61
# <small>nlohmann::basic_json::</small>max_size ```cpp size_type max_size() const noexcept; ``` Returns the maximum number of elements a JSON value is able to hold due to system or library implementation limitations, i.e. `std::distance(begin(), end())` for the JSON value. ## Return value The return value depends on the different types and is defined as follows: | Value type | return value | |------------|-------------------------------------------| | null | `0` (same as [`size()`](size.md)) | | boolean | `1` (same as [`size()`](size.md)) | | string | `1` (same as [`size()`](size.md)) | | number | `1` (same as [`size()`](size.md)) | | binary | `1` (same as [`size()`](size.md)) | | object | result of function `object_t::max_size()` | | array | result of function `array_t::max_size()` | ## Exception safety No-throw guarantee: this function never throws exceptions. ## Complexity Constant, as long as [`array_t`](array_t.md) and [`object_t`](object_t.md) satisfy the [Container](https://en.cppreference.com/w/cpp/named_req/Container) concept; that is, their `max_size()` functions have constant complexity. ## Notes This function does not return the maximal length of a string stored as JSON value -- it returns the maximal number of string elements the JSON value can store which is `1`. ## Examples ??? example The following code calls `max_size()` on the different value types. ```cpp --8<-- "examples/max_size.cpp" ``` Output: ```json --8<-- "examples/max_size.output" ``` Note the output is platform-dependent. ## Version history - Added in version 1.0.0. - Extended to return `1` for binary types in version 3.8.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/merge_patch.md
.md
1,537
64
# <small>nlohmann::basic_json::</small>merge_patch ```cpp void merge_patch(const basic_json& apply_patch); ``` The merge patch format is primarily intended for use with the HTTP PATCH method as a means of describing a set of modifications to a target resource's content. This function applies a merge patch to the current JSON value. The function implements the following algorithm from Section 2 of [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396): ```python define MergePatch(Target, Patch): if Patch is an Object: if Target is not an Object: Target = {} // Ignore the contents and set it to an empty Object for each Name/Value pair in Patch: if Value is null: if Name exists in Target: remove the Name/Value pair from Target else: Target[Name] = MergePatch(Target[Name], Value) return Target else: return Patch ``` Thereby, `Target` is the current object; that is, the patch is applied to the current value. ## Parameters `apply_patch` (in) : the patch to apply ## Complexity Linear in the lengths of `apply_patch`. ## Examples ??? example The following code shows how a JSON Merge Patch is applied to a JSON document. ```cpp --8<-- "examples/merge_patch.cpp" ``` Output: ```json --8<-- "examples/merge_patch.output" ``` ## See also - [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396) - [patch](patch.md) apply a JSON patch ## Version history - Added in version 3.0.0.
Markdown
3D
OpenMS/OpenMS
src/openms/extern/nlohmann_json/docs/mkdocs/docs/api/basic_json/from_ubjson.md
.md
3,556
107
# <small>nlohmann::basic_json::</small>from_ubjson ```cpp // (1) template<typename InputType> static basic_json from_ubjson(InputType&& i, const bool strict = true, const bool allow_exceptions = true); // (2) template<typename IteratorType> static basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict = true, const bool allow_exceptions = true); ``` Deserializes a given input to a JSON value using the UBJSON (Universal Binary JSON) serialization format. 1. Reads from a compatible input. 2. Reads from an iterator range. The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/ubjson.md). ## Template parameters `InputType` : A compatible input, for instance: - an `std::istream` object - a `FILE` pointer - a C-style array of characters - a pointer to a null-terminated string of single byte characters - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. `IteratorType` : a compatible iterator type ## Parameters `i` (in) : an input in UBJSON format convertible to an input adapter `first` (in) : iterator to start of the input `last` (in) : iterator to end of the input `strict` (in) : whether to expect the input to be consumed until EOF (`#!cpp true` by default) `allow_exceptions` (in) : whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) ## Return value deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be `value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). ## Exception safety Strong guarantee: if an exception is thrown, there are no changes in the JSON value. ## Exceptions - Throws [parse_error.110](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or the end of file was not reached when `strict` was set to true - Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs - Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string could not be parsed successfully ## Complexity Linear in the size of the input. ## Examples ??? example The example shows the deserialization of a byte vector in UBJSON format to a JSON value. ```cpp --8<-- "examples/from_ubjson.cpp" ``` Output: ```json --8<-- "examples/from_ubjson.output" ``` ## Version history - Added in version 3.1.0. - Added `allow_exceptions` parameter in version 3.2.0. !!! warning "Deprecation" - Overload (2) replaces calls to `from_ubjson` with a pointer and a length as first two parameters, which has been deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like `#!cpp from_ubjson(ptr, len, ...);` with `#!cpp from_ubjson(ptr, ptr+len, ...);`. - Overload (2) replaces calls to `from_ubjson` with a pair of iterators as their first parameter, which has been deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like `#!cpp from_ubjson({ptr, ptr+len}, ...);` with `#!cpp from_ubjson(ptr, ptr+len, ...);`. You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated function.
Markdown