From 344ced40125cfc03b5d22c58bbee3ba7fb4d2b3f Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 26 Nov 2023 14:01:20 +0100 Subject: [PATCH] Deployed 360ce457f with MkDocs version: 1.5.3 --- 404.html | 2 +- api/adl_serializer/from_json/index.html | 158 ++-- api/adl_serializer/index.html | 24 +- api/adl_serializer/to_json/index.html | 58 +- api/basic_json/accept/index.html | 46 +- api/basic_json/array/index.html | 40 +- api/basic_json/array_t/index.html | 26 +- api/basic_json/at/index.html | 712 +++++++++--------- api/basic_json/back/index.html | 84 +-- api/basic_json/basic_json/index.html | 600 +++++++-------- api/basic_json/begin/index.html | 26 +- api/basic_json/binary/index.html | 36 +- api/basic_json/binary_t/index.html | 22 +- api/basic_json/boolean_t/index.html | 22 +- api/basic_json/cbegin/index.html | 24 +- api/basic_json/cbor_tag_handler_t/index.html | 58 +- api/basic_json/cend/index.html | 26 +- api/basic_json/clear/index.html | 74 +- api/basic_json/contains/index.html | 164 ++-- api/basic_json/count/index.html | 66 +- api/basic_json/crbegin/index.html | 24 +- api/basic_json/crend/index.html | 26 +- .../default_object_comparator_t/index.html | 26 +- api/basic_json/diff/index.html | 88 +-- api/basic_json/dump/index.html | 176 ++--- api/basic_json/emplace/index.html | 54 +- api/basic_json/emplace_back/index.html | 44 +- api/basic_json/empty/index.html | 80 +- api/basic_json/end/index.html | 28 +- api/basic_json/erase/index.html | 216 +++--- api/basic_json/error_handler_t/index.html | 58 +- api/basic_json/exception/index.html | 40 +- api/basic_json/find/index.html | 84 +-- api/basic_json/flatten/index.html | 82 +- api/basic_json/from_bjdata/index.html | 54 +- api/basic_json/from_bson/index.html | 56 +- api/basic_json/from_cbor/index.html | 58 +- api/basic_json/from_msgpack/index.html | 54 +- api/basic_json/from_ubjson/index.html | 54 +- api/basic_json/front/index.html | 60 +- api/basic_json/get/index.html | 166 ++-- api/basic_json/get_allocator/index.html | 32 +- api/basic_json/get_binary/index.html | 26 +- api/basic_json/get_ptr/index.html | 42 +- api/basic_json/get_ref/index.html | 50 +- api/basic_json/get_to/index.html | 130 ++-- api/basic_json/index.html | 144 ++-- api/basic_json/input_format_t/index.html | 194 ++--- api/basic_json/insert/index.html | 144 ++-- api/basic_json/invalid_iterator/index.html | 42 +- api/basic_json/is_array/index.html | 72 +- api/basic_json/is_binary/index.html | 72 +- api/basic_json/is_boolean/index.html | 72 +- api/basic_json/is_discarded/index.html | 76 +- api/basic_json/is_null/index.html | 72 +- api/basic_json/is_number/index.html | 80 +- api/basic_json/is_number_float/index.html | 72 +- api/basic_json/is_number_integer/index.html | 72 +- api/basic_json/is_number_unsigned/index.html | 72 +- api/basic_json/is_object/index.html | 72 +- api/basic_json/is_primitive/index.html | 80 +- api/basic_json/is_string/index.html | 72 +- api/basic_json/is_structured/index.html | 80 +- api/basic_json/items/index.html | 84 +-- api/basic_json/json_base_class_t/index.html | 170 ++--- api/basic_json/json_serializer/index.html | 86 +-- api/basic_json/max_size/index.html | 58 +- api/basic_json/merge_patch/index.html | 50 +- api/basic_json/meta/index.html | 54 +- api/basic_json/number_float_t/index.html | 22 +- api/basic_json/number_integer_t/index.html | 22 +- api/basic_json/number_unsigned_t/index.html | 22 +- api/basic_json/object/index.html | 52 +- api/basic_json/object_comparator_t/index.html | 28 +- api/basic_json/object_t/index.html | 36 +- api/basic_json/operator+=/index.html | 124 +-- api/basic_json/operator=/index.html | 40 +- api/basic_json/operator[]/index.html | 366 ++++----- api/basic_json/operator_ValueType/index.html | 132 ++-- api/basic_json/operator_eq/index.html | 184 ++--- api/basic_json/operator_ge/index.html | 54 +- api/basic_json/operator_gt/index.html | 54 +- api/basic_json/operator_le/index.html | 54 +- api/basic_json/operator_lt/index.html | 54 +- api/basic_json/operator_ne/index.html | 104 +-- api/basic_json/operator_spaceship/index.html | 144 ++-- api/basic_json/operator_value_t/index.html | 82 +- api/basic_json/other_error/index.html | 44 +- api/basic_json/out_of_range/index.html | 40 +- api/basic_json/parse/index.html | 462 ++++++------ api/basic_json/parse_error/index.html | 42 +- api/basic_json/parse_event_t/index.html | 18 +- api/basic_json/parser_callback_t/index.html | 122 +-- api/basic_json/patch/index.html | 54 +- api/basic_json/patch_inplace/index.html | 58 +- api/basic_json/push_back/index.html | 124 +-- api/basic_json/rbegin/index.html | 26 +- api/basic_json/rend/index.html | 28 +- api/basic_json/sax_parse/index.html | 274 +++---- api/basic_json/size/index.html | 70 +- api/basic_json/std_hash/index.html | 58 +- api/basic_json/std_swap/index.html | 44 +- api/basic_json/string_t/index.html | 22 +- api/basic_json/swap/index.html | 148 ++-- api/basic_json/to_bjdata/index.html | 116 +-- api/basic_json/to_bson/index.html | 40 +- api/basic_json/to_cbor/index.html | 40 +- api/basic_json/to_msgpack/index.html | 40 +- api/basic_json/to_string/index.html | 42 +- api/basic_json/to_ubjson/index.html | 116 +-- api/basic_json/type/index.html | 66 +- api/basic_json/type_error/index.html | 40 +- api/basic_json/type_name/index.html | 64 +- api/basic_json/unflatten/index.html | 82 +- api/basic_json/update/index.html | 186 ++--- api/basic_json/value/index.html | 180 ++--- api/basic_json/value_t/index.html | 88 +-- api/basic_json/~basic_json/index.html | 4 +- .../byte_container_with_subtype/index.html | 44 +- .../clear_subtype/index.html | 32 +- .../has_subtype/index.html | 30 +- api/byte_container_with_subtype/index.html | 6 +- .../set_subtype/index.html | 32 +- .../subtype/index.html | 32 +- api/json/index.html | 118 +-- api/json_pointer/back/index.html | 28 +- api/json_pointer/empty/index.html | 42 +- api/json_pointer/index.html | 6 +- api/json_pointer/json_pointer/index.html | 86 +-- api/json_pointer/operator_eq/index.html | 108 +-- api/json_pointer/operator_ne/index.html | 98 +-- api/json_pointer/operator_slash/index.html | 36 +- api/json_pointer/operator_slasheq/index.html | 46 +- api/json_pointer/operator_string_t/index.html | 42 +- api/json_pointer/parent_pointer/index.html | 36 +- api/json_pointer/pop_back/index.html | 40 +- api/json_pointer/push_back/index.html | 42 +- api/json_pointer/string_t/index.html | 26 +- api/json_pointer/to_string/index.html | 84 +-- api/json_sax/binary/index.html | 180 ++--- api/json_sax/boolean/index.html | 250 +++--- api/json_sax/end_array/index.html | 250 +++--- api/json_sax/end_object/index.html | 250 +++--- api/json_sax/index.html | 6 +- api/json_sax/key/index.html | 250 +++--- api/json_sax/null/index.html | 250 +++--- api/json_sax/number_float/index.html | 250 +++--- api/json_sax/number_integer/index.html | 250 +++--- api/json_sax/number_unsigned/index.html | 250 +++--- api/json_sax/parse_error/index.html | 254 +++---- api/json_sax/start_array/index.html | 250 +++--- api/json_sax/start_object/index.html | 250 +++--- api/json_sax/string/index.html | 250 +++--- api/macros/index.html | 2 +- api/macros/json_assert/index.html | 38 +- api/macros/json_diagnostics/index.html | 72 +- .../index.html | 128 ++-- api/macros/json_has_cpp_11/index.html | 10 +- api/macros/json_has_filesystem/index.html | 12 +- api/macros/json_has_ranges/index.html | 10 +- api/macros/json_has_static_rtti/index.html | 10 +- .../json_has_three_way_comparison/index.html | 10 +- api/macros/json_no_io/index.html | 10 +- api/macros/json_noexception/index.html | 10 +- .../index.html | 4 +- .../index.html | 8 +- api/macros/json_throw_user/index.html | 18 +- api/macros/json_use_global_udls/index.html | 38 +- .../json_use_implicit_conversions/index.html | 12 +- .../index.html | 12 +- .../nlohmann_define_type_intrusive/index.html | 401 ++++++---- .../index.html | 361 +++++---- api/macros/nlohmann_json_namespace/index.html | 20 +- .../nlohmann_json_namespace_begin/index.html | 72 +- .../index.html | 18 +- .../nlohmann_json_serialize_enum/index.html | 166 ++-- .../nlohmann_json_version_major/index.html | 30 +- api/operator_gtgt/index.html | 56 +- api/operator_literal_json/index.html | 42 +- api/operator_literal_json_pointer/index.html | 38 +- api/operator_ltlt/index.html | 84 +-- api/ordered_json/index.html | 36 +- api/ordered_map/index.html | 80 +- assets/javascripts/bundle.5a2dcb6a.min.js | 29 - assets/javascripts/bundle.5a2dcb6a.min.js.map | 8 - assets/javascripts/bundle.aecac24b.min.js | 29 + assets/javascripts/bundle.aecac24b.min.js.map | 7 + .../javascripts/extra/bundle.5f09fbc3.min.js | 18 - .../extra/bundle.5f09fbc3.min.js.map | 8 - assets/javascripts/lunr/min/lunr.el.min.js | 1 + assets/javascripts/lunr/min/lunr.he.min.js | 1 + assets/javascripts/lunr/min/lunr.hy.min.js | 1 + assets/javascripts/lunr/min/lunr.kn.min.js | 1 + assets/javascripts/lunr/min/lunr.ko.min.js | 2 +- assets/javascripts/lunr/min/lunr.sa.min.js | 1 + assets/javascripts/lunr/min/lunr.te.min.js | 1 + assets/javascripts/lunr/min/lunr.zh.min.js | 2 +- assets/javascripts/lunr/wordcut.js | 4 +- ...16e2a7d4.min.js => search.f886a092.min.js} | 22 +- ....min.js.map => search.f886a092.min.js.map} | 9 +- assets/stylesheets/extra.0d2c79a8.min.css | 1 - assets/stylesheets/extra.0d2c79a8.min.css.map | 1 - assets/stylesheets/main.4b4a2bd9.min.css | 1 + assets/stylesheets/main.4b4a2bd9.min.css.map | 1 + assets/stylesheets/main.975780f9.min.css | 1 - assets/stylesheets/main.975780f9.min.css.map | 1 - assets/stylesheets/palette.2505c338.min.css | 1 - .../stylesheets/palette.2505c338.min.css.map | 1 - assets/stylesheets/palette.356b1318.min.css | 1 + .../stylesheets/palette.356b1318.min.css.map | 1 + ...type_intrusive_only_serialize_explicit.cpp | 38 + ...e_intrusive_only_serialize_explicit.output | 1 + ...ne_type_intrusive_only_serialize_macro.cpp | 33 + ...type_intrusive_only_serialize_macro.output | 1 + ..._non_intrusive_only_serialize_explicit.cpp | 31 + ...n_intrusive_only_serialize_explicit.output | 1 + ...ype_non_intrusive_only_serialize_macro.cpp | 26 + ..._non_intrusive_only_serialize_macro.output | 1 + features/arbitrary_types/index.html | 220 +++--- features/assertions/index.html | 58 +- features/binary_formats/bjdata/index.html | 144 ++-- features/binary_formats/bson/index.html | 68 +- features/binary_formats/cbor/index.html | 66 +- features/binary_formats/index.html | 2 +- .../binary_formats/messagepack/index.html | 66 +- features/binary_formats/ubjson/index.html | 134 ++-- features/binary_values/index.html | 108 +-- features/comments/index.html | 78 +- .../element_access/checked_access/index.html | 26 +- .../element_access/default_value/index.html | 10 +- features/element_access/index.html | 2 +- .../unchecked_access/index.html | 44 +- features/enum_conversion/index.html | 40 +- features/iterators/index.html | 102 +-- features/json_patch/index.html | 132 ++-- features/json_pointer/index.html | 48 +- features/macros/index.html | 2 +- features/merge_patch/index.html | 48 +- features/namespace/index.html | 4 +- features/object_order/index.html | 108 +-- features/parsing/index.html | 2 +- features/parsing/json_lines/index.html | 56 +- features/parsing/parse_exceptions/index.html | 108 +-- features/parsing/parser_callbacks/index.html | 136 ++-- features/parsing/sax_interface/index.html | 30 +- features/types/index.html | 56 +- features/types/number_handling/index.html | 88 +-- home/code_of_conduct/index.html | 2 +- home/design_goals/index.html | 2 +- home/exceptions/index.html | 252 +++---- home/faq/index.html | 46 +- home/license/index.html | 2 +- home/releases/index.html | 20 +- home/sponsors/index.html | 2 +- index.html | 2 +- integration/cmake/index.html | 4 +- integration/index.html | 6 +- integration/migration_guide/index.html | 112 +-- integration/package_managers/index.html | 134 ++-- integration/pkg-config/index.html | 6 +- search/search_index.json | 2 +- sitemap.xml | 448 +++++------ sitemap.xml.gz | Bin 1652 -> 1653 bytes 263 files changed, 9968 insertions(+), 9734 deletions(-) delete mode 100644 assets/javascripts/bundle.5a2dcb6a.min.js delete mode 100644 assets/javascripts/bundle.5a2dcb6a.min.js.map create mode 100644 assets/javascripts/bundle.aecac24b.min.js create mode 100644 assets/javascripts/bundle.aecac24b.min.js.map delete mode 100644 assets/javascripts/extra/bundle.5f09fbc3.min.js delete mode 100644 assets/javascripts/extra/bundle.5f09fbc3.min.js.map create mode 100644 assets/javascripts/lunr/min/lunr.el.min.js create mode 100644 assets/javascripts/lunr/min/lunr.he.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hy.min.js create mode 100644 assets/javascripts/lunr/min/lunr.kn.min.js create mode 100644 assets/javascripts/lunr/min/lunr.sa.min.js create mode 100644 assets/javascripts/lunr/min/lunr.te.min.js rename assets/javascripts/workers/{search.16e2a7d4.min.js => search.f886a092.min.js} (59%) rename assets/javascripts/workers/{search.16e2a7d4.min.js.map => search.f886a092.min.js.map} (51%) delete mode 100644 assets/stylesheets/extra.0d2c79a8.min.css delete mode 100644 assets/stylesheets/extra.0d2c79a8.min.css.map create mode 100644 assets/stylesheets/main.4b4a2bd9.min.css create mode 100644 assets/stylesheets/main.4b4a2bd9.min.css.map delete mode 100644 assets/stylesheets/main.975780f9.min.css delete mode 100644 assets/stylesheets/main.975780f9.min.css.map delete mode 100644 assets/stylesheets/palette.2505c338.min.css delete mode 100644 assets/stylesheets/palette.2505c338.min.css.map create mode 100644 assets/stylesheets/palette.356b1318.min.css create mode 100644 assets/stylesheets/palette.356b1318.min.css.map create mode 100644 examples/nlohmann_define_type_intrusive_only_serialize_explicit.cpp create mode 100644 examples/nlohmann_define_type_intrusive_only_serialize_explicit.output create mode 100644 examples/nlohmann_define_type_intrusive_only_serialize_macro.cpp create mode 100644 examples/nlohmann_define_type_intrusive_only_serialize_macro.output create mode 100644 examples/nlohmann_define_type_non_intrusive_only_serialize_explicit.cpp create mode 100644 examples/nlohmann_define_type_non_intrusive_only_serialize_explicit.output create mode 100644 examples/nlohmann_define_type_non_intrusive_only_serialize_macro.cpp create mode 100644 examples/nlohmann_define_type_non_intrusive_only_serialize_macro.output diff --git a/404.html b/404.html index 4f2a571f2..55d322c4d 100644 --- a/404.html +++ b/404.html @@ -1 +1 @@ - JSON for Modern C++

404 - Not found

\ No newline at end of file + JSON for Modern C++

404 - Not found

\ No newline at end of file diff --git a/api/adl_serializer/from_json/index.html b/api/adl_serializer/from_json/index.html index 831d134c5..5fc7bfa7c 100644 --- a/api/adl_serializer/from_json/index.html +++ b/api/adl_serializer/from_json/index.html @@ -1,104 +1,104 @@ - from_json - JSON for Modern C++
Skip to content

nlohmann::adl_serializer::from_json

// (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())
+ from_json - JSON for Modern C++       

nlohmann::adl_serializer::from_json

// (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() function of the 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: (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.

#include <iostream>
-#include <nlohmann/json.hpp>
+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() function of the 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: (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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-namespace ns
-{
+namespace ns
+{
 // a simple struct to model a person
-struct person
-{
-    std::string name;
-    std::string address;
-    int age;
-};
+struct person
+{
+    std::string name;
+    std::string address;
+    int age;
+};
 } // namespace ns
 
-namespace ns
-{
-void from_json(const json& j, person& p)
-{
-    j.at("name").get_to(p.name);
-    j.at("address").get_to(p.address);
-    j.at("age").get_to(p.age);
-}
+namespace ns
+{
+void from_json(const json& j, person& p)
+{
+    j.at("name").get_to(p.name);
+    j.at("address").get_to(p.address);
+    j.at("age").get_to(p.age);
+}
 } // namespace ns
 
-int main()
-{
-    json j;
-    j["name"] = "Ned Flanders";
-    j["address"] = "744 Evergreen Terrace";
-    j["age"] = 60;
+int main()
+{
+    json j;
+    j["name"] = "Ned Flanders";
+    j["address"] = "744 Evergreen Terrace";
+    j["age"] = 60;
 
-    auto p = j.template get<ns::person>();
+    auto p = j.template get<ns::person>();
 
-    std::cout << p.name << " (" << p.age << ") lives in " << p.address << std::endl;
-}
-

Output:

Ned Flanders (60) lives in 744 Evergreen Terrace
-
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.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << p.name << " (" << p.age << ") lives in " << p.address << std::endl;
+}
+

Output:

Ned Flanders (60) lives in 744 Evergreen Terrace
+
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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-namespace ns
-{
+namespace ns
+{
 // a simple struct to model a person (not default constructible)
-struct person
-{
-    person(std::string n, std::string a, int aa)
-        : name(std::move(n)), address(std::move(a)), age(aa)
-    {}
+struct person
+{
+    person(std::string n, std::string a, int aa)
+        : name(std::move(n)), address(std::move(a)), age(aa)
+    {}
 
-    std::string name;
-    std::string address;
-    int age;
-};
+    std::string name;
+    std::string address;
+    int age;
+};
 } // namespace ns
 
-namespace nlohmann
-{
-template <>
-struct adl_serializer<ns::person>
-{
-    static ns::person from_json(const json& j)
-    {
-        return {j.at("name"), j.at("address"), j.at("age")};
-    }
+namespace nlohmann
+{
+template <>
+struct adl_serializer<ns::person>
+{
+    static ns::person from_json(const json& j)
+    {
+        return {j.at("name"), j.at("address"), j.at("age")};
+    }
 
     // Here's the catch! You must provide a to_json method! Otherwise, you
     // will not be able to convert person to json, since you fully
     // specialized adl_serializer on that type
-    static void to_json(json& j, ns::person p)
-    {
-        j["name"] = p.name;
-        j["address"] = p.address;
-        j["age"] = p.age;
-    }
-};
+    static void to_json(json& j, ns::person p)
+    {
+        j["name"] = p.name;
+        j["address"] = p.address;
+        j["age"] = p.age;
+    }
+};
 } // namespace nlohmann
 
-int main()
-{
-    json j;
-    j["name"] = "Ned Flanders";
-    j["address"] = "744 Evergreen Terrace";
-    j["age"] = 60;
+int main()
+{
+    json j;
+    j["name"] = "Ned Flanders";
+    j["address"] = "744 Evergreen Terrace";
+    j["age"] = 60;
 
-    auto p = j.template get<ns::person>();
+    auto p = j.template get<ns::person>();
 
-    std::cout << p.name << " (" << p.age << ") lives in " << p.address << std::endl;
-}
-

Output:

Ned Flanders (60) lives in 744 Evergreen Terrace
-

See also

Version history

  • Added in version 2.1.0.

Last update: June 11, 2023
\ No newline at end of file + std::cout << p.name << " (" << p.age << ") lives in " << p.address << std::endl; +} +

Output:

Ned Flanders (60) lives in 744 Evergreen Terrace
+

See also

Version history

  • Added in version 2.1.0.

Last update: November 1, 2023
\ No newline at end of file diff --git a/api/adl_serializer/index.html b/api/adl_serializer/index.html index 2f9bd8611..e28cb5e99 100644 --- a/api/adl_serializer/index.html +++ b/api/adl_serializer/index.html @@ -1,15 +1,15 @@ - Overview - JSON for Modern C++
Skip to content

nlohmann::adl_serializer

template<typename, typename>
-struct adl_serializer;
-

Serializer that uses ADL (Argument-Dependent Lookup) to choose to_json/from_json functions from the types' namespaces.

It is implemented similar to

template<typename ValueType>
-struct adl_serializer {
-    template<typename BasicJsonType>
-    static void to_json(BasicJsonType& j, const T& value) {
+ Overview - JSON for Modern C++       

nlohmann::adl_serializer

template<typename, typename>
+struct adl_serializer;
+

Serializer that uses ADL (Argument-Dependent Lookup) to choose to_json/from_json functions from the types' namespaces.

It is implemented similar to

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) {
+    template<typename BasicJsonType>
+    static void from_json(const BasicJsonType& j, T& value) {
         // same thing, but with the "from_json" method
-    }
-};
-

Member functions

  • from_json - convert a JSON value to any value type
  • to_json - convert any value type to a JSON value

Version history

  • Added in version 2.1.0.

Last update: May 1, 2022
\ No newline at end of file + } +}; +

Member functions

  • from_json - convert a JSON value to any value type
  • to_json - convert any value type to a JSON value

Version history

  • Added in version 2.1.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/adl_serializer/to_json/index.html b/api/adl_serializer/to_json/index.html index 9089b3cca..f9f44b714 100644 --- a/api/adl_serializer/to_json/index.html +++ b/api/adl_serializer/to_json/index.html @@ -1,38 +1,38 @@ - to_json - JSON for Modern C++
Skip to content

nlohmann::adl_serializer::to_json

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 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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ to_json - JSON for Modern C++       

nlohmann::adl_serializer::to_json

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 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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-namespace ns
-{
+namespace ns
+{
 // a simple struct to model a person
-struct person
-{
-    std::string name;
-    std::string address;
-    int age;
-};
+struct person
+{
+    std::string name;
+    std::string address;
+    int age;
+};
 } // namespace ns
 
-namespace ns
-{
-void to_json(json& j, const person& p)
-{
-    j = json{ {"name", p.name}, {"address", p.address}, {"age", p.age} };
-}
+namespace ns
+{
+void to_json(json& j, const person& p)
+{
+    j = json{ {"name", p.name}, {"address", p.address}, {"age", p.age} };
+}
 } // namespace ns
 
-int main()
-{
-    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
+int main()
+{
+    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
 
-    json j = p;
+    json j = p;
 
-    std::cout << j << std::endl;
-}
-

Output:

{"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}
-

See also

Version history

  • Added in version 2.1.0.

Last update: August 5, 2022
\ No newline at end of file + std::cout << j << std::endl; +} +

Output:

{"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}
+

See also

Version history

  • Added in version 2.1.0.

Last update: November 1, 2023
\ No newline at end of file diff --git a/api/basic_json/accept/index.html b/api/basic_json/accept/index.html index 202f58559..0cb1b68f5 100644 --- a/api/basic_json/accept/index.html +++ b/api/basic_json/accept/index.html @@ -1,37 +1,37 @@ - accept - JSON for Modern C++
Skip to content

nlohmann::basic_json::accept

// (1)
-template<typename InputType>
-static bool accept(InputType&& i,
-                   const bool ignore_comments = false);
+ accept - JSON for Modern C++       

nlohmann::basic_json::accept

// (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 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 (true) or yield a parse error (false); (optional, 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.

Runtime assertion

The precondition that a passed FILE pointer must not be null is enforced with a runtime assertion.

Examples

Example

The example below demonstrates the accept() function reading from a string.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+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 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 (true) or yield a parse error (false); (optional, 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.

Runtime assertion

The precondition that a passed FILE pointer must not be null is enforced with a runtime assertion.

Examples

Example

The example below demonstrates the accept() function reading from a string.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // a valid JSON text
-    auto valid_text = R"(
+    auto valid_text = R"(
     {
         "numbers": [1, 2, 3]
     }
-    )";
+    )";
 
     // an invalid JSON text
-    auto invalid_text = R"(
+    auto invalid_text = R"(
     {
         "strings": ["extra", "comma", ]
     }
-    )";
+    )";
 
-    std::cout << std::boolalpha
-              << json::accept(valid_text) << ' '
-              << json::accept(invalid_text) << '\n';
-}
-

Output:

true false
-

See also

  • parse - deserialize from a compatible input
  • operator>> - deserialize from stream

Version history

  • Added in version 3.0.0.
  • Ignoring comments via ignore_comments added in version 3.9.0.

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 accept({ptr, ptr+len}, ...); with accept(ptr, ptr+len, ...);.

You should be warned by your compiler with a -Wdeprecated-declarations warning if you are using a deprecated function.


Last update: July 28, 2022
\ No newline at end of file + std::cout << std::boolalpha + << json::accept(valid_text) << ' ' + << json::accept(invalid_text) << '\n'; +} +

Output:

true false
+

See also

  • parse - deserialize from a compatible input
  • operator>> - deserialize from stream

Version history

  • Added in version 3.0.0.
  • Ignoring comments via ignore_comments added in version 3.9.0.

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 accept({ptr, ptr+len}, ...); with accept(ptr, ptr+len, ...);.

You should be warned by your compiler with a -Wdeprecated-declarations warning if you are using a deprecated function.


Last update: July 28, 2022
\ No newline at end of file diff --git a/api/basic_json/array/index.html b/api/basic_json/array/index.html index 7392a2946..7b6d92b10 100644 --- a/api/basic_json/array/index.html +++ b/api/basic_json/array/index.html @@ -1,25 +1,25 @@ - array - JSON for Modern C++
Skip to content

nlohmann::basic_json::array

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 [a, b, c]. If the initializer list is empty, the empty array [] 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)). 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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ array - JSON for Modern C++       

nlohmann::basic_json::array

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 [a, b, c]. If the initializer list is empty, the empty array [] 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)). 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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON arrays
-    json j_no_init_list = json::array();
-    json j_empty_init_list = json::array({});
-    json j_nonempty_init_list = json::array({1, 2, 3, 4});
-    json j_list_of_pairs = json::array({ {"one", 1}, {"two", 2} });
+    json j_no_init_list = json::array();
+    json j_empty_init_list = json::array({});
+    json j_nonempty_init_list = json::array({1, 2, 3, 4});
+    json j_list_of_pairs = json::array({ {"one", 1}, {"two", 2} });
 
     // serialize the JSON arrays
-    std::cout << j_no_init_list << '\n';
-    std::cout << j_empty_init_list << '\n';
-    std::cout << j_nonempty_init_list << '\n';
-    std::cout << j_list_of_pairs << '\n';
-}
-

Output:

[]
-[]
-[1,2,3,4]
-[["one",1],["two",2]]
-

See also

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << j_no_init_list << '\n'; + std::cout << j_empty_init_list << '\n'; + std::cout << j_nonempty_init_list << '\n'; + std::cout << j_list_of_pairs << '\n'; +} +

Output:

[]
+[]
+[1,2,3,4]
+[["one",1],["two",2]]
+

See also

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/array_t/index.html b/api/basic_json/array_t/index.html index 6ae713bf7..0d0d47e6c 100644 --- a/api/basic_json/array_t/index.html +++ b/api/basic_json/array_t/index.html @@ -1,17 +1,17 @@ - array_t - JSON for Modern C++
Skip to content

nlohmann::basic_json::array_t

using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
-

The type used to store JSON arrays.

RFC 8259 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:

std::vector<
+ array_t - JSON for Modern C++       

nlohmann::basic_json::array_t

using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
+

The type used to store JSON arrays.

RFC 8259 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:

std::vector<
   basic_json, // value_type
   std::allocator<basic_json> // allocator_type
->
-

Limits

RFC 8259 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 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 array_t* must be dereferenced.

Examples

Example

The following code shows that array_t is by default, a typedef to std::vector<nlohmann::json>.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+>
+

Limits

RFC 8259 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 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 array_t* must be dereferenced.

Examples

Example

The following code shows that array_t is by default, a typedef to std::vector<nlohmann::json>.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    std::cout << std::boolalpha << std::is_same<std::vector<json>, json::array_t>::value << std::endl;
-}
-

Output:

true
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file +int main() +{ + std::cout << std::boolalpha << std::is_same<std::vector<json>, json::array_t>::value << std::endl; +} +

Output:

true
+

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/at/index.html b/api/basic_json/at/index.html index a3a357984..d6f9e26f6 100644 --- a/api/basic_json/at/index.html +++ b/api/basic_json/at/index.html @@ -1,501 +1,501 @@ - at - JSON for Modern C++
Skip to content

nlohmann::basic_json::at

// (1)
-reference at(size_type idx);
-const_reference at(size_type idx) const;
+ at - JSON for Modern C++       

nlohmann::basic_json::at

// (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;
+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;
+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 typename object_t::key_type and 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 that is comparable with string_t using object_comparator_t. 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 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 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 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 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 if an array index in the passed JSON pointer ptr begins with '0'. See example below.
    • Throws parse_error.109 if an array index in the passed JSON pointer ptr is not a number. See example below.
    • Throws out_of_range.401 if an array index in the passed JSON pointer ptr is out of range. See example below.
    • Throws out_of_range.402 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 if the JSON pointer describes a key of an object which cannot be found. See example below.
    • Throws out_of_range.404 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: (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.

#include <iostream>
-#include <nlohmann/json.hpp>
+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 typename object_t::key_type and 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 that is comparable with string_t using object_comparator_t. 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 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 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 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 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 if an array index in the passed JSON pointer ptr begins with '0'. See example below.
    • Throws parse_error.109 if an array index in the passed JSON pointer ptr is not a number. See example below.
    • Throws out_of_range.401 if an array index in the passed JSON pointer ptr is out of range. See example below.
    • Throws out_of_range.402 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 if the JSON pointer describes a key of an object which cannot be found. See example below.
    • Throws out_of_range.404 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: (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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON array
-    json array = {"first", "2nd", "third", "fourth"};
+    json array = {"first", "2nd", "third", "fourth"};
 
     // output element at index 2 (third element)
-    std::cout << array.at(2) << '\n';
+    std::cout << array.at(2) << '\n';
 
     // change element at index 1 (second element) to "second"
-    array.at(1) = "second";
+    array.at(1) = "second";
 
     // output changed array
-    std::cout << array << '\n';
+    std::cout << array << '\n';
 
     // exception type_error.304
-    try
-    {
+    try
+    {
         // use at() on a non-array type
-        json str = "I am a string";
-        str.at(0) = "Another string";
-    }
-    catch (const json::type_error& e)
-    {
-        std::cout << e.what() << '\n';
-    }
+        json str = "I am a string";
+        str.at(0) = "Another string";
+    }
+    catch (const json::type_error& e)
+    {
+        std::cout << e.what() << '\n';
+    }
 
     // exception out_of_range.401
-    try
-    {
+    try
+    {
         // try to write beyond the array limit
-        array.at(5) = "sixth";
-    }
-    catch (const json::out_of_range& e)
-    {
-        std::cout << e.what() << '\n';
-    }
-}
-

Output:

"third"
-["first","second","third","fourth"]
-[json.exception.type_error.304] cannot use at() with string
-[json.exception.out_of_range.401] array index 5 is out of range
-
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.

#include <iostream>
-#include <nlohmann/json.hpp>
+        array.at(5) = "sixth";
+    }
+    catch (const json::out_of_range& e)
+    {
+        std::cout << e.what() << '\n';
+    }
+}
+

Output:

"third"
+["first","second","third","fourth"]
+[json.exception.type_error.304] cannot use at() with string
+[json.exception.out_of_range.401] array index 5 is out of range
+
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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON array
-    const json array = {"first", "2nd", "third", "fourth"};
+    const json array = {"first", "2nd", "third", "fourth"};
 
     // output element at index 2 (third element)
-    std::cout << array.at(2) << '\n';
+    std::cout << array.at(2) << '\n';
 
     // exception type_error.304
-    try
-    {
+    try
+    {
         // use at() on a non-array type
-        const json str = "I am a string";
-        std::cout << str.at(0) << '\n';
-    }
-    catch (const json::type_error& e)
-    {
-        std::cout << e.what() << '\n';
-    }
+        const json str = "I am a string";
+        std::cout << str.at(0) << '\n';
+    }
+    catch (const json::type_error& e)
+    {
+        std::cout << e.what() << '\n';
+    }
 
     // exception out_of_range.401
-    try
-    {
+    try
+    {
         // try to read beyond the array limit
-        std::cout << array.at(5) << '\n';
-    }
-    catch (const json::out_of_range& e)
-    {
-        std::cout << e.what() << '\n';
-    }
-}
-

Output:

"third"
-[json.exception.type_error.304] cannot use at() with string
-[json.exception.out_of_range.401] array index 5 is out of range
-
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.

#include <iostream>
-#include <nlohmann/json.hpp>
+        std::cout << array.at(5) << '\n';
+    }
+    catch (const json::out_of_range& e)
+    {
+        std::cout << e.what() << '\n';
+    }
+}
+

Output:

"third"
+[json.exception.type_error.304] cannot use at() with string
+[json.exception.out_of_range.401] array index 5 is out of range
+
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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON object
-    json object =
-    {
-        {"the good", "il buono"},
-        {"the bad", "il cattivo"},
-        {"the ugly", "il brutto"}
-    };
+    json object =
+    {
+        {"the good", "il buono"},
+        {"the bad", "il cattivo"},
+        {"the ugly", "il brutto"}
+    };
 
     // output element with key "the ugly"
-    std::cout << object.at("the ugly") << '\n';
+    std::cout << object.at("the ugly") << '\n';
 
     // change element with key "the bad"
-    object.at("the bad") = "il cattivo";
+    object.at("the bad") = "il cattivo";
 
     // output changed array
-    std::cout << object << '\n';
+    std::cout << object << '\n';
 
     // exception type_error.304
-    try
-    {
+    try
+    {
         // use at() on a non-object type
-        json str = "I am a string";
-        str.at("the good") = "Another string";
-    }
-    catch (const json::type_error& e)
-    {
-        std::cout << e.what() << '\n';
-    }
+        json str = "I am a string";
+        str.at("the good") = "Another string";
+    }
+    catch (const json::type_error& e)
+    {
+        std::cout << e.what() << '\n';
+    }
 
     // exception out_of_range.401
-    try
-    {
+    try
+    {
         // try to write at a nonexisting key
-        object.at("the fast") = "il rapido";
-    }
-    catch (const json::out_of_range& e)
-    {
-        std::cout << e.what() << '\n';
-    }
-}
-

Output:

"il brutto"
-{"the bad":"il cattivo","the good":"il buono","the ugly":"il brutto"}
-[json.exception.type_error.304] cannot use at() with string
-[json.exception.out_of_range.403] key 'the fast' not found
-
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.

#include <iostream>
-#include <nlohmann/json.hpp>
+        object.at("the fast") = "il rapido";
+    }
+    catch (const json::out_of_range& e)
+    {
+        std::cout << e.what() << '\n';
+    }
+}
+

Output:

"il brutto"
+{"the bad":"il cattivo","the good":"il buono","the ugly":"il brutto"}
+[json.exception.type_error.304] cannot use at() with string
+[json.exception.out_of_range.403] key 'the fast' not found
+
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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON object
-    const json object =
-    {
-        {"the good", "il buono"},
-        {"the bad", "il cattivo"},
-        {"the ugly", "il brutto"}
-    };
+    const json object =
+    {
+        {"the good", "il buono"},
+        {"the bad", "il cattivo"},
+        {"the ugly", "il brutto"}
+    };
 
     // output element with key "the ugly"
-    std::cout << object.at("the ugly") << '\n';
+    std::cout << object.at("the ugly") << '\n';
 
     // exception type_error.304
-    try
-    {
+    try
+    {
         // use at() on a non-object type
-        const json str = "I am a string";
-        std::cout << str.at("the good") << '\n';
-    }
-    catch (const json::type_error& e)
-    {
-        std::cout << e.what() << '\n';
-    }
+        const json str = "I am a string";
+        std::cout << str.at("the good") << '\n';
+    }
+    catch (const json::type_error& e)
+    {
+        std::cout << e.what() << '\n';
+    }
 
     // exception out_of_range.401
-    try
-    {
+    try
+    {
         // try to read from a nonexisting key
-        std::cout << object.at("the fast") << '\n';
-    }
-    catch (const json::out_of_range)
-    {
-        std::cout << "out of range" << '\n';
-    }
-}
-

Output:

"il brutto"
-[json.exception.type_error.304] cannot use at() with string
-out of range
-
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.

#include <iostream>
-#include <string_view>
-#include <nlohmann/json.hpp>
+        std::cout << object.at("the fast") << '\n';
+    }
+    catch (const json::out_of_range)
+    {
+        std::cout << "out of range" << '\n';
+    }
+}
+

Output:

"il brutto"
+[json.exception.type_error.304] cannot use at() with string
+out of range
+
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.

#include <iostream>
+#include <string_view>
+#include <nlohmann/json.hpp>
 
-using namespace std::string_view_literals;
-using json = nlohmann::json;
+using namespace std::string_view_literals;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON object
-    json object =
-    {
-        {"the good", "il buono"},
-        {"the bad", "il cattivo"},
-        {"the ugly", "il brutto"}
-    };
+    json object =
+    {
+        {"the good", "il buono"},
+        {"the bad", "il cattivo"},
+        {"the ugly", "il brutto"}
+    };
 
     // output element with key "the ugly" using string_view
-    std::cout << object.at("the ugly"sv) << '\n';
+    std::cout << object.at("the ugly"sv) << '\n';
 
     // change element with key "the bad" using string_view
-    object.at("the bad"sv) = "il cattivo";
+    object.at("the bad"sv) = "il cattivo";
 
     // output changed array
-    std::cout << object << '\n';
+    std::cout << object << '\n';
 
     // exception type_error.304
-    try
-    {
+    try
+    {
         // use at() with string_view on a non-object type
-        json str = "I am a string";
-        str.at("the good"sv) = "Another string";
-    }
-    catch (const json::type_error& e)
-    {
-        std::cout << e.what() << '\n';
-    }
+        json str = "I am a string";
+        str.at("the good"sv) = "Another string";
+    }
+    catch (const json::type_error& e)
+    {
+        std::cout << e.what() << '\n';
+    }
 
     // exception out_of_range.401
-    try
-    {
+    try
+    {
         // try to write at a nonexisting key using string_view
-        object.at("the fast"sv) = "il rapido";
-    }
-    catch (const json::out_of_range& e)
-    {
-        std::cout << e.what() << '\n';
-    }
-}
-

Output:

"il brutto"
-{"the bad":"il cattivo","the good":"il buono","the ugly":"il brutto"}
-[json.exception.type_error.304] cannot use at() with string
-[json.exception.out_of_range.403] key 'the fast' not found
-
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.

#include <iostream>
-#include <string_view>
-#include <nlohmann/json.hpp>
+        object.at("the fast"sv) = "il rapido";
+    }
+    catch (const json::out_of_range& e)
+    {
+        std::cout << e.what() << '\n';
+    }
+}
+

Output:

"il brutto"
+{"the bad":"il cattivo","the good":"il buono","the ugly":"il brutto"}
+[json.exception.type_error.304] cannot use at() with string
+[json.exception.out_of_range.403] key 'the fast' not found
+
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.

#include <iostream>
+#include <string_view>
+#include <nlohmann/json.hpp>
 
-using namespace std::string_view_literals;
-using json = nlohmann::json;
+using namespace std::string_view_literals;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON object
-    const json object =
-    {
-        {"the good", "il buono"},
-        {"the bad", "il cattivo"},
-        {"the ugly", "il brutto"}
-    };
+    const json object =
+    {
+        {"the good", "il buono"},
+        {"the bad", "il cattivo"},
+        {"the ugly", "il brutto"}
+    };
 
     // output element with key "the ugly" using string_view
-    std::cout << object.at("the ugly"sv) << '\n';
+    std::cout << object.at("the ugly"sv) << '\n';
 
     // exception type_error.304
-    try
-    {
+    try
+    {
         // use at() with string_view on a non-object type
-        const json str = "I am a string";
-        std::cout << str.at("the good"sv) << '\n';
-    }
-    catch (const json::type_error& e)
-    {
-        std::cout << e.what() << '\n';
-    }
+        const json str = "I am a string";
+        std::cout << str.at("the good"sv) << '\n';
+    }
+    catch (const json::type_error& e)
+    {
+        std::cout << e.what() << '\n';
+    }
 
     // exception out_of_range.401
-    try
-    {
+    try
+    {
         // try to read from a nonexisting key using string_view
-        std::cout << object.at("the fast"sv) << '\n';
-    }
-    catch (const json::out_of_range)
-    {
-        std::cout << "out of range" << '\n';
-    }
-}
-

Output:

"il brutto"
-[json.exception.type_error.304] cannot use at() with string
-out of range
-
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.

#include <iostream>
-#include <nlohmann/json.hpp>
+        std::cout << object.at("the fast"sv) << '\n';
+    }
+    catch (const json::out_of_range)
+    {
+        std::cout << "out of range" << '\n';
+    }
+}
+

Output:

"il brutto"
+[json.exception.type_error.304] cannot use at() with string
+out of range
+
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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
+int main()
+{
     // create a JSON value
-    json j =
-    {
-        {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
-    };
+    json j =
+    {
+        {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
+    };
 
     // read-only access
 
     // output element with JSON pointer "/number"
-    std::cout << j.at("/number"_json_pointer) << '\n';
+    std::cout << j.at("/number"_json_pointer) << '\n';
     // output element with JSON pointer "/string"
-    std::cout << j.at("/string"_json_pointer) << '\n';
+    std::cout << j.at("/string"_json_pointer) << '\n';
     // output element with JSON pointer "/array"
-    std::cout << j.at("/array"_json_pointer) << '\n';
+    std::cout << j.at("/array"_json_pointer) << '\n';
     // output element with JSON pointer "/array/1"
-    std::cout << j.at("/array/1"_json_pointer) << '\n';
+    std::cout << j.at("/array/1"_json_pointer) << '\n';
 
     // writing access
 
     // change the string
-    j.at("/string"_json_pointer) = "bar";
+    j.at("/string"_json_pointer) = "bar";
     // output the changed string
-    std::cout << j["string"] << '\n';
+    std::cout << j["string"] << '\n';
 
     // change an array element
-    j.at("/array/1"_json_pointer) = 21;
+    j.at("/array/1"_json_pointer) = 21;
     // output the changed array
-    std::cout << j["array"] << '\n';
+    std::cout << j["array"] << '\n';
 
     // out_of_range.106
-    try
-    {
+    try
+    {
         // try to use an array index with leading '0'
-        json::reference ref = j.at("/array/01"_json_pointer);
-    }
-    catch (const json::parse_error& e)
-    {
-        std::cout << e.what() << '\n';
-    }
+        json::reference ref = j.at("/array/01"_json_pointer);
+    }
+    catch (const json::parse_error& e)
+    {
+        std::cout << e.what() << '\n';
+    }
 
     // out_of_range.109
-    try
-    {
+    try
+    {
         // try to use an array index that is not a number
-        json::reference ref = j.at("/array/one"_json_pointer);
-    }
-    catch (const json::parse_error& e)
-    {
-        std::cout << e.what() << '\n';
-    }
+        json::reference ref = j.at("/array/one"_json_pointer);
+    }
+    catch (const json::parse_error& e)
+    {
+        std::cout << e.what() << '\n';
+    }
 
     // out_of_range.401
-    try
-    {
+    try
+    {
         // try to use an invalid array index
-        json::reference ref = j.at("/array/4"_json_pointer);
-    }
-    catch (const json::out_of_range& e)
-    {
-        std::cout << e.what() << '\n';
-    }
+        json::reference ref = j.at("/array/4"_json_pointer);
+    }
+    catch (const json::out_of_range& e)
+    {
+        std::cout << e.what() << '\n';
+    }
 
     // out_of_range.402
-    try
-    {
+    try
+    {
         // try to use the array index '-'
-        json::reference ref = j.at("/array/-"_json_pointer);
-    }
-    catch (const json::out_of_range& e)
-    {
-        std::cout << e.what() << '\n';
-    }
+        json::reference ref = j.at("/array/-"_json_pointer);
+    }
+    catch (const json::out_of_range& e)
+    {
+        std::cout << e.what() << '\n';
+    }
 
     // out_of_range.403
-    try
-    {
+    try
+    {
         // try to use a JSON pointer to a nonexistent object key
-        json::const_reference ref = j.at("/foo"_json_pointer);
-    }
-    catch (const json::out_of_range& e)
-    {
-        std::cout << e.what() << '\n';
-    }
+        json::const_reference ref = j.at("/foo"_json_pointer);
+    }
+    catch (const json::out_of_range& e)
+    {
+        std::cout << e.what() << '\n';
+    }
 
     // out_of_range.404
-    try
-    {
+    try
+    {
         // try to use a JSON pointer that cannot be resolved
-        json::reference ref = j.at("/number/foo"_json_pointer);
-    }
-    catch (const json::out_of_range& e)
-    {
-        std::cout << e.what() << '\n';
-    }
-}
-

Output:

1
-"foo"
-[1,2]
-2
-"bar"
-[1,21]
-[json.exception.parse_error.106] parse error: array index '01' must not begin with '0'
-[json.exception.parse_error.109] parse error: array index 'one' is not a number
-[json.exception.out_of_range.401] array index 4 is out of range
-[json.exception.out_of_range.402] array index '-' (2) is out of range
-[json.exception.out_of_range.403] key 'foo' not found
-[json.exception.out_of_range.404] unresolved reference token 'foo'
-
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.

#include <iostream>
-#include <nlohmann/json.hpp>
+        json::reference ref = j.at("/number/foo"_json_pointer);
+    }
+    catch (const json::out_of_range& e)
+    {
+        std::cout << e.what() << '\n';
+    }
+}
+

Output:

1
+"foo"
+[1,2]
+2
+"bar"
+[1,21]
+[json.exception.parse_error.106] parse error: array index '01' must not begin with '0'
+[json.exception.parse_error.109] parse error: array index 'one' is not a number
+[json.exception.out_of_range.401] array index 4 is out of range
+[json.exception.out_of_range.402] array index '-' (2) is out of range
+[json.exception.out_of_range.403] key 'foo' not found
+[json.exception.out_of_range.404] unresolved reference token 'foo'
+
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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
+int main()
+{
     // create a JSON value
-    const json j =
-    {
-        {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
-    };
+    const json j =
+    {
+        {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
+    };
 
     // read-only access
 
     // output element with JSON pointer "/number"
-    std::cout << j.at("/number"_json_pointer) << '\n';
+    std::cout << j.at("/number"_json_pointer) << '\n';
     // output element with JSON pointer "/string"
-    std::cout << j.at("/string"_json_pointer) << '\n';
+    std::cout << j.at("/string"_json_pointer) << '\n';
     // output element with JSON pointer "/array"
-    std::cout << j.at("/array"_json_pointer) << '\n';
+    std::cout << j.at("/array"_json_pointer) << '\n';
     // output element with JSON pointer "/array/1"
-    std::cout << j.at("/array/1"_json_pointer) << '\n';
+    std::cout << j.at("/array/1"_json_pointer) << '\n';
 
     // out_of_range.109
-    try
-    {
+    try
+    {
         // try to use an array index that is not a number
-        json::const_reference ref = j.at("/array/one"_json_pointer);
-    }
-    catch (const json::parse_error& e)
-    {
-        std::cout << e.what() << '\n';
-    }
+        json::const_reference ref = j.at("/array/one"_json_pointer);
+    }
+    catch (const json::parse_error& e)
+    {
+        std::cout << e.what() << '\n';
+    }
 
     // out_of_range.401
-    try
-    {
+    try
+    {
         // try to use an invalid array index
-        json::const_reference ref = j.at("/array/4"_json_pointer);
-    }
-    catch (const json::out_of_range& e)
-    {
-        std::cout << e.what() << '\n';
-    }
+        json::const_reference ref = j.at("/array/4"_json_pointer);
+    }
+    catch (const json::out_of_range& e)
+    {
+        std::cout << e.what() << '\n';
+    }
 
     // out_of_range.402
-    try
-    {
+    try
+    {
         // try to use the array index '-'
-        json::const_reference ref = j.at("/array/-"_json_pointer);
-    }
-    catch (const json::out_of_range& e)
-    {
-        std::cout << e.what() << '\n';
-    }
+        json::const_reference ref = j.at("/array/-"_json_pointer);
+    }
+    catch (const json::out_of_range& e)
+    {
+        std::cout << e.what() << '\n';
+    }
 
     // out_of_range.403
-    try
-    {
+    try
+    {
         // try to use a JSON pointer to a nonexistent object key
-        json::const_reference ref = j.at("/foo"_json_pointer);
-    }
-    catch (const json::out_of_range& e)
-    {
-        std::cout << e.what() << '\n';
-    }
+        json::const_reference ref = j.at("/foo"_json_pointer);
+    }
+    catch (const json::out_of_range& e)
+    {
+        std::cout << e.what() << '\n';
+    }
 
     // out_of_range.404
-    try
-    {
+    try
+    {
         // try to use a JSON pointer that cannot be resolved
-        json::const_reference ref = j.at("/number/foo"_json_pointer);
-    }
-    catch (const json::out_of_range& e)
-    {
-        std::cout << e.what() << '\n';
-    }
-}
-

Output:

1
-"foo"
-[1,2]
-2
-[json.exception.parse_error.109] parse error: array index 'one' is not a number
-[json.exception.out_of_range.401] array index 4 is out of range
-[json.exception.out_of_range.402] array index '-' (2) is out of range
-[json.exception.out_of_range.403] key 'foo' not found
-[json.exception.out_of_range.404] unresolved reference token 'foo'
-

See also

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.

Last update: July 31, 2022
\ No newline at end of file + json::const_reference ref = j.at("/number/foo"_json_pointer); + } + catch (const json::out_of_range& e) + { + std::cout << e.what() << '\n'; + } +} +

Output:

1
+"foo"
+[1,2]
+2
+[json.exception.parse_error.109] parse error: array index 'one' is not a number
+[json.exception.out_of_range.401] array index 4 is out of range
+[json.exception.out_of_range.402] array index '-' (2) is out of range
+[json.exception.out_of_range.403] key 'foo' not found
+[json.exception.out_of_range.404] unresolved reference token 'foo'
+

See also

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.

Last update: July 31, 2022
\ No newline at end of file diff --git a/api/basic_json/back/index.html b/api/basic_json/back/index.html index 4c5fbf170..96711e259 100644 --- a/api/basic_json/back/index.html +++ b/api/basic_json/back/index.html @@ -1,52 +1,52 @@ - back - JSON for Modern C++
Skip to content

nlohmann::basic_json::back

reference back();
+ back - JSON for Modern C++       

nlohmann::basic_json::back

reference back();
 
-const_reference back() const;
-

Returns a reference to the last element in the container. For a JSON container c, the expression c.back() is equivalent to

auto tmp = c.end();
---tmp;
-return *tmp;
-

Return value

In case of a structured type (array or object), a reference to the last 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 null, exception invalid_iterator.214 is thrown.

Complexity

Constant.

Notes

Precondition

The array or object must not be empty. Calling back on an empty array or object yields undefined behavior.

Examples

Example

The following code shows an example for back().

#include <iostream>
-#include <nlohmann/json.hpp>
+const_reference back() const;
+

Returns a reference to the last element in the container. For a JSON container c, the expression c.back() is equivalent to

auto tmp = c.end();
+--tmp;
+return *tmp;
+

Return value

In case of a structured type (array or object), a reference to the last 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 null, exception invalid_iterator.214 is thrown.

Complexity

Constant.

Notes

Precondition

The array or object must not be empty. Calling back on an empty array or object yields undefined behavior.

Examples

Example

The following code shows an example for back().

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_object_empty(json::value_t::object);
-    json j_array = {1, 2, 4, 8, 16};
-    json j_array_empty(json::value_t::array);
-    json j_string = "Hello, world";
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_object_empty(json::value_t::object);
+    json j_array = {1, 2, 4, 8, 16};
+    json j_array_empty(json::value_t::array);
+    json j_string = "Hello, world";
 
     // call back()
-    std::cout << j_boolean.back() << '\n';
-    std::cout << j_number_integer.back() << '\n';
-    std::cout << j_number_float.back() << '\n';
-    std::cout << j_object.back() << '\n';
+    std::cout << j_boolean.back() << '\n';
+    std::cout << j_number_integer.back() << '\n';
+    std::cout << j_number_float.back() << '\n';
+    std::cout << j_object.back() << '\n';
     //std::cout << j_object_empty.back() << '\n';  // undefined behavior
-    std::cout << j_array.back() << '\n';
+    std::cout << j_array.back() << '\n';
     //std::cout << j_array_empty.back() << '\n';   // undefined behavior
-    std::cout << j_string.back() << '\n';
+    std::cout << j_string.back() << '\n';
 
     // back() called on a null value
-    try
-    {
-        json j_null;
-        j_null.back();
-    }
-    catch (const json::invalid_iterator& e)
-    {
-        std::cout << e.what() << '\n';
-    }
-}
-

Output:

true
-17
-23.42
-2
-16
-"Hello, world"
-[json.exception.invalid_iterator.214] cannot get value
-

See also

  • front to access the first element

Version history

  • Added in version 1.0.0.
  • Adjusted code to return reference to binary values in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file + try + { + json j_null; + j_null.back(); + } + catch (const json::invalid_iterator& e) + { + std::cout << e.what() << '\n'; + } +} +

Output:

true
+17
+23.42
+2
+16
+"Hello, world"
+[json.exception.invalid_iterator.214] cannot get value
+

See also

  • front to access the first element

Version history

  • Added in version 1.0.0.
  • Adjusted code to return reference to binary values in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/basic_json/index.html b/api/basic_json/basic_json/index.html index bb370e9bd..b3b2bbeca 100644 --- a/api/basic_json/basic_json/index.html +++ b/api/basic_json/basic_json/index.html @@ -1,458 +1,458 @@ - (Constructor) - JSON for Modern C++
Skip to content

nlohmann::basic_json::basic_json

// (1)
-basic_json(const value_t v);
+ (Constructor) - JSON for Modern C++       

nlohmann::basic_json::basic_json

// (1)
+basic_json(const value_t v);
 
 // (2)
-basic_json(std::nullptr_t = nullptr) noexcept;
+basic_json(std::nullptr_t = nullptr) noexcept;
 
 // (3)
-template<typename CompatibleType>
-basic_json(CompatibleType&& val) noexcept(noexcept(
-           JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
-                                      std::forward<CompatibleType>(val))));
+template<typename CompatibleType>
+basic_json(CompatibleType&& val) noexcept(noexcept(
+           JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
+                                      std::forward<CompatibleType>(val))));
 
 // (4)
-template<typename BasicJsonType>
-basic_json(const BasicJsonType& val);
+template<typename BasicJsonType>
+basic_json(const BasicJsonType& val);
 
 // (5)
-basic_json(initializer_list_t init,
-           bool type_deduction = true,
-           value_t manual_type = value_t::array);
+basic_json(initializer_list_t init,
+           bool type_deduction = true,
+           value_t manual_type = value_t::array);
 
 // (6)
-basic_json(size_type cnt, const basic_json& val);
+basic_json(size_type cnt, const basic_json& val);
 
 // (7)
-basic_json(iterator first, iterator last);
-basic_json(const_iterator first, const_iterator last);
+basic_json(iterator first, iterator last);
+basic_json(const_iterator first, const_iterator last);
 
 // (8)
-basic_json(const basic_json& other);
+basic_json(const basic_json& other);
 
 // (9)
-basic_json(basic_json&& other) noexcept;
-
  1. Create an empty JSON value with a given type. The value will be default initialized with an empty value which depends on the type:

    Value type initial value
    null null
    boolean false
    string ""
    number 0
    object {}
    array []
    binary empty array

    The postcondition of this constructor can be restored by calling clear().

  2. Create a null JSON value. It either takes a null pointer as parameter (explicitly creating null) or no parameter (implicitly creating null). The passed null pointer itself is not read -- it is only used to choose the right constructor.

  3. This is a "catch all" constructor for all compatible JSON types; that is, types for which a to_json() method exists. The constructor forwards the parameter val to that method (to json_serializer<U>::to_json method with U = uncvref_t<CompatibleType>, to be exact).

    Template type CompatibleType includes, but is not limited to, the following types:

    • arrays: array_t and all kinds of compatible containers such as std::vector, std::deque, std::list, std::forward_list, std::array, std::valarray, std::set, std::unordered_set, std::multiset, and std::unordered_multiset with a value_type from which a basic_json value can be constructed.
    • objects: object_t and all kinds of compatible associative containers such as std::map, std::unordered_map, std::multimap, and std::unordered_multimap with a key_type compatible to string_t and a value_type from which a basic_json value can be constructed.
    • strings: string_t, string literals, and all compatible string containers can be used.
    • numbers: number_integer_t, number_unsigned_t, number_float_t, and all convertible number types such as int, size_t, int64_t, float or double can be used.
    • boolean: boolean_t / bool can be used.
    • binary: binary_t / std::vector<uint8_t> may be used; unfortunately because string literals cannot be distinguished from binary character arrays by the C++ type system, all types compatible with const char* will be directed to the string constructor instead. This is both for backwards compatibility, and due to the fact that a binary type is not a standard JSON type.

    See the examples below.

  4. This is a constructor for existing basic_json types. It does not hijack copy/move constructors, since the parameter has different template arguments than the current ones.

    The constructor tries to convert the internal m_value of the parameter.

  5. Creates a JSON value of type array or object from the passed initializer list init. In case type_deduction is true (default), the type of the JSON value to be created is deducted from the initializer list init according to the following rules:

    1. If the list is empty, an empty JSON object value {} is created.
    2. If the list consists of pairs whose first element is a string, a JSON object value is created where the first elements of the pairs are treated as keys and the second elements are as values.
    3. In all other cases, an array is created.

    The rules aim to create the best fit between a C++ initializer list and JSON values. The rationale is as follows:

    1. The empty initializer list is written as {} which is exactly an empty JSON object.
    2. C++ has no way of describing mapped types other than to list a list of pairs. As JSON requires that keys must be of type string, rule 2 is the weakest constraint one can pose on initializer lists to interpret them as an object.
    3. In all other cases, the initializer list could not be interpreted as JSON object type, so interpreting it as JSON array type is safe.

    With the rules described above, the following JSON values cannot be expressed by an initializer list:

    • the empty array ([]): use array(initializer_list_t) with an empty initializer list in this case
    • arrays whose elements satisfy rule 2: use array(initializer_list_t) with the same initializer list in this case

    Function array() and object() force array and object creation from initializer lists, respectively.

  6. Constructs a JSON array value by creating cnt copies of a passed value. In case cnt is 0, an empty array is created.

  7. Constructs the JSON value with the contents of the range [first, last). The semantics depends on the different types a JSON value can have:

    • In case of a null type, invalid_iterator.206 is thrown.
    • In case of other primitive types (number, boolean, or string), first must be begin() and last must be end(). In this case, the value is copied. Otherwise, invalid_iterator.204 is thrown.
    • In case of structured types (array, object), the constructor behaves as similar versions for std::vector or std::map; that is, a JSON array or object is constructed from the values in the range.
  8. Creates a copy of a given JSON value.

  9. Move constructor. Constructs a JSON value with the contents of the given value other using move semantics. It "steals" the resources from other and leaves it as JSON null value.

Template parameters

CompatibleType

a type such that:

  • CompatibleType is not derived from std::istream,
  • CompatibleType is not basic_json (to avoid hijacking copy/move constructors),
  • CompatibleType is not a different basic_json type (i.e. with different template arguments)
  • CompatibleType is not a basic_json nested type (e.g., json_pointer, iterator, etc.)
  • json_serializer<U> (with U = uncvref_t<CompatibleType>) has a to_json(basic_json_t&, CompatibleType&&) method
BasicJsonType:

a type such that:

  • BasicJsonType is a basic_json type.
  • BasicJsonType has different template arguments than basic_json_t.
U:
uncvref_t<CompatibleType>

Parameters

v (in)
the type of the value to create
val (in)
the value to be forwarded to the respective constructor
init (in)
initializer list with JSON values
type_deduction (in)
internal parameter; when set to true, the type of the JSON value is deducted from the initializer list init; when set to false, the type provided via manual_type is forced. This mode is used by the functions array(initializer_list_t) and object(initializer_list_t).
manual_type (in)
internal parameter; when type_deduction is set to false, the created JSON value will use the provided type (only value_t::array and value_t::object are valid); when type_deduction is set to true, this parameter has no effect
cnt (in)
the number of JSON copies of val to create
first (in)
begin of the range to copy from (included)
last (in)
end of the range to copy from (excluded)
other (in)
the JSON value to copy/move

Exception safety

  1. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
  2. No-throw guarantee: this constructor never throws exceptions.
  3. Depends on the called constructor. For types directly supported by the library (i.e., all types for which no to_json() function was provided), strong guarantee holds: if an exception is thrown, there are no changes to any JSON value.
  4. Depends on the called constructor. For types directly supported by the library (i.e., all types for which no to_json() function was provided), strong guarantee holds: if an exception is thrown, there are no changes to any JSON value.
  5. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
  6. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
  7. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
  8. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
  9. No-throw guarantee: this constructor never throws exceptions.

Exceptions

  1. (none)
  2. The function does not throw exceptions.
  3. (none)
  4. (none)
  5. The function can throw the following exceptions:
    • Throws type_error.301 if type_deduction is false, manual_type is value_t::object, but init contains an element which is not a pair whose first element is a string. In this case, the constructor could not create an object. If type_deduction would have been true, an array would have been created. See object(initializer_list_t) for an example.
  6. (none)
  7. The function can throw the following exceptions:
    • Throws invalid_iterator.201 if iterators first and last are not compatible (i.e., do not belong to the same JSON value). In this case, the range [first, last) is undefined.
    • Throws invalid_iterator.204 if iterators first and last belong to a primitive type (number, boolean, or string), but first does not point to the first element anymore. In this case, the range [first, last) is undefined. See example code below.
    • Throws invalid_iterator.206 if iterators first and last belong to a null value. In this case, the range [first, last) is undefined.
  8. (none)
  9. The function does not throw exceptions.

Complexity

  1. Constant.
  2. Constant.
  3. Usually linear in the size of the passed val, also depending on the implementation of the called to_json() method.
  4. Usually linear in the size of the passed val, also depending on the implementation of the called to_json() method.
  5. Linear in the size of the initializer list init.
  6. Linear in cnt.
  7. Linear in distance between first and last.
  8. Linear in the size of other.
  9. Constant.

Notes

  • Overload 5:

    Empty initializer list

    When used without parentheses around an empty initializer list, basic_json() is called instead of this function, yielding the JSON null value.

  • Overload 7:

    Preconditions

    • Iterators first and last must be initialized. **This precondition is enforced with a runtime assertion.
    • Range [first, last) is valid. Usually, this precondition cannot be checked efficiently. Only certain edge cases are detected; see the description of the exceptions above. A violation of this precondition yields undefined behavior.

    Runtime assertion

    A precondition is enforced with a runtime assertion.

  • Overload 8:

    Postcondition

    *this == other

  • Overload 9:

    Postconditions

    • `*this has the same value as other before the call.
    • other is a JSON null value

Examples

Example: (1) create an empty value with a given type

The following code shows the constructor for different value_t values.

#include <iostream>
-#include <nlohmann/json.hpp>
+basic_json(basic_json&& other) noexcept;
+
  1. Create an empty JSON value with a given type. The value will be default initialized with an empty value which depends on the type:

    Value type initial value
    null null
    boolean false
    string ""
    number 0
    object {}
    array []
    binary empty array

    The postcondition of this constructor can be restored by calling clear().

  2. Create a null JSON value. It either takes a null pointer as parameter (explicitly creating null) or no parameter (implicitly creating null). The passed null pointer itself is not read -- it is only used to choose the right constructor.

  3. This is a "catch all" constructor for all compatible JSON types; that is, types for which a to_json() method exists. The constructor forwards the parameter val to that method (to json_serializer<U>::to_json method with U = uncvref_t<CompatibleType>, to be exact).

    Template type CompatibleType includes, but is not limited to, the following types:

    • arrays: array_t and all kinds of compatible containers such as std::vector, std::deque, std::list, std::forward_list, std::array, std::valarray, std::set, std::unordered_set, std::multiset, and std::unordered_multiset with a value_type from which a basic_json value can be constructed.
    • objects: object_t and all kinds of compatible associative containers such as std::map, std::unordered_map, std::multimap, and std::unordered_multimap with a key_type compatible to string_t and a value_type from which a basic_json value can be constructed.
    • strings: string_t, string literals, and all compatible string containers can be used.
    • numbers: number_integer_t, number_unsigned_t, number_float_t, and all convertible number types such as int, size_t, int64_t, float or double can be used.
    • boolean: boolean_t / bool can be used.
    • binary: binary_t / std::vector<uint8_t> may be used; unfortunately because string literals cannot be distinguished from binary character arrays by the C++ type system, all types compatible with const char* will be directed to the string constructor instead. This is both for backwards compatibility, and due to the fact that a binary type is not a standard JSON type.

    See the examples below.

  4. This is a constructor for existing basic_json types. It does not hijack copy/move constructors, since the parameter has different template arguments than the current ones.

    The constructor tries to convert the internal m_value of the parameter.

  5. Creates a JSON value of type array or object from the passed initializer list init. In case type_deduction is true (default), the type of the JSON value to be created is deducted from the initializer list init according to the following rules:

    1. If the list is empty, an empty JSON object value {} is created.
    2. If the list consists of pairs whose first element is a string, a JSON object value is created where the first elements of the pairs are treated as keys and the second elements are as values.
    3. In all other cases, an array is created.

    The rules aim to create the best fit between a C++ initializer list and JSON values. The rationale is as follows:

    1. The empty initializer list is written as {} which is exactly an empty JSON object.
    2. C++ has no way of describing mapped types other than to list a list of pairs. As JSON requires that keys must be of type string, rule 2 is the weakest constraint one can pose on initializer lists to interpret them as an object.
    3. In all other cases, the initializer list could not be interpreted as JSON object type, so interpreting it as JSON array type is safe.

    With the rules described above, the following JSON values cannot be expressed by an initializer list:

    • the empty array ([]): use array(initializer_list_t) with an empty initializer list in this case
    • arrays whose elements satisfy rule 2: use array(initializer_list_t) with the same initializer list in this case

    Function array() and object() force array and object creation from initializer lists, respectively.

  6. Constructs a JSON array value by creating cnt copies of a passed value. In case cnt is 0, an empty array is created.

  7. Constructs the JSON value with the contents of the range [first, last). The semantics depends on the different types a JSON value can have:

    • In case of a null type, invalid_iterator.206 is thrown.
    • In case of other primitive types (number, boolean, or string), first must be begin() and last must be end(). In this case, the value is copied. Otherwise, invalid_iterator.204 is thrown.
    • In case of structured types (array, object), the constructor behaves as similar versions for std::vector or std::map; that is, a JSON array or object is constructed from the values in the range.
  8. Creates a copy of a given JSON value.

  9. Move constructor. Constructs a JSON value with the contents of the given value other using move semantics. It "steals" the resources from other and leaves it as JSON null value.

Template parameters

CompatibleType

a type such that:

  • CompatibleType is not derived from std::istream,
  • CompatibleType is not basic_json (to avoid hijacking copy/move constructors),
  • CompatibleType is not a different basic_json type (i.e. with different template arguments)
  • CompatibleType is not a basic_json nested type (e.g., json_pointer, iterator, etc.)
  • json_serializer<U> (with U = uncvref_t<CompatibleType>) has a to_json(basic_json_t&, CompatibleType&&) method
BasicJsonType:

a type such that:

  • BasicJsonType is a basic_json type.
  • BasicJsonType has different template arguments than basic_json_t.
U:
uncvref_t<CompatibleType>

Parameters

v (in)
the type of the value to create
val (in)
the value to be forwarded to the respective constructor
init (in)
initializer list with JSON values
type_deduction (in)
internal parameter; when set to true, the type of the JSON value is deducted from the initializer list init; when set to false, the type provided via manual_type is forced. This mode is used by the functions array(initializer_list_t) and object(initializer_list_t).
manual_type (in)
internal parameter; when type_deduction is set to false, the created JSON value will use the provided type (only value_t::array and value_t::object are valid); when type_deduction is set to true, this parameter has no effect
cnt (in)
the number of JSON copies of val to create
first (in)
begin of the range to copy from (included)
last (in)
end of the range to copy from (excluded)
other (in)
the JSON value to copy/move

Exception safety

  1. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
  2. No-throw guarantee: this constructor never throws exceptions.
  3. Depends on the called constructor. For types directly supported by the library (i.e., all types for which no to_json() function was provided), strong guarantee holds: if an exception is thrown, there are no changes to any JSON value.
  4. Depends on the called constructor. For types directly supported by the library (i.e., all types for which no to_json() function was provided), strong guarantee holds: if an exception is thrown, there are no changes to any JSON value.
  5. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
  6. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
  7. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
  8. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
  9. No-throw guarantee: this constructor never throws exceptions.

Exceptions

  1. (none)
  2. The function does not throw exceptions.
  3. (none)
  4. (none)
  5. The function can throw the following exceptions:
    • Throws type_error.301 if type_deduction is false, manual_type is value_t::object, but init contains an element which is not a pair whose first element is a string. In this case, the constructor could not create an object. If type_deduction would have been true, an array would have been created. See object(initializer_list_t) for an example.
  6. (none)
  7. The function can throw the following exceptions:
    • Throws invalid_iterator.201 if iterators first and last are not compatible (i.e., do not belong to the same JSON value). In this case, the range [first, last) is undefined.
    • Throws invalid_iterator.204 if iterators first and last belong to a primitive type (number, boolean, or string), but first does not point to the first element anymore. In this case, the range [first, last) is undefined. See example code below.
    • Throws invalid_iterator.206 if iterators first and last belong to a null value. In this case, the range [first, last) is undefined.
  8. (none)
  9. The function does not throw exceptions.

Complexity

  1. Constant.
  2. Constant.
  3. Usually linear in the size of the passed val, also depending on the implementation of the called to_json() method.
  4. Usually linear in the size of the passed val, also depending on the implementation of the called to_json() method.
  5. Linear in the size of the initializer list init.
  6. Linear in cnt.
  7. Linear in distance between first and last.
  8. Linear in the size of other.
  9. Constant.

Notes

  • Overload 5:

    Empty initializer list

    When used without parentheses around an empty initializer list, basic_json() is called instead of this function, yielding the JSON null value.

  • Overload 7:

    Preconditions

    • Iterators first and last must be initialized. **This precondition is enforced with a runtime assertion.
    • Range [first, last) is valid. Usually, this precondition cannot be checked efficiently. Only certain edge cases are detected; see the description of the exceptions above. A violation of this precondition yields undefined behavior.

    Runtime assertion

    A precondition is enforced with a runtime assertion.

  • Overload 8:

    Postcondition

    *this == other

  • Overload 9:

    Postconditions

    • `*this has the same value as other before the call.
    • other is a JSON null value

Examples

Example: (1) create an empty value with a given type

The following code shows the constructor for different value_t values.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create the different JSON values with default values
-    json j_null(json::value_t::null);
-    json j_boolean(json::value_t::boolean);
-    json j_number_integer(json::value_t::number_integer);
-    json j_number_float(json::value_t::number_float);
-    json j_object(json::value_t::object);
-    json j_array(json::value_t::array);
-    json j_string(json::value_t::string);
+    json j_null(json::value_t::null);
+    json j_boolean(json::value_t::boolean);
+    json j_number_integer(json::value_t::number_integer);
+    json j_number_float(json::value_t::number_float);
+    json j_object(json::value_t::object);
+    json j_array(json::value_t::array);
+    json j_string(json::value_t::string);
 
     // serialize the JSON values
-    std::cout << j_null << '\n';
-    std::cout << j_boolean << '\n';
-    std::cout << j_number_integer << '\n';
-    std::cout << j_number_float << '\n';
-    std::cout << j_object << '\n';
-    std::cout << j_array << '\n';
-    std::cout << j_string << '\n';
-}
-

Output:

null
-false
-0
-0.0
-{}
-[]
-""
-
Example: (2) create a null object

The following code shows the constructor with and without a null pointer parameter.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << j_null << '\n';
+    std::cout << j_boolean << '\n';
+    std::cout << j_number_integer << '\n';
+    std::cout << j_number_float << '\n';
+    std::cout << j_object << '\n';
+    std::cout << j_array << '\n';
+    std::cout << j_string << '\n';
+}
+

Output:

null
+false
+0
+0.0
+{}
+[]
+""
+
Example: (2) create a null object

The following code shows the constructor with and without a null pointer parameter.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // implicitly create a JSON null value
-    json j1;
+    json j1;
 
     // explicitly create a JSON null value
-    json j2(nullptr);
+    json j2(nullptr);
 
     // serialize the JSON null value
-    std::cout << j1 << '\n' << j2 << '\n';
-}
-

Output:

null
-null
-
Example: (3) create a JSON value from compatible types

The following code shows the constructor with several compatible types.

#include <iostream>
-#include <deque>
-#include <list>
-#include <forward_list>
-#include <set>
-#include <unordered_map>
-#include <unordered_set>
-#include <valarray>
-#include <nlohmann/json.hpp>
+    std::cout << j1 << '\n' << j2 << '\n';
+}
+

Output:

null
+null
+
Example: (3) create a JSON value from compatible types

The following code shows the constructor with several compatible types.

#include <iostream>
+#include <deque>
+#include <list>
+#include <forward_list>
+#include <set>
+#include <unordered_map>
+#include <unordered_set>
+#include <valarray>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // ============
     // object types
     // ============
 
     // create an object from an object_t value
-    json::object_t object_value = { {"one", 1}, {"two", 2} };
-    json j_object_t(object_value);
+    json::object_t object_value = { {"one", 1}, {"two", 2} };
+    json j_object_t(object_value);
 
     // create an object from std::map
-    std::map<std::string, int> c_map
-    {
-        {"one", 1}, {"two", 2}, {"three", 3}
-    };
-    json j_map(c_map);
+    std::map<std::string, int> c_map
+    {
+        {"one", 1}, {"two", 2}, {"three", 3}
+    };
+    json j_map(c_map);
 
     // create an object from std::unordered_map
-    std::unordered_map<const char*, double> c_umap
-    {
-        {"one", 1.2}, {"two", 2.3}, {"three", 3.4}
-    };
-    json j_umap(c_umap);
+    std::unordered_map<const char*, double> c_umap
+    {
+        {"one", 1.2}, {"two", 2.3}, {"three", 3.4}
+    };
+    json j_umap(c_umap);
 
     // create an object from std::multimap
-    std::multimap<std::string, bool> c_mmap
-    {
-        {"one", true}, {"two", true}, {"three", false}, {"three", true}
-    };
+    std::multimap<std::string, bool> c_mmap
+    {
+        {"one", true}, {"two", true}, {"three", false}, {"three", true}
+    };
     json j_mmap(c_mmap); // only one entry for key "three" is used
 
     // create an object from std::unordered_multimap
-    std::unordered_multimap<std::string, bool> c_ummap
-    {
-        {"one", true}, {"two", true}, {"three", false}, {"three", true}
-    };
+    std::unordered_multimap<std::string, bool> c_ummap
+    {
+        {"one", true}, {"two", true}, {"three", false}, {"three", true}
+    };
     json j_ummap(c_ummap); // only one entry for key "three" is used
 
     // serialize the JSON objects
-    std::cout << j_object_t << '\n';
-    std::cout << j_map << '\n';
-    std::cout << j_umap << '\n';
-    std::cout << j_mmap << '\n';
-    std::cout << j_ummap << "\n\n";
+    std::cout << j_object_t << '\n';
+    std::cout << j_map << '\n';
+    std::cout << j_umap << '\n';
+    std::cout << j_mmap << '\n';
+    std::cout << j_ummap << "\n\n";
 
     // ===========
     // array types
     // ===========
 
     // create an array from an array_t value
-    json::array_t array_value = {"one", "two", 3, 4.5, false};
-    json j_array_t(array_value);
+    json::array_t array_value = {"one", "two", 3, 4.5, false};
+    json j_array_t(array_value);
 
     // create an array from std::vector
-    std::vector<int> c_vector {1, 2, 3, 4};
-    json j_vec(c_vector);
+    std::vector<int> c_vector {1, 2, 3, 4};
+    json j_vec(c_vector);
 
     // create an array from std::valarray
-    std::valarray<short> c_valarray {10, 9, 8, 7};
-    json j_valarray(c_valarray);
+    std::valarray<short> c_valarray {10, 9, 8, 7};
+    json j_valarray(c_valarray);
 
     // create an array from std::deque
-    std::deque<double> c_deque {1.2, 2.3, 3.4, 5.6};
-    json j_deque(c_deque);
+    std::deque<double> c_deque {1.2, 2.3, 3.4, 5.6};
+    json j_deque(c_deque);
 
     // create an array from std::list
-    std::list<bool> c_list {true, true, false, true};
-    json j_list(c_list);
+    std::list<bool> c_list {true, true, false, true};
+    json j_list(c_list);
 
     // create an array from std::forward_list
-    std::forward_list<std::int64_t> c_flist {12345678909876, 23456789098765, 34567890987654, 45678909876543};
-    json j_flist(c_flist);
+    std::forward_list<std::int64_t> c_flist {12345678909876, 23456789098765, 34567890987654, 45678909876543};
+    json j_flist(c_flist);
 
     // create an array from std::array
-    std::array<unsigned long, 4> c_array {{1, 2, 3, 4}};
-    json j_array(c_array);
+    std::array<unsigned long, 4> c_array {{1, 2, 3, 4}};
+    json j_array(c_array);
 
     // create an array from std::set
-    std::set<std::string> c_set {"one", "two", "three", "four", "one"};
+    std::set<std::string> c_set {"one", "two", "three", "four", "one"};
     json j_set(c_set); // only one entry for "one" is used
 
     // create an array from std::unordered_set
-    std::unordered_set<std::string> c_uset {"one", "two", "three", "four", "one"};
+    std::unordered_set<std::string> c_uset {"one", "two", "three", "four", "one"};
     json j_uset(c_uset); // only one entry for "one" is used
 
     // create an array from std::multiset
-    std::multiset<std::string> c_mset {"one", "two", "one", "four"};
+    std::multiset<std::string> c_mset {"one", "two", "one", "four"};
     json j_mset(c_mset); // both entries for "one" are used
 
     // create an array from std::unordered_multiset
-    std::unordered_multiset<std::string> c_umset {"one", "two", "one", "four"};
+    std::unordered_multiset<std::string> c_umset {"one", "two", "one", "four"};
     json j_umset(c_umset); // both entries for "one" are used
 
     // serialize the JSON arrays
-    std::cout << j_array_t << '\n';
-    std::cout << j_vec << '\n';
-    std::cout << j_valarray << '\n';
-    std::cout << j_deque << '\n';
-    std::cout << j_list << '\n';
-    std::cout << j_flist << '\n';
-    std::cout << j_array << '\n';
-    std::cout << j_set << '\n';
-    std::cout << j_uset << '\n';
-    std::cout << j_mset << '\n';
-    std::cout << j_umset << "\n\n";
+    std::cout << j_array_t << '\n';
+    std::cout << j_vec << '\n';
+    std::cout << j_valarray << '\n';
+    std::cout << j_deque << '\n';
+    std::cout << j_list << '\n';
+    std::cout << j_flist << '\n';
+    std::cout << j_array << '\n';
+    std::cout << j_set << '\n';
+    std::cout << j_uset << '\n';
+    std::cout << j_mset << '\n';
+    std::cout << j_umset << "\n\n";
 
     // ============
     // string types
     // ============
 
     // create string from a string_t value
-    json::string_t string_value = "The quick brown fox jumps over the lazy dog.";
-    json j_string_t(string_value);
+    json::string_t string_value = "The quick brown fox jumps over the lazy dog.";
+    json j_string_t(string_value);
 
     // create a JSON string directly from a string literal
-    json j_string_literal("The quick brown fox jumps over the lazy dog.");
+    json j_string_literal("The quick brown fox jumps over the lazy dog.");
 
     // create string from std::string
-    std::string s_stdstring = "The quick brown fox jumps over the lazy dog.";
-    json j_stdstring(s_stdstring);
+    std::string s_stdstring = "The quick brown fox jumps over the lazy dog.";
+    json j_stdstring(s_stdstring);
 
     // serialize the JSON strings
-    std::cout << j_string_t << '\n';
-    std::cout << j_string_literal << '\n';
-    std::cout << j_stdstring << "\n\n";
+    std::cout << j_string_t << '\n';
+    std::cout << j_string_literal << '\n';
+    std::cout << j_stdstring << "\n\n";
 
     // ============
     // number types
     // ============
 
     // create a JSON number from number_integer_t
-    json::number_integer_t value_integer_t = -42;
-    json j_integer_t(value_integer_t);
+    json::number_integer_t value_integer_t = -42;
+    json j_integer_t(value_integer_t);
 
     // create a JSON number from number_unsigned_t
-    json::number_integer_t value_unsigned_t = 17;
-    json j_unsigned_t(value_unsigned_t);
+    json::number_integer_t value_unsigned_t = 17;
+    json j_unsigned_t(value_unsigned_t);
 
     // create a JSON number from an anonymous enum
-    enum { enum_value = 17 };
-    json j_enum(enum_value);
+    enum { enum_value = 17 };
+    json j_enum(enum_value);
 
     // create values of different integer types
-    short n_short = 42;
-    int n_int = -23;
-    long n_long = 1024;
-    int_least32_t n_int_least32_t = -17;
-    uint8_t n_uint8_t = 8;
+    short n_short = 42;
+    int n_int = -23;
+    long n_long = 1024;
+    int_least32_t n_int_least32_t = -17;
+    uint8_t n_uint8_t = 8;
 
     // create (integer) JSON numbers
-    json j_short(n_short);
-    json j_int(n_int);
-    json j_long(n_long);
-    json j_int_least32_t(n_int_least32_t);
-    json j_uint8_t(n_uint8_t);
+    json j_short(n_short);
+    json j_int(n_int);
+    json j_long(n_long);
+    json j_int_least32_t(n_int_least32_t);
+    json j_uint8_t(n_uint8_t);
 
     // create values of different floating-point types
-    json::number_float_t v_ok = 3.141592653589793;
-    json::number_float_t v_nan = NAN;
-    json::number_float_t v_infinity = INFINITY;
+    json::number_float_t v_ok = 3.141592653589793;
+    json::number_float_t v_nan = NAN;
+    json::number_float_t v_infinity = INFINITY;
 
     // create values of different floating-point types
-    float n_float = 42.23;
-    float n_float_nan = 1.0f / 0.0f;
-    double n_double = 23.42;
+    float n_float = 42.23;
+    float n_float_nan = 1.0f / 0.0f;
+    double n_double = 23.42;
 
     // create (floating point) JSON numbers
-    json j_ok(v_ok);
-    json j_nan(v_nan);
-    json j_infinity(v_infinity);
-    json j_float(n_float);
-    json j_float_nan(n_float_nan);
-    json j_double(n_double);
+    json j_ok(v_ok);
+    json j_nan(v_nan);
+    json j_infinity(v_infinity);
+    json j_float(n_float);
+    json j_float_nan(n_float_nan);
+    json j_double(n_double);
 
     // serialize the JSON numbers
-    std::cout << j_integer_t << '\n';
-    std::cout << j_unsigned_t << '\n';
-    std::cout << j_enum << '\n';
-    std::cout << j_short << '\n';
-    std::cout << j_int << '\n';
-    std::cout << j_long << '\n';
-    std::cout << j_int_least32_t << '\n';
-    std::cout << j_uint8_t << '\n';
-    std::cout << j_ok << '\n';
-    std::cout << j_nan << '\n';
-    std::cout << j_infinity << '\n';
-    std::cout << j_float << '\n';
-    std::cout << j_float_nan << '\n';
-    std::cout << j_double << "\n\n";
+    std::cout << j_integer_t << '\n';
+    std::cout << j_unsigned_t << '\n';
+    std::cout << j_enum << '\n';
+    std::cout << j_short << '\n';
+    std::cout << j_int << '\n';
+    std::cout << j_long << '\n';
+    std::cout << j_int_least32_t << '\n';
+    std::cout << j_uint8_t << '\n';
+    std::cout << j_ok << '\n';
+    std::cout << j_nan << '\n';
+    std::cout << j_infinity << '\n';
+    std::cout << j_float << '\n';
+    std::cout << j_float_nan << '\n';
+    std::cout << j_double << "\n\n";
 
     // =============
     // boolean types
     // =============
 
     // create boolean values
-    json j_truth = true;
-    json j_falsity = false;
+    json j_truth = true;
+    json j_falsity = false;
 
     // serialize the JSON booleans
-    std::cout << j_truth << '\n';
-    std::cout << j_falsity << '\n';
-}
-

Output:

{"one":1,"two":2}
-{"one":1,"three":3,"two":2}
-{"one":1.2,"three":3.4,"two":2.3}
-{"one":true,"three":false,"two":true}
-{"one":true,"three":false,"two":true}
+    std::cout << j_truth << '\n';
+    std::cout << j_falsity << '\n';
+}
+

Output:

{"one":1,"two":2}
+{"one":1,"three":3,"two":2}
+{"one":1.2,"three":3.4,"two":2.3}
+{"one":true,"three":false,"two":true}
+{"one":true,"three":false,"two":true}
 
-["one","two",3,4.5,false]
-[1,2,3,4]
-[10,9,8,7]
-[1.2,2.3,3.4,5.6]
-[true,true,false,true]
-[12345678909876,23456789098765,34567890987654,45678909876543]
-[1,2,3,4]
-["four","one","three","two"]
-["four","three","two","one"]
-["four","one","one","two"]
-["four","two","one","one"]
+["one","two",3,4.5,false]
+[1,2,3,4]
+[10,9,8,7]
+[1.2,2.3,3.4,5.6]
+[true,true,false,true]
+[12345678909876,23456789098765,34567890987654,45678909876543]
+[1,2,3,4]
+["four","one","three","two"]
+["four","three","two","one"]
+["four","one","one","two"]
+["four","two","one","one"]
 
-"The quick brown fox jumps over the lazy dog."
-"The quick brown fox jumps over the lazy dog."
-"The quick brown fox jumps over the lazy dog."
+"The quick brown fox jumps over the lazy dog."
+"The quick brown fox jumps over the lazy dog."
+"The quick brown fox jumps over the lazy dog."
 
--42
-17
-17
-42
--23
-1024
--17
-8
-3.141592653589793
-null
-null
-42.22999954223633
-null
-23.42
+-42
+17
+17
+42
+-23
+1024
+-17
+8
+3.141592653589793
+null
+null
+42.22999954223633
+null
+23.42
 
-true
-false
-

Note the output is platform-dependent.

Example: (5) create a container (array or object) from an initializer list

The example below shows how JSON values are created from initializer lists.

#include <iostream>
-#include <nlohmann/json.hpp>
+true
+false
+

Note the output is platform-dependent.

Example: (5) create a container (array or object) from an initializer list

The example below shows how JSON values are created from initializer lists.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_empty_init_list = json({});
-    json j_object = { {"one", 1}, {"two", 2} };
-    json j_array = {1, 2, 3, 4};
-    json j_nested_object = { {"one", {1}}, {"two", {1, 2}} };
-    json j_nested_array = { {{1}, "one"}, {{1, 2}, "two"} };
+    json j_empty_init_list = json({});
+    json j_object = { {"one", 1}, {"two", 2} };
+    json j_array = {1, 2, 3, 4};
+    json j_nested_object = { {"one", {1}}, {"two", {1, 2}} };
+    json j_nested_array = { {{1}, "one"}, {{1, 2}, "two"} };
 
     // serialize the JSON value
-    std::cout << j_empty_init_list << '\n';
-    std::cout << j_object << '\n';
-    std::cout << j_array << '\n';
-    std::cout << j_nested_object << '\n';
-    std::cout << j_nested_array << '\n';
-}
-

Output:

{}
-{"one":1,"two":2}
-[1,2,3,4]
-{"one":[1],"two":[1,2]}
-[[[1],"one"],[[1,2],"two"]]
-
Example: (6) construct an array with count copies of given value

The following code shows examples for creating arrays with several copies of a given value.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << j_empty_init_list << '\n';
+    std::cout << j_object << '\n';
+    std::cout << j_array << '\n';
+    std::cout << j_nested_object << '\n';
+    std::cout << j_nested_array << '\n';
+}
+

Output:

{}
+{"one":1,"two":2}
+[1,2,3,4]
+{"one":[1],"two":[1,2]}
+[[[1],"one"],[[1,2],"two"]]
+
Example: (6) construct an array with count copies of given value

The following code shows examples for creating arrays with several copies of a given value.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create an array by creating copies of a JSON value
-    json value = "Hello";
-    json array_0 = json(0, value);
-    json array_1 = json(1, value);
-    json array_5 = json(5, value);
+    json value = "Hello";
+    json array_0 = json(0, value);
+    json array_1 = json(1, value);
+    json array_5 = json(5, value);
 
     // serialize the JSON arrays
-    std::cout << array_0 << '\n';
-    std::cout << array_1 << '\n';
-    std::cout << array_5 << '\n';
-}
-

Output:

[]
-["Hello"]
-["Hello","Hello","Hello","Hello","Hello"]
-
Example: (7) construct a JSON container given an iterator range

The example below shows several ways to create JSON values by specifying a subrange with iterators.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << array_0 << '\n';
+    std::cout << array_1 << '\n';
+    std::cout << array_5 << '\n';
+}
+

Output:

[]
+["Hello"]
+["Hello","Hello","Hello","Hello","Hello"]
+
Example: (7) construct a JSON container given an iterator range

The example below shows several ways to create JSON values by specifying a subrange with iterators.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_array = {"alpha", "bravo", "charly", "delta", "easy"};
-    json j_number = 42;
-    json j_object = {{"one", "eins"}, {"two", "zwei"}};
+    json j_array = {"alpha", "bravo", "charly", "delta", "easy"};
+    json j_number = 42;
+    json j_object = {{"one", "eins"}, {"two", "zwei"}};
 
     // create copies using iterators
-    json j_array_range(j_array.begin() + 1, j_array.end() - 2);
-    json j_number_range(j_number.begin(), j_number.end());
-    json j_object_range(j_object.begin(), j_object.find("two"));
+    json j_array_range(j_array.begin() + 1, j_array.end() - 2);
+    json j_number_range(j_number.begin(), j_number.end());
+    json j_object_range(j_object.begin(), j_object.find("two"));
 
     // serialize the values
-    std::cout << j_array_range << '\n';
-    std::cout << j_number_range << '\n';
-    std::cout << j_object_range << '\n';
+    std::cout << j_array_range << '\n';
+    std::cout << j_number_range << '\n';
+    std::cout << j_object_range << '\n';
 
     // example for an exception
-    try
-    {
-        json j_invalid(j_number.begin() + 1, j_number.end());
-    }
-    catch (const json::invalid_iterator& e)
-    {
-        std::cout << e.what() << '\n';
-    }
-}
-

Output:

["bravo","charly"]
-42
-{"one":"eins"}
-[json.exception.invalid_iterator.204] iterators out of range
-
Example: (8) copy constructor

The following code shows an example for the copy constructor.

#include <iostream>
-#include <nlohmann/json.hpp>
+    try
+    {
+        json j_invalid(j_number.begin() + 1, j_number.end());
+    }
+    catch (const json::invalid_iterator& e)
+    {
+        std::cout << e.what() << '\n';
+    }
+}
+

Output:

["bravo","charly"]
+42
+{"one":"eins"}
+[json.exception.invalid_iterator.204] iterators out of range
+
Example: (8) copy constructor

The following code shows an example for the copy constructor.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON array
-    json j1 = {"one", "two", 3, 4.5, false};
+    json j1 = {"one", "two", 3, 4.5, false};
 
     // create a copy
-    json j2(j1);
+    json j2(j1);
 
     // serialize the JSON array
-    std::cout << j1 << " = " << j2 << '\n';
-    std::cout << std::boolalpha << (j1 == j2) << '\n';
-}
-

Output:

["one","two",3,4.5,false] = ["one","two",3,4.5,false]
-true
-
Example: (9) move constructor

The code below shows the move constructor explicitly called via std::move.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << j1 << " = " << j2 << '\n';
+    std::cout << std::boolalpha << (j1 == j2) << '\n';
+}
+

Output:

["one","two",3,4.5,false] = ["one","two",3,4.5,false]
+true
+
Example: (9) move constructor

The code below shows the move constructor explicitly called via std::move.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON value
-    json a = 23;
+    json a = 23;
 
     // move contents of a to b
-    json b(std::move(a));
+    json b(std::move(a));
 
     // serialize the JSON arrays
-    std::cout << a << '\n';
-    std::cout << b << '\n';
-}
-

Output:

null
-23
-

Version history

  1. Since version 1.0.0.
  2. Since version 1.0.0.
  3. Since version 2.1.0.
  4. Since version 3.2.0.
  5. Since version 1.0.0.
  6. Since version 1.0.0.
  7. Since version 1.0.0.
  8. Since version 1.0.0.
  9. Since version 1.0.0.

Last update: July 29, 2022
\ No newline at end of file + std::cout << a << '\n'; + std::cout << b << '\n'; +} +

Output:

null
+23
+

Version history

  1. Since version 1.0.0.
  2. Since version 1.0.0.
  3. Since version 2.1.0.
  4. Since version 3.2.0.
  5. Since version 1.0.0.
  6. Since version 1.0.0.
  7. Since version 1.0.0.
  8. Since version 1.0.0.
  9. Since version 1.0.0.

Last update: July 29, 2022
\ No newline at end of file diff --git a/api/basic_json/begin/index.html b/api/basic_json/begin/index.html index 2ca7fb510..15159e353 100644 --- a/api/basic_json/begin/index.html +++ b/api/basic_json/begin/index.html @@ -1,20 +1,20 @@ - begin - JSON for Modern C++
Skip to content

nlohmann::basic_json::begin

iterator begin() noexcept;
-const_iterator begin() const noexcept;
-

Returns an iterator to the first element.

Illustration from cppreference.com

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().

#include <iostream>
-#include <nlohmann/json.hpp>
+ begin - JSON for Modern C++       

nlohmann::basic_json::begin

iterator begin() noexcept;
+const_iterator begin() const noexcept;
+

Returns an iterator to the first element.

Illustration from cppreference.com

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().

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create an array value
-    json array = {1, 2, 3, 4, 5};
+    json array = {1, 2, 3, 4, 5};
 
     // get an iterator to the first element
-    json::iterator it = array.begin();
+    json::iterator it = array.begin();
 
     // serialize the element that the iterator points to
-    std::cout << *it << '\n';
-}
-

Output:

1
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << *it << '\n'; +} +

Output:

1
+

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/binary/index.html b/api/basic_json/binary/index.html index a42ba34d8..78945f5b0 100644 --- a/api/basic_json/binary/index.html +++ b/api/basic_json/binary/index.html @@ -1,27 +1,27 @@ - binary - JSON for Modern C++
Skip to content

nlohmann::basic_json::binary

// (1)
-static basic_json binary(const typename binary_t::container_type& init);
-static basic_json binary(typename binary_t::container_type&& init);
+ binary - JSON for Modern C++       

nlohmann::basic_json::binary

// (1)
+static basic_json binary(const typename binary_t::container_type& init);
+static basic_json binary(typename binary_t::container_type&& init);
 
 // (2)
-static basic_json binary(const typename binary_t::container_type& init,
-                         std::uint8_t subtype);
-static basic_json binary(typename binary_t::container_type&& init,
-                         std::uint8_t subtype);
-
  1. Creates a JSON binary array value from a given binary container.
  2. Creates a JSON binary array value from a given binary container with subtype.

Binary values are part of various binary formats, such as CBOR, MessagePack, and BSON. This constructor is used to create a value for serialization to those formats.

Parameters

init (in)
container containing bytes to use as binary type
subtype (in)
subtype to use in CBOR, MessagePack, and BSON

Return value

JSON binary 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; constant for typename binary_t::container_type&& init versions.

Notes

Note, this function exists because of the difficulty in correctly specifying the correct template overload in the standard value ctor, as both JSON arrays and JSON binary arrays are backed with some form of a std::vector. Because JSON binary arrays are a non-standard extension it was decided that it would be best to prevent automatic initialization of a binary array type, for backwards compatibility and so it does not happen on accident.

Examples

Example

The following code shows how to create a binary value.

#include <iostream>
-#include <nlohmann/json.hpp>
+static basic_json binary(const typename binary_t::container_type& init,
+                         std::uint8_t subtype);
+static basic_json binary(typename binary_t::container_type&& init,
+                         std::uint8_t subtype);
+
  1. Creates a JSON binary array value from a given binary container.
  2. Creates a JSON binary array value from a given binary container with subtype.

Binary values are part of various binary formats, such as CBOR, MessagePack, and BSON. This constructor is used to create a value for serialization to those formats.

Parameters

init (in)
container containing bytes to use as binary type
subtype (in)
subtype to use in CBOR, MessagePack, and BSON

Return value

JSON binary 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; constant for typename binary_t::container_type&& init versions.

Notes

Note, this function exists because of the difficulty in correctly specifying the correct template overload in the standard value ctor, as both JSON arrays and JSON binary arrays are backed with some form of a std::vector. Because JSON binary arrays are a non-standard extension it was decided that it would be best to prevent automatic initialization of a binary array type, for backwards compatibility and so it does not happen on accident.

Examples

Example

The following code shows how to create a binary value.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a binary vector
-    std::vector<std::uint8_t> vec = {0xCA, 0xFE, 0xBA, 0xBE};
+    std::vector<std::uint8_t> vec = {0xCA, 0xFE, 0xBA, 0xBE};
 
     // create a binary JSON value with subtype 42
-    json j = json::binary(vec, 42);
+    json j = json::binary(vec, 42);
 
     // output type and subtype
-    std::cout << "type: " << j.type_name() << ", subtype: " << j.get_binary().subtype() << std::endl;
-}
-

Output:

type: binary, subtype: 42
-

Version history

  • Added in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << "type: " << j.type_name() << ", subtype: " << j.get_binary().subtype() << std::endl; +} +

Output:

type: binary, subtype: 42
+

Version history

  • Added in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/binary_t/index.html b/api/basic_json/binary_t/index.html index 829cb0525..4d24ecf8a 100644 --- a/api/basic_json/binary_t/index.html +++ b/api/basic_json/binary_t/index.html @@ -1,13 +1,13 @@ - binary_t - JSON for Modern C++
Skip to content

nlohmann::basic_json::binary_t

using binary_t = byte_container_with_subtype<BinaryType>;
-

This type is a type designed to carry binary data that appears in various serialized formats, such as CBOR's Major Type 2, MessagePack's bin, and BSON's generic binary subtype. This type is NOT a part of standard JSON and exists solely for compatibility with these binary types. As such, it is simply defined as an ordered sequence of zero or more byte values.

Additionally, as an implementation detail, the subtype of the binary data is carried around as a std::uint64_t, which is compatible with both of the binary data formats that use binary subtyping, (though the specific numbering is incompatible with each other, and it is up to the user to translate between them). The subtype is added to BinaryType via the helper type byte_container_with_subtype.

CBOR's RFC 7049 describes this type as:

Major type 2: a byte string. The string's length in bytes is represented following the rules for positive integers (major type 0).

MessagePack's documentation on the bin type family describes this type as:

Bin format family stores a byte array in 2, 3, or 5 bytes of extra bytes in addition to the size of the byte array.

BSON's specifications describe several binary types; however, this type is intended to represent the generic binary type which has the description:

Generic binary subtype - This is the most commonly used binary subtype and should be the 'default' for drivers and tools.

None of these impose any limitations on the internal representation other than the basic unit of storage be some type of array whose parts are decomposable into bytes.

The default representation of this binary format is a std::vector<std::uint8_t>, which is a very common way to represent a byte array in modern C++.

Template parameters

BinaryType
container type to store arrays

Notes

Default type

The default values for BinaryType is std::vector<std::uint8_t>.

Storage

Binary Arrays are stored as pointers in a basic_json type. That is, for any access to array values, a pointer of the type binary_t* must be dereferenced.

Notes on subtypes

  • CBOR

    • Binary values are represented as byte strings. Subtypes are written as tags.
  • MessagePack

    • If a subtype is given and the binary array contains exactly 1, 2, 4, 8, or 16 elements, the fixext family (fixext1, fixext2, fixext4, fixext8) is used. For other sizes, the ext family (ext8, ext16, ext32) is used. The subtype is then added as signed 8-bit integer.
    • If no subtype is given, the bin family (bin8, bin16, bin32) is used.
  • BSON

    • If a subtype is given, it is used and added as unsigned 8-bit integer.
    • If no subtype is given, the generic binary subtype 0x00 is used.

Examples

Example

The following code shows that binary_t is by default, a typedef to nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+ binary_t - JSON for Modern C++       

nlohmann::basic_json::binary_t

using binary_t = byte_container_with_subtype<BinaryType>;
+

This type is a type designed to carry binary data that appears in various serialized formats, such as CBOR's Major Type 2, MessagePack's bin, and BSON's generic binary subtype. This type is NOT a part of standard JSON and exists solely for compatibility with these binary types. As such, it is simply defined as an ordered sequence of zero or more byte values.

Additionally, as an implementation detail, the subtype of the binary data is carried around as a std::uint64_t, which is compatible with both of the binary data formats that use binary subtyping, (though the specific numbering is incompatible with each other, and it is up to the user to translate between them). The subtype is added to BinaryType via the helper type byte_container_with_subtype.

CBOR's RFC 7049 describes this type as:

Major type 2: a byte string. The string's length in bytes is represented following the rules for positive integers (major type 0).

MessagePack's documentation on the bin type family describes this type as:

Bin format family stores a byte array in 2, 3, or 5 bytes of extra bytes in addition to the size of the byte array.

BSON's specifications describe several binary types; however, this type is intended to represent the generic binary type which has the description:

Generic binary subtype - This is the most commonly used binary subtype and should be the 'default' for drivers and tools.

None of these impose any limitations on the internal representation other than the basic unit of storage be some type of array whose parts are decomposable into bytes.

The default representation of this binary format is a std::vector<std::uint8_t>, which is a very common way to represent a byte array in modern C++.

Template parameters

BinaryType
container type to store arrays

Notes

Default type

The default values for BinaryType is std::vector<std::uint8_t>.

Storage

Binary Arrays are stored as pointers in a basic_json type. That is, for any access to array values, a pointer of the type binary_t* must be dereferenced.

Notes on subtypes

  • CBOR

    • Binary values are represented as byte strings. Subtypes are written as tags.
  • MessagePack

    • If a subtype is given and the binary array contains exactly 1, 2, 4, 8, or 16 elements, the fixext family (fixext1, fixext2, fixext4, fixext8) is used. For other sizes, the ext family (ext8, ext16, ext32) is used. The subtype is then added as signed 8-bit integer.
    • If no subtype is given, the bin family (bin8, bin16, bin32) is used.
  • BSON

    • If a subtype is given, it is used and added as unsigned 8-bit integer.
    • If no subtype is given, the generic binary subtype 0x00 is used.

Examples

Example

The following code shows that binary_t is by default, a typedef to nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    std::cout << std::boolalpha << std::is_same<nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>, json::binary_t>::value << std::endl;
-}
-

Output:

true
-

See also

Version history

  • Added in version 3.8.0. Changed type of subtype to std::uint64_t in version 3.10.0.

Last update: May 1, 2022
\ No newline at end of file +int main() +{ + std::cout << std::boolalpha << std::is_same<nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>, json::binary_t>::value << std::endl; +} +

Output:

true
+

See also

Version history

  • Added in version 3.8.0. Changed type of subtype to std::uint64_t in version 3.10.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/boolean_t/index.html b/api/basic_json/boolean_t/index.html index 24932a91f..18cc9b676 100644 --- a/api/basic_json/boolean_t/index.html +++ b/api/basic_json/boolean_t/index.html @@ -1,13 +1,13 @@ - boolean_t - JSON for Modern C++
Skip to content

nlohmann::basic_json::boolean_t

using boolean_t = BooleanType;
-

The type used to store JSON booleans.

RFC 8259 implicitly describes a boolean as a type which differentiates the two literals true and 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 (bool), the default value for boolean_t is 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 bool.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+ boolean_t - JSON for Modern C++       

nlohmann::basic_json::boolean_t

using boolean_t = BooleanType;
+

The type used to store JSON booleans.

RFC 8259 implicitly describes a boolean as a type which differentiates the two literals true and 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 (bool), the default value for boolean_t is 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 bool.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    std::cout << std::boolalpha << std::is_same<bool, json::boolean_t>::value << std::endl;
-}
-

Output:

true
-

Version history

  • Added in version 1.0.0.

Last update: August 5, 2022
\ No newline at end of file +int main() +{ + std::cout << std::boolalpha << std::is_same<bool, json::boolean_t>::value << std::endl; +} +

Output:

true
+

Version history

  • Added in version 1.0.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/basic_json/cbegin/index.html b/api/basic_json/cbegin/index.html index 7caf4718f..9df8be5b6 100644 --- a/api/basic_json/cbegin/index.html +++ b/api/basic_json/cbegin/index.html @@ -1,19 +1,19 @@ - cbegin - JSON for Modern C++
Skip to content

nlohmann::basic_json::cbegin

const_iterator cbegin() const noexcept;
-

Returns an iterator to the first element.

Illustration from cppreference.com

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().

#include <iostream>
-#include <nlohmann/json.hpp>
+ cbegin - JSON for Modern C++       

nlohmann::basic_json::cbegin

const_iterator cbegin() const noexcept;
+

Returns an iterator to the first element.

Illustration from cppreference.com

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().

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create an array value
-    const json array = {1, 2, 3, 4, 5};
+    const json array = {1, 2, 3, 4, 5};
 
     // get an iterator to the first element
-    json::const_iterator it = array.cbegin();
+    json::const_iterator it = array.cbegin();
 
     // serialize the element that the iterator points to
-    std::cout << *it << '\n';
-}
-

Output:

1
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << *it << '\n'; +} +

Output:

1
+

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/cbor_tag_handler_t/index.html b/api/basic_json/cbor_tag_handler_t/index.html index c60498b94..35a513975 100644 --- a/api/basic_json/cbor_tag_handler_t/index.html +++ b/api/basic_json/cbor_tag_handler_t/index.html @@ -1,38 +1,38 @@ - cbor_tag_handler_t - JSON for Modern C++
Skip to content

nlohmann::basic_json::cbor_tag_handler_t

enum class cbor_tag_handler_t
-{
-    error,
-    ignore,
-    store
-};
-

This enumeration is used in the from_cbor function to choose how to treat tags:

error
throw a parse_error exception in case of a tag
ignore
ignore tags
store
store tagged values as binary container with subtype (for bytes 0xd8..0xdb)

Examples

Example

The example below shows how the different values of the cbor_tag_handler_t influence the behavior of from_cbor when reading a tagged byte string.

#include <iostream>
-#include <nlohmann/json.hpp>
+ cbor_tag_handler_t - JSON for Modern C++       

nlohmann::basic_json::cbor_tag_handler_t

enum class cbor_tag_handler_t
+{
+    error,
+    ignore,
+    store
+};
+

This enumeration is used in the from_cbor function to choose how to treat tags:

error
throw a parse_error exception in case of a tag
ignore
ignore tags
store
store tagged values as binary container with subtype (for bytes 0xd8..0xdb)

Examples

Example

The example below shows how the different values of the cbor_tag_handler_t influence the behavior of from_cbor when reading a tagged byte string.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // tagged byte string
-    std::vector<std::uint8_t> vec = {{0xd8, 0x42, 0x44, 0xcA, 0xfe, 0xba, 0xbe}};
+    std::vector<std::uint8_t> vec = {{0xd8, 0x42, 0x44, 0xcA, 0xfe, 0xba, 0xbe}};
 
     // cbor_tag_handler_t::error throws
-    try
-    {
-        auto b_throw_on_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::error);
-    }
-    catch (const json::parse_error& e)
-    {
-        std::cout << e.what() << std::endl;
-    }
+    try
+    {
+        auto b_throw_on_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::error);
+    }
+    catch (const json::parse_error& e)
+    {
+        std::cout << e.what() << std::endl;
+    }
 
     // cbor_tag_handler_t::ignore ignores the tag
-    auto b_ignore_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::ignore);
-    std::cout << b_ignore_tag << std::endl;
+    auto b_ignore_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::ignore);
+    std::cout << b_ignore_tag << std::endl;
 
     // cbor_tag_handler_t::store stores the tag as binary subtype
-    auto b_store_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::store);
-    std::cout << b_store_tag << std::endl;
-}
-

Output:

[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing CBOR value: invalid byte: 0xD8
-{"bytes":[202,254,186,190],"subtype":null}
-{"bytes":[202,254,186,190],"subtype":66}
-

Version history

  • Added in version 3.9.0. Added value store in 3.10.0.

Last update: May 17, 2022
\ No newline at end of file + auto b_store_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::store); + std::cout << b_store_tag << std::endl; +} +

Output:

[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing CBOR value: invalid byte: 0xD8
+{"bytes":[202,254,186,190],"subtype":null}
+{"bytes":[202,254,186,190],"subtype":66}
+

Version history

  • Added in version 3.9.0. Added value store in 3.10.0.

Last update: May 17, 2022
\ No newline at end of file diff --git a/api/basic_json/cend/index.html b/api/basic_json/cend/index.html index 3d737fee2..38c89965a 100644 --- a/api/basic_json/cend/index.html +++ b/api/basic_json/cend/index.html @@ -1,22 +1,22 @@ - cend - JSON for Modern C++
Skip to content

nlohmann::basic_json::cend

const_iterator cend() const noexcept;
-

Returns an iterator to one past the last element.

Illustration from cppreference.com

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().

#include <iostream>
-#include <nlohmann/json.hpp>
+ cend - JSON for Modern C++       

nlohmann::basic_json::cend

const_iterator cend() const noexcept;
+

Returns an iterator to one past the last element.

Illustration from cppreference.com

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().

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create an array value
-    json array = {1, 2, 3, 4, 5};
+    json array = {1, 2, 3, 4, 5};
 
     // get an iterator to one past the last element
-    json::const_iterator it = array.cend();
+    json::const_iterator it = array.cend();
 
     // decrement the iterator to point to the last element
-    --it;
+    --it;
 
     // serialize the element that the iterator points to
-    std::cout << *it << '\n';
-}
-

Output:

5
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << *it << '\n'; +} +

Output:

5
+

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/clear/index.html b/api/basic_json/clear/index.html index bbc45ad5b..6400f917c 100644 --- a/api/basic_json/clear/index.html +++ b/api/basic_json/clear/index.html @@ -1,44 +1,44 @@ - clear - JSON for Modern C++
Skip to content

nlohmann::basic_json::clear

void clear() noexcept;
-

Clears the content of a JSON value and resets it to the default value as if basic_json(value_t) would have been called with the current value type from type():

Value type initial value
null null
boolean false
string ""
number 0
binary An empty byte vector
object {}
array []

Has the same effect as calling

*this = basic_json(type());
-

Exception safety

No-throw guarantee: this function never throws exceptions.

Complexity

Linear in the size of the JSON value.

Notes

All iterators, pointers and references related to this container are invalidated.

Examples

Example

The example below shows the effect of clear() to different JSON types.

#include <iostream>
-#include <nlohmann/json.hpp>
+ clear - JSON for Modern C++       

nlohmann::basic_json::clear

void clear() noexcept;
+

Clears the content of a JSON value and resets it to the default value as if basic_json(value_t) would have been called with the current value type from type():

Value type initial value
null null
boolean false
string ""
number 0
binary An empty byte vector
object {}
array []

Has the same effect as calling

*this = basic_json(type());
+

Exception safety

No-throw guarantee: this function never throws exceptions.

Complexity

Linear in the size of the JSON value.

Notes

All iterators, pointers and references related to this container are invalidated.

Examples

Example

The example below shows the effect of clear() to different JSON types.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
 
     // call clear()
-    j_null.clear();
-    j_boolean.clear();
-    j_number_integer.clear();
-    j_number_float.clear();
-    j_object.clear();
-    j_array.clear();
-    j_string.clear();
+    j_null.clear();
+    j_boolean.clear();
+    j_number_integer.clear();
+    j_number_float.clear();
+    j_object.clear();
+    j_array.clear();
+    j_string.clear();
 
     // serialize the cleared values()
-    std::cout << j_null << '\n';
-    std::cout << j_boolean << '\n';
-    std::cout << j_number_integer << '\n';
-    std::cout << j_number_float << '\n';
-    std::cout << j_object << '\n';
-    std::cout << j_array << '\n';
-    std::cout << j_string << '\n';
-}
-

Output:

null
-false
-0
-0.0
-{}
-[]
-""
-

Version history

  • Added in version 1.0.0.
  • Added support for binary types in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << j_null << '\n'; + std::cout << j_boolean << '\n'; + std::cout << j_number_integer << '\n'; + std::cout << j_number_float << '\n'; + std::cout << j_object << '\n'; + std::cout << j_array << '\n'; + std::cout << j_string << '\n'; +} +

Output:

null
+false
+0
+0.0
+{}
+[]
+""
+

Version history

  • Added in version 1.0.0.
  • Added support for binary types in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/contains/index.html b/api/basic_json/contains/index.html index 27571bbd3..6a10ce75f 100644 --- a/api/basic_json/contains/index.html +++ b/api/basic_json/contains/index.html @@ -1,104 +1,104 @@ - contains - JSON for Modern C++
Skip to content

nlohmann::basic_json::contains

// (1)
-bool contains(const typename object_t::key_type& key) const;
+ contains - JSON for Modern C++       

nlohmann::basic_json::contains

// (1)
+bool contains(const typename object_t::key_type& key) const;
 
 // (2)
-template<typename KeyType>
-bool contains(KeyType&& key) const;
+template<typename KeyType>
+bool contains(KeyType&& key) const;
 
 // (3)
-bool contains(const json_pointer& ptr) const;
-
  1. Check whether an element exists in a JSON object with a key equivalent to key. If the element is not found or the JSON value is not an object, false is returned.
  2. See 1. This overload is only available if KeyType is comparable with typename object_t::key_type and typename object_comparator_t::is_transparent denotes a type.
  3. Check whether the given JSON pointer ptr can be resolved in the current JSON value.

Template parameters

KeyType
A type for an object key other than json_pointer that is comparable with string_t using object_comparator_t. This can also be a string view (C++17).

Parameters

key (in)
key value to check its existence.
ptr (in)
JSON pointer to check its existence.

Return value

  1. true if an element with specified key exists. If no such element with such key is found or the JSON value is not an object, false is returned.
  2. See 1.
  3. true if the JSON pointer can be resolved to a stored value, false otherwise.

Exception safety

Strong exception safety: if an exception occurs, the original value stays intact.

Exceptions

  1. The function does not throw exceptions.
  2. The function does not throw exceptions.
  3. The function can throw the following exceptions:

Complexity

Logarithmic in the size of the JSON object.

Notes

  • This method always returns false when executed on a JSON type that is not an object.
  • This method can be executed on any JSON value type.

Postconditions

If j.contains(x) returns true for a key or JSON pointer x, then it is safe to call j[x].

Examples

Example: (1) check with key

The example shows how contains() is used.

#include <iostream>
-#include <nlohmann/json.hpp>
+bool contains(const json_pointer& ptr) const;
+
  1. Check whether an element exists in a JSON object with a key equivalent to key. If the element is not found or the JSON value is not an object, false is returned.
  2. See 1. This overload is only available if KeyType is comparable with typename object_t::key_type and typename object_comparator_t::is_transparent denotes a type.
  3. Check whether the given JSON pointer ptr can be resolved in the current JSON value.

Template parameters

KeyType
A type for an object key other than json_pointer that is comparable with string_t using object_comparator_t. This can also be a string view (C++17).

Parameters

key (in)
key value to check its existence.
ptr (in)
JSON pointer to check its existence.

Return value

  1. true if an element with specified key exists. If no such element with such key is found or the JSON value is not an object, false is returned.
  2. See 1.
  3. true if the JSON pointer can be resolved to a stored value, false otherwise.

Exception safety

Strong exception safety: if an exception occurs, the original value stays intact.

Exceptions

  1. The function does not throw exceptions.
  2. The function does not throw exceptions.
  3. The function can throw the following exceptions:

Complexity

Logarithmic in the size of the JSON object.

Notes

  • This method always returns false when executed on a JSON type that is not an object.
  • This method can be executed on any JSON value type.

Postconditions

If j.contains(x) returns true for a key or JSON pointer x, then it is safe to call j[x].

Examples

Example: (1) check with key

The example shows how contains() is used.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
+int main()
+{
     // create some JSON values
-    json j_object = R"( {"key": "value"} )"_json;
-    json j_array = R"( [1, 2, 3] )"_json;
+    json j_object = R"( {"key": "value"} )"_json;
+    json j_array = R"( [1, 2, 3] )"_json;
 
     // call contains
-    std::cout << std::boolalpha <<
-              "j_object contains 'key': " << j_object.contains("key") << '\n' <<
-              "j_object contains 'another': " << j_object.contains("another") << '\n' <<
-              "j_array contains 'key': " << j_array.contains("key") << std::endl;
-}
-

Output:

j_object contains 'key': true
-j_object contains 'another': false
-j_array contains 'key': false
-
Example: (2) check with key using string_view

The example shows how contains() is used.

#include <iostream>
-#include <string_view>
-#include <nlohmann/json.hpp>
+    std::cout << std::boolalpha <<
+              "j_object contains 'key': " << j_object.contains("key") << '\n' <<
+              "j_object contains 'another': " << j_object.contains("another") << '\n' <<
+              "j_array contains 'key': " << j_array.contains("key") << std::endl;
+}
+

Output:

j_object contains 'key': true
+j_object contains 'another': false
+j_array contains 'key': false
+
Example: (2) check with key using string_view

The example shows how contains() is used.

#include <iostream>
+#include <string_view>
+#include <nlohmann/json.hpp>
 
-using namespace std::string_view_literals;
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using namespace std::string_view_literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
+int main()
+{
     // create some JSON values
-    json j_object = R"( {"key": "value"} )"_json;
-    json j_array = R"( [1, 2, 3] )"_json;
+    json j_object = R"( {"key": "value"} )"_json;
+    json j_array = R"( [1, 2, 3] )"_json;
 
     // call contains
-    std::cout << std::boolalpha <<
-              "j_object contains 'key': " << j_object.contains("key"sv) << '\n' <<
-              "j_object contains 'another': " << j_object.contains("another"sv) << '\n' <<
-              "j_array contains 'key': " << j_array.contains("key"sv) << std::endl;
-}
-

Output:

j_object contains 'key': true
-j_object contains 'another': false
-j_array contains 'key': false
-
Example: (3) check with JSON pointer

The example shows how contains() is used.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << std::boolalpha <<
+              "j_object contains 'key': " << j_object.contains("key"sv) << '\n' <<
+              "j_object contains 'another': " << j_object.contains("another"sv) << '\n' <<
+              "j_array contains 'key': " << j_array.contains("key"sv) << std::endl;
+}
+

Output:

j_object contains 'key': true
+j_object contains 'another': false
+j_array contains 'key': false
+
Example: (3) check with JSON pointer

The example shows how contains() is used.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
+int main()
+{
     // create a JSON value
-    json j =
-    {
-        {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
-    };
+    json j =
+    {
+        {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
+    };
 
-    std::cout << std::boolalpha
-              << j.contains("/number"_json_pointer) << '\n'
-              << j.contains("/string"_json_pointer) << '\n'
-              << j.contains("/array"_json_pointer) << '\n'
-              << j.contains("/array/1"_json_pointer) << '\n'
-              << j.contains("/array/-"_json_pointer) << '\n'
-              << j.contains("/array/4"_json_pointer) << '\n'
-              << j.contains("/baz"_json_pointer) << std::endl;
+    std::cout << std::boolalpha
+              << j.contains("/number"_json_pointer) << '\n'
+              << j.contains("/string"_json_pointer) << '\n'
+              << j.contains("/array"_json_pointer) << '\n'
+              << j.contains("/array/1"_json_pointer) << '\n'
+              << j.contains("/array/-"_json_pointer) << '\n'
+              << j.contains("/array/4"_json_pointer) << '\n'
+              << j.contains("/baz"_json_pointer) << std::endl;
 
-    try
-    {
+    try
+    {
         // try to use an array index with leading '0'
-        j.contains("/array/01"_json_pointer);
-    }
-    catch (const json::parse_error& e)
-    {
-        std::cout << e.what() << '\n';
-    }
+        j.contains("/array/01"_json_pointer);
+    }
+    catch (const json::parse_error& e)
+    {
+        std::cout << e.what() << '\n';
+    }
 
-    try
-    {
+    try
+    {
         // try to use an array index that is not a number
-        j.contains("/array/one"_json_pointer);
-    }
-    catch (const json::parse_error& e)
-    {
-        std::cout << e.what() << '\n';
-    }
-}
-

Output:

true
-true
-true
-true
-false
-false
-false
-

Version history

  1. Added in version 3.11.0.
  2. Added in version 3.6.0. Extended template KeyType to support comparable types in version 3.11.0.
  3. Added in version 3.7.0.

Last update: July 31, 2022
\ No newline at end of file + j.contains("/array/one"_json_pointer); + } + catch (const json::parse_error& e) + { + std::cout << e.what() << '\n'; + } +} +

Output:

true
+true
+true
+true
+false
+false
+false
+

Version history

  1. Added in version 3.11.0.
  2. Added in version 3.6.0. Extended template KeyType to support comparable types in version 3.11.0.
  3. Added in version 3.7.0.

Last update: July 31, 2022
\ No newline at end of file diff --git a/api/basic_json/count/index.html b/api/basic_json/count/index.html index e8cd67f64..b8071e744 100644 --- a/api/basic_json/count/index.html +++ b/api/basic_json/count/index.html @@ -1,49 +1,49 @@ - count - JSON for Modern C++
Skip to content

nlohmann::basic_json::count

// (1)
-size_type count(const typename object_t::key_type& key) const;
+ count - JSON for Modern C++       

nlohmann::basic_json::count

// (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 typename object_t::key_type and typename object_comparator_t::is_transparent denotes a type.

Template parameters

KeyType
A type for an object key other than json_pointer that is comparable with string_t using object_comparator_t. 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: (1) count number of elements

The example shows how count() is used.

#include <iostream>
-#include <nlohmann/json.hpp>
+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 typename object_t::key_type and typename object_comparator_t::is_transparent denotes a type.

Template parameters

KeyType
A type for an object key other than json_pointer that is comparable with string_t using object_comparator_t. 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: (1) count number of elements

The example shows how count() is used.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON object
-    json j_object = {{"one", 1}, {"two", 2}};
+    json j_object = {{"one", 1}, {"two", 2}};
 
     // call count()
-    auto count_two = j_object.count("two");
-    auto count_three = j_object.count("three");
+    auto count_two = j_object.count("two");
+    auto count_three = j_object.count("three");
 
     // print values
-    std::cout << "number of elements with key \"two\": " << count_two << '\n';
-    std::cout << "number of elements with key \"three\": " << count_three << '\n';
-}
-

Output:

number of elements with key "two": 1
-number of elements with key "three": 0
-
Example: (2) count number of elements using string_view

The example shows how count() is used.

#include <iostream>
-#include <string_view>
-#include <nlohmann/json.hpp>
+    std::cout << "number of elements with key \"two\": " << count_two << '\n';
+    std::cout << "number of elements with key \"three\": " << count_three << '\n';
+}
+

Output:

number of elements with key "two": 1
+number of elements with key "three": 0
+
Example: (2) count number of elements using string_view

The example shows how count() is used.

#include <iostream>
+#include <string_view>
+#include <nlohmann/json.hpp>
 
-using namespace std::string_view_literals;
-using json = nlohmann::json;
+using namespace std::string_view_literals;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON object
-    json j_object = {{"one", 1}, {"two", 2}};
+    json j_object = {{"one", 1}, {"two", 2}};
 
     // call count()
-    auto count_two = j_object.count("two"sv);
-    auto count_three = j_object.count("three"sv);
+    auto count_two = j_object.count("two"sv);
+    auto count_three = j_object.count("three"sv);
 
     // print values
-    std::cout << "number of elements with key \"two\": " << count_two << '\n';
-    std::cout << "number of elements with key \"three\": " << count_three << '\n';
-}
-

Output:

number of elements with key "two": 1
-number of elements with key "three": 0
-

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.

Last update: July 31, 2022
\ No newline at end of file + std::cout << "number of elements with key \"two\": " << count_two << '\n'; + std::cout << "number of elements with key \"three\": " << count_three << '\n'; +} +

Output:

number of elements with key "two": 1
+number of elements with key "three": 0
+

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.

Last update: July 31, 2022
\ No newline at end of file diff --git a/api/basic_json/crbegin/index.html b/api/basic_json/crbegin/index.html index 93381d082..779f2f2e0 100644 --- a/api/basic_json/crbegin/index.html +++ b/api/basic_json/crbegin/index.html @@ -1,19 +1,19 @@ - crbegin - JSON for Modern C++
Skip to content

nlohmann::basic_json::crbegin

const_reverse_iterator crbegin() const noexcept;
-

Returns an iterator to the reverse-beginning; that is, the last element.

Illustration from cppreference.com

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 crbegin().

#include <iostream>
-#include <nlohmann/json.hpp>
+ crbegin - JSON for Modern C++       

nlohmann::basic_json::crbegin

const_reverse_iterator crbegin() const noexcept;
+

Returns an iterator to the reverse-beginning; that is, the last element.

Illustration from cppreference.com

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 crbegin().

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create an array value
-    json array = {1, 2, 3, 4, 5};
+    json array = {1, 2, 3, 4, 5};
 
     // get an iterator to the reverse-beginning
-    json::const_reverse_iterator it = array.crbegin();
+    json::const_reverse_iterator it = array.crbegin();
 
     // serialize the element that the iterator points to
-    std::cout << *it << '\n';
-}
-

Output:

5
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << *it << '\n'; +} +

Output:

5
+

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/crend/index.html b/api/basic_json/crend/index.html index 9b4aaf50a..8445fb58b 100644 --- a/api/basic_json/crend/index.html +++ b/api/basic_json/crend/index.html @@ -1,22 +1,22 @@ - crend - JSON for Modern C++
Skip to content

nlohmann::basic_json::crend

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

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().

#include <iostream>
-#include <nlohmann/json.hpp>
+ crend - JSON for Modern C++       

nlohmann::basic_json::crend

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

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().

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create an array value
-    json array = {1, 2, 3, 4, 5};
+    json array = {1, 2, 3, 4, 5};
 
     // get an iterator to the reverse-end
-    json::const_reverse_iterator it = array.crend();
+    json::const_reverse_iterator it = array.crend();
 
     // increment the iterator to point to the first element
-    --it;
+    --it;
 
     // serialize the element that the iterator points to
-    std::cout << *it << '\n';
-}
-

Output:

1
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << *it << '\n'; +} +

Output:

1
+

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/default_object_comparator_t/index.html b/api/basic_json/default_object_comparator_t/index.html index e00c6938b..5dc7500fd 100644 --- a/api/basic_json/default_object_comparator_t/index.html +++ b/api/basic_json/default_object_comparator_t/index.html @@ -1,17 +1,17 @@ - default_object_comparator_t - JSON for Modern C++
Skip to content

nlohmann::basic_json::default_object_comparator_t

using default_object_comparator_t = std::less<StringType>;  // until C++14
+ default_object_comparator_t - JSON for Modern C++       

nlohmann::basic_json::default_object_comparator_t

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.

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 and can be obtained via object_comparator_t.

Examples

Example

The example below demonstrates the default comparator.

#include <iostream>
-#include <nlohmann/json.hpp>
+

The default comparator used by object_t.

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 and can be obtained via object_comparator_t.

Examples

Example

The example below demonstrates the default comparator.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    std::cout << std::boolalpha
-              << "one < two : " << json::default_object_comparator_t{}("one", "two") << "\n"
-              << "three < four : " << json::default_object_comparator_t{}("three", "four") << std::endl;
-}
-

Output:

one < two : true
-three < four : false
-

Version history

  • Added in version 3.11.0.

Last update: May 17, 2022
\ No newline at end of file +int main() +{ + std::cout << std::boolalpha + << "one < two : " << json::default_object_comparator_t{}("one", "two") << "\n" + << "three < four : " << json::default_object_comparator_t{}("three", "four") << std::endl; +} +

Output:

one < two : true
+three < four : false
+

Version history

  • Added in version 3.11.0.

Last update: May 17, 2022
\ No newline at end of file diff --git a/api/basic_json/diff/index.html b/api/basic_json/diff/index.html index 9db537349..7749575e1 100644 --- a/api/basic_json/diff/index.html +++ b/api/basic_json/diff/index.html @@ -1,66 +1,66 @@ - diff - JSON for Modern C++
Skip to content

nlohmann::basic_json::diff

static basic_json diff(const basic_json& source,
-                       const basic_json& target);
-

Creates a JSON Patch so that value source can be changed into the value target by calling patch function.

For two JSON values source and target, the following code yields always true:

source.patch(diff(source, target)) == target;
-

Parameters

source (in)
JSON value to compare from
target (in)
JSON value to compare against

Return value

a JSON patch to convert the source to target

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the JSON value.

Complexity

Linear in the lengths of source and target.

Notes

Currently, only remove, add, and replace operations are generated.

Examples

Example

The following code shows how a JSON patch is created as a diff for two JSON values.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+ diff - JSON for Modern C++       

nlohmann::basic_json::diff

static basic_json diff(const basic_json& source,
+                       const basic_json& target);
+

Creates a JSON Patch so that value source can be changed into the value target by calling patch function.

For two JSON values source and target, the following code yields always true:

source.patch(diff(source, target)) == target;
+

Parameters

source (in)
JSON value to compare from
target (in)
JSON value to compare against

Return value

a JSON patch to convert the source to target

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the JSON value.

Complexity

Linear in the lengths of source and target.

Notes

Currently, only remove, add, and replace operations are generated.

Examples

Example

The following code shows how a JSON patch is created as a diff for two JSON values.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
+int main()
+{
     // the source document
-    json source = R"(
+    json source = R"(
         {
             "baz": "qux",
             "foo": "bar"
         }
-    )"_json;
+    )"_json;
 
     // the target document
-    json target = R"(
+    json target = R"(
         {
             "baz": "boo",
             "hello": [
                 "world"
             ]
         }
-    )"_json;
+    )"_json;
 
     // create the patch
-    json patch = json::diff(source, target);
+    json patch = json::diff(source, target);
 
     // roundtrip
-    json patched_source = source.patch(patch);
+    json patched_source = source.patch(patch);
 
     // output patch and roundtrip result
-    std::cout << std::setw(4) << patch << "\n\n"
-              << std::setw(4) << patched_source << std::endl;
-}
-

Output:

[
-    {
-        "op": "replace",
-        "path": "/baz",
-        "value": "boo"
-    },
-    {
-        "op": "remove",
-        "path": "/foo"
-    },
-    {
-        "op": "add",
-        "path": "/hello",
-        "value": [
-            "world"
-        ]
-    }
-]
+    std::cout << std::setw(4) << patch << "\n\n"
+              << std::setw(4) << patched_source << std::endl;
+}
+

Output:

[
+    {
+        "op": "replace",
+        "path": "/baz",
+        "value": "boo"
+    },
+    {
+        "op": "remove",
+        "path": "/foo"
+    },
+    {
+        "op": "add",
+        "path": "/hello",
+        "value": [
+            "world"
+        ]
+    }
+]
 
-{
-    "baz": "boo",
-    "hello": [
-        "world"
-    ]
-}
-

See also

Version history

  • Added in version 2.0.0.

Last update: May 1, 2022
\ No newline at end of file +{ + "baz": "boo", + "hello": [ + "world" + ] +} +

See also

Version history

  • Added in version 2.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/dump/index.html b/api/basic_json/dump/index.html index 664a2e18d..978600967 100644 --- a/api/basic_json/dump/index.html +++ b/api/basic_json/dump/index.html @@ -1,108 +1,108 @@ - dump - JSON for Modern C++
Skip to content

nlohmann::basic_json::dump

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, 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: 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 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 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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ dump - JSON for Modern C++       

nlohmann::basic_json::dump

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, 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: 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 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 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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hellö 😀!";
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hellö 😀!";
 
     // call dump()
-    std::cout << "objects:" << '\n'
-              << j_object.dump() << "\n\n"
-              << j_object.dump(-1) << "\n\n"
-              << j_object.dump(0) << "\n\n"
-              << j_object.dump(4) << "\n\n"
-              << j_object.dump(1, '\t') << "\n\n";
+    std::cout << "objects:" << '\n'
+              << j_object.dump() << "\n\n"
+              << j_object.dump(-1) << "\n\n"
+              << j_object.dump(0) << "\n\n"
+              << j_object.dump(4) << "\n\n"
+              << j_object.dump(1, '\t') << "\n\n";
 
-    std::cout << "arrays:" << '\n'
-              << j_array.dump() << "\n\n"
-              << j_array.dump(-1) << "\n\n"
-              << j_array.dump(0) << "\n\n"
-              << j_array.dump(4) << "\n\n"
-              << j_array.dump(1, '\t') << "\n\n";
+    std::cout << "arrays:" << '\n'
+              << j_array.dump() << "\n\n"
+              << j_array.dump(-1) << "\n\n"
+              << j_array.dump(0) << "\n\n"
+              << j_array.dump(4) << "\n\n"
+              << j_array.dump(1, '\t') << "\n\n";
 
-    std::cout << "strings:" << '\n'
-              << j_string.dump() << '\n'
-              << j_string.dump(-1, ' ', true) << '\n';
+    std::cout << "strings:" << '\n'
+              << j_string.dump() << '\n'
+              << j_string.dump(-1, ' ', true) << '\n';
 
     // create JSON value with invalid UTF-8 byte sequence
-    json j_invalid = \xA9ü";
-    try
-    {
-        std::cout << j_invalid.dump() << std::endl;
-    }
-    catch (const json::type_error& e)
-    {
-        std::cout << e.what() << std::endl;
-    }
+    json j_invalid = \xA9ü";
+    try
+    {
+        std::cout << j_invalid.dump() << std::endl;
+    }
+    catch (const json::type_error& e)
+    {
+        std::cout << e.what() << std::endl;
+    }
 
-    std::cout << "string with replaced invalid characters: "
-              << j_invalid.dump(-1, ' ', false, json::error_handler_t::replace)
-              << "\nstring with ignored invalid characters: "
-              << j_invalid.dump(-1, ' ', false, json::error_handler_t::ignore)
-              << '\n';
-}
-

Output:

objects:
-{"one":1,"two":2}
+    std::cout << "string with replaced invalid characters: "
+              << j_invalid.dump(-1, ' ', false, json::error_handler_t::replace)
+              << "\nstring with ignored invalid characters: "
+              << j_invalid.dump(-1, ' ', false, json::error_handler_t::ignore)
+              << '\n';
+}
+

Output:

objects:
+{"one":1,"two":2}
 
-{"one":1,"two":2}
+{"one":1,"two":2}
 
-{
-"one": 1,
-"two": 2
-}
+{
+"one": 1,
+"two": 2
+}
 
-{
-    "one": 1,
-    "two": 2
-}
+{
+    "one": 1,
+    "two": 2
+}
 
-{
-    "one": 1,
-    "two": 2
-}
+{
+    "one": 1,
+    "two": 2
+}
 
-arrays:
-[1,2,4,8,16]
+arrays:
+[1,2,4,8,16]
 
-[1,2,4,8,16]
+[1,2,4,8,16]
 
-[
-1,
-2,
-4,
-8,
-16
-]
+[
+1,
+2,
+4,
+8,
+16
+]
 
-[
-    1,
-    2,
-    4,
-    8,
-    16
-]
+[
+    1,
+    2,
+    4,
+    8,
+    16
+]
 
-[
-    1,
-    2,
-    4,
-    8,
-    16
-]
+[
+    1,
+    2,
+    4,
+    8,
+    16
+]
 
-strings:
-"Hellö 😀!"
-"Hell\u00f6 \ud83d\ude00!"
-[json.exception.type_error.316] invalid UTF-8 byte at index 2: 0xA9
-string with replaced invalid characters: "ä�ü"
-string with ignored invalid characters: "äü"
-

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.

Last update: May 1, 2022
\ No newline at end of file +strings: +"Hellö 😀!" +"Hell\u00f6 \ud83d\ude00!" +[json.exception.type_error.316] invalid UTF-8 byte at index 2: 0xA9 +string with replaced invalid characters: "ä�ü" +string with ignored invalid characters: "äü" +

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.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/emplace/index.html b/api/basic_json/emplace/index.html index c82d9c7d1..58cdffc51 100644 --- a/api/basic_json/emplace/index.html +++ b/api/basic_json/emplace/index.html @@ -1,40 +1,40 @@ - emplace - JSON for Modern C++
Skip to content

nlohmann::basic_json::emplace

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 bool denoting whether the insertion took place.

Exceptions

Throws type_error.311 when called on a type other than JSON object or 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 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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ emplace - JSON for Modern C++       

nlohmann::basic_json::emplace

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 bool denoting whether the insertion took place.

Exceptions

Throws type_error.311 when called on a type other than JSON object or 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 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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json object = {{"one", 1}, {"two", 2}};
-    json null;
+    json object = {{"one", 1}, {"two", 2}};
+    json null;
 
     // print values
-    std::cout << object << '\n';
-    std::cout << null << '\n';
+    std::cout << object << '\n';
+    std::cout << null << '\n';
 
     // add values
-    auto res1 = object.emplace("three", 3);
-    null.emplace("A", "a");
-    null.emplace("B", "b");
+    auto res1 = object.emplace("three", 3);
+    null.emplace("A", "a");
+    null.emplace("B", "b");
 
     // the following call will not add an object, because there is already
     // a value stored at key "B"
-    auto res2 = null.emplace("B", "c");
+    auto res2 = null.emplace("B", "c");
 
     // print values
-    std::cout << object << '\n';
-    std::cout << *res1.first << " " << std::boolalpha << res1.second << '\n';
+    std::cout << object << '\n';
+    std::cout << *res1.first << " " << std::boolalpha << res1.second << '\n';
 
-    std::cout << null << '\n';
-    std::cout << *res2.first << " " << std::boolalpha << res2.second << '\n';
-}
-

Output:

{"one":1,"two":2}
-null
-{"one":1,"three":3,"two":2}
-3 true
-{"A":"a","B":"b"}
-"b" false
-

Version history

  • Since version 2.0.8.

Last update: May 1, 2022
\ No newline at end of file + std::cout << null << '\n'; + std::cout << *res2.first << " " << std::boolalpha << res2.second << '\n'; +} +

Output:

{"one":1,"two":2}
+null
+{"one":1,"three":3,"two":2}
+3 true
+{"A":"a","B":"b"}
+"b" false
+

Version history

  • Since version 2.0.8.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/emplace_back/index.html b/api/basic_json/emplace_back/index.html index 16fde7b3b..2b54b2b0d 100644 --- a/api/basic_json/emplace_back/index.html +++ b/api/basic_json/emplace_back/index.html @@ -1,31 +1,31 @@ - emplace_back - JSON for Modern C++
Skip to content

nlohmann::basic_json::emplace_back

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 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 when called on a type other than JSON array or 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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ emplace_back - JSON for Modern C++       

nlohmann::basic_json::emplace_back

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 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 when called on a type other than JSON array or 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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json array = {1, 2, 3, 4, 5};
-    json null;
+    json array = {1, 2, 3, 4, 5};
+    json null;
 
     // print values
-    std::cout << array << '\n';
-    std::cout << null << '\n';
+    std::cout << array << '\n';
+    std::cout << null << '\n';
 
     // add values
-    array.emplace_back(6);
-    null.emplace_back("first");
-    null.emplace_back(3, "second");
+    array.emplace_back(6);
+    null.emplace_back("first");
+    null.emplace_back(3, "second");
 
     // print values
-    std::cout << array << '\n';
-    std::cout << null << '\n';
-}
-

Output:

[1,2,3,4,5]
-null
-[1,2,3,4,5,6]
-["first",["second","second","second"]]
-

Version history

  • Since version 2.0.8.
  • Returns reference since 3.7.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << array << '\n'; + std::cout << null << '\n'; +} +

Output:

[1,2,3,4,5]
+null
+[1,2,3,4,5,6]
+["first",["second","second","second"]]
+

Version history

  • Since version 2.0.8.
  • Returns reference since 3.7.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/empty/index.html b/api/basic_json/empty/index.html index 2484d809f..cd8acd8c1 100644 --- a/api/basic_json/empty/index.html +++ b/api/basic_json/empty/index.html @@ -1,45 +1,45 @@ - empty - JSON for Modern C++
Skip to content

nlohmann::basic_json::empty

bool empty() const noexcept;
-

Checks if a JSON value has no elements (i.e. whether its size() is 0).

Return value

The return value depends on the different types and is defined as follows:

Value type return value
null true
boolean false
string false
number false
binary 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 and object_t satisfy the Container concept; that is, their empty() functions have constant complexity.

Possible implementation

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 false in the case of a string.

Examples

Example

The following code uses empty() to check if a JSON object contains any elements.

#include <iostream>
-#include <nlohmann/json.hpp>
+ empty - JSON for Modern C++       

nlohmann::basic_json::empty

bool empty() const noexcept;
+

Checks if a JSON value has no elements (i.e. whether its size() is 0).

Return value

The return value depends on the different types and is defined as follows:

Value type return value
null true
boolean false
string false
number false
binary 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 and object_t satisfy the Container concept; that is, their empty() functions have constant complexity.

Possible implementation

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 false in the case of a string.

Examples

Example

The following code uses empty() to check if a JSON object contains any elements.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_object_empty(json::value_t::object);
-    json j_array = {1, 2, 4, 8, 16};
-    json j_array_empty(json::value_t::array);
-    json j_string = "Hello, world";
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_object_empty(json::value_t::object);
+    json j_array = {1, 2, 4, 8, 16};
+    json j_array_empty(json::value_t::array);
+    json j_string = "Hello, world";
 
     // call empty()
-    std::cout << std::boolalpha;
-    std::cout << j_null.empty() << '\n';
-    std::cout << j_boolean.empty() << '\n';
-    std::cout << j_number_integer.empty() << '\n';
-    std::cout << j_number_float.empty() << '\n';
-    std::cout << j_object.empty() << '\n';
-    std::cout << j_object_empty.empty() << '\n';
-    std::cout << j_array.empty() << '\n';
-    std::cout << j_array_empty.empty() << '\n';
-    std::cout << j_string.empty() << '\n';
-}
-

Output:

true
-false
-false
-false
-false
-true
-false
-true
-false
-

Version history

  • Added in version 1.0.0.
  • Extended to return false for binary types in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << j_null.empty() << '\n'; + std::cout << j_boolean.empty() << '\n'; + std::cout << j_number_integer.empty() << '\n'; + std::cout << j_number_float.empty() << '\n'; + std::cout << j_object.empty() << '\n'; + std::cout << j_object_empty.empty() << '\n'; + std::cout << j_array.empty() << '\n'; + std::cout << j_array_empty.empty() << '\n'; + std::cout << j_string.empty() << '\n'; +} +

Output:

true
+false
+false
+false
+false
+true
+false
+true
+false
+

Version history

  • Added in version 1.0.0.
  • Extended to return false for binary types in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/end/index.html b/api/basic_json/end/index.html index 2c3dcdea7..0d09e1cf9 100644 --- a/api/basic_json/end/index.html +++ b/api/basic_json/end/index.html @@ -1,23 +1,23 @@ - end - JSON for Modern C++
Skip to content

nlohmann::basic_json::end

iterator end() noexcept;
-const_iterator end() const noexcept;
-

Returns an iterator to one past the last element.

Illustration from cppreference.com

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 end().

#include <iostream>
-#include <nlohmann/json.hpp>
+ end - JSON for Modern C++       

nlohmann::basic_json::end

iterator end() noexcept;
+const_iterator end() const noexcept;
+

Returns an iterator to one past the last element.

Illustration from cppreference.com

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 end().

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create an array value
-    json array = {1, 2, 3, 4, 5};
+    json array = {1, 2, 3, 4, 5};
 
     // get an iterator to one past the last element
-    json::iterator it = array.end();
+    json::iterator it = array.end();
 
     // decrement the iterator to point to the last element
-    --it;
+    --it;
 
     // serialize the element that the iterator points to
-    std::cout << *it << '\n';
-}
-

Output:

5
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << *it << '\n'; +} +

Output:

5
+

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/erase/index.html b/api/basic_json/erase/index.html index 0e279023c..394c41867 100644 --- a/api/basic_json/erase/index.html +++ b/api/basic_json/erase/index.html @@ -1,151 +1,151 @@ - erase - JSON for Modern C++
Skip to content

nlohmann::basic_json::erase

// (1)
-iterator erase(iterator pos);
-const_iterator erase(const_iterator pos);
+ erase - JSON for Modern C++       

nlohmann::basic_json::erase

// (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);
+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);
+size_type erase(const typename object_t::key_type& key);
 
 // (4)
-template<typename KeyType>
-size_type erase(KeyType&& key);
+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 null, the resulting JSON value will be 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 null, the resulting JSON value will be null.

  3. Removes an element from a JSON object by key.

  4. See 3. This overload is only available if KeyType is comparable with typename object_t::key_type and 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 that is comparable with string_t using object_comparator_t. 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 if called on a null value; example: "cannot use erase() with null"
    • Throws invalid_iterator.202 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 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 if called on a null value; example: "cannot use erase() with null"
    • Throws invalid_iterator.203 if called on iterators which does not belong to the current JSON value; example: "iterators do not fit current value"
    • Throws invalid_iterator.204 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 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 when called on a type other than JSON object; example: "cannot use erase() with null"
    • Throws out_of_range.401 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: (1) remove element given an iterator

The example shows the effect of erase() for different JSON types using an iterator.

#include <iostream>
-#include <nlohmann/json.hpp>
+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 null, the resulting JSON value will be 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 null, the resulting JSON value will be null.

  3. Removes an element from a JSON object by key.

  4. See 3. This overload is only available if KeyType is comparable with typename object_t::key_type and 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 that is comparable with string_t using object_comparator_t. 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 if called on a null value; example: "cannot use erase() with null"
    • Throws invalid_iterator.202 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 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 if called on a null value; example: "cannot use erase() with null"
    • Throws invalid_iterator.203 if called on iterators which does not belong to the current JSON value; example: "iterators do not fit current value"
    • Throws invalid_iterator.204 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 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 when called on a type other than JSON object; example: "cannot use erase() with null"
    • Throws out_of_range.401 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: (1) remove element given an iterator

The example shows the effect of erase() for different JSON types using an iterator.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
 
     // call erase()
-    j_boolean.erase(j_boolean.begin());
-    j_number_integer.erase(j_number_integer.begin());
-    j_number_float.erase(j_number_float.begin());
-    j_object.erase(j_object.find("two"));
-    j_array.erase(j_array.begin() + 2);
-    j_string.erase(j_string.begin());
+    j_boolean.erase(j_boolean.begin());
+    j_number_integer.erase(j_number_integer.begin());
+    j_number_float.erase(j_number_float.begin());
+    j_object.erase(j_object.find("two"));
+    j_array.erase(j_array.begin() + 2);
+    j_string.erase(j_string.begin());
 
     // print values
-    std::cout << j_boolean << '\n';
-    std::cout << j_number_integer << '\n';
-    std::cout << j_number_float << '\n';
-    std::cout << j_object << '\n';
-    std::cout << j_array << '\n';
-    std::cout << j_string << '\n';
-}
-

Output:

null
-null
-null
-{"one":1}
-[1,2,8,16]
-null
-
Example: (2) remove elements given an iterator range

The example shows the effect of erase() for different JSON types using an iterator range.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << j_boolean << '\n';
+    std::cout << j_number_integer << '\n';
+    std::cout << j_number_float << '\n';
+    std::cout << j_object << '\n';
+    std::cout << j_array << '\n';
+    std::cout << j_string << '\n';
+}
+

Output:

null
+null
+null
+{"one":1}
+[1,2,8,16]
+null
+
Example: (2) remove elements given an iterator range

The example shows the effect of erase() for different JSON types using an iterator range.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
 
     // call erase()
-    j_boolean.erase(j_boolean.begin(), j_boolean.end());
-    j_number_integer.erase(j_number_integer.begin(), j_number_integer.end());
-    j_number_float.erase(j_number_float.begin(), j_number_float.end());
-    j_object.erase(j_object.find("two"), j_object.end());
-    j_array.erase(j_array.begin() + 1, j_array.begin() + 3);
-    j_string.erase(j_string.begin(), j_string.end());
+    j_boolean.erase(j_boolean.begin(), j_boolean.end());
+    j_number_integer.erase(j_number_integer.begin(), j_number_integer.end());
+    j_number_float.erase(j_number_float.begin(), j_number_float.end());
+    j_object.erase(j_object.find("two"), j_object.end());
+    j_array.erase(j_array.begin() + 1, j_array.begin() + 3);
+    j_string.erase(j_string.begin(), j_string.end());
 
     // print values
-    std::cout << j_boolean << '\n';
-    std::cout << j_number_integer << '\n';
-    std::cout << j_number_float << '\n';
-    std::cout << j_object << '\n';
-    std::cout << j_array << '\n';
-    std::cout << j_string << '\n';
-}
-

Output:

null
-null
-null
-{"one":1}
-[1,8,16]
-null
-
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.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << j_boolean << '\n';
+    std::cout << j_number_integer << '\n';
+    std::cout << j_number_float << '\n';
+    std::cout << j_object << '\n';
+    std::cout << j_array << '\n';
+    std::cout << j_string << '\n';
+}
+

Output:

null
+null
+null
+{"one":1}
+[1,8,16]
+null
+
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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON object
-    json j_object = {{"one", 1}, {"two", 2}};
+    json j_object = {{"one", 1}, {"two", 2}};
 
     // call erase()
-    auto count_one = j_object.erase("one");
-    auto count_three = j_object.erase("three");
+    auto count_one = j_object.erase("one");
+    auto count_three = j_object.erase("three");
 
     // print values
-    std::cout << j_object << '\n';
-    std::cout << count_one << " " << count_three << '\n';
-}
-

Output:

{"two":2}
-1 0
-
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.

#include <iostream>
-#include <string_view>
-#include <nlohmann/json.hpp>
+    std::cout << j_object << '\n';
+    std::cout << count_one << " " << count_three << '\n';
+}
+

Output:

{"two":2}
+1 0
+
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.

#include <iostream>
+#include <string_view>
+#include <nlohmann/json.hpp>
 
-using namespace std::string_view_literals;
-using json = nlohmann::json;
+using namespace std::string_view_literals;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON object
-    json j_object = {{"one", 1}, {"two", 2}};
+    json j_object = {{"one", 1}, {"two", 2}};
 
     // call erase()
-    auto count_one = j_object.erase("one"sv);
-    auto count_three = j_object.erase("three"sv);
+    auto count_one = j_object.erase("one"sv);
+    auto count_three = j_object.erase("three"sv);
 
     // print values
-    std::cout << j_object << '\n';
-    std::cout << count_one << " " << count_three << '\n';
-}
-

Output:

{"two":2}
-1 0
-
Example: (5) remove element from a JSON array given an index

The example shows the effect of erase() using an array index.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << j_object << '\n';
+    std::cout << count_one << " " << count_three << '\n';
+}
+

Output:

{"two":2}
+1 0
+
Example: (5) remove element from a JSON array given an index

The example shows the effect of erase() using an array index.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON array
-    json j_array = {0, 1, 2, 3, 4, 5};
+    json j_array = {0, 1, 2, 3, 4, 5};
 
     // call erase()
-    j_array.erase(2);
+    j_array.erase(2);
 
     // print values
-    std::cout << j_array << '\n';
-}
-

Output:

[0,1,3,4,5]
-

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.

Last update: July 31, 2022
\ No newline at end of file + std::cout << j_array << '\n'; +} +

Output:

[0,1,3,4,5]
+

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.

Last update: July 31, 2022
\ No newline at end of file diff --git a/api/basic_json/error_handler_t/index.html b/api/basic_json/error_handler_t/index.html index 533b98582..a670e7da7 100644 --- a/api/basic_json/error_handler_t/index.html +++ b/api/basic_json/error_handler_t/index.html @@ -1,33 +1,33 @@ - error_handler_t - JSON for Modern C++
Skip to content

nlohmann::basic_json::error_handler_t

enum class error_handler_t {
-    strict,
-    replace,
-    ignore
-};
-

This enumeration is used in the dump 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 when reading serializing an invalid UTF-8 sequence.

#include <iostream>
-#include <nlohmann/json.hpp>
+ error_handler_t - JSON for Modern C++       

nlohmann::basic_json::error_handler_t

enum class error_handler_t {
+    strict,
+    replace,
+    ignore
+};
+

This enumeration is used in the dump 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 when reading serializing an invalid UTF-8 sequence.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON value with invalid UTF-8 byte sequence
-    json j_invalid = \xA9ü";
-    try
-    {
-        std::cout << j_invalid.dump() << std::endl;
-    }
-    catch (const json::type_error& e)
-    {
-        std::cout << e.what() << std::endl;
-    }
+    json j_invalid = \xA9ü";
+    try
+    {
+        std::cout << j_invalid.dump() << std::endl;
+    }
+    catch (const json::type_error& e)
+    {
+        std::cout << e.what() << std::endl;
+    }
 
-    std::cout << "string with replaced invalid characters: "
-              << j_invalid.dump(-1, ' ', false, json::error_handler_t::replace)
-              << "\nstring with ignored invalid characters: "
-              << j_invalid.dump(-1, ' ', false, json::error_handler_t::ignore)
-              << '\n';
-}
-

Output:

[json.exception.type_error.316] invalid UTF-8 byte at index 2: 0xA9
-string with replaced invalid characters: "ä�ü"
-string with ignored invalid characters: "äü"
-

Version history

  • Added in version 3.4.0.

Last update: May 17, 2022
\ No newline at end of file + std::cout << "string with replaced invalid characters: " + << j_invalid.dump(-1, ' ', false, json::error_handler_t::replace) + << "\nstring with ignored invalid characters: " + << j_invalid.dump(-1, ' ', false, json::error_handler_t::ignore) + << '\n'; +} +

Output:

[json.exception.type_error.316] invalid UTF-8 byte at index 2: 0xA9
+string with replaced invalid characters: "ä�ü"
+string with ignored invalid characters: "äü"
+

Version history

  • Added in version 3.4.0.

Last update: May 17, 2022
\ No newline at end of file diff --git a/api/basic_json/exception/index.html b/api/basic_json/exception/index.html index 4fa47f726..4e692da72 100644 --- a/api/basic_json/exception/index.html +++ b/api/basic_json/exception/index.html @@ -1,24 +1,24 @@ - exception - JSON for Modern C++
Skip to content

nlohmann::basic_json::exception

class exception : public std::exception;
-

This class is an extension of std::exception objects with a member id for exception ids. It is used as the base class for all exceptions thrown by the basic_json class. This class can hence be used as "wildcard" to catch exceptions, see example below.

uml diagram

Subclasses:

  • parse_error for exceptions indicating a parse error
  • invalid_iterator for exceptions indicating errors with iterators
  • type_error for exceptions indicating executing a member function with a wrong type
  • out_of_range for exceptions indicating access out of the defined range
  • other_error for exceptions indicating other library errors

Member functions

  • what - returns explanatory string

Member variables

  • id - the id of the exception

Notes

To have nothrow-copy-constructible exceptions, we internally use std::runtime_error which can cope with arbitrary-length error messages. Intermediate strings are built with static functions and then passed to the actual constructor.

Examples

Example

The following code shows how arbitrary library exceptions can be caught.

#include <iostream>
-#include <nlohmann/json.hpp>
+ exception - JSON for Modern C++       

nlohmann::basic_json::exception

class exception : public std::exception;
+

This class is an extension of std::exception objects with a member id for exception ids. It is used as the base class for all exceptions thrown by the basic_json class. This class can hence be used as "wildcard" to catch exceptions, see example below.

uml diagram

Subclasses:

  • parse_error for exceptions indicating a parse error
  • invalid_iterator for exceptions indicating errors with iterators
  • type_error for exceptions indicating executing a member function with a wrong type
  • out_of_range for exceptions indicating access out of the defined range
  • other_error for exceptions indicating other library errors

Member functions

  • what - returns explanatory string

Member variables

  • id - the id of the exception

Notes

To have nothrow-copy-constructible exceptions, we internally use std::runtime_error which can cope with arbitrary-length error messages. Intermediate strings are built with static functions and then passed to the actual constructor.

Examples

Example

The following code shows how arbitrary library exceptions can be caught.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    try
-    {
+int main()
+{
+    try
+    {
         // calling at() for a non-existing key
-        json j = {{"foo", "bar"}};
-        json k = j.at("non-existing");
-    }
-    catch (const json::exception& e)
-    {
+        json j = {{"foo", "bar"}};
+        json k = j.at("non-existing");
+    }
+    catch (const json::exception& e)
+    {
         // output exception information
-        std::cout << "message: " << e.what() << '\n'
-                  << "exception id: " << e.id << std::endl;
-    }
-}
-

Output:

message: [json.exception.out_of_range.403] key 'non-existing' not found
-exception id: 403
-

See also

List of exceptions

Version history

  • Since version 3.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << "message: " << e.what() << '\n' + << "exception id: " << e.id << std::endl; + } +} +

Output:

message: [json.exception.out_of_range.403] key 'non-existing' not found
+exception id: 403
+

See also

List of exceptions

Version history

  • Since version 3.0.0.

Last update: November 1, 2023
\ No newline at end of file diff --git a/api/basic_json/find/index.html b/api/basic_json/find/index.html index fb7c4e7a4..3621fb48c 100644 --- a/api/basic_json/find/index.html +++ b/api/basic_json/find/index.html @@ -1,58 +1,58 @@ - find - JSON for Modern C++
Skip to content

nlohmann::basic_json::find

// (1)
-iterator find(const typename object_t::key_type& key);
-const_iterator find(const typename object_t::key_type& key) const;
+ find - JSON for Modern C++       

nlohmann::basic_json::find

// (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 typename object_t::key_type and typename object_comparator_t::is_transparent denotes a type.

Template parameters

KeyType
A type for an object key other than json_pointer that is comparable with string_t using object_comparator_t. 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: (1) find object element by key

The example shows how find() is used.

#include <iostream>
-#include <nlohmann/json.hpp>
+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 typename object_t::key_type and typename object_comparator_t::is_transparent denotes a type.

Template parameters

KeyType
A type for an object key other than json_pointer that is comparable with string_t using object_comparator_t. 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: (1) find object element by key

The example shows how find() is used.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON object
-    json j_object = {{"one", 1}, {"two", 2}};
+    json j_object = {{"one", 1}, {"two", 2}};
 
     // call find
-    auto it_two = j_object.find("two");
-    auto it_three = j_object.find("three");
+    auto it_two = j_object.find("two");
+    auto it_three = j_object.find("three");
 
     // print values
-    std::cout << std::boolalpha;
-    std::cout << "\"two\" was found: " << (it_two != j_object.end()) << '\n';
-    std::cout << "value at key \"two\": " << *it_two << '\n';
-    std::cout << "\"three\" was found: " << (it_three != j_object.end()) << '\n';
-}
-

Output:

"two" was found: true
-value at key "two": 2
-"three" was found: false
-
Example: (2) find object element by key using string_view

The example shows how find() is used.

#include <iostream>
-#include <string_view>
-#include <nlohmann/json.hpp>
+    std::cout << std::boolalpha;
+    std::cout << "\"two\" was found: " << (it_two != j_object.end()) << '\n';
+    std::cout << "value at key \"two\": " << *it_two << '\n';
+    std::cout << "\"three\" was found: " << (it_three != j_object.end()) << '\n';
+}
+

Output:

"two" was found: true
+value at key "two": 2
+"three" was found: false
+
Example: (2) find object element by key using string_view

The example shows how find() is used.

#include <iostream>
+#include <string_view>
+#include <nlohmann/json.hpp>
 
-using namespace std::string_view_literals;
-using json = nlohmann::json;
+using namespace std::string_view_literals;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON object
-    json j_object = {{"one", 1}, {"two", 2}};
+    json j_object = {{"one", 1}, {"two", 2}};
 
     // call find
-    auto it_two = j_object.find("two"sv);
-    auto it_three = j_object.find("three"sv);
+    auto it_two = j_object.find("two"sv);
+    auto it_three = j_object.find("three"sv);
 
     // print values
-    std::cout << std::boolalpha;
-    std::cout << "\"two\" was found: " << (it_two != j_object.end()) << '\n';
-    std::cout << "value at key \"two\": " << *it_two << '\n';
-    std::cout << "\"three\" was found: " << (it_three != j_object.end()) << '\n';
-}
-

Output:

"two" was found: true
-value at key "two": 2
-"three" was found: false
-

See also

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.

Last update: July 31, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << "\"two\" was found: " << (it_two != j_object.end()) << '\n'; + std::cout << "value at key \"two\": " << *it_two << '\n'; + std::cout << "\"three\" was found: " << (it_three != j_object.end()) << '\n'; +} +

Output:

"two" was found: true
+value at key "two": 2
+"three" was found: false
+

See also

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.

Last update: July 31, 2022
\ No newline at end of file diff --git a/api/basic_json/flatten/index.html b/api/basic_json/flatten/index.html index f909f1085..a2ba063fb 100644 --- a/api/basic_json/flatten/index.html +++ b/api/basic_json/flatten/index.html @@ -1,46 +1,46 @@ - flatten - JSON for Modern C++
Skip to content

nlohmann::basic_json::flatten

basic_json flatten() const;
-

The function creates a JSON object whose keys are JSON pointers (see RFC 6901) and whose values are all primitive (see is_primitive() for more information). The original JSON value can be restored using the unflatten() function.

Return value

an object that maps JSON pointers to primitive values

Exception safety

Strong exception safety: if an exception occurs, the original value stays intact.

Complexity

Linear in the size the JSON value.

Notes

Empty objects and arrays are flattened to null and will not be reconstructed correctly by the unflatten() function.

Examples

Example

The following code shows how a JSON object is flattened to an object whose keys consist of JSON pointers.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+ flatten - JSON for Modern C++       

nlohmann::basic_json::flatten

basic_json flatten() const;
+

The function creates a JSON object whose keys are JSON pointers (see RFC 6901) and whose values are all primitive (see is_primitive() for more information). The original JSON value can be restored using the unflatten() function.

Return value

an object that maps JSON pointers to primitive values

Exception safety

Strong exception safety: if an exception occurs, the original value stays intact.

Complexity

Linear in the size the JSON value.

Notes

Empty objects and arrays are flattened to null and will not be reconstructed correctly by the unflatten() function.

Examples

Example

The following code shows how a JSON object is flattened to an object whose keys consist of JSON pointers.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON value
-    json j =
-    {
-        {"pi", 3.141},
-        {"happy", true},
-        {"name", "Niels"},
-        {"nothing", nullptr},
-        {
-            "answer", {
-                {"everything", 42}
-            }
-        },
-        {"list", {1, 0, 2}},
-        {
-            "object", {
-                {"currency", "USD"},
-                {"value", 42.99}
-            }
-        }
-    };
+    json j =
+    {
+        {"pi", 3.141},
+        {"happy", true},
+        {"name", "Niels"},
+        {"nothing", nullptr},
+        {
+            "answer", {
+                {"everything", 42}
+            }
+        },
+        {"list", {1, 0, 2}},
+        {
+            "object", {
+                {"currency", "USD"},
+                {"value", 42.99}
+            }
+        }
+    };
 
     // call flatten()
-    std::cout << std::setw(4) << j.flatten() << '\n';
-}
-

Output:

{
-    "/answer/everything": 42,
-    "/happy": true,
-    "/list/0": 1,
-    "/list/1": 0,
-    "/list/2": 2,
-    "/name": "Niels",
-    "/nothing": null,
-    "/object/currency": "USD",
-    "/object/value": 42.99,
-    "/pi": 3.141
-}
-

See also

Version history

  • Added in version 2.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << std::setw(4) << j.flatten() << '\n'; +} +

Output:

{
+    "/answer/everything": 42,
+    "/happy": true,
+    "/list/0": 1,
+    "/list/1": 0,
+    "/list/2": 2,
+    "/name": "Niels",
+    "/nothing": null,
+    "/object/currency": "USD",
+    "/object/value": 42.99,
+    "/pi": 3.141
+}
+

See also

Version history

  • Added in version 2.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/from_bjdata/index.html b/api/basic_json/from_bjdata/index.html index 5960287ac..33271fa94 100644 --- a/api/basic_json/from_bjdata/index.html +++ b/api/basic_json/from_bjdata/index.html @@ -1,35 +1,35 @@ - from_bjdata - JSON for Modern C++
Skip to content

nlohmann::basic_json::from_bjdata

// (1)
-template<typename InputType>
-static basic_json from_bjdata(InputType&& i,
-                              const bool strict = true,
-                              const bool allow_exceptions = true);
+ from_bjdata - JSON for Modern C++       

nlohmann::basic_json::from_bjdata

// (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.

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 (true by default)
allow_exceptions (in)
whether to throw exceptions in case of a parse error (optional, true by default)

Return value

deserialized JSON value; in case of a parse error and allow_exceptions set to false, the return value will be value_t::discarded. The latter can be checked with is_discarded.

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the JSON value.

Exceptions

  • Throws parse_error.110 if the given input ends prematurely or the end of file was not reached when strict was set to true
  • Throws parse_error.112 if a parse error occurs
  • Throws parse_error.113 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.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+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.

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 (true by default)
allow_exceptions (in)
whether to throw exceptions in case of a parse error (optional, true by default)

Return value

deserialized JSON value; in case of a parse error and allow_exceptions set to false, the return value will be value_t::discarded. The latter can be checked with is_discarded.

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the JSON value.

Exceptions

  • Throws parse_error.110 if the given input ends prematurely or the end of file was not reached when strict was set to true
  • Throws parse_error.112 if a parse error occurs
  • Throws parse_error.113 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.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create byte vector
-    std::vector<std::uint8_t> v = {0x7B, 0x69, 0x07, 0x63, 0x6F, 0x6D, 0x70, 0x61,
-                                   0x63, 0x74, 0x54, 0x69, 0x06, 0x73, 0x63, 0x68,
-                                   0x65, 0x6D, 0x61, 0x69, 0x00, 0x7D
-                                  };
+    std::vector<std::uint8_t> v = {0x7B, 0x69, 0x07, 0x63, 0x6F, 0x6D, 0x70, 0x61,
+                                   0x63, 0x74, 0x54, 0x69, 0x06, 0x73, 0x63, 0x68,
+                                   0x65, 0x6D, 0x61, 0x69, 0x00, 0x7D
+                                  };
 
     // deserialize it with BJData
-    json j = json::from_bjdata(v);
+    json j = json::from_bjdata(v);
 
     // print the deserialized JSON value
-    std::cout << std::setw(2) << j << std::endl;
-}
-

Output:

{
-  "compact": true,
-  "schema": 0
-}
-

Version history

  • Added in version 3.11.0.

Last update: May 17, 2022
\ No newline at end of file + std::cout << std::setw(2) << j << std::endl; +} +

Output:

{
+  "compact": true,
+  "schema": 0
+}
+

Version history

  • Added in version 3.11.0.

Last update: May 17, 2022
\ No newline at end of file diff --git a/api/basic_json/from_bson/index.html b/api/basic_json/from_bson/index.html index 7393eb7b8..3fd02924b 100644 --- a/api/basic_json/from_bson/index.html +++ b/api/basic_json/from_bson/index.html @@ -1,36 +1,36 @@ - from_bson - JSON for Modern C++
Skip to content

nlohmann::basic_json::from_bson

// (1)
-template<typename InputType>
-static basic_json from_bson(InputType&& i,
-                            const bool strict = true,
-                            const bool allow_exceptions = true);
+ from_bson - JSON for Modern C++       

nlohmann::basic_json::from_bson

// (1)
+template<typename InputType>
+static basic_json from_bson(InputType&& i,
+                            const bool strict = true,
+                            const bool allow_exceptions = true);
 // (2)
-template<typename IteratorType>
-static basic_json from_bson(IteratorType first, IteratorType last,
-                            const bool strict = true,
-                            const bool allow_exceptions = true);
-

Deserializes a given input to a JSON value using the BSON (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.

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 BSON 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 (true by default)
allow_exceptions (in)
whether to throw exceptions in case of a parse error (optional, true by default)

Return value

deserialized JSON value; in case of a parse error and allow_exceptions set to false, the return value will be value_t::discarded. The latter can be checked with is_discarded.

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the JSON value.

Exceptions

Throws parse_error.114 if an unsupported BSON record type is encountered.

Complexity

Linear in the size of the input.

Examples

Example

The example shows the deserialization of a byte vector in BSON format to a JSON value.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+template<typename IteratorType>
+static basic_json from_bson(IteratorType first, IteratorType last,
+                            const bool strict = true,
+                            const bool allow_exceptions = true);
+

Deserializes a given input to a JSON value using the BSON (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.

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 BSON 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 (true by default)
allow_exceptions (in)
whether to throw exceptions in case of a parse error (optional, true by default)

Return value

deserialized JSON value; in case of a parse error and allow_exceptions set to false, the return value will be value_t::discarded. The latter can be checked with is_discarded.

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the JSON value.

Exceptions

Throws parse_error.114 if an unsupported BSON record type is encountered.

Complexity

Linear in the size of the input.

Examples

Example

The example shows the deserialization of a byte vector in BSON format to a JSON value.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create byte vector
-    std::vector<std::uint8_t> v = {0x1b, 0x00, 0x00, 0x00, 0x08, 0x63, 0x6f, 0x6d,
-                                   0x70, 0x61, 0x63, 0x74, 0x00, 0x01, 0x10, 0x73,
-                                   0x63, 0x68, 0x65, 0x6d, 0x61, 0x00, 0x00, 0x00,
-                                   0x00, 0x00, 0x00
-                                  };
+    std::vector<std::uint8_t> v = {0x1b, 0x00, 0x00, 0x00, 0x08, 0x63, 0x6f, 0x6d,
+                                   0x70, 0x61, 0x63, 0x74, 0x00, 0x01, 0x10, 0x73,
+                                   0x63, 0x68, 0x65, 0x6d, 0x61, 0x00, 0x00, 0x00,
+                                   0x00, 0x00, 0x00
+                                  };
 
     // deserialize it with BSON
-    json j = json::from_bson(v);
+    json j = json::from_bson(v);
 
     // print the deserialized JSON value
-    std::cout << std::setw(2) << j << std::endl;
-}
-

Output:

{
-  "compact": true,
-  "schema": 0
-}
-

See also

Version history

  • Added in version 3.4.0.

Deprecation

  • Overload (2) replaces calls to from_bson 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 from_bson(ptr, len, ...); with from_bson(ptr, ptr+len, ...);.
  • Overload (2) replaces calls to from_bson 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 from_bson({ptr, ptr+len}, ...); with from_bson(ptr, ptr+len, ...);.

You should be warned by your compiler with a -Wdeprecated-declarations warning if you are using a deprecated function.


Last update: May 1, 2022
\ No newline at end of file + std::cout << std::setw(2) << j << std::endl; +} +

Output:

{
+  "compact": true,
+  "schema": 0
+}
+

See also

Version history

  • Added in version 3.4.0.

Deprecation

  • Overload (2) replaces calls to from_bson 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 from_bson(ptr, len, ...); with from_bson(ptr, ptr+len, ...);.
  • Overload (2) replaces calls to from_bson 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 from_bson({ptr, ptr+len}, ...); with from_bson(ptr, ptr+len, ...);.

You should be warned by your compiler with a -Wdeprecated-declarations warning if you are using a deprecated function.


Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/from_cbor/index.html b/api/basic_json/from_cbor/index.html index 5ff1c752b..8ceff960e 100644 --- a/api/basic_json/from_cbor/index.html +++ b/api/basic_json/from_cbor/index.html @@ -1,38 +1,38 @@ - from_cbor - JSON for Modern C++
Skip to content

nlohmann::basic_json::from_cbor

// (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);
+ from_cbor - JSON for Modern C++       

nlohmann::basic_json::from_cbor

// (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.

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 (true by default)
allow_exceptions (in)
whether to throw exceptions in case of a parse error (optional, true by default)
tag_handler (in)
how to treat CBOR tags (optional, error by default); see cbor_tag_handler_t for more information

Return value

deserialized JSON value; in case of a parse error and allow_exceptions set to false, the return value will be value_t::discarded. The latter can be checked with is_discarded.

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the JSON value.

Exceptions

  • Throws parse_error.110 if the given input ends prematurely or the end of file was not reached when strict was set to true
  • Throws parse_error.112 if unsupported features from CBOR were used in the given input or if the input is not valid CBOR
  • Throws parse_error.113 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.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+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.

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 (true by default)
allow_exceptions (in)
whether to throw exceptions in case of a parse error (optional, true by default)
tag_handler (in)
how to treat CBOR tags (optional, error by default); see cbor_tag_handler_t for more information

Return value

deserialized JSON value; in case of a parse error and allow_exceptions set to false, the return value will be value_t::discarded. The latter can be checked with is_discarded.

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the JSON value.

Exceptions

  • Throws parse_error.110 if the given input ends prematurely or the end of file was not reached when strict was set to true
  • Throws parse_error.112 if unsupported features from CBOR were used in the given input or if the input is not valid CBOR
  • Throws parse_error.113 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.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create byte vector
-    std::vector<std::uint8_t> v = {0xa2, 0x67, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63,
-                                   0x74, 0xf5, 0x66, 0x73, 0x63, 0x68, 0x65, 0x6d,
-                                   0x61, 0x00
-                                  };
+    std::vector<std::uint8_t> v = {0xa2, 0x67, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63,
+                                   0x74, 0xf5, 0x66, 0x73, 0x63, 0x68, 0x65, 0x6d,
+                                   0x61, 0x00
+                                  };
 
     // deserialize it with CBOR
-    json j = json::from_cbor(v);
+    json j = json::from_cbor(v);
 
     // print the deserialized JSON value
-    std::cout << std::setw(2) << j << std::endl;
-}
-

Output:

{
-  "compact": true,
-  "schema": 0
-}
-

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.

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 from_cbor(ptr, len, ...); with 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 from_cbor({ptr, ptr+len}, ...); with from_cbor(ptr, ptr+len, ...);.

You should be warned by your compiler with a -Wdeprecated-declarations warning if you are using a deprecated function.


Last update: May 1, 2022
\ No newline at end of file + std::cout << std::setw(2) << j << std::endl; +} +

Output:

{
+  "compact": true,
+  "schema": 0
+}
+

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.

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 from_cbor(ptr, len, ...); with 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 from_cbor({ptr, ptr+len}, ...); with from_cbor(ptr, ptr+len, ...);.

You should be warned by your compiler with a -Wdeprecated-declarations warning if you are using a deprecated function.


Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/from_msgpack/index.html b/api/basic_json/from_msgpack/index.html index 9bbc647be..2efb9295e 100644 --- a/api/basic_json/from_msgpack/index.html +++ b/api/basic_json/from_msgpack/index.html @@ -1,35 +1,35 @@ - from_msgpack - JSON for Modern C++
Skip to content

nlohmann::basic_json::from_msgpack

// (1)
-template<typename InputType>
-static basic_json from_msgpack(InputType&& i,
-                               const bool strict = true,
-                               const bool allow_exceptions = true);
+ from_msgpack - JSON for Modern C++       

nlohmann::basic_json::from_msgpack

// (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.

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 (true by default)
allow_exceptions (in)
whether to throw exceptions in case of a parse error (optional, true by default)

Return value

deserialized JSON value; in case of a parse error and allow_exceptions set to false, the return value will be value_t::discarded. The latter can be checked with is_discarded.

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the JSON value.

Exceptions

  • Throws parse_error.110 if the given input ends prematurely or the end of file was not reached when strict was set to true
  • Throws parse_error.112 if unsupported features from MessagePack were used in the given input or if the input is not valid MessagePack
  • Throws parse_error.113 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.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+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.

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 (true by default)
allow_exceptions (in)
whether to throw exceptions in case of a parse error (optional, true by default)

Return value

deserialized JSON value; in case of a parse error and allow_exceptions set to false, the return value will be value_t::discarded. The latter can be checked with is_discarded.

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the JSON value.

Exceptions

  • Throws parse_error.110 if the given input ends prematurely or the end of file was not reached when strict was set to true
  • Throws parse_error.112 if unsupported features from MessagePack were used in the given input or if the input is not valid MessagePack
  • Throws parse_error.113 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.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create byte vector
-    std::vector<std::uint8_t> v = {0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63,
-                                   0x74, 0xc3, 0xa6, 0x73, 0x63, 0x68, 0x65, 0x6d,
-                                   0x61, 0x00
-                                  };
+    std::vector<std::uint8_t> v = {0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63,
+                                   0x74, 0xc3, 0xa6, 0x73, 0x63, 0x68, 0x65, 0x6d,
+                                   0x61, 0x00
+                                  };
 
     // deserialize it with MessagePack
-    json j = json::from_msgpack(v);
+    json j = json::from_msgpack(v);
 
     // print the deserialized JSON value
-    std::cout << std::setw(2) << j << std::endl;
-}
-

Output:

{
-  "compact": true,
-  "schema": 0
-}
-

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.

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 from_msgpack(ptr, len, ...); with 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 from_msgpack({ptr, ptr+len}, ...); with from_msgpack(ptr, ptr+len, ...);.

You should be warned by your compiler with a -Wdeprecated-declarations warning if you are using a deprecated function.


Last update: May 1, 2022
\ No newline at end of file + std::cout << std::setw(2) << j << std::endl; +} +

Output:

{
+  "compact": true,
+  "schema": 0
+}
+

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.

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 from_msgpack(ptr, len, ...); with 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 from_msgpack({ptr, ptr+len}, ...); with from_msgpack(ptr, ptr+len, ...);.

You should be warned by your compiler with a -Wdeprecated-declarations warning if you are using a deprecated function.


Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/from_ubjson/index.html b/api/basic_json/from_ubjson/index.html index 95af6afaf..ba36012d1 100644 --- a/api/basic_json/from_ubjson/index.html +++ b/api/basic_json/from_ubjson/index.html @@ -1,35 +1,35 @@ - from_ubjson - JSON for Modern C++
Skip to content

nlohmann::basic_json::from_ubjson

// (1)
-template<typename InputType>
-static basic_json from_ubjson(InputType&& i,
-                              const bool strict = true,
-                              const bool allow_exceptions = true);
+ from_ubjson - JSON for Modern C++       

nlohmann::basic_json::from_ubjson

// (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.

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 (true by default)
allow_exceptions (in)
whether to throw exceptions in case of a parse error (optional, true by default)

Return value

deserialized JSON value; in case of a parse error and allow_exceptions set to false, the return value will be value_t::discarded. The latter can be checked with is_discarded.

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the JSON value.

Exceptions

  • Throws parse_error.110 if the given input ends prematurely or the end of file was not reached when strict was set to true
  • Throws parse_error.112 if a parse error occurs
  • Throws parse_error.113 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.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+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.

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 (true by default)
allow_exceptions (in)
whether to throw exceptions in case of a parse error (optional, true by default)

Return value

deserialized JSON value; in case of a parse error and allow_exceptions set to false, the return value will be value_t::discarded. The latter can be checked with is_discarded.

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the JSON value.

Exceptions

  • Throws parse_error.110 if the given input ends prematurely or the end of file was not reached when strict was set to true
  • Throws parse_error.112 if a parse error occurs
  • Throws parse_error.113 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.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create byte vector
-    std::vector<std::uint8_t> v = {0x7B, 0x69, 0x07, 0x63, 0x6F, 0x6D, 0x70, 0x61,
-                                   0x63, 0x74, 0x54, 0x69, 0x06, 0x73, 0x63, 0x68,
-                                   0x65, 0x6D, 0x61, 0x69, 0x00, 0x7D
-                                  };
+    std::vector<std::uint8_t> v = {0x7B, 0x69, 0x07, 0x63, 0x6F, 0x6D, 0x70, 0x61,
+                                   0x63, 0x74, 0x54, 0x69, 0x06, 0x73, 0x63, 0x68,
+                                   0x65, 0x6D, 0x61, 0x69, 0x00, 0x7D
+                                  };
 
     // deserialize it with UBJSON
-    json j = json::from_ubjson(v);
+    json j = json::from_ubjson(v);
 
     // print the deserialized JSON value
-    std::cout << std::setw(2) << j << std::endl;
-}
-

Output:

{
-  "compact": true,
-  "schema": 0
-}
-

Version history

  • Added in version 3.1.0.
  • Added allow_exceptions parameter in version 3.2.0.

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 from_ubjson(ptr, len, ...); with 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 from_ubjson({ptr, ptr+len}, ...); with from_ubjson(ptr, ptr+len, ...);.

You should be warned by your compiler with a -Wdeprecated-declarations warning if you are using a deprecated function.


Last update: May 1, 2022
\ No newline at end of file + std::cout << std::setw(2) << j << std::endl; +} +

Output:

{
+  "compact": true,
+  "schema": 0
+}
+

Version history

  • Added in version 3.1.0.
  • Added allow_exceptions parameter in version 3.2.0.

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 from_ubjson(ptr, len, ...); with 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 from_ubjson({ptr, ptr+len}, ...); with from_ubjson(ptr, ptr+len, ...);.

You should be warned by your compiler with a -Wdeprecated-declarations warning if you are using a deprecated function.


Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/front/index.html b/api/basic_json/front/index.html index 9a253605f..5114d2126 100644 --- a/api/basic_json/front/index.html +++ b/api/basic_json/front/index.html @@ -1,38 +1,38 @@ - front - JSON for Modern C++
Skip to content

nlohmann::basic_json::front

reference front();
-const_reference front() const;
-

Returns a reference to the first element in the container. For a JSON container c, the expression c.front() is equivalent to *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 null, exception invalid_iterator.214 is thrown.

Complexity

Constant.

Notes

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().

#include <iostream>
-#include <nlohmann/json.hpp>
+ front - JSON for Modern C++       

nlohmann::basic_json::front

reference front();
+const_reference front() const;
+

Returns a reference to the first element in the container. For a JSON container c, the expression c.front() is equivalent to *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 null, exception invalid_iterator.214 is thrown.

Complexity

Constant.

Notes

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().

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_object_empty(json::value_t::object);
-    json j_array = {1, 2, 4, 8, 16};
-    json j_array_empty(json::value_t::array);
-    json j_string = "Hello, world";
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_object_empty(json::value_t::object);
+    json j_array = {1, 2, 4, 8, 16};
+    json j_array_empty(json::value_t::array);
+    json j_string = "Hello, world";
 
     // call front()
     //std::cout << j_null.front() << '\n';          // would throw
-    std::cout << j_boolean.front() << '\n';
-    std::cout << j_number_integer.front() << '\n';
-    std::cout << j_number_float.front() << '\n';
-    std::cout << j_object.front() << '\n';
+    std::cout << j_boolean.front() << '\n';
+    std::cout << j_number_integer.front() << '\n';
+    std::cout << j_number_float.front() << '\n';
+    std::cout << j_object.front() << '\n';
     //std::cout << j_object_empty.front() << '\n';  // undefined behavior
-    std::cout << j_array.front() << '\n';
+    std::cout << j_array.front() << '\n';
     //std::cout << j_array_empty.front() << '\n';   // undefined behavior
-    std::cout << j_string.front() << '\n';
-}
-

Output:

true
-17
-23.42
-1
-1
-"Hello, world"
-

See also

  • back 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.

Last update: May 1, 2022
\ No newline at end of file + std::cout << j_string.front() << '\n'; +} +

Output:

true
+17
+23.42
+1
+1
+"Hello, world"
+

See also

  • back 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.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/get/index.html b/api/basic_json/get/index.html index e9a0fd7ce..73ef79396 100644 --- a/api/basic_json/get/index.html +++ b/api/basic_json/get/index.html @@ -1,106 +1,106 @@ - get - JSON for Modern C++
Skip to content

nlohmann::basic_json::get

// (1)
-template<typename ValueType>
-ValueType get() const noexcept(
-    noexcept(JSONSerializer<ValueType>::from_json(
-        std::declval<const basic_json_t&>(), std::declval<ValueType&>())));
+ get - JSON for Modern C++       

nlohmann::basic_json::get

// (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;
+template<typename BasicJsonType>
+BasicJsonType get() const;
 
 // (3)
-template<typename PointerType>
-PointerType get_ptr();
+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 and DefaultConstructible. The value is converted by calling the json_serializer<ValueType> from_json() method.

    The function is equivalent to executing

    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 and not DefaultConstructible, the value is converted by calling the json_serializer<ValueType> from_json() method.

    The function is then equivalent to executing

    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

    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, object_t, string_t, boolean_t, number_integer_t, or number_unsigned_t, number_float_t, or binary_t. Other types will not compile.

Return value

  1. copy of the JSON value, converted to ValueType
  2. a copy of *this, converted into BasicJsonType
  3. pointer to the internally stored JSON value if the requested pointer type fits to the JSON value; nullptr otherwise

Exceptions

Depends on what json_serializer<ValueType> from_json() method throws

Notes

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>.

#include <iostream>
-#include <unordered_map>
-#include <nlohmann/json.hpp>
+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 and DefaultConstructible. The value is converted by calling the json_serializer<ValueType> from_json() method.

    The function is equivalent to executing

    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 and not DefaultConstructible, the value is converted by calling the json_serializer<ValueType> from_json() method.

    The function is then equivalent to executing

    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

    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, object_t, string_t, boolean_t, number_integer_t, or number_unsigned_t, number_float_t, or binary_t. Other types will not compile.

Return value

  1. copy of the JSON value, converted to ValueType
  2. a copy of *this, converted into BasicJsonType
  3. pointer to the internally stored JSON value if the requested pointer type fits to the JSON value; nullptr otherwise

Exceptions

Depends on what json_serializer<ValueType> from_json() method throws

Notes

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>.

#include <iostream>
+#include <unordered_map>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON value with different types
-    json json_types =
-    {
-        {"boolean", true},
-        {
-            "number", {
-                {"integer", 42},
-                {"floating-point", 17.23}
-            }
-        },
-        {"string", "Hello, world!"},
-        {"array", {1, 2, 3, 4, 5}},
-        {"null", nullptr}
-    };
+    json json_types =
+    {
+        {"boolean", true},
+        {
+            "number", {
+                {"integer", 42},
+                {"floating-point", 17.23}
+            }
+        },
+        {"string", "Hello, world!"},
+        {"array", {1, 2, 3, 4, 5}},
+        {"null", nullptr}
+    };
 
     // use explicit conversions
-    auto v1 = json_types["boolean"].template get<bool>();
-    auto v2 = json_types["number"]["integer"].template get<int>();
-    auto v3 = json_types["number"]["integer"].template get<short>();
-    auto v4 = json_types["number"]["floating-point"].template get<float>();
-    auto v5 = json_types["number"]["floating-point"].template get<int>();
-    auto v6 = json_types["string"].template get<std::string>();
-    auto v7 = json_types["array"].template get<std::vector<short>>();
-    auto v8 = json_types.template get<std::unordered_map<std::string, json>>();
+    auto v1 = json_types["boolean"].template get<bool>();
+    auto v2 = json_types["number"]["integer"].template get<int>();
+    auto v3 = json_types["number"]["integer"].template get<short>();
+    auto v4 = json_types["number"]["floating-point"].template get<float>();
+    auto v5 = json_types["number"]["floating-point"].template get<int>();
+    auto v6 = json_types["string"].template get<std::string>();
+    auto v7 = json_types["array"].template get<std::vector<short>>();
+    auto v8 = json_types.template get<std::unordered_map<std::string, json>>();
 
     // print the conversion results
-    std::cout << v1 << '\n';
-    std::cout << v2 << ' ' << v3 << '\n';
-    std::cout << v4 << ' ' << v5 << '\n';
-    std::cout << v6 << '\n';
+    std::cout << v1 << '\n';
+    std::cout << v2 << ' ' << v3 << '\n';
+    std::cout << v4 << ' ' << v5 << '\n';
+    std::cout << v6 << '\n';
 
-    for (auto i : v7)
-    {
-        std::cout << i << ' ';
-    }
-    std::cout << "\n\n";
+    for (auto i : v7)
+    {
+        std::cout << i << ' ';
+    }
+    std::cout << "\n\n";
 
-    for (auto i : v8)
-    {
-        std::cout << i.first << ": " << i.second << '\n';
-    }
-}
-

Output:

1
-42 42
-17.23 17
-Hello, world!
+    for (auto i : v8)
+    {
+        std::cout << i.first << ": " << i.second << '\n';
+    }
+}
+

Output:

1
+42 42
+17.23 17
+Hello, world!
 1 2 3 4 5 
 
-string: "Hello, world!"
-number: {"floating-point":17.23,"integer":42}
-null: null
-boolean: true
-array: [1,2,3,4,5]
-
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.

#include <iostream>
-#include <nlohmann/json.hpp>
+string: "Hello, world!"
+number: {"floating-point":17.23,"integer":42}
+null: null
+boolean: true
+array: [1,2,3,4,5]
+
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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON number
-    json value = 17;
+    json value = 17;
 
     // explicitly getting pointers
-    auto p1 = value.template get<const json::number_integer_t*>();
-    auto p2 = value.template get<json::number_integer_t*>();
-    auto p3 = value.template get<json::number_integer_t* const>();
-    auto p4 = value.template get<const json::number_integer_t* const>();
-    auto p5 = value.template get<json::number_float_t*>();
+    auto p1 = value.template get<const json::number_integer_t*>();
+    auto p2 = value.template get<json::number_integer_t*>();
+    auto p3 = value.template get<json::number_integer_t* const>();
+    auto p4 = value.template get<const json::number_integer_t* const>();
+    auto p5 = value.template get<json::number_float_t*>();
 
     // print the pointees
-    std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n';
-    std::cout << std::boolalpha << (p5 == nullptr) << '\n';
-}
-

Output:

17 17 17 17
-true
-

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.

Last update: May 1, 2022
\ No newline at end of file + std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n'; + std::cout << std::boolalpha << (p5 == nullptr) << '\n'; +} +

Output:

17 17 17 17
+true
+

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.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/get_allocator/index.html b/api/basic_json/get_allocator/index.html index f1c1921f8..3595fd913 100644 --- a/api/basic_json/get_allocator/index.html +++ b/api/basic_json/get_allocator/index.html @@ -1,21 +1,21 @@ - get_allocator - JSON for Modern C++
Skip to content

nlohmann::basic_json::get_allocator

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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ get_allocator - JSON for Modern C++       

nlohmann::basic_json::get_allocator

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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    auto alloc = json::get_allocator();
-    using traits_t = std::allocator_traits<decltype(alloc)>;
+int main()
+{
+    auto alloc = json::get_allocator();
+    using traits_t = std::allocator_traits<decltype(alloc)>;
 
-    json* j = traits_t::allocate(alloc, 1);
-    traits_t::construct(alloc, j, "Hello, world!");
+    json* j = traits_t::allocate(alloc, 1);
+    traits_t::construct(alloc, j, "Hello, world!");
 
-    std::cout << *j << std::endl;
+    std::cout << *j << std::endl;
 
-    traits_t::destroy(alloc, j);
-    traits_t::deallocate(alloc, j, 1);
-}
-

Output:

"Hello, world!"
-

Version history

  • Added in version 1.0.0.

Last update: May 17, 2022
\ No newline at end of file + traits_t::destroy(alloc, j); + traits_t::deallocate(alloc, j, 1); +} +

Output:

"Hello, world!"
+

Version history

  • Added in version 1.0.0.

Last update: May 17, 2022
\ No newline at end of file diff --git a/api/basic_json/get_binary/index.html b/api/basic_json/get_binary/index.html index 51e90ee25..516ab4eff 100644 --- a/api/basic_json/get_binary/index.html +++ b/api/basic_json/get_binary/index.html @@ -1,21 +1,21 @@ - get_binary - JSON for Modern C++
Skip to content

nlohmann::basic_json::get_binary

binary_t& get_binary();
+ get_binary - JSON for Modern C++       

nlohmann::basic_json::get_binary

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 if the value is not binary

Complexity

Constant.

Examples

Example

The following code shows how to query a binary value.

#include <iostream>
-#include <nlohmann/json.hpp>
+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 if the value is not binary

Complexity

Constant.

Examples

Example

The following code shows how to query a binary value.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a binary vector
-    std::vector<std::uint8_t> vec = {0xCA, 0xFE, 0xBA, 0xBE};
+    std::vector<std::uint8_t> vec = {0xCA, 0xFE, 0xBA, 0xBE};
 
     // create a binary JSON value with subtype 42
-    json j = json::binary(vec, 42);
+    json j = json::binary(vec, 42);
 
     // output type and subtype
-    std::cout << "type: " << j.type_name() << ", subtype: " << j.get_binary().subtype() << std::endl;
-}
-

Output:

type: binary, subtype: 42
-

Version history

  • Added in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << "type: " << j.type_name() << ", subtype: " << j.get_binary().subtype() << std::endl; +} +

Output:

type: binary, subtype: 42
+

Version history

  • Added in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/get_ptr/index.html b/api/basic_json/get_ptr/index.html index b48d24003..6d0434c52 100644 --- a/api/basic_json/get_ptr/index.html +++ b/api/basic_json/get_ptr/index.html @@ -1,29 +1,29 @@ - get_ptr - JSON for Modern C++
Skip to content

nlohmann::basic_json::get_ptr

template<typename PointerType>
-PointerType get_ptr() noexcept;
+ get_ptr - JSON for Modern C++       

nlohmann::basic_json::get_ptr

template<typename PointerType>
+PointerType get_ptr() noexcept;
 
-template<typename PointerType>
-constexpr const PointerType get_ptr() const noexcept;
-

Implicit pointer access to the internally stored JSON value. No copies are made.

Template parameters

PointerType
pointer type; must be a pointer to array_t, object_t, string_t, boolean_t, number_integer_t, or number_unsigned_t, number_float_t, or binary_t. Other types will not compile.

Return value

pointer to the internally stored JSON value if the requested pointer type fits to the JSON value; nullptr otherwise

Exception safety

No-throw guarantee: this function never throws exceptions.

Complexity

Constant.

Notes

Undefined behavior

Writing data to the pointee of the result yields an undefined state.

Examples

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 nullptr is returned if the value and the requested pointer type does not match.

#include <iostream>
-#include <nlohmann/json.hpp>
+template<typename PointerType>
+constexpr const PointerType get_ptr() const noexcept;
+

Implicit pointer access to the internally stored JSON value. No copies are made.

Template parameters

PointerType
pointer type; must be a pointer to array_t, object_t, string_t, boolean_t, number_integer_t, or number_unsigned_t, number_float_t, or binary_t. Other types will not compile.

Return value

pointer to the internally stored JSON value if the requested pointer type fits to the JSON value; nullptr otherwise

Exception safety

No-throw guarantee: this function never throws exceptions.

Complexity

Constant.

Notes

Undefined behavior

Writing data to the pointee of the result yields an undefined state.

Examples

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 nullptr is returned if the value and the requested pointer type does not match.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON number
-    json value = 17;
+    json value = 17;
 
     // explicitly getting pointers
-    auto p1 = value.get_ptr<const json::number_integer_t*>();
-    auto p2 = value.get_ptr<json::number_integer_t*>();
-    auto p3 = value.get_ptr<json::number_integer_t* const>();
-    auto p4 = value.get_ptr<const json::number_integer_t* const>();
-    auto p5 = value.get_ptr<json::number_float_t*>();
+    auto p1 = value.get_ptr<const json::number_integer_t*>();
+    auto p2 = value.get_ptr<json::number_integer_t*>();
+    auto p3 = value.get_ptr<json::number_integer_t* const>();
+    auto p4 = value.get_ptr<const json::number_integer_t* const>();
+    auto p5 = value.get_ptr<json::number_float_t*>();
 
     // print the pointees
-    std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n';
-    std::cout << std::boolalpha << (p5 == nullptr) << '\n';
-}
-

Output:

17 17 17 17
-true
-

Version history

  • Added in version 1.0.0.
  • Extended to binary types in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n'; + std::cout << std::boolalpha << (p5 == nullptr) << '\n'; +} +

Output:

17 17 17 17
+true
+

Version history

  • Added in version 1.0.0.
  • Extended to binary types in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/get_ref/index.html b/api/basic_json/get_ref/index.html index 732bc9e43..fadd6abe1 100644 --- a/api/basic_json/get_ref/index.html +++ b/api/basic_json/get_ref/index.html @@ -1,35 +1,35 @@ - get_ref - JSON for Modern C++
Skip to content

nlohmann::basic_json::get_ref

template<typename ReferenceType>
-ReferenceType get_ref();
+ get_ref - JSON for Modern C++       

nlohmann::basic_json::get_ref

template<typename ReferenceType>
+ReferenceType get_ref();
 
-template<typename ReferenceType>
-const ReferenceType get_ref() const;
-

Implicit reference access to the internally stored JSON value. No copies are made.

Template parameters

ReferenceType
reference type; must be a reference to array_t, object_t, string_t, boolean_t, number_integer_t, or number_unsigned_t, number_float_t, or binary_t. Enforced by a static assertion.

Return value

reference to the internally stored JSON value if the requested reference type fits to the JSON value; throws type_error.303 otherwise

Exception safety

Strong exception safety: if an exception occurs, the original value stays intact.

Exceptions

Throws type_error.303 if the requested reference type does not match the stored JSON value type; example: "incompatible ReferenceType for get_ref, actual type is binary".

Complexity

Constant.

Notes

Undefined behavior

Writing data to the referee of the result yields an undefined state.

Examples

Example

The example shows several calls to get_ref().

#include <iostream>
-#include <nlohmann/json.hpp>
+template<typename ReferenceType>
+const ReferenceType get_ref() const;
+

Implicit reference access to the internally stored JSON value. No copies are made.

Template parameters

ReferenceType
reference type; must be a reference to array_t, object_t, string_t, boolean_t, number_integer_t, or number_unsigned_t, number_float_t, or binary_t. Enforced by a static assertion.

Return value

reference to the internally stored JSON value if the requested reference type fits to the JSON value; throws type_error.303 otherwise

Exception safety

Strong exception safety: if an exception occurs, the original value stays intact.

Exceptions

Throws type_error.303 if the requested reference type does not match the stored JSON value type; example: "incompatible ReferenceType for get_ref, actual type is binary".

Complexity

Constant.

Notes

Undefined behavior

Writing data to the referee of the result yields an undefined state.

Examples

Example

The example shows several calls to get_ref().

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON number
-    json value = 17;
+    json value = 17;
 
     // explicitly getting references
-    auto r1 = value.get_ref<const json::number_integer_t&>();
-    auto r2 = value.get_ref<json::number_integer_t&>();
+    auto r1 = value.get_ref<const json::number_integer_t&>();
+    auto r2 = value.get_ref<json::number_integer_t&>();
 
     // print the values
-    std::cout << r1 << ' ' << r2 << '\n';
+    std::cout << r1 << ' ' << r2 << '\n';
 
     // incompatible type throws exception
-    try
-    {
-        auto r3 = value.get_ref<json::number_float_t&>();
-    }
-    catch (const json::type_error& ex)
-    {
-        std::cout << ex.what() << '\n';
-    }
-}
-

Output:

17 17
-[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number
-

Version history

  • Added in version 1.1.0.
  • Extended to binary types in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file + try + { + auto r3 = value.get_ref<json::number_float_t&>(); + } + catch (const json::type_error& ex) + { + std::cout << ex.what() << '\n'; + } +} +

Output:

17 17
+[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number
+

Version history

  • Added in version 1.1.0.
  • Extended to binary types in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/get_to/index.html b/api/basic_json/get_to/index.html index 86141103a..c5050d1c2 100644 --- a/api/basic_json/get_to/index.html +++ b/api/basic_json/get_to/index.html @@ -1,77 +1,77 @@ - get_to - JSON for Modern C++
Skip to content

nlohmann::basic_json::get_to

template<typename ValueType>
-ValueType& get_to(ValueType& v) const noexcept(
-    noexcept(JSONSerializer<ValueType>::from_json(
-        std::declval<const basic_json_t&>(), v)));
-

Explicit type conversion between the JSON value and a compatible value. The value is filled into the input parameter by calling the json_serializer<ValueType> from_json() method.

The function is equivalent to executing

ValueType v;
-JSONSerializer<ValueType>::from_json(*this, v);
-

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&)

Template parameters

ValueType
the value type to return

Return value

the input parameter, allowing chaining calls

Exceptions

Depends on what json_serializer<ValueType> from_json() method throws

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 #cpp std::unordered_map<std::string, json>.

#include <iostream>
-#include <unordered_map>
-#include <nlohmann/json.hpp>
+ get_to - JSON for Modern C++       

nlohmann::basic_json::get_to

template<typename ValueType>
+ValueType& get_to(ValueType& v) const noexcept(
+    noexcept(JSONSerializer<ValueType>::from_json(
+        std::declval<const basic_json_t&>(), v)));
+

Explicit type conversion between the JSON value and a compatible value. The value is filled into the input parameter by calling the json_serializer<ValueType> from_json() method.

The function is equivalent to executing

ValueType v;
+JSONSerializer<ValueType>::from_json(*this, v);
+

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&)

Template parameters

ValueType
the value type to return

Return value

the input parameter, allowing chaining calls

Exceptions

Depends on what json_serializer<ValueType> from_json() method throws

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 #cpp std::unordered_map<std::string, json>.

#include <iostream>
+#include <unordered_map>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON value with different types
-    json json_types =
-    {
-        {"boolean", true},
-        {
-            "number", {
-                {"integer", 42},
-                {"floating-point", 17.23}
-            }
-        },
-        {"string", "Hello, world!"},
-        {"array", {1, 2, 3, 4, 5}},
-        {"null", nullptr}
-    };
+    json json_types =
+    {
+        {"boolean", true},
+        {
+            "number", {
+                {"integer", 42},
+                {"floating-point", 17.23}
+            }
+        },
+        {"string", "Hello, world!"},
+        {"array", {1, 2, 3, 4, 5}},
+        {"null", nullptr}
+    };
 
-    bool v1;
-    int v2;
-    short v3;
-    float v4;
-    int v5;
-    std::string v6;
-    std::vector<short> v7;
-    std::unordered_map<std::string, json> v8;
+    bool v1;
+    int v2;
+    short v3;
+    float v4;
+    int v5;
+    std::string v6;
+    std::vector<short> v7;
+    std::unordered_map<std::string, json> v8;
 
     // use explicit conversions
-    json_types["boolean"].get_to(v1);
-    json_types["number"]["integer"].get_to(v2);
-    json_types["number"]["integer"].get_to(v3);
-    json_types["number"]["floating-point"].get_to(v4);
-    json_types["number"]["floating-point"].get_to(v5);
-    json_types["string"].get_to(v6);
-    json_types["array"].get_to(v7);
-    json_types.get_to(v8);
+    json_types["boolean"].get_to(v1);
+    json_types["number"]["integer"].get_to(v2);
+    json_types["number"]["integer"].get_to(v3);
+    json_types["number"]["floating-point"].get_to(v4);
+    json_types["number"]["floating-point"].get_to(v5);
+    json_types["string"].get_to(v6);
+    json_types["array"].get_to(v7);
+    json_types.get_to(v8);
 
     // print the conversion results
-    std::cout << v1 << '\n';
-    std::cout << v2 << ' ' << v3 << '\n';
-    std::cout << v4 << ' ' << v5 << '\n';
-    std::cout << v6 << '\n';
+    std::cout << v1 << '\n';
+    std::cout << v2 << ' ' << v3 << '\n';
+    std::cout << v4 << ' ' << v5 << '\n';
+    std::cout << v6 << '\n';
 
-    for (auto i : v7)
-    {
-        std::cout << i << ' ';
-    }
-    std::cout << "\n\n";
+    for (auto i : v7)
+    {
+        std::cout << i << ' ';
+    }
+    std::cout << "\n\n";
 
-    for (auto i : v8)
-    {
-        std::cout << i.first << ": " << i.second << '\n';
-    }
-}
-

Output:

1
-42 42
-17.23 17
-Hello, world!
+    for (auto i : v8)
+    {
+        std::cout << i.first << ": " << i.second << '\n';
+    }
+}
+

Output:

1
+42 42
+17.23 17
+Hello, world!
 1 2 3 4 5 
 
-string: "Hello, world!"
-number: {"floating-point":17.23,"integer":42}
-null: null
-boolean: true
-array: [1,2,3,4,5]
-

Version history

  • Since version 3.3.0.

Last update: May 1, 2022
\ No newline at end of file +string: "Hello, world!" +number: {"floating-point":17.23,"integer":42} +null: null +boolean: true +array: [1,2,3,4,5] +

Version history

  • Since version 3.3.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/index.html b/api/basic_json/index.html index 8cd8e31cd..a5ace1c04 100644 --- a/api/basic_json/index.html +++ b/api/basic_json/index.html @@ -1,81 +1,81 @@ - Overview - JSON for Modern C++
Skip to content

nlohmann::basic_json

Defined in header <nlohmann/json.hpp>

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
ArrayType type for JSON arrays array_t
StringType type for JSON strings and object keys string_t
BooleanType type for JSON booleans boolean_t
NumberIntegerType type for JSON integer numbers number_integer_t
NumberUnsignedType type for JSON unsigned integer numbers number_unsigned_t
NumberFloatType type for JSON floating-point numbers number_float_t
AllocatorType type of the allocator to use
JSONSerializer the serializer to resolve internal calls to to_json() and from_json() json_serializer
BinaryType type for binary arrays binary_t
CustomBaseClass extension point for user code json_base_class_t

Specializations

  • json - default specialization
  • ordered_json - specialization that maintains the insertion order of object keys

Iterator invalidation

Todo

Requirements

The class satisfies the following concept requirements:

Basic

Layout

  • StandardLayoutType: JSON values have 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: JSON values can be compared with ==, see operator==.
  • LessThanComparable: JSON values can be compared with <, see operator<.
  • Swappable: Any JSON lvalue or rvalue of can be swapped with any lvalue or rvalue of other compatible types, using unqualified function swap.
  • NullablePointer: JSON values can be compared against std::nullptr_t objects which are used to model the null value.

Container

  • Container: JSON values can be used like STL containers and provide iterator access.
  • ReversibleContainer: JSON values can be used like STL containers and provide reverse iterator access.

Member types

Exceptions

  • exception - general exception of the basic_json class
    • parse_error - exception indicating a parse error
    • invalid_iterator - exception indicating errors with iterators
    • type_error - exception indicating executing a member function with a wrong type
    • out_of_range - exception indicating access out of the defined range
    • other_error - exception indicating other library errors

Container types

Type Definition
value_type basic_json
reference value_type&
const_reference const value_type&
difference_type std::ptrdiff_t
size_type std::size_t
allocator_type AllocatorType<basic_json>
pointer std::allocator_traits<allocator_type>::pointer
const_pointer std::allocator_traits<allocator_type>::const_pointer
iterator LegacyBidirectionalIterator
const_iterator constant LegacyBidirectionalIterator
reverse_iterator reverse iterator, derived from iterator
const_reverse_iterator reverse iterator, derived from const_iterator
iteration_proxy helper type for items function

JSON value data types

Parser callback

Member functions

Object inspection

Functions to inspect the type of a JSON value.

Value access

Direct access to the stored value of a JSON value.

Element access

Access to the JSON value

  • at - access specified element with bounds checking
  • operator[] - access specified element
  • value - access specified object element with default value
  • front - access the first element
  • back - access the last element

Lookup

  • find - find an element in a JSON object
  • count - returns the number of occurrences of a key in a JSON object
  • contains - check the existence of an element in a JSON object

Iterators

  • begin - returns an iterator to the first element
  • cbegin - returns a const iterator to the first element
  • end - returns an iterator to one past the last element
  • cend - returns a const iterator to one past the last element
  • rbegin - returns an iterator to the reverse-beginning
  • rend - returns an iterator to the reverse-end
  • crbegin - returns a const iterator to the reverse-beginning
  • crend - returns a const iterator to the reverse-end
  • items - wrapper to access iterator member functions in range-based for

Capacity

  • empty - checks whether the container is empty
  • size - returns the number of elements
  • max_size - returns the maximum possible number of elements

Modifiers

  • clear - clears the contents
  • push_back - add a value to an array/object
  • operator+= - add a value to an array/object
  • emplace_back - add a value to an array
  • emplace - add a value to an object if key does not exist
  • erase - remove elements
  • insert - inserts elements
  • update - updates a JSON object from another object, overwriting existing keys
  • swap - exchanges the values

Lexicographical comparison operators

Serialization / Dumping

  • dump - serialization

Deserialization / Parsing

  • parse (static) - deserialize from a compatible input
  • accept (static) - check if the input is valid JSON
  • sax_parse (static) - generate SAX events

JSON Pointer functions

  • flatten - return flattened JSON value
  • unflatten - unflatten a previously flattened JSON value

JSON Patch functions

  • patch - applies a JSON patch
  • patch_inplace - applies a JSON patch in place
  • diff (static) - creates a diff as a JSON patch

JSON Merge Patch functions

Static functions

  • meta - returns version information on the library
  • get_allocator - returns the allocator associated with the container

Binary formats

  • from_bjdata (static) - create a JSON value from an input in BJData format
  • from_bson (static) - create a JSON value from an input in BSON format
  • from_cbor (static) - create a JSON value from an input in CBOR format
  • from_msgpack (static) - create a JSON value from an input in MessagePack format
  • from_ubjson (static) - create a JSON value from an input in UBJSON format
  • to_bjdata (static) - create a BJData serialization of a given JSON value
  • to_bson (static) - create a BSON serialization of a given JSON value
  • to_cbor (static) - create a CBOR serialization of a given JSON value
  • to_msgpack (static) - create a MessagePack serialization of a given JSON value
  • to_ubjson (static) - create a UBJSON serialization of a given JSON value

Non-member functions

Literals

Helper classes

Examples

Example

The example shows how the library is used.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+ Overview - JSON for Modern C++       

nlohmann::basic_json

Defined in header <nlohmann/json.hpp>

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
ArrayType type for JSON arrays array_t
StringType type for JSON strings and object keys string_t
BooleanType type for JSON booleans boolean_t
NumberIntegerType type for JSON integer numbers number_integer_t
NumberUnsignedType type for JSON unsigned integer numbers number_unsigned_t
NumberFloatType type for JSON floating-point numbers number_float_t
AllocatorType type of the allocator to use
JSONSerializer the serializer to resolve internal calls to to_json() and from_json() json_serializer
BinaryType type for binary arrays binary_t
CustomBaseClass extension point for user code json_base_class_t

Specializations

  • json - default specialization
  • ordered_json - specialization that maintains the insertion order of object keys

Iterator invalidation

Todo

Requirements

The class satisfies the following concept requirements:

Basic

Layout

  • StandardLayoutType: JSON values have 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: JSON values can be compared with ==, see operator==.
  • LessThanComparable: JSON values can be compared with <, see operator<.
  • Swappable: Any JSON lvalue or rvalue of can be swapped with any lvalue or rvalue of other compatible types, using unqualified function swap.
  • NullablePointer: JSON values can be compared against std::nullptr_t objects which are used to model the null value.

Container

  • Container: JSON values can be used like STL containers and provide iterator access.
  • ReversibleContainer: JSON values can be used like STL containers and provide reverse iterator access.

Member types

Exceptions

  • exception - general exception of the basic_json class
    • parse_error - exception indicating a parse error
    • invalid_iterator - exception indicating errors with iterators
    • type_error - exception indicating executing a member function with a wrong type
    • out_of_range - exception indicating access out of the defined range
    • other_error - exception indicating other library errors

Container types

Type Definition
value_type basic_json
reference value_type&
const_reference const value_type&
difference_type std::ptrdiff_t
size_type std::size_t
allocator_type AllocatorType<basic_json>
pointer std::allocator_traits<allocator_type>::pointer
const_pointer std::allocator_traits<allocator_type>::const_pointer
iterator LegacyBidirectionalIterator
const_iterator constant LegacyBidirectionalIterator
reverse_iterator reverse iterator, derived from iterator
const_reverse_iterator reverse iterator, derived from const_iterator
iteration_proxy helper type for items function

JSON value data types

Parser callback

Member functions

Object inspection

Functions to inspect the type of a JSON value.

Value access

Direct access to the stored value of a JSON value.

Element access

Access to the JSON value

  • at - access specified element with bounds checking
  • operator[] - access specified element
  • value - access specified object element with default value
  • front - access the first element
  • back - access the last element

Lookup

  • find - find an element in a JSON object
  • count - returns the number of occurrences of a key in a JSON object
  • contains - check the existence of an element in a JSON object

Iterators

  • begin - returns an iterator to the first element
  • cbegin - returns a const iterator to the first element
  • end - returns an iterator to one past the last element
  • cend - returns a const iterator to one past the last element
  • rbegin - returns an iterator to the reverse-beginning
  • rend - returns an iterator to the reverse-end
  • crbegin - returns a const iterator to the reverse-beginning
  • crend - returns a const iterator to the reverse-end
  • items - wrapper to access iterator member functions in range-based for

Capacity

  • empty - checks whether the container is empty
  • size - returns the number of elements
  • max_size - returns the maximum possible number of elements

Modifiers

  • clear - clears the contents
  • push_back - add a value to an array/object
  • operator+= - add a value to an array/object
  • emplace_back - add a value to an array
  • emplace - add a value to an object if key does not exist
  • erase - remove elements
  • insert - inserts elements
  • update - updates a JSON object from another object, overwriting existing keys
  • swap - exchanges the values

Lexicographical comparison operators

Serialization / Dumping

  • dump - serialization

Deserialization / Parsing

  • parse (static) - deserialize from a compatible input
  • accept (static) - check if the input is valid JSON
  • sax_parse (static) - generate SAX events

JSON Pointer functions

  • flatten - return flattened JSON value
  • unflatten - unflatten a previously flattened JSON value

JSON Patch functions

  • patch - applies a JSON patch
  • patch_inplace - applies a JSON patch in place
  • diff (static) - creates a diff as a JSON patch

JSON Merge Patch functions

Static functions

  • meta - returns version information on the library
  • get_allocator - returns the allocator associated with the container

Binary formats

  • from_bjdata (static) - create a JSON value from an input in BJData format
  • from_bson (static) - create a JSON value from an input in BSON format
  • from_cbor (static) - create a JSON value from an input in CBOR format
  • from_msgpack (static) - create a JSON value from an input in MessagePack format
  • from_ubjson (static) - create a JSON value from an input in UBJSON format
  • to_bjdata (static) - create a BJData serialization of a given JSON value
  • to_bson (static) - create a BSON serialization of a given JSON value
  • to_cbor (static) - create a CBOR serialization of a given JSON value
  • to_msgpack (static) - create a MessagePack serialization of a given JSON value
  • to_ubjson (static) - create a UBJSON serialization of a given JSON value

Non-member functions

Literals

Helper classes

Examples

Example

The example shows how the library is used.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON object
-    json j =
-    {
-        {"pi", 3.141},
-        {"happy", true},
-        {"name", "Niels"},
-        {"nothing", nullptr},
-        {
-            "answer", {
-                {"everything", 42}
-            }
-        },
-        {"list", {1, 0, 2}},
-        {
-            "object", {
-                {"currency", "USD"},
-                {"value", 42.99}
-            }
-        }
-    };
+    json j =
+    {
+        {"pi", 3.141},
+        {"happy", true},
+        {"name", "Niels"},
+        {"nothing", nullptr},
+        {
+            "answer", {
+                {"everything", 42}
+            }
+        },
+        {"list", {1, 0, 2}},
+        {
+            "object", {
+                {"currency", "USD"},
+                {"value", 42.99}
+            }
+        }
+    };
 
     // add new values
-    j["new"]["key"]["value"] = {"another", "list"};
+    j["new"]["key"]["value"] = {"another", "list"};
 
     // count elements
-    auto s = j.size();
-    j["size"] = s;
+    auto s = j.size();
+    j["size"] = s;
 
     // pretty print with indent of 4 spaces
-    std::cout << std::setw(4) << j << '\n';
-}
-

Output:

{
-    "answer": {
-        "everything": 42
-    },
-    "happy": true,
-    "list": [
-        1,
-        0,
-        2
-    ],
-    "name": "Niels",
-    "new": {
-        "key": {
-            "value": [
-                "another",
-                "list"
-            ]
-        }
-    },
-    "nothing": null,
-    "object": {
-        "currency": "USD",
-        "value": 42.99
-    },
-    "pi": 3.141,
-    "size": 8
-}
-

See also

Version history

  • Added in version 1.0.0.

Last update: September 23, 2023
\ No newline at end of file + std::cout << std::setw(4) << j << '\n'; +} +

Output:

{
+    "answer": {
+        "everything": 42
+    },
+    "happy": true,
+    "list": [
+        1,
+        0,
+        2
+    ],
+    "name": "Niels",
+    "new": {
+        "key": {
+            "value": [
+                "another",
+                "list"
+            ]
+        }
+    },
+    "nothing": null,
+    "object": {
+        "currency": "USD",
+        "value": 42.99
+    },
+    "pi": 3.141,
+    "size": 8
+}
+

See also

Version history

  • Added in version 1.0.0.

Last update: November 1, 2023
\ No newline at end of file diff --git a/api/basic_json/input_format_t/index.html b/api/basic_json/input_format_t/index.html index ece7d5e55..ea7ff9676 100644 --- a/api/basic_json/input_format_t/index.html +++ b/api/basic_json/input_format_t/index.html @@ -1,126 +1,126 @@ - input_format_t - JSON for Modern C++
Skip to content

nlohmann::basic_json::input_format_t

enum class input_format_t {
-    json,
-    cbor,
-    msgpack,
-    ubjson,
-    bson,
-    bjdata
-};
-

This enumeration is used in the sax_parse function to choose the input format to parse:

json
JSON (JavaScript Object Notation)
cbor
CBOR (Concise Binary Object Representation)
msgpack
MessagePack
ubjson
UBJSON (Universal Binary JSON)
bson
BSON (Binary JSON)
bjdata
BJData (Binary JData)

Examples

Example

The example below shows how an input_format_t enum value is passed to sax_parse to set the input format to CBOR.

#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <nlohmann/json.hpp>
+ input_format_t - JSON for Modern C++       

nlohmann::basic_json::input_format_t

enum class input_format_t {
+    json,
+    cbor,
+    msgpack,
+    ubjson,
+    bson,
+    bjdata
+};
+

This enumeration is used in the sax_parse function to choose the input format to parse:

json
JSON (JavaScript Object Notation)
cbor
CBOR (Concise Binary Object Representation)
msgpack
MessagePack
ubjson
UBJSON (Universal Binary JSON)
bson
BSON (Binary JSON)
bjdata
BJData (Binary JData)

Examples

Example

The example below shows how an input_format_t enum value is passed to sax_parse to set the input format to CBOR.

#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
 // a simple event consumer that collects string representations of the passed
 // values; note inheriting from json::json_sax_t is not required, but can
 // help not to forget a required function
-class sax_event_consumer : public json::json_sax_t
-{
-  public:
-    std::vector<std::string> events;
+class sax_event_consumer : public json::json_sax_t
+{
+  public:
+    std::vector<std::string> events;
 
-    bool null() override
-    {
-        events.push_back("null()");
-        return true;
-    }
+    bool null() override
+    {
+        events.push_back("null()");
+        return true;
+    }
 
-    bool boolean(bool val) override
-    {
-        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
-        return true;
-    }
+    bool boolean(bool val) override
+    {
+        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
+        return true;
+    }
 
-    bool number_integer(number_integer_t val) override
-    {
-        events.push_back("number_integer(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_integer(number_integer_t val) override
+    {
+        events.push_back("number_integer(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_unsigned(number_unsigned_t val) override
-    {
-        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_unsigned(number_unsigned_t val) override
+    {
+        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_float(number_float_t val, const string_t& s) override
-    {
-        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
-        return true;
-    }
+    bool number_float(number_float_t val, const string_t& s) override
+    {
+        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
+        return true;
+    }
 
-    bool string(string_t& val) override
-    {
-        events.push_back("string(val=" + val + ")");
-        return true;
-    }
+    bool string(string_t& val) override
+    {
+        events.push_back("string(val=" + val + ")");
+        return true;
+    }
 
-    bool start_object(std::size_t elements) override
-    {
-        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_object(std::size_t elements) override
+    {
+        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_object() override
-    {
-        events.push_back("end_object()");
-        return true;
-    }
+    bool end_object() override
+    {
+        events.push_back("end_object()");
+        return true;
+    }
 
-    bool start_array(std::size_t elements) override
-    {
-        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_array(std::size_t elements) override
+    {
+        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_array() override
-    {
-        events.push_back("end_array()");
-        return true;
-    }
+    bool end_array() override
+    {
+        events.push_back("end_array()");
+        return true;
+    }
 
-    bool key(string_t& val) override
-    {
-        events.push_back("key(val=" + val + ")");
-        return true;
-    }
+    bool key(string_t& val) override
+    {
+        events.push_back("key(val=" + val + ")");
+        return true;
+    }
 
-    bool binary(json::binary_t& val) override
-    {
-        events.push_back("binary(val=[...])");
-        return true;
-    }
+    bool binary(json::binary_t& val) override
+    {
+        events.push_back("binary(val=[...])");
+        return true;
+    }
 
-    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
-    {
-        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
-        return false;
-    }
-};
+    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
+    {
+        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
+        return false;
+    }
+};
 
-int main()
-{
+int main()
+{
     // CBOR byte string
-    std::vector<std::uint8_t> vec = {{0x44, 0xcA, 0xfe, 0xba, 0xbe}};
+    std::vector<std::uint8_t> vec = {{0x44, 0xcA, 0xfe, 0xba, 0xbe}};
 
     // create a SAX event consumer object
-    sax_event_consumer sec;
+    sax_event_consumer sec;
 
     // parse CBOR
-    bool result = json::sax_parse(vec, &sec, json::input_format_t::cbor);
+    bool result = json::sax_parse(vec, &sec, json::input_format_t::cbor);
 
     // output the recorded events
-    for (auto& event : sec.events)
-    {
-        std::cout << event << "\n";
-    }
+    for (auto& event : sec.events)
+    {
+        std::cout << event << "\n";
+    }
 
     // output the result of sax_parse
-    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
-}
-

Output:

binary(val=[...])
+    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
+}
+

Output:

binary(val=[...])
 
-result: true
-

Version history

  • Added in version 3.2.0.

Last update: May 17, 2022
\ No newline at end of file +result: true +

Version history

  • Added in version 3.2.0.

Last update: May 17, 2022
\ No newline at end of file diff --git a/api/basic_json/insert/index.html b/api/basic_json/insert/index.html index 07c2eb171..69a513187 100644 --- a/api/basic_json/insert/index.html +++ b/api/basic_json/insert/index.html @@ -1,119 +1,119 @@ - insert - JSON for Modern C++
Skip to content

nlohmann::basic_json::insert

// (1)
-iterator insert(const_iterator pos, const basic_json& val);
-iterator insert(const_iterator pos, basic_json&& val);
+ insert - JSON for Modern C++       

nlohmann::basic_json::insert

// (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);
+iterator insert(const_iterator pos, size_type cnt, const basic_json& val);
 
 // (3)
-iterator insert(const_iterator pos, const_iterator first, const_iterator last);
+iterator insert(const_iterator pos, const_iterator first, const_iterator last);
 
 // (4)
-iterator insert(const_iterator pos, initializer_list_t ilist);
+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 cnt==0
  3. iterator pointing to the first element inserted, or pos if 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 if called on JSON values other than arrays; example: "cannot use insert() with string"
    • Throws invalid_iterator.202 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 if called on JSON values other than arrays; example: "cannot use insert() with string"
    • Throws invalid_iterator.202 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 if called on JSON values other than arrays; example: "cannot use insert() with string"
    • Throws invalid_iterator.202 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 if first and last do not belong to the same JSON value; example: "iterators do not fit"
    • Throws invalid_iterator.211 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 if called on JSON values other than arrays; example: "cannot use insert() with string"
    • Throws invalid_iterator.202 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 if called on JSON values other than objects; example: "cannot use insert() with string"
    • Throws invalid_iterator.202 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 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 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 (1): insert element into array

The example shows how insert() is used.

#include <iostream>
-#include <nlohmann/json.hpp>
+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 cnt==0
  3. iterator pointing to the first element inserted, or pos if 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 if called on JSON values other than arrays; example: "cannot use insert() with string"
    • Throws invalid_iterator.202 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 if called on JSON values other than arrays; example: "cannot use insert() with string"
    • Throws invalid_iterator.202 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 if called on JSON values other than arrays; example: "cannot use insert() with string"
    • Throws invalid_iterator.202 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 if first and last do not belong to the same JSON value; example: "iterators do not fit"
    • Throws invalid_iterator.211 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 if called on JSON values other than arrays; example: "cannot use insert() with string"
    • Throws invalid_iterator.202 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 if called on JSON values other than objects; example: "cannot use insert() with string"
    • Throws invalid_iterator.202 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 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 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 (1): insert element into array

The example shows how insert() is used.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON array
-    json v = {1, 2, 3, 4};
+    json v = {1, 2, 3, 4};
 
     // insert number 10 before number 3
-    auto new_pos = v.insert(v.begin() + 2, 10);
+    auto new_pos = v.insert(v.begin() + 2, 10);
 
     // output new array and result of insert call
-    std::cout << *new_pos << '\n';
-    std::cout << v << '\n';
-}
-

Output:

10
-[1,2,10,3,4]
-
Example (2): insert copies of element into array

The example shows how insert() is used.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << *new_pos << '\n';
+    std::cout << v << '\n';
+}
+

Output:

10
+[1,2,10,3,4]
+
Example (2): insert copies of element into array

The example shows how insert() is used.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON array
-    json v = {1, 2, 3, 4};
+    json v = {1, 2, 3, 4};
 
     // insert number 7 copies of number 7 before number 3
-    auto new_pos = v.insert(v.begin() + 2, 7, 7);
+    auto new_pos = v.insert(v.begin() + 2, 7, 7);
 
     // output new array and result of insert call
-    std::cout << *new_pos << '\n';
-    std::cout << v << '\n';
-}
-

Output:

7
-[1,2,7,7,7,7,7,7,7,3,4]
-
Example (3): insert range of elements into array

The example shows how insert() is used.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << *new_pos << '\n';
+    std::cout << v << '\n';
+}
+

Output:

7
+[1,2,7,7,7,7,7,7,7,3,4]
+
Example (3): insert range of elements into array

The example shows how insert() is used.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON array
-    json v = {1, 2, 3, 4};
+    json v = {1, 2, 3, 4};
 
     // create a JSON array to copy values from
-    json v2 = {"one", "two", "three", "four"};
+    json v2 = {"one", "two", "three", "four"};
 
     // insert range from v2 before the end of array v
-    auto new_pos = v.insert(v.end(), v2.begin(), v2.end());
+    auto new_pos = v.insert(v.end(), v2.begin(), v2.end());
 
     // output new array and result of insert call
-    std::cout << *new_pos << '\n';
-    std::cout << v << '\n';
-}
-

Output:

"one"
-[1,2,3,4,"one","two","three","four"]
-
Example (4): insert elements from initializer list into array

The example shows how insert() is used.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << *new_pos << '\n';
+    std::cout << v << '\n';
+}
+

Output:

"one"
+[1,2,3,4,"one","two","three","four"]
+
Example (4): insert elements from initializer list into array

The example shows how insert() is used.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON array
-    json v = {1, 2, 3, 4};
+    json v = {1, 2, 3, 4};
 
     // insert range from v2 before the end of array v
-    auto new_pos = v.insert(v.end(), {7, 8, 9});
+    auto new_pos = v.insert(v.end(), {7, 8, 9});
 
     // output new array and result of insert call
-    std::cout << *new_pos << '\n';
-    std::cout << v << '\n';
-}
-

Output:

7
-[1,2,3,4,7,8,9]
-
Example (5): insert range of elements into object

The example shows how insert() is used.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << *new_pos << '\n';
+    std::cout << v << '\n';
+}
+

Output:

7
+[1,2,3,4,7,8,9]
+
Example (5): insert range of elements into object

The example shows how insert() is used.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create two JSON objects
-    json j1 = {{"one", "eins"}, {"two", "zwei"}};
-    json j2 = {{"eleven", "elf"}, {"seventeen", "siebzehn"}};
+    json j1 = {{"one", "eins"}, {"two", "zwei"}};
+    json j2 = {{"eleven", "elf"}, {"seventeen", "siebzehn"}};
 
     // output objects
-    std::cout << j1 << '\n';
-    std::cout << j2 << '\n';
+    std::cout << j1 << '\n';
+    std::cout << j2 << '\n';
 
     // insert range from j2 to j1
-    j1.insert(j2.begin(), j2.end());
+    j1.insert(j2.begin(), j2.end());
 
     // output result of insert call
-    std::cout << j1 << '\n';
-}
-

Output:

{"one":"eins","two":"zwei"}
-{"eleven":"elf","seventeen":"siebzehn"}
-{"eleven":"elf","one":"eins","seventeen":"siebzehn","two":"zwei"}
-

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.

Last update: May 1, 2022
\ No newline at end of file + std::cout << j1 << '\n'; +} +

Output:

{"one":"eins","two":"zwei"}
+{"eleven":"elf","seventeen":"siebzehn"}
+{"eleven":"elf","one":"eins","seventeen":"siebzehn","two":"zwei"}
+

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.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/invalid_iterator/index.html b/api/basic_json/invalid_iterator/index.html index 2c8fd1107..7f46afc42 100644 --- a/api/basic_json/invalid_iterator/index.html +++ b/api/basic_json/invalid_iterator/index.html @@ -1,25 +1,25 @@ - invalid_iterator - JSON for Modern C++
Skip to content

nlohmann::basic_json::invalid_iterator

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).

uml diagram

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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ invalid_iterator - JSON for Modern C++       

nlohmann::basic_json::invalid_iterator

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).

uml diagram

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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    try
-    {
+int main()
+{
+    try
+    {
         // calling iterator::key() on non-object iterator
-        json j = "string";
-        json::iterator it = j.begin();
-        auto k = it.key();
-    }
-    catch (const json::invalid_iterator& e)
-    {
+        json j = "string";
+        json::iterator it = j.begin();
+        auto k = it.key();
+    }
+    catch (const json::invalid_iterator& e)
+    {
         // output exception information
-        std::cout << "message: " << e.what() << '\n'
-                  << "exception id: " << e.id << std::endl;
-    }
-}
-

Output:

message: [json.exception.invalid_iterator.207] cannot use key() for non-object iterators
-exception id: 207
-

See also

Version history

  • Since version 3.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << "message: " << e.what() << '\n' + << "exception id: " << e.id << std::endl; + } +} +

Output:

message: [json.exception.invalid_iterator.207] cannot use key() for non-object iterators
+exception id: 207
+

See also

Version history

  • Since version 3.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/is_array/index.html b/api/basic_json/is_array/index.html index fc4044b0e..65ebdb733 100644 --- a/api/basic_json/is_array/index.html +++ b/api/basic_json/is_array/index.html @@ -1,41 +1,41 @@ - is_array - JSON for Modern C++
Skip to content

nlohmann::basic_json::is_array

constexpr bool is_array() const noexcept;
-

This function returns true if and only if the JSON value is an array.

Return value

true if type is an array, 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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ is_array - JSON for Modern C++       

nlohmann::basic_json::is_array

constexpr bool is_array() const noexcept;
+

This function returns true if and only if the JSON value is an array.

Return value

true if type is an array, 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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_unsigned_integer = 12345678987654321u;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
-    json j_binary = json::binary({1, 2, 3});
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_unsigned_integer = 12345678987654321u;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
+    json j_binary = json::binary({1, 2, 3});
 
     // call is_array()
-    std::cout << std::boolalpha;
-    std::cout << j_null.is_array() << '\n';
-    std::cout << j_boolean.is_array() << '\n';
-    std::cout << j_number_integer.is_array() << '\n';
-    std::cout << j_number_unsigned_integer.is_array() << '\n';
-    std::cout << j_number_float.is_array() << '\n';
-    std::cout << j_object.is_array() << '\n';
-    std::cout << j_array.is_array() << '\n';
-    std::cout << j_string.is_array() << '\n';
-    std::cout << j_binary.is_array() << '\n';
-}
-

Output:

false
-false
-false
-false
-false
-false
-true
-false
-false
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << j_null.is_array() << '\n'; + std::cout << j_boolean.is_array() << '\n'; + std::cout << j_number_integer.is_array() << '\n'; + std::cout << j_number_unsigned_integer.is_array() << '\n'; + std::cout << j_number_float.is_array() << '\n'; + std::cout << j_object.is_array() << '\n'; + std::cout << j_array.is_array() << '\n'; + std::cout << j_string.is_array() << '\n'; + std::cout << j_binary.is_array() << '\n'; +} +

Output:

false
+false
+false
+false
+false
+false
+true
+false
+false
+

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/is_binary/index.html b/api/basic_json/is_binary/index.html index 007633496..7918ccdd6 100644 --- a/api/basic_json/is_binary/index.html +++ b/api/basic_json/is_binary/index.html @@ -1,41 +1,41 @@ - is_binary - JSON for Modern C++
Skip to content

nlohmann::basic_json::is_binary

constexpr bool is_binary() const noexcept;
-

This function returns true if and only if the JSON value is binary array.

Return value

true if type is binary, false otherwise.

Exception safety

No-throw guarantee: this member function never throws exceptions.

Complexity

Constant.

Examples

Example

The following code exemplifies is_binary() for all JSON types.

#include <iostream>
-#include <nlohmann/json.hpp>
+ is_binary - JSON for Modern C++       

nlohmann::basic_json::is_binary

constexpr bool is_binary() const noexcept;
+

This function returns true if and only if the JSON value is binary array.

Return value

true if type is binary, false otherwise.

Exception safety

No-throw guarantee: this member function never throws exceptions.

Complexity

Constant.

Examples

Example

The following code exemplifies is_binary() for all JSON types.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_unsigned_integer = 12345678987654321u;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
-    json j_binary = json::binary({1, 2, 3});
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_unsigned_integer = 12345678987654321u;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
+    json j_binary = json::binary({1, 2, 3});
 
     // call is_binary()
-    std::cout << std::boolalpha;
-    std::cout << j_null.is_binary() << '\n';
-    std::cout << j_boolean.is_binary() << '\n';
-    std::cout << j_number_integer.is_binary() << '\n';
-    std::cout << j_number_unsigned_integer.is_binary() << '\n';
-    std::cout << j_number_float.is_binary() << '\n';
-    std::cout << j_object.is_binary() << '\n';
-    std::cout << j_array.is_binary() << '\n';
-    std::cout << j_string.is_binary() << '\n';
-    std::cout << j_binary.is_binary() << '\n';
-}
-

Output:

false
-false
-false
-false
-false
-false
-false
-false
-true
-

Version history

  • Added in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << j_null.is_binary() << '\n'; + std::cout << j_boolean.is_binary() << '\n'; + std::cout << j_number_integer.is_binary() << '\n'; + std::cout << j_number_unsigned_integer.is_binary() << '\n'; + std::cout << j_number_float.is_binary() << '\n'; + std::cout << j_object.is_binary() << '\n'; + std::cout << j_array.is_binary() << '\n'; + std::cout << j_string.is_binary() << '\n'; + std::cout << j_binary.is_binary() << '\n'; +} +

Output:

false
+false
+false
+false
+false
+false
+false
+false
+true
+

Version history

  • Added in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/is_boolean/index.html b/api/basic_json/is_boolean/index.html index 2e1a34d94..e8ed5d952 100644 --- a/api/basic_json/is_boolean/index.html +++ b/api/basic_json/is_boolean/index.html @@ -1,41 +1,41 @@ - is_boolean - JSON for Modern C++
Skip to content

nlohmann::basic_json::is_boolean

constexpr bool is_boolean() const noexcept;
-

This function returns true if and only if the JSON value is true or false.

Return value

true if type is boolean, 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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ is_boolean - JSON for Modern C++       

nlohmann::basic_json::is_boolean

constexpr bool is_boolean() const noexcept;
+

This function returns true if and only if the JSON value is true or false.

Return value

true if type is boolean, 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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_unsigned_integer = 12345678987654321u;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
-    json j_binary = json::binary({1, 2, 3});
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_unsigned_integer = 12345678987654321u;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
+    json j_binary = json::binary({1, 2, 3});
 
     // call is_boolean()
-    std::cout << std::boolalpha;
-    std::cout << j_null.is_boolean() << '\n';
-    std::cout << j_boolean.is_boolean() << '\n';
-    std::cout << j_number_integer.is_boolean() << '\n';
-    std::cout << j_number_unsigned_integer.is_boolean() << '\n';
-    std::cout << j_number_float.is_boolean() << '\n';
-    std::cout << j_object.is_boolean() << '\n';
-    std::cout << j_array.is_boolean() << '\n';
-    std::cout << j_string.is_boolean() << '\n';
-    std::cout << j_binary.is_boolean() << '\n';
-}
-

Output:

false
-true
-false
-false
-false
-false
-false
-false
-false
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << j_null.is_boolean() << '\n'; + std::cout << j_boolean.is_boolean() << '\n'; + std::cout << j_number_integer.is_boolean() << '\n'; + std::cout << j_number_unsigned_integer.is_boolean() << '\n'; + std::cout << j_number_float.is_boolean() << '\n'; + std::cout << j_object.is_boolean() << '\n'; + std::cout << j_array.is_boolean() << '\n'; + std::cout << j_string.is_boolean() << '\n'; + std::cout << j_binary.is_boolean() << '\n'; +} +

Output:

false
+true
+false
+false
+false
+false
+false
+false
+false
+

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/is_discarded/index.html b/api/basic_json/is_discarded/index.html index 6a119b195..dd0e61768 100644 --- a/api/basic_json/is_discarded/index.html +++ b/api/basic_json/is_discarded/index.html @@ -1,43 +1,43 @@ - is_discarded - JSON for Modern C++
Skip to content

nlohmann::basic_json::is_discarded

constexpr bool is_discarded() const noexcept;
-

This function returns true for a JSON value if either:

  • the value was discarded during parsing with a callback function (see parser_callback_t), or
  • the value is the result of parsing invalid JSON with parameter allow_exceptions set to false; see parse for more information.

Return value

true if type is discarded, false otherwise.

Exception safety

No-throw guarantee: this member function never throws exceptions.

Complexity

Constant.

Notes

Comparisons

Discarded values are never compared equal with operator==. That is, checking whether a JSON value j is discarded will only work via:

j.is_discarded()
-

because

j == json::value_t::discarded
-

will always be false.

Removal during parsing with callback functions

When a value is discarded by a callback function (see parser_callback_t) during parsing, then it is removed when it is part of a structured value. For instance, if the second value of an array is discarded, instead of [null, discarded, false], the array [null, false] is returned. Only if the top-level value is discarded, the return value of the parse call is discarded.

This function will always be false for JSON values after parsing. That is, discarded values can only occur during parsing, but will be removed when inside a structured value or replaced by null in other cases.

Examples

Example

The following code exemplifies is_discarded() for all JSON types.

#include <iostream>
-#include <nlohmann/json.hpp>
+ is_discarded - JSON for Modern C++       

nlohmann::basic_json::is_discarded

constexpr bool is_discarded() const noexcept;
+

This function returns true for a JSON value if either:

  • the value was discarded during parsing with a callback function (see parser_callback_t), or
  • the value is the result of parsing invalid JSON with parameter allow_exceptions set to false; see parse for more information.

Return value

true if type is discarded, false otherwise.

Exception safety

No-throw guarantee: this member function never throws exceptions.

Complexity

Constant.

Notes

Comparisons

Discarded values are never compared equal with operator==. That is, checking whether a JSON value j is discarded will only work via:

j.is_discarded()
+

because

j == json::value_t::discarded
+

will always be false.

Removal during parsing with callback functions

When a value is discarded by a callback function (see parser_callback_t) during parsing, then it is removed when it is part of a structured value. For instance, if the second value of an array is discarded, instead of [null, discarded, false], the array [null, false] is returned. Only if the top-level value is discarded, the return value of the parse call is discarded.

This function will always be false for JSON values after parsing. That is, discarded values can only occur during parsing, but will be removed when inside a structured value or replaced by null in other cases.

Examples

Example

The following code exemplifies is_discarded() for all JSON types.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_unsigned_integer = 12345678987654321u;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
-    json j_binary = json::binary({1, 2, 3});
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_unsigned_integer = 12345678987654321u;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
+    json j_binary = json::binary({1, 2, 3});
 
     // call is_discarded()
-    std::cout << std::boolalpha;
-    std::cout << j_null.is_discarded() << '\n';
-    std::cout << j_boolean.is_discarded() << '\n';
-    std::cout << j_number_integer.is_discarded() << '\n';
-    std::cout << j_number_unsigned_integer.is_discarded() << '\n';
-    std::cout << j_number_float.is_discarded() << '\n';
-    std::cout << j_object.is_discarded() << '\n';
-    std::cout << j_array.is_discarded() << '\n';
-    std::cout << j_string.is_discarded() << '\n';
-    std::cout << j_binary.is_discarded() << '\n';
-}
-

Output:

false
-false
-false
-false
-false
-false
-false
-false
-false
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << j_null.is_discarded() << '\n'; + std::cout << j_boolean.is_discarded() << '\n'; + std::cout << j_number_integer.is_discarded() << '\n'; + std::cout << j_number_unsigned_integer.is_discarded() << '\n'; + std::cout << j_number_float.is_discarded() << '\n'; + std::cout << j_object.is_discarded() << '\n'; + std::cout << j_array.is_discarded() << '\n'; + std::cout << j_string.is_discarded() << '\n'; + std::cout << j_binary.is_discarded() << '\n'; +} +

Output:

false
+false
+false
+false
+false
+false
+false
+false
+false
+

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/is_null/index.html b/api/basic_json/is_null/index.html index 366e3dc9e..5aca1df7a 100644 --- a/api/basic_json/is_null/index.html +++ b/api/basic_json/is_null/index.html @@ -1,41 +1,41 @@ - is_null - JSON for Modern C++
Skip to content

nlohmann::basic_json::is_null

constexpr bool is_null() const noexcept;
-

This function returns true if and only if the JSON value is null.

Return value

true if type is null, 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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ is_null - JSON for Modern C++       

nlohmann::basic_json::is_null

constexpr bool is_null() const noexcept;
+

This function returns true if and only if the JSON value is null.

Return value

true if type is null, 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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_unsigned_integer = 12345678987654321u;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
-    json j_binary = json::binary({1, 2, 3});
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_unsigned_integer = 12345678987654321u;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
+    json j_binary = json::binary({1, 2, 3});
 
     // call is_null()
-    std::cout << std::boolalpha;
-    std::cout << j_null.is_null() << '\n';
-    std::cout << j_boolean.is_null() << '\n';
-    std::cout << j_number_integer.is_null() << '\n';
-    std::cout << j_number_unsigned_integer.is_null() << '\n';
-    std::cout << j_number_float.is_null() << '\n';
-    std::cout << j_object.is_null() << '\n';
-    std::cout << j_array.is_null() << '\n';
-    std::cout << j_string.is_null() << '\n';
-    std::cout << j_binary.is_null() << '\n';
-}
-

Output:

true
-false
-false
-false
-false
-false
-false
-false
-false
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << j_null.is_null() << '\n'; + std::cout << j_boolean.is_null() << '\n'; + std::cout << j_number_integer.is_null() << '\n'; + std::cout << j_number_unsigned_integer.is_null() << '\n'; + std::cout << j_number_float.is_null() << '\n'; + std::cout << j_object.is_null() << '\n'; + std::cout << j_array.is_null() << '\n'; + std::cout << j_string.is_null() << '\n'; + std::cout << j_binary.is_null() << '\n'; +} +

Output:

true
+false
+false
+false
+false
+false
+false
+false
+false
+

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/is_number/index.html b/api/basic_json/is_number/index.html index 62ce8ecf6..1825874ee 100644 --- a/api/basic_json/is_number/index.html +++ b/api/basic_json/is_number/index.html @@ -1,45 +1,45 @@ - is_number - JSON for Modern C++
Skip to content

nlohmann::basic_json::is_number

constexpr bool is_number() const noexcept;
-

This function returns true if and only if the JSON value is a number. This includes both integer (signed and unsigned) and floating-point values.

Return value

true if type is number (regardless whether integer, unsigned integer or floating-type), false otherwise.

Exception safety

No-throw guarantee: this member function never throws exceptions.

Complexity

Constant.

Possible implementation

constexpr bool is_number() const noexcept
-{
-    return is_number_integer() || is_number_float();
-}
-

Examples

Example

The following code exemplifies is_number() for all JSON types.

#include <iostream>
-#include <nlohmann/json.hpp>
+ is_number - JSON for Modern C++       

nlohmann::basic_json::is_number

constexpr bool is_number() const noexcept;
+

This function returns true if and only if the JSON value is a number. This includes both integer (signed and unsigned) and floating-point values.

Return value

true if type is number (regardless whether integer, unsigned integer or floating-type), false otherwise.

Exception safety

No-throw guarantee: this member function never throws exceptions.

Complexity

Constant.

Possible implementation

constexpr bool is_number() const noexcept
+{
+    return is_number_integer() || is_number_float();
+}
+

Examples

Example

The following code exemplifies is_number() for all JSON types.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_unsigned_integer = 12345678987654321u;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
-    json j_binary = json::binary({1, 2, 3});
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_unsigned_integer = 12345678987654321u;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
+    json j_binary = json::binary({1, 2, 3});
 
     // call is_number()
-    std::cout << std::boolalpha;
-    std::cout << j_null.is_number() << '\n';
-    std::cout << j_boolean.is_number() << '\n';
-    std::cout << j_number_integer.is_number() << '\n';
-    std::cout << j_number_unsigned_integer.is_number() << '\n';
-    std::cout << j_number_float.is_number() << '\n';
-    std::cout << j_object.is_number() << '\n';
-    std::cout << j_array.is_number() << '\n';
-    std::cout << j_string.is_number() << '\n';
-    std::cout << j_binary.is_number() << '\n';
-}
-

Output:

false
-false
-true
-true
-true
-false
-false
-false
-false
-

See also

Version history

  • Added in version 1.0.0.
  • Extended to also return true for unsigned integers in 2.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << j_null.is_number() << '\n'; + std::cout << j_boolean.is_number() << '\n'; + std::cout << j_number_integer.is_number() << '\n'; + std::cout << j_number_unsigned_integer.is_number() << '\n'; + std::cout << j_number_float.is_number() << '\n'; + std::cout << j_object.is_number() << '\n'; + std::cout << j_array.is_number() << '\n'; + std::cout << j_string.is_number() << '\n'; + std::cout << j_binary.is_number() << '\n'; +} +

Output:

false
+false
+true
+true
+true
+false
+false
+false
+false
+

See also

Version history

  • Added in version 1.0.0.
  • Extended to also return true for unsigned integers in 2.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/is_number_float/index.html b/api/basic_json/is_number_float/index.html index 6a4f6923a..f2248048f 100644 --- a/api/basic_json/is_number_float/index.html +++ b/api/basic_json/is_number_float/index.html @@ -1,41 +1,41 @@ - is_number_float - JSON for Modern C++
Skip to content

nlohmann::basic_json::is_number_float

constexpr bool is_number_float() const noexcept;
-

This function returns true if and only if the JSON value is a floating-point number. This excludes signed and unsigned integer values.

Return value

true if type is a floating-point number, 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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ is_number_float - JSON for Modern C++       

nlohmann::basic_json::is_number_float

constexpr bool is_number_float() const noexcept;
+

This function returns true if and only if the JSON value is a floating-point number. This excludes signed and unsigned integer values.

Return value

true if type is a floating-point number, 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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_unsigned_integer = 12345678987654321u;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
-    json j_binary = json::binary({1, 2, 3});
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_unsigned_integer = 12345678987654321u;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
+    json j_binary = json::binary({1, 2, 3});
 
     // call is_number_float()
-    std::cout << std::boolalpha;
-    std::cout << j_null.is_number_float() << '\n';
-    std::cout << j_boolean.is_number_float() << '\n';
-    std::cout << j_number_integer.is_number_float() << '\n';
-    std::cout << j_number_unsigned_integer.is_number_float() << '\n';
-    std::cout << j_number_float.is_number_float() << '\n';
-    std::cout << j_object.is_number_float() << '\n';
-    std::cout << j_array.is_number_float() << '\n';
-    std::cout << j_string.is_number_float() << '\n';
-    std::cout << j_binary.is_number_float() << '\n';
-}
-

Output:

false
-false
-false
-false
-true
-false
-false
-false
-false
-

See also

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << j_null.is_number_float() << '\n'; + std::cout << j_boolean.is_number_float() << '\n'; + std::cout << j_number_integer.is_number_float() << '\n'; + std::cout << j_number_unsigned_integer.is_number_float() << '\n'; + std::cout << j_number_float.is_number_float() << '\n'; + std::cout << j_object.is_number_float() << '\n'; + std::cout << j_array.is_number_float() << '\n'; + std::cout << j_string.is_number_float() << '\n'; + std::cout << j_binary.is_number_float() << '\n'; +} +

Output:

false
+false
+false
+false
+true
+false
+false
+false
+false
+

See also

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/is_number_integer/index.html b/api/basic_json/is_number_integer/index.html index 8ad5432ac..91001953d 100644 --- a/api/basic_json/is_number_integer/index.html +++ b/api/basic_json/is_number_integer/index.html @@ -1,41 +1,41 @@ - is_number_integer - JSON for Modern C++
Skip to content

nlohmann::basic_json::is_number_integer

constexpr bool is_number_integer() const noexcept;
-

This function returns true if and only if the JSON value is a signed or unsigned integer number. This excludes floating-point values.

Return value

true if type is an integer or unsigned integer number, 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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ is_number_integer - JSON for Modern C++       

nlohmann::basic_json::is_number_integer

constexpr bool is_number_integer() const noexcept;
+

This function returns true if and only if the JSON value is a signed or unsigned integer number. This excludes floating-point values.

Return value

true if type is an integer or unsigned integer number, 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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_unsigned_integer = 12345678987654321u;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
-    json j_binary = json::binary({1, 2, 3});
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_unsigned_integer = 12345678987654321u;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
+    json j_binary = json::binary({1, 2, 3});
 
     // call is_number_integer()
-    std::cout << std::boolalpha;
-    std::cout << j_null.is_number_integer() << '\n';
-    std::cout << j_boolean.is_number_integer() << '\n';
-    std::cout << j_number_integer.is_number_integer() << '\n';
-    std::cout << j_number_unsigned_integer.is_number_integer() << '\n';
-    std::cout << j_number_float.is_number_integer() << '\n';
-    std::cout << j_object.is_number_integer() << '\n';
-    std::cout << j_array.is_number_integer() << '\n';
-    std::cout << j_string.is_number_integer() << '\n';
-    std::cout << j_binary.is_number_integer() << '\n';
-}
-

Output:

false
-false
-true
-true
-false
-false
-false
-false
-false
-

See also

Version history

  • Added in version 1.0.0.
  • Extended to also return true for unsigned integers in 2.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << j_null.is_number_integer() << '\n'; + std::cout << j_boolean.is_number_integer() << '\n'; + std::cout << j_number_integer.is_number_integer() << '\n'; + std::cout << j_number_unsigned_integer.is_number_integer() << '\n'; + std::cout << j_number_float.is_number_integer() << '\n'; + std::cout << j_object.is_number_integer() << '\n'; + std::cout << j_array.is_number_integer() << '\n'; + std::cout << j_string.is_number_integer() << '\n'; + std::cout << j_binary.is_number_integer() << '\n'; +} +

Output:

false
+false
+true
+true
+false
+false
+false
+false
+false
+

See also

Version history

  • Added in version 1.0.0.
  • Extended to also return true for unsigned integers in 2.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/is_number_unsigned/index.html b/api/basic_json/is_number_unsigned/index.html index 223a4fa29..f22e1b28c 100644 --- a/api/basic_json/is_number_unsigned/index.html +++ b/api/basic_json/is_number_unsigned/index.html @@ -1,41 +1,41 @@ - is_number_unsigned - JSON for Modern C++
Skip to content

nlohmann::basic_json::is_number_unsigned

constexpr bool is_number_unsigned() const noexcept;
-

This function returns true if and only if the JSON value is an unsigned integer number. This excludes floating-point and signed integer values.

Return value

true if type is an unsigned integer number, 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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ is_number_unsigned - JSON for Modern C++       

nlohmann::basic_json::is_number_unsigned

constexpr bool is_number_unsigned() const noexcept;
+

This function returns true if and only if the JSON value is an unsigned integer number. This excludes floating-point and signed integer values.

Return value

true if type is an unsigned integer number, 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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_unsigned_integer = 12345678987654321u;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
-    json j_binary = json::binary({1, 2, 3});
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_unsigned_integer = 12345678987654321u;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
+    json j_binary = json::binary({1, 2, 3});
 
     // call is_number_unsigned()
-    std::cout << std::boolalpha;
-    std::cout << j_null.is_number_unsigned() << '\n';
-    std::cout << j_boolean.is_number_unsigned() << '\n';
-    std::cout << j_number_integer.is_number_unsigned() << '\n';
-    std::cout << j_number_unsigned_integer.is_number_unsigned() << '\n';
-    std::cout << j_number_float.is_number_unsigned() << '\n';
-    std::cout << j_object.is_number_unsigned() << '\n';
-    std::cout << j_array.is_number_unsigned() << '\n';
-    std::cout << j_string.is_number_unsigned() << '\n';
-    std::cout << j_binary.is_number_unsigned() << '\n';
-}
-

Output:

false
-false
-false
-true
-false
-false
-false
-false
-false
-

See also

Version history

  • Added in version 2.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << j_null.is_number_unsigned() << '\n'; + std::cout << j_boolean.is_number_unsigned() << '\n'; + std::cout << j_number_integer.is_number_unsigned() << '\n'; + std::cout << j_number_unsigned_integer.is_number_unsigned() << '\n'; + std::cout << j_number_float.is_number_unsigned() << '\n'; + std::cout << j_object.is_number_unsigned() << '\n'; + std::cout << j_array.is_number_unsigned() << '\n'; + std::cout << j_string.is_number_unsigned() << '\n'; + std::cout << j_binary.is_number_unsigned() << '\n'; +} +

Output:

false
+false
+false
+true
+false
+false
+false
+false
+false
+

See also

Version history

  • Added in version 2.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/is_object/index.html b/api/basic_json/is_object/index.html index 550a75c4d..47b1d7fc0 100644 --- a/api/basic_json/is_object/index.html +++ b/api/basic_json/is_object/index.html @@ -1,41 +1,41 @@ - is_object - JSON for Modern C++
Skip to content

nlohmann::basic_json::is_object

constexpr bool is_object() const noexcept;
-

This function returns true if and only if the JSON value is an object.

Return value

true if type is an object, false otherwise.

Exception safety

No-throw guarantee: this member function never throws exceptions.

Complexity

Constant.

Examples

Example

The following code exemplifies is_object() for all JSON types.

#include <iostream>
-#include <nlohmann/json.hpp>
+ is_object - JSON for Modern C++       

nlohmann::basic_json::is_object

constexpr bool is_object() const noexcept;
+

This function returns true if and only if the JSON value is an object.

Return value

true if type is an object, false otherwise.

Exception safety

No-throw guarantee: this member function never throws exceptions.

Complexity

Constant.

Examples

Example

The following code exemplifies is_object() for all JSON types.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_float = 23.42;
-    json j_number_unsigned_integer = 12345678987654321u;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
-    json j_binary = json::binary({1, 2, 3});
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_float = 23.42;
+    json j_number_unsigned_integer = 12345678987654321u;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
+    json j_binary = json::binary({1, 2, 3});
 
     // call is_object()
-    std::cout << std::boolalpha;
-    std::cout << j_null.is_object() << '\n';
-    std::cout << j_boolean.is_object() << '\n';
-    std::cout << j_number_integer.is_object() << '\n';
-    std::cout << j_number_unsigned_integer.is_object() << '\n';
-    std::cout << j_number_float.is_object() << '\n';
-    std::cout << j_object.is_object() << '\n';
-    std::cout << j_array.is_object() << '\n';
-    std::cout << j_string.is_object() << '\n';
-    std::cout << j_binary.is_object() << '\n';
-}
-

Output:

false
-false
-false
-false
-false
-true
-false
-false
-false
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << j_null.is_object() << '\n'; + std::cout << j_boolean.is_object() << '\n'; + std::cout << j_number_integer.is_object() << '\n'; + std::cout << j_number_unsigned_integer.is_object() << '\n'; + std::cout << j_number_float.is_object() << '\n'; + std::cout << j_object.is_object() << '\n'; + std::cout << j_array.is_object() << '\n'; + std::cout << j_string.is_object() << '\n'; + std::cout << j_binary.is_object() << '\n'; +} +

Output:

false
+false
+false
+false
+false
+true
+false
+false
+false
+

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/is_primitive/index.html b/api/basic_json/is_primitive/index.html index 47c3fd8d5..bd41b2019 100644 --- a/api/basic_json/is_primitive/index.html +++ b/api/basic_json/is_primitive/index.html @@ -1,45 +1,45 @@ - is_primitive - JSON for Modern C++
Skip to content

nlohmann::basic_json::is_primitive

constexpr bool is_primitive() const noexcept;
-

This function returns true if and only if the JSON type is primitive (string, number, boolean, null, binary).

Return value

true if type is primitive (string, number, boolean, null, or binary), false otherwise.

Exception safety

No-throw guarantee: this member function never throws exceptions.

Complexity

Constant.

Possible implementation

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:

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 true for binary values.

Examples

Example

The following code exemplifies is_primitive() for all JSON types.

#include <iostream>
-#include <nlohmann/json.hpp>
+ is_primitive - JSON for Modern C++       

nlohmann::basic_json::is_primitive

constexpr bool is_primitive() const noexcept;
+

This function returns true if and only if the JSON type is primitive (string, number, boolean, null, binary).

Return value

true if type is primitive (string, number, boolean, null, or binary), false otherwise.

Exception safety

No-throw guarantee: this member function never throws exceptions.

Complexity

Constant.

Possible implementation

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:

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 true for binary values.

Examples

Example

The following code exemplifies is_primitive() for all JSON types.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_float = 23.42;
-    json j_number_unsigned_integer = 12345678987654321u;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
-    json j_binary = json::binary({1, 2, 3});
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_float = 23.42;
+    json j_number_unsigned_integer = 12345678987654321u;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
+    json j_binary = json::binary({1, 2, 3});
 
     // call is_primitive()
-    std::cout << std::boolalpha;
-    std::cout << j_null.is_primitive() << '\n';
-    std::cout << j_boolean.is_primitive() << '\n';
-    std::cout << j_number_integer.is_primitive() << '\n';
-    std::cout << j_number_unsigned_integer.is_primitive() << '\n';
-    std::cout << j_number_float.is_primitive() << '\n';
-    std::cout << j_object.is_primitive() << '\n';
-    std::cout << j_array.is_primitive() << '\n';
-    std::cout << j_string.is_primitive() << '\n';
-    std::cout << j_binary.is_primitive() << '\n';
-}
-

Output:

true
-true
-true
-true
-true
-false
-false
-true
-true
-

See also

Version history

  • Added in version 1.0.0.
  • Extended to return true for binary types in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << j_null.is_primitive() << '\n'; + std::cout << j_boolean.is_primitive() << '\n'; + std::cout << j_number_integer.is_primitive() << '\n'; + std::cout << j_number_unsigned_integer.is_primitive() << '\n'; + std::cout << j_number_float.is_primitive() << '\n'; + std::cout << j_object.is_primitive() << '\n'; + std::cout << j_array.is_primitive() << '\n'; + std::cout << j_string.is_primitive() << '\n'; + std::cout << j_binary.is_primitive() << '\n'; +} +

Output:

true
+true
+true
+true
+true
+false
+false
+true
+true
+

See also

Version history

  • Added in version 1.0.0.
  • Extended to return true for binary types in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/is_string/index.html b/api/basic_json/is_string/index.html index 293f1a401..3ff9f1433 100644 --- a/api/basic_json/is_string/index.html +++ b/api/basic_json/is_string/index.html @@ -1,41 +1,41 @@ - is_string - JSON for Modern C++
Skip to content

nlohmann::basic_json::is_string

constexpr bool is_string() const noexcept;
-

This function returns true if and only if the JSON value is a string.

Return value

true if type is a string, 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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ is_string - JSON for Modern C++       

nlohmann::basic_json::is_string

constexpr bool is_string() const noexcept;
+

This function returns true if and only if the JSON value is a string.

Return value

true if type is a string, 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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_float = 23.42;
-    json j_number_unsigned_integer = 12345678987654321u;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
-    json j_binary = json::binary({1, 2, 3});
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_float = 23.42;
+    json j_number_unsigned_integer = 12345678987654321u;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
+    json j_binary = json::binary({1, 2, 3});
 
     // call is_string()
-    std::cout << std::boolalpha;
-    std::cout << j_null.is_string() << '\n';
-    std::cout << j_boolean.is_string() << '\n';
-    std::cout << j_number_integer.is_string() << '\n';
-    std::cout << j_number_unsigned_integer.is_string() << '\n';
-    std::cout << j_number_float.is_string() << '\n';
-    std::cout << j_object.is_string() << '\n';
-    std::cout << j_array.is_string() << '\n';
-    std::cout << j_string.is_string() << '\n';
-    std::cout << j_binary.is_string() << '\n';
-}
-

Output:

false
-false
-false
-false
-false
-false
-false
-true
-false
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << j_null.is_string() << '\n'; + std::cout << j_boolean.is_string() << '\n'; + std::cout << j_number_integer.is_string() << '\n'; + std::cout << j_number_unsigned_integer.is_string() << '\n'; + std::cout << j_number_float.is_string() << '\n'; + std::cout << j_object.is_string() << '\n'; + std::cout << j_array.is_string() << '\n'; + std::cout << j_string.is_string() << '\n'; + std::cout << j_binary.is_string() << '\n'; +} +

Output:

false
+false
+false
+false
+false
+false
+false
+true
+false
+

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/is_structured/index.html b/api/basic_json/is_structured/index.html index fbee1d1b3..8e75ed0b3 100644 --- a/api/basic_json/is_structured/index.html +++ b/api/basic_json/is_structured/index.html @@ -1,45 +1,45 @@ - is_structured - JSON for Modern C++
Skip to content

nlohmann::basic_json::is_structured

constexpr bool is_structured() const noexcept;
-

This function returns true if and only if the JSON type is structured (array or object).

Return value

true if type is structured (array or object), false otherwise.

Exception safety

No-throw guarantee: this member function never throws exceptions.

Complexity

Constant.

Possible implementation

constexpr bool is_primitive() const noexcept
-{
-    return is_array() || is_object();
-}
-

Notes

The term structured stems from RFC 8259:

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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ is_structured - JSON for Modern C++       

nlohmann::basic_json::is_structured

constexpr bool is_structured() const noexcept;
+

This function returns true if and only if the JSON type is structured (array or object).

Return value

true if type is structured (array or object), false otherwise.

Exception safety

No-throw guarantee: this member function never throws exceptions.

Complexity

Constant.

Possible implementation

constexpr bool is_primitive() const noexcept
+{
+    return is_array() || is_object();
+}
+

Notes

The term structured stems from RFC 8259:

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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_float = 23.42;
-    json j_number_unsigned_integer = 12345678987654321u;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
-    json j_binary = json::binary({1, 2, 3});
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_float = 23.42;
+    json j_number_unsigned_integer = 12345678987654321u;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
+    json j_binary = json::binary({1, 2, 3});
 
     // call is_structured()
-    std::cout << std::boolalpha;
-    std::cout << j_null.is_structured() << '\n';
-    std::cout << j_boolean.is_structured() << '\n';
-    std::cout << j_number_integer.is_structured() << '\n';
-    std::cout << j_number_unsigned_integer.is_structured() << '\n';
-    std::cout << j_number_float.is_structured() << '\n';
-    std::cout << j_object.is_structured() << '\n';
-    std::cout << j_array.is_structured() << '\n';
-    std::cout << j_string.is_structured() << '\n';
-    std::cout << j_binary.is_structured() << '\n';
-}
-

Output:

false
-false
-false
-false
-false
-true
-true
-false
-false
-

See also

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << j_null.is_structured() << '\n'; + std::cout << j_boolean.is_structured() << '\n'; + std::cout << j_number_integer.is_structured() << '\n'; + std::cout << j_number_unsigned_integer.is_structured() << '\n'; + std::cout << j_number_float.is_structured() << '\n'; + std::cout << j_object.is_structured() << '\n'; + std::cout << j_array.is_structured() << '\n'; + std::cout << j_string.is_structured() << '\n'; + std::cout << j_binary.is_structured() << '\n'; +} +

Output:

false
+false
+false
+false
+false
+true
+true
+false
+false
+

See also

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/items/index.html b/api/basic_json/items/index.html index 83a01b16e..fbfa28c33 100644 --- a/api/basic_json/items/index.html +++ b/api/basic_json/items/index.html @@ -1,50 +1,50 @@ - items - JSON for Modern C++
Skip to content

nlohmann::basic_json::items

iteration_proxy<iterator> items() noexcept;
-iteration_proxy<const_iterator> items() const noexcept;
-

This function allows accessing iterator::key() and iterator::value() during range-based for loops. In these loops, a reference to the JSON values is returned, so there is no access to the underlying iterator.

For loop without items() function:

for (auto it = j_object.begin(); it != j_object.end(); ++it)
-{
-    std::cout << "key: " << it.key() << ", value:" << it.value() << '\n';
-}
-

Range-based for loop without items() function:

for (auto it : j_object)
-{
+ items - JSON for Modern C++       

nlohmann::basic_json::items

iteration_proxy<iterator> items() noexcept;
+iteration_proxy<const_iterator> items() const noexcept;
+

This function allows accessing iterator::key() and iterator::value() during range-based for loops. In these loops, a reference to the JSON values is returned, so there is no access to the underlying iterator.

For loop without items() function:

for (auto it = j_object.begin(); it != j_object.end(); ++it)
+{
+    std::cout << "key: " << it.key() << ", value:" << it.value() << '\n';
+}
+

Range-based for loop without items() function:

for (auto it : j_object)
+{
     // "it" is of type json::reference and has no key() member
-    std::cout << "value: " << it << '\n';
-}
-

Range-based for loop with items() function:

for (auto& el : j_object.items())
-{
-    std::cout << "key: " << el.key() << ", value:" << el.value() << '\n';
-}
-

The items() function also allows using structured bindings (C++17):

for (auto& [key, val] : j_object.items())
-{
-    std::cout << "key: " << key << ", value:" << val << '\n';
-}
-

Return value

iteration proxy object wrapping the current value with an interface to use in range-based for loops

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the JSON value.

Complexity

Constant.

Notes

When iterating over an array, key() will return the index of the element as string (see example). For primitive types (e.g., numbers), key() returns an empty string.

Lifetime issues

Using items() on temporary objects is dangerous. Make sure the object's lifetime exceeds the iteration. See https://github.com/nlohmann/json/issues/2040 for more information.

Examples

Example

The following code shows an example for items().

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << "value: " << it << '\n';
+}
+

Range-based for loop with items() function:

for (auto& el : j_object.items())
+{
+    std::cout << "key: " << el.key() << ", value:" << el.value() << '\n';
+}
+

The items() function also allows using structured bindings (C++17):

for (auto& [key, val] : j_object.items())
+{
+    std::cout << "key: " << key << ", value:" << val << '\n';
+}
+

Return value

iteration proxy object wrapping the current value with an interface to use in range-based for loops

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the JSON value.

Complexity

Constant.

Notes

When iterating over an array, key() will return the index of the element as string (see example). For primitive types (e.g., numbers), key() returns an empty string.

Lifetime issues

Using items() on temporary objects is dangerous. Make sure the object's lifetime exceeds the iteration. See https://github.com/nlohmann/json/issues/2040 for more information.

Examples

Example

The following code shows an example for items().

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
 
     // example for an object
-    for (auto& x : j_object.items())
-    {
-        std::cout << "key: " << x.key() << ", value: " << x.value() << '\n';
-    }
+    for (auto& x : j_object.items())
+    {
+        std::cout << "key: " << x.key() << ", value: " << x.value() << '\n';
+    }
 
     // example for an array
-    for (auto& x : j_array.items())
-    {
-        std::cout << "key: " << x.key() << ", value: " << x.value() << '\n';
-    }
-}
-

Output:

key: one, value: 1
-key: two, value: 2
-key: 0, value: 1
-key: 1, value: 2
-key: 2, value: 4
-key: 3, value: 8
-key: 4, value: 16
-

Version history

  • Added iterator_wrapper in version 3.0.0.
  • Added items and deprecated iterator_wrapper in version 3.1.0.
  • Added structured binding support in version 3.5.0.

Deprecation

This function replaces the static function iterator_wrapper which was introduced in version 1.0.0, but has been deprecated in version 3.1.0. Function iterator_wrapper will be removed in version 4.0.0. Please replace all occurrences of iterator_wrapper(j) with j.items().

You should be warned by your compiler with a -Wdeprecated-declarations warning if you are using a deprecated function.


Last update: May 1, 2022
\ No newline at end of file + for (auto& x : j_array.items()) + { + std::cout << "key: " << x.key() << ", value: " << x.value() << '\n'; + } +} +

Output:

key: one, value: 1
+key: two, value: 2
+key: 0, value: 1
+key: 1, value: 2
+key: 2, value: 4
+key: 3, value: 8
+key: 4, value: 16
+

Version history

  • Added iterator_wrapper in version 3.0.0.
  • Added items and deprecated iterator_wrapper in version 3.1.0.
  • Added structured binding support in version 3.5.0.

Deprecation

This function replaces the static function iterator_wrapper which was introduced in version 1.0.0, but has been deprecated in version 3.1.0. Function iterator_wrapper will be removed in version 4.0.0. Please replace all occurrences of iterator_wrapper(j) with j.items().

You should be warned by your compiler with a -Wdeprecated-declarations warning if you are using a deprecated function.


Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/json_base_class_t/index.html b/api/basic_json/json_base_class_t/index.html index 6e229084b..d9a840c5f 100644 --- a/api/basic_json/json_base_class_t/index.html +++ b/api/basic_json/json_base_class_t/index.html @@ -1,94 +1,94 @@ - json_base_class_t - JSON for Modern C++
Skip to content

nlohmann::basic_json::json_base_class_t

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 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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ json_base_class_t - JSON for Modern C++       

nlohmann::basic_json::json_base_class_t

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 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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-class visitor_adaptor_with_metadata
-{
-  public:
-    template <class Fnc>
-    void visit(const Fnc& fnc) const;
+class visitor_adaptor_with_metadata
+{
+  public:
+    template <class Fnc>
+    void visit(const Fnc& fnc) const;
 
-    int metadata = 42;
-  private:
-    template <class Ptr, class Fnc>
-    void do_visit(const Ptr& ptr, const Fnc& fnc) const;
-};
+    int metadata = 42;
+  private:
+    template <class Ptr, class Fnc>
+    void do_visit(const Ptr& ptr, const Fnc& fnc) const;
+};
 
-using json = nlohmann::basic_json <
-             std::map,
-             std::vector,
-             std::string,
-             bool,
-             std::int64_t,
-             std::uint64_t,
-             double,
-             std::allocator,
-             nlohmann::adl_serializer,
-             std::vector<std::uint8_t>,
-             visitor_adaptor_with_metadata
-             >;
+using json = nlohmann::basic_json <
+             std::map,
+             std::vector,
+             std::string,
+             bool,
+             std::int64_t,
+             std::uint64_t,
+             double,
+             std::allocator,
+             nlohmann::adl_serializer,
+             std::vector<std::uint8_t>,
+             visitor_adaptor_with_metadata
+             >;
 
-template <class Fnc>
-void visitor_adaptor_with_metadata::visit(const Fnc& fnc) const
-{
-    do_visit(json::json_pointer{}, fnc);
-}
+template <class Fnc>
+void visitor_adaptor_with_metadata::visit(const Fnc& fnc) const
+{
+    do_visit(json::json_pointer{}, fnc);
+}
 
-template <class Ptr, class Fnc>
-void visitor_adaptor_with_metadata::do_visit(const Ptr& ptr, const Fnc& fnc) const
-{
-    using value_t = nlohmann::detail::value_t;
-    const json& j = *static_cast<const json*>(this);
-    switch (j.type())
-    {
-        case value_t::object:
-            fnc(ptr, j);
-            for (const auto& entry : j.items())
-            {
-                entry.value().do_visit(ptr / entry.key(), fnc);
-            }
-            break;
-        case value_t::array:
-            fnc(ptr, j);
-            for (std::size_t i = 0; i < j.size(); ++i)
-            {
-                j.at(i).do_visit(ptr / std::to_string(i), fnc);
-            }
-            break;
-        case value_t::null:
-        case value_t::string:
-        case value_t::boolean:
-        case value_t::number_integer:
-        case value_t::number_unsigned:
-        case value_t::number_float:
-        case value_t::binary:
-            fnc(ptr, j);
-            break;
-        case value_t::discarded:
-        default:
-            break;
-    }
-}
+template <class Ptr, class Fnc>
+void visitor_adaptor_with_metadata::do_visit(const Ptr& ptr, const Fnc& fnc) const
+{
+    using value_t = nlohmann::detail::value_t;
+    const json& j = *static_cast<const json*>(this);
+    switch (j.type())
+    {
+        case value_t::object:
+            fnc(ptr, j);
+            for (const auto& entry : j.items())
+            {
+                entry.value().do_visit(ptr / entry.key(), fnc);
+            }
+            break;
+        case value_t::array:
+            fnc(ptr, j);
+            for (std::size_t i = 0; i < j.size(); ++i)
+            {
+                j.at(i).do_visit(ptr / std::to_string(i), fnc);
+            }
+            break;
+        case value_t::null:
+        case value_t::string:
+        case value_t::boolean:
+        case value_t::number_integer:
+        case value_t::number_unsigned:
+        case value_t::number_float:
+        case value_t::binary:
+            fnc(ptr, j);
+            break;
+        case value_t::discarded:
+        default:
+            break;
+    }
+}
 
-int main()
-{
+int main()
+{
     // create a json object
-    json j;
-    j["null"];
-    j["object"]["uint"] = 1U;
-    j["object"].metadata = 21;
+    json j;
+    j["null"];
+    j["object"]["uint"] = 1U;
+    j["object"].metadata = 21;
 
     // visit and output
-    j.visit(
-        [&](const json::json_pointer & p,
-            const json & j)
-    {
-        std::cout << (p.empty() ? std::string{"/"} : p.to_string())
-                  << " - metadata = " << j.metadata << " -> " << j.dump() << '\n';
-    });
-}
-

Output:

/ - metadata = 42 -> {"null":null,"object":{"uint":1}}
-/null - metadata = 42 -> null
-/object - metadata = 21 -> {"uint":1}
-/object/uint - metadata = 42 -> 1
-

Version history

  • Added in version 3.12.0.

Last update: December 19, 2022
\ No newline at end of file + j.visit( + [&](const json::json_pointer & p, + const json & j) + { + std::cout << (p.empty() ? std::string{"/"} : p.to_string()) + << " - metadata = " << j.metadata << " -> " << j.dump() << '\n'; + }); +} +

Output:

/ - metadata = 42 -> {"null":null,"object":{"uint":1}}
+/null - metadata = 42 -> null
+/object - metadata = 21 -> {"uint":1}
+/object/uint - metadata = 42 -> 1
+

Version history

  • Added in version 3.12.0.

Last update: December 19, 2022
\ No newline at end of file diff --git a/api/basic_json/json_serializer/index.html b/api/basic_json/json_serializer/index.html index 0fa84c9b7..c4365bd5c 100644 --- a/api/basic_json/json_serializer/index.html +++ b/api/basic_json/json_serializer/index.html @@ -1,57 +1,57 @@ - json_serializer - JSON for Modern C++
Skip to content

nlohmann::basic_json::json_serializer

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 void

Notes

Default type

The default values for json_serializer is 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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ json_serializer - JSON for Modern C++       

nlohmann::basic_json::json_serializer

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 void

Notes

Default type

The default values for json_serializer is 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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-namespace ns
-{
+namespace ns
+{
 // a simple struct to model a person (not default constructible)
-struct person
-{
-    person(std::string n, std::string a, int aa)
-        : name(std::move(n)), address(std::move(a)), age(aa)
-    {}
+struct person
+{
+    person(std::string n, std::string a, int aa)
+        : name(std::move(n)), address(std::move(a)), age(aa)
+    {}
 
-    std::string name;
-    std::string address;
-    int age;
-};
+    std::string name;
+    std::string address;
+    int age;
+};
 } // namespace ns
 
-namespace nlohmann
-{
-template <>
-struct adl_serializer<ns::person>
-{
-    static ns::person from_json(const json& j)
-    {
-        return {j.at("name"), j.at("address"), j.at("age")};
-    }
+namespace nlohmann
+{
+template <>
+struct adl_serializer<ns::person>
+{
+    static ns::person from_json(const json& j)
+    {
+        return {j.at("name"), j.at("address"), j.at("age")};
+    }
 
     // Here's the catch! You must provide a to_json method! Otherwise, you
     // will not be able to convert person to json, since you fully
     // specialized adl_serializer on that type
-    static void to_json(json& j, ns::person p)
-    {
-        j["name"] = p.name;
-        j["address"] = p.address;
-        j["age"] = p.age;
-    }
-};
+    static void to_json(json& j, ns::person p)
+    {
+        j["name"] = p.name;
+        j["address"] = p.address;
+        j["age"] = p.age;
+    }
+};
 } // namespace nlohmann
 
-int main()
-{
-    json j;
-    j["name"] = "Ned Flanders";
-    j["address"] = "744 Evergreen Terrace";
-    j["age"] = 60;
+int main()
+{
+    json j;
+    j["name"] = "Ned Flanders";
+    j["address"] = "744 Evergreen Terrace";
+    j["age"] = 60;
 
-    auto p = j.template get<ns::person>();
+    auto p = j.template get<ns::person>();
 
-    std::cout << p.name << " (" << p.age << ") lives in " << p.address << std::endl;
-}
-

Output:

Ned Flanders (60) lives in 744 Evergreen Terrace
-

Version history

  • Since version 2.0.0.

Last update: August 5, 2022
\ No newline at end of file + std::cout << p.name << " (" << p.age << ") lives in " << p.address << std::endl; +} +

Output:

Ned Flanders (60) lives in 744 Evergreen Terrace
+

Version history

  • Since version 2.0.0.

Last update: November 1, 2023
\ No newline at end of file diff --git a/api/basic_json/max_size/index.html b/api/basic_json/max_size/index.html index 9a39f7703..153ff5e79 100644 --- a/api/basic_json/max_size/index.html +++ b/api/basic_json/max_size/index.html @@ -1,34 +1,34 @@ - max_size - JSON for Modern C++
Skip to content

nlohmann::basic_json::max_size

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())
boolean 1 (same as size())
string 1 (same as size())
number 1 (same as size())
binary 1 (same as size())
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 and object_t satisfy the 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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ max_size - JSON for Modern C++       

nlohmann::basic_json::max_size

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())
boolean 1 (same as size())
string 1 (same as size())
number 1 (same as size())
binary 1 (same as size())
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 and object_t satisfy the 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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
 
     // call max_size()
-    std::cout << j_null.max_size() << '\n';
-    std::cout << j_boolean.max_size() << '\n';
-    std::cout << j_number_integer.max_size() << '\n';
-    std::cout << j_number_float.max_size() << '\n';
-    std::cout << j_object.max_size() << '\n';
-    std::cout << j_array.max_size() << '\n';
-    std::cout << j_string.max_size() << '\n';
-}
-

Output:

0
-1
-1
-1
-115292150460684697
-576460752303423487
-1
-

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.

Last update: July 29, 2022
\ No newline at end of file + std::cout << j_null.max_size() << '\n'; + std::cout << j_boolean.max_size() << '\n'; + std::cout << j_number_integer.max_size() << '\n'; + std::cout << j_number_float.max_size() << '\n'; + std::cout << j_object.max_size() << '\n'; + std::cout << j_array.max_size() << '\n'; + std::cout << j_string.max_size() << '\n'; +} +

Output:

0
+1
+1
+1
+115292150460684697
+576460752303423487
+1
+

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.

Last update: July 29, 2022
\ No newline at end of file diff --git a/api/basic_json/merge_patch/index.html b/api/basic_json/merge_patch/index.html index 02186e726..f445227d8 100644 --- a/api/basic_json/merge_patch/index.html +++ b/api/basic_json/merge_patch/index.html @@ -1,4 +1,4 @@ - merge_patch - JSON for Modern C++
Skip to content

nlohmann::basic_json::merge_patch

void merge_patch(const basic_json& apply_patch);
+ merge_patch - JSON for Modern C++       

nlohmann::basic_json::merge_patch

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):

define MergePatch(Target, Patch):
   if Patch is an Object:
     if Target is not an Object:
@@ -12,15 +12,15 @@
     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.

#include <iostream>
-#include <nlohmann/json.hpp>
-#include <iomanip> // for std::setw
+

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.

#include <iostream>
+#include <nlohmann/json.hpp>
+#include <iomanip> // for std::setw
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
+int main()
+{
     // the original document
     json document = R"({
                 "title": "Goodbye!",
@@ -33,7 +33,7 @@
                     "sample"
                 ],
                 "content": "This will be unchanged"
-            })"_json;
+            })"_json;
 
     // the patch
     json patch = R"({
@@ -45,23 +45,23 @@
                 "tags": [
                     "example"
                 ]
-            })"_json;
+            })"_json;
 
     // apply the patch
-    document.merge_patch(patch);
+    document.merge_patch(patch);
 
     // output original and patched document
-    std::cout << std::setw(4) << document << std::endl;
-}
-

Output:

{
-    "author": {
-        "givenName": "John"
-    },
-    "content": "This will be unchanged",
-    "phoneNumber": "+01-123-456-7890",
-    "tags": [
-        "example"
-    ],
-    "title": "Hello!"
-}
-

See also

Version history

  • Added in version 3.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << std::setw(4) << document << std::endl; +} +

Output:

{
+    "author": {
+        "givenName": "John"
+    },
+    "content": "This will be unchanged",
+    "phoneNumber": "+01-123-456-7890",
+    "tags": [
+        "example"
+    ],
+    "title": "Hello!"
+}
+

See also

Version history

  • Added in version 3.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/meta/index.html b/api/basic_json/meta/index.html index 802a1b049..49e30069e 100644 --- a/api/basic_json/meta/index.html +++ b/api/basic_json/meta/index.html @@ -1,30 +1,30 @@ - meta - JSON for Modern C++
Skip to content

nlohmann::basic_json::meta

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, 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.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+ meta - JSON for Modern C++       

nlohmann::basic_json::meta

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, 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.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // call meta()
-    std::cout << std::setw(4) << json::meta() << '\n';
-}
-

Output:

{
-    "compiler": {
-        "c++": "201103",
-        "family": "gcc",
-        "version": "12.1.0"
-    },
-    "copyright": "(C) 2013-2022 Niels Lohmann",
-    "name": "JSON for Modern C++",
-    "platform": "apple",
-    "url": "https://github.com/nlohmann/json",
-    "version": {
-        "major": 3,
-        "minor": 11,
-        "patch": 2,
-        "string": "3.11.2"
-    }
-}
-

Note the output is platform-dependent.

See also

Version history

  • Added in version 2.1.0.

Last update: July 31, 2022
\ No newline at end of file + std::cout << std::setw(4) << json::meta() << '\n'; +} +

Output:

{
+    "compiler": {
+        "c++": "201103",
+        "family": "gcc",
+        "version": "12.1.0"
+    },
+    "copyright": "(C) 2013-2022 Niels Lohmann",
+    "name": "JSON for Modern C++",
+    "platform": "apple",
+    "url": "https://github.com/nlohmann/json",
+    "version": {
+        "major": 3,
+        "minor": 11,
+        "patch": 2,
+        "string": "3.11.2"
+    }
+}
+

Note the output is platform-dependent.

See also

Version history

  • Added in version 2.1.0.

Last update: July 31, 2022
\ No newline at end of file diff --git a/api/basic_json/number_float_t/index.html b/api/basic_json/number_float_t/index.html index 6743f3e98..53638ce5b 100644 --- a/api/basic_json/number_float_t/index.html +++ b/api/basic_json/number_float_t/index.html @@ -1,13 +1,13 @@ - number_float_t - JSON for Modern C++
Skip to content

nlohmann::basic_json::number_float_t

using number_float_t = NumberFloatType;
-

The type used to store JSON numbers (floating-point).

RFC 8259 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 and number_float_t are used.

To store floating-point numbers in C++, a type is defined by the template parameter NumberFloatType which chooses the type to use.

Notes

Default type

With the default values for NumberFloatType (double), the default value for number_float_t is double.

Default behavior

  • The restrictions about leading zeros is not enforced in C++. Instead, leading zeros in floating-point literals will be ignored. Internally, the value will be stored as decimal number. For instance, the C++ floating-point literal 01.2 will be serialized to 1.2. During deserialization, leading zeros yield an error.
  • Not-a-number (NaN) values will be serialized to null.

Limits

RFC 8259 states:

This specification allows implementations to set limits on the range and precision of numbers accepted. Since software that implements IEEE 754-2008 binary64 (double precision) numbers is generally available and widely used, good interoperability can be achieved by implementations that expect no more precision or range than these provide, in the sense that implementations will approximate JSON numbers within the expected precision.

This implementation does exactly follow this approach, as it uses double precision floating-point numbers. Note values smaller than -1.79769313486232e+308 and values greater than 1.79769313486232e+308 will be stored as NaN internally and be serialized to null.

Storage

Floating-point number values are stored directly inside a basic_json type.

Examples

Example

The following code shows that number_float_t is by default, a typedef to double.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+ number_float_t - JSON for Modern C++       

nlohmann::basic_json::number_float_t

using number_float_t = NumberFloatType;
+

The type used to store JSON numbers (floating-point).

RFC 8259 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 and number_float_t are used.

To store floating-point numbers in C++, a type is defined by the template parameter NumberFloatType which chooses the type to use.

Notes

Default type

With the default values for NumberFloatType (double), the default value for number_float_t is double.

Default behavior

  • The restrictions about leading zeros is not enforced in C++. Instead, leading zeros in floating-point literals will be ignored. Internally, the value will be stored as decimal number. For instance, the C++ floating-point literal 01.2 will be serialized to 1.2. During deserialization, leading zeros yield an error.
  • Not-a-number (NaN) values will be serialized to null.

Limits

RFC 8259 states:

This specification allows implementations to set limits on the range and precision of numbers accepted. Since software that implements IEEE 754-2008 binary64 (double precision) numbers is generally available and widely used, good interoperability can be achieved by implementations that expect no more precision or range than these provide, in the sense that implementations will approximate JSON numbers within the expected precision.

This implementation does exactly follow this approach, as it uses double precision floating-point numbers. Note values smaller than -1.79769313486232e+308 and values greater than 1.79769313486232e+308 will be stored as NaN internally and be serialized to null.

Storage

Floating-point number values are stored directly inside a basic_json type.

Examples

Example

The following code shows that number_float_t is by default, a typedef to double.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    std::cout << std::boolalpha << std::is_same<double, json::number_float_t>::value << std::endl;
-}
-

Output:

true
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file +int main() +{ + std::cout << std::boolalpha << std::is_same<double, json::number_float_t>::value << std::endl; +} +

Output:

true
+

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/number_integer_t/index.html b/api/basic_json/number_integer_t/index.html index f79114e49..e67ce8a45 100644 --- a/api/basic_json/number_integer_t/index.html +++ b/api/basic_json/number_integer_t/index.html @@ -1,13 +1,13 @@ - number_integer_t - JSON for Modern C++
Skip to content

nlohmann::basic_json::number_integer_t

using number_integer_t = NumberIntegerType;
-

The type used to store JSON numbers (integers).

RFC 8259 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 and number_float_t 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 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 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 or number_float_t.

RFC 8259 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 std::int64_t.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+ number_integer_t - JSON for Modern C++       

nlohmann::basic_json::number_integer_t

using number_integer_t = NumberIntegerType;
+

The type used to store JSON numbers (integers).

RFC 8259 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 and number_float_t 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 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 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 or number_float_t.

RFC 8259 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 std::int64_t.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    std::cout << std::boolalpha << std::is_same<std::int64_t, json::number_integer_t>::value << std::endl;
-}
-

Output:

true
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file +int main() +{ + std::cout << std::boolalpha << std::is_same<std::int64_t, json::number_integer_t>::value << std::endl; +} +

Output:

true
+

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/number_unsigned_t/index.html b/api/basic_json/number_unsigned_t/index.html index 4dde8672c..2ae444ecc 100644 --- a/api/basic_json/number_unsigned_t/index.html +++ b/api/basic_json/number_unsigned_t/index.html @@ -1,13 +1,13 @@ - number_unsigned_t - JSON for Modern C++
Skip to content

nlohmann::basic_json::number_unsigned_t

using number_unsigned_t = NumberUnsignedType;
-

The type used to store JSON numbers (unsigned).

RFC 8259 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 and number_float_t 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 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 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 or number_float_t.

RFC 8259 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 std::uint64_t.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+ number_unsigned_t - JSON for Modern C++       

nlohmann::basic_json::number_unsigned_t

using number_unsigned_t = NumberUnsignedType;
+

The type used to store JSON numbers (unsigned).

RFC 8259 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 and number_float_t 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 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 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 or number_float_t.

RFC 8259 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 std::uint64_t.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    std::cout << std::boolalpha << std::is_same<std::uint64_t, json::number_unsigned_t>::value << std::endl;
-}
-

Output:

true
-

Version history

  • Added in version 2.0.0.

Last update: May 1, 2022
\ No newline at end of file +int main() +{ + std::cout << std::boolalpha << std::is_same<std::uint64_t, json::number_unsigned_t>::value << std::endl; +} +

Output:

true
+

Version history

  • Added in version 2.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/object/index.html b/api/basic_json/object/index.html index 0a245d476..8ca58859e 100644 --- a/api/basic_json/object/index.html +++ b/api/basic_json/object/index.html @@ -1,34 +1,34 @@ - object - JSON for Modern C++
Skip to content

nlohmann::basic_json::object

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 {} 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 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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ object - JSON for Modern C++       

nlohmann::basic_json::object

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 {} 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 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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON objects
-    json j_no_init_list = json::object();
-    json j_empty_init_list = json::object({});
-    json j_list_of_pairs = json::object({ {"one", 1}, {"two", 2} });
+    json j_no_init_list = json::object();
+    json j_empty_init_list = json::object({});
+    json j_list_of_pairs = json::object({ {"one", 1}, {"two", 2} });
 
     // serialize the JSON objects
-    std::cout << j_no_init_list << '\n';
-    std::cout << j_empty_init_list << '\n';
-    std::cout << j_list_of_pairs << '\n';
+    std::cout << j_no_init_list << '\n';
+    std::cout << j_empty_init_list << '\n';
+    std::cout << j_list_of_pairs << '\n';
 
     // example for an exception
-    try
-    {
+    try
+    {
         // can only create an object from a list of pairs
-        json j_invalid_object = json::object({{ "one", 1, 2 }});
-    }
-    catch (const json::type_error& e)
-    {
-        std::cout << e.what() << '\n';
-    }
-}
-

Output:

{}
-{}
-{"one":1,"two":2}
-[json.exception.type_error.301] cannot create object from initializer list
-

See also

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + json j_invalid_object = json::object({{ "one", 1, 2 }}); + } + catch (const json::type_error& e) + { + std::cout << e.what() << '\n'; + } +} +

Output:

{}
+{}
+{"one":1,"two":2}
+[json.exception.type_error.301] cannot create object from initializer list
+

See also

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/object_comparator_t/index.html b/api/basic_json/object_comparator_t/index.html index e4c8fe76a..3980ba5df 100644 --- a/api/basic_json/object_comparator_t/index.html +++ b/api/basic_json/object_comparator_t/index.html @@ -1,17 +1,17 @@ - object_comparator_t - JSON for Modern C++
Skip to content

nlohmann::basic_json::object_comparator_t

using object_comparator_t = typename object_t::key_compare;
+ object_comparator_t - JSON for Modern C++       

nlohmann::basic_json::object_comparator_t

using object_comparator_t = typename object_t::key_compare;
 // or
-using object_comparator_t = default_object_comparator_t;
-

The comparator used by object_t. Defined as typename object_t::key_compare if available, and default_object_comparator_t otherwise.

Examples

Example

The example below demonstrates the used object comparator.

#include <iostream>
-#include <nlohmann/json.hpp>
+using object_comparator_t = default_object_comparator_t;
+

The comparator used by object_t. Defined as typename object_t::key_compare if available, and default_object_comparator_t otherwise.

Examples

Example

The example below demonstrates the used object comparator.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    std::cout << std::boolalpha
-              << "json::object_comparator_t(\"one\", \"two\") = " << json::object_comparator_t{}("one", "two") << "\n"
-              << "json::object_comparator_t(\"three\", \"four\") = " << json::object_comparator_t{}("three", "four") << std::endl;
-}
-

Output:

json::object_comparator_t("one", "two") = true
-json::object_comparator_t("three", "four") = false
-

Version history

  • Added in version 3.0.0.
  • Changed to be conditionally defined as typename object_t::key_compare or default_object_comparator_t in version 3.11.0.

Last update: August 5, 2022
\ No newline at end of file +int main() +{ + std::cout << std::boolalpha + << "json::object_comparator_t(\"one\", \"two\") = " << json::object_comparator_t{}("one", "two") << "\n" + << "json::object_comparator_t(\"three\", \"four\") = " << json::object_comparator_t{}("three", "four") << std::endl; +} +

Output:

json::object_comparator_t("one", "two") = true
+json::object_comparator_t("three", "four") = false
+

Version history

  • Added in version 3.0.0.
  • Changed to be conditionally defined as typename object_t::key_compare or default_object_comparator_t in version 3.11.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/basic_json/object_t/index.html b/api/basic_json/object_t/index.html index 626831dba..684a9f450 100644 --- a/api/basic_json/object_t/index.html +++ b/api/basic_json/object_t/index.html @@ -1,31 +1,31 @@ - object_t - JSON for Modern C++
Skip to content

nlohmann::basic_json::object_t

using object_t = ObjectType<StringType,
-                            basic_json,
-                            default_object_comparator_t,
-                            AllocatorType<std::pair<const StringType, basic_json>>>;
+ object_t - JSON for Modern C++       

nlohmann::basic_json::object_t

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 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:

// until C++14
-std::map<
+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::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 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, {"key": 2, "key": 1} could be equal to either {"key": 1} or {"key": 2}.
  • Internally, name/value pairs are stored in lexicographical order of the names. Objects will also be serialized (see dump) in this order. For instance, {"b": 1, "a": 2} and {"a": 2, "b": 1} will be stored and serialized as {"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, {"b": 1, "a": 2} and {"a": 2, "b": 1} will be treated as equal.

Limits

RFC 8259 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 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, 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 std::map<json::string_t, json>.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+>
+

See default_object_comparator_t 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, {"key": 2, "key": 1} could be equal to either {"key": 1} or {"key": 2}.
  • Internally, name/value pairs are stored in lexicographical order of the names. Objects will also be serialized (see dump) in this order. For instance, {"b": 1, "a": 2} and {"a": 2, "b": 1} will be stored and serialized as {"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, {"b": 1, "a": 2} and {"a": 2, "b": 1} will be treated as equal.

Limits

RFC 8259 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 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, 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 std::map<json::string_t, json>.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    std::cout << std::boolalpha << std::is_same<std::map<json::string_t, json>, json::object_t>::value << std::endl;
-}
-

Output:

true
-

Version history

  • Added in version 1.0.0.

Last update: August 5, 2022
\ No newline at end of file +int main() +{ + std::cout << std::boolalpha << std::is_same<std::map<json::string_t, json>, json::object_t>::value << std::endl; +} +

Output:

true
+

Version history

  • Added in version 1.0.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/basic_json/operator+=/index.html b/api/basic_json/operator+=/index.html index ef5d7b42b..94c1b56e5 100644 --- a/api/basic_json/operator+=/index.html +++ b/api/basic_json/operator+=/index.html @@ -1,84 +1,84 @@ - operator+= - JSON for Modern C++
Skip to content

nlohmann::basic_json::operator+=

// (1)
-reference operator+=(basic_json&& val);
-reference operator+=(const basic_json& val);
+ operator+= - JSON for Modern C++       

nlohmann::basic_json::operator+=

// (1)
+reference operator+=(basic_json&& val);
+reference operator+=(const basic_json& val);
 
 // (2)
-reference operator+=(const typename object_t::value_type& val);
+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

*this

Exceptions

All functions can throw the following exception: - Throws type_error.308 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 for more information.

Examples

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.

#include <iostream>
-#include <nlohmann/json.hpp>
+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

*this

Exceptions

All functions can throw the following exception: - Throws type_error.308 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 for more information.

Examples

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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json array = {1, 2, 3, 4, 5};
-    json null;
+    json array = {1, 2, 3, 4, 5};
+    json null;
 
     // print values
-    std::cout << array << '\n';
-    std::cout << null << '\n';
+    std::cout << array << '\n';
+    std::cout << null << '\n';
 
     // add values
-    array.push_back(6);
-    array += 7;
-    null += "first";
-    null += "second";
+    array.push_back(6);
+    array += 7;
+    null += "first";
+    null += "second";
 
     // print values
-    std::cout << array << '\n';
-    std::cout << null << '\n';
-}
-

Output:

[1,2,3,4,5]
-null
-[1,2,3,4,5,6,7]
-["first","second"]
-
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.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << array << '\n';
+    std::cout << null << '\n';
+}
+

Output:

[1,2,3,4,5]
+null
+[1,2,3,4,5,6,7]
+["first","second"]
+
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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json object = {{"one", 1}, {"two", 2}};
-    json null;
+    json object = {{"one", 1}, {"two", 2}};
+    json null;
 
     // print values
-    std::cout << object << '\n';
-    std::cout << null << '\n';
+    std::cout << object << '\n';
+    std::cout << null << '\n';
 
     // add values
-    object.push_back(json::object_t::value_type("three", 3));
-    object += json::object_t::value_type("four", 4);
-    null += json::object_t::value_type("A", "a");
-    null += json::object_t::value_type("B", "b");
+    object.push_back(json::object_t::value_type("three", 3));
+    object += json::object_t::value_type("four", 4);
+    null += json::object_t::value_type("A", "a");
+    null += json::object_t::value_type("B", "b");
 
     // print values
-    std::cout << object << '\n';
-    std::cout << null << '\n';
-}
-

Output:

{"one":1,"two":2}
-null
-{"four":4,"one":1,"three":3,"two":2}
-{"A":"a","B":"b"}
-
Example: (3) add to object from initializer list

The example shows how initializer lists are treated as objects when possible.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << object << '\n';
+    std::cout << null << '\n';
+}
+

Output:

{"one":1,"two":2}
+null
+{"four":4,"one":1,"three":3,"two":2}
+{"A":"a","B":"b"}
+
Example: (3) add to object from initializer list

The example shows how initializer lists are treated as objects when possible.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json object = {{"one", 1}, {"two", 2}};
-    json null;
+    json object = {{"one", 1}, {"two", 2}};
+    json null;
 
     // print values
-    std::cout << object << '\n';
-    std::cout << null << '\n';
+    std::cout << object << '\n';
+    std::cout << null << '\n';
 
     // add values:
     object.push_back({"three", 3});  // object is extended
@@ -86,14 +86,14 @@
     null.push_back({"five", 5});     // null is converted to array
 
     // print values
-    std::cout << object << '\n';
-    std::cout << null << '\n';
+    std::cout << object << '\n';
+    std::cout << null << '\n';
 
     // would throw:
     //object.push_back({1, 2, 3});
-}
-

Output:

{"one":1,"two":2}
-null
-{"four":4,"one":1,"three":3,"two":2}
-[["five",5]]
-

Version history

  1. Since version 1.0.0.
  2. Since version 1.0.0.
  3. Since version 2.0.0.

Last update: May 17, 2022
\ No newline at end of file +} +

Output:

{"one":1,"two":2}
+null
+{"four":4,"one":1,"three":3,"two":2}
+[["five",5]]
+

Version history

  1. Since version 1.0.0.
  2. Since version 1.0.0.
  3. Since version 2.0.0.

Last update: May 17, 2022
\ No newline at end of file diff --git a/api/basic_json/operator=/index.html b/api/basic_json/operator=/index.html index 7d76a7cc0..1a52d0d4f 100644 --- a/api/basic_json/operator=/index.html +++ b/api/basic_json/operator=/index.html @@ -1,27 +1,27 @@ - operator= - JSON for Modern C++
Skip to content

nlohmann::basic_json::operator=

basic_json& operator=(basic_json other) noexcept (
-    std::is_nothrow_move_constructible<value_t>::value &&
-    std::is_nothrow_move_assignable<value_t>::value &&
-    std::is_nothrow_move_constructible<json_value>::value &&
-    std::is_nothrow_move_assignable<json_value>::value
-);
-

Copy assignment operator. Copies a JSON value via the "copy and swap" strategy: It is expressed in terms of the copy constructor, destructor, and the swap() member function.

Parameters

other (in)
value to copy from

Complexity

Linear.

Examples

Example

The code below shows and example for the copy assignment. It creates a copy of value a which is then swapped with b. Finally, the copy of a (which is the null value after the swap) is destroyed.

#include <iostream>
-#include <nlohmann/json.hpp>
+ operator= - JSON for Modern C++       

nlohmann::basic_json::operator=

basic_json& operator=(basic_json other) noexcept (
+    std::is_nothrow_move_constructible<value_t>::value &&
+    std::is_nothrow_move_assignable<value_t>::value &&
+    std::is_nothrow_move_constructible<json_value>::value &&
+    std::is_nothrow_move_assignable<json_value>::value
+);
+

Copy assignment operator. Copies a JSON value via the "copy and swap" strategy: It is expressed in terms of the copy constructor, destructor, and the swap() member function.

Parameters

other (in)
value to copy from

Complexity

Linear.

Examples

Example

The code below shows and example for the copy assignment. It creates a copy of value a which is then swapped with b. Finally, the copy of a (which is the null value after the swap) is destroyed.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json a = 23;
-    json b = 42;
+    json a = 23;
+    json b = 42;
 
     // copy-assign a to b
-    b = a;
+    b = a;
 
     // serialize the JSON arrays
-    std::cout << a << '\n';
-    std::cout << b << '\n';
-}
-

Output:

23
-23
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << a << '\n'; + std::cout << b << '\n'; +} +

Output:

23
+23
+

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/operator[]/index.html b/api/basic_json/operator[]/index.html index d0746eeeb..5708c92fe 100644 --- a/api/basic_json/operator[]/index.html +++ b/api/basic_json/operator[]/index.html @@ -1,286 +1,286 @@ - operator[] - JSON for Modern C++
Skip to content

nlohmann::basic_json::operator[]

// (1)
-reference operator[](size_type idx);
-const_reference operator[](size_type idx) const;
+ operator[] - JSON for Modern C++       

nlohmann::basic_json::operator[]

// (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;
+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;
+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 typename object_t::key_type and 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 that is comparable with string_t using object_comparator_t. 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 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 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 if an array index in the passed JSON pointer ptr begins with '0'.
    • Throws parse_error.109 if an array index in the passed JSON pointer ptr is not a number.
    • Throws out_of_range.402 if the array index '-' is used in the passed JSON pointer ptr for the const version.
    • Throws out_of_range.404 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

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!
  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 null values to make idx a valid reference to the last stored element. In case the value was 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 null value to make key a valid reference. In case the value was 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 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 null value before a reference to it is returned. All indices between the current maximum and the given index are also filled with null.
    • The special value - is treated as a synonym for the index past the end.

Examples

Example: (1) access specified array element

The example below shows how array elements can be read and written using [] operator. Note the addition of null values.

#include <iostream>
-#include <nlohmann/json.hpp>
+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 typename object_t::key_type and 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 that is comparable with string_t using object_comparator_t. 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 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 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 if an array index in the passed JSON pointer ptr begins with '0'.
    • Throws parse_error.109 if an array index in the passed JSON pointer ptr is not a number.
    • Throws out_of_range.402 if the array index '-' is used in the passed JSON pointer ptr for the const version.
    • Throws out_of_range.404 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

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!
  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 null values to make idx a valid reference to the last stored element. In case the value was 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 null value to make key a valid reference. In case the value was 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 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 null value before a reference to it is returned. All indices between the current maximum and the given index are also filled with null.
    • The special value - is treated as a synonym for the index past the end.

Examples

Example: (1) access specified array element

The example below shows how array elements can be read and written using [] operator. Note the addition of null values.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON array
-    json array = {1, 2, 3, 4, 5};
+    json array = {1, 2, 3, 4, 5};
 
     // output element at index 3 (fourth element)
-    std::cout << array[3] << '\n';
+    std::cout << array[3] << '\n';
 
     // change last element to 6
-    array[array.size() - 1] = 6;
+    array[array.size() - 1] = 6;
 
     // output changed array
-    std::cout << array << '\n';
+    std::cout << array << '\n';
 
     // write beyond array limit
-    array[10] = 11;
+    array[10] = 11;
 
     // output changed array
-    std::cout << array << '\n';
-}
-

Output:

4
-[1,2,3,4,6]
-[1,2,3,4,6,null,null,null,null,null,11]
-
Example: (1) access specified array element (const)

The example below shows how array elements can be read using the [] operator.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << array << '\n';
+}
+

Output:

4
+[1,2,3,4,6]
+[1,2,3,4,6,null,null,null,null,null,11]
+
Example: (1) access specified array element (const)

The example below shows how array elements can be read using the [] operator.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON array
-    const json array = {"first", "2nd", "third", "fourth"};
+    const json array = {"first", "2nd", "third", "fourth"};
 
     // output element at index 2 (third element)
-    std::cout << array.at(2) << '\n';
-}
-

Output:

"third"
-
Example: (2) access specified object element

The example below shows how object elements can be read and written using the [] operator.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+    std::cout << array.at(2) << '\n';
+}
+

Output:

"third"
+
Example: (2) access specified object element

The example below shows how object elements can be read and written using the [] operator.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON object
-    json object =
-    {
-        {"one", 1}, {"two", 2}, {"three", 2.9}
-    };
+    json object =
+    {
+        {"one", 1}, {"two", 2}, {"three", 2.9}
+    };
 
     // output element with key "two"
-    std::cout << object["two"] << "\n\n";
+    std::cout << object["two"] << "\n\n";
 
     // change element with key "three"
-    object["three"] = 3;
+    object["three"] = 3;
 
     // output changed array
-    std::cout << std::setw(4) << object << "\n\n";
+    std::cout << std::setw(4) << object << "\n\n";
 
     // mention nonexisting key
-    object["four"];
+    object["four"];
 
     // write to nonexisting key
-    object["five"]["really"]["nested"] = true;
+    object["five"]["really"]["nested"] = true;
 
     // output changed object
-    std::cout << std::setw(4) << object << '\n';
-}
-

Output:

2
+    std::cout << std::setw(4) << object << '\n';
+}
+

Output:

2
 
-{
-    "one": 1,
-    "three": 3,
-    "two": 2
-}
+{
+    "one": 1,
+    "three": 3,
+    "two": 2
+}
 
-{
-    "five": {
-        "really": {
-            "nested": true
-        }
-    },
-    "four": null,
-    "one": 1,
-    "three": 3,
-    "two": 2
-}
-
Example: (2) access specified object element (const)

The example below shows how object elements can be read using the [] operator.

#include <iostream>
-#include <nlohmann/json.hpp>
+{
+    "five": {
+        "really": {
+            "nested": true
+        }
+    },
+    "four": null,
+    "one": 1,
+    "three": 3,
+    "two": 2
+}
+
Example: (2) access specified object element (const)

The example below shows how object elements can be read using the [] operator.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON object
-    const json object =
-    {
-        {"one", 1}, {"two", 2}, {"three", 2.9}
-    };
+    const json object =
+    {
+        {"one", 1}, {"two", 2}, {"three", 2.9}
+    };
 
     // output element with key "two"
-    std::cout << object["two"] << '\n';
-}
-

Output:

2
-
Example: (3) access specified object element using string_view

The example below shows how object elements can be read using the [] operator.

#include <iostream>
-#include <iomanip>
-#include <string_view>
-#include <nlohmann/json.hpp>
+    std::cout << object["two"] << '\n';
+}
+

Output:

2
+
Example: (3) access specified object element using string_view

The example below shows how object elements can be read using the [] operator.

#include <iostream>
+#include <iomanip>
+#include <string_view>
+#include <nlohmann/json.hpp>
 
-using namespace std::string_view_literals;
-using json = nlohmann::json;
+using namespace std::string_view_literals;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON object
-    json object =
-    {
-        {"one", 1}, {"two", 2}, {"three", 2.9}
-    };
+    json object =
+    {
+        {"one", 1}, {"two", 2}, {"three", 2.9}
+    };
 
     // output element with key "two"
-    std::cout << object["two"sv] << "\n\n";
+    std::cout << object["two"sv] << "\n\n";
 
     // change element with key "three"
-    object["three"sv] = 3;
+    object["three"sv] = 3;
 
     // output changed array
-    std::cout << std::setw(4) << object << "\n\n";
+    std::cout << std::setw(4) << object << "\n\n";
 
     // mention nonexisting key
-    object["four"sv];
+    object["four"sv];
 
     // write to nonexisting key
-    object["five"sv]["really"sv]["nested"sv] = true;
+    object["five"sv]["really"sv]["nested"sv] = true;
 
     // output changed object
-    std::cout << std::setw(4) << object << '\n';
-}
-

Output:

2
+    std::cout << std::setw(4) << object << '\n';
+}
+

Output:

2
 
-{
-    "one": 1,
-    "three": 3,
-    "two": 2
-}
+{
+    "one": 1,
+    "three": 3,
+    "two": 2
+}
 
-{
-    "five": {
-        "really": {
-            "nested": true
-        }
-    },
-    "four": null,
-    "one": 1,
-    "three": 3,
-    "two": 2
-}
-
Example: (3) access specified object element using string_view (const)

The example below shows how object elements can be read using the [] operator.

#include <iostream>
-#include <string_view>
-#include <nlohmann/json.hpp>
+{
+    "five": {
+        "really": {
+            "nested": true
+        }
+    },
+    "four": null,
+    "one": 1,
+    "three": 3,
+    "two": 2
+}
+
Example: (3) access specified object element using string_view (const)

The example below shows how object elements can be read using the [] operator.

#include <iostream>
+#include <string_view>
+#include <nlohmann/json.hpp>
 
-using namespace std::string_view_literals;
-using json = nlohmann::json;
+using namespace std::string_view_literals;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON object
-    const json object =
-    {
-        {"one", 1}, {"two", 2}, {"three", 2.9}
-    };
+    const json object =
+    {
+        {"one", 1}, {"two", 2}, {"three", 2.9}
+    };
 
     // output element with key "two"
-    std::cout << object["two"sv] << '\n';
-}
-

Output:

2
-
Example: (4) access specified element via JSON Pointer

The example below shows how values can be read and written using JSON Pointers.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << object["two"sv] << '\n';
+}
+

Output:

2
+
Example: (4) access specified element via JSON Pointer

The example below shows how values can be read and written using JSON Pointers.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
+int main()
+{
     // create a JSON value
-    json j =
-    {
-        {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
-    };
+    json j =
+    {
+        {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
+    };
 
     // read-only access
 
     // output element with JSON pointer "/number"
-    std::cout << j["/number"_json_pointer] << '\n';
+    std::cout << j["/number"_json_pointer] << '\n';
     // output element with JSON pointer "/string"
-    std::cout << j["/string"_json_pointer] << '\n';
+    std::cout << j["/string"_json_pointer] << '\n';
     // output element with JSON pointer "/array"
-    std::cout << j["/array"_json_pointer] << '\n';
+    std::cout << j["/array"_json_pointer] << '\n';
     // output element with JSON pointer "/array/1"
-    std::cout << j["/array/1"_json_pointer] << '\n';
+    std::cout << j["/array/1"_json_pointer] << '\n';
 
     // writing access
 
     // change the string
-    j["/string"_json_pointer] = "bar";
+    j["/string"_json_pointer] = "bar";
     // output the changed string
-    std::cout << j["string"] << '\n';
+    std::cout << j["string"] << '\n';
 
     // "change" a nonexisting object entry
-    j["/boolean"_json_pointer] = true;
+    j["/boolean"_json_pointer] = true;
     // output the changed object
-    std::cout << j << '\n';
+    std::cout << j << '\n';
 
     // change an array element
-    j["/array/1"_json_pointer] = 21;
+    j["/array/1"_json_pointer] = 21;
     // "change" an array element with nonexisting index
-    j["/array/4"_json_pointer] = 44;
+    j["/array/4"_json_pointer] = 44;
     // output the changed array
-    std::cout << j["array"] << '\n';
+    std::cout << j["array"] << '\n';
 
     // "change" the array element past the end
-    j["/array/-"_json_pointer] = 55;
+    j["/array/-"_json_pointer] = 55;
     // output the changed array
-    std::cout << j["array"] << '\n';
-}
-

Output:

1
-"foo"
-[1,2]
-2
-"bar"
-{"array":[1,2],"boolean":true,"number":1,"string":"bar"}
-[1,21,null,null,44]
-[1,21,null,null,44,55]
-
Example: (4) access specified element via JSON Pointer (const)

The example below shows how values can be read using JSON Pointers.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << j["array"] << '\n';
+}
+

Output:

1
+"foo"
+[1,2]
+2
+"bar"
+{"array":[1,2],"boolean":true,"number":1,"string":"bar"}
+[1,21,null,null,44]
+[1,21,null,null,44,55]
+
Example: (4) access specified element via JSON Pointer (const)

The example below shows how values can be read using JSON Pointers.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
+int main()
+{
     // create a JSON value
-    const json j =
-    {
-        {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
-    };
+    const json j =
+    {
+        {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
+    };
 
     // read-only access
 
     // output element with JSON pointer "/number"
-    std::cout << j["/number"_json_pointer] << '\n';
+    std::cout << j["/number"_json_pointer] << '\n';
     // output element with JSON pointer "/string"
-    std::cout << j["/string"_json_pointer] << '\n';
+    std::cout << j["/string"_json_pointer] << '\n';
     // output element with JSON pointer "/array"
-    std::cout << j["/array"_json_pointer] << '\n';
+    std::cout << j["/array"_json_pointer] << '\n';
     // output element with JSON pointer "/array/1"
-    std::cout << j["/array/1"_json_pointer] << '\n';
-}
-

Output:

1
-"foo"
-[1,2]
-2
-

See also

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.

Last update: August 5, 2022
\ No newline at end of file + std::cout << j["/array/1"_json_pointer] << '\n'; +} +

Output:

1
+"foo"
+[1,2]
+2
+

See also

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.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/basic_json/operator_ValueType/index.html b/api/basic_json/operator_ValueType/index.html index c88e67d90..758932d59 100644 --- a/api/basic_json/operator_ValueType/index.html +++ b/api/basic_json/operator_ValueType/index.html @@ -1,79 +1,79 @@ - operator ValueType - JSON for Modern C++
Skip to content

nlohmann::basic_json::operator ValueType

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(). See 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

Definition of JSON_EXPLICIT

By default JSON_EXPLICIT is defined to the empty string, so the signature is:

template<typename ValueType>
-operator ValueType() const;
-

If JSON_USE_IMPLICIT_CONVERSIONS is set to 0, JSON_EXPLICIT is defined to explicit:

template<typename ValueType>
-explicit operator ValueType() const;
-

That is, implicit conversions can be switched off by defining JSON_USE_IMPLICIT_CONVERSIONS to 0.

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 explicit by default.

You can prepare existing code by already defining JSON_USE_IMPLICIT_CONVERSIONS to 0 and replace any implicit conversions with calls to get.

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>.

#include <iostream>
-#include <unordered_map>
-#include <nlohmann/json.hpp>
+ operator ValueType - JSON for Modern C++       

nlohmann::basic_json::operator ValueType

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(). See 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

Definition of JSON_EXPLICIT

By default JSON_EXPLICIT is defined to the empty string, so the signature is:

template<typename ValueType>
+operator ValueType() const;
+

If JSON_USE_IMPLICIT_CONVERSIONS is set to 0, JSON_EXPLICIT is defined to explicit:

template<typename ValueType>
+explicit operator ValueType() const;
+

That is, implicit conversions can be switched off by defining JSON_USE_IMPLICIT_CONVERSIONS to 0.

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 explicit by default.

You can prepare existing code by already defining JSON_USE_IMPLICIT_CONVERSIONS to 0 and replace any implicit conversions with calls to get.

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>.

#include <iostream>
+#include <unordered_map>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON value with different types
-    json json_types =
-    {
-        {"boolean", true},
-        {
-            "number", {
-                {"integer", 42},
-                {"floating-point", 17.23}
-            }
-        },
-        {"string", "Hello, world!"},
-        {"array", {1, 2, 3, 4, 5}},
-        {"null", nullptr}
-    };
+    json json_types =
+    {
+        {"boolean", true},
+        {
+            "number", {
+                {"integer", 42},
+                {"floating-point", 17.23}
+            }
+        },
+        {"string", "Hello, world!"},
+        {"array", {1, 2, 3, 4, 5}},
+        {"null", nullptr}
+    };
 
     // use implicit conversions
-    bool v1 = json_types["boolean"];
-    int v2 = json_types["number"]["integer"];
-    short v3 = json_types["number"]["integer"];
-    float v4 = json_types["number"]["floating-point"];
-    int v5 = json_types["number"]["floating-point"];
-    std::string v6 = json_types["string"];
-    std::vector<short> v7 = json_types["array"];
-    std::unordered_map<std::string, json> v8 = json_types;
+    bool v1 = json_types["boolean"];
+    int v2 = json_types["number"]["integer"];
+    short v3 = json_types["number"]["integer"];
+    float v4 = json_types["number"]["floating-point"];
+    int v5 = json_types["number"]["floating-point"];
+    std::string v6 = json_types["string"];
+    std::vector<short> v7 = json_types["array"];
+    std::unordered_map<std::string, json> v8 = json_types;
 
     // print the conversion results
-    std::cout << v1 << '\n';
-    std::cout << v2 << ' ' << v3 << '\n';
-    std::cout << v4 << ' ' << v5 << '\n';
-    std::cout << v6 << '\n';
+    std::cout << v1 << '\n';
+    std::cout << v2 << ' ' << v3 << '\n';
+    std::cout << v4 << ' ' << v5 << '\n';
+    std::cout << v6 << '\n';
 
-    for (auto i : v7)
-    {
-        std::cout << i << ' ';
-    }
-    std::cout << "\n\n";
+    for (auto i : v7)
+    {
+        std::cout << i << ' ';
+    }
+    std::cout << "\n\n";
 
-    for (auto i : v8)
-    {
-        std::cout << i.first << ": " << i.second << '\n';
-    }
+    for (auto i : v8)
+    {
+        std::cout << i.first << ": " << i.second << '\n';
+    }
 
     // example for an exception
-    try
-    {
-        bool v1 = json_types["string"];
-    }
-    catch (const json::type_error& e)
-    {
-        std::cout << e.what() << '\n';
-    }
-}
-

Output:

1
-42 42
-17.23 17
-Hello, world!
+    try
+    {
+        bool v1 = json_types["string"];
+    }
+    catch (const json::type_error& e)
+    {
+        std::cout << e.what() << '\n';
+    }
+}
+

Output:

1
+42 42
+17.23 17
+Hello, world!
 1 2 3 4 5 
 
-string: "Hello, world!"
-number: {"floating-point":17.23,"integer":42}
-null: null
-boolean: true
-array: [1,2,3,4,5]
-[json.exception.type_error.302] type must be boolean, but is string
-

Version history


Last update: July 31, 2022
\ No newline at end of file +string: "Hello, world!" +number: {"floating-point":17.23,"integer":42} +null: null +boolean: true +array: [1,2,3,4,5] +[json.exception.type_error.302] type must be boolean, but is string +

Version history


Last update: July 31, 2022
\ No newline at end of file diff --git a/api/basic_json/operator_eq/index.html b/api/basic_json/operator_eq/index.html index 0d4a6396c..10c73a41b 100644 --- a/api/basic_json/operator_eq/index.html +++ b/api/basic_json/operator_eq/index.html @@ -1,118 +1,118 @@ - operator== - JSON for Modern C++
Skip to content

nlohmann::basic_json::operator==

// until C++20
+ operator== - JSON for Modern C++       

nlohmann::basic_json::operator==

// until C++20
 bool operator==(const_reference lhs, const_reference rhs) noexcept;   // (1)
 
-template<typename ScalarType>
+template<typename ScalarType>
 bool operator==(const_reference lhs, const ScalarType rhs) noexcept;  // (2)
 
-template<typename ScalarType>
+template<typename ScalarType>
 bool operator==(ScalarType lhs, const const_reference rhs) noexcept;  // (2)
 
 // since C++20
-class basic_json {
+class basic_json {
     bool operator==(const_reference rhs) const noexcept;              // (1)
 
-    template<typename ScalarType>
+    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

Comparing special values

  • NaN values are unordered within the domain of numbers. The following comparisons all yield false:
    1. Comparing a NaN with itself.
    2. Comparing a NaN with another NaN.
    3. Comparing a NaN and any other number.
  • JSON null values are all equal.
  • Discarded values never compare equal to themselves.

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 could be used, for instance

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:

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)
+};
+
  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

Comparing special values

  • NaN values are unordered within the domain of numbers. The following comparisons all yield false:
    1. Comparing a NaN with itself.
    2. Comparing a NaN with another NaN.
    3. Comparing a NaN and any other number.
  • JSON null values are all equal.
  • Discarded values never compare equal to themselves.

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 could be used, for instance

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:

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();
+            case value_t::number_float:
+                return std::abs(lhs - rhs) <= std::numeric_limits<float>::epsilon();
             // other cases remain the same with the original
-            ...
-    }
-...
-}
-

Comparing different basic_json specializations

Comparing different basic_json specializations can have surprising effects. For instance, the result of comparing the JSON objects

{
-   "version": 1,
-   "type": "integer"
-}
-

and

{
-   "type": "integer",
-   "version": 1
-}
-

depends on whether nlohmann::json or nlohmann::ordered_json is used:

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+            ...
+    }
+...
+}
+

Comparing different basic_json specializations

Comparing different basic_json specializations can have surprising effects. For instance, the result of comparing the JSON objects

{
+   "version": 1,
+   "type": "integer"
+}
+

and

{
+   "type": "integer",
+   "version": 1
+}
+

depends on whether nlohmann::json or nlohmann::ordered_json is used:

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    nlohmann::json uj1 = {{"version", 1}, {"type", "integer"}};
-    nlohmann::json uj2 = {{"type", "integer"}, {"version", 1}};
+int main()
+{
+    nlohmann::json uj1 = {{"version", 1}, {"type", "integer"}};
+    nlohmann::json uj2 = {{"type", "integer"}, {"version", 1}};
 
-    nlohmann::ordered_json oj1 = {{"version", 1}, {"type", "integer"}};
-    nlohmann::ordered_json oj2 = {{"type", "integer"}, {"version", 1}};
+    nlohmann::ordered_json oj1 = {{"version", 1}, {"type", "integer"}};
+    nlohmann::ordered_json oj2 = {{"type", "integer"}, {"version", 1}};
 
-    std::cout << std::boolalpha << (uj1 == uj2) << '\n' << (oj1 == oj2) << std::endl;
-}
-

Output:

true
-false
-

Examples

Example

The example demonstrates comparing several JSON types.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << std::boolalpha << (uj1 == uj2) << '\n' << (oj1 == oj2) << std::endl;
+}
+

Output:

true
+false
+

Examples

Example

The example demonstrates comparing several JSON types.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create several JSON values
-    json array_1 = {1, 2, 3};
-    json array_2 = {1, 2, 4};
-    json object_1 = {{"A", "a"}, {"B", "b"}};
-    json object_2 = {{"B", "b"}, {"A", "a"}};
-    json number_1 = 17;
-    json number_2 = 17.000000000000001L;
-    json string_1 = "foo";
-    json string_2 = "bar";
+    json array_1 = {1, 2, 3};
+    json array_2 = {1, 2, 4};
+    json object_1 = {{"A", "a"}, {"B", "b"}};
+    json object_2 = {{"B", "b"}, {"A", "a"}};
+    json number_1 = 17;
+    json number_2 = 17.000000000000001L;
+    json string_1 = "foo";
+    json string_2 = "bar";
 
     // output values and comparisons
-    std::cout << std::boolalpha;
-    std::cout << array_1 << " == " << array_2 << " " << (array_1 == array_2) << '\n';
-    std::cout << object_1 << " == " << object_2 << " " << (object_1 == object_2) << '\n';
-    std::cout << number_1 << " == " << number_2 << " " << (number_1 == number_2) << '\n';
-    std::cout << string_1 << " == " << string_2 << " " << (string_1 == string_2) << '\n';
-}
-

Output:

[1,2,3] == [1,2,4] false
-{"A":"a","B":"b"} == {"A":"a","B":"b"} true
-17 == 17.0 true
-"foo" == "bar" false
-
Example

The example demonstrates comparing several JSON types against the null pointer (JSON null).

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << std::boolalpha;
+    std::cout << array_1 << " == " << array_2 << " " << (array_1 == array_2) << '\n';
+    std::cout << object_1 << " == " << object_2 << " " << (object_1 == object_2) << '\n';
+    std::cout << number_1 << " == " << number_2 << " " << (number_1 == number_2) << '\n';
+    std::cout << string_1 << " == " << string_2 << " " << (string_1 == string_2) << '\n';
+}
+

Output:

[1,2,3] == [1,2,4] false
+{"A":"a","B":"b"} == {"A":"a","B":"b"} true
+17 == 17.0 true
+"foo" == "bar" false
+
Example

The example demonstrates comparing several JSON types against the null pointer (JSON null).

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create several JSON values
-    json array = {1, 2, 3};
-    json object = {{"A", "a"}, {"B", "b"}};
-    json number = 17;
-    json string = "foo";
-    json null;
+    json array = {1, 2, 3};
+    json object = {{"A", "a"}, {"B", "b"}};
+    json number = 17;
+    json string = "foo";
+    json null;
 
     // output values and comparisons
-    std::cout << std::boolalpha;
-    std::cout << array << " == nullptr " << (array == nullptr) << '\n';
-    std::cout << object << " == nullptr " << (object == nullptr) << '\n';
-    std::cout << number << " == nullptr " << (number == nullptr) << '\n';
-    std::cout << string << " == nullptr " << (string == nullptr) << '\n';
-    std::cout << null << " == nullptr " << (null == nullptr) << '\n';
-}
-

Output:

[1,2,3] == nullptr false
-{"A":"a","B":"b"} == nullptr false
-17 == nullptr false
-"foo" == nullptr false
-null == nullptr true
-

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.

Last update: August 5, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << array << " == nullptr " << (array == nullptr) << '\n'; + std::cout << object << " == nullptr " << (object == nullptr) << '\n'; + std::cout << number << " == nullptr " << (number == nullptr) << '\n'; + std::cout << string << " == nullptr " << (string == nullptr) << '\n'; + std::cout << null << " == nullptr " << (null == nullptr) << '\n'; +} +

Output:

[1,2,3] == nullptr false
+{"A":"a","B":"b"} == nullptr false
+17 == nullptr false
+"foo" == nullptr false
+null == nullptr true
+

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.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/basic_json/operator_ge/index.html b/api/basic_json/operator_ge/index.html index f449deb36..4631012cb 100644 --- a/api/basic_json/operator_ge/index.html +++ b/api/basic_json/operator_ge/index.html @@ -1,37 +1,37 @@ - operator>= - JSON for Modern C++
Skip to content

nlohmann::basic_json::operator>=

// until C++20
+ operator>= - JSON for Modern C++       

nlohmann::basic_json::operator>=

// until C++20
 bool operator>=(const_reference lhs, const_reference rhs) noexcept;   // (1)
 
-template<typename ScalarType>
+template<typename ScalarType>
 bool operator>=(const_reference lhs, const ScalarType rhs) noexcept;  // (2)
 
-template<typename ScalarType>
+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 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 !(lhs < rhs) (see operator<).
  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

Comparing NaN

NaN values are unordered within the domain of numbers. The following comparisons all yield false: 1. Comparing a NaN with itself. 2. Comparing a NaN with another NaN. 3. Comparing a NaN and any other number.

Operator overload resolution

Since C++20 overload resolution will consider the rewritten candidate generated from operator<=>.

Examples

Example

The example demonstrates comparing several JSON types.

#include <iostream>
-#include <nlohmann/json.hpp>
+
  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 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 !(lhs < rhs) (see operator<).
  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

Comparing NaN

NaN values are unordered within the domain of numbers. The following comparisons all yield false: 1. Comparing a NaN with itself. 2. Comparing a NaN with another NaN. 3. Comparing a NaN and any other number.

Operator overload resolution

Since C++20 overload resolution will consider the rewritten candidate generated from operator<=>.

Examples

Example

The example demonstrates comparing several JSON types.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create several JSON values
-    json array_1 = {1, 2, 3};
-    json array_2 = {1, 2, 4};
-    json object_1 = {{"A", "a"}, {"B", "b"}};
-    json object_2 = {{"B", "b"}, {"A", "a"}};
-    json number_1 = 17;
-    json number_2 = 17.0000000000001L;
-    json string_1 = "foo";
-    json string_2 = "bar";
+    json array_1 = {1, 2, 3};
+    json array_2 = {1, 2, 4};
+    json object_1 = {{"A", "a"}, {"B", "b"}};
+    json object_2 = {{"B", "b"}, {"A", "a"}};
+    json number_1 = 17;
+    json number_2 = 17.0000000000001L;
+    json string_1 = "foo";
+    json string_2 = "bar";
 
     // output values and comparisons
-    std::cout << std::boolalpha;
-    std::cout << array_1 << " >= " << array_2 << " " << (array_1 >= array_2) << '\n';
-    std::cout << object_1 << " >= " << object_2 << " " << (object_1 >= object_2) << '\n';
-    std::cout << number_1 << " >= " << number_2 << " " << (number_1 >= number_2) << '\n';
-    std::cout << string_1 << " >= " << string_2 << " " << (string_1 >= string_2) << '\n';
-}
-

Output:

[1,2,3] >= [1,2,4] false
-{"A":"a","B":"b"} >= {"A":"a","B":"b"} true
-17 >= 17.0000000000001 false
-"foo" >= "bar" true
-

See also

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.

Last update: August 5, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << array_1 << " >= " << array_2 << " " << (array_1 >= array_2) << '\n'; + std::cout << object_1 << " >= " << object_2 << " " << (object_1 >= object_2) << '\n'; + std::cout << number_1 << " >= " << number_2 << " " << (number_1 >= number_2) << '\n'; + std::cout << string_1 << " >= " << string_2 << " " << (string_1 >= string_2) << '\n'; +} +

Output:

[1,2,3] >= [1,2,4] false
+{"A":"a","B":"b"} >= {"A":"a","B":"b"} true
+17 >= 17.0000000000001 false
+"foo" >= "bar" true
+

See also

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.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/basic_json/operator_gt/index.html b/api/basic_json/operator_gt/index.html index 09976ea5e..ab38a93f4 100644 --- a/api/basic_json/operator_gt/index.html +++ b/api/basic_json/operator_gt/index.html @@ -1,37 +1,37 @@ - operator> - JSON for Modern C++
Skip to content

nlohmann::basic_json::operator>

// until C++20
+ operator> - JSON for Modern C++       

nlohmann::basic_json::operator>

// until C++20
 bool operator>(const_reference lhs, const_reference rhs) noexcept;   // (1)
 
-template<typename ScalarType>
+template<typename ScalarType>
 bool operator>(const_reference lhs, const ScalarType rhs) noexcept;  // (2)
 
-template<typename ScalarType>
+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 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 !(lhs <= rhs) (see operator<=).
  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

Comparing NaN

NaN values are unordered within the domain of numbers. The following comparisons all yield false: 1. Comparing a NaN with itself. 2. Comparing a NaN with another NaN. 3. Comparing a NaN and any other number.

Operator overload resolution

Since C++20 overload resolution will consider the rewritten candidate generated from operator<=>.

Examples

Example

The example demonstrates comparing several JSON types.

#include <iostream>
-#include <nlohmann/json.hpp>
+
  1. Compares whether one JSON value lhs is greater than another JSON value rhs according to the following rules:

    • The comparison always yields 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 !(lhs <= rhs) (see operator<=).
  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

Comparing NaN

NaN values are unordered within the domain of numbers. The following comparisons all yield false: 1. Comparing a NaN with itself. 2. Comparing a NaN with another NaN. 3. Comparing a NaN and any other number.

Operator overload resolution

Since C++20 overload resolution will consider the rewritten candidate generated from operator<=>.

Examples

Example

The example demonstrates comparing several JSON types.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create several JSON values
-    json array_1 = {1, 2, 3};
-    json array_2 = {1, 2, 4};
-    json object_1 = {{"A", "a"}, {"B", "b"}};
-    json object_2 = {{"B", "b"}, {"A", "a"}};
-    json number_1 = 17;
-    json number_2 = 17.0000000000001L;
-    json string_1 = "foo";
-    json string_2 = "bar";
+    json array_1 = {1, 2, 3};
+    json array_2 = {1, 2, 4};
+    json object_1 = {{"A", "a"}, {"B", "b"}};
+    json object_2 = {{"B", "b"}, {"A", "a"}};
+    json number_1 = 17;
+    json number_2 = 17.0000000000001L;
+    json string_1 = "foo";
+    json string_2 = "bar";
 
     // output values and comparisons
-    std::cout << std::boolalpha;
-    std::cout << array_1 << " > " << array_2 << " " << (array_1 > array_2) << '\n';
-    std::cout << object_1 << " > " << object_2 << " " << (object_1 > object_2) << '\n';
-    std::cout << number_1 << " > " << number_2 << " " << (number_1 > number_2) << '\n';
-    std::cout << string_1 << " > " << string_2 << " " << (string_1 > string_2) << '\n';
-}
-

Output:

[1,2,3] > [1,2,4] false
-{"A":"a","B":"b"} > {"A":"a","B":"b"} false
-17 > 17.0000000000001 false
-"foo" > "bar" true
-

See also

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.

Last update: July 31, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << array_1 << " > " << array_2 << " " << (array_1 > array_2) << '\n'; + std::cout << object_1 << " > " << object_2 << " " << (object_1 > object_2) << '\n'; + std::cout << number_1 << " > " << number_2 << " " << (number_1 > number_2) << '\n'; + std::cout << string_1 << " > " << string_2 << " " << (string_1 > string_2) << '\n'; +} +

Output:

[1,2,3] > [1,2,4] false
+{"A":"a","B":"b"} > {"A":"a","B":"b"} false
+17 > 17.0000000000001 false
+"foo" > "bar" true
+

See also

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.

Last update: July 31, 2022
\ No newline at end of file diff --git a/api/basic_json/operator_le/index.html b/api/basic_json/operator_le/index.html index 7baaf6f29..a7788914b 100644 --- a/api/basic_json/operator_le/index.html +++ b/api/basic_json/operator_le/index.html @@ -1,37 +1,37 @@ - operator<= - JSON for Modern C++
Skip to content

nlohmann::basic_json::operator<=

// until C++20
+ operator<= - JSON for Modern C++       

nlohmann::basic_json::operator<=

// until C++20
 bool operator<=(const_reference lhs, const_reference rhs) noexcept;   // (1)
 
-template<typename ScalarType>
+template<typename ScalarType>
 bool operator<=(const_reference lhs, const ScalarType rhs) noexcept;  // (2)
 
-template<typename ScalarType>
+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 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 !(rhs < lhs) (see operator<).
  2. 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

Comparing NaN

NaN values are unordered within the domain of numbers. The following comparisons all yield false: 1. Comparing a NaN with itself. 2. Comparing a NaN with another NaN. 3. Comparing a NaN and any other number.

Operator overload resolution

Since C++20 overload resolution will consider the rewritten candidate generated from operator<=>.

Examples

Example

The example demonstrates comparing several JSON types.

#include <iostream>
-#include <nlohmann/json.hpp>
+
  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 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 !(rhs < lhs) (see operator<).
  2. 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

Comparing NaN

NaN values are unordered within the domain of numbers. The following comparisons all yield false: 1. Comparing a NaN with itself. 2. Comparing a NaN with another NaN. 3. Comparing a NaN and any other number.

Operator overload resolution

Since C++20 overload resolution will consider the rewritten candidate generated from operator<=>.

Examples

Example

The example demonstrates comparing several JSON types.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create several JSON values
-    json array_1 = {1, 2, 3};
-    json array_2 = {1, 2, 4};
-    json object_1 = {{"A", "a"}, {"B", "b"}};
-    json object_2 = {{"B", "b"}, {"A", "a"}};
-    json number_1 = 17;
-    json number_2 = 17.0000000000001L;
-    json string_1 = "foo";
-    json string_2 = "bar";
+    json array_1 = {1, 2, 3};
+    json array_2 = {1, 2, 4};
+    json object_1 = {{"A", "a"}, {"B", "b"}};
+    json object_2 = {{"B", "b"}, {"A", "a"}};
+    json number_1 = 17;
+    json number_2 = 17.0000000000001L;
+    json string_1 = "foo";
+    json string_2 = "bar";
 
     // output values and comparisons
-    std::cout << std::boolalpha;
-    std::cout << array_1 << " <= " << array_2 << " " << (array_1 <= array_2) << '\n';
-    std::cout << object_1 << " <= " << object_2 << " " << (object_1 <= object_2) << '\n';
-    std::cout << number_1 << " <= " << number_2 << " " << (number_1 <= number_2) << '\n';
-    std::cout << string_1 << " <= " << string_2 << " " << (string_1 <= string_2) << '\n';
-}
-

Output:

[1,2,3] <= [1,2,4] true
-{"A":"a","B":"b"} <= {"A":"a","B":"b"} true
-17 <= 17.0000000000001 true
-"foo" <= "bar" false
-

See also

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.

Last update: July 31, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << array_1 << " <= " << array_2 << " " << (array_1 <= array_2) << '\n'; + std::cout << object_1 << " <= " << object_2 << " " << (object_1 <= object_2) << '\n'; + std::cout << number_1 << " <= " << number_2 << " " << (number_1 <= number_2) << '\n'; + std::cout << string_1 << " <= " << string_2 << " " << (string_1 <= string_2) << '\n'; +} +

Output:

[1,2,3] <= [1,2,4] true
+{"A":"a","B":"b"} <= {"A":"a","B":"b"} true
+17 <= 17.0000000000001 true
+"foo" <= "bar" false
+

See also

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.

Last update: July 31, 2022
\ No newline at end of file diff --git a/api/basic_json/operator_lt/index.html b/api/basic_json/operator_lt/index.html index f7102cb7f..8f39a18f6 100644 --- a/api/basic_json/operator_lt/index.html +++ b/api/basic_json/operator_lt/index.html @@ -1,37 +1,37 @@ - operator< - JSON for Modern C++
Skip to content

nlohmann::basic_json::operator<

// until C++20
+ operator< - JSON for Modern C++       

nlohmann::basic_json::operator<

// until C++20
 bool operator<(const_reference lhs, const_reference rhs) noexcept;   // (1)
 
-template<typename ScalarType>
+template<typename ScalarType>
 bool operator<(const_reference lhs, const ScalarType rhs) noexcept;  // (2)
 
-template<typename ScalarType>
+template<typename ScalarType>
 bool operator<(ScalarType lhs, const const_reference rhs) noexcept;  // (2)
-
  1. Compares whether one JSON value lhs is less than another JSON value rhs according to the following rules:

    • If either operand is discarded, the comparison yields false.
    • If both operands have the same type, the values are compared using their respective operator<.
    • Integer and floating-point numbers are automatically converted before comparison.
    • In case lhs and rhs have different types, the values are ignored and the order of the types is considered, which is:
      1. null
      2. boolean
      3. number (all types)
      4. object
      5. array
      6. string
      7. binary For instance, any boolean value is considered less than any string.
  2. Compares wether a JSON value is less than a scalar or a scalar is less 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 less than rhs

Exception safety

No-throw guarantee: this function never throws exceptions.

Complexity

Linear.

Notes

Comparing NaN

NaN values are unordered within the domain of numbers. The following comparisons all yield false: 1. Comparing a NaN with itself. 2. Comparing a NaN with another NaN. 3. Comparing a NaN and any other number.

Operator overload resolution

Since C++20 overload resolution will consider the rewritten candidate generated from operator<=>.

Examples

Example

The example demonstrates comparing several JSON types.

#include <iostream>
-#include <nlohmann/json.hpp>
+
  1. Compares whether one JSON value lhs is less than another JSON value rhs according to the following rules:

    • If either operand is discarded, the comparison yields false.
    • If both operands have the same type, the values are compared using their respective operator<.
    • Integer and floating-point numbers are automatically converted before comparison.
    • In case lhs and rhs have different types, the values are ignored and the order of the types is considered, which is:
      1. null
      2. boolean
      3. number (all types)
      4. object
      5. array
      6. string
      7. binary For instance, any boolean value is considered less than any string.
  2. Compares wether a JSON value is less than a scalar or a scalar is less 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 less than rhs

Exception safety

No-throw guarantee: this function never throws exceptions.

Complexity

Linear.

Notes

Comparing NaN

NaN values are unordered within the domain of numbers. The following comparisons all yield false: 1. Comparing a NaN with itself. 2. Comparing a NaN with another NaN. 3. Comparing a NaN and any other number.

Operator overload resolution

Since C++20 overload resolution will consider the rewritten candidate generated from operator<=>.

Examples

Example

The example demonstrates comparing several JSON types.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create several JSON values
-    json array_1 = {1, 2, 3};
-    json array_2 = {1, 2, 4};
-    json object_1 = {{"A", "a"}, {"B", "b"}};
-    json object_2 = {{"B", "b"}, {"A", "a"}};
-    json number_1 = 17;
-    json number_2 = 17.0000000000001L;
-    json string_1 = "foo";
-    json string_2 = "bar";
+    json array_1 = {1, 2, 3};
+    json array_2 = {1, 2, 4};
+    json object_1 = {{"A", "a"}, {"B", "b"}};
+    json object_2 = {{"B", "b"}, {"A", "a"}};
+    json number_1 = 17;
+    json number_2 = 17.0000000000001L;
+    json string_1 = "foo";
+    json string_2 = "bar";
 
     // output values and comparisons
-    std::cout << std::boolalpha;
-    std::cout << array_1 << " == " << array_2 << " " << (array_1 < array_2) << '\n';
-    std::cout << object_1 << " == " << object_2 << " " << (object_1 < object_2) << '\n';
-    std::cout << number_1 << " == " << number_2 << " " << (number_1 < number_2) << '\n';
-    std::cout << string_1 << " == " << string_2 << " " << (string_1 < string_2) << '\n';
-}
-

Output:

[1,2,3] == [1,2,4] true
-{"A":"a","B":"b"} == {"A":"a","B":"b"} false
-17 == 17.0000000000001 true
-"foo" == "bar" false
-

See also

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.

Last update: May 29, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << array_1 << " == " << array_2 << " " << (array_1 < array_2) << '\n'; + std::cout << object_1 << " == " << object_2 << " " << (object_1 < object_2) << '\n'; + std::cout << number_1 << " == " << number_2 << " " << (number_1 < number_2) << '\n'; + std::cout << string_1 << " == " << string_2 << " " << (string_1 < string_2) << '\n'; +} +

Output:

[1,2,3] == [1,2,4] true
+{"A":"a","B":"b"} == {"A":"a","B":"b"} false
+17 == 17.0000000000001 true
+"foo" == "bar" false
+

See also

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.

Last update: May 29, 2022
\ No newline at end of file diff --git a/api/basic_json/operator_ne/index.html b/api/basic_json/operator_ne/index.html index a92047b84..a3615c626 100644 --- a/api/basic_json/operator_ne/index.html +++ b/api/basic_json/operator_ne/index.html @@ -1,72 +1,72 @@ - operator!= - JSON for Modern C++
Skip to content

nlohmann::basic_json::operator!=

// until C++20
+ operator!= - JSON for Modern C++       

nlohmann::basic_json::operator!=

// until C++20
 bool operator!=(const_reference lhs, const_reference rhs) noexcept;   // (1)
 
-template<typename ScalarType>
+template<typename ScalarType>
 bool operator!=(const_reference lhs, const ScalarType rhs) noexcept;  // (2)
 
-template<typename ScalarType>
+template<typename ScalarType>
 bool operator!=(ScalarType lhs, const const_reference rhs) noexcept;  // (2)
 
 // since C++20
-class basic_json {
+class basic_json {
     bool operator!=(const_reference rhs) const noexcept;              // (1)
 
-    template<typename ScalarType>
+    template<typename ScalarType>
     bool operator!=(ScalarType rhs) const noexcept;                   // (2)
-};
-
  1. Compares two JSON values for inequality according to the following rules:

    • The comparison always yields 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 !(lhs == rhs) (until C++20) or !(*this == rhs) (since C++20).
  2. Compares a JSON value and a scalar or a scalar and a JSON value for inequality 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 not equal

Exception safety

No-throw guarantee: this function never throws exceptions.

Complexity

Linear.

Notes

Comparing NaN

NaN values are unordered within the domain of numbers. The following comparisons all yield false: 1. Comparing a NaN with itself. 2. Comparing a NaN with another NaN. 3. Comparing a NaN and any other number.

Examples

Example

The example demonstrates comparing several JSON types.

#include <iostream>
-#include <nlohmann/json.hpp>
+};
+
  1. Compares two JSON values for inequality according to the following rules:

    • The comparison always yields 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 !(lhs == rhs) (until C++20) or !(*this == rhs) (since C++20).
  2. Compares a JSON value and a scalar or a scalar and a JSON value for inequality 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 not equal

Exception safety

No-throw guarantee: this function never throws exceptions.

Complexity

Linear.

Notes

Comparing NaN

NaN values are unordered within the domain of numbers. The following comparisons all yield false: 1. Comparing a NaN with itself. 2. Comparing a NaN with another NaN. 3. Comparing a NaN and any other number.

Examples

Example

The example demonstrates comparing several JSON types.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create several JSON values
-    json array_1 = {1, 2, 3};
-    json array_2 = {1, 2, 4};
-    json object_1 = {{"A", "a"}, {"B", "b"}};
-    json object_2 = {{"B", "b"}, {"A", "a"}};
-    json number_1 = 17;
-    json number_2 = 17.000000000000001L;
-    json string_1 = "foo";
-    json string_2 = "bar";
+    json array_1 = {1, 2, 3};
+    json array_2 = {1, 2, 4};
+    json object_1 = {{"A", "a"}, {"B", "b"}};
+    json object_2 = {{"B", "b"}, {"A", "a"}};
+    json number_1 = 17;
+    json number_2 = 17.000000000000001L;
+    json string_1 = "foo";
+    json string_2 = "bar";
 
     // output values and comparisons
-    std::cout << std::boolalpha;
-    std::cout << array_1 << " != " << array_2 << " " << (array_1 != array_2) << '\n';
-    std::cout << object_1 << " != " << object_2 << " " << (object_1 != object_2) << '\n';
-    std::cout << number_1 << " != " << number_2 << " " << (number_1 != number_2) << '\n';
-    std::cout << string_1 << " != " << string_2 << " " << (string_1 != string_2) << '\n';
-}
-

Output:

[1,2,3] != [1,2,4] true
-{"A":"a","B":"b"} != {"A":"a","B":"b"} false
-17 != 17.0 false
-"foo" != "bar" true
-
Example

The example demonstrates comparing several JSON types against the null pointer (JSON null).

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << std::boolalpha;
+    std::cout << array_1 << " != " << array_2 << " " << (array_1 != array_2) << '\n';
+    std::cout << object_1 << " != " << object_2 << " " << (object_1 != object_2) << '\n';
+    std::cout << number_1 << " != " << number_2 << " " << (number_1 != number_2) << '\n';
+    std::cout << string_1 << " != " << string_2 << " " << (string_1 != string_2) << '\n';
+}
+

Output:

[1,2,3] != [1,2,4] true
+{"A":"a","B":"b"} != {"A":"a","B":"b"} false
+17 != 17.0 false
+"foo" != "bar" true
+
Example

The example demonstrates comparing several JSON types against the null pointer (JSON null).

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create several JSON values
-    json array = {1, 2, 3};
-    json object = {{"A", "a"}, {"B", "b"}};
-    json number = 17;
-    json string = "foo";
-    json null;
+    json array = {1, 2, 3};
+    json object = {{"A", "a"}, {"B", "b"}};
+    json number = 17;
+    json string = "foo";
+    json null;
 
     // output values and comparisons
-    std::cout << std::boolalpha;
-    std::cout << array << " != nullptr " << (array != nullptr) << '\n';
-    std::cout << object << " != nullptr " << (object != nullptr) << '\n';
-    std::cout << number << " != nullptr " << (number != nullptr) << '\n';
-    std::cout << string << " != nullptr " << (string != nullptr) << '\n';
-    std::cout << null << " != nullptr " << (null != nullptr) << '\n';
-}
-

Output:

[1,2,3] != nullptr true
-{"A":"a","B":"b"} != nullptr true
-17 != nullptr true
-"foo" != nullptr true
-null != nullptr false
-

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.

Last update: August 5, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << array << " != nullptr " << (array != nullptr) << '\n'; + std::cout << object << " != nullptr " << (object != nullptr) << '\n'; + std::cout << number << " != nullptr " << (number != nullptr) << '\n'; + std::cout << string << " != nullptr " << (string != nullptr) << '\n'; + std::cout << null << " != nullptr " << (null != nullptr) << '\n'; +} +

Output:

[1,2,3] != nullptr true
+{"A":"a","B":"b"} != nullptr true
+17 != nullptr true
+"foo" != nullptr true
+null != nullptr false
+

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.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/basic_json/operator_spaceship/index.html b/api/basic_json/operator_spaceship/index.html index 9a65337bb..a17e7d964 100644 --- a/api/basic_json/operator_spaceship/index.html +++ b/api/basic_json/operator_spaceship/index.html @@ -1,96 +1,96 @@ - operator - JSON for Modern C++
Skip to content

nlohmann::basic_json::operator<=>

// since C++20
-class basic_json {
+ operator - JSON for Modern C++       

nlohmann::basic_json::operator<=>

// since C++20
+class basic_json {
     std::partial_ordering operator<=>(const_reference rhs) const noexcept;  // (1)
 
-    template<typename ScalarType>
+    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).
  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

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: (1) comparing JSON values

The example demonstrates comparing several JSON values.

#include <compare>
-#include <iostream>
-#include <nlohmann/json.hpp>
+};
+
  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).
  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

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: (1) comparing JSON values

The example demonstrates comparing several JSON values.

#include <compare>
+#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-const char* to_string(const std::partial_ordering& po)
-{
-    if (std::is_lt(po))
-    {
-        return "less";
-    }
-    else if (std::is_gt(po))
-    {
-        return "greater";
-    }
-    else if (std::is_eq(po))
-    {
-        return "equivalent";
-    }
-    return "unordered";
-}
+const char* to_string(const std::partial_ordering& po)
+{
+    if (std::is_lt(po))
+    {
+        return "less";
+    }
+    else if (std::is_gt(po))
+    {
+        return "greater";
+    }
+    else if (std::is_eq(po))
+    {
+        return "equivalent";
+    }
+    return "unordered";
+}
 
-int main()
-{
+int main()
+{
     // create several JSON values
-    json array_1 = {1, 2, 3};
-    json array_2 = {1, 2, 4};
-    json object_1 = {{"A", "a"}, {"B", "b"}};
-    json object_2 = {{"B", "b"}, {"A", "a"}};
-    json number = 17;
-    json string = "foo";
-    json discarded = json(json::value_t::discarded);
+    json array_1 = {1, 2, 3};
+    json array_2 = {1, 2, 4};
+    json object_1 = {{"A", "a"}, {"B", "b"}};
+    json object_2 = {{"B", "b"}, {"A", "a"}};
+    json number = 17;
+    json string = "foo";
+    json discarded = json(json::value_t::discarded);
 
     // output values and comparisons
     std::cout << array_1 << " <=> " << array_2 << " := " << to_string(array_1 <=> array_2) << '\n'; // *NOPAD*
     std::cout << object_1 << " <=> " << object_2 << " := " << to_string(object_1 <=> object_2) << '\n'; // *NOPAD*
     std::cout << string << " <=> " << number << " := " << to_string(string <=> number) << '\n'; // *NOPAD*
     std::cout << string << " <=> " << discarded << " := " << to_string(string <=> discarded) << '\n'; // *NOPAD*
-}
-

Output:

[1,2,3] <=> [1,2,4] := less
-{"A":"a","B":"b"} <=> {"A":"a","B":"b"} := equivalent
-"foo" <=> 17 := greater
-"foo" <=> <discarded> := unordered
-
Example: (2) comparing JSON values and scalars

The example demonstrates comparing several JSON values and scalars.

#include <compare>
-#include <iostream>
-#include <nlohmann/json.hpp>
+}
+

Output:

[1,2,3] <=> [1,2,4] := less
+{"A":"a","B":"b"} <=> {"A":"a","B":"b"} := equivalent
+"foo" <=> 17 := greater
+"foo" <=> <discarded> := unordered
+
Example: (2) comparing JSON values and scalars

The example demonstrates comparing several JSON values and scalars.

#include <compare>
+#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-const char* to_string(const std::partial_ordering& po)
-{
-    if (std::is_lt(po))
-    {
-        return "less";
-    }
-    else if (std::is_gt(po))
-    {
-        return "greater";
-    }
-    else if (std::is_eq(po))
-    {
-        return "equivalent";
-    }
-    return "unordered";
-}
+const char* to_string(const std::partial_ordering& po)
+{
+    if (std::is_lt(po))
+    {
+        return "less";
+    }
+    else if (std::is_gt(po))
+    {
+        return "greater";
+    }
+    else if (std::is_eq(po))
+    {
+        return "equivalent";
+    }
+    return "unordered";
+}
 
-int main()
-{
-    using float_limits = std::numeric_limits<json::number_float_t>;
-    constexpr auto nan = float_limits::quiet_NaN();
+int main()
+{
+    using float_limits = std::numeric_limits<json::number_float_t>;
+    constexpr auto nan = float_limits::quiet_NaN();
 
     // create several JSON values
-    json boolean = false;
-    json number = 17;
-    json string = "17";
+    json boolean = false;
+    json number = 17;
+    json string = "17";
 
     // output values and comparisons
-    std::cout << std::boolalpha << std::fixed;
+    std::cout << std::boolalpha << std::fixed;
     std::cout << boolean << " <=> " << true << " := " << to_string(boolean <=> true) << '\n'; // *NOPAD*
     std::cout << number << " <=> " << 17.0 << " := " << to_string(number <=> 17.0) << '\n'; // *NOPAD*
     std::cout << number << " <=> " << nan << " := " << to_string(number <=> nan) << '\n'; // *NOPAD*
     std::cout << string << " <=> " << 17 << " := " << to_string(string <=> 17) << '\n'; // *NOPAD*
-}
-

Output:

false <=> true := less
-17 <=> 17.000000 := equivalent
-17 <=> nan := unordered
-"17" <=> 17 := greater
-

See also

Version history

  1. Added in version 3.11.0.
  2. Added in version 3.11.0.

Last update: August 5, 2022
\ No newline at end of file +} +

Output:

false <=> true := less
+17 <=> 17.000000 := equivalent
+17 <=> nan := unordered
+"17" <=> 17 := greater
+

See also

Version history

  1. Added in version 3.11.0.
  2. Added in version 3.11.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/basic_json/operator_value_t/index.html b/api/basic_json/operator_value_t/index.html index 1cb9d7edc..ed89291e9 100644 --- a/api/basic_json/operator_value_t/index.html +++ b/api/basic_json/operator_value_t/index.html @@ -1,48 +1,48 @@ - operator value_t - JSON for Modern C++
Skip to content

nlohmann::basic_json::operator value_t

constexpr operator value_t() const noexcept;
-

Return the type of the JSON value as a value from the value_t enumeration.

Return value

the type of the JSON value

Value type return value
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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ operator value_t - JSON for Modern C++       

nlohmann::basic_json::operator value_t

constexpr operator value_t() const noexcept;
+

Return the type of the JSON value as a value from the value_t enumeration.

Return value

the type of the JSON value

Value type return value
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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = -17;
-    json j_number_unsigned = 42u;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = -17;
+    json j_number_unsigned = 42u;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
 
     // call operator value_t()
-    json::value_t t_null = j_null;
-    json::value_t t_boolean = j_boolean;
-    json::value_t t_number_integer = j_number_integer;
-    json::value_t t_number_unsigned = j_number_unsigned;
-    json::value_t t_number_float = j_number_float;
-    json::value_t t_object = j_object;
-    json::value_t t_array = j_array;
-    json::value_t t_string = j_string;
+    json::value_t t_null = j_null;
+    json::value_t t_boolean = j_boolean;
+    json::value_t t_number_integer = j_number_integer;
+    json::value_t t_number_unsigned = j_number_unsigned;
+    json::value_t t_number_float = j_number_float;
+    json::value_t t_object = j_object;
+    json::value_t t_array = j_array;
+    json::value_t t_string = j_string;
 
     // print types
-    std::cout << std::boolalpha;
-    std::cout << (t_null == json::value_t::null) << '\n';
-    std::cout << (t_boolean == json::value_t::boolean) << '\n';
-    std::cout << (t_number_integer == json::value_t::number_integer) << '\n';
-    std::cout << (t_number_unsigned == json::value_t::number_unsigned) << '\n';
-    std::cout << (t_number_float == json::value_t::number_float) << '\n';
-    std::cout << (t_object == json::value_t::object) << '\n';
-    std::cout << (t_array == json::value_t::array) << '\n';
-    std::cout << (t_string == json::value_t::string) << '\n';
-}
-

Output:

true
-true
-true
-true
-true
-true
-true
-true
-

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.

Last update: May 1, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << (t_null == json::value_t::null) << '\n'; + std::cout << (t_boolean == json::value_t::boolean) << '\n'; + std::cout << (t_number_integer == json::value_t::number_integer) << '\n'; + std::cout << (t_number_unsigned == json::value_t::number_unsigned) << '\n'; + std::cout << (t_number_float == json::value_t::number_float) << '\n'; + std::cout << (t_object == json::value_t::object) << '\n'; + std::cout << (t_array == json::value_t::array) << '\n'; + std::cout << (t_string == json::value_t::string) << '\n'; +} +

Output:

true
+true
+true
+true
+true
+true
+true
+true
+

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.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/other_error/index.html b/api/basic_json/other_error/index.html index 5b33ad2b2..0cf17dace 100644 --- a/api/basic_json/other_error/index.html +++ b/api/basic_json/other_error/index.html @@ -1,34 +1,34 @@ - other_error - JSON for Modern C++
Skip to content

nlohmann::basic_json::other_error

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).

uml diagram

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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ other_error - JSON for Modern C++       

nlohmann::basic_json::other_error

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).

uml diagram

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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
-    try
-    {
+int main()
+{
+    try
+    {
         // executing a failing JSON Patch operation
         json value = R"({
             "best_biscuit": {
                 "name": "Oreo"
             }
-        })"_json;
+        })"_json;
         json patch = R"([{
             "op": "test",
             "path": "/best_biscuit/name",
             "value": "Choco Leibniz"
-        }])"_json;
-        value.patch(patch);
-    }
-    catch (const json::other_error& e)
-    {
+        }])"_json;
+        value.patch(patch);
+    }
+    catch (const json::other_error& e)
+    {
         // output exception information
-        std::cout << "message: " << e.what() << '\n'
-                  << "exception id: " << e.id << std::endl;
-    }
-}
-

Output:

message: [json.exception.other_error.501] unsuccessful: {"op":"test","path":"/best_biscuit/name","value":"Choco Leibniz"}
-exception id: 501
-

See also

Version history

  • Since version 3.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << "message: " << e.what() << '\n' + << "exception id: " << e.id << std::endl; + } +} +

Output:

message: [json.exception.other_error.501] unsuccessful: {"op":"test","path":"/best_biscuit/name","value":"Choco Leibniz"}
+exception id: 501
+

See also

Version history

  • Since version 3.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/out_of_range/index.html b/api/basic_json/out_of_range/index.html index 251f726bd..f49500714 100644 --- a/api/basic_json/out_of_range/index.html +++ b/api/basic_json/out_of_range/index.html @@ -1,24 +1,24 @@ - out_of_range - JSON for Modern C++
Skip to content

nlohmann::basic_json::out_of_range

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).

uml diagram

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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ out_of_range - JSON for Modern C++       

nlohmann::basic_json::out_of_range

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).

uml diagram

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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    try
-    {
+int main()
+{
+    try
+    {
         // calling at() for an invalid index
-        json j = {1, 2, 3, 4};
-        j.at(4) = 10;
-    }
-    catch (const json::out_of_range& e)
-    {
+        json j = {1, 2, 3, 4};
+        j.at(4) = 10;
+    }
+    catch (const json::out_of_range& e)
+    {
         // output exception information
-        std::cout << "message: " << e.what() << '\n'
-                  << "exception id: " << e.id << std::endl;
-    }
-}
-

Output:

message: [json.exception.out_of_range.401] array index 4 is out of range
-exception id: 401
-

See also

Version history

  • Since version 3.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << "message: " << e.what() << '\n' + << "exception id: " << e.id << std::endl; + } +} +

Output:

message: [json.exception.out_of_range.401] array index 4 is out of range
+exception id: 401
+

See also

Version history

  • Since version 3.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/parse/index.html b/api/basic_json/parse/index.html index 6117b157e..0b22c8ede 100644 --- a/api/basic_json/parse/index.html +++ b/api/basic_json/parse/index.html @@ -1,26 +1,26 @@ - parse - JSON for Modern C++
Skip to content

nlohmann::basic_json::parse

// (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);
+ parse - JSON for Modern C++       

nlohmann::basic_json::parse

// (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 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, true by default)
ignore_comments (in)
whether comments should be ignored and treated like whitespace (true) or yield a parse error (false); (optional, 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 false, the return value will be value_t::discarded. The latter can be checked with is_discarded.

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the JSON value.

Exceptions

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.

Runtime assertion

The precondition that a passed FILE pointer must not be null is enforced with a runtime assertion.

Examples

Parsing from a character array

The example below demonstrates the parse() function reading from an array.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+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 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, true by default)
ignore_comments (in)
whether comments should be ignored and treated like whitespace (true) or yield a parse error (false); (optional, 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 false, the return value will be value_t::discarded. The latter can be checked with is_discarded.

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the JSON value.

Exceptions

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.

Runtime assertion

The precondition that a passed FILE pointer must not be null is enforced with a runtime assertion.

Examples

Parsing from a character array

The example below demonstrates the parse() function reading from an array.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // a JSON text
-    char text[] = R"(
+    char text[] = R"(
     {
         "Image": {
             "Width":  800,
@@ -35,41 +35,41 @@
             "IDs": [116, 943, 234, 38793]
         }
     }
-    )";
+    )";
 
     // parse and serialize JSON
-    json j_complete = json::parse(text);
-    std::cout << std::setw(4) << j_complete << "\n\n";
-}
-

Output:

{
-    "Image": {
-        "Animated": false,
-        "Height": 600,
-        "IDs": [
-            116,
-            943,
-            234,
-            38793
-        ],
-        "Thumbnail": {
-            "Height": 125,
-            "Url": "http://www.example.com/image/481989943",
-            "Width": 100
-        },
-        "Title": "View from 15th Floor",
-        "Width": 800
-    }
-}
-
Parsing from a string

The example below demonstrates the parse() function with and without callback function.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+    json j_complete = json::parse(text);
+    std::cout << std::setw(4) << j_complete << "\n\n";
+}
+

Output:

{
+    "Image": {
+        "Animated": false,
+        "Height": 600,
+        "IDs": [
+            116,
+            943,
+            234,
+            38793
+        ],
+        "Thumbnail": {
+            "Height": 125,
+            "Url": "http://www.example.com/image/481989943",
+            "Width": 100
+        },
+        "Title": "View from 15th Floor",
+        "Width": 800
+    }
+}
+
Parsing from a string

The example below demonstrates the parse() function with and without callback function.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // a JSON text
-    auto text = R"(
+    auto text = R"(
     {
         "Image": {
             "Width":  800,
@@ -84,75 +84,75 @@
             "IDs": [116, 943, 234, 38793]
         }
     }
-    )";
+    )";
 
     // parse and serialize JSON
-    json j_complete = json::parse(text);
-    std::cout << std::setw(4) << j_complete << "\n\n";
+    json j_complete = json::parse(text);
+    std::cout << std::setw(4) << j_complete << "\n\n";
 
     // define parser callback
-    json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
-    {
+    json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
+    {
         // skip object elements with key "Thumbnail"
-        if (event == json::parse_event_t::key and parsed == json("Thumbnail"))
-        {
-            return false;
-        }
-        else
-        {
-            return true;
-        }
-    };
+        if (event == json::parse_event_t::key and parsed == json("Thumbnail"))
+        {
+            return false;
+        }
+        else
+        {
+            return true;
+        }
+    };
 
     // parse (with callback) and serialize JSON
-    json j_filtered = json::parse(text, cb);
-    std::cout << std::setw(4) << j_filtered << '\n';
-}
-

Output:

{
-    "Image": {
-        "Animated": false,
-        "Height": 600,
-        "IDs": [
-            116,
-            943,
-            234,
-            38793
-        ],
-        "Thumbnail": {
-            "Height": 125,
-            "Url": "http://www.example.com/image/481989943",
-            "Width": 100
-        },
-        "Title": "View from 15th Floor",
-        "Width": 800
-    }
-}
+    json j_filtered = json::parse(text, cb);
+    std::cout << std::setw(4) << j_filtered << '\n';
+}
+

Output:

{
+    "Image": {
+        "Animated": false,
+        "Height": 600,
+        "IDs": [
+            116,
+            943,
+            234,
+            38793
+        ],
+        "Thumbnail": {
+            "Height": 125,
+            "Url": "http://www.example.com/image/481989943",
+            "Width": 100
+        },
+        "Title": "View from 15th Floor",
+        "Width": 800
+    }
+}
 
-{
-    "Image": {
-        "Animated": false,
-        "Height": 600,
-        "IDs": [
-            116,
-            943,
-            234,
-            38793
-        ],
-        "Title": "View from 15th Floor",
-        "Width": 800
-    }
-}
-
Parsing from an input stream

The example below demonstrates the parse() function with and without callback function.

#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <nlohmann/json.hpp>
+{
+    "Image": {
+        "Animated": false,
+        "Height": 600,
+        "IDs": [
+            116,
+            943,
+            234,
+            38793
+        ],
+        "Title": "View from 15th Floor",
+        "Width": 800
+    }
+}
+
Parsing from an input stream

The example below demonstrates the parse() function with and without callback function.

#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // a JSON text
-    auto text = R"(
+    auto text = R"(
     {
         "Image": {
             "Width":  800,
@@ -167,168 +167,168 @@
             "IDs": [116, 943, 234, 38793]
         }
     }
-    )";
+    )";
 
     // fill a stream with JSON text
-    std::stringstream ss;
-    ss << text;
+    std::stringstream ss;
+    ss << text;
 
     // parse and serialize JSON
-    json j_complete = json::parse(ss);
-    std::cout << std::setw(4) << j_complete << "\n\n";
+    json j_complete = json::parse(ss);
+    std::cout << std::setw(4) << j_complete << "\n\n";
 
     // define parser callback
-    json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
-    {
+    json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
+    {
         // skip object elements with key "Thumbnail"
-        if (event == json::parse_event_t::key and parsed == json("Thumbnail"))
-        {
-            return false;
-        }
-        else
-        {
-            return true;
-        }
-    };
+        if (event == json::parse_event_t::key and parsed == json("Thumbnail"))
+        {
+            return false;
+        }
+        else
+        {
+            return true;
+        }
+    };
 
     // fill a stream with JSON text
-    ss.clear();
-    ss << text;
+    ss.clear();
+    ss << text;
 
     // parse (with callback) and serialize JSON
-    json j_filtered = json::parse(ss, cb);
-    std::cout << std::setw(4) << j_filtered << '\n';
-}
-

Output:

{
-    "Image": {
-        "Animated": false,
-        "Height": 600,
-        "IDs": [
-            116,
-            943,
-            234,
-            38793
-        ],
-        "Thumbnail": {
-            "Height": 125,
-            "Url": "http://www.example.com/image/481989943",
-            "Width": 100
-        },
-        "Title": "View from 15th Floor",
-        "Width": 800
-    }
-}
+    json j_filtered = json::parse(ss, cb);
+    std::cout << std::setw(4) << j_filtered << '\n';
+}
+

Output:

{
+    "Image": {
+        "Animated": false,
+        "Height": 600,
+        "IDs": [
+            116,
+            943,
+            234,
+            38793
+        ],
+        "Thumbnail": {
+            "Height": 125,
+            "Url": "http://www.example.com/image/481989943",
+            "Width": 100
+        },
+        "Title": "View from 15th Floor",
+        "Width": 800
+    }
+}
 
-{
-    "Image": {
-        "Animated": false,
-        "Height": 600,
-        "IDs": [
-            116,
-            943,
-            234,
-            38793
-        ],
-        "Title": "View from 15th Floor",
-        "Width": 800
-    }
-}
-
Parsing from a contiguous container

The example below demonstrates the parse() function reading from a contiguous container.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+{
+    "Image": {
+        "Animated": false,
+        "Height": 600,
+        "IDs": [
+            116,
+            943,
+            234,
+            38793
+        ],
+        "Title": "View from 15th Floor",
+        "Width": 800
+    }
+}
+
Parsing from a contiguous container

The example below demonstrates the parse() function reading from a contiguous container.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // a JSON text given as std::vector
-    std::vector<std::uint8_t> text = {'[', '1', ',', '2', ',', '3', ']', '\0'};
+    std::vector<std::uint8_t> text = {'[', '1', ',', '2', ',', '3', ']', '\0'};
 
     // parse and serialize JSON
-    json j_complete = json::parse(text);
-    std::cout << std::setw(4) << j_complete << "\n\n";
-}
-

Output:

[
-    1,
-    2,
-    3
-]
-
Parsing from a non null-terminated string

The example below demonstrates the parse() function reading from a string that is not null-terminated.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+    json j_complete = json::parse(text);
+    std::cout << std::setw(4) << j_complete << "\n\n";
+}
+

Output:

[
+    1,
+    2,
+    3
+]
+
Parsing from a non null-terminated string

The example below demonstrates the parse() function reading from a string that is not null-terminated.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // a JSON text given as string that is not null-terminated
-    const char* ptr = "[1,2,3]another value";
+    const char* ptr = "[1,2,3]another value";
 
     // parse and serialize JSON
-    json j_complete = json::parse(ptr, ptr + 7);
-    std::cout << std::setw(4) << j_complete << "\n\n";
-}
-

Output:

[
-    1,
-    2,
-    3
-]
-
Parsing from an iterator pair

The example below demonstrates the parse() function reading from an iterator pair.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+    json j_complete = json::parse(ptr, ptr + 7);
+    std::cout << std::setw(4) << j_complete << "\n\n";
+}
+

Output:

[
+    1,
+    2,
+    3
+]
+
Parsing from an iterator pair

The example below demonstrates the parse() function reading from an iterator pair.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // a JSON text given an input with other values
-    std::vector<std::uint8_t> input = {'[', '1', ',', '2', ',', '3', ']', 'o', 't', 'h', 'e', 'r'};
+    std::vector<std::uint8_t> input = {'[', '1', ',', '2', ',', '3', ']', 'o', 't', 'h', 'e', 'r'};
 
     // parse and serialize JSON
-    json j_complete = json::parse(input.begin(), input.begin() + 7);
-    std::cout << std::setw(4) << j_complete << "\n\n";
-}
-

Output:

[
-    1,
-    2,
-    3
-]
-
Effect of allow_exceptions parameter

The example below demonstrates the effect of the allow_exceptions parameter in the ´parse()` function.

#include <iostream>
-#include <nlohmann/json.hpp>
+    json j_complete = json::parse(input.begin(), input.begin() + 7);
+    std::cout << std::setw(4) << j_complete << "\n\n";
+}
+

Output:

[
+    1,
+    2,
+    3
+]
+
Effect of allow_exceptions parameter

The example below demonstrates the effect of the allow_exceptions parameter in the ´parse()` function.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // an invalid JSON text
-    std::string text = R"(
+    std::string text = R"(
     {
         "key": "value without closing quotes
     }
-    )";
+    )";
 
     // parse with exceptions
-    try
-    {
-        json j = json::parse(text);
-    }
-    catch (const json::parse_error& e)
-    {
-        std::cout << e.what() << std::endl;
-    }
+    try
+    {
+        json j = json::parse(text);
+    }
+    catch (const json::parse_error& e)
+    {
+        std::cout << e.what() << std::endl;
+    }
 
     // parse without exceptions
-    json j = json::parse(text, nullptr, false);
+    json j = json::parse(text, nullptr, false);
 
-    if (j.is_discarded())
-    {
-        std::cout << "the input is invalid JSON" << std::endl;
-    }
-    else
-    {
-        std::cout << "the input is valid JSON: " << j << std::endl;
-    }
-}
+    if (j.is_discarded())
+    {
+        std::cout << "the input is invalid JSON" << std::endl;
+    }
+    else
+    {
+        std::cout << "the input is valid JSON: " << j << std::endl;
+    }
+}
 

Output:

[json.exception.parse_error.101] parse error at line 4, column 0: syntax error while parsing value - invalid string: control character U+000A (LF) must be escaped to \u000A or \n; last read: '"value without closing quotes<U+000A>'
 the input is invalid JSON
-

See also

  • accept - check if the input is valid JSON
  • operator>> - 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.

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 parse({ptr, ptr+len}, ...); with parse(ptr, ptr+len, ...);.

You should be warned by your compiler with a -Wdeprecated-declarations warning if you are using a deprecated function.


Last update: July 28, 2022
\ No newline at end of file +

See also

  • accept - check if the input is valid JSON
  • operator>> - 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.

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 parse({ptr, ptr+len}, ...); with parse(ptr, ptr+len, ...);.

You should be warned by your compiler with a -Wdeprecated-declarations warning if you are using a deprecated function.


Last update: July 28, 2022
\ No newline at end of file diff --git a/api/basic_json/parse_error/index.html b/api/basic_json/parse_error/index.html index 129daf479..4d5805bdc 100644 --- a/api/basic_json/parse_error/index.html +++ b/api/basic_json/parse_error/index.html @@ -1,25 +1,25 @@ - parse_error - JSON for Modern C++
Skip to content

nlohmann::basic_json::parse_error

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).

uml diagram

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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ parse_error - JSON for Modern C++       

nlohmann::basic_json::parse_error

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).

uml diagram

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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    try
-    {
+int main()
+{
+    try
+    {
         // parsing input with a syntax error
-        json::parse("[1,2,3,]");
-    }
-    catch (const json::parse_error& e)
-    {
+        json::parse("[1,2,3,]");
+    }
+    catch (const json::parse_error& e)
+    {
         // output exception information
-        std::cout << "message: " << e.what() << '\n'
-                  << "exception id: " << e.id << '\n'
-                  << "byte position of error: " << e.byte << std::endl;
-    }
-}
-

Output:

message: [json.exception.parse_error.101] parse error at line 1, column 8: syntax error while parsing value - unexpected ']'; expected '[', '{', or a literal
-exception id: 101
-byte position of error: 8
-

See also

Version history

  • Since version 3.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << "message: " << e.what() << '\n' + << "exception id: " << e.id << '\n' + << "byte position of error: " << e.byte << std::endl; + } +} +

Output:

message: [json.exception.parse_error.101] parse error at line 1, column 8: syntax error while parsing value - unexpected ']'; expected '[', '{', or a literal
+exception id: 101
+byte position of error: 8
+

See also

Version history

  • Since version 3.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/parse_event_t/index.html b/api/basic_json/parse_event_t/index.html index d1b521669..80eb06d8b 100644 --- a/api/basic_json/parse_event_t/index.html +++ b/api/basic_json/parse_event_t/index.html @@ -1,9 +1,9 @@ - parse_event_t - JSON for Modern C++
Skip to content

nlohmann::basic_json::parse_event_t

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

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + parse_event_t - JSON for Modern C++
Skip to content

nlohmann::basic_json::parse_event_t

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

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/parser_callback_t/index.html b/api/basic_json/parser_callback_t/index.html index cbf5ba7d0..0c6f7d1a5 100644 --- a/api/basic_json/parser_callback_t/index.html +++ b/api/basic_json/parser_callback_t/index.html @@ -1,16 +1,16 @@ - parser_callback_t - JSON for Modern C++
Skip to content

nlohmann::basic_json::parser_callback_t

template<typename BasicJsonType>
-using parser_callback_t =
-    std::function<bool(int depth, parse_event_t event, BasicJsonType& parsed)>;
-

With a parser callback function, the result of parsing a JSON text can be influenced. When passed to parse, it is called on certain events (passed as parse_event_t via parameter event) with a set recursion depth depth and context JSON value parsed. The return value of the callback function is a boolean indicating whether the element that emitted the callback shall be kept or not.

We distinguish six scenarios (determined by the event type) in which the callback function can be called. The following table describes the values of the parameters depth, event, and parsed.

parameter event description parameter depth parameter parsed
parse_event_t::object_start the parser read { and started to process a JSON object depth of the parent of the JSON object a JSON value with type discarded
parse_event_t::key the parser read a key of a value in an object depth of the currently parsed JSON object a JSON string containing the key
parse_event_t::object_end the parser read } and finished processing a JSON object depth of the parent of the JSON object the parsed JSON object
parse_event_t::array_start the parser read [ and started to process a JSON array depth of the parent of the JSON array a JSON value with type discarded
parse_event_t::array_end the parser read ] and finished processing a JSON array depth of the parent of the JSON array the parsed JSON array
parse_event_t::value the parser finished reading a JSON value depth of the value the parsed JSON value

Example when certain parse events are triggered

Discarding a value (i.e., returning false) has different effects depending on the context in which function was called:

  • Discarded values in structured types are skipped. That is, the parser will behave as if the discarded value was never read.
  • In case a value outside a structured type is skipped, it is replaced with null. This case happens if the top-level element is skipped.

Parameters

depth (in)
the depth of the recursion during parsing
event (in)
an event of type parse_event_t indicating the context in the callback function has been called
parsed (in, out)
the current intermediate parse result; note that writing to this value has no effect for parse_event_t::key events

Return value

Whether the JSON value which called the function during parsing should be kept (true) or not (false). In the latter case, it is either skipped completely or replaced by an empty discarded object.

Examples

Example

The example below demonstrates the parse() function with and without callback function.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+ parser_callback_t - JSON for Modern C++       

nlohmann::basic_json::parser_callback_t

template<typename BasicJsonType>
+using parser_callback_t =
+    std::function<bool(int depth, parse_event_t event, BasicJsonType& parsed)>;
+

With a parser callback function, the result of parsing a JSON text can be influenced. When passed to parse, it is called on certain events (passed as parse_event_t via parameter event) with a set recursion depth depth and context JSON value parsed. The return value of the callback function is a boolean indicating whether the element that emitted the callback shall be kept or not.

We distinguish six scenarios (determined by the event type) in which the callback function can be called. The following table describes the values of the parameters depth, event, and parsed.

parameter event description parameter depth parameter parsed
parse_event_t::object_start the parser read { and started to process a JSON object depth of the parent of the JSON object a JSON value with type discarded
parse_event_t::key the parser read a key of a value in an object depth of the currently parsed JSON object a JSON string containing the key
parse_event_t::object_end the parser read } and finished processing a JSON object depth of the parent of the JSON object the parsed JSON object
parse_event_t::array_start the parser read [ and started to process a JSON array depth of the parent of the JSON array a JSON value with type discarded
parse_event_t::array_end the parser read ] and finished processing a JSON array depth of the parent of the JSON array the parsed JSON array
parse_event_t::value the parser finished reading a JSON value depth of the value the parsed JSON value

Example when certain parse events are triggered

Discarding a value (i.e., returning false) has different effects depending on the context in which function was called:

  • Discarded values in structured types are skipped. That is, the parser will behave as if the discarded value was never read.
  • In case a value outside a structured type is skipped, it is replaced with null. This case happens if the top-level element is skipped.

Parameters

depth (in)
the depth of the recursion during parsing
event (in)
an event of type parse_event_t indicating the context in the callback function has been called
parsed (in, out)
the current intermediate parse result; note that writing to this value has no effect for parse_event_t::key events

Return value

Whether the JSON value which called the function during parsing should be kept (true) or not (false). In the latter case, it is either skipped completely or replaced by an empty discarded object.

Examples

Example

The example below demonstrates the parse() function with and without callback function.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // a JSON text
-    auto text = R"(
+    auto text = R"(
     {
         "Image": {
             "Width":  800,
@@ -25,62 +25,62 @@
             "IDs": [116, 943, 234, 38793]
         }
     }
-    )";
+    )";
 
     // parse and serialize JSON
-    json j_complete = json::parse(text);
-    std::cout << std::setw(4) << j_complete << "\n\n";
+    json j_complete = json::parse(text);
+    std::cout << std::setw(4) << j_complete << "\n\n";
 
     // define parser callback
-    json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
-    {
+    json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
+    {
         // skip object elements with key "Thumbnail"
-        if (event == json::parse_event_t::key and parsed == json("Thumbnail"))
-        {
-            return false;
-        }
-        else
-        {
-            return true;
-        }
-    };
+        if (event == json::parse_event_t::key and parsed == json("Thumbnail"))
+        {
+            return false;
+        }
+        else
+        {
+            return true;
+        }
+    };
 
     // parse (with callback) and serialize JSON
-    json j_filtered = json::parse(text, cb);
-    std::cout << std::setw(4) << j_filtered << '\n';
-}
-

Output:

{
-    "Image": {
-        "Animated": false,
-        "Height": 600,
-        "IDs": [
-            116,
-            943,
-            234,
-            38793
-        ],
-        "Thumbnail": {
-            "Height": 125,
-            "Url": "http://www.example.com/image/481989943",
-            "Width": 100
-        },
-        "Title": "View from 15th Floor",
-        "Width": 800
-    }
-}
+    json j_filtered = json::parse(text, cb);
+    std::cout << std::setw(4) << j_filtered << '\n';
+}
+

Output:

{
+    "Image": {
+        "Animated": false,
+        "Height": 600,
+        "IDs": [
+            116,
+            943,
+            234,
+            38793
+        ],
+        "Thumbnail": {
+            "Height": 125,
+            "Url": "http://www.example.com/image/481989943",
+            "Width": 100
+        },
+        "Title": "View from 15th Floor",
+        "Width": 800
+    }
+}
 
-{
-    "Image": {
-        "Animated": false,
-        "Height": 600,
-        "IDs": [
-            116,
-            943,
-            234,
-            38793
-        ],
-        "Title": "View from 15th Floor",
-        "Width": 800
-    }
-}
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file +{ + "Image": { + "Animated": false, + "Height": 600, + "IDs": [ + 116, + 943, + 234, + 38793 + ], + "Title": "View from 15th Floor", + "Width": 800 + } +} +

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/patch/index.html b/api/basic_json/patch/index.html index bd2c03653..a2e1a42df 100644 --- a/api/basic_json/patch/index.html +++ b/api/basic_json/patch/index.html @@ -1,46 +1,46 @@ - patch - JSON for Modern C++
Skip to content

nlohmann::basic_json::patch

basic_json patch(const basic_json& json_patch) const;
-

JSON Patch 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 if the JSON patch does not consist of an array of objects.
  • Throws parse_error.105 if the JSON patch is malformed (e.g., mandatory attributes are missing); example: "operation add must have member path".
  • Throws out_of_range.401 if an array index is out of range.
  • Throws out_of_range.403 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 if JSON pointer has no parent ("add", "remove", "move")
  • Throws out_of_range.501 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.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+ patch - JSON for Modern C++       

nlohmann::basic_json::patch

basic_json patch(const basic_json& json_patch) const;
+

JSON Patch 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 if the JSON patch does not consist of an array of objects.
  • Throws parse_error.105 if the JSON patch is malformed (e.g., mandatory attributes are missing); example: "operation add must have member path".
  • Throws out_of_range.401 if an array index is out of range.
  • Throws out_of_range.403 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 if JSON pointer has no parent ("add", "remove", "move")
  • Throws out_of_range.501 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.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
+int main()
+{
     // the original document
-    json doc = R"(
+    json doc = R"(
         {
           "baz": "qux",
           "foo": "bar"
         }
-    )"_json;
+    )"_json;
 
     // the patch
-    json patch = R"(
+    json patch = R"(
         [
           { "op": "replace", "path": "/baz", "value": "boo" },
           { "op": "add", "path": "/hello", "value": ["world"] },
           { "op": "remove", "path": "/foo"}
         ]
-    )"_json;
+    )"_json;
 
     // apply the patch
-    json patched_doc = doc.patch(patch);
+    json patched_doc = doc.patch(patch);
 
     // output original and patched document
-    std::cout << std::setw(4) << doc << "\n\n"
-              << std::setw(4) << patched_doc << std::endl;
-}
-

Output:

{
-    "baz": "qux",
-    "foo": "bar"
-}
+    std::cout << std::setw(4) << doc << "\n\n"
+              << std::setw(4) << patched_doc << std::endl;
+}
+

Output:

{
+    "baz": "qux",
+    "foo": "bar"
+}
 
-{
-    "baz": "boo",
-    "hello": [
-        "world"
-    ]
-}
-

See also

Version history

  • Added in version 2.0.0.

Last update: July 21, 2022
\ No newline at end of file +{ + "baz": "boo", + "hello": [ + "world" + ] +} +

See also

Version history

  • Added in version 2.0.0.

Last update: July 21, 2022
\ No newline at end of file diff --git a/api/basic_json/patch_inplace/index.html b/api/basic_json/patch_inplace/index.html index 8fe924c16..4742ada12 100644 --- a/api/basic_json/patch_inplace/index.html +++ b/api/basic_json/patch_inplace/index.html @@ -1,50 +1,50 @@ - patch_inplace - JSON for Modern C++
Skip to content

nlohmann::basic_json::patch_inplace

void patch_inplace(const basic_json& json_patch) const;
-

JSON Patch 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 if the JSON patch does not consist of an array of objects.
  • Throws parse_error.105 if the JSON patch is malformed (e.g., mandatory attributes are missing); example: "operation add must have member path".
  • Throws out_of_range.401 if an array index is out of range.
  • Throws out_of_range.403 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 if JSON pointer has no parent ("add", "remove", "move")
  • Throws out_of_range.501 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_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.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+ patch_inplace - JSON for Modern C++       

nlohmann::basic_json::patch_inplace

void patch_inplace(const basic_json& json_patch) const;
+

JSON Patch 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 if the JSON patch does not consist of an array of objects.
  • Throws parse_error.105 if the JSON patch is malformed (e.g., mandatory attributes are missing); example: "operation add must have member path".
  • Throws out_of_range.401 if an array index is out of range.
  • Throws out_of_range.403 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 if JSON pointer has no parent ("add", "remove", "move")
  • Throws out_of_range.501 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_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.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
+int main()
+{
     // the original document
-    json doc = R"(
+    json doc = R"(
         {
           "baz": "qux",
           "foo": "bar"
         }
-    )"_json;
+    )"_json;
 
     // the patch
-    json patch = R"(
+    json patch = R"(
         [
           { "op": "replace", "path": "/baz", "value": "boo" },
           { "op": "add", "path": "/hello", "value": ["world"] },
           { "op": "remove", "path": "/foo"}
         ]
-    )"_json;
+    )"_json;
 
     // output original document
-    std::cout << "Before\n" << std::setw(4) << doc << std::endl;
+    std::cout << "Before\n" << std::setw(4) << doc << std::endl;
 
     // apply the patch
-    doc.patch_inplace(patch);
+    doc.patch_inplace(patch);
 
     // output patched document
-    std::cout << "\nAfter\n" << std::setw(4) << doc << std::endl;
-}
-

Output:

Before
-{
-    "baz": "qux",
-    "foo": "bar"
-}
+    std::cout << "\nAfter\n" << std::setw(4) << doc << std::endl;
+}
+

Output:

Before
+{
+    "baz": "qux",
+    "foo": "bar"
+}
 
-After
-{
-    "baz": "boo",
-    "hello": [
-        "world"
-    ]
-}
-

See also

Version history

  • Added in version 3.11.0.

Last update: July 22, 2022
\ No newline at end of file +After +{ + "baz": "boo", + "hello": [ + "world" + ] +} +

See also

Version history

  • Added in version 3.11.0.

Last update: July 22, 2022
\ No newline at end of file diff --git a/api/basic_json/push_back/index.html b/api/basic_json/push_back/index.html index 43c414a95..edf836812 100644 --- a/api/basic_json/push_back/index.html +++ b/api/basic_json/push_back/index.html @@ -1,84 +1,84 @@ - push_back - JSON for Modern C++
Skip to content

nlohmann::basic_json::push_back

// (1)
-void push_back(basic_json&& val);
-void push_back(const basic_json& val);
+ push_back - JSON for Modern C++       

nlohmann::basic_json::push_back

// (1)
+void push_back(basic_json&& val);
+void push_back(const basic_json& val);
 
 // (2)
-void push_back(const typename object_t::value_type& val);
+void push_back(const typename object_t::value_type& val);
 
 // (3)
-void push_back(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 push_back 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 push_back(const typename object_t::value_type&). Otherwise, init is converted to a JSON value and added using push_back(basic_json&&).

Parameters

val (in)
the value to add to the JSON array/object
init (in)
an initializer list

Exceptions

All functions can throw the following exception: - Throws type_error.308 when called on a type other than JSON array or null; example: "cannot use push_back() 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 for more information.

Examples

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.

#include <iostream>
-#include <nlohmann/json.hpp>
+void push_back(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 push_back 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 push_back(const typename object_t::value_type&). Otherwise, init is converted to a JSON value and added using push_back(basic_json&&).

Parameters

val (in)
the value to add to the JSON array/object
init (in)
an initializer list

Exceptions

All functions can throw the following exception: - Throws type_error.308 when called on a type other than JSON array or null; example: "cannot use push_back() 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 for more information.

Examples

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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json array = {1, 2, 3, 4, 5};
-    json null;
+    json array = {1, 2, 3, 4, 5};
+    json null;
 
     // print values
-    std::cout << array << '\n';
-    std::cout << null << '\n';
+    std::cout << array << '\n';
+    std::cout << null << '\n';
 
     // add values
-    array.push_back(6);
-    array += 7;
-    null += "first";
-    null += "second";
+    array.push_back(6);
+    array += 7;
+    null += "first";
+    null += "second";
 
     // print values
-    std::cout << array << '\n';
-    std::cout << null << '\n';
-}
-

Output:

[1,2,3,4,5]
-null
-[1,2,3,4,5,6,7]
-["first","second"]
-
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.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << array << '\n';
+    std::cout << null << '\n';
+}
+

Output:

[1,2,3,4,5]
+null
+[1,2,3,4,5,6,7]
+["first","second"]
+
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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json object = {{"one", 1}, {"two", 2}};
-    json null;
+    json object = {{"one", 1}, {"two", 2}};
+    json null;
 
     // print values
-    std::cout << object << '\n';
-    std::cout << null << '\n';
+    std::cout << object << '\n';
+    std::cout << null << '\n';
 
     // add values
-    object.push_back(json::object_t::value_type("three", 3));
-    object += json::object_t::value_type("four", 4);
-    null += json::object_t::value_type("A", "a");
-    null += json::object_t::value_type("B", "b");
+    object.push_back(json::object_t::value_type("three", 3));
+    object += json::object_t::value_type("four", 4);
+    null += json::object_t::value_type("A", "a");
+    null += json::object_t::value_type("B", "b");
 
     // print values
-    std::cout << object << '\n';
-    std::cout << null << '\n';
-}
-

Output:

{"one":1,"two":2}
-null
-{"four":4,"one":1,"three":3,"two":2}
-{"A":"a","B":"b"}
-
Example: (3) add to object from initializer list

The example shows how initializer lists are treated as objects when possible.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << object << '\n';
+    std::cout << null << '\n';
+}
+

Output:

{"one":1,"two":2}
+null
+{"four":4,"one":1,"three":3,"two":2}
+{"A":"a","B":"b"}
+
Example: (3) add to object from initializer list

The example shows how initializer lists are treated as objects when possible.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json object = {{"one", 1}, {"two", 2}};
-    json null;
+    json object = {{"one", 1}, {"two", 2}};
+    json null;
 
     // print values
-    std::cout << object << '\n';
-    std::cout << null << '\n';
+    std::cout << object << '\n';
+    std::cout << null << '\n';
 
     // add values:
     object.push_back({"three", 3});  // object is extended
@@ -86,14 +86,14 @@
     null.push_back({"five", 5});     // null is converted to array
 
     // print values
-    std::cout << object << '\n';
-    std::cout << null << '\n';
+    std::cout << object << '\n';
+    std::cout << null << '\n';
 
     // would throw:
     //object.push_back({1, 2, 3});
-}
-

Output:

{"one":1,"two":2}
-null
-{"four":4,"one":1,"three":3,"two":2}
-[["five",5]]
-

Version history

  1. Since version 1.0.0.
  2. Since version 1.0.0.
  3. Since version 2.0.0.

Last update: May 17, 2022
\ No newline at end of file +} +

Output:

{"one":1,"two":2}
+null
+{"four":4,"one":1,"three":3,"two":2}
+[["five",5]]
+

Version history

  1. Since version 1.0.0.
  2. Since version 1.0.0.
  3. Since version 2.0.0.

Last update: May 17, 2022
\ No newline at end of file diff --git a/api/basic_json/rbegin/index.html b/api/basic_json/rbegin/index.html index b1736bd3c..913617ab1 100644 --- a/api/basic_json/rbegin/index.html +++ b/api/basic_json/rbegin/index.html @@ -1,20 +1,20 @@ - rbegin - JSON for Modern C++
Skip to content

nlohmann::basic_json::rbegin

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

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().

#include <iostream>
-#include <nlohmann/json.hpp>
+ rbegin - JSON for Modern C++       

nlohmann::basic_json::rbegin

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

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().

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create an array value
-    json array = {1, 2, 3, 4, 5};
+    json array = {1, 2, 3, 4, 5};
 
     // get an iterator to the reverse-beginning
-    json::reverse_iterator it = array.rbegin();
+    json::reverse_iterator it = array.rbegin();
 
     // serialize the element that the iterator points to
-    std::cout << *it << '\n';
-}
-

Output:

5
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << *it << '\n'; +} +

Output:

5
+

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/rend/index.html b/api/basic_json/rend/index.html index d5b54619e..3bab0bd8e 100644 --- a/api/basic_json/rend/index.html +++ b/api/basic_json/rend/index.html @@ -1,23 +1,23 @@ - rend - JSON for Modern C++
Skip to content

nlohmann::basic_json::rend

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

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().

#include <iostream>
-#include <nlohmann/json.hpp>
+ rend - JSON for Modern C++       

nlohmann::basic_json::rend

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

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().

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create an array value
-    json array = {1, 2, 3, 4, 5};
+    json array = {1, 2, 3, 4, 5};
 
     // get an iterator to the reverse-end
-    json::reverse_iterator it = array.rend();
+    json::reverse_iterator it = array.rend();
 
     // increment the iterator to point to the first element
-    --it;
+    --it;
 
     // serialize the element that the iterator points to
-    std::cout << *it << '\n';
-}
-

Output:

1
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << *it << '\n'; +} +

Output:

1
+

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/sax_parse/index.html b/api/basic_json/sax_parse/index.html index 94094ef2e..c2341696e 100644 --- a/api/basic_json/sax_parse/index.html +++ b/api/basic_json/sax_parse/index.html @@ -1,116 +1,116 @@ - sax_parse - JSON for Modern C++
Skip to content

nlohmann::basic_json::sax_parse

// (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);
+ sax_parse - JSON for Modern C++       

nlohmann::basic_json::sax_parse

// (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.

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 for more information
strict (in)
whether the input has to be consumed completely (optional, true by default)
ignore_comments (in)
whether comments should be ignored and treated like whitespace (true) or yield a parse error (false); (optional, 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.

#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <nlohmann/json.hpp>
+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.

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 for more information
strict (in)
whether the input has to be consumed completely (optional, true by default)
ignore_comments (in)
whether comments should be ignored and treated like whitespace (true) or yield a parse error (false); (optional, 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.

#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
 // a simple event consumer that collects string representations of the passed
 // values; note inheriting from json::json_sax_t is not required, but can
 // help not to forget a required function
-class sax_event_consumer : public json::json_sax_t
-{
-  public:
-    std::vector<std::string> events;
+class sax_event_consumer : public json::json_sax_t
+{
+  public:
+    std::vector<std::string> events;
 
-    bool null() override
-    {
-        events.push_back("null()");
-        return true;
-    }
+    bool null() override
+    {
+        events.push_back("null()");
+        return true;
+    }
 
-    bool boolean(bool val) override
-    {
-        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
-        return true;
-    }
+    bool boolean(bool val) override
+    {
+        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
+        return true;
+    }
 
-    bool number_integer(number_integer_t val) override
-    {
-        events.push_back("number_integer(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_integer(number_integer_t val) override
+    {
+        events.push_back("number_integer(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_unsigned(number_unsigned_t val) override
-    {
-        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_unsigned(number_unsigned_t val) override
+    {
+        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_float(number_float_t val, const string_t& s) override
-    {
-        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
-        return true;
-    }
+    bool number_float(number_float_t val, const string_t& s) override
+    {
+        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
+        return true;
+    }
 
-    bool string(string_t& val) override
-    {
-        events.push_back("string(val=" + val + ")");
-        return true;
-    }
+    bool string(string_t& val) override
+    {
+        events.push_back("string(val=" + val + ")");
+        return true;
+    }
 
-    bool start_object(std::size_t elements) override
-    {
-        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_object(std::size_t elements) override
+    {
+        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_object() override
-    {
-        events.push_back("end_object()");
-        return true;
-    }
+    bool end_object() override
+    {
+        events.push_back("end_object()");
+        return true;
+    }
 
-    bool start_array(std::size_t elements) override
-    {
-        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_array(std::size_t elements) override
+    {
+        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_array() override
-    {
-        events.push_back("end_array()");
-        return true;
-    }
+    bool end_array() override
+    {
+        events.push_back("end_array()");
+        return true;
+    }
 
-    bool key(string_t& val) override
-    {
-        events.push_back("key(val=" + val + ")");
-        return true;
-    }
+    bool key(string_t& val) override
+    {
+        events.push_back("key(val=" + val + ")");
+        return true;
+    }
 
-    bool binary(json::binary_t& val) override
-    {
-        events.push_back("binary(val=[...])");
-        return true;
-    }
+    bool binary(json::binary_t& val) override
+    {
+        events.push_back("binary(val=[...])");
+        return true;
+    }
 
-    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
-    {
-        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
-        return false;
-    }
-};
+    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
+    {
+        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
+        return false;
+    }
+};
 
-int main()
-{
+int main()
+{
     // a JSON text
-    auto text = R"(
+    auto text = R"(
     {
         "Image": {
             "Width":  800,
@@ -127,58 +127,58 @@
             "Distance": 12.723374634
         }
     }]
-    )";
+    )";
 
     // create a SAX event consumer object
-    sax_event_consumer sec;
+    sax_event_consumer sec;
 
     // parse JSON
-    bool result = json::sax_parse(text, &sec);
+    bool result = json::sax_parse(text, &sec);
 
     // output the recorded events
-    for (auto& event : sec.events)
-    {
-        std::cout << event << "\n";
-    }
+    for (auto& event : sec.events)
+    {
+        std::cout << event << "\n";
+    }
 
     // output the result of sax_parse
-    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
-}
-

Output:

start_object(elements=18446744073709551615)
-key(val=Image)
-start_object(elements=18446744073709551615)
-key(val=Width)
-number_unsigned(val=800)
-key(val=Height)
-number_unsigned(val=600)
-key(val=Title)
-string(val=View from 15th Floor)
-key(val=Thumbnail)
-start_object(elements=18446744073709551615)
-key(val=Url)
-string(val=http://www.example.com/image/481989943)
-key(val=Height)
-number_unsigned(val=125)
-key(val=Width)
-number_unsigned(val=100)
-end_object()
-key(val=Animated)
-boolean(val=false)
-key(val=IDs)
-start_array(elements=18446744073709551615)
-number_unsigned(val=116)
-number_unsigned(val=943)
-number_unsigned(val=234)
-number_integer(val=-38793)
-end_array()
-key(val=DeletionDate)
-null()
-key(val=Distance)
-number_float(val=12.723375, s=12.723374634)
-end_object()
-end_object()
-parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
-            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
+    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
+}
+

Output:

start_object(elements=18446744073709551615)
+key(val=Image)
+start_object(elements=18446744073709551615)
+key(val=Width)
+number_unsigned(val=800)
+key(val=Height)
+number_unsigned(val=600)
+key(val=Title)
+string(val=View from 15th Floor)
+key(val=Thumbnail)
+start_object(elements=18446744073709551615)
+key(val=Url)
+string(val=http://www.example.com/image/481989943)
+key(val=Height)
+number_unsigned(val=125)
+key(val=Width)
+number_unsigned(val=100)
+end_object()
+key(val=Animated)
+boolean(val=false)
+key(val=IDs)
+start_array(elements=18446744073709551615)
+number_unsigned(val=116)
+number_unsigned(val=943)
+number_unsigned(val=234)
+number_integer(val=-38793)
+end_array()
+key(val=DeletionDate)
+null()
+key(val=Distance)
+number_float(val=12.723375, s=12.723374634)
+end_object()
+end_object()
+parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
+            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
 
-result: false
-

Version history

  • Added in version 3.2.0.
  • Ignoring comments via ignore_comments added in version 3.9.0.

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 sax_parse({ptr, ptr+len}); with sax_parse(ptr, ptr+len);.


Last update: May 1, 2022
\ No newline at end of file +result: false +

Version history

  • Added in version 3.2.0.
  • Ignoring comments via ignore_comments added in version 3.9.0.

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 sax_parse({ptr, ptr+len}); with sax_parse(ptr, ptr+len);.


Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/size/index.html b/api/basic_json/size/index.html index e86edfc5a..9b79a184d 100644 --- a/api/basic_json/size/index.html +++ b/api/basic_json/size/index.html @@ -1,40 +1,40 @@ - size - JSON for Modern C++
Skip to content

nlohmann::basic_json::size

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 and object_t satisfy the 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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ size - JSON for Modern C++       

nlohmann::basic_json::size

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 and object_t satisfy the 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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = 17;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_object_empty(json::value_t::object);
-    json j_array = {1, 2, 4, 8, 16};
-    json j_array_empty(json::value_t::array);
-    json j_string = "Hello, world";
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = 17;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_object_empty(json::value_t::object);
+    json j_array = {1, 2, 4, 8, 16};
+    json j_array_empty(json::value_t::array);
+    json j_string = "Hello, world";
 
     // call size()
-    std::cout << j_null.size() << '\n';
-    std::cout << j_boolean.size() << '\n';
-    std::cout << j_number_integer.size() << '\n';
-    std::cout << j_number_float.size() << '\n';
-    std::cout << j_object.size() << '\n';
-    std::cout << j_object_empty.size() << '\n';
-    std::cout << j_array.size() << '\n';
-    std::cout << j_array_empty.size() << '\n';
-    std::cout << j_string.size() << '\n';
-}
-

Output:

0
-1
-1
-1
-2
-0
-5
-0
-1
-

Version history

  • Added in version 1.0.0.
  • Extended to return 1 for binary types in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << j_null.size() << '\n'; + std::cout << j_boolean.size() << '\n'; + std::cout << j_number_integer.size() << '\n'; + std::cout << j_number_float.size() << '\n'; + std::cout << j_object.size() << '\n'; + std::cout << j_object_empty.size() << '\n'; + std::cout << j_array.size() << '\n'; + std::cout << j_array_empty.size() << '\n'; + std::cout << j_string.size() << '\n'; +} +

Output:

0
+1
+1
+1
+2
+0
+5
+0
+1
+

Version history

  • Added in version 1.0.0.
  • Extended to return 1 for binary types in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/std_hash/index.html b/api/basic_json/std_hash/index.html index 08b3c741c..a42f08447 100644 --- a/api/basic_json/std_hash/index.html +++ b/api/basic_json/std_hash/index.html @@ -1,31 +1,31 @@ - std::hash<basic_json> - JSON for Modern C++
Skip to content

std::hash<nlohmann::basic_json>

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 null, 0, 0U, and false, etc.

Examples

Example

The example shows how to calculate hash values for different JSON values.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+ std::hash<basic_json> - JSON for Modern C++       

std::hash<nlohmann::basic_json>

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 null, 0, 0U, and false, etc.

Examples

Example

The example shows how to calculate hash values for different JSON values.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
-    std::cout << "hash(null) = " << std::hash<json> {}(json(nullptr)) << '\n'
-              << "hash(false) = " << std::hash<json> {}(json(false)) << '\n'
-              << "hash(0) = " << std::hash<json> {}(json(0)) << '\n'
-              << "hash(0U) = " << std::hash<json> {}(json(0U)) << '\n'
-              << "hash(\"\") = " << std::hash<json> {}(json("")) << '\n'
-              << "hash({}) = " << std::hash<json> {}(json::object()) << '\n'
-              << "hash([]) = " << std::hash<json> {}(json::array()) << '\n'
-              << "hash({\"hello\": \"world\"}) = " << std::hash<json> {}("{\"hello\": \"world\"}"_json)
-              << std::endl;
-}
-

Output:

hash(null) = 2654435769
-hash(false) = 2654436030
-hash(0) = 2654436095
-hash(0U) = 2654436156
-hash("") = 6142509191626859748
-hash({}) = 2654435832
-hash([]) = 2654435899
-hash({"hello": "world"}) = 4469488738203676328
-

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.

Last update: July 29, 2022
\ No newline at end of file +int main() +{ + std::cout << "hash(null) = " << std::hash<json> {}(json(nullptr)) << '\n' + << "hash(false) = " << std::hash<json> {}(json(false)) << '\n' + << "hash(0) = " << std::hash<json> {}(json(0)) << '\n' + << "hash(0U) = " << std::hash<json> {}(json(0U)) << '\n' + << "hash(\"\") = " << std::hash<json> {}(json("")) << '\n' + << "hash({}) = " << std::hash<json> {}(json::object()) << '\n' + << "hash([]) = " << std::hash<json> {}(json::array()) << '\n' + << "hash({\"hello\": \"world\"}) = " << std::hash<json> {}("{\"hello\": \"world\"}"_json) + << std::endl; +} +

Output:

hash(null) = 2654435769
+hash(false) = 2654436030
+hash(0) = 2654436095
+hash(0U) = 2654436156
+hash("") = 6142509191626859748
+hash({}) = 2654435832
+hash([]) = 2654435899
+hash({"hello": "world"}) = 4469488738203676328
+

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.

Last update: July 29, 2022
\ No newline at end of file diff --git a/api/basic_json/std_swap/index.html b/api/basic_json/std_swap/index.html index 23c2f3abc..398c73e6f 100644 --- a/api/basic_json/std_swap/index.html +++ b/api/basic_json/std_swap/index.html @@ -1,29 +1,29 @@ - std::swap<basic_json> - JSON for Modern C++
Skip to content

std::swap<basic_json>

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

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.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+ std::swap<basic_json> - JSON for Modern C++       

std::swap<basic_json>

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

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.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j1 = {{"one", 1}, {"two", 2}};
-    json j2 = {1, 2, 4, 8, 16};
+    json j1 = {{"one", 1}, {"two", 2}};
+    json j2 = {1, 2, 4, 8, 16};
 
-    std::cout << "j1 = " << j1 << " | j2 = " << j2 << '\n';
+    std::cout << "j1 = " << j1 << " | j2 = " << j2 << '\n';
 
     // swap values
-    std::swap(j1, j2);
+    std::swap(j1, j2);
 
-    std::cout << "j1 = " << j1 << " | j2 = " << j2 << std::endl;
-}
-

Output:

j1 = {"one":1,"two":2} | j2 = [1,2,4,8,16]
-j1 = [1,2,4,8,16] | j2 = {"one":1,"two":2}
-

See also

Version history

  • Added in version 1.0.0.
  • Extended for arbitrary basic_json types in version 3.10.5.

Last update: May 1, 2022
\ No newline at end of file + std::cout << "j1 = " << j1 << " | j2 = " << j2 << std::endl; +} +

Output:

j1 = {"one":1,"two":2} | j2 = [1,2,4,8,16]
+j1 = [1,2,4,8,16] | j2 = {"one":1,"two":2}
+

See also

Version history

  • Added in version 1.0.0.
  • Extended for arbitrary basic_json types in version 3.10.5.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/string_t/index.html b/api/basic_json/string_t/index.html index 5c4380e41..edf5b1d09 100644 --- a/api/basic_json/string_t/index.html +++ b/api/basic_json/string_t/index.html @@ -1,13 +1,13 @@ - string_t - JSON for Modern C++
Skip to content

nlohmann::basic_json::string_t

using string_t = StringType;
-

The type used to store JSON strings.

RFC 8259 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.

Notes

Default type

With the default values for StringType (std::string), the default value for string_t is 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 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 std::string.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+ string_t - JSON for Modern C++       

nlohmann::basic_json::string_t

using string_t = StringType;
+

The type used to store JSON strings.

RFC 8259 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.

Notes

Default type

With the default values for StringType (std::string), the default value for string_t is 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 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 std::string.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    std::cout << std::boolalpha << std::is_same<std::string, json::string_t>::value << std::endl;
-}
-

Output:

true
-

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file +int main() +{ + std::cout << std::boolalpha << std::is_same<std::string, json::string_t>::value << std::endl; +} +

Output:

true
+

Version history

  • Added in version 1.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/swap/index.html b/api/basic_json/swap/index.html index 2f4aa396b..aecbe7230 100644 --- a/api/basic_json/swap/index.html +++ b/api/basic_json/swap/index.html @@ -1,129 +1,129 @@ - swap - JSON for Modern C++
Skip to content

nlohmann::basic_json::swap

// (1)
-void swap(reference other) noexcept;
+ swap - JSON for Modern C++       

nlohmann::basic_json::swap

// (1)
+void swap(reference other) noexcept;
 
 // (2)
-void swap(reference left, reference right) noexcept;
+void swap(reference left, reference right) noexcept;
 
 // (3)
-void swap(array_t& other);
+void swap(array_t& other);
 
 // (4)
-void swap(object_t& other);
+void swap(object_t& other);
 
 // (5)
-void swap(string_t& other);
+void swap(string_t& other);
 
 // (6)
-void swap(binary_t& other);
+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 if called on JSON values other than arrays; example: "cannot use swap() with boolean"
  4. Throws type_error.310 if called on JSON values other than objects; example: "cannot use swap() with boolean"
  5. Throws type_error.310 if called on JSON values other than strings; example: "cannot use swap() with boolean"
  6. Throws type_error.310 if called on JSON values other than binaries; example: "cannot use swap() with boolean"
  7. Throws type_error.310 if called on JSON values other than binaries; example: "cannot use swap() with boolean"

Complexity

Constant.

Examples

Example: Swap JSON value (1, 2)

The example below shows how JSON values can be swapped with swap().

#include <iostream>
-#include <nlohmann/json.hpp>
+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 if called on JSON values other than arrays; example: "cannot use swap() with boolean"
  4. Throws type_error.310 if called on JSON values other than objects; example: "cannot use swap() with boolean"
  5. Throws type_error.310 if called on JSON values other than strings; example: "cannot use swap() with boolean"
  6. Throws type_error.310 if called on JSON values other than binaries; example: "cannot use swap() with boolean"
  7. Throws type_error.310 if called on JSON values other than binaries; example: "cannot use swap() with boolean"

Complexity

Constant.

Examples

Example: Swap JSON value (1, 2)

The example below shows how JSON values can be swapped with swap().

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create two JSON values
-    json j1 = {1, 2, 3, 4, 5};
-    json j2 = {{"pi", 3.141592653589793}, {"e", 2.718281828459045}};
+    json j1 = {1, 2, 3, 4, 5};
+    json j2 = {{"pi", 3.141592653589793}, {"e", 2.718281828459045}};
 
     // swap the values
-    j1.swap(j2);
+    j1.swap(j2);
 
     // output the values
-    std::cout << "j1 = " << j1 << '\n';
-    std::cout << "j2 = " << j2 << '\n';
-}
-

Output:

j1 = {"e":2.718281828459045,"pi":3.141592653589793}
-j2 = [1,2,3,4,5]
-
Example: Swap array (3)

The example below shows how arrays can be swapped with swap().

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << "j1 = " << j1 << '\n';
+    std::cout << "j2 = " << j2 << '\n';
+}
+

Output:

j1 = {"e":2.718281828459045,"pi":3.141592653589793}
+j2 = [1,2,3,4,5]
+
Example: Swap array (3)

The example below shows how arrays can be swapped with swap().

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON value
-    json value = {{"array", {1, 2, 3, 4}}};
+    json value = {{"array", {1, 2, 3, 4}}};
 
     // create an array_t
-    json::array_t array = {"Snap", "Crackle", "Pop"};
+    json::array_t array = {"Snap", "Crackle", "Pop"};
 
     // swap the array stored in the JSON value
-    value["array"].swap(array);
+    value["array"].swap(array);
 
     // output the values
-    std::cout << "value = " << value << '\n';
-    std::cout << "array = " << array << '\n';
-}
-

Output:

value = {"array":["Snap","Crackle","Pop"]}
-array = [1,2,3,4]
-
Example: Swap object (4)

The example below shows how objects can be swapped with swap().

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << "value = " << value << '\n';
+    std::cout << "array = " << array << '\n';
+}
+

Output:

value = {"array":["Snap","Crackle","Pop"]}
+array = [1,2,3,4]
+
Example: Swap object (4)

The example below shows how objects can be swapped with swap().

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON value
-    json value = { {"translation", {{"one", "eins"}, {"two", "zwei"}}} };
+    json value = { {"translation", {{"one", "eins"}, {"two", "zwei"}}} };
 
     // create an object_t
-    json::object_t object = {{"cow", "Kuh"}, {"dog", "Hund"}};
+    json::object_t object = {{"cow", "Kuh"}, {"dog", "Hund"}};
 
     // swap the object stored in the JSON value
-    value["translation"].swap(object);
+    value["translation"].swap(object);
 
     // output the values
-    std::cout << "value = " << value << '\n';
-    std::cout << "object = " << object << '\n';
-}
-

Output:

value = {"translation":{"cow":"Kuh","dog":"Hund"}}
-object = {"one":"eins","two":"zwei"}
-
Example: Swap string (5)

The example below shows how strings can be swapped with swap().

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << "value = " << value << '\n';
+    std::cout << "object = " << object << '\n';
+}
+

Output:

value = {"translation":{"cow":"Kuh","dog":"Hund"}}
+object = {"one":"eins","two":"zwei"}
+
Example: Swap string (5)

The example below shows how strings can be swapped with swap().

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON value
-    json value = { "the good", "the bad", "the ugly" };
+    json value = { "the good", "the bad", "the ugly" };
 
     // create string_t
-    json::string_t string = "the fast";
+    json::string_t string = "the fast";
 
     // swap the object stored in the JSON value
-    value[1].swap(string);
+    value[1].swap(string);
 
     // output the values
-    std::cout << "value = " << value << '\n';
-    std::cout << "string = " << string << '\n';
-}
-

Output:

value = ["the good","the fast","the ugly"]
-string = the bad
-
Example: Swap string (6)

The example below shows how binary values can be swapped with swap().

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << "value = " << value << '\n';
+    std::cout << "string = " << string << '\n';
+}
+

Output:

value = ["the good","the fast","the ugly"]
+string = the bad
+
Example: Swap string (6)

The example below shows how binary values can be swapped with swap().

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a binary value
-    json value = json::binary({1, 2, 3});
+    json value = json::binary({1, 2, 3});
 
     // create a binary_t
-    json::binary_t binary = {{4, 5, 6}};
+    json::binary_t binary = {{4, 5, 6}};
 
     // swap the object stored in the JSON value
-    value.swap(binary);
+    value.swap(binary);
 
     // output the values
-    std::cout << "value = " << value << '\n';
-    std::cout << "binary = " << json(binary) << '\n';
-}
-

Output:

value = {"bytes":[4,5,6],"subtype":null}
-binary = {"bytes":[1,2,3],"subtype":null}
-

See also

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.

Last update: May 1, 2022
\ No newline at end of file + std::cout << "value = " << value << '\n'; + std::cout << "binary = " << json(binary) << '\n'; +} +

Output:

value = {"bytes":[4,5,6],"subtype":null}
+binary = {"bytes":[1,2,3],"subtype":null}
+

See also

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.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/to_bjdata/index.html b/api/basic_json/to_bjdata/index.html index a5cf301ea..8ae0971b9 100644 --- a/api/basic_json/to_bjdata/index.html +++ b/api/basic_json/to_bjdata/index.html @@ -1,79 +1,79 @@ - to_bjdata - JSON for Modern C++
Skip to content

nlohmann::basic_json::to_bjdata

// (1)
-static std::vector<std::uint8_t> to_bjdata(const basic_json& j,
-                                           const bool use_size = false,
-                                           const bool use_type = false);
+ to_bjdata - JSON for Modern C++       

nlohmann::basic_json::to_bjdata

// (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.

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, false by default.
use_type (in)
whether to add type annotations to container types (must be combined with use_size = true); optional, 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.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+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.

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, false by default.
use_type (in)
whether to add type annotations to container types (must be combined with use_size = true); optional, 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.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
 // function to print BJData's diagnostic format
-void print_byte(uint8_t byte)
-{
-    if (32 < byte and byte < 128)
-    {
-        std::cout << (char)byte;
-    }
-    else
-    {
-        std::cout << (int)byte;
-    }
-}
+void print_byte(uint8_t byte)
+{
+    if (32 < byte and byte < 128)
+    {
+        std::cout << (char)byte;
+    }
+    else
+    {
+        std::cout << (int)byte;
+    }
+}
 
-int main()
-{
+int main()
+{
     // create a JSON value
-    json j = R"({"compact": true, "schema": false})"_json;
+    json j = R"({"compact": true, "schema": false})"_json;
 
     // serialize it to BJData
-    std::vector<std::uint8_t> v = json::to_bjdata(j);
+    std::vector<std::uint8_t> v = json::to_bjdata(j);
 
     // print the vector content
-    for (auto& byte : v)
-    {
-        print_byte(byte);
-    }
-    std::cout << std::endl;
+    for (auto& byte : v)
+    {
+        print_byte(byte);
+    }
+    std::cout << std::endl;
 
     // create an array of numbers
-    json array = {1, 2, 3, 4, 5, 6, 7, 8};
+    json array = {1, 2, 3, 4, 5, 6, 7, 8};
 
     // serialize it to BJData using default representation
-    std::vector<std::uint8_t> v_array = json::to_bjdata(array);
+    std::vector<std::uint8_t> v_array = json::to_bjdata(array);
     // serialize it to BJData using size optimization
-    std::vector<std::uint8_t> v_array_size = json::to_bjdata(array, true);
+    std::vector<std::uint8_t> v_array_size = json::to_bjdata(array, true);
     // serialize it to BJData using type optimization
-    std::vector<std::uint8_t> v_array_size_and_type = json::to_bjdata(array, true, true);
+    std::vector<std::uint8_t> v_array_size_and_type = json::to_bjdata(array, true, true);
 
     // print the vector contents
-    for (auto& byte : v_array)
-    {
-        print_byte(byte);
-    }
-    std::cout << std::endl;
+    for (auto& byte : v_array)
+    {
+        print_byte(byte);
+    }
+    std::cout << std::endl;
 
-    for (auto& byte : v_array_size)
-    {
-        print_byte(byte);
-    }
-    std::cout << std::endl;
+    for (auto& byte : v_array_size)
+    {
+        print_byte(byte);
+    }
+    std::cout << std::endl;
 
-    for (auto& byte : v_array_size_and_type)
-    {
-        print_byte(byte);
-    }
-    std::cout << std::endl;
-}
-

Output:

{i7compactTi6schemaF}
-[i1i2i3i4i5i6i7i8]
-[#i8i1i2i3i4i5i6i7i8
-[$i#i812345678
-

Version history

  • Added in version 3.11.0.

Last update: August 5, 2022
\ No newline at end of file + for (auto& byte : v_array_size_and_type) + { + print_byte(byte); + } + std::cout << std::endl; +} +

Output:

{i7compactTi6schemaF}
+[i1i2i3i4i5i6i7i8]
+[#i8i1i2i3i4i5i6i7i8
+[$i#i812345678
+

Version history

  • Added in version 3.11.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/basic_json/to_bson/index.html b/api/basic_json/to_bson/index.html index b7b65eb4d..042a7f83b 100644 --- a/api/basic_json/to_bson/index.html +++ b/api/basic_json/to_bson/index.html @@ -1,30 +1,30 @@ - to_bson - JSON for Modern C++
Skip to content

nlohmann::basic_json::to_bson

// (1)
-static std::vector<std::uint8_t> to_bson(const basic_json& j);
+ to_bson - JSON for Modern C++       

nlohmann::basic_json::to_bson

// (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.

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.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+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.

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.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
+int main()
+{
     // create a JSON value
-    json j = R"({"compact": true, "schema": 0})"_json;
+    json j = R"({"compact": true, "schema": 0})"_json;
 
     // serialize it to BSON
-    std::vector<std::uint8_t> v = json::to_bson(j);
+    std::vector<std::uint8_t> v = json::to_bson(j);
 
     // print the vector content
-    for (auto& byte : v)
-    {
-        std::cout << "0x" << std::hex << std::setw(2) << std::setfill('0') << (int)byte << " ";
-    }
-    std::cout << std::endl;
-}
+    for (auto& byte : v)
+    {
+        std::cout << "0x" << std::hex << std::setw(2) << std::setfill('0') << (int)byte << " ";
+    }
+    std::cout << std::endl;
+}
 

Output:

0x1b 0x00 0x00 0x00 0x08 0x63 0x6f 0x6d 0x70 0x61 0x63 0x74 0x00 0x01 0x10 0x73 0x63 0x68 0x65 0x6d 0x61 0x00 0x00 0x00 0x00 0x00 0x00 
-

Version history

  • Added in version 3.4.0.

Last update: May 1, 2022
\ No newline at end of file +

Version history

  • Added in version 3.4.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/to_cbor/index.html b/api/basic_json/to_cbor/index.html index 47f146325..1aadb604e 100644 --- a/api/basic_json/to_cbor/index.html +++ b/api/basic_json/to_cbor/index.html @@ -1,30 +1,30 @@ - to_cbor - JSON for Modern C++
Skip to content

nlohmann::basic_json::to_cbor

// (1)
-static std::vector<std::uint8_t> to_cbor(const basic_json& j);
+ to_cbor - JSON for Modern C++       

nlohmann::basic_json::to_cbor

// (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.

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.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+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.

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.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
+int main()
+{
     // create a JSON value
-    json j = R"({"compact": true, "schema": 0})"_json;
+    json j = R"({"compact": true, "schema": 0})"_json;
 
     // serialize it to CBOR
-    std::vector<std::uint8_t> v = json::to_cbor(j);
+    std::vector<std::uint8_t> v = json::to_cbor(j);
 
     // print the vector content
-    for (auto& byte : v)
-    {
-        std::cout << "0x" << std::hex << std::setw(2) << std::setfill('0') << (int)byte << " ";
-    }
-    std::cout << std::endl;
-}
+    for (auto& byte : v)
+    {
+        std::cout << "0x" << std::hex << std::setw(2) << std::setfill('0') << (int)byte << " ";
+    }
+    std::cout << std::endl;
+}
 

Output:

0xa2 0x67 0x63 0x6f 0x6d 0x70 0x61 0x63 0x74 0xf5 0x66 0x73 0x63 0x68 0x65 0x6d 0x61 0x00 
-

Version history

  • Added in version 2.0.9.
  • Compact representation of floating-point numbers added in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file +

Version history

  • Added in version 2.0.9.
  • Compact representation of floating-point numbers added in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/to_msgpack/index.html b/api/basic_json/to_msgpack/index.html index 423b8da9a..49dab03a6 100644 --- a/api/basic_json/to_msgpack/index.html +++ b/api/basic_json/to_msgpack/index.html @@ -1,30 +1,30 @@ - to_msgpack - JSON for Modern C++
Skip to content

nlohmann::basic_json::to_msgpack

// (1)
-static std::vector<std::uint8_t> to_msgpack(const basic_json& j);
+ to_msgpack - JSON for Modern C++       

nlohmann::basic_json::to_msgpack

// (1)
+static std::vector<std::uint8_t> to_msgpack(const basic_json& j);
 
 // (2)
-static void to_msgpack(const basic_json& j, detail::output_adapter<std::uint8_t> o);
-static void to_msgpack(const basic_json& j, detail::output_adapter<char> o);
-

Serializes a given JSON value j to a byte vector using the MessagePack serialization format. MessagePack 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 MessagePack serialization.
  2. Writes the MessagePack serialization to an output adapter.

The exact mapping and its limitations is described on a dedicated page.

Parameters

j (in)
JSON value to serialize
o (in)
output adapter to write serialization to

Return value

  1. MessagePack 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 MessagePack format.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+static void to_msgpack(const basic_json& j, detail::output_adapter<std::uint8_t> o);
+static void to_msgpack(const basic_json& j, detail::output_adapter<char> o);
+

Serializes a given JSON value j to a byte vector using the MessagePack serialization format. MessagePack 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 MessagePack serialization.
  2. Writes the MessagePack serialization to an output adapter.

The exact mapping and its limitations is described on a dedicated page.

Parameters

j (in)
JSON value to serialize
o (in)
output adapter to write serialization to

Return value

  1. MessagePack 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 MessagePack format.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
+int main()
+{
     // create a JSON value
-    json j = R"({"compact": true, "schema": 0})"_json;
+    json j = R"({"compact": true, "schema": 0})"_json;
 
     // serialize it to MessagePack
-    std::vector<std::uint8_t> v = json::to_msgpack(j);
+    std::vector<std::uint8_t> v = json::to_msgpack(j);
 
     // print the vector content
-    for (auto& byte : v)
-    {
-        std::cout << "0x" << std::hex << std::setw(2) << std::setfill('0') << (int)byte << " ";
-    }
-    std::cout << std::endl;
-}
+    for (auto& byte : v)
+    {
+        std::cout << "0x" << std::hex << std::setw(2) << std::setfill('0') << (int)byte << " ";
+    }
+    std::cout << std::endl;
+}
 

Output:

0x82 0xa7 0x63 0x6f 0x6d 0x70 0x61 0x63 0x74 0xc3 0xa6 0x73 0x63 0x68 0x65 0x6d 0x61 0x00 
-

Version history

  • Added in version 2.0.9.

Last update: May 1, 2022
\ No newline at end of file +

Version history

  • Added in version 2.0.9.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/to_string/index.html b/api/basic_json/to_string/index.html index 7703d53c0..3a1e2400a 100644 --- a/api/basic_json/to_string/index.html +++ b/api/basic_json/to_string/index.html @@ -1,31 +1,31 @@ - to_string - JSON for Modern C++
Skip to content

to_string(basic_json)

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

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 if a string stored inside the JSON value is not UTF-8 encoded

Complexity

Linear.

Possible implementation

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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ to_string - JSON for Modern C++       

to_string(basic_json)

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

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 if a string stored inside the JSON value is not UTF-8 encoded

Complexity

Linear.

Possible implementation

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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using std::to_string;
+using json = nlohmann::json;
+using std::to_string;
 
-int main()
-{
+int main()
+{
     // create values
-    json j = {{"one", 1}, {"two", 2}};
-    int i = 42;
+    json j = {{"one", 1}, {"two", 2}};
+    int i = 42;
 
     // use ADL to select best to_string function
     auto j_str = to_string(j);  // calling nlohmann::to_string
     auto i_str = to_string(i);  // calling std::to_string
 
     // serialize without indentation
-    std::cout << j_str << "\n\n"
-              << i_str << std::endl;
-}
-

Output:

{"one":1,"two":2}
+    std::cout << j_str << "\n\n"
+              << i_str << std::endl;
+}
+

Output:

{"one":1,"two":2}
 
-42
-

See also

Version history

Added in version 3.7.0.


Last update: May 1, 2022
\ No newline at end of file +42 +

See also

Version history

Added in version 3.7.0.


Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/to_ubjson/index.html b/api/basic_json/to_ubjson/index.html index 8b50b709d..af3838dcc 100644 --- a/api/basic_json/to_ubjson/index.html +++ b/api/basic_json/to_ubjson/index.html @@ -1,79 +1,79 @@ - to_ubjson - JSON for Modern C++
Skip to content

nlohmann::basic_json::to_ubjson

// (1)
-static std::vector<std::uint8_t> to_ubjson(const basic_json& j,
-                                           const bool use_size = false,
-                                           const bool use_type = false);
+ to_ubjson - JSON for Modern C++       

nlohmann::basic_json::to_ubjson

// (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.

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, false by default.
use_type (in)
whether to add type annotations to container types (must be combined with use_size = true); optional, 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.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+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.

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, false by default.
use_type (in)
whether to add type annotations to container types (must be combined with use_size = true); optional, 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.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
 // function to print UBJSON's diagnostic format
-void print_byte(uint8_t byte)
-{
-    if (32 < byte and byte < 128)
-    {
-        std::cout << (char)byte;
-    }
-    else
-    {
-        std::cout << (int)byte;
-    }
-}
+void print_byte(uint8_t byte)
+{
+    if (32 < byte and byte < 128)
+    {
+        std::cout << (char)byte;
+    }
+    else
+    {
+        std::cout << (int)byte;
+    }
+}
 
-int main()
-{
+int main()
+{
     // create a JSON value
-    json j = R"({"compact": true, "schema": false})"_json;
+    json j = R"({"compact": true, "schema": false})"_json;
 
     // serialize it to UBJSON
-    std::vector<std::uint8_t> v = json::to_ubjson(j);
+    std::vector<std::uint8_t> v = json::to_ubjson(j);
 
     // print the vector content
-    for (auto& byte : v)
-    {
-        print_byte(byte);
-    }
-    std::cout << std::endl;
+    for (auto& byte : v)
+    {
+        print_byte(byte);
+    }
+    std::cout << std::endl;
 
     // create an array of numbers
-    json array = {1, 2, 3, 4, 5, 6, 7, 8};
+    json array = {1, 2, 3, 4, 5, 6, 7, 8};
 
     // serialize it to UBJSON using default representation
-    std::vector<std::uint8_t> v_array = json::to_ubjson(array);
+    std::vector<std::uint8_t> v_array = json::to_ubjson(array);
     // serialize it to UBJSON using size optimization
-    std::vector<std::uint8_t> v_array_size = json::to_ubjson(array, true);
+    std::vector<std::uint8_t> v_array_size = json::to_ubjson(array, true);
     // serialize it to UBJSON using type optimization
-    std::vector<std::uint8_t> v_array_size_and_type = json::to_ubjson(array, true, true);
+    std::vector<std::uint8_t> v_array_size_and_type = json::to_ubjson(array, true, true);
 
     // print the vector contents
-    for (auto& byte : v_array)
-    {
-        print_byte(byte);
-    }
-    std::cout << std::endl;
+    for (auto& byte : v_array)
+    {
+        print_byte(byte);
+    }
+    std::cout << std::endl;
 
-    for (auto& byte : v_array_size)
-    {
-        print_byte(byte);
-    }
-    std::cout << std::endl;
+    for (auto& byte : v_array_size)
+    {
+        print_byte(byte);
+    }
+    std::cout << std::endl;
 
-    for (auto& byte : v_array_size_and_type)
-    {
-        print_byte(byte);
-    }
-    std::cout << std::endl;
-}
-

Output:

{i7compactTi6schemaF}
-[i1i2i3i4i5i6i7i8]
-[#i8i1i2i3i4i5i6i7i8
-[$i#i812345678
-

Version history

  • Added in version 3.1.0.

Last update: May 1, 2022
\ No newline at end of file + for (auto& byte : v_array_size_and_type) + { + print_byte(byte); + } + std::cout << std::endl; +} +

Output:

{i7compactTi6schemaF}
+[i1i2i3i4i5i6i7i8]
+[#i8i1i2i3i4i5i6i7i8
+[$i#i812345678
+

Version history

  • Added in version 3.1.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/type/index.html b/api/basic_json/type/index.html index f7c3fc09f..02d1e358b 100644 --- a/api/basic_json/type/index.html +++ b/api/basic_json/type/index.html @@ -1,38 +1,38 @@ - type - JSON for Modern C++
Skip to content

nlohmann::basic_json::type

constexpr value_t type() const noexcept;
-

Return the type of the JSON value as a value from the value_t enumeration.

Return value

the type of the JSON value

Value type return value
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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ type - JSON for Modern C++       

nlohmann::basic_json::type

constexpr value_t type() const noexcept;
+

Return the type of the JSON value as a value from the value_t enumeration.

Return value

the type of the JSON value

Value type return value
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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = -17;
-    json j_number_unsigned = 42u;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = -17;
+    json j_number_unsigned = 42u;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
 
     // call type()
-    std::cout << std::boolalpha;
-    std::cout << (j_null.type() == json::value_t::null) << '\n';
-    std::cout << (j_boolean.type() == json::value_t::boolean) << '\n';
-    std::cout << (j_number_integer.type() == json::value_t::number_integer) << '\n';
-    std::cout << (j_number_unsigned.type() == json::value_t::number_unsigned) << '\n';
-    std::cout << (j_number_float.type() == json::value_t::number_float) << '\n';
-    std::cout << (j_object.type() == json::value_t::object) << '\n';
-    std::cout << (j_array.type() == json::value_t::array) << '\n';
-    std::cout << (j_string.type() == json::value_t::string) << '\n';
-}
-

Output:

true
-true
-true
-true
-true
-true
-true
-true
-

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.

Last update: May 1, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << (j_null.type() == json::value_t::null) << '\n'; + std::cout << (j_boolean.type() == json::value_t::boolean) << '\n'; + std::cout << (j_number_integer.type() == json::value_t::number_integer) << '\n'; + std::cout << (j_number_unsigned.type() == json::value_t::number_unsigned) << '\n'; + std::cout << (j_number_float.type() == json::value_t::number_float) << '\n'; + std::cout << (j_object.type() == json::value_t::object) << '\n'; + std::cout << (j_array.type() == json::value_t::array) << '\n'; + std::cout << (j_string.type() == json::value_t::string) << '\n'; +} +

Output:

true
+true
+true
+true
+true
+true
+true
+true
+

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.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/type_error/index.html b/api/basic_json/type_error/index.html index c0bc8b062..5849bac99 100644 --- a/api/basic_json/type_error/index.html +++ b/api/basic_json/type_error/index.html @@ -1,24 +1,24 @@ - type_error - JSON for Modern C++
Skip to content

nlohmann::basic_json::type_error

class type_error : public exception;
-

This exception is thrown in case of a type error; that is, a library function is executed on a JSON value whose type does not match the expected semantics.

Exceptions have ids 3xx (see list of type errors).

uml diagram

Member functions

  • what - returns explanatory string

Member variables

  • id - the id of the exception

Examples

Example

The following code shows how a type_error exception can be caught.

#include <iostream>
-#include <nlohmann/json.hpp>
+ type_error - JSON for Modern C++       

nlohmann::basic_json::type_error

class type_error : public exception;
+

This exception is thrown in case of a type error; that is, a library function is executed on a JSON value whose type does not match the expected semantics.

Exceptions have ids 3xx (see list of type errors).

uml diagram

Member functions

  • what - returns explanatory string

Member variables

  • id - the id of the exception

Examples

Example

The following code shows how a type_error exception can be caught.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    try
-    {
+int main()
+{
+    try
+    {
         // calling push_back() on a string value
-        json j = "string";
-        j.push_back("another string");
-    }
-    catch (const json::type_error& e)
-    {
+        json j = "string";
+        j.push_back("another string");
+    }
+    catch (const json::type_error& e)
+    {
         // output exception information
-        std::cout << "message: " << e.what() << '\n'
-                  << "exception id: " << e.id << std::endl;
-    }
-}
-

Output:

message: [json.exception.type_error.308] cannot use push_back() with string
-exception id: 308
-

See also

Version history

  • Since version 3.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << "message: " << e.what() << '\n' + << "exception id: " << e.id << std::endl; + } +} +

Output:

message: [json.exception.type_error.308] cannot use push_back() with string
+exception id: 308
+

See also

Version history

  • Since version 3.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/type_name/index.html b/api/basic_json/type_name/index.html index 8b77cb41c..5c7549e19 100644 --- a/api/basic_json/type_name/index.html +++ b/api/basic_json/type_name/index.html @@ -1,37 +1,37 @@ - type_name - JSON for Modern C++
Skip to content

nlohmann::basic_json::type_name

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 type return value
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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ type_name - JSON for Modern C++       

nlohmann::basic_json::type_name

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 type return value
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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = -17;
-    json j_number_unsigned = 42u;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = -17;
+    json j_number_unsigned = 42u;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
 
     // call type_name()
-    std::cout << j_null << " is a " << j_null.type_name() << '\n';
-    std::cout << j_boolean << " is a " << j_boolean.type_name() << '\n';
-    std::cout << j_number_integer << " is a " << j_number_integer.type_name() << '\n';
-    std::cout << j_number_unsigned << " is a " << j_number_unsigned.type_name() << '\n';
-    std::cout << j_number_float << " is a " << j_number_float.type_name() << '\n';
-    std::cout << j_object << " is an " << j_object.type_name() << '\n';
-    std::cout << j_array << " is an " << j_array.type_name() << '\n';
-    std::cout << j_string << " is a " << j_string.type_name() << '\n';
-}
-

Output:

null is a null
-true is a boolean
--17 is a number
-42 is a number
-23.42 is a number
-{"one":1,"two":2} is an object
-[1,2,4,8,16] is an array
-"Hello, world" is a string
-

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.

Last update: May 1, 2022
\ No newline at end of file + std::cout << j_null << " is a " << j_null.type_name() << '\n'; + std::cout << j_boolean << " is a " << j_boolean.type_name() << '\n'; + std::cout << j_number_integer << " is a " << j_number_integer.type_name() << '\n'; + std::cout << j_number_unsigned << " is a " << j_number_unsigned.type_name() << '\n'; + std::cout << j_number_float << " is a " << j_number_float.type_name() << '\n'; + std::cout << j_object << " is an " << j_object.type_name() << '\n'; + std::cout << j_array << " is an " << j_array.type_name() << '\n'; + std::cout << j_string << " is a " << j_string.type_name() << '\n'; +} +

Output:

null is a null
+true is a boolean
+-17 is a number
+42 is a number
+23.42 is a number
+{"one":1,"two":2} is an object
+[1,2,4,8,16] is an array
+"Hello, world" is a string
+

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.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/unflatten/index.html b/api/basic_json/unflatten/index.html index f6c5fc78e..5fd994698 100644 --- a/api/basic_json/unflatten/index.html +++ b/api/basic_json/unflatten/index.html @@ -1,46 +1,46 @@ - unflatten - JSON for Modern C++
Skip to content

nlohmann::basic_json::unflatten

basic_json unflatten() const;
-

The function restores the arbitrary nesting of a JSON value that has been flattened before using the flatten() function. The JSON value must meet certain constraints:

  1. The value must be an object.
  2. The keys must be JSON pointers (see RFC 6901)
  3. The mapped values must be primitive JSON types.

Return value

the original JSON from a flattened version

Exception safety

Strong exception safety: if an exception occurs, the original value stays intact.

Exceptions

The function can throw the following exceptions:

Complexity

Linear in the size the JSON value.

Notes

Empty objects and arrays are flattened by flatten() to null values and can not unflattened to their original type. Apart from this example, for a JSON value j, the following is always true: j == j.flatten().unflatten().

Examples

Example

The following code shows how a flattened JSON object is unflattened into the original nested JSON object.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+ unflatten - JSON for Modern C++       

nlohmann::basic_json::unflatten

basic_json unflatten() const;
+

The function restores the arbitrary nesting of a JSON value that has been flattened before using the flatten() function. The JSON value must meet certain constraints:

  1. The value must be an object.
  2. The keys must be JSON pointers (see RFC 6901)
  3. The mapped values must be primitive JSON types.

Return value

the original JSON from a flattened version

Exception safety

Strong exception safety: if an exception occurs, the original value stays intact.

Exceptions

The function can throw the following exceptions:

Complexity

Linear in the size the JSON value.

Notes

Empty objects and arrays are flattened by flatten() to null values and can not unflattened to their original type. Apart from this example, for a JSON value j, the following is always true: j == j.flatten().unflatten().

Examples

Example

The following code shows how a flattened JSON object is unflattened into the original nested JSON object.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON value
-    json j_flattened =
-    {
-        {"/answer/everything", 42},
-        {"/happy", true},
-        {"/list/0", 1},
-        {"/list/1", 0},
-        {"/list/2", 2},
-        {"/name", "Niels"},
-        {"/nothing", nullptr},
-        {"/object/currency", "USD"},
-        {"/object/value", 42.99},
-        {"/pi", 3.141}
-    };
+    json j_flattened =
+    {
+        {"/answer/everything", 42},
+        {"/happy", true},
+        {"/list/0", 1},
+        {"/list/1", 0},
+        {"/list/2", 2},
+        {"/name", "Niels"},
+        {"/nothing", nullptr},
+        {"/object/currency", "USD"},
+        {"/object/value", 42.99},
+        {"/pi", 3.141}
+    };
 
     // call unflatten()
-    std::cout << std::setw(4) << j_flattened.unflatten() << '\n';
-}
-

Output:

{
-    "answer": {
-        "everything": 42
-    },
-    "happy": true,
-    "list": [
-        1,
-        0,
-        2
-    ],
-    "name": "Niels",
-    "nothing": null,
-    "object": {
-        "currency": "USD",
-        "value": 42.99
-    },
-    "pi": 3.141
-}
-

See also

Version history

  • Added in version 2.0.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << std::setw(4) << j_flattened.unflatten() << '\n'; +} +

Output:

{
+    "answer": {
+        "everything": 42
+    },
+    "happy": true,
+    "list": [
+        1,
+        0,
+        2
+    ],
+    "name": "Niels",
+    "nothing": null,
+    "object": {
+        "currency": "USD",
+        "value": 42.99
+    },
+    "pi": 3.141
+}
+

See also

Version history

  • Added in version 2.0.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/basic_json/update/index.html b/api/basic_json/update/index.html index 715bc8909..94c98380d 100644 --- a/api/basic_json/update/index.html +++ b/api/basic_json/update/index.html @@ -1,113 +1,113 @@ - update - JSON for Modern C++
Skip to content

nlohmann::basic_json::update

// (1)
-void update(const_reference j, bool merge_objects = false);
+ update - JSON for Modern C++       

nlohmann::basic_json::update

// (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 false (default), existing keys are overwritten. When merge_objects is true, recursively merges objects with common keys.

The function is motivated by Python's dict.update function.

Parameters

j (in)
JSON object to read values from
merge_objects (in)
when true, existing keys are not overwritten, but contents of objects are merged recursively (default: 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 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 if called on JSON values other than objects; example: "cannot use update() with string"
    • Throws invalid_iterator.202 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 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.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+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 false (default), existing keys are overwritten. When merge_objects is true, recursively merges objects with common keys.

The function is motivated by Python's dict.update function.

Parameters

j (in)
JSON object to read values from
merge_objects (in)
when true, existing keys are not overwritten, but contents of objects are merged recursively (default: 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 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 if called on JSON values other than objects; example: "cannot use update() with string"
    • Throws invalid_iterator.202 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 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.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
+int main()
+{
     // create two JSON objects
-    json o1 = R"( {"color": "red", "price": 17.99, "names": {"de": "Flugzeug"}} )"_json;
-    json o2 = R"( {"color": "blue", "speed": 100, "names": {"en": "plane"}} )"_json;
-    json o3 = o1;
+    json o1 = R"( {"color": "red", "price": 17.99, "names": {"de": "Flugzeug"}} )"_json;
+    json o2 = R"( {"color": "blue", "speed": 100, "names": {"en": "plane"}} )"_json;
+    json o3 = o1;
 
     // add all keys from o2 to o1 (updating "color", replacing "names")
-    o1.update(o2);
+    o1.update(o2);
 
     // add all keys from o2 to o1 (updating "color", merging "names")
-    o3.update(o2, true);
+    o3.update(o2, true);
 
     // output updated object o1 and o3
-    std::cout << std::setw(2) << o1 << '\n';
-    std::cout << std::setw(2) << o3 << '\n';
-}
-

Output:

{
-  "color": "blue",
-  "names": {
-    "en": "plane"
-  },
-  "price": 17.99,
-  "speed": 100
-}
-{
-  "color": "blue",
-  "names": {
-    "de": "Flugzeug",
-    "en": "plane"
-  },
-  "price": 17.99,
-  "speed": 100
-}
-
Example

The example shows how update() is used.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+    std::cout << std::setw(2) << o1 << '\n';
+    std::cout << std::setw(2) << o3 << '\n';
+}
+

Output:

{
+  "color": "blue",
+  "names": {
+    "en": "plane"
+  },
+  "price": 17.99,
+  "speed": 100
+}
+{
+  "color": "blue",
+  "names": {
+    "de": "Flugzeug",
+    "en": "plane"
+  },
+  "price": 17.99,
+  "speed": 100
+}
+
Example

The example shows how update() is used.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
+int main()
+{
     // create two JSON objects
-    json o1 = R"( {"color": "red", "price": 17.99, "names": {"de": "Flugzeug"}} )"_json;
-    json o2 = R"( {"color": "blue", "speed": 100, "names": {"en": "plane"}} )"_json;
-    json o3 = o1;
+    json o1 = R"( {"color": "red", "price": 17.99, "names": {"de": "Flugzeug"}} )"_json;
+    json o2 = R"( {"color": "blue", "speed": 100, "names": {"en": "plane"}} )"_json;
+    json o3 = o1;
 
     // add all keys from o2 to o1 (updating "color", replacing "names")
-    o1.update(o2.begin(), o2.end());
+    o1.update(o2.begin(), o2.end());
 
     // add all keys from o2 to o1 (updating "color", merging "names")
-    o3.update(o2.begin(), o2.end(), true);
+    o3.update(o2.begin(), o2.end(), true);
 
     // output updated object o1 and o3
-    std::cout << std::setw(2) << o1 << '\n';
-    std::cout << std::setw(2) << o3 << '\n';
-}
-

Output:

{
-  "color": "blue",
-  "names": {
-    "en": "plane"
-  },
-  "price": 17.99,
-  "speed": 100
-}
-{
-  "color": "blue",
-  "names": {
-    "de": "Flugzeug",
-    "en": "plane"
-  },
-  "price": 17.99,
-  "speed": 100
-}
-
Example

One common use case for this function is the handling of user settings. Assume your application can be configured in some aspects:

{
-    "color": "red",
-    "active": true,
-    "name": {"de": "Maus", "en": "mouse"}
-}
-

The user may override the default settings selectively:

{
-    "color": "blue",
-    "name": {"es": "ratón"},
-}
-

Then update manages the merging of default settings and user settings:

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:

{
-    "color": "blue",
-    "active": true,
-    "name": {"es": "ratón"}
-}
-

Note existing keys were just overwritten. To merge objects, merge_objects setting should be set to true:

auto user_settings = json::parse("config.json");
-auto effective_settings = get_default_settings();
-effective_settings.update(user_settings, true);
-
{
-    "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.

Last update: September 17, 2022
\ No newline at end of file + std::cout << std::setw(2) << o1 << '\n'; + std::cout << std::setw(2) << o3 << '\n'; +} +

Output:

{
+  "color": "blue",
+  "names": {
+    "en": "plane"
+  },
+  "price": 17.99,
+  "speed": 100
+}
+{
+  "color": "blue",
+  "names": {
+    "de": "Flugzeug",
+    "en": "plane"
+  },
+  "price": 17.99,
+  "speed": 100
+}
+
Example

One common use case for this function is the handling of user settings. Assume your application can be configured in some aspects:

{
+    "color": "red",
+    "active": true,
+    "name": {"de": "Maus", "en": "mouse"}
+}
+

The user may override the default settings selectively:

{
+    "color": "blue",
+    "name": {"es": "ratón"},
+}
+

Then update manages the merging of default settings and user settings:

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:

{
+    "color": "blue",
+    "active": true,
+    "name": {"es": "ratón"}
+}
+

Note existing keys were just overwritten. To merge objects, merge_objects setting should be set to true:

auto user_settings = json::parse("config.json");
+auto effective_settings = get_default_settings();
+effective_settings.update(user_settings, true);
+
{
+    "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.

Last update: September 17, 2022
\ No newline at end of file diff --git a/api/basic_json/value/index.html b/api/basic_json/value/index.html index d92f3023c..3167f5c9d 100644 --- a/api/basic_json/value/index.html +++ b/api/basic_json/value/index.html @@ -1,121 +1,121 @@ - value - JSON for Modern C++
Skip to content

nlohmann::basic_json::value

// (1)
-template<class ValueType>
-ValueType value(const typename object_t::key_type& key,
-                ValueType&& default_value) const;
+ value - JSON for Modern C++       

nlohmann::basic_json::value

// (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;
+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

    try {
    -   return at(key);
    -} catch(out_of_range) {
    -   return default_value;
    -}
    -

  2. See 1. This overload is only available if KeyType is comparable with typename object_t::key_type and 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

    try {
    -   return at(ptr);
    -} catch(out_of_range) {
    -   return default_value;
    -}
    -

Differences to at and operator[]

  • Unlike at, this function does not throw if the given key/ptr was not found.
  • Unlike operator[], 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 that is comparable with string_t using object_comparator_t. This can also be a string view (C++17).
ValueType
type compatible to JSON values, for instance int for JSON integer numbers, bool for JSON booleans, or 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 if default_value does not match the type of the value at key
    • Throws type_error.306 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 if default_value does not match the type of the value at ptr
    • Throws type_error.306 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: (1) access specified object element with default value

The example below shows how object elements can be queried with a default value.

#include <iostream>
-#include <nlohmann/json.hpp>
+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

    try {
    +   return at(key);
    +} catch(out_of_range) {
    +   return default_value;
    +}
    +

  2. See 1. This overload is only available if KeyType is comparable with typename object_t::key_type and 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

    try {
    +   return at(ptr);
    +} catch(out_of_range) {
    +   return default_value;
    +}
    +

Differences to at and operator[]

  • Unlike at, this function does not throw if the given key/ptr was not found.
  • Unlike operator[], 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 that is comparable with string_t using object_comparator_t. This can also be a string view (C++17).
ValueType
type compatible to JSON values, for instance int for JSON integer numbers, bool for JSON booleans, or 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 if default_value does not match the type of the value at key
    • Throws type_error.306 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 if default_value does not match the type of the value at ptr
    • Throws type_error.306 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: (1) access specified object element with default value

The example below shows how object elements can be queried with a default value.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON object with different entry types
-    json j =
-    {
-        {"integer", 1},
-        {"floating", 42.23},
-        {"string", "hello world"},
-        {"boolean", true},
-        {"object", {{"key1", 1}, {"key2", 2}}},
-        {"array", {1, 2, 3}}
-    };
+    json j =
+    {
+        {"integer", 1},
+        {"floating", 42.23},
+        {"string", "hello world"},
+        {"boolean", true},
+        {"object", {{"key1", 1}, {"key2", 2}}},
+        {"array", {1, 2, 3}}
+    };
 
     // access existing values
-    int v_integer = j.value("integer", 0);
-    double v_floating = j.value("floating", 47.11);
+    int v_integer = j.value("integer", 0);
+    double v_floating = j.value("floating", 47.11);
 
     // access nonexisting values and rely on default value
-    std::string v_string = j.value("nonexisting", "oops");
-    bool v_boolean = j.value("nonexisting", false);
+    std::string v_string = j.value("nonexisting", "oops");
+    bool v_boolean = j.value("nonexisting", false);
 
     // output values
-    std::cout << std::boolalpha << v_integer << " " << v_floating
-              << " " << v_string << " " << v_boolean << "\n";
-}
-

Output:

1 42.23 oops false
-
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.

#include <iostream>
-#include <string_view>
-#include <nlohmann/json.hpp>
+    std::cout << std::boolalpha << v_integer << " " << v_floating
+              << " " << v_string << " " << v_boolean << "\n";
+}
+

Output:

1 42.23 oops false
+
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.

#include <iostream>
+#include <string_view>
+#include <nlohmann/json.hpp>
 
-using namespace std::string_view_literals;
-using json = nlohmann::json;
+using namespace std::string_view_literals;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON object with different entry types
-    json j =
-    {
-        {"integer", 1},
-        {"floating", 42.23},
-        {"string", "hello world"},
-        {"boolean", true},
-        {"object", {{"key1", 1}, {"key2", 2}}},
-        {"array", {1, 2, 3}}
-    };
+    json j =
+    {
+        {"integer", 1},
+        {"floating", 42.23},
+        {"string", "hello world"},
+        {"boolean", true},
+        {"object", {{"key1", 1}, {"key2", 2}}},
+        {"array", {1, 2, 3}}
+    };
 
     // access existing values
-    int v_integer = j.value("integer"sv, 0);
-    double v_floating = j.value("floating"sv, 47.11);
+    int v_integer = j.value("integer"sv, 0);
+    double v_floating = j.value("floating"sv, 47.11);
 
     // access nonexisting values and rely on default value
-    std::string v_string = j.value("nonexisting"sv, "oops");
-    bool v_boolean = j.value("nonexisting"sv, false);
+    std::string v_string = j.value("nonexisting"sv, "oops");
+    bool v_boolean = j.value("nonexisting"sv, false);
 
     // output values
-    std::cout << std::boolalpha << v_integer << " " << v_floating
-              << " " << v_string << " " << v_boolean << "\n";
-}
-

Output:

1 42.23 oops false
-
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.

#include <iostream>
-#include <nlohmann/json.hpp>
+    std::cout << std::boolalpha << v_integer << " " << v_floating
+              << " " << v_string << " " << v_boolean << "\n";
+}
+

Output:

1 42.23 oops false
+
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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
+int main()
+{
     // create a JSON object with different entry types
-    json j =
-    {
-        {"integer", 1},
-        {"floating", 42.23},
-        {"string", "hello world"},
-        {"boolean", true},
-        {"object", {{"key1", 1}, {"key2", 2}}},
-        {"array", {1, 2, 3}}
-    };
+    json j =
+    {
+        {"integer", 1},
+        {"floating", 42.23},
+        {"string", "hello world"},
+        {"boolean", true},
+        {"object", {{"key1", 1}, {"key2", 2}}},
+        {"array", {1, 2, 3}}
+    };
 
     // access existing values
-    int v_integer = j.value("/integer"_json_pointer, 0);
-    double v_floating = j.value("/floating"_json_pointer, 47.11);
+    int v_integer = j.value("/integer"_json_pointer, 0);
+    double v_floating = j.value("/floating"_json_pointer, 47.11);
 
     // access nonexisting values and rely on default value
-    std::string v_string = j.value("/nonexisting"_json_pointer, "oops");
-    bool v_boolean = j.value("/nonexisting"_json_pointer, false);
+    std::string v_string = j.value("/nonexisting"_json_pointer, "oops");
+    bool v_boolean = j.value("/nonexisting"_json_pointer, false);
 
     // output values
-    std::cout << std::boolalpha << v_integer << " " << v_floating
-              << " " << v_string << " " << v_boolean << "\n";
-}
-

Output:

1 42.23 oops false
-

See also

  • see at for access by reference with range checking
  • see operator[] 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.

Last update: August 7, 2022
\ No newline at end of file + std::cout << std::boolalpha << v_integer << " " << v_floating + << " " << v_string << " " << v_boolean << "\n"; +} +

Output:

1 42.23 oops false
+

See also

  • see at for access by reference with range checking
  • see operator[] 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.

Last update: August 7, 2022
\ No newline at end of file diff --git a/api/basic_json/value_t/index.html b/api/basic_json/value_t/index.html index a3e5a4b88..0f7313c75 100644 --- a/api/basic_json/value_t/index.html +++ b/api/basic_json/value_t/index.html @@ -1,49 +1,49 @@ - value_t - JSON for Modern C++
Skip to content

nlohmann::basic_json::value_t

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_object, is_array, is_string, is_boolean, is_number (with is_number_integer, is_number_unsigned, and is_number_float), is_discarded, is_binary, is_primitive, and is_structured rely on it.

Notes

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.

Types of numbers

There are three enumerators for numbers (number_integer, number_unsigned, and number_float) to distinguish between different types of numbers:

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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ value_t - JSON for Modern C++       

nlohmann::basic_json::value_t

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_object, is_array, is_string, is_boolean, is_number (with is_number_integer, is_number_unsigned, and is_number_float), is_discarded, is_binary, is_primitive, and is_structured rely on it.

Notes

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.

Types of numbers

There are three enumerators for numbers (number_integer, number_unsigned, and number_float) to distinguish between different types of numbers:

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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_null;
-    json j_boolean = true;
-    json j_number_integer = -17;
-    json j_number_unsigned = 42u;
-    json j_number_float = 23.42;
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
-    json j_string = "Hello, world";
+    json j_null;
+    json j_boolean = true;
+    json j_number_integer = -17;
+    json j_number_unsigned = 42u;
+    json j_number_float = 23.42;
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
+    json j_string = "Hello, world";
 
     // call type()
-    std::cout << std::boolalpha;
-    std::cout << (j_null.type() == json::value_t::null) << '\n';
-    std::cout << (j_boolean.type() == json::value_t::boolean) << '\n';
-    std::cout << (j_number_integer.type() == json::value_t::number_integer) << '\n';
-    std::cout << (j_number_unsigned.type() == json::value_t::number_unsigned) << '\n';
-    std::cout << (j_number_float.type() == json::value_t::number_float) << '\n';
-    std::cout << (j_object.type() == json::value_t::object) << '\n';
-    std::cout << (j_array.type() == json::value_t::array) << '\n';
-    std::cout << (j_string.type() == json::value_t::string) << '\n';
-}
-

Output:

true
-true
-true
-true
-true
-true
-true
-true
-

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.

Last update: August 5, 2022
\ No newline at end of file + std::cout << std::boolalpha; + std::cout << (j_null.type() == json::value_t::null) << '\n'; + std::cout << (j_boolean.type() == json::value_t::boolean) << '\n'; + std::cout << (j_number_integer.type() == json::value_t::number_integer) << '\n'; + std::cout << (j_number_unsigned.type() == json::value_t::number_unsigned) << '\n'; + std::cout << (j_number_float.type() == json::value_t::number_float) << '\n'; + std::cout << (j_object.type() == json::value_t::object) << '\n'; + std::cout << (j_array.type() == json::value_t::array) << '\n'; + std::cout << (j_string.type() == json::value_t::string) << '\n'; +} +

Output:

true
+true
+true
+true
+true
+true
+true
+true
+

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.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/basic_json/~basic_json/index.html b/api/basic_json/~basic_json/index.html index b7580938f..1cedf672f 100644 --- a/api/basic_json/~basic_json/index.html +++ b/api/basic_json/~basic_json/index.html @@ -1,2 +1,2 @@ - (Destructor) - JSON for Modern C++
Skip to content

nlohmann::basic_json::~basic_json

~basic_json() noexcept;
-

Destroys the JSON value and frees all allocated memory.

Exception safety

No-throw guarantee: this member function never throws exceptions.

Complexity

Linear.

Version history

  • Added in version 1.0.0.

Last update: August 5, 2022
\ No newline at end of file + (Destructor) - JSON for Modern C++
Skip to content

nlohmann::basic_json::~basic_json

~basic_json() noexcept;
+

Destroys the JSON value and frees all allocated memory.

Exception safety

No-throw guarantee: this member function never throws exceptions.

Complexity

Linear.

Version history

  • Added in version 1.0.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/byte_container_with_subtype/byte_container_with_subtype/index.html b/api/byte_container_with_subtype/byte_container_with_subtype/index.html index 660b74848..5015cc19a 100644 --- a/api/byte_container_with_subtype/byte_container_with_subtype/index.html +++ b/api/byte_container_with_subtype/byte_container_with_subtype/index.html @@ -1,37 +1,37 @@ - (constructor) - JSON for Modern C++
Skip to content

nlohmann::byte_container_with_subtype::byte_container_with_subtype

// (1)
-byte_container_with_subtype();
+ (constructor) - JSON for Modern C++       

nlohmann::byte_container_with_subtype::byte_container_with_subtype

// (1)
+byte_container_with_subtype();
 
 // (2)
-byte_container_with_subtype(const container_type& container);
-byte_container_with_subtype(container_type&& container);
+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.

#include <iostream>
-#include <nlohmann/json.hpp>
+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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
 // define a byte container based on std::vector
-using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;
+using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // (1) create empty container
-    auto c1 = byte_container_with_subtype();
+    auto c1 = byte_container_with_subtype();
 
-    std::vector<std::uint8_t> bytes = {{0xca, 0xfe, 0xba, 0xbe}};
+    std::vector<std::uint8_t> bytes = {{0xca, 0xfe, 0xba, 0xbe}};
 
     // (2) create container
-    auto c2 = byte_container_with_subtype(bytes);
+    auto c2 = byte_container_with_subtype(bytes);
 
     // (3) create container with subtype
-    auto c3 = byte_container_with_subtype(bytes, 42);
+    auto c3 = byte_container_with_subtype(bytes, 42);
 
-    std::cout << json(c1) << "\n" << json(c2) << "\n" << json(c3) << std::endl;
-}
-

Output:

{"bytes":[],"subtype":null}
-{"bytes":[202,254,186,190],"subtype":null}
-{"bytes":[202,254,186,190],"subtype":42}
-

Version history

Since version 3.8.0.


Last update: May 17, 2022
\ No newline at end of file + std::cout << json(c1) << "\n" << json(c2) << "\n" << json(c3) << std::endl; +} +

Output:

{"bytes":[],"subtype":null}
+{"bytes":[202,254,186,190],"subtype":null}
+{"bytes":[202,254,186,190],"subtype":42}
+

Version history

Since version 3.8.0.


Last update: May 17, 2022
\ No newline at end of file diff --git a/api/byte_container_with_subtype/clear_subtype/index.html b/api/byte_container_with_subtype/clear_subtype/index.html index 83a2cfd0b..3d1f47591 100644 --- a/api/byte_container_with_subtype/clear_subtype/index.html +++ b/api/byte_container_with_subtype/clear_subtype/index.html @@ -1,25 +1,25 @@ - clear_subtype - JSON for Modern C++
Skip to content

nlohmann::byte_container_with_subtype::clear_subtype

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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ clear_subtype - JSON for Modern C++       

nlohmann::byte_container_with_subtype::clear_subtype

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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
 // define a byte container based on std::vector
-using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;
+using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    std::vector<std::uint8_t> bytes = {{0xca, 0xfe, 0xba, 0xbe}};
+int main()
+{
+    std::vector<std::uint8_t> bytes = {{0xca, 0xfe, 0xba, 0xbe}};
 
     // create container with subtype
-    auto c1 = byte_container_with_subtype(bytes, 42);
+    auto c1 = byte_container_with_subtype(bytes, 42);
 
-    std::cout << "before calling clear_subtype(): " << json(c1) << '\n';
+    std::cout << "before calling clear_subtype(): " << json(c1) << '\n';
 
-    c1.clear_subtype();
+    c1.clear_subtype();
 
-    std::cout << "after calling clear_subtype(): " << json(c1) << '\n';
-}
-

Output:

before calling clear_subtype(): {"bytes":[202,254,186,190],"subtype":42}
-after calling clear_subtype(): {"bytes":[202,254,186,190],"subtype":null}
-

Version history

Since version 3.8.0.


Last update: May 17, 2022
\ No newline at end of file + std::cout << "after calling clear_subtype(): " << json(c1) << '\n'; +} +

Output:

before calling clear_subtype(): {"bytes":[202,254,186,190],"subtype":42}
+after calling clear_subtype(): {"bytes":[202,254,186,190],"subtype":null}
+

Version history

Since version 3.8.0.


Last update: May 17, 2022
\ No newline at end of file diff --git a/api/byte_container_with_subtype/has_subtype/index.html b/api/byte_container_with_subtype/has_subtype/index.html index cc7b751a0..cdf59c099 100644 --- a/api/byte_container_with_subtype/has_subtype/index.html +++ b/api/byte_container_with_subtype/has_subtype/index.html @@ -1,23 +1,23 @@ - has_subtype - JSON for Modern C++
Skip to content

nlohmann::byte_container_with_subtype::has_subtype

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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ has_subtype - JSON for Modern C++       

nlohmann::byte_container_with_subtype::has_subtype

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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
 // define a byte container based on std::vector
-using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;
+using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;
 
-int main()
-{
-    std::vector<std::uint8_t> bytes = {{0xca, 0xfe, 0xba, 0xbe}};
+int main()
+{
+    std::vector<std::uint8_t> bytes = {{0xca, 0xfe, 0xba, 0xbe}};
 
     // create container
-    auto c1 = byte_container_with_subtype(bytes);
+    auto c1 = byte_container_with_subtype(bytes);
 
     // create container with subtype
-    auto c2 = byte_container_with_subtype(bytes, 42);
+    auto c2 = byte_container_with_subtype(bytes, 42);
 
-    std::cout << std::boolalpha << "c1.has_subtype() = " << c1.has_subtype()
-              << "\nc2.has_subtype() = " << c2.has_subtype() << std::endl;
-}
-

Output:

c1.has_subtype() = false
-c2.has_subtype() = true
-

Version history

Since version 3.8.0.


Last update: May 17, 2022
\ No newline at end of file + std::cout << std::boolalpha << "c1.has_subtype() = " << c1.has_subtype() + << "\nc2.has_subtype() = " << c2.has_subtype() << std::endl; +} +

Output:

c1.has_subtype() = false
+c2.has_subtype() = true
+

Version history

Since version 3.8.0.


Last update: May 17, 2022
\ No newline at end of file diff --git a/api/byte_container_with_subtype/index.html b/api/byte_container_with_subtype/index.html index 4419198d0..2b1b11d16 100644 --- a/api/byte_container_with_subtype/index.html +++ b/api/byte_container_with_subtype/index.html @@ -1,3 +1,3 @@ - Overview - JSON for Modern C++
Skip to content

nlohmann::byte_container_with_subtype

template<typename BinaryType>
-class byte_container_with_subtype : public BinaryType;
-

This type extends the template parameter BinaryType provided to basic_json 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 (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 (std::uint64_t)

Member functions

Version history

  • Added in version 3.8.0.
  • Changed type of subtypes to std::uint64_t in 3.10.0.

Last update: May 1, 2022
\ No newline at end of file + Overview - JSON for Modern C++
Skip to content

nlohmann::byte_container_with_subtype

template<typename BinaryType>
+class byte_container_with_subtype : public BinaryType;
+

This type extends the template parameter BinaryType provided to basic_json 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 (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 (std::uint64_t)

Member functions

Version history

  • Added in version 3.8.0.
  • Changed type of subtypes to std::uint64_t in 3.10.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/byte_container_with_subtype/set_subtype/index.html b/api/byte_container_with_subtype/set_subtype/index.html index e8527641e..8ae780ad3 100644 --- a/api/byte_container_with_subtype/set_subtype/index.html +++ b/api/byte_container_with_subtype/set_subtype/index.html @@ -1,26 +1,26 @@ - set_subtype - JSON for Modern C++
Skip to content

nlohmann::byte_container_with_subtype::set_subtype

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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ set_subtype - JSON for Modern C++       

nlohmann::byte_container_with_subtype::set_subtype

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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
 // define a byte container based on std::vector
-using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;
+using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    std::vector<std::uint8_t> bytes = {{0xca, 0xfe, 0xba, 0xbe}};
+int main()
+{
+    std::vector<std::uint8_t> bytes = {{0xca, 0xfe, 0xba, 0xbe}};
 
     // create container without subtype
-    auto c = byte_container_with_subtype(bytes);
+    auto c = byte_container_with_subtype(bytes);
 
-    std::cout << "before calling set_subtype(42): " << json(c) << '\n';
+    std::cout << "before calling set_subtype(42): " << json(c) << '\n';
 
     // set the subtype
-    c.set_subtype(42);
+    c.set_subtype(42);
 
-    std::cout << "after calling set_subtype(42): " << json(c) << '\n';
-}
-

Output:

before calling set_subtype(42): {"bytes":[202,254,186,190],"subtype":null}
-after calling set_subtype(42): {"bytes":[202,254,186,190],"subtype":42}
-

Version history

Since version 3.8.0.


Last update: May 17, 2022
\ No newline at end of file + std::cout << "after calling set_subtype(42): " << json(c) << '\n'; +} +

Output:

before calling set_subtype(42): {"bytes":[202,254,186,190],"subtype":null}
+after calling set_subtype(42): {"bytes":[202,254,186,190],"subtype":42}
+

Version history

Since version 3.8.0.


Last update: May 17, 2022
\ No newline at end of file diff --git a/api/byte_container_with_subtype/subtype/index.html b/api/byte_container_with_subtype/subtype/index.html index 886123912..f66323832 100644 --- a/api/byte_container_with_subtype/subtype/index.html +++ b/api/byte_container_with_subtype/subtype/index.html @@ -1,26 +1,26 @@ - subtype - JSON for Modern C++
Skip to content

nlohmann::byte_container_with_subtype::subtype

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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ subtype - JSON for Modern C++       

nlohmann::byte_container_with_subtype::subtype

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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
 // define a byte container based on std::vector
-using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;
+using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;
 
-int main()
-{
-    std::vector<std::uint8_t> bytes = {{0xca, 0xfe, 0xba, 0xbe}};
+int main()
+{
+    std::vector<std::uint8_t> bytes = {{0xca, 0xfe, 0xba, 0xbe}};
 
     // create container
-    auto c1 = byte_container_with_subtype(bytes);
+    auto c1 = byte_container_with_subtype(bytes);
 
     // create container with subtype
-    auto c2 = byte_container_with_subtype(bytes, 42);
+    auto c2 = byte_container_with_subtype(bytes, 42);
 
-    std::cout << "c1.subtype() = " << c1.subtype()
-              << "\nc2.subtype() = " << c2.subtype() << std::endl;
+    std::cout << "c1.subtype() = " << c1.subtype()
+              << "\nc2.subtype() = " << c2.subtype() << std::endl;
 
     // in case no subtype is set, return special value
-    assert(c1.subtype() == static_cast<byte_container_with_subtype::subtype_type>(-1));
-}
-

Output:

c1.subtype() = 18446744073709551615
-c2.subtype() = 42
-

Version history

  • Added in version 3.8.0
  • Fixed return value to properly return subtype_type(-1) as documented in version 3.10.0.

Last update: May 17, 2022
\ No newline at end of file + assert(c1.subtype() == static_cast<byte_container_with_subtype::subtype_type>(-1)); +} +

Output:

c1.subtype() = 18446744073709551615
+c2.subtype() = 42
+

Version history

  • Added in version 3.8.0
  • Fixed return value to properly return subtype_type(-1) as documented in version 3.10.0.

Last update: May 17, 2022
\ No newline at end of file diff --git a/api/json/index.html b/api/json/index.html index 3d369663c..f33355284 100644 --- a/api/json/index.html +++ b/api/json/index.html @@ -1,68 +1,68 @@ - json - JSON for Modern C++
Skip to content

nlohmann::json

using json = basic_json<>;
-

This type is the default specialization of the basic_json class which uses the standard template types.

Examples

Example

The example below demonstrates how to use the type nlohmann::json.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+ json - JSON for Modern C++       

nlohmann::json

using json = basic_json<>;
+

This type is the default specialization of the basic_json class which uses the standard template types.

Examples

Example

The example below demonstrates how to use the type nlohmann::json.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON object
-    json j =
-    {
-        {"pi", 3.141},
-        {"happy", true},
-        {"name", "Niels"},
-        {"nothing", nullptr},
-        {
-            "answer", {
-                {"everything", 42}
-            }
-        },
-        {"list", {1, 0, 2}},
-        {
-            "object", {
-                {"currency", "USD"},
-                {"value", 42.99}
-            }
-        }
-    };
+    json j =
+    {
+        {"pi", 3.141},
+        {"happy", true},
+        {"name", "Niels"},
+        {"nothing", nullptr},
+        {
+            "answer", {
+                {"everything", 42}
+            }
+        },
+        {"list", {1, 0, 2}},
+        {
+            "object", {
+                {"currency", "USD"},
+                {"value", 42.99}
+            }
+        }
+    };
 
     // add new values
-    j["new"]["key"]["value"] = {"another", "list"};
+    j["new"]["key"]["value"] = {"another", "list"};
 
     // count elements
-    auto s = j.size();
-    j["size"] = s;
+    auto s = j.size();
+    j["size"] = s;
 
     // pretty print with indent of 4 spaces
-    std::cout << std::setw(4) << j << '\n';
-}
-

Output:

{
-    "answer": {
-        "everything": 42
-    },
-    "happy": true,
-    "list": [
-        1,
-        0,
-        2
-    ],
-    "name": "Niels",
-    "new": {
-        "key": {
-            "value": [
-                "another",
-                "list"
-            ]
-        }
-    },
-    "nothing": null,
-    "object": {
-        "currency": "USD",
-        "value": 42.99
-    },
-    "pi": 3.141,
-    "size": 8
-}
-

Version history

Since version 1.0.0.


Last update: May 17, 2022
\ No newline at end of file + std::cout << std::setw(4) << j << '\n'; +} +

Output:

{
+    "answer": {
+        "everything": 42
+    },
+    "happy": true,
+    "list": [
+        1,
+        0,
+        2
+    ],
+    "name": "Niels",
+    "new": {
+        "key": {
+            "value": [
+                "another",
+                "list"
+            ]
+        }
+    },
+    "nothing": null,
+    "object": {
+        "currency": "USD",
+        "value": 42.99
+    },
+    "pi": 3.141,
+    "size": 8
+}
+

Version history

Since version 1.0.0.


Last update: May 17, 2022
\ No newline at end of file diff --git a/api/json_pointer/back/index.html b/api/json_pointer/back/index.html index 9270fbe9e..b32f09feb 100644 --- a/api/json_pointer/back/index.html +++ b/api/json_pointer/back/index.html @@ -1,19 +1,19 @@ - back - JSON for Modern C++
Skip to content

nlohmann::json_pointer::back

const string_t& back() const;
-

Return last reference token.

Return value

Last reference token.

Exceptions

Throws out_of_range.405 if JSON pointer has no parent.

Complexity

Constant.

Examples

Example

The example shows the usage of back.

#include <iostream>
-#include <nlohmann/json.hpp>
+ back - JSON for Modern C++       

nlohmann::json_pointer::back

const string_t& back() const;
+

Return last reference token.

Return value

Last reference token.

Exceptions

Throws out_of_range.405 if JSON pointer has no parent.

Complexity

Constant.

Examples

Example

The example shows the usage of back.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // different JSON Pointers
-    json::json_pointer ptr1("/foo");
-    json::json_pointer ptr2("/foo/0");
+    json::json_pointer ptr1("/foo");
+    json::json_pointer ptr2("/foo/0");
 
     // call empty()
-    std::cout << "last reference token of \"" << ptr1 << "\" is \"" << ptr1.back() << "\"\n"
-              << "last reference token of \"" << ptr2 << "\" is \"" << ptr2.back() << "\"" << std::endl;
-}
-

Output:

last reference token of "/foo" is "foo"
-last reference token of "/foo/0" is "0"
-

Version history

  • Added in version 3.6.0.
  • Changed return type to string_t in version 3.11.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << "last reference token of \"" << ptr1 << "\" is \"" << ptr1.back() << "\"\n" + << "last reference token of \"" << ptr2 << "\" is \"" << ptr2.back() << "\"" << std::endl; +} +

Output:

last reference token of "/foo" is "foo"
+last reference token of "/foo/0" is "0"
+

Version history

  • Added in version 3.6.0.
  • Changed return type to string_t in version 3.11.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/json_pointer/empty/index.html b/api/json_pointer/empty/index.html index 325d2bdfa..e9a5add02 100644 --- a/api/json_pointer/empty/index.html +++ b/api/json_pointer/empty/index.html @@ -1,26 +1,26 @@ - empty - JSON for Modern C++
Skip to content

nlohmann::json_pointer::empty

bool empty() const noexcept;
-

Return whether pointer points to the root document.

Return value

true iff the JSON pointer points to the root document.

Exception safety

No-throw guarantee: this function never throws exceptions.

Complexity

Constant.

Examples

Example

The example shows the result of empty for different JSON Pointers.

#include <iostream>
-#include <nlohmann/json.hpp>
+ empty - JSON for Modern C++       

nlohmann::json_pointer::empty

bool empty() const noexcept;
+

Return whether pointer points to the root document.

Return value

true iff the JSON pointer points to the root document.

Exception safety

No-throw guarantee: this function never throws exceptions.

Complexity

Constant.

Examples

Example

The example shows the result of empty for different JSON Pointers.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // different JSON Pointers
-    json::json_pointer ptr0;
-    json::json_pointer ptr1("");
-    json::json_pointer ptr2("/foo");
-    json::json_pointer ptr3("/foo/0");
+    json::json_pointer ptr0;
+    json::json_pointer ptr1("");
+    json::json_pointer ptr2("/foo");
+    json::json_pointer ptr3("/foo/0");
 
     // call empty()
-    std::cout << std::boolalpha
-              << "\"" << ptr0 << "\": " << ptr0.empty() << '\n'
-              << "\"" << ptr1 << "\": " << ptr1.empty() << '\n'
-              << "\"" << ptr2 << "\": " << ptr2.empty() << '\n'
-              << "\"" << ptr3 << "\": " << ptr3.empty() << std::endl;
-}
-

Output:

"": true
-"": true
-"/foo": false
-"/foo/0": false
-

Version history

Added in version 3.6.0.


Last update: May 1, 2022
\ No newline at end of file + std::cout << std::boolalpha + << "\"" << ptr0 << "\": " << ptr0.empty() << '\n' + << "\"" << ptr1 << "\": " << ptr1.empty() << '\n' + << "\"" << ptr2 << "\": " << ptr2.empty() << '\n' + << "\"" << ptr3 << "\": " << ptr3.empty() << std::endl; +} +

Output:

"": true
+"": true
+"/foo": false
+"/foo/0": false
+

Version history

Added in version 3.6.0.


Last update: May 1, 2022
\ No newline at end of file diff --git a/api/json_pointer/index.html b/api/json_pointer/index.html index 938aee263..8c5bd32b7 100644 --- a/api/json_pointer/index.html +++ b/api/json_pointer/index.html @@ -1,3 +1,3 @@ - Overview - JSON for Modern C++
Skip to content

nlohmann::json_pointer

template<typename RefStringType>
-class json_pointer;
-

A JSON pointer defines a string syntax for identifying a specific value within a JSON document. It can be used with functions at and operator[]. Furthermore, JSON pointers are the base for JSON patches.

Template parameters

RefStringType
the string type used for the reference tokens making up the JSON pointer

Deprecation

For backwards compatibility RefStringType may also be a specialization of basic_json in which case string_t will be deduced as basic_json::string_t. This feature is deprecated and may be removed in a future major version.

Member types

  • string_t - the string type used for the reference tokens

Member functions

Literals

See also

Version history

  • Added in version 2.0.0.
  • Changed template parameter from basic_json to string type in version 3.11.0.

Last update: August 5, 2022
\ No newline at end of file + Overview - JSON for Modern C++
Skip to content

nlohmann::json_pointer

template<typename RefStringType>
+class json_pointer;
+

A JSON pointer defines a string syntax for identifying a specific value within a JSON document. It can be used with functions at and operator[]. Furthermore, JSON pointers are the base for JSON patches.

Template parameters

RefStringType
the string type used for the reference tokens making up the JSON pointer

Deprecation

For backwards compatibility RefStringType may also be a specialization of basic_json in which case string_t will be deduced as basic_json::string_t. This feature is deprecated and may be removed in a future major version.

Member types

  • string_t - the string type used for the reference tokens

Member functions

Literals

See also

Version history

  • Added in version 2.0.0.
  • Changed template parameter from basic_json to string type in version 3.11.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/json_pointer/json_pointer/index.html b/api/json_pointer/json_pointer/index.html index 87ae83588..8c207c7f9 100644 --- a/api/json_pointer/json_pointer/index.html +++ b/api/json_pointer/json_pointer/index.html @@ -1,52 +1,52 @@ - (Constructor) - JSON for Modern C++
Skip to content

nlohmann::json_pointer::json_pointer

explicit json_pointer(const string_t& s = "");
-

Create a JSON pointer according to the syntax described in Section 3 of RFC6901.

Parameters

s (in)
string representing the JSON pointer; if omitted, the empty string is assumed which references the whole JSON value

Exceptions

  • Throws parse_error.107 if the given JSON pointer s is nonempty and does not begin with a slash (/); see example below.
  • Throws parse_error.108 if a tilde (~) in the given JSON pointer s is not followed by 0 (representing ~) or 1 (representing /); see example below.

Examples

Example

The example shows the construction several valid JSON pointers as well as the exceptional behavior.

#include <iostream>
-#include <nlohmann/json.hpp>
+ (Constructor) - JSON for Modern C++       

nlohmann::json_pointer::json_pointer

explicit json_pointer(const string_t& s = "");
+

Create a JSON pointer according to the syntax described in Section 3 of RFC6901.

Parameters

s (in)
string representing the JSON pointer; if omitted, the empty string is assumed which references the whole JSON value

Exceptions

  • Throws parse_error.107 if the given JSON pointer s is nonempty and does not begin with a slash (/); see example below.
  • Throws parse_error.108 if a tilde (~) in the given JSON pointer s is not followed by 0 (representing ~) or 1 (representing /); see example below.

Examples

Example

The example shows the construction several valid JSON pointers as well as the exceptional behavior.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // correct JSON pointers
-    json::json_pointer p1;
-    json::json_pointer p2("");
-    json::json_pointer p3("/");
-    json::json_pointer p4("//");
-    json::json_pointer p5("/foo/bar");
-    json::json_pointer p6("/foo/bar/-");
-    json::json_pointer p7("/foo/~0");
-    json::json_pointer p8("/foo/~1");
+    json::json_pointer p1;
+    json::json_pointer p2("");
+    json::json_pointer p3("/");
+    json::json_pointer p4("//");
+    json::json_pointer p5("/foo/bar");
+    json::json_pointer p6("/foo/bar/-");
+    json::json_pointer p7("/foo/~0");
+    json::json_pointer p8("/foo/~1");
 
     // error: JSON pointer does not begin with a slash
-    try
-    {
-        json::json_pointer p9("foo");
-    }
-    catch (const json::parse_error& e)
-    {
-        std::cout << e.what() << '\n';
-    }
+    try
+    {
+        json::json_pointer p9("foo");
+    }
+    catch (const json::parse_error& e)
+    {
+        std::cout << e.what() << '\n';
+    }
 
     // error: JSON pointer uses escape symbol ~ not followed by 0 or 1
-    try
-    {
-        json::json_pointer p10("/foo/~");
-    }
-    catch (const json::parse_error& e)
-    {
-        std::cout << e.what() << '\n';
-    }
+    try
+    {
+        json::json_pointer p10("/foo/~");
+    }
+    catch (const json::parse_error& e)
+    {
+        std::cout << e.what() << '\n';
+    }
 
     // error: JSON pointer uses escape symbol ~ not followed by 0 or 1
-    try
-    {
-        json::json_pointer p11("/foo/~3");
-    }
-    catch (const json::parse_error& e)
-    {
-        std::cout << e.what() << '\n';
-    }
-}
-

Output:

[json.exception.parse_error.107] parse error at byte 1: JSON pointer must be empty or begin with '/' - was: 'foo'
-[json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1'
-[json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1'
-

Version history

  • Added in version 2.0.0.
  • Changed type of s to string_t in version 3.11.0.

Last update: May 1, 2022
\ No newline at end of file + try + { + json::json_pointer p11("/foo/~3"); + } + catch (const json::parse_error& e) + { + std::cout << e.what() << '\n'; + } +} +

Output:

[json.exception.parse_error.107] parse error at byte 1: JSON pointer must be empty or begin with '/' - was: 'foo'
+[json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1'
+[json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1'
+

Version history

  • Added in version 2.0.0.
  • Changed type of s to string_t in version 3.11.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/json_pointer/operator_eq/index.html b/api/json_pointer/operator_eq/index.html index 677ccfb7d..db49f814a 100644 --- a/api/json_pointer/operator_eq/index.html +++ b/api/json_pointer/operator_eq/index.html @@ -1,85 +1,85 @@ - operator== - JSON for Modern C++
Skip to content

nlohmann::json_pointer::operator==

// until C++20
-template<typename RefStringTypeLhs, typename RefStringTypeRhs>
-bool operator==(
-    const json_pointer<RefStringTypeLhs>& lhs,
+ operator== - JSON for Modern C++       

nlohmann::json_pointer::operator==

// until C++20
+template<typename RefStringTypeLhs, typename RefStringTypeRhs>
+bool operator==(
+    const json_pointer<RefStringTypeLhs>& lhs,
     const json_pointer<RefStringTypeRhs>& rhs) noexcept;            // (1)
 
-template<typename RefStringTypeLhs, typename StringType>
-bool operator==(
-    const json_pointer<RefStringTypeLhs>& lhs,
+template<typename RefStringTypeLhs, typename StringType>
+bool operator==(
+    const json_pointer<RefStringTypeLhs>& lhs,
     const StringType& rhs);                                         // (2)
 
-template<typename RefStringTypeRhs, typename StringType>
-bool operator==(
-    const StringType& lhs,
+template<typename RefStringTypeRhs, typename StringType>
+bool operator==(
+    const StringType& lhs,
     const json_pointer<RefStringTypeRhs>& rhs);                     // (2)
 
 // since C++20
-class json_pointer {
-    template<typename RefStringTypeRhs>
-    bool operator==(
+class json_pointer {
+    template<typename RefStringTypeRhs>
+    bool operator==(
         const json_pointer<RefStringTypeRhs>& rhs) const noexcept;  // (1)
 
     bool operator==(const string_t& rhs) const;                     // (2)
-};
-
  1. Compares two JSON pointers for equality by comparing their reference tokens.

  2. Compares a JSON pointer and a string or a string and a JSON pointer for equality by converting the string to a JSON pointer and comparing the JSON pointers according to 1.

Template parameters

RefStringTypeLhs, RefStringTypeRhs
the string type of the left-hand side or right-hand side JSON pointer, respectively
StringType
the string type derived from the json_pointer operand (json_pointer::string_t)

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

  1. No-throw guarantee: this function never throws exceptions.
  2. Strong exception safety: if an exception occurs, the original value stays intact.

Exceptions

  1. (none)
  2. The function can throw the following exceptions:
  3. Throws parse_error.107 if the given JSON pointer s is nonempty and does not begin with a slash (/); see example below.
  4. Throws parse_error.108 if a tilde (~) in the given JSON pointer s is not followed by 0 (representing ~) or 1 (representing /); see example below.

Complexity

Constant if lhs and rhs differ in the number of reference tokens, otherwise linear in the number of reference tokens.

Notes

Deprecation

Overload 2 is deprecated and will be removed in a future major version release.

Examples

Example: (1) Comparing JSON pointers

The example demonstrates comparing JSON pointers.

#include <iostream>
-#include <nlohmann/json.hpp>
+};
+
  1. Compares two JSON pointers for equality by comparing their reference tokens.

  2. Compares a JSON pointer and a string or a string and a JSON pointer for equality by converting the string to a JSON pointer and comparing the JSON pointers according to 1.

Template parameters

RefStringTypeLhs, RefStringTypeRhs
the string type of the left-hand side or right-hand side JSON pointer, respectively
StringType
the string type derived from the json_pointer operand (json_pointer::string_t)

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

  1. No-throw guarantee: this function never throws exceptions.
  2. Strong exception safety: if an exception occurs, the original value stays intact.

Exceptions

  1. (none)
  2. The function can throw the following exceptions:
  3. Throws parse_error.107 if the given JSON pointer s is nonempty and does not begin with a slash (/); see example below.
  4. Throws parse_error.108 if a tilde (~) in the given JSON pointer s is not followed by 0 (representing ~) or 1 (representing /); see example below.

Complexity

Constant if lhs and rhs differ in the number of reference tokens, otherwise linear in the number of reference tokens.

Notes

Deprecation

Overload 2 is deprecated and will be removed in a future major version release.

Examples

Example: (1) Comparing JSON pointers

The example demonstrates comparing JSON pointers.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // different JSON pointers
-    json::json_pointer ptr0;
-    json::json_pointer ptr1("");
-    json::json_pointer ptr2("/foo");
+    json::json_pointer ptr0;
+    json::json_pointer ptr1("");
+    json::json_pointer ptr2("/foo");
 
     // compare JSON pointers
-    std::cout << std::boolalpha
-              << "\"" << ptr0 << "\" == \"" << ptr0 << "\": " << (ptr0 == ptr0) << '\n'
-              << "\"" << ptr0 << "\" == \"" << ptr1 << "\": " << (ptr0 == ptr1) << '\n'
-              << "\"" << ptr1 << "\" == \"" << ptr2 << "\": " << (ptr1 == ptr2) << '\n'
-              << "\"" << ptr2 << "\" == \"" << ptr2 << "\": " << (ptr2 == ptr2) << std::endl;
-}
+    std::cout << std::boolalpha
+              << "\"" << ptr0 << "\" == \"" << ptr0 << "\": " << (ptr0 == ptr0) << '\n'
+              << "\"" << ptr0 << "\" == \"" << ptr1 << "\": " << (ptr0 == ptr1) << '\n'
+              << "\"" << ptr1 << "\" == \"" << ptr2 << "\": " << (ptr1 == ptr2) << '\n'
+              << "\"" << ptr2 << "\" == \"" << ptr2 << "\": " << (ptr2 == ptr2) << std::endl;
+}
 

Output:

"" == "": true
 "" == "": true
 "" == "/foo": false
 "/foo" == "/foo": true
-
Example: (2) Comparing JSON pointers and strings

The example demonstrates comparing JSON pointers and strings, and when doing so may raise an exception.

#include <exception>
-#include <iostream>
-#include <nlohmann/json.hpp>
+
Example: (2) Comparing JSON pointers and strings

The example demonstrates comparing JSON pointers and strings, and when doing so may raise an exception.

#include <exception>
+#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // different JSON pointers
-    json::json_pointer ptr0;
-    json::json_pointer ptr1("");
-    json::json_pointer ptr2("/foo");
+    json::json_pointer ptr0;
+    json::json_pointer ptr1("");
+    json::json_pointer ptr2("/foo");
 
     // different strings
-    std::string str0("");
-    std::string str1("/foo");
-    std::string str2("bar");
+    std::string str0("");
+    std::string str1("/foo");
+    std::string str2("bar");
 
     // compare JSON pointers and strings
-    std::cout << std::boolalpha
-              << "\"" << ptr0 << "\" == \"" << str0 << "\": " << (ptr0 == str0) << '\n'
-              << "\"" << str0 << "\" == \"" << ptr1 << "\": " << (str0 == ptr1) << '\n'
-              << "\"" << ptr2 << "\" == \"" << str1 << "\": " << (ptr2 == str1) << std::endl;
+    std::cout << std::boolalpha
+              << "\"" << ptr0 << "\" == \"" << str0 << "\": " << (ptr0 == str0) << '\n'
+              << "\"" << str0 << "\" == \"" << ptr1 << "\": " << (str0 == ptr1) << '\n'
+              << "\"" << ptr2 << "\" == \"" << str1 << "\": " << (ptr2 == str1) << std::endl;
 
-    try
-    {
-        std::cout << "\"" << str2 << "\" == \"" << ptr2 << "\": " << (str2 == ptr2) << std::endl;
-    }
-    catch (const json::parse_error& ex)
-    {
-        std::cout << ex.what() << std::endl;
-    }
-}
+    try
+    {
+        std::cout << "\"" << str2 << "\" == \"" << ptr2 << "\": " << (str2 == ptr2) << std::endl;
+    }
+    catch (const json::parse_error& ex)
+    {
+        std::cout << ex.what() << std::endl;
+    }
+}
 

Output:

"" == "": true
 "" == "": true
 "/foo" == "/foo": true
 "bar" == "/foo": [json.exception.parse_error.107] parse error at byte 1: JSON pointer must be empty or begin with '/' - was: 'bar'
-

Version history

  1. Added in version 2.1.0. Added C++20 member functions in version 3.11.2.
  2. Added for backward compatibility and deprecated in version 3.11.2.

Last update: August 7, 2022
\ No newline at end of file +

Version history

  1. Added in version 2.1.0. Added C++20 member functions in version 3.11.2.
  2. Added for backward compatibility and deprecated in version 3.11.2.

Last update: August 7, 2022
\ No newline at end of file diff --git a/api/json_pointer/operator_ne/index.html b/api/json_pointer/operator_ne/index.html index 28e5580ec..15e60161b 100644 --- a/api/json_pointer/operator_ne/index.html +++ b/api/json_pointer/operator_ne/index.html @@ -1,75 +1,75 @@ - operator!= - JSON for Modern C++
Skip to content

nlohmann::json_pointer::operator!=

// until C++20
-template<typename RefStringTypeLhs, typename RefStringTypeRhs>
-bool operator!=(
-    const json_pointer<RefStringTypeLhs>& lhs,
+ operator!= - JSON for Modern C++       

nlohmann::json_pointer::operator!=

// until C++20
+template<typename RefStringTypeLhs, typename RefStringTypeRhs>
+bool operator!=(
+    const json_pointer<RefStringTypeLhs>& lhs,
     const json_pointer<RefStringTypeRhs>& rhs) noexcept;  // (1)
 
-template<typename RefStringTypeLhs, typename StringType>
-bool operator!=(
-    const json_pointer<RefStringTypeLhs>& lhs,
+template<typename RefStringTypeLhs, typename StringType>
+bool operator!=(
+    const json_pointer<RefStringTypeLhs>& lhs,
     const StringType& rhs);                               // (2)
 
-template<typename RefStringTypeRhs, typename StringType>
-bool operator!=(
-    const StringType& lhs,
+template<typename RefStringTypeRhs, typename StringType>
+bool operator!=(
+    const StringType& lhs,
     const json_pointer<RefStringTypeRhs>& rhs);           // (2)
-
  1. Compares two JSON pointers for inequality by comparing their reference tokens.

  2. Compares a JSON pointer and a string or a string and a JSON pointer for inequality by converting the string to a JSON pointer and comparing the JSON pointers according to 1.

Template parameters

RefStringTypeLhs, RefStringTypeRhs
the string type of the left-hand side or right-hand side JSON pointer, respectively
StringType
the string type derived from the json_pointer operand (json_pointer::string_t)

Parameters

lhs (in)
first value to consider
rhs (in)
second value to consider

Return value

whether the values lhs/*this and rhs are not equal

Exception safety

  1. No-throw guarantee: this function never throws exceptions.
  2. Strong exception safety: if an exception occurs, the original value stays intact.

Exceptions

  1. (none)
  2. The function can throw the following exceptions:
  3. Throws parse_error.107 if the given JSON pointer s is nonempty and does not begin with a slash (/); see example below.
  4. Throws parse_error.108 if a tilde (~) in the given JSON pointer s is not followed by 0 (representing ~) or 1 (representing /); see example below.

Complexity

Constant if lhs and rhs differ in the number of reference tokens, otherwise linear in the number of reference tokens.

Notes

Operator overload resolution

Since C++20 overload resolution will consider the rewritten candidate generated from operator==.

Deprecation

Overload 2 is deprecated and will be removed in a future major version release.

Examples

Example: (1) Comparing JSON pointers

The example demonstrates comparing JSON pointers.

#include <iostream>
-#include <nlohmann/json.hpp>
+
  1. Compares two JSON pointers for inequality by comparing their reference tokens.

  2. Compares a JSON pointer and a string or a string and a JSON pointer for inequality by converting the string to a JSON pointer and comparing the JSON pointers according to 1.

Template parameters

RefStringTypeLhs, RefStringTypeRhs
the string type of the left-hand side or right-hand side JSON pointer, respectively
StringType
the string type derived from the json_pointer operand (json_pointer::string_t)

Parameters

lhs (in)
first value to consider
rhs (in)
second value to consider

Return value

whether the values lhs/*this and rhs are not equal

Exception safety

  1. No-throw guarantee: this function never throws exceptions.
  2. Strong exception safety: if an exception occurs, the original value stays intact.

Exceptions

  1. (none)
  2. The function can throw the following exceptions:
  3. Throws parse_error.107 if the given JSON pointer s is nonempty and does not begin with a slash (/); see example below.
  4. Throws parse_error.108 if a tilde (~) in the given JSON pointer s is not followed by 0 (representing ~) or 1 (representing /); see example below.

Complexity

Constant if lhs and rhs differ in the number of reference tokens, otherwise linear in the number of reference tokens.

Notes

Operator overload resolution

Since C++20 overload resolution will consider the rewritten candidate generated from operator==.

Deprecation

Overload 2 is deprecated and will be removed in a future major version release.

Examples

Example: (1) Comparing JSON pointers

The example demonstrates comparing JSON pointers.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // different JSON pointers
-    json::json_pointer ptr0;
-    json::json_pointer ptr1("");
-    json::json_pointer ptr2("/foo");
+    json::json_pointer ptr0;
+    json::json_pointer ptr1("");
+    json::json_pointer ptr2("/foo");
 
     // compare JSON pointers
-    std::cout << std::boolalpha
-              << "\"" << ptr0 << "\" != \"" << ptr0 << "\": " << (ptr0 != ptr0) << '\n'
-              << "\"" << ptr0 << "\" != \"" << ptr1 << "\": " << (ptr0 != ptr1) << '\n'
-              << "\"" << ptr1 << "\" != \"" << ptr2 << "\": " << (ptr1 != ptr2) << '\n'
-              << "\"" << ptr2 << "\" != \"" << ptr2 << "\": " << (ptr2 != ptr2) << std::endl;
-}
+    std::cout << std::boolalpha
+              << "\"" << ptr0 << "\" != \"" << ptr0 << "\": " << (ptr0 != ptr0) << '\n'
+              << "\"" << ptr0 << "\" != \"" << ptr1 << "\": " << (ptr0 != ptr1) << '\n'
+              << "\"" << ptr1 << "\" != \"" << ptr2 << "\": " << (ptr1 != ptr2) << '\n'
+              << "\"" << ptr2 << "\" != \"" << ptr2 << "\": " << (ptr2 != ptr2) << std::endl;
+}
 

Output:

"" != "": false
 "" != "": false
 "" != "/foo": true
 "/foo" != "/foo": false
-
Example: (2) Comparing JSON pointers and strings

The example demonstrates comparing JSON pointers and strings, and when doing so may raise an exception.

#include <iostream>
-#include <nlohmann/json.hpp>
+
Example: (2) Comparing JSON pointers and strings

The example demonstrates comparing JSON pointers and strings, and when doing so may raise an exception.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // different JSON pointers
-    json::json_pointer ptr0;
-    json::json_pointer ptr1("");
-    json::json_pointer ptr2("/foo");
+    json::json_pointer ptr0;
+    json::json_pointer ptr1("");
+    json::json_pointer ptr2("/foo");
 
     // different strings
-    std::string str0("");
-    std::string str1("/foo");
-    std::string str2("bar");
+    std::string str0("");
+    std::string str1("/foo");
+    std::string str2("bar");
 
     // compare JSON pointers and strings
-    std::cout << std::boolalpha
-              << "\"" << ptr0 << "\" != \"" << str0 << "\": " << (ptr0 != str0) << '\n'
-              << "\"" << str0 << "\" != \"" << ptr1 << "\": " << (str0 != ptr1) << '\n'
-              << "\"" << ptr2 << "\" != \"" << str1 << "\": " << (ptr2 != str1) << std::endl;
+    std::cout << std::boolalpha
+              << "\"" << ptr0 << "\" != \"" << str0 << "\": " << (ptr0 != str0) << '\n'
+              << "\"" << str0 << "\" != \"" << ptr1 << "\": " << (str0 != ptr1) << '\n'
+              << "\"" << ptr2 << "\" != \"" << str1 << "\": " << (ptr2 != str1) << std::endl;
 
-    try
-    {
-        std::cout << "\"" << str2 << "\" != \"" << ptr2 << "\": " << (str2 != ptr2) << std::endl;
-    }
-    catch (const json::parse_error& ex)
-    {
-        std::cout << ex.what() << std::endl;
-    }
-}
+    try
+    {
+        std::cout << "\"" << str2 << "\" != \"" << ptr2 << "\": " << (str2 != ptr2) << std::endl;
+    }
+    catch (const json::parse_error& ex)
+    {
+        std::cout << ex.what() << std::endl;
+    }
+}
 

Output:

"" != "": false
 "" != "": false
 "/foo" != "/foo": false
 "bar" != "/foo": [json.exception.parse_error.107] parse error at byte 1: JSON pointer must be empty or begin with '/' - was: 'bar'
-

Version history

  1. Added in version 2.1.0.
  2. Added for backward compatibility and deprecated in version 3.11.2.

Last update: August 7, 2022
\ No newline at end of file +

Version history

  1. Added in version 2.1.0.
  2. Added for backward compatibility and deprecated in version 3.11.2.

Last update: August 7, 2022
\ No newline at end of file diff --git a/api/json_pointer/operator_slash/index.html b/api/json_pointer/operator_slash/index.html index 932c9be61..f9cefa932 100644 --- a/api/json_pointer/operator_slash/index.html +++ b/api/json_pointer/operator_slash/index.html @@ -1,31 +1,31 @@ - operator/ - JSON for Modern C++
Skip to content

nlohmann::json_pointer::operator/

// (1)
-json_pointer operator/(const json_pointer& lhs, const json_pointer& rhs);
+ operator/ - JSON for Modern C++       

nlohmann::json_pointer::operator/

// (1)
+json_pointer operator/(const json_pointer& lhs, const json_pointer& rhs);
 
 // (2)
-json_pointer operator/(const json_pointer& lhs, string_t token);
+json_pointer operator/(const json_pointer& lhs, string_t token);
 
 // (3)
-json_pointer operator/(const json_pointer& lhs, std::size_t array_idx);
-
  1. create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
  2. create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
  3. create a new JSON pointer by appending the array-index-token at the end of the JSON pointer

Parameters

lhs (in)
JSON pointer
rhs (in)
JSON pointer to append
token (in)
reference token to append
array_idx (in)
array index to append

Return value

  1. a new JSON pointer with rhs appended to lhs
  2. a new JSON pointer with unescaped token appended to lhs
  3. a new JSON pointer with array_idx appended to lhs

Complexity

  1. Linear in the length of lhs and rhs.
  2. Linear in the length of lhs.
  3. Linear in the length of lhs.

Examples

Example

The example shows the usage of operator/.

#include <iostream>
-#include <nlohmann/json.hpp>
+json_pointer operator/(const json_pointer& lhs, std::size_t array_idx);
+
  1. create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
  2. create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
  3. create a new JSON pointer by appending the array-index-token at the end of the JSON pointer

Parameters

lhs (in)
JSON pointer
rhs (in)
JSON pointer to append
token (in)
reference token to append
array_idx (in)
array index to append

Return value

  1. a new JSON pointer with rhs appended to lhs
  2. a new JSON pointer with unescaped token appended to lhs
  3. a new JSON pointer with array_idx appended to lhs

Complexity

  1. Linear in the length of lhs and rhs.
  2. Linear in the length of lhs.
  3. Linear in the length of lhs.

Examples

Example

The example shows the usage of operator/.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON pointer
-    json::json_pointer ptr("/foo");
+    json::json_pointer ptr("/foo");
 
     // append a JSON Pointer
-    std::cout << "\"" << ptr / json::json_pointer("/bar/baz") << "\"\n";
+    std::cout << "\"" << ptr / json::json_pointer("/bar/baz") << "\"\n";
 
     // append a string
-    std::cout << "\"" << ptr / "fob" << "\"\n";
+    std::cout << "\"" << ptr / "fob" << "\"\n";
 
     // append an array index
-    std::cout << "\"" << ptr / 42 << "\"" << std::endl;
-}
-

Output:

"/foo/bar/baz"
-"/foo/fob"
-"/foo/42"
-

Version history

  1. Added in version 3.6.0.
  2. Added in version 3.6.0. Changed type of token to string_t in version 3.11.0.
  3. Added in version 3.6.0.

Last update: May 1, 2022
\ No newline at end of file + std::cout << "\"" << ptr / 42 << "\"" << std::endl; +} +

Output:

"/foo/bar/baz"
+"/foo/fob"
+"/foo/42"
+

Version history

  1. Added in version 3.6.0.
  2. Added in version 3.6.0. Changed type of token to string_t in version 3.11.0.
  3. Added in version 3.6.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/json_pointer/operator_slasheq/index.html b/api/json_pointer/operator_slasheq/index.html index 95c6085c8..252a07e73 100644 --- a/api/json_pointer/operator_slasheq/index.html +++ b/api/json_pointer/operator_slasheq/index.html @@ -1,36 +1,36 @@ - operator/= - JSON for Modern C++
Skip to content

nlohmann::json_pointer::operator/=

// (1)
-json_pointer& operator/=(const json_pointer& ptr);
+ operator/= - JSON for Modern C++       

nlohmann::json_pointer::operator/=

// (1)
+json_pointer& operator/=(const json_pointer& ptr);
 
 // (2)
-json_pointer& operator/=(string_t token);
+json_pointer& operator/=(string_t token);
 
 // (3)
-json_pointer& operator/=(std::size_t array_idx)
-
  1. append another JSON pointer at the end of this JSON pointer
  2. append an unescaped reference token at the end of this JSON pointer
  3. append an array index at the end of this JSON pointer

Parameters

ptr (in)
JSON pointer to append
token (in)
reference token to append
array_idx (in)
array index to append

Return value

  1. JSON pointer with ptr appended
  2. JSON pointer with token appended without escaping token
  3. JSON pointer with array_idx appended

Complexity

  1. Linear in the length of ptr.
  2. Amortized constant.
  3. Amortized constant.

Examples

Example

The example shows the usage of operator/=.

#include <iostream>
-#include <nlohmann/json.hpp>
+json_pointer& operator/=(std::size_t array_idx)
+
  1. append another JSON pointer at the end of this JSON pointer
  2. append an unescaped reference token at the end of this JSON pointer
  3. append an array index at the end of this JSON pointer

Parameters

ptr (in)
JSON pointer to append
token (in)
reference token to append
array_idx (in)
array index to append

Return value

  1. JSON pointer with ptr appended
  2. JSON pointer with token appended without escaping token
  3. JSON pointer with array_idx appended

Complexity

  1. Linear in the length of ptr.
  2. Amortized constant.
  3. Amortized constant.

Examples

Example

The example shows the usage of operator/=.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create a JSON pointer
-    json::json_pointer ptr("/foo");
-    std::cout << "\"" << ptr << "\"\n";
+    json::json_pointer ptr("/foo");
+    std::cout << "\"" << ptr << "\"\n";
 
     // append a JSON Pointer
-    ptr /= json::json_pointer("/bar/baz");
-    std::cout << "\"" << ptr << "\"\n";
+    ptr /= json::json_pointer("/bar/baz");
+    std::cout << "\"" << ptr << "\"\n";
 
     // append a string
-    ptr /= "fob";
-    std::cout << "\"" << ptr << "\"\n";
+    ptr /= "fob";
+    std::cout << "\"" << ptr << "\"\n";
 
     // append an array index
-    ptr /= 42;
-    std::cout << "\"" << ptr << "\"" << std::endl;
-}
-

Output:

"/foo"
-"/foo/bar/baz"
-"/foo/bar/baz/fob"
-"/foo/bar/baz/fob/42"
-

Version history

  1. Added in version 3.6.0.
  2. Added in version 3.6.0. Changed type of token to string_t in version 3.11.0.
  3. Added in version 3.6.0.

Last update: May 1, 2022
\ No newline at end of file + ptr /= 42; + std::cout << "\"" << ptr << "\"" << std::endl; +} +

Output:

"/foo"
+"/foo/bar/baz"
+"/foo/bar/baz/fob"
+"/foo/bar/baz/fob/42"
+

Version history

  1. Added in version 3.6.0.
  2. Added in version 3.6.0. Changed type of token to string_t in version 3.11.0.
  3. Added in version 3.6.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/json_pointer/operator_string_t/index.html b/api/json_pointer/operator_string_t/index.html index a90e008ff..5a225c5ef 100644 --- a/api/json_pointer/operator_string_t/index.html +++ b/api/json_pointer/operator_string_t/index.html @@ -1,27 +1,27 @@ - operator string_t - JSON for Modern C++
Skip to content

nlohmann::json_pointer::operator string_t

operator string_t() const
-

Return a string representation of the JSON pointer.

Return value

A string representation of the JSON pointer

Possible implementation

operator string_t() const
-{
-    return to_string();
-}
-

Notes

Deprecation

This function is deprecated in favor of to_string and will be removed in a future major version release.

Examples

Example

The example shows how JSON Pointers can be implicitly converted to strings.

#include <iostream>
-#include <nlohmann/json.hpp>
+ operator string_t - JSON for Modern C++       

nlohmann::json_pointer::operator string_t

operator string_t() const
+

Return a string representation of the JSON pointer.

Return value

A string representation of the JSON pointer

Possible implementation

operator string_t() const
+{
+    return to_string();
+}
+

Notes

Deprecation

This function is deprecated in favor of to_string and will be removed in a future major version release.

Examples

Example

The example shows how JSON Pointers can be implicitly converted to strings.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // different JSON Pointers
-    json::json_pointer ptr1("/foo/0");
-    json::json_pointer ptr2("/a~1b");
+    json::json_pointer ptr1("/foo/0");
+    json::json_pointer ptr2("/a~1b");
 
     // implicit conversion to string
-    std::string s;
-    s += ptr1;
-    s += "\n";
-    s += ptr2;
+    std::string s;
+    s += ptr1;
+    s += "\n";
+    s += ptr2;
 
-    std::cout << s << std::endl;
-}
-

Output:

/foo/0
-/a~1b
-

Version history

  • Since version 2.0.0.
  • Changed type to string_t and deprecated in version 3.11.0.

Last update: July 28, 2022
\ No newline at end of file + std::cout << s << std::endl; +} +

Output:

/foo/0
+/a~1b
+

Version history

  • Since version 2.0.0.
  • Changed type to string_t and deprecated in version 3.11.0.

Last update: July 28, 2022
\ No newline at end of file diff --git a/api/json_pointer/parent_pointer/index.html b/api/json_pointer/parent_pointer/index.html index 205896ba9..7b4d9c588 100644 --- a/api/json_pointer/parent_pointer/index.html +++ b/api/json_pointer/parent_pointer/index.html @@ -1,23 +1,23 @@ - parent_pointer - JSON for Modern C++
Skip to content

nlohmann::json_pointer::parent_pointer

json_pointer parent_pointer() const;
-

Returns the parent of this JSON pointer.

Return value

Parent of this JSON pointer; in case this JSON pointer is the root, the root itself is returned.

Complexity

Linear in the length of the JSON pointer.

Examples

Example

The example shows the result of parent_pointer for different JSON Pointers.

#include <iostream>
-#include <nlohmann/json.hpp>
+ parent_pointer - JSON for Modern C++       

nlohmann::json_pointer::parent_pointer

json_pointer parent_pointer() const;
+

Returns the parent of this JSON pointer.

Return value

Parent of this JSON pointer; in case this JSON pointer is the root, the root itself is returned.

Complexity

Linear in the length of the JSON pointer.

Examples

Example

The example shows the result of parent_pointer for different JSON Pointers.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // different JSON Pointers
-    json::json_pointer ptr1("");
-    json::json_pointer ptr2("/foo");
-    json::json_pointer ptr3("/foo/0");
+    json::json_pointer ptr1("");
+    json::json_pointer ptr2("/foo");
+    json::json_pointer ptr3("/foo/0");
 
     // call parent_pointer()
-    std::cout << std::boolalpha
-              << "parent of \"" << ptr1 << "\" is \"" << ptr1.parent_pointer() << "\"\n"
-              << "parent of \"" << ptr2 << "\" is \"" << ptr2.parent_pointer() << "\"\n"
-              << "parent of \"" << ptr3 << "\" is \"" << ptr3.parent_pointer() << "\"" << std::endl;
-}
-

Output:

parent of "" is ""
-parent of "/foo" is ""
-parent of "/foo/0" is "/foo"
-

Version history

Added in version 3.6.0.


Last update: May 1, 2022
\ No newline at end of file + std::cout << std::boolalpha + << "parent of \"" << ptr1 << "\" is \"" << ptr1.parent_pointer() << "\"\n" + << "parent of \"" << ptr2 << "\" is \"" << ptr2.parent_pointer() << "\"\n" + << "parent of \"" << ptr3 << "\" is \"" << ptr3.parent_pointer() << "\"" << std::endl; +} +

Output:

parent of "" is ""
+parent of "/foo" is ""
+parent of "/foo/0" is "/foo"
+

Version history

Added in version 3.6.0.


Last update: May 1, 2022
\ No newline at end of file diff --git a/api/json_pointer/pop_back/index.html b/api/json_pointer/pop_back/index.html index 47cd990b9..9e265eaf9 100644 --- a/api/json_pointer/pop_back/index.html +++ b/api/json_pointer/pop_back/index.html @@ -1,27 +1,27 @@ - pop_back - JSON for Modern C++
Skip to content

nlohmann::json_pointer::pop_back

void pop_back();
-

Remove last reference token.

Exceptions

Throws out_of_range.405 if JSON pointer has no parent.

Complexity

Constant.

Examples

Example

The example shows the usage of pop_back.

#include <iostream>
-#include <nlohmann/json.hpp>
+ pop_back - JSON for Modern C++       

nlohmann::json_pointer::pop_back

void pop_back();
+

Remove last reference token.

Exceptions

Throws out_of_range.405 if JSON pointer has no parent.

Complexity

Constant.

Examples

Example

The example shows the usage of pop_back.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create empty JSON Pointer
-    json::json_pointer ptr("/foo/bar/baz");
-    std::cout << "\"" << ptr << "\"\n";
+    json::json_pointer ptr("/foo/bar/baz");
+    std::cout << "\"" << ptr << "\"\n";
 
     // call pop_back()
-    ptr.pop_back();
-    std::cout << "\"" << ptr << "\"\n";
+    ptr.pop_back();
+    std::cout << "\"" << ptr << "\"\n";
 
-    ptr.pop_back();
-    std::cout << "\"" << ptr << "\"\n";
+    ptr.pop_back();
+    std::cout << "\"" << ptr << "\"\n";
 
-    ptr.pop_back();
-    std::cout << "\"" << ptr << "\"\n";
-}
-

Output:

"/foo/bar/baz"
-"/foo/bar"
-"/foo"
-""
-

Version history

Added in version 3.6.0.


Last update: May 1, 2022
\ No newline at end of file + ptr.pop_back(); + std::cout << "\"" << ptr << "\"\n"; +} +

Output:

"/foo/bar/baz"
+"/foo/bar"
+"/foo"
+""
+

Version history

Added in version 3.6.0.


Last update: May 1, 2022
\ No newline at end of file diff --git a/api/json_pointer/push_back/index.html b/api/json_pointer/push_back/index.html index 6f815d1a3..90a6b8250 100644 --- a/api/json_pointer/push_back/index.html +++ b/api/json_pointer/push_back/index.html @@ -1,29 +1,29 @@ - push_back - JSON for Modern C++
Skip to content

nlohmann::json_pointer::push_back

void push_back(const string_t& token);
+ push_back - JSON for Modern C++       

nlohmann::json_pointer::push_back

void push_back(const string_t& token);
 
-void push_back(string_t&& token);
-

Append an unescaped token at the end of the reference pointer.

Parameters

token (in)
token to add

Complexity

Amortized constant.

Examples

Example

The example shows the result of push_back for different JSON Pointers.

#include <iostream>
-#include <nlohmann/json.hpp>
+void push_back(string_t&& token);
+

Append an unescaped token at the end of the reference pointer.

Parameters

token (in)
token to add

Complexity

Amortized constant.

Examples

Example

The example shows the result of push_back for different JSON Pointers.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create empty JSON Pointer
-    json::json_pointer ptr;
-    std::cout << "\"" << ptr << "\"\n";
+    json::json_pointer ptr;
+    std::cout << "\"" << ptr << "\"\n";
 
     // call push_back()
-    ptr.push_back("foo");
-    std::cout << "\"" << ptr << "\"\n";
+    ptr.push_back("foo");
+    std::cout << "\"" << ptr << "\"\n";
 
-    ptr.push_back("0");
-    std::cout << "\"" << ptr << "\"\n";
+    ptr.push_back("0");
+    std::cout << "\"" << ptr << "\"\n";
 
-    ptr.push_back("bar");
-    std::cout << "\"" << ptr << "\"\n";
-}
-

Output:

""
-"/foo"
-"/foo/0"
-"/foo/0/bar"
-

Version history

  • Added in version 3.6.0.
  • Changed type of token to string_t in version 3.11.0.

Last update: May 1, 2022
\ No newline at end of file + ptr.push_back("bar"); + std::cout << "\"" << ptr << "\"\n"; +} +

Output:

""
+"/foo"
+"/foo/0"
+"/foo/0/bar"
+

Version history

  • Added in version 3.6.0.
  • Changed type of token to string_t in version 3.11.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/json_pointer/string_t/index.html b/api/json_pointer/string_t/index.html index 71b2c2604..03144b38a 100644 --- a/api/json_pointer/string_t/index.html +++ b/api/json_pointer/string_t/index.html @@ -1,17 +1,17 @@ - string_t - JSON for Modern C++
Skip to content

nlohmann::json_pointer::string_t

using string_t = RefStringType;
-

The string type used for the reference tokens making up the JSON pointer.

See basic_json::string_t for more information.

Examples

Example

The example shows the type string_t and its relation to basic_json::string_t.

#include <iostream>
-#include <nlohmann/json.hpp>
+ string_t - JSON for Modern C++       

nlohmann::json_pointer::string_t

using string_t = RefStringType;
+

The string type used for the reference tokens making up the JSON pointer.

See basic_json::string_t for more information.

Examples

Example

The example shows the type string_t and its relation to basic_json::string_t.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    json::json_pointer::string_t s = "This is a string.";
+int main()
+{
+    json::json_pointer::string_t s = "This is a string.";
 
-    std::cout << s << std::endl;
+    std::cout << s << std::endl;
 
-    std::cout << std::boolalpha << std::is_same<json::json_pointer::string_t, json::string_t>::value << std::endl;
-}
-

Output:

This is a string.
-true
-

Version history

  • Added in version 3.11.0.

Last update: May 17, 2022
\ No newline at end of file + std::cout << std::boolalpha << std::is_same<json::json_pointer::string_t, json::string_t>::value << std::endl; +} +

Output:

This is a string.
+true
+

Version history

  • Added in version 3.11.0.

Last update: May 17, 2022
\ No newline at end of file diff --git a/api/json_pointer/to_string/index.html b/api/json_pointer/to_string/index.html index e3693fd44..c3009dec0 100644 --- a/api/json_pointer/to_string/index.html +++ b/api/json_pointer/to_string/index.html @@ -1,49 +1,49 @@ - to_string - JSON for Modern C++
Skip to content

nlohmann::json_pointer::to_string

string_t to_string() const;
-

Return a string representation of the JSON pointer.

Return value

A string representation of the JSON pointer

Notes

For each JSON pointer ptr, it holds:

ptr == json_pointer(ptr.to_string());
-

Examples

Example

The example shows the result of to_string.

#include <iostream>
-#include <nlohmann/json.hpp>
+ to_string - JSON for Modern C++       

nlohmann::json_pointer::to_string

string_t to_string() const;
+

Return a string representation of the JSON pointer.

Return value

A string representation of the JSON pointer

Notes

For each JSON pointer ptr, it holds:

ptr == json_pointer(ptr.to_string());
+

Examples

Example

The example shows the result of to_string.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // different JSON Pointers
-    json::json_pointer ptr1("");
-    json::json_pointer ptr2("/foo");
-    json::json_pointer ptr3("/foo/0");
-    json::json_pointer ptr4("/");
-    json::json_pointer ptr5("/a~1b");
-    json::json_pointer ptr6("/c%d");
-    json::json_pointer ptr7("/e^f");
-    json::json_pointer ptr8("/g|h");
-    json::json_pointer ptr9("/i\\j");
-    json::json_pointer ptr10("/k\"l");
-    json::json_pointer ptr11("/ ");
-    json::json_pointer ptr12("/m~0n");
+    json::json_pointer ptr1("");
+    json::json_pointer ptr2("/foo");
+    json::json_pointer ptr3("/foo/0");
+    json::json_pointer ptr4("/");
+    json::json_pointer ptr5("/a~1b");
+    json::json_pointer ptr6("/c%d");
+    json::json_pointer ptr7("/e^f");
+    json::json_pointer ptr8("/g|h");
+    json::json_pointer ptr9("/i\\j");
+    json::json_pointer ptr10("/k\"l");
+    json::json_pointer ptr11("/ ");
+    json::json_pointer ptr12("/m~0n");
 
-    std::cout << "\"" << ptr1.to_string() << "\"\n"
-              << "\"" << ptr2.to_string() << "\"\n"
-              << "\"" << ptr3.to_string() << "\"\n"
-              << "\"" << ptr4.to_string() << "\"\n"
-              << "\"" << ptr5.to_string() << "\"\n"
-              << "\"" << ptr6.to_string() << "\"\n"
-              << "\"" << ptr7.to_string() << "\"\n"
-              << "\"" << ptr8.to_string() << "\"\n"
-              << "\"" << ptr9.to_string() << "\"\n"
-              << "\"" << ptr10.to_string() << "\"\n"
-              << "\"" << ptr11.to_string() << "\"\n"
-              << "\"" << ptr12.to_string() << "\"" << std::endl;
-}
-

Output:

""
-"/foo"
-"/foo/0"
-"/"
-"/a~1b"
-"/c%d"
-"/e^f"
-"/g|h"
-"/i\j"
+    std::cout << "\"" << ptr1.to_string() << "\"\n"
+              << "\"" << ptr2.to_string() << "\"\n"
+              << "\"" << ptr3.to_string() << "\"\n"
+              << "\"" << ptr4.to_string() << "\"\n"
+              << "\"" << ptr5.to_string() << "\"\n"
+              << "\"" << ptr6.to_string() << "\"\n"
+              << "\"" << ptr7.to_string() << "\"\n"
+              << "\"" << ptr8.to_string() << "\"\n"
+              << "\"" << ptr9.to_string() << "\"\n"
+              << "\"" << ptr10.to_string() << "\"\n"
+              << "\"" << ptr11.to_string() << "\"\n"
+              << "\"" << ptr12.to_string() << "\"" << std::endl;
+}
+

Output:

""
+"/foo"
+"/foo/0"
+"/"
+"/a~1b"
+"/c%d"
+"/e^f"
+"/g|h"
+"/i\j"
 "/k"l"
 "/ "
 "/m~0n"
-

Version history

  • Since version 2.0.0.
  • Changed return type to string_t in version 3.11.0.

Last update: May 1, 2022
\ No newline at end of file +

Version history

  • Since version 2.0.0.
  • Changed return type to string_t in version 3.11.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/json_sax/binary/index.html b/api/json_sax/binary/index.html index 23af06fe5..0d445aae2 100644 --- a/api/json_sax/binary/index.html +++ b/api/json_sax/binary/index.html @@ -1,119 +1,119 @@ - binary - JSON for Modern C++
Skip to content

nlohmann::json_sax::binary

virtual bool binary(binary_t& val) = 0;
-

A binary value was read.

Parameters

val (in)
binary value

Return value

Whether parsing should proceed.

Notes

It is safe to move the passed binary value.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <nlohmann/json.hpp>
+ binary - JSON for Modern C++       

nlohmann::json_sax::binary

virtual bool binary(binary_t& val) = 0;
+

A binary value was read.

Parameters

val (in)
binary value

Return value

Whether parsing should proceed.

Notes

It is safe to move the passed binary value.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
 // a simple event consumer that collects string representations of the passed
 // values; note inheriting from json::json_sax_t is not required, but can
 // help not to forget a required function
-class sax_event_consumer : public json::json_sax_t
-{
-  public:
-    std::vector<std::string> events;
+class sax_event_consumer : public json::json_sax_t
+{
+  public:
+    std::vector<std::string> events;
 
-    bool null() override
-    {
-        events.push_back("null()");
-        return true;
-    }
+    bool null() override
+    {
+        events.push_back("null()");
+        return true;
+    }
 
-    bool boolean(bool val) override
-    {
-        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
-        return true;
-    }
+    bool boolean(bool val) override
+    {
+        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
+        return true;
+    }
 
-    bool number_integer(number_integer_t val) override
-    {
-        events.push_back("number_integer(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_integer(number_integer_t val) override
+    {
+        events.push_back("number_integer(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_unsigned(number_unsigned_t val) override
-    {
-        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_unsigned(number_unsigned_t val) override
+    {
+        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_float(number_float_t val, const string_t& s) override
-    {
-        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
-        return true;
-    }
+    bool number_float(number_float_t val, const string_t& s) override
+    {
+        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
+        return true;
+    }
 
-    bool string(string_t& val) override
-    {
-        events.push_back("string(val=" + val + ")");
-        return true;
-    }
+    bool string(string_t& val) override
+    {
+        events.push_back("string(val=" + val + ")");
+        return true;
+    }
 
-    bool start_object(std::size_t elements) override
-    {
-        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_object(std::size_t elements) override
+    {
+        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_object() override
-    {
-        events.push_back("end_object()");
-        return true;
-    }
+    bool end_object() override
+    {
+        events.push_back("end_object()");
+        return true;
+    }
 
-    bool start_array(std::size_t elements) override
-    {
-        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_array(std::size_t elements) override
+    {
+        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_array() override
-    {
-        events.push_back("end_array()");
-        return true;
-    }
+    bool end_array() override
+    {
+        events.push_back("end_array()");
+        return true;
+    }
 
-    bool key(string_t& val) override
-    {
-        events.push_back("key(val=" + val + ")");
-        return true;
-    }
+    bool key(string_t& val) override
+    {
+        events.push_back("key(val=" + val + ")");
+        return true;
+    }
 
-    bool binary(json::binary_t& val) override
-    {
-        events.push_back("binary(val=[...])");
-        return true;
-    }
+    bool binary(json::binary_t& val) override
+    {
+        events.push_back("binary(val=[...])");
+        return true;
+    }
 
-    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
-    {
-        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
-        return false;
-    }
-};
+    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
+    {
+        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
+        return false;
+    }
+};
 
-int main()
-{
+int main()
+{
     // CBOR byte string
-    std::vector<std::uint8_t> vec = {{0x44, 0xcA, 0xfe, 0xba, 0xbe}};
+    std::vector<std::uint8_t> vec = {{0x44, 0xcA, 0xfe, 0xba, 0xbe}};
 
     // create a SAX event consumer object
-    sax_event_consumer sec;
+    sax_event_consumer sec;
 
     // parse CBOR
-    bool result = json::sax_parse(vec, &sec, json::input_format_t::cbor);
+    bool result = json::sax_parse(vec, &sec, json::input_format_t::cbor);
 
     // output the recorded events
-    for (auto& event : sec.events)
-    {
-        std::cout << event << "\n";
-    }
+    for (auto& event : sec.events)
+    {
+        std::cout << event << "\n";
+    }
 
     // output the result of sax_parse
-    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
-}
-

Output:

binary(val=[...])
+    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
+}
+

Output:

binary(val=[...])
 
-result: true
-

Version history

  • Added in version 3.8.0.

Last update: August 5, 2022
\ No newline at end of file +result: true +

Version history

  • Added in version 3.8.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/json_sax/boolean/index.html b/api/json_sax/boolean/index.html index eea262991..c3eba6d9d 100644 --- a/api/json_sax/boolean/index.html +++ b/api/json_sax/boolean/index.html @@ -1,102 +1,102 @@ - boolean - JSON for Modern C++
Skip to content

nlohmann::json_sax::boolean

virtual bool boolean(bool val) = 0;
-

A boolean value was read.

Parameters

val (in)
boolean value

Return value

Whether parsing should proceed.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <nlohmann/json.hpp>
+ boolean - JSON for Modern C++       

nlohmann::json_sax::boolean

virtual bool boolean(bool val) = 0;
+

A boolean value was read.

Parameters

val (in)
boolean value

Return value

Whether parsing should proceed.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
 // a simple event consumer that collects string representations of the passed
 // values; note inheriting from json::json_sax_t is not required, but can
 // help not to forget a required function
-class sax_event_consumer : public json::json_sax_t
-{
-  public:
-    std::vector<std::string> events;
+class sax_event_consumer : public json::json_sax_t
+{
+  public:
+    std::vector<std::string> events;
 
-    bool null() override
-    {
-        events.push_back("null()");
-        return true;
-    }
+    bool null() override
+    {
+        events.push_back("null()");
+        return true;
+    }
 
-    bool boolean(bool val) override
-    {
-        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
-        return true;
-    }
+    bool boolean(bool val) override
+    {
+        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
+        return true;
+    }
 
-    bool number_integer(number_integer_t val) override
-    {
-        events.push_back("number_integer(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_integer(number_integer_t val) override
+    {
+        events.push_back("number_integer(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_unsigned(number_unsigned_t val) override
-    {
-        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_unsigned(number_unsigned_t val) override
+    {
+        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_float(number_float_t val, const string_t& s) override
-    {
-        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
-        return true;
-    }
+    bool number_float(number_float_t val, const string_t& s) override
+    {
+        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
+        return true;
+    }
 
-    bool string(string_t& val) override
-    {
-        events.push_back("string(val=" + val + ")");
-        return true;
-    }
+    bool string(string_t& val) override
+    {
+        events.push_back("string(val=" + val + ")");
+        return true;
+    }
 
-    bool start_object(std::size_t elements) override
-    {
-        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_object(std::size_t elements) override
+    {
+        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_object() override
-    {
-        events.push_back("end_object()");
-        return true;
-    }
+    bool end_object() override
+    {
+        events.push_back("end_object()");
+        return true;
+    }
 
-    bool start_array(std::size_t elements) override
-    {
-        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_array(std::size_t elements) override
+    {
+        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_array() override
-    {
-        events.push_back("end_array()");
-        return true;
-    }
+    bool end_array() override
+    {
+        events.push_back("end_array()");
+        return true;
+    }
 
-    bool key(string_t& val) override
-    {
-        events.push_back("key(val=" + val + ")");
-        return true;
-    }
+    bool key(string_t& val) override
+    {
+        events.push_back("key(val=" + val + ")");
+        return true;
+    }
 
-    bool binary(json::binary_t& val) override
-    {
-        events.push_back("binary(val=[...])");
-        return true;
-    }
+    bool binary(json::binary_t& val) override
+    {
+        events.push_back("binary(val=[...])");
+        return true;
+    }
 
-    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
-    {
-        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
-        return false;
-    }
-};
+    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
+    {
+        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
+        return false;
+    }
+};
 
-int main()
-{
+int main()
+{
     // a JSON text
-    auto text = R"(
+    auto text = R"(
     {
         "Image": {
             "Width":  800,
@@ -113,58 +113,58 @@
             "Distance": 12.723374634
         }
     }]
-    )";
+    )";
 
     // create a SAX event consumer object
-    sax_event_consumer sec;
+    sax_event_consumer sec;
 
     // parse JSON
-    bool result = json::sax_parse(text, &sec);
+    bool result = json::sax_parse(text, &sec);
 
     // output the recorded events
-    for (auto& event : sec.events)
-    {
-        std::cout << event << "\n";
-    }
+    for (auto& event : sec.events)
+    {
+        std::cout << event << "\n";
+    }
 
     // output the result of sax_parse
-    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
-}
-

Output:

start_object(elements=18446744073709551615)
-key(val=Image)
-start_object(elements=18446744073709551615)
-key(val=Width)
-number_unsigned(val=800)
-key(val=Height)
-number_unsigned(val=600)
-key(val=Title)
-string(val=View from 15th Floor)
-key(val=Thumbnail)
-start_object(elements=18446744073709551615)
-key(val=Url)
-string(val=http://www.example.com/image/481989943)
-key(val=Height)
-number_unsigned(val=125)
-key(val=Width)
-number_unsigned(val=100)
-end_object()
-key(val=Animated)
-boolean(val=false)
-key(val=IDs)
-start_array(elements=18446744073709551615)
-number_unsigned(val=116)
-number_unsigned(val=943)
-number_unsigned(val=234)
-number_integer(val=-38793)
-end_array()
-key(val=DeletionDate)
-null()
-key(val=Distance)
-number_float(val=12.723375, s=12.723374634)
-end_object()
-end_object()
-parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
-            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
+    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
+}
+

Output:

start_object(elements=18446744073709551615)
+key(val=Image)
+start_object(elements=18446744073709551615)
+key(val=Width)
+number_unsigned(val=800)
+key(val=Height)
+number_unsigned(val=600)
+key(val=Title)
+string(val=View from 15th Floor)
+key(val=Thumbnail)
+start_object(elements=18446744073709551615)
+key(val=Url)
+string(val=http://www.example.com/image/481989943)
+key(val=Height)
+number_unsigned(val=125)
+key(val=Width)
+number_unsigned(val=100)
+end_object()
+key(val=Animated)
+boolean(val=false)
+key(val=IDs)
+start_array(elements=18446744073709551615)
+number_unsigned(val=116)
+number_unsigned(val=943)
+number_unsigned(val=234)
+number_integer(val=-38793)
+end_array()
+key(val=DeletionDate)
+null()
+key(val=Distance)
+number_float(val=12.723375, s=12.723374634)
+end_object()
+end_object()
+parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
+            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
 
-result: false
-

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file +result: false +

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/json_sax/end_array/index.html b/api/json_sax/end_array/index.html index 31f9c22ef..53f71f23f 100644 --- a/api/json_sax/end_array/index.html +++ b/api/json_sax/end_array/index.html @@ -1,102 +1,102 @@ - end_array - JSON for Modern C++
Skip to content

nlohmann::json_sax::end_array

virtual bool end_array() = 0;
-

The end of an array was read.

Return value

Whether parsing should proceed.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <nlohmann/json.hpp>
+ end_array - JSON for Modern C++       

nlohmann::json_sax::end_array

virtual bool end_array() = 0;
+

The end of an array was read.

Return value

Whether parsing should proceed.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
 // a simple event consumer that collects string representations of the passed
 // values; note inheriting from json::json_sax_t is not required, but can
 // help not to forget a required function
-class sax_event_consumer : public json::json_sax_t
-{
-  public:
-    std::vector<std::string> events;
+class sax_event_consumer : public json::json_sax_t
+{
+  public:
+    std::vector<std::string> events;
 
-    bool null() override
-    {
-        events.push_back("null()");
-        return true;
-    }
+    bool null() override
+    {
+        events.push_back("null()");
+        return true;
+    }
 
-    bool boolean(bool val) override
-    {
-        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
-        return true;
-    }
+    bool boolean(bool val) override
+    {
+        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
+        return true;
+    }
 
-    bool number_integer(number_integer_t val) override
-    {
-        events.push_back("number_integer(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_integer(number_integer_t val) override
+    {
+        events.push_back("number_integer(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_unsigned(number_unsigned_t val) override
-    {
-        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_unsigned(number_unsigned_t val) override
+    {
+        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_float(number_float_t val, const string_t& s) override
-    {
-        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
-        return true;
-    }
+    bool number_float(number_float_t val, const string_t& s) override
+    {
+        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
+        return true;
+    }
 
-    bool string(string_t& val) override
-    {
-        events.push_back("string(val=" + val + ")");
-        return true;
-    }
+    bool string(string_t& val) override
+    {
+        events.push_back("string(val=" + val + ")");
+        return true;
+    }
 
-    bool start_object(std::size_t elements) override
-    {
-        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_object(std::size_t elements) override
+    {
+        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_object() override
-    {
-        events.push_back("end_object()");
-        return true;
-    }
+    bool end_object() override
+    {
+        events.push_back("end_object()");
+        return true;
+    }
 
-    bool start_array(std::size_t elements) override
-    {
-        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_array(std::size_t elements) override
+    {
+        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_array() override
-    {
-        events.push_back("end_array()");
-        return true;
-    }
+    bool end_array() override
+    {
+        events.push_back("end_array()");
+        return true;
+    }
 
-    bool key(string_t& val) override
-    {
-        events.push_back("key(val=" + val + ")");
-        return true;
-    }
+    bool key(string_t& val) override
+    {
+        events.push_back("key(val=" + val + ")");
+        return true;
+    }
 
-    bool binary(json::binary_t& val) override
-    {
-        events.push_back("binary(val=[...])");
-        return true;
-    }
+    bool binary(json::binary_t& val) override
+    {
+        events.push_back("binary(val=[...])");
+        return true;
+    }
 
-    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
-    {
-        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
-        return false;
-    }
-};
+    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
+    {
+        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
+        return false;
+    }
+};
 
-int main()
-{
+int main()
+{
     // a JSON text
-    auto text = R"(
+    auto text = R"(
     {
         "Image": {
             "Width":  800,
@@ -113,58 +113,58 @@
             "Distance": 12.723374634
         }
     }]
-    )";
+    )";
 
     // create a SAX event consumer object
-    sax_event_consumer sec;
+    sax_event_consumer sec;
 
     // parse JSON
-    bool result = json::sax_parse(text, &sec);
+    bool result = json::sax_parse(text, &sec);
 
     // output the recorded events
-    for (auto& event : sec.events)
-    {
-        std::cout << event << "\n";
-    }
+    for (auto& event : sec.events)
+    {
+        std::cout << event << "\n";
+    }
 
     // output the result of sax_parse
-    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
-}
-

Output:

start_object(elements=18446744073709551615)
-key(val=Image)
-start_object(elements=18446744073709551615)
-key(val=Width)
-number_unsigned(val=800)
-key(val=Height)
-number_unsigned(val=600)
-key(val=Title)
-string(val=View from 15th Floor)
-key(val=Thumbnail)
-start_object(elements=18446744073709551615)
-key(val=Url)
-string(val=http://www.example.com/image/481989943)
-key(val=Height)
-number_unsigned(val=125)
-key(val=Width)
-number_unsigned(val=100)
-end_object()
-key(val=Animated)
-boolean(val=false)
-key(val=IDs)
-start_array(elements=18446744073709551615)
-number_unsigned(val=116)
-number_unsigned(val=943)
-number_unsigned(val=234)
-number_integer(val=-38793)
-end_array()
-key(val=DeletionDate)
-null()
-key(val=Distance)
-number_float(val=12.723375, s=12.723374634)
-end_object()
-end_object()
-parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
-            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
+    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
+}
+

Output:

start_object(elements=18446744073709551615)
+key(val=Image)
+start_object(elements=18446744073709551615)
+key(val=Width)
+number_unsigned(val=800)
+key(val=Height)
+number_unsigned(val=600)
+key(val=Title)
+string(val=View from 15th Floor)
+key(val=Thumbnail)
+start_object(elements=18446744073709551615)
+key(val=Url)
+string(val=http://www.example.com/image/481989943)
+key(val=Height)
+number_unsigned(val=125)
+key(val=Width)
+number_unsigned(val=100)
+end_object()
+key(val=Animated)
+boolean(val=false)
+key(val=IDs)
+start_array(elements=18446744073709551615)
+number_unsigned(val=116)
+number_unsigned(val=943)
+number_unsigned(val=234)
+number_integer(val=-38793)
+end_array()
+key(val=DeletionDate)
+null()
+key(val=Distance)
+number_float(val=12.723375, s=12.723374634)
+end_object()
+end_object()
+parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
+            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
 
-result: false
-

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file +result: false +

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/json_sax/end_object/index.html b/api/json_sax/end_object/index.html index 336f30556..016e68c06 100644 --- a/api/json_sax/end_object/index.html +++ b/api/json_sax/end_object/index.html @@ -1,102 +1,102 @@ - end_object - JSON for Modern C++
Skip to content

nlohmann::json_sax::end_object

virtual bool end_object() = 0;
-

The end of an object was read.

Return value

Whether parsing should proceed.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <nlohmann/json.hpp>
+ end_object - JSON for Modern C++       

nlohmann::json_sax::end_object

virtual bool end_object() = 0;
+

The end of an object was read.

Return value

Whether parsing should proceed.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
 // a simple event consumer that collects string representations of the passed
 // values; note inheriting from json::json_sax_t is not required, but can
 // help not to forget a required function
-class sax_event_consumer : public json::json_sax_t
-{
-  public:
-    std::vector<std::string> events;
+class sax_event_consumer : public json::json_sax_t
+{
+  public:
+    std::vector<std::string> events;
 
-    bool null() override
-    {
-        events.push_back("null()");
-        return true;
-    }
+    bool null() override
+    {
+        events.push_back("null()");
+        return true;
+    }
 
-    bool boolean(bool val) override
-    {
-        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
-        return true;
-    }
+    bool boolean(bool val) override
+    {
+        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
+        return true;
+    }
 
-    bool number_integer(number_integer_t val) override
-    {
-        events.push_back("number_integer(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_integer(number_integer_t val) override
+    {
+        events.push_back("number_integer(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_unsigned(number_unsigned_t val) override
-    {
-        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_unsigned(number_unsigned_t val) override
+    {
+        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_float(number_float_t val, const string_t& s) override
-    {
-        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
-        return true;
-    }
+    bool number_float(number_float_t val, const string_t& s) override
+    {
+        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
+        return true;
+    }
 
-    bool string(string_t& val) override
-    {
-        events.push_back("string(val=" + val + ")");
-        return true;
-    }
+    bool string(string_t& val) override
+    {
+        events.push_back("string(val=" + val + ")");
+        return true;
+    }
 
-    bool start_object(std::size_t elements) override
-    {
-        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_object(std::size_t elements) override
+    {
+        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_object() override
-    {
-        events.push_back("end_object()");
-        return true;
-    }
+    bool end_object() override
+    {
+        events.push_back("end_object()");
+        return true;
+    }
 
-    bool start_array(std::size_t elements) override
-    {
-        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_array(std::size_t elements) override
+    {
+        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_array() override
-    {
-        events.push_back("end_array()");
-        return true;
-    }
+    bool end_array() override
+    {
+        events.push_back("end_array()");
+        return true;
+    }
 
-    bool key(string_t& val) override
-    {
-        events.push_back("key(val=" + val + ")");
-        return true;
-    }
+    bool key(string_t& val) override
+    {
+        events.push_back("key(val=" + val + ")");
+        return true;
+    }
 
-    bool binary(json::binary_t& val) override
-    {
-        events.push_back("binary(val=[...])");
-        return true;
-    }
+    bool binary(json::binary_t& val) override
+    {
+        events.push_back("binary(val=[...])");
+        return true;
+    }
 
-    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
-    {
-        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
-        return false;
-    }
-};
+    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
+    {
+        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
+        return false;
+    }
+};
 
-int main()
-{
+int main()
+{
     // a JSON text
-    auto text = R"(
+    auto text = R"(
     {
         "Image": {
             "Width":  800,
@@ -113,58 +113,58 @@
             "Distance": 12.723374634
         }
     }]
-    )";
+    )";
 
     // create a SAX event consumer object
-    sax_event_consumer sec;
+    sax_event_consumer sec;
 
     // parse JSON
-    bool result = json::sax_parse(text, &sec);
+    bool result = json::sax_parse(text, &sec);
 
     // output the recorded events
-    for (auto& event : sec.events)
-    {
-        std::cout << event << "\n";
-    }
+    for (auto& event : sec.events)
+    {
+        std::cout << event << "\n";
+    }
 
     // output the result of sax_parse
-    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
-}
-

Output:

start_object(elements=18446744073709551615)
-key(val=Image)
-start_object(elements=18446744073709551615)
-key(val=Width)
-number_unsigned(val=800)
-key(val=Height)
-number_unsigned(val=600)
-key(val=Title)
-string(val=View from 15th Floor)
-key(val=Thumbnail)
-start_object(elements=18446744073709551615)
-key(val=Url)
-string(val=http://www.example.com/image/481989943)
-key(val=Height)
-number_unsigned(val=125)
-key(val=Width)
-number_unsigned(val=100)
-end_object()
-key(val=Animated)
-boolean(val=false)
-key(val=IDs)
-start_array(elements=18446744073709551615)
-number_unsigned(val=116)
-number_unsigned(val=943)
-number_unsigned(val=234)
-number_integer(val=-38793)
-end_array()
-key(val=DeletionDate)
-null()
-key(val=Distance)
-number_float(val=12.723375, s=12.723374634)
-end_object()
-end_object()
-parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
-            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
+    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
+}
+

Output:

start_object(elements=18446744073709551615)
+key(val=Image)
+start_object(elements=18446744073709551615)
+key(val=Width)
+number_unsigned(val=800)
+key(val=Height)
+number_unsigned(val=600)
+key(val=Title)
+string(val=View from 15th Floor)
+key(val=Thumbnail)
+start_object(elements=18446744073709551615)
+key(val=Url)
+string(val=http://www.example.com/image/481989943)
+key(val=Height)
+number_unsigned(val=125)
+key(val=Width)
+number_unsigned(val=100)
+end_object()
+key(val=Animated)
+boolean(val=false)
+key(val=IDs)
+start_array(elements=18446744073709551615)
+number_unsigned(val=116)
+number_unsigned(val=943)
+number_unsigned(val=234)
+number_integer(val=-38793)
+end_array()
+key(val=DeletionDate)
+null()
+key(val=Distance)
+number_float(val=12.723375, s=12.723374634)
+end_object()
+end_object()
+parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
+            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
 
-result: false
-

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file +result: false +

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/json_sax/index.html b/api/json_sax/index.html index 56f2c5c6a..36d32ca0a 100644 --- a/api/json_sax/index.html +++ b/api/json_sax/index.html @@ -1,3 +1,3 @@ - Overview - JSON for Modern C++
Skip to content

nlohmann::json_sax

template<typename BasicJsonType>
-struct json_sax;
-

This class describes the SAX interface used by sax_parse. Each function is called in different situations while the input is parsed. The boolean return value informs the parser whether to continue processing the input.

Template parameters

BasicJsonType
a specialization of basic_json

Member types

Member functions

  • binary (virtual) - a binary value was read
  • boolean (virtual) - a boolean value was read
  • end_array (virtual) - the end of an array was read
  • end_object (virtual) - the end of an object was read
  • key (virtual) - an object key was read
  • null (virtual) - a null value was read
  • number_float (virtual) - a floating-point number was read
  • number_integer (virtual) - an integer number was read
  • number_unsigned (virtual) - an unsigned integer number was read
  • parse_error (virtual) - a parse error occurred
  • start_array (virtual) - the beginning of an array was read
  • start_object (virtual) - the beginning of an object was read
  • string (virtual) - a string value was read

Version history

  • Added in version 3.2.0.
  • Support for binary values (binary_t, binary) added in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file + Overview - JSON for Modern C++
Skip to content

nlohmann::json_sax

template<typename BasicJsonType>
+struct json_sax;
+

This class describes the SAX interface used by sax_parse. Each function is called in different situations while the input is parsed. The boolean return value informs the parser whether to continue processing the input.

Template parameters

BasicJsonType
a specialization of basic_json

Member types

Member functions

  • binary (virtual) - a binary value was read
  • boolean (virtual) - a boolean value was read
  • end_array (virtual) - the end of an array was read
  • end_object (virtual) - the end of an object was read
  • key (virtual) - an object key was read
  • null (virtual) - a null value was read
  • number_float (virtual) - a floating-point number was read
  • number_integer (virtual) - an integer number was read
  • number_unsigned (virtual) - an unsigned integer number was read
  • parse_error (virtual) - a parse error occurred
  • start_array (virtual) - the beginning of an array was read
  • start_object (virtual) - the beginning of an object was read
  • string (virtual) - a string value was read

Version history

  • Added in version 3.2.0.
  • Support for binary values (binary_t, binary) added in version 3.8.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/json_sax/key/index.html b/api/json_sax/key/index.html index a2f1cc127..8d4f44dba 100644 --- a/api/json_sax/key/index.html +++ b/api/json_sax/key/index.html @@ -1,102 +1,102 @@ - key - JSON for Modern C++
Skip to content

nlohmann::json_sax::key

virtual bool key(string_t& val) = 0;
-

An object key was read.

Parameters

val (in)
object key

Return value

Whether parsing should proceed.

Notes

It is safe to move the passed object key value.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <nlohmann/json.hpp>
+ key - JSON for Modern C++       

nlohmann::json_sax::key

virtual bool key(string_t& val) = 0;
+

An object key was read.

Parameters

val (in)
object key

Return value

Whether parsing should proceed.

Notes

It is safe to move the passed object key value.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
 // a simple event consumer that collects string representations of the passed
 // values; note inheriting from json::json_sax_t is not required, but can
 // help not to forget a required function
-class sax_event_consumer : public json::json_sax_t
-{
-  public:
-    std::vector<std::string> events;
+class sax_event_consumer : public json::json_sax_t
+{
+  public:
+    std::vector<std::string> events;
 
-    bool null() override
-    {
-        events.push_back("null()");
-        return true;
-    }
+    bool null() override
+    {
+        events.push_back("null()");
+        return true;
+    }
 
-    bool boolean(bool val) override
-    {
-        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
-        return true;
-    }
+    bool boolean(bool val) override
+    {
+        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
+        return true;
+    }
 
-    bool number_integer(number_integer_t val) override
-    {
-        events.push_back("number_integer(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_integer(number_integer_t val) override
+    {
+        events.push_back("number_integer(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_unsigned(number_unsigned_t val) override
-    {
-        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_unsigned(number_unsigned_t val) override
+    {
+        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_float(number_float_t val, const string_t& s) override
-    {
-        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
-        return true;
-    }
+    bool number_float(number_float_t val, const string_t& s) override
+    {
+        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
+        return true;
+    }
 
-    bool string(string_t& val) override
-    {
-        events.push_back("string(val=" + val + ")");
-        return true;
-    }
+    bool string(string_t& val) override
+    {
+        events.push_back("string(val=" + val + ")");
+        return true;
+    }
 
-    bool start_object(std::size_t elements) override
-    {
-        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_object(std::size_t elements) override
+    {
+        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_object() override
-    {
-        events.push_back("end_object()");
-        return true;
-    }
+    bool end_object() override
+    {
+        events.push_back("end_object()");
+        return true;
+    }
 
-    bool start_array(std::size_t elements) override
-    {
-        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_array(std::size_t elements) override
+    {
+        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_array() override
-    {
-        events.push_back("end_array()");
-        return true;
-    }
+    bool end_array() override
+    {
+        events.push_back("end_array()");
+        return true;
+    }
 
-    bool key(string_t& val) override
-    {
-        events.push_back("key(val=" + val + ")");
-        return true;
-    }
+    bool key(string_t& val) override
+    {
+        events.push_back("key(val=" + val + ")");
+        return true;
+    }
 
-    bool binary(json::binary_t& val) override
-    {
-        events.push_back("binary(val=[...])");
-        return true;
-    }
+    bool binary(json::binary_t& val) override
+    {
+        events.push_back("binary(val=[...])");
+        return true;
+    }
 
-    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
-    {
-        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
-        return false;
-    }
-};
+    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
+    {
+        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
+        return false;
+    }
+};
 
-int main()
-{
+int main()
+{
     // a JSON text
-    auto text = R"(
+    auto text = R"(
     {
         "Image": {
             "Width":  800,
@@ -113,58 +113,58 @@
             "Distance": 12.723374634
         }
     }]
-    )";
+    )";
 
     // create a SAX event consumer object
-    sax_event_consumer sec;
+    sax_event_consumer sec;
 
     // parse JSON
-    bool result = json::sax_parse(text, &sec);
+    bool result = json::sax_parse(text, &sec);
 
     // output the recorded events
-    for (auto& event : sec.events)
-    {
-        std::cout << event << "\n";
-    }
+    for (auto& event : sec.events)
+    {
+        std::cout << event << "\n";
+    }
 
     // output the result of sax_parse
-    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
-}
-

Output:

start_object(elements=18446744073709551615)
-key(val=Image)
-start_object(elements=18446744073709551615)
-key(val=Width)
-number_unsigned(val=800)
-key(val=Height)
-number_unsigned(val=600)
-key(val=Title)
-string(val=View from 15th Floor)
-key(val=Thumbnail)
-start_object(elements=18446744073709551615)
-key(val=Url)
-string(val=http://www.example.com/image/481989943)
-key(val=Height)
-number_unsigned(val=125)
-key(val=Width)
-number_unsigned(val=100)
-end_object()
-key(val=Animated)
-boolean(val=false)
-key(val=IDs)
-start_array(elements=18446744073709551615)
-number_unsigned(val=116)
-number_unsigned(val=943)
-number_unsigned(val=234)
-number_integer(val=-38793)
-end_array()
-key(val=DeletionDate)
-null()
-key(val=Distance)
-number_float(val=12.723375, s=12.723374634)
-end_object()
-end_object()
-parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
-            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
+    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
+}
+

Output:

start_object(elements=18446744073709551615)
+key(val=Image)
+start_object(elements=18446744073709551615)
+key(val=Width)
+number_unsigned(val=800)
+key(val=Height)
+number_unsigned(val=600)
+key(val=Title)
+string(val=View from 15th Floor)
+key(val=Thumbnail)
+start_object(elements=18446744073709551615)
+key(val=Url)
+string(val=http://www.example.com/image/481989943)
+key(val=Height)
+number_unsigned(val=125)
+key(val=Width)
+number_unsigned(val=100)
+end_object()
+key(val=Animated)
+boolean(val=false)
+key(val=IDs)
+start_array(elements=18446744073709551615)
+number_unsigned(val=116)
+number_unsigned(val=943)
+number_unsigned(val=234)
+number_integer(val=-38793)
+end_array()
+key(val=DeletionDate)
+null()
+key(val=Distance)
+number_float(val=12.723375, s=12.723374634)
+end_object()
+end_object()
+parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
+            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
 
-result: false
-

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file +result: false +

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/json_sax/null/index.html b/api/json_sax/null/index.html index e55ac4ec2..76898224c 100644 --- a/api/json_sax/null/index.html +++ b/api/json_sax/null/index.html @@ -1,102 +1,102 @@ - null - JSON for Modern C++
Skip to content

nlohmann::json_sax::null

virtual bool null() = 0;
-

A null value was read.

Return value

Whether parsing should proceed.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <nlohmann/json.hpp>
+ null - JSON for Modern C++       

nlohmann::json_sax::null

virtual bool null() = 0;
+

A null value was read.

Return value

Whether parsing should proceed.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
 // a simple event consumer that collects string representations of the passed
 // values; note inheriting from json::json_sax_t is not required, but can
 // help not to forget a required function
-class sax_event_consumer : public json::json_sax_t
-{
-  public:
-    std::vector<std::string> events;
+class sax_event_consumer : public json::json_sax_t
+{
+  public:
+    std::vector<std::string> events;
 
-    bool null() override
-    {
-        events.push_back("null()");
-        return true;
-    }
+    bool null() override
+    {
+        events.push_back("null()");
+        return true;
+    }
 
-    bool boolean(bool val) override
-    {
-        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
-        return true;
-    }
+    bool boolean(bool val) override
+    {
+        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
+        return true;
+    }
 
-    bool number_integer(number_integer_t val) override
-    {
-        events.push_back("number_integer(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_integer(number_integer_t val) override
+    {
+        events.push_back("number_integer(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_unsigned(number_unsigned_t val) override
-    {
-        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_unsigned(number_unsigned_t val) override
+    {
+        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_float(number_float_t val, const string_t& s) override
-    {
-        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
-        return true;
-    }
+    bool number_float(number_float_t val, const string_t& s) override
+    {
+        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
+        return true;
+    }
 
-    bool string(string_t& val) override
-    {
-        events.push_back("string(val=" + val + ")");
-        return true;
-    }
+    bool string(string_t& val) override
+    {
+        events.push_back("string(val=" + val + ")");
+        return true;
+    }
 
-    bool start_object(std::size_t elements) override
-    {
-        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_object(std::size_t elements) override
+    {
+        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_object() override
-    {
-        events.push_back("end_object()");
-        return true;
-    }
+    bool end_object() override
+    {
+        events.push_back("end_object()");
+        return true;
+    }
 
-    bool start_array(std::size_t elements) override
-    {
-        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_array(std::size_t elements) override
+    {
+        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_array() override
-    {
-        events.push_back("end_array()");
-        return true;
-    }
+    bool end_array() override
+    {
+        events.push_back("end_array()");
+        return true;
+    }
 
-    bool key(string_t& val) override
-    {
-        events.push_back("key(val=" + val + ")");
-        return true;
-    }
+    bool key(string_t& val) override
+    {
+        events.push_back("key(val=" + val + ")");
+        return true;
+    }
 
-    bool binary(json::binary_t& val) override
-    {
-        events.push_back("binary(val=[...])");
-        return true;
-    }
+    bool binary(json::binary_t& val) override
+    {
+        events.push_back("binary(val=[...])");
+        return true;
+    }
 
-    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
-    {
-        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
-        return false;
-    }
-};
+    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
+    {
+        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
+        return false;
+    }
+};
 
-int main()
-{
+int main()
+{
     // a JSON text
-    auto text = R"(
+    auto text = R"(
     {
         "Image": {
             "Width":  800,
@@ -113,58 +113,58 @@
             "Distance": 12.723374634
         }
     }]
-    )";
+    )";
 
     // create a SAX event consumer object
-    sax_event_consumer sec;
+    sax_event_consumer sec;
 
     // parse JSON
-    bool result = json::sax_parse(text, &sec);
+    bool result = json::sax_parse(text, &sec);
 
     // output the recorded events
-    for (auto& event : sec.events)
-    {
-        std::cout << event << "\n";
-    }
+    for (auto& event : sec.events)
+    {
+        std::cout << event << "\n";
+    }
 
     // output the result of sax_parse
-    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
-}
-

Output:

start_object(elements=18446744073709551615)
-key(val=Image)
-start_object(elements=18446744073709551615)
-key(val=Width)
-number_unsigned(val=800)
-key(val=Height)
-number_unsigned(val=600)
-key(val=Title)
-string(val=View from 15th Floor)
-key(val=Thumbnail)
-start_object(elements=18446744073709551615)
-key(val=Url)
-string(val=http://www.example.com/image/481989943)
-key(val=Height)
-number_unsigned(val=125)
-key(val=Width)
-number_unsigned(val=100)
-end_object()
-key(val=Animated)
-boolean(val=false)
-key(val=IDs)
-start_array(elements=18446744073709551615)
-number_unsigned(val=116)
-number_unsigned(val=943)
-number_unsigned(val=234)
-number_integer(val=-38793)
-end_array()
-key(val=DeletionDate)
-null()
-key(val=Distance)
-number_float(val=12.723375, s=12.723374634)
-end_object()
-end_object()
-parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
-            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
+    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
+}
+

Output:

start_object(elements=18446744073709551615)
+key(val=Image)
+start_object(elements=18446744073709551615)
+key(val=Width)
+number_unsigned(val=800)
+key(val=Height)
+number_unsigned(val=600)
+key(val=Title)
+string(val=View from 15th Floor)
+key(val=Thumbnail)
+start_object(elements=18446744073709551615)
+key(val=Url)
+string(val=http://www.example.com/image/481989943)
+key(val=Height)
+number_unsigned(val=125)
+key(val=Width)
+number_unsigned(val=100)
+end_object()
+key(val=Animated)
+boolean(val=false)
+key(val=IDs)
+start_array(elements=18446744073709551615)
+number_unsigned(val=116)
+number_unsigned(val=943)
+number_unsigned(val=234)
+number_integer(val=-38793)
+end_array()
+key(val=DeletionDate)
+null()
+key(val=Distance)
+number_float(val=12.723375, s=12.723374634)
+end_object()
+end_object()
+parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
+            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
 
-result: false
-

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file +result: false +

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/json_sax/number_float/index.html b/api/json_sax/number_float/index.html index 6eea14b07..d8c92f001 100644 --- a/api/json_sax/number_float/index.html +++ b/api/json_sax/number_float/index.html @@ -1,102 +1,102 @@ - number_float - JSON for Modern C++
Skip to content

nlohmann::json_sax::number_float

virtual bool number_float(number_float_t val, const string_t& s) = 0;
-

A floating-point number was read.

Parameters

val (in)
floating-point value
s (in)
string representation of the original input

Return value

Whether parsing should proceed.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <nlohmann/json.hpp>
+ number_float - JSON for Modern C++       

nlohmann::json_sax::number_float

virtual bool number_float(number_float_t val, const string_t& s) = 0;
+

A floating-point number was read.

Parameters

val (in)
floating-point value
s (in)
string representation of the original input

Return value

Whether parsing should proceed.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
 // a simple event consumer that collects string representations of the passed
 // values; note inheriting from json::json_sax_t is not required, but can
 // help not to forget a required function
-class sax_event_consumer : public json::json_sax_t
-{
-  public:
-    std::vector<std::string> events;
+class sax_event_consumer : public json::json_sax_t
+{
+  public:
+    std::vector<std::string> events;
 
-    bool null() override
-    {
-        events.push_back("null()");
-        return true;
-    }
+    bool null() override
+    {
+        events.push_back("null()");
+        return true;
+    }
 
-    bool boolean(bool val) override
-    {
-        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
-        return true;
-    }
+    bool boolean(bool val) override
+    {
+        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
+        return true;
+    }
 
-    bool number_integer(number_integer_t val) override
-    {
-        events.push_back("number_integer(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_integer(number_integer_t val) override
+    {
+        events.push_back("number_integer(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_unsigned(number_unsigned_t val) override
-    {
-        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_unsigned(number_unsigned_t val) override
+    {
+        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_float(number_float_t val, const string_t& s) override
-    {
-        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
-        return true;
-    }
+    bool number_float(number_float_t val, const string_t& s) override
+    {
+        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
+        return true;
+    }
 
-    bool string(string_t& val) override
-    {
-        events.push_back("string(val=" + val + ")");
-        return true;
-    }
+    bool string(string_t& val) override
+    {
+        events.push_back("string(val=" + val + ")");
+        return true;
+    }
 
-    bool start_object(std::size_t elements) override
-    {
-        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_object(std::size_t elements) override
+    {
+        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_object() override
-    {
-        events.push_back("end_object()");
-        return true;
-    }
+    bool end_object() override
+    {
+        events.push_back("end_object()");
+        return true;
+    }
 
-    bool start_array(std::size_t elements) override
-    {
-        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_array(std::size_t elements) override
+    {
+        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_array() override
-    {
-        events.push_back("end_array()");
-        return true;
-    }
+    bool end_array() override
+    {
+        events.push_back("end_array()");
+        return true;
+    }
 
-    bool key(string_t& val) override
-    {
-        events.push_back("key(val=" + val + ")");
-        return true;
-    }
+    bool key(string_t& val) override
+    {
+        events.push_back("key(val=" + val + ")");
+        return true;
+    }
 
-    bool binary(json::binary_t& val) override
-    {
-        events.push_back("binary(val=[...])");
-        return true;
-    }
+    bool binary(json::binary_t& val) override
+    {
+        events.push_back("binary(val=[...])");
+        return true;
+    }
 
-    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
-    {
-        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
-        return false;
-    }
-};
+    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
+    {
+        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
+        return false;
+    }
+};
 
-int main()
-{
+int main()
+{
     // a JSON text
-    auto text = R"(
+    auto text = R"(
     {
         "Image": {
             "Width":  800,
@@ -113,58 +113,58 @@
             "Distance": 12.723374634
         }
     }]
-    )";
+    )";
 
     // create a SAX event consumer object
-    sax_event_consumer sec;
+    sax_event_consumer sec;
 
     // parse JSON
-    bool result = json::sax_parse(text, &sec);
+    bool result = json::sax_parse(text, &sec);
 
     // output the recorded events
-    for (auto& event : sec.events)
-    {
-        std::cout << event << "\n";
-    }
+    for (auto& event : sec.events)
+    {
+        std::cout << event << "\n";
+    }
 
     // output the result of sax_parse
-    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
-}
-

Output:

start_object(elements=18446744073709551615)
-key(val=Image)
-start_object(elements=18446744073709551615)
-key(val=Width)
-number_unsigned(val=800)
-key(val=Height)
-number_unsigned(val=600)
-key(val=Title)
-string(val=View from 15th Floor)
-key(val=Thumbnail)
-start_object(elements=18446744073709551615)
-key(val=Url)
-string(val=http://www.example.com/image/481989943)
-key(val=Height)
-number_unsigned(val=125)
-key(val=Width)
-number_unsigned(val=100)
-end_object()
-key(val=Animated)
-boolean(val=false)
-key(val=IDs)
-start_array(elements=18446744073709551615)
-number_unsigned(val=116)
-number_unsigned(val=943)
-number_unsigned(val=234)
-number_integer(val=-38793)
-end_array()
-key(val=DeletionDate)
-null()
-key(val=Distance)
-number_float(val=12.723375, s=12.723374634)
-end_object()
-end_object()
-parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
-            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
+    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
+}
+

Output:

start_object(elements=18446744073709551615)
+key(val=Image)
+start_object(elements=18446744073709551615)
+key(val=Width)
+number_unsigned(val=800)
+key(val=Height)
+number_unsigned(val=600)
+key(val=Title)
+string(val=View from 15th Floor)
+key(val=Thumbnail)
+start_object(elements=18446744073709551615)
+key(val=Url)
+string(val=http://www.example.com/image/481989943)
+key(val=Height)
+number_unsigned(val=125)
+key(val=Width)
+number_unsigned(val=100)
+end_object()
+key(val=Animated)
+boolean(val=false)
+key(val=IDs)
+start_array(elements=18446744073709551615)
+number_unsigned(val=116)
+number_unsigned(val=943)
+number_unsigned(val=234)
+number_integer(val=-38793)
+end_array()
+key(val=DeletionDate)
+null()
+key(val=Distance)
+number_float(val=12.723375, s=12.723374634)
+end_object()
+end_object()
+parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
+            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
 
-result: false
-

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file +result: false +

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/json_sax/number_integer/index.html b/api/json_sax/number_integer/index.html index 9ddc8dc06..b56935b28 100644 --- a/api/json_sax/number_integer/index.html +++ b/api/json_sax/number_integer/index.html @@ -1,102 +1,102 @@ - number_integer - JSON for Modern C++
Skip to content

nlohmann::json_sax::number_integer

virtual bool number_integer(number_integer_t val) = 0;
-

An integer number was read.

Parameters

val (in)
integer value

Return value

Whether parsing should proceed.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <nlohmann/json.hpp>
+ number_integer - JSON for Modern C++       

nlohmann::json_sax::number_integer

virtual bool number_integer(number_integer_t val) = 0;
+

An integer number was read.

Parameters

val (in)
integer value

Return value

Whether parsing should proceed.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
 // a simple event consumer that collects string representations of the passed
 // values; note inheriting from json::json_sax_t is not required, but can
 // help not to forget a required function
-class sax_event_consumer : public json::json_sax_t
-{
-  public:
-    std::vector<std::string> events;
+class sax_event_consumer : public json::json_sax_t
+{
+  public:
+    std::vector<std::string> events;
 
-    bool null() override
-    {
-        events.push_back("null()");
-        return true;
-    }
+    bool null() override
+    {
+        events.push_back("null()");
+        return true;
+    }
 
-    bool boolean(bool val) override
-    {
-        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
-        return true;
-    }
+    bool boolean(bool val) override
+    {
+        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
+        return true;
+    }
 
-    bool number_integer(number_integer_t val) override
-    {
-        events.push_back("number_integer(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_integer(number_integer_t val) override
+    {
+        events.push_back("number_integer(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_unsigned(number_unsigned_t val) override
-    {
-        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_unsigned(number_unsigned_t val) override
+    {
+        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_float(number_float_t val, const string_t& s) override
-    {
-        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
-        return true;
-    }
+    bool number_float(number_float_t val, const string_t& s) override
+    {
+        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
+        return true;
+    }
 
-    bool string(string_t& val) override
-    {
-        events.push_back("string(val=" + val + ")");
-        return true;
-    }
+    bool string(string_t& val) override
+    {
+        events.push_back("string(val=" + val + ")");
+        return true;
+    }
 
-    bool start_object(std::size_t elements) override
-    {
-        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_object(std::size_t elements) override
+    {
+        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_object() override
-    {
-        events.push_back("end_object()");
-        return true;
-    }
+    bool end_object() override
+    {
+        events.push_back("end_object()");
+        return true;
+    }
 
-    bool start_array(std::size_t elements) override
-    {
-        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_array(std::size_t elements) override
+    {
+        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_array() override
-    {
-        events.push_back("end_array()");
-        return true;
-    }
+    bool end_array() override
+    {
+        events.push_back("end_array()");
+        return true;
+    }
 
-    bool key(string_t& val) override
-    {
-        events.push_back("key(val=" + val + ")");
-        return true;
-    }
+    bool key(string_t& val) override
+    {
+        events.push_back("key(val=" + val + ")");
+        return true;
+    }
 
-    bool binary(json::binary_t& val) override
-    {
-        events.push_back("binary(val=[...])");
-        return true;
-    }
+    bool binary(json::binary_t& val) override
+    {
+        events.push_back("binary(val=[...])");
+        return true;
+    }
 
-    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
-    {
-        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
-        return false;
-    }
-};
+    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
+    {
+        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
+        return false;
+    }
+};
 
-int main()
-{
+int main()
+{
     // a JSON text
-    auto text = R"(
+    auto text = R"(
     {
         "Image": {
             "Width":  800,
@@ -113,58 +113,58 @@
             "Distance": 12.723374634
         }
     }]
-    )";
+    )";
 
     // create a SAX event consumer object
-    sax_event_consumer sec;
+    sax_event_consumer sec;
 
     // parse JSON
-    bool result = json::sax_parse(text, &sec);
+    bool result = json::sax_parse(text, &sec);
 
     // output the recorded events
-    for (auto& event : sec.events)
-    {
-        std::cout << event << "\n";
-    }
+    for (auto& event : sec.events)
+    {
+        std::cout << event << "\n";
+    }
 
     // output the result of sax_parse
-    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
-}
-

Output:

start_object(elements=18446744073709551615)
-key(val=Image)
-start_object(elements=18446744073709551615)
-key(val=Width)
-number_unsigned(val=800)
-key(val=Height)
-number_unsigned(val=600)
-key(val=Title)
-string(val=View from 15th Floor)
-key(val=Thumbnail)
-start_object(elements=18446744073709551615)
-key(val=Url)
-string(val=http://www.example.com/image/481989943)
-key(val=Height)
-number_unsigned(val=125)
-key(val=Width)
-number_unsigned(val=100)
-end_object()
-key(val=Animated)
-boolean(val=false)
-key(val=IDs)
-start_array(elements=18446744073709551615)
-number_unsigned(val=116)
-number_unsigned(val=943)
-number_unsigned(val=234)
-number_integer(val=-38793)
-end_array()
-key(val=DeletionDate)
-null()
-key(val=Distance)
-number_float(val=12.723375, s=12.723374634)
-end_object()
-end_object()
-parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
-            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
+    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
+}
+

Output:

start_object(elements=18446744073709551615)
+key(val=Image)
+start_object(elements=18446744073709551615)
+key(val=Width)
+number_unsigned(val=800)
+key(val=Height)
+number_unsigned(val=600)
+key(val=Title)
+string(val=View from 15th Floor)
+key(val=Thumbnail)
+start_object(elements=18446744073709551615)
+key(val=Url)
+string(val=http://www.example.com/image/481989943)
+key(val=Height)
+number_unsigned(val=125)
+key(val=Width)
+number_unsigned(val=100)
+end_object()
+key(val=Animated)
+boolean(val=false)
+key(val=IDs)
+start_array(elements=18446744073709551615)
+number_unsigned(val=116)
+number_unsigned(val=943)
+number_unsigned(val=234)
+number_integer(val=-38793)
+end_array()
+key(val=DeletionDate)
+null()
+key(val=Distance)
+number_float(val=12.723375, s=12.723374634)
+end_object()
+end_object()
+parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
+            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
 
-result: false
-

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file +result: false +

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/json_sax/number_unsigned/index.html b/api/json_sax/number_unsigned/index.html index 35419aae2..934692b36 100644 --- a/api/json_sax/number_unsigned/index.html +++ b/api/json_sax/number_unsigned/index.html @@ -1,102 +1,102 @@ - number_unsigned - JSON for Modern C++
Skip to content

nlohmann::json_sax::number_unsigned

virtual bool number_unsigned(number_unsigned_t val) = 0;
-

An unsigned integer number was read.

Parameters

val (in)
unsigned integer value

Return value

Whether parsing should proceed.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <nlohmann/json.hpp>
+ number_unsigned - JSON for Modern C++       

nlohmann::json_sax::number_unsigned

virtual bool number_unsigned(number_unsigned_t val) = 0;
+

An unsigned integer number was read.

Parameters

val (in)
unsigned integer value

Return value

Whether parsing should proceed.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
 // a simple event consumer that collects string representations of the passed
 // values; note inheriting from json::json_sax_t is not required, but can
 // help not to forget a required function
-class sax_event_consumer : public json::json_sax_t
-{
-  public:
-    std::vector<std::string> events;
+class sax_event_consumer : public json::json_sax_t
+{
+  public:
+    std::vector<std::string> events;
 
-    bool null() override
-    {
-        events.push_back("null()");
-        return true;
-    }
+    bool null() override
+    {
+        events.push_back("null()");
+        return true;
+    }
 
-    bool boolean(bool val) override
-    {
-        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
-        return true;
-    }
+    bool boolean(bool val) override
+    {
+        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
+        return true;
+    }
 
-    bool number_integer(number_integer_t val) override
-    {
-        events.push_back("number_integer(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_integer(number_integer_t val) override
+    {
+        events.push_back("number_integer(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_unsigned(number_unsigned_t val) override
-    {
-        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_unsigned(number_unsigned_t val) override
+    {
+        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_float(number_float_t val, const string_t& s) override
-    {
-        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
-        return true;
-    }
+    bool number_float(number_float_t val, const string_t& s) override
+    {
+        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
+        return true;
+    }
 
-    bool string(string_t& val) override
-    {
-        events.push_back("string(val=" + val + ")");
-        return true;
-    }
+    bool string(string_t& val) override
+    {
+        events.push_back("string(val=" + val + ")");
+        return true;
+    }
 
-    bool start_object(std::size_t elements) override
-    {
-        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_object(std::size_t elements) override
+    {
+        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_object() override
-    {
-        events.push_back("end_object()");
-        return true;
-    }
+    bool end_object() override
+    {
+        events.push_back("end_object()");
+        return true;
+    }
 
-    bool start_array(std::size_t elements) override
-    {
-        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_array(std::size_t elements) override
+    {
+        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_array() override
-    {
-        events.push_back("end_array()");
-        return true;
-    }
+    bool end_array() override
+    {
+        events.push_back("end_array()");
+        return true;
+    }
 
-    bool key(string_t& val) override
-    {
-        events.push_back("key(val=" + val + ")");
-        return true;
-    }
+    bool key(string_t& val) override
+    {
+        events.push_back("key(val=" + val + ")");
+        return true;
+    }
 
-    bool binary(json::binary_t& val) override
-    {
-        events.push_back("binary(val=[...])");
-        return true;
-    }
+    bool binary(json::binary_t& val) override
+    {
+        events.push_back("binary(val=[...])");
+        return true;
+    }
 
-    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
-    {
-        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
-        return false;
-    }
-};
+    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
+    {
+        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
+        return false;
+    }
+};
 
-int main()
-{
+int main()
+{
     // a JSON text
-    auto text = R"(
+    auto text = R"(
     {
         "Image": {
             "Width":  800,
@@ -113,58 +113,58 @@
             "Distance": 12.723374634
         }
     }]
-    )";
+    )";
 
     // create a SAX event consumer object
-    sax_event_consumer sec;
+    sax_event_consumer sec;
 
     // parse JSON
-    bool result = json::sax_parse(text, &sec);
+    bool result = json::sax_parse(text, &sec);
 
     // output the recorded events
-    for (auto& event : sec.events)
-    {
-        std::cout << event << "\n";
-    }
+    for (auto& event : sec.events)
+    {
+        std::cout << event << "\n";
+    }
 
     // output the result of sax_parse
-    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
-}
-

Output:

start_object(elements=18446744073709551615)
-key(val=Image)
-start_object(elements=18446744073709551615)
-key(val=Width)
-number_unsigned(val=800)
-key(val=Height)
-number_unsigned(val=600)
-key(val=Title)
-string(val=View from 15th Floor)
-key(val=Thumbnail)
-start_object(elements=18446744073709551615)
-key(val=Url)
-string(val=http://www.example.com/image/481989943)
-key(val=Height)
-number_unsigned(val=125)
-key(val=Width)
-number_unsigned(val=100)
-end_object()
-key(val=Animated)
-boolean(val=false)
-key(val=IDs)
-start_array(elements=18446744073709551615)
-number_unsigned(val=116)
-number_unsigned(val=943)
-number_unsigned(val=234)
-number_integer(val=-38793)
-end_array()
-key(val=DeletionDate)
-null()
-key(val=Distance)
-number_float(val=12.723375, s=12.723374634)
-end_object()
-end_object()
-parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
-            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
+    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
+}
+

Output:

start_object(elements=18446744073709551615)
+key(val=Image)
+start_object(elements=18446744073709551615)
+key(val=Width)
+number_unsigned(val=800)
+key(val=Height)
+number_unsigned(val=600)
+key(val=Title)
+string(val=View from 15th Floor)
+key(val=Thumbnail)
+start_object(elements=18446744073709551615)
+key(val=Url)
+string(val=http://www.example.com/image/481989943)
+key(val=Height)
+number_unsigned(val=125)
+key(val=Width)
+number_unsigned(val=100)
+end_object()
+key(val=Animated)
+boolean(val=false)
+key(val=IDs)
+start_array(elements=18446744073709551615)
+number_unsigned(val=116)
+number_unsigned(val=943)
+number_unsigned(val=234)
+number_integer(val=-38793)
+end_array()
+key(val=DeletionDate)
+null()
+key(val=Distance)
+number_float(val=12.723375, s=12.723374634)
+end_object()
+end_object()
+parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
+            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
 
-result: false
-

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file +result: false +

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/json_sax/parse_error/index.html b/api/json_sax/parse_error/index.html index bfe81772a..ce7bb67b2 100644 --- a/api/json_sax/parse_error/index.html +++ b/api/json_sax/parse_error/index.html @@ -1,104 +1,104 @@ - parse_error - JSON for Modern C++
Skip to content

nlohmann::json_sax::parse_error

virtual bool parse_error(std::size_t position,
-                         const std::string& last_token,
-                         const detail::exception& ex) = 0;
-

A parse error occurred.

Parameters

position (in)
the position in the input where the error occurs
last_token (in)
the last read token
ex (in)
an exception object describing the error

Return value

Whether parsing should proceed (must return false).

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <nlohmann/json.hpp>
+ parse_error - JSON for Modern C++       

nlohmann::json_sax::parse_error

virtual bool parse_error(std::size_t position,
+                         const std::string& last_token,
+                         const detail::exception& ex) = 0;
+

A parse error occurred.

Parameters

position (in)
the position in the input where the error occurs
last_token (in)
the last read token
ex (in)
an exception object describing the error

Return value

Whether parsing should proceed (must return false).

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
 // a simple event consumer that collects string representations of the passed
 // values; note inheriting from json::json_sax_t is not required, but can
 // help not to forget a required function
-class sax_event_consumer : public json::json_sax_t
-{
-  public:
-    std::vector<std::string> events;
+class sax_event_consumer : public json::json_sax_t
+{
+  public:
+    std::vector<std::string> events;
 
-    bool null() override
-    {
-        events.push_back("null()");
-        return true;
-    }
+    bool null() override
+    {
+        events.push_back("null()");
+        return true;
+    }
 
-    bool boolean(bool val) override
-    {
-        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
-        return true;
-    }
+    bool boolean(bool val) override
+    {
+        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
+        return true;
+    }
 
-    bool number_integer(number_integer_t val) override
-    {
-        events.push_back("number_integer(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_integer(number_integer_t val) override
+    {
+        events.push_back("number_integer(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_unsigned(number_unsigned_t val) override
-    {
-        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_unsigned(number_unsigned_t val) override
+    {
+        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_float(number_float_t val, const string_t& s) override
-    {
-        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
-        return true;
-    }
+    bool number_float(number_float_t val, const string_t& s) override
+    {
+        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
+        return true;
+    }
 
-    bool string(string_t& val) override
-    {
-        events.push_back("string(val=" + val + ")");
-        return true;
-    }
+    bool string(string_t& val) override
+    {
+        events.push_back("string(val=" + val + ")");
+        return true;
+    }
 
-    bool start_object(std::size_t elements) override
-    {
-        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_object(std::size_t elements) override
+    {
+        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_object() override
-    {
-        events.push_back("end_object()");
-        return true;
-    }
+    bool end_object() override
+    {
+        events.push_back("end_object()");
+        return true;
+    }
 
-    bool start_array(std::size_t elements) override
-    {
-        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_array(std::size_t elements) override
+    {
+        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_array() override
-    {
-        events.push_back("end_array()");
-        return true;
-    }
+    bool end_array() override
+    {
+        events.push_back("end_array()");
+        return true;
+    }
 
-    bool key(string_t& val) override
-    {
-        events.push_back("key(val=" + val + ")");
-        return true;
-    }
+    bool key(string_t& val) override
+    {
+        events.push_back("key(val=" + val + ")");
+        return true;
+    }
 
-    bool binary(json::binary_t& val) override
-    {
-        events.push_back("binary(val=[...])");
-        return true;
-    }
+    bool binary(json::binary_t& val) override
+    {
+        events.push_back("binary(val=[...])");
+        return true;
+    }
 
-    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
-    {
-        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
-        return false;
-    }
-};
+    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
+    {
+        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
+        return false;
+    }
+};
 
-int main()
-{
+int main()
+{
     // a JSON text
-    auto text = R"(
+    auto text = R"(
     {
         "Image": {
             "Width":  800,
@@ -115,58 +115,58 @@
             "Distance": 12.723374634
         }
     }]
-    )";
+    )";
 
     // create a SAX event consumer object
-    sax_event_consumer sec;
+    sax_event_consumer sec;
 
     // parse JSON
-    bool result = json::sax_parse(text, &sec);
+    bool result = json::sax_parse(text, &sec);
 
     // output the recorded events
-    for (auto& event : sec.events)
-    {
-        std::cout << event << "\n";
-    }
+    for (auto& event : sec.events)
+    {
+        std::cout << event << "\n";
+    }
 
     // output the result of sax_parse
-    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
-}
-

Output:

start_object(elements=18446744073709551615)
-key(val=Image)
-start_object(elements=18446744073709551615)
-key(val=Width)
-number_unsigned(val=800)
-key(val=Height)
-number_unsigned(val=600)
-key(val=Title)
-string(val=View from 15th Floor)
-key(val=Thumbnail)
-start_object(elements=18446744073709551615)
-key(val=Url)
-string(val=http://www.example.com/image/481989943)
-key(val=Height)
-number_unsigned(val=125)
-key(val=Width)
-number_unsigned(val=100)
-end_object()
-key(val=Animated)
-boolean(val=false)
-key(val=IDs)
-start_array(elements=18446744073709551615)
-number_unsigned(val=116)
-number_unsigned(val=943)
-number_unsigned(val=234)
-number_integer(val=-38793)
-end_array()
-key(val=DeletionDate)
-null()
-key(val=Distance)
-number_float(val=12.723375, s=12.723374634)
-end_object()
-end_object()
-parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
-            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
+    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
+}
+

Output:

start_object(elements=18446744073709551615)
+key(val=Image)
+start_object(elements=18446744073709551615)
+key(val=Width)
+number_unsigned(val=800)
+key(val=Height)
+number_unsigned(val=600)
+key(val=Title)
+string(val=View from 15th Floor)
+key(val=Thumbnail)
+start_object(elements=18446744073709551615)
+key(val=Url)
+string(val=http://www.example.com/image/481989943)
+key(val=Height)
+number_unsigned(val=125)
+key(val=Width)
+number_unsigned(val=100)
+end_object()
+key(val=Animated)
+boolean(val=false)
+key(val=IDs)
+start_array(elements=18446744073709551615)
+number_unsigned(val=116)
+number_unsigned(val=943)
+number_unsigned(val=234)
+number_integer(val=-38793)
+end_array()
+key(val=DeletionDate)
+null()
+key(val=Distance)
+number_float(val=12.723375, s=12.723374634)
+end_object()
+end_object()
+parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
+            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
 
-result: false
-

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file +result: false +

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/json_sax/start_array/index.html b/api/json_sax/start_array/index.html index 31665f2db..8e06e71c4 100644 --- a/api/json_sax/start_array/index.html +++ b/api/json_sax/start_array/index.html @@ -1,102 +1,102 @@ - start_array - JSON for Modern C++
Skip to content

nlohmann::json_sax::start_array

virtual bool start_array(std::size_t elements) = 0;
-

The beginning of an array was read.

Parameters

elements (in)
number of object elements or -1 if unknown

Return value

Whether parsing should proceed.

Notes

Binary formats may report the number of elements.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <nlohmann/json.hpp>
+ start_array - JSON for Modern C++       

nlohmann::json_sax::start_array

virtual bool start_array(std::size_t elements) = 0;
+

The beginning of an array was read.

Parameters

elements (in)
number of object elements or -1 if unknown

Return value

Whether parsing should proceed.

Notes

Binary formats may report the number of elements.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
 // a simple event consumer that collects string representations of the passed
 // values; note inheriting from json::json_sax_t is not required, but can
 // help not to forget a required function
-class sax_event_consumer : public json::json_sax_t
-{
-  public:
-    std::vector<std::string> events;
+class sax_event_consumer : public json::json_sax_t
+{
+  public:
+    std::vector<std::string> events;
 
-    bool null() override
-    {
-        events.push_back("null()");
-        return true;
-    }
+    bool null() override
+    {
+        events.push_back("null()");
+        return true;
+    }
 
-    bool boolean(bool val) override
-    {
-        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
-        return true;
-    }
+    bool boolean(bool val) override
+    {
+        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
+        return true;
+    }
 
-    bool number_integer(number_integer_t val) override
-    {
-        events.push_back("number_integer(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_integer(number_integer_t val) override
+    {
+        events.push_back("number_integer(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_unsigned(number_unsigned_t val) override
-    {
-        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_unsigned(number_unsigned_t val) override
+    {
+        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_float(number_float_t val, const string_t& s) override
-    {
-        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
-        return true;
-    }
+    bool number_float(number_float_t val, const string_t& s) override
+    {
+        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
+        return true;
+    }
 
-    bool string(string_t& val) override
-    {
-        events.push_back("string(val=" + val + ")");
-        return true;
-    }
+    bool string(string_t& val) override
+    {
+        events.push_back("string(val=" + val + ")");
+        return true;
+    }
 
-    bool start_object(std::size_t elements) override
-    {
-        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_object(std::size_t elements) override
+    {
+        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_object() override
-    {
-        events.push_back("end_object()");
-        return true;
-    }
+    bool end_object() override
+    {
+        events.push_back("end_object()");
+        return true;
+    }
 
-    bool start_array(std::size_t elements) override
-    {
-        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_array(std::size_t elements) override
+    {
+        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_array() override
-    {
-        events.push_back("end_array()");
-        return true;
-    }
+    bool end_array() override
+    {
+        events.push_back("end_array()");
+        return true;
+    }
 
-    bool key(string_t& val) override
-    {
-        events.push_back("key(val=" + val + ")");
-        return true;
-    }
+    bool key(string_t& val) override
+    {
+        events.push_back("key(val=" + val + ")");
+        return true;
+    }
 
-    bool binary(json::binary_t& val) override
-    {
-        events.push_back("binary(val=[...])");
-        return true;
-    }
+    bool binary(json::binary_t& val) override
+    {
+        events.push_back("binary(val=[...])");
+        return true;
+    }
 
-    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
-    {
-        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
-        return false;
-    }
-};
+    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
+    {
+        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
+        return false;
+    }
+};
 
-int main()
-{
+int main()
+{
     // a JSON text
-    auto text = R"(
+    auto text = R"(
     {
         "Image": {
             "Width":  800,
@@ -113,58 +113,58 @@
             "Distance": 12.723374634
         }
     }]
-    )";
+    )";
 
     // create a SAX event consumer object
-    sax_event_consumer sec;
+    sax_event_consumer sec;
 
     // parse JSON
-    bool result = json::sax_parse(text, &sec);
+    bool result = json::sax_parse(text, &sec);
 
     // output the recorded events
-    for (auto& event : sec.events)
-    {
-        std::cout << event << "\n";
-    }
+    for (auto& event : sec.events)
+    {
+        std::cout << event << "\n";
+    }
 
     // output the result of sax_parse
-    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
-}
-

Output:

start_object(elements=18446744073709551615)
-key(val=Image)
-start_object(elements=18446744073709551615)
-key(val=Width)
-number_unsigned(val=800)
-key(val=Height)
-number_unsigned(val=600)
-key(val=Title)
-string(val=View from 15th Floor)
-key(val=Thumbnail)
-start_object(elements=18446744073709551615)
-key(val=Url)
-string(val=http://www.example.com/image/481989943)
-key(val=Height)
-number_unsigned(val=125)
-key(val=Width)
-number_unsigned(val=100)
-end_object()
-key(val=Animated)
-boolean(val=false)
-key(val=IDs)
-start_array(elements=18446744073709551615)
-number_unsigned(val=116)
-number_unsigned(val=943)
-number_unsigned(val=234)
-number_integer(val=-38793)
-end_array()
-key(val=DeletionDate)
-null()
-key(val=Distance)
-number_float(val=12.723375, s=12.723374634)
-end_object()
-end_object()
-parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
-            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
+    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
+}
+

Output:

start_object(elements=18446744073709551615)
+key(val=Image)
+start_object(elements=18446744073709551615)
+key(val=Width)
+number_unsigned(val=800)
+key(val=Height)
+number_unsigned(val=600)
+key(val=Title)
+string(val=View from 15th Floor)
+key(val=Thumbnail)
+start_object(elements=18446744073709551615)
+key(val=Url)
+string(val=http://www.example.com/image/481989943)
+key(val=Height)
+number_unsigned(val=125)
+key(val=Width)
+number_unsigned(val=100)
+end_object()
+key(val=Animated)
+boolean(val=false)
+key(val=IDs)
+start_array(elements=18446744073709551615)
+number_unsigned(val=116)
+number_unsigned(val=943)
+number_unsigned(val=234)
+number_integer(val=-38793)
+end_array()
+key(val=DeletionDate)
+null()
+key(val=Distance)
+number_float(val=12.723375, s=12.723374634)
+end_object()
+end_object()
+parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
+            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
 
-result: false
-

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file +result: false +

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/json_sax/start_object/index.html b/api/json_sax/start_object/index.html index 1cdd711c2..766915029 100644 --- a/api/json_sax/start_object/index.html +++ b/api/json_sax/start_object/index.html @@ -1,102 +1,102 @@ - start_object - JSON for Modern C++
Skip to content

nlohmann::json_sax::start_object

virtual bool start_object(std::size_t elements) = 0;
-

The beginning of an object was read.

Parameters

elements (in)
number of object elements or -1 if unknown

Return value

Whether parsing should proceed.

Notes

Binary formats may report the number of elements.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <nlohmann/json.hpp>
+ start_object - JSON for Modern C++       

nlohmann::json_sax::start_object

virtual bool start_object(std::size_t elements) = 0;
+

The beginning of an object was read.

Parameters

elements (in)
number of object elements or -1 if unknown

Return value

Whether parsing should proceed.

Notes

Binary formats may report the number of elements.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
 // a simple event consumer that collects string representations of the passed
 // values; note inheriting from json::json_sax_t is not required, but can
 // help not to forget a required function
-class sax_event_consumer : public json::json_sax_t
-{
-  public:
-    std::vector<std::string> events;
+class sax_event_consumer : public json::json_sax_t
+{
+  public:
+    std::vector<std::string> events;
 
-    bool null() override
-    {
-        events.push_back("null()");
-        return true;
-    }
+    bool null() override
+    {
+        events.push_back("null()");
+        return true;
+    }
 
-    bool boolean(bool val) override
-    {
-        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
-        return true;
-    }
+    bool boolean(bool val) override
+    {
+        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
+        return true;
+    }
 
-    bool number_integer(number_integer_t val) override
-    {
-        events.push_back("number_integer(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_integer(number_integer_t val) override
+    {
+        events.push_back("number_integer(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_unsigned(number_unsigned_t val) override
-    {
-        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_unsigned(number_unsigned_t val) override
+    {
+        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_float(number_float_t val, const string_t& s) override
-    {
-        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
-        return true;
-    }
+    bool number_float(number_float_t val, const string_t& s) override
+    {
+        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
+        return true;
+    }
 
-    bool string(string_t& val) override
-    {
-        events.push_back("string(val=" + val + ")");
-        return true;
-    }
+    bool string(string_t& val) override
+    {
+        events.push_back("string(val=" + val + ")");
+        return true;
+    }
 
-    bool start_object(std::size_t elements) override
-    {
-        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_object(std::size_t elements) override
+    {
+        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_object() override
-    {
-        events.push_back("end_object()");
-        return true;
-    }
+    bool end_object() override
+    {
+        events.push_back("end_object()");
+        return true;
+    }
 
-    bool start_array(std::size_t elements) override
-    {
-        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_array(std::size_t elements) override
+    {
+        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_array() override
-    {
-        events.push_back("end_array()");
-        return true;
-    }
+    bool end_array() override
+    {
+        events.push_back("end_array()");
+        return true;
+    }
 
-    bool key(string_t& val) override
-    {
-        events.push_back("key(val=" + val + ")");
-        return true;
-    }
+    bool key(string_t& val) override
+    {
+        events.push_back("key(val=" + val + ")");
+        return true;
+    }
 
-    bool binary(json::binary_t& val) override
-    {
-        events.push_back("binary(val=[...])");
-        return true;
-    }
+    bool binary(json::binary_t& val) override
+    {
+        events.push_back("binary(val=[...])");
+        return true;
+    }
 
-    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
-    {
-        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
-        return false;
-    }
-};
+    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
+    {
+        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
+        return false;
+    }
+};
 
-int main()
-{
+int main()
+{
     // a JSON text
-    auto text = R"(
+    auto text = R"(
     {
         "Image": {
             "Width":  800,
@@ -113,58 +113,58 @@
             "Distance": 12.723374634
         }
     }]
-    )";
+    )";
 
     // create a SAX event consumer object
-    sax_event_consumer sec;
+    sax_event_consumer sec;
 
     // parse JSON
-    bool result = json::sax_parse(text, &sec);
+    bool result = json::sax_parse(text, &sec);
 
     // output the recorded events
-    for (auto& event : sec.events)
-    {
-        std::cout << event << "\n";
-    }
+    for (auto& event : sec.events)
+    {
+        std::cout << event << "\n";
+    }
 
     // output the result of sax_parse
-    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
-}
-

Output:

start_object(elements=18446744073709551615)
-key(val=Image)
-start_object(elements=18446744073709551615)
-key(val=Width)
-number_unsigned(val=800)
-key(val=Height)
-number_unsigned(val=600)
-key(val=Title)
-string(val=View from 15th Floor)
-key(val=Thumbnail)
-start_object(elements=18446744073709551615)
-key(val=Url)
-string(val=http://www.example.com/image/481989943)
-key(val=Height)
-number_unsigned(val=125)
-key(val=Width)
-number_unsigned(val=100)
-end_object()
-key(val=Animated)
-boolean(val=false)
-key(val=IDs)
-start_array(elements=18446744073709551615)
-number_unsigned(val=116)
-number_unsigned(val=943)
-number_unsigned(val=234)
-number_integer(val=-38793)
-end_array()
-key(val=DeletionDate)
-null()
-key(val=Distance)
-number_float(val=12.723375, s=12.723374634)
-end_object()
-end_object()
-parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
-            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
+    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
+}
+

Output:

start_object(elements=18446744073709551615)
+key(val=Image)
+start_object(elements=18446744073709551615)
+key(val=Width)
+number_unsigned(val=800)
+key(val=Height)
+number_unsigned(val=600)
+key(val=Title)
+string(val=View from 15th Floor)
+key(val=Thumbnail)
+start_object(elements=18446744073709551615)
+key(val=Url)
+string(val=http://www.example.com/image/481989943)
+key(val=Height)
+number_unsigned(val=125)
+key(val=Width)
+number_unsigned(val=100)
+end_object()
+key(val=Animated)
+boolean(val=false)
+key(val=IDs)
+start_array(elements=18446744073709551615)
+number_unsigned(val=116)
+number_unsigned(val=943)
+number_unsigned(val=234)
+number_integer(val=-38793)
+end_array()
+key(val=DeletionDate)
+null()
+key(val=Distance)
+number_float(val=12.723375, s=12.723374634)
+end_object()
+end_object()
+parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
+            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
 
-result: false
-

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file +result: false +

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/json_sax/string/index.html b/api/json_sax/string/index.html index b07b8264b..f79ff91f2 100644 --- a/api/json_sax/string/index.html +++ b/api/json_sax/string/index.html @@ -1,102 +1,102 @@ - string - JSON for Modern C++
Skip to content

nlohmann::json_sax::string

virtual bool string(string_t& val) = 0;
-

A string value was read.

Parameters

val (in)
string value

Return value

Whether parsing should proceed.

Notes

It is safe to move the passed string value.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <nlohmann/json.hpp>
+ string - JSON for Modern C++       

nlohmann::json_sax::string

virtual bool string(string_t& val) = 0;
+

A string value was read.

Parameters

val (in)
string value

Return value

Whether parsing should proceed.

Notes

It is safe to move the passed string value.

Examples

Example

The example below shows how the SAX interface is used.

#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
 // a simple event consumer that collects string representations of the passed
 // values; note inheriting from json::json_sax_t is not required, but can
 // help not to forget a required function
-class sax_event_consumer : public json::json_sax_t
-{
-  public:
-    std::vector<std::string> events;
+class sax_event_consumer : public json::json_sax_t
+{
+  public:
+    std::vector<std::string> events;
 
-    bool null() override
-    {
-        events.push_back("null()");
-        return true;
-    }
+    bool null() override
+    {
+        events.push_back("null()");
+        return true;
+    }
 
-    bool boolean(bool val) override
-    {
-        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
-        return true;
-    }
+    bool boolean(bool val) override
+    {
+        events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")");
+        return true;
+    }
 
-    bool number_integer(number_integer_t val) override
-    {
-        events.push_back("number_integer(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_integer(number_integer_t val) override
+    {
+        events.push_back("number_integer(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_unsigned(number_unsigned_t val) override
-    {
-        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
-        return true;
-    }
+    bool number_unsigned(number_unsigned_t val) override
+    {
+        events.push_back("number_unsigned(val=" + std::to_string(val) + ")");
+        return true;
+    }
 
-    bool number_float(number_float_t val, const string_t& s) override
-    {
-        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
-        return true;
-    }
+    bool number_float(number_float_t val, const string_t& s) override
+    {
+        events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")");
+        return true;
+    }
 
-    bool string(string_t& val) override
-    {
-        events.push_back("string(val=" + val + ")");
-        return true;
-    }
+    bool string(string_t& val) override
+    {
+        events.push_back("string(val=" + val + ")");
+        return true;
+    }
 
-    bool start_object(std::size_t elements) override
-    {
-        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_object(std::size_t elements) override
+    {
+        events.push_back("start_object(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_object() override
-    {
-        events.push_back("end_object()");
-        return true;
-    }
+    bool end_object() override
+    {
+        events.push_back("end_object()");
+        return true;
+    }
 
-    bool start_array(std::size_t elements) override
-    {
-        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
-        return true;
-    }
+    bool start_array(std::size_t elements) override
+    {
+        events.push_back("start_array(elements=" + std::to_string(elements) + ")");
+        return true;
+    }
 
-    bool end_array() override
-    {
-        events.push_back("end_array()");
-        return true;
-    }
+    bool end_array() override
+    {
+        events.push_back("end_array()");
+        return true;
+    }
 
-    bool key(string_t& val) override
-    {
-        events.push_back("key(val=" + val + ")");
-        return true;
-    }
+    bool key(string_t& val) override
+    {
+        events.push_back("key(val=" + val + ")");
+        return true;
+    }
 
-    bool binary(json::binary_t& val) override
-    {
-        events.push_back("binary(val=[...])");
-        return true;
-    }
+    bool binary(json::binary_t& val) override
+    {
+        events.push_back("binary(val=[...])");
+        return true;
+    }
 
-    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
-    {
-        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
-        return false;
-    }
-};
+    bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override
+    {
+        events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n            ex=" + std::string(ex.what()) + ")");
+        return false;
+    }
+};
 
-int main()
-{
+int main()
+{
     // a JSON text
-    auto text = R"(
+    auto text = R"(
     {
         "Image": {
             "Width":  800,
@@ -113,58 +113,58 @@
             "Distance": 12.723374634
         }
     }]
-    )";
+    )";
 
     // create a SAX event consumer object
-    sax_event_consumer sec;
+    sax_event_consumer sec;
 
     // parse JSON
-    bool result = json::sax_parse(text, &sec);
+    bool result = json::sax_parse(text, &sec);
 
     // output the recorded events
-    for (auto& event : sec.events)
-    {
-        std::cout << event << "\n";
-    }
+    for (auto& event : sec.events)
+    {
+        std::cout << event << "\n";
+    }
 
     // output the result of sax_parse
-    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
-}
-

Output:

start_object(elements=18446744073709551615)
-key(val=Image)
-start_object(elements=18446744073709551615)
-key(val=Width)
-number_unsigned(val=800)
-key(val=Height)
-number_unsigned(val=600)
-key(val=Title)
-string(val=View from 15th Floor)
-key(val=Thumbnail)
-start_object(elements=18446744073709551615)
-key(val=Url)
-string(val=http://www.example.com/image/481989943)
-key(val=Height)
-number_unsigned(val=125)
-key(val=Width)
-number_unsigned(val=100)
-end_object()
-key(val=Animated)
-boolean(val=false)
-key(val=IDs)
-start_array(elements=18446744073709551615)
-number_unsigned(val=116)
-number_unsigned(val=943)
-number_unsigned(val=234)
-number_integer(val=-38793)
-end_array()
-key(val=DeletionDate)
-null()
-key(val=Distance)
-number_float(val=12.723375, s=12.723374634)
-end_object()
-end_object()
-parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
-            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
+    std::cout << "\nresult: " << std::boolalpha << result << std::endl;
+}
+

Output:

start_object(elements=18446744073709551615)
+key(val=Image)
+start_object(elements=18446744073709551615)
+key(val=Width)
+number_unsigned(val=800)
+key(val=Height)
+number_unsigned(val=600)
+key(val=Title)
+string(val=View from 15th Floor)
+key(val=Thumbnail)
+start_object(elements=18446744073709551615)
+key(val=Url)
+string(val=http://www.example.com/image/481989943)
+key(val=Height)
+number_unsigned(val=125)
+key(val=Width)
+number_unsigned(val=100)
+end_object()
+key(val=Animated)
+boolean(val=false)
+key(val=IDs)
+start_array(elements=18446744073709551615)
+number_unsigned(val=116)
+number_unsigned(val=943)
+number_unsigned(val=234)
+number_integer(val=-38793)
+end_array()
+key(val=DeletionDate)
+null()
+key(val=Distance)
+number_float(val=12.723375, s=12.723374634)
+end_object()
+end_object()
+parse_error(position=460, last_token=12.723374634<U+000A>        }<U+000A>    }],
+            ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input)
 
-result: false
-

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file +result: false +

Version history

  • Added in version 3.2.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/macros/index.html b/api/macros/index.html index b148ea9b9..964d56320 100644 --- a/api/macros/index.html +++ b/api/macros/index.html @@ -1 +1 @@ - Overview - JSON for Modern C++
Skip to content

Macros

Some aspects of the library can be configured by defining preprocessor macros before including the json.hpp header. See also the macro overview page.

Runtime assertions

Exceptions

Language support

Library version

Library namespace

Type conversions

Comparison behavior

Serialization/deserialization macros


Last update: August 10, 2022
\ No newline at end of file + Overview - JSON for Modern C++
Skip to content

Macros

Some aspects of the library can be configured by defining preprocessor macros before including the json.hpp header. See also the macro overview page.

Runtime assertions

Exceptions

Language support

Library version

Library namespace

Type conversions

Comparison behavior

Serialization/deserialization macros


Last update: November 26, 2023
\ No newline at end of file diff --git a/api/macros/json_assert/index.html b/api/macros/json_assert/index.html index 1b7fd7aa8..4db5b2711 100644 --- a/api/macros/json_assert/index.html +++ b/api/macros/json_assert/index.html @@ -1,27 +1,27 @@ - JSON_ASSERT - JSON for Modern C++
Skip to content

JSON_ASSERT

#define JSON_ASSERT(x) /* value */
-

This macro controls which code is executed for runtime assertions of the library.

Parameters

x (in)
expression of scalar type

Default definition

The default value is assert(x).

#define JSON_ASSERT(x) assert(x)
-

Therefore, assertions can be switched off by defining NDEBUG.

Notes

  • The library uses numerous assertions to guarantee invariants and to abort in case of otherwise undefined behavior (e.g., when calling operator[] with a missing object key on a const object). See page runtime assertions for more information.
  • Defining the macro to code that does not call std::abort may leave the library in an undefined state.
  • The macro is undefined outside the library.

Examples

Example 1: default behavior

The following code will trigger an assertion at runtime:

#include <nlohmann/json.hpp>
+ JSON_ASSERT - JSON for Modern C++       

JSON_ASSERT

#define JSON_ASSERT(x) /* value */
+

This macro controls which code is executed for runtime assertions of the library.

Parameters

x (in)
expression of scalar type

Default definition

The default value is assert(x).

#define JSON_ASSERT(x) assert(x)
+

Therefore, assertions can be switched off by defining NDEBUG.

Notes

  • The library uses numerous assertions to guarantee invariants and to abort in case of otherwise undefined behavior (e.g., when calling operator[] with a missing object key on a const object). See page runtime assertions for more information.
  • Defining the macro to code that does not call std::abort may leave the library in an undefined state.
  • The macro is undefined outside the library.

Examples

Example 1: default behavior

The following code will trigger an assertion at runtime:

#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    const json j = {{"key", "value"}};
-    auto v = j["missing"];
-}
+int main()
+{
+    const json j = {{"key", "value"}};
+    auto v = j["missing"];
+}
 

Output:

Assertion failed: (m_value.object->find(key) != m_value.object->end()), function operator[], file json.hpp, line 2144.
-
Example 2: user-defined behavior

The assertion reporting can be changed by defining JSON_ASSERT(x) differently.

#include <cstdio>
-#include <cstdlib>
+
Example 2: user-defined behavior

The assertion reporting can be changed by defining JSON_ASSERT(x) differently.

#include <cstdio>
+#include <cstdlib>
 #define JSON_ASSERT(x) if(!(x)){fprintf(stderr, "assertion error in %s\n", __FUNCTION__); std::abort();}
 
-#include <nlohmann/json.hpp>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    const json j = {{"key", "value"}};
-    auto v = j["missing"];
-}
+int main()
+{
+    const json j = {{"key", "value"}};
+    auto v = j["missing"];
+}
 

Output:

assertion error in operator[]
-

Version history

  • Added in version 3.9.0.

Last update: May 1, 2022
\ No newline at end of file +

Version history

  • Added in version 3.9.0.

Last update: May 1, 2022
\ No newline at end of file diff --git a/api/macros/json_diagnostics/index.html b/api/macros/json_diagnostics/index.html index 5816a840a..8aa8a0bce 100644 --- a/api/macros/json_diagnostics/index.html +++ b/api/macros/json_diagnostics/index.html @@ -1,47 +1,47 @@ - JSON_DIAGNOSTICS - JSON for Modern C++
Skip to content

JSON_DIAGNOSTICS

#define JSON_DIAGNOSTICS /* value */
+ JSON_DIAGNOSTICS - JSON for Modern C++       

JSON_DIAGNOSTICS

#define JSON_DIAGNOSTICS /* value */
 

This macro enables extended diagnostics for exception messages. Possible values are 1 to enable or 0 to disable (default).

When enabled, exception messages contain a JSON Pointer to the JSON value that triggered the exception. Note that enabling this macro increases the size of every JSON value by one pointer and adds some runtime overhead.

Default definition

The default value is 0 (extended diagnostics are switched off).

#define JSON_DIAGNOSTICS 0
-

When the macro is not defined, the library will define it to its default value.

Notes

ABI compatibility

As of version 3.11.0, this macro is no longer required to be defined consistently throughout a codebase to avoid One Definition Rule (ODR) violations, as the value of this macro is encoded in the namespace, resulting in distinct symbol names.

This allows different parts of a codebase to use different versions or configurations of this library without causing improper behavior.

Where possible, it is still recommended that all code define this the same way for maximum interoperability.

CMake option

Diagnostic messages can also be controlled with the CMake option JSON_Diagnostics (OFF by default) which defines JSON_DIAGNOSTICS accordingly.

Examples

Example 1: default behavior
#include <iostream>
-#include <nlohmann/json.hpp>
+

When the macro is not defined, the library will define it to its default value.

Notes

ABI compatibility

As of version 3.11.0, this macro is no longer required to be defined consistently throughout a codebase to avoid One Definition Rule (ODR) violations, as the value of this macro is encoded in the namespace, resulting in distinct symbol names.

This allows different parts of a codebase to use different versions or configurations of this library without causing improper behavior.

Where possible, it is still recommended that all code define this the same way for maximum interoperability.

CMake option

Diagnostic messages can also be controlled with the CMake option JSON_Diagnostics (OFF by default) which defines JSON_DIAGNOSTICS accordingly.

Examples

Example 1: default behavior
#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    json j;
-    j["address"]["street"] = "Fake Street";
-    j["address"]["housenumber"] = "12";
+int main()
+{
+    json j;
+    j["address"]["street"] = "Fake Street";
+    j["address"]["housenumber"] = "12";
 
-    try
-    {
-        int housenumber = j["address"]["housenumber"];
-    }
-    catch (const json::exception& e)
-    {
-        std::cout << e.what() << '\n';
-    }
-}
+    try
+    {
+        int housenumber = j["address"]["housenumber"];
+    }
+    catch (const json::exception& e)
+    {
+        std::cout << e.what() << '\n';
+    }
+}
 

Output:

[json.exception.type_error.302] type must be number, but is string
-

This exception can be hard to debug if storing the value "12" and accessing it is further apart.

Example 2: extended diagnostic messages
#include <iostream>
+

This exception can be hard to debug if storing the value "12" and accessing it is further apart.

Example 2: extended diagnostic messages
#include <iostream>
 
 # define JSON_DIAGNOSTICS 1
-#include <nlohmann/json.hpp>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    json j;
-    j["address"]["street"] = "Fake Street";
-    j["address"]["housenumber"] = "12";
+int main()
+{
+    json j;
+    j["address"]["street"] = "Fake Street";
+    j["address"]["housenumber"] = "12";
 
-    try
-    {
-        int housenumber = j["address"]["housenumber"];
-    }
-    catch (const json::exception& e)
-    {
-        std::cout << e.what() << '\n';
-    }
-}
+    try
+    {
+        int housenumber = j["address"]["housenumber"];
+    }
+    catch (const json::exception& e)
+    {
+        std::cout << e.what() << '\n';
+    }
+}
 

Output:

[json.exception.type_error.302] (/address/housenumber) type must be number, but is string
-

Now the exception message contains a JSON Pointer /address/housenumber that indicates which value has the wrong type.

Version history

  • Added in version 3.10.0.
  • As of version 3.11.0 the definition is allowed to vary between translation units.

Last update: July 31, 2022
\ No newline at end of file +

Now the exception message contains a JSON Pointer /address/housenumber that indicates which value has the wrong type.

Version history

  • Added in version 3.10.0.
  • As of version 3.11.0 the definition is allowed to vary between translation units.

Last update: July 31, 2022
\ No newline at end of file diff --git a/api/macros/json_disable_enum_serialization/index.html b/api/macros/json_disable_enum_serialization/index.html index 8f1ee46ad..0d6a112a2 100644 --- a/api/macros/json_disable_enum_serialization/index.html +++ b/api/macros/json_disable_enum_serialization/index.html @@ -1,92 +1,92 @@ - JSON_DISABLE_ENUM_SERIALIZATION - JSON for Modern C++
Skip to content

JSON_DISABLE_ENUM_SERIALIZATION

#define JSON_DISABLE_ENUM_SERIALIZATION /* value */
+ JSON_DISABLE_ENUM_SERIALIZATION - JSON for Modern C++       

JSON_DISABLE_ENUM_SERIALIZATION

#define JSON_DISABLE_ENUM_SERIALIZATION /* value */
 

When defined to 1, default serialization and deserialization functions for enums are excluded and have to be provided by the user, for example, using NLOHMANN_JSON_SERIALIZE_ENUM (see arbitrary type conversions for more details).

Parsing or serializing an enum will result in a compiler error.

This works for both unscoped and scoped enums.

Default definition

The default value is 0.

#define JSON_DISABLE_ENUM_SERIALIZATION 0
 

Notes

CMake option

Enum serialization can also be controlled with the CMake option JSON_DisableEnumSerialization (OFF by default) which defines JSON_DISABLE_ENUM_SERIALIZATION accordingly.

Examples

Example 1: Disabled behavior

The code below forces the library not to create default serialization/deserialization functions from_json and to_json, meaning the code below does not compile.

#define JSON_DISABLE_ENUM_SERIALIZATION 1
-#include <nlohmann/json.hpp>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-enum class Choice
-{
-    first,
-    second,
-};
+enum class Choice
+{
+    first,
+    second,
+};
 
-int main()
-{
+int main()
+{
     // normally invokes to_json serialization function but with JSON_DISABLE_ENUM_SERIALIZATION defined, it does not
     const json j = Choice::first; 
 
     // normally invokes from_json parse function but with JSON_DISABLE_ENUM_SERIALIZATION defined, it does not
-    Choice ch = j.template get<Choice>();
-}
+    Choice ch = j.template get<Choice>();
+}
 
Example 2: Serialize enum macro

The code below forces the library not to create default serialization/deserialization functions from_json and to_json, but uses NLOHMANN_JSON_SERIALIZE_ENUM to parse and serialize the enum.

#define JSON_DISABLE_ENUM_SERIALIZATION 1
-#include <nlohmann/json.hpp>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-enum class Choice
-{
-    first,
-    second,
-};
+enum class Choice
+{
+    first,
+    second,
+};
 
-NLOHMANN_JSON_SERIALIZE_ENUM(Choice,
-{
-    { Choice::first, "first" },
-    { Choice::second, "second" },
-})
+NLOHMANN_JSON_SERIALIZE_ENUM(Choice,
+{
+    { Choice::first, "first" },
+    { Choice::second, "second" },
+})
 
-int main()
-{
+int main()
+{
     // uses user-defined to_json function defined by macro
     const json j = Choice::first; 
 
     // uses user-defined from_json function defined by macro
-    Choice ch = j.template get<Choice>();
-}
+    Choice ch = j.template get<Choice>();
+}
 
Example 3: User-defined serialization/deserialization functions

The code below forces the library not to create default serialization/deserialization functions from_json and to_json, but uses user-defined functions to parse and serialize the enum.

#define JSON_DISABLE_ENUM_SERIALIZATION 1
-#include <nlohmann/json.hpp>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-enum class Choice
-{
-    first,
-    second,
-};
+enum class Choice
+{
+    first,
+    second,
+};
 
-void from_json(const json& j, Choice& ch)
-{
-    auto value = j.template get<std::string>();
-    if (value == "first")
-    {
-        ch = Choice::first;
-    }
-    else if (value == "second")
-    {
-        ch = Choice::second;
-    }
-}
+void from_json(const json& j, Choice& ch)
+{
+    auto value = j.template get<std::string>();
+    if (value == "first")
+    {
+        ch = Choice::first;
+    }
+    else if (value == "second")
+    {
+        ch = Choice::second;
+    }
+}
 
-void to_json(json& j, const Choice& ch)
-{
-    auto value = j.template get<std::string>();
-    if (value == "first")
-    {
-        ch = Choice::first;
-    }
-    else if (value == "second")
-    {
-        ch = Choice::second;
-    }
-}
+void to_json(json& j, const Choice& ch)
+{
+    auto value = j.template get<std::string>();
+    if (value == "first")
+    {
+        ch = Choice::first;
+    }
+    else if (value == "second")
+    {
+        ch = Choice::second;
+    }
+}
 
-int main()
-{
+int main()
+{
     // uses user-defined to_json function
     const json j = Choice::first; 
 
     // uses user-defined from_json function
-    Choice ch = j.template get<Choice>();
-}
-

See also

Version history

  • Added in version 3.11.0.

Last update: June 11, 2023
\ No newline at end of file + Choice ch = j.template get<Choice>(); +} +

See also

Version history

  • Added in version 3.11.0.

Last update: June 11, 2023
\ No newline at end of file diff --git a/api/macros/json_has_cpp_11/index.html b/api/macros/json_has_cpp_11/index.html index b550132b1..a72cf0a83 100644 --- a/api/macros/json_has_cpp_11/index.html +++ b/api/macros/json_has_cpp_11/index.html @@ -1,9 +1,9 @@ - JSON_HAS_CPP_20 - JSON for Modern C++
Skip to content

JSON_HAS_CPP_11, JSON_HAS_CPP_14, JSON_HAS_CPP_17, JSON_HAS_CPP_20

#define JSON_HAS_CPP_11
+ JSON_HAS_CPP_20 - JSON for Modern C++       

JSON_HAS_CPP_11, JSON_HAS_CPP_14, JSON_HAS_CPP_17, JSON_HAS_CPP_20

#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 __cplusplus, _HAS_CXX17, or _MSVC_LANG.

Notes

  • 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:

#define JSON_HAS_CPP_14 1
-#include <nlohmann/json.hpp>
+

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 __cplusplus, _HAS_CXX17, or _MSVC_LANG.

Notes

  • 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:

#define JSON_HAS_CPP_14 1
+#include <nlohmann/json.hpp>
 
-...
-

Version history

  • Added in version 3.10.5.

Last update: May 17, 2022
\ No newline at end of file +... +

Version history

  • Added in version 3.10.5.

Last update: May 17, 2022
\ No newline at end of file diff --git a/api/macros/json_has_filesystem/index.html b/api/macros/json_has_filesystem/index.html index 76670c300..983d85549 100644 --- a/api/macros/json_has_filesystem/index.html +++ b/api/macros/json_has_filesystem/index.html @@ -1,7 +1,7 @@ - JSON_HAS_FILESYSTEM - JSON for Modern C++
Skip to content

JSON_HAS_FILESYSTEM / JSON_HAS_EXPERIMENTAL_FILESYSTEM

#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. As compiler support for filesystem is limited, the library tries to detect whether <filesystem>/std::filesystem (JSON_HAS_FILESYSTEM) or <experimental/filesystem>/std::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_lib_filesystem, __cpp_lib_experimental_filesystem, __has_include(<filesystem>), or __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>.

#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
-#include <nlohmann/json.hpp>
+ JSON_HAS_FILESYSTEM - JSON for Modern C++       

JSON_HAS_FILESYSTEM / JSON_HAS_EXPERIMENTAL_FILESYSTEM

#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. As compiler support for filesystem is limited, the library tries to detect whether <filesystem>/std::filesystem (JSON_HAS_FILESYSTEM) or <experimental/filesystem>/std::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_lib_filesystem, __cpp_lib_experimental_filesystem, __has_include(<filesystem>), or __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>.

#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
+#include <nlohmann/json.hpp>
 
-...
-

Version history

  • Added in version 3.10.5.

Last update: May 17, 2022
\ No newline at end of file +... +

Version history

  • Added in version 3.10.5.

Last update: May 17, 2022
\ No newline at end of file diff --git a/api/macros/json_has_ranges/index.html b/api/macros/json_has_ranges/index.html index 4abbc1e61..de813969a 100644 --- a/api/macros/json_has_ranges/index.html +++ b/api/macros/json_has_ranges/index.html @@ -1,6 +1,6 @@ - JSON_HAS_RANGES - JSON for Modern C++
Skip to content

JSON_HAS_RANGES

#define JSON_HAS_RANGES /* value */
-

This macro indicates whether the standard library has any support for ranges. Implies support for concepts. Possible values are 1 when supported or 0 when unsupported.

Default definition

The default value is detected based on the preprocessor macro __cpp_lib_ranges.

When the macro is not defined, the library will define it to its default value.

Examples

Example

The code below forces the library to enable support for ranges:

#define JSON_HAS_RANGES 1
-#include <nlohmann/json.hpp>
+ JSON_HAS_RANGES - JSON for Modern C++       

JSON_HAS_RANGES

#define JSON_HAS_RANGES /* value */
+

This macro indicates whether the standard library has any support for ranges. Implies support for concepts. Possible values are 1 when supported or 0 when unsupported.

Default definition

The default value is detected based on the preprocessor macro __cpp_lib_ranges.

When the macro is not defined, the library will define it to its default value.

Examples

Example

The code below forces the library to enable support for ranges:

#define JSON_HAS_RANGES 1
+#include <nlohmann/json.hpp>
 
-...
-

Version history

  • Added in version 3.11.0.

Last update: July 31, 2022
\ No newline at end of file +... +

Version history

  • Added in version 3.11.0.

Last update: July 31, 2022
\ No newline at end of file diff --git a/api/macros/json_has_static_rtti/index.html b/api/macros/json_has_static_rtti/index.html index aeda43ed3..08f91cc5c 100644 --- a/api/macros/json_has_static_rtti/index.html +++ b/api/macros/json_has_static_rtti/index.html @@ -1,6 +1,6 @@ - JSON_HAS_STATIC_RTTI - JSON for Modern C++
Skip to content

JSON_HAS_STATIC_RTTI

#define JSON_HAS_STATIC_RTTI /* value */
-

This macro indicates whether the standard library has any support for RTTI (run time type information). Possible values are 1 when supported or 0 when unsupported.

Default definition

The default value is detected based on the preprocessor macro _HAS_STATIC_RTTI.

When the macro is not defined, the library will define it to its default value.

Examples

Example

The code below forces the library to enable support for libraries with RTTI dependence:

#define JSON_HAS_STATIC_RTTI 1
-#include <nlohmann/json.hpp>
+ JSON_HAS_STATIC_RTTI - JSON for Modern C++       

JSON_HAS_STATIC_RTTI

#define JSON_HAS_STATIC_RTTI /* value */
+

This macro indicates whether the standard library has any support for RTTI (run time type information). Possible values are 1 when supported or 0 when unsupported.

Default definition

The default value is detected based on the preprocessor macro _HAS_STATIC_RTTI.

When the macro is not defined, the library will define it to its default value.

Examples

Example

The code below forces the library to enable support for libraries with RTTI dependence:

#define JSON_HAS_STATIC_RTTI 1
+#include <nlohmann/json.hpp>
 
-...
-

Version history

  • Added in version ?.

Last update: September 24, 2023
\ No newline at end of file +... +

Version history

  • Added in version ?.

Last update: September 24, 2023
\ No newline at end of file diff --git a/api/macros/json_has_three_way_comparison/index.html b/api/macros/json_has_three_way_comparison/index.html index 17b921bd9..612b4e83f 100644 --- a/api/macros/json_has_three_way_comparison/index.html +++ b/api/macros/json_has_three_way_comparison/index.html @@ -1,6 +1,6 @@ - JSON_HAS_THREE_WAY_COMPARISON - JSON for Modern C++
Skip to content

JSON_HAS_THREE_WAY_COMPARISON

#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_impl_three_way_comparison and __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:

#define JSON_HAS_THREE_WAY_COMPARISON 1
-#include <nlohmann/json.hpp>
+ JSON_HAS_THREE_WAY_COMPARISON - JSON for Modern C++       

JSON_HAS_THREE_WAY_COMPARISON

#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_impl_three_way_comparison and __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:

#define JSON_HAS_THREE_WAY_COMPARISON 1
+#include <nlohmann/json.hpp>
 
-...
-

Version history

  • Added in version 3.11.0.

Last update: July 31, 2022
\ No newline at end of file +... +

Version history

  • Added in version 3.11.0.

Last update: July 31, 2022
\ No newline at end of file diff --git a/api/macros/json_no_io/index.html b/api/macros/json_no_io/index.html index 3840aaca0..8195349c4 100644 --- a/api/macros/json_no_io/index.html +++ b/api/macros/json_no_io/index.html @@ -1,7 +1,7 @@ - JSON_NO_IO - JSON for Modern C++
Skip to content

JSON_NO_IO

#define JSON_NO_IO
-

When defined, headers <cstdio>, <ios>, <iosfwd>, <istream>, and <ostream> are not included and parse functions relying on these headers are excluded. This is relevant for environments where these I/O functions are disallowed for security reasons (e.g., Intel Software Guard Extensions (SGX)).

Default definition

By default, JSON_NO_IO is not defined.

#undef JSON_NO_IO
+ JSON_NO_IO - JSON for Modern C++       

JSON_NO_IO

#define JSON_NO_IO
+

When defined, headers <cstdio>, <ios>, <iosfwd>, <istream>, and <ostream> are not included and parse functions relying on these headers are excluded. This is relevant for environments where these I/O functions are disallowed for security reasons (e.g., Intel Software Guard Extensions (SGX)).

Default definition

By default, JSON_NO_IO is not defined.

#undef JSON_NO_IO
 

Examples

Example

The code below forces the library not to use the headers <cstdio>, <ios>, <iosfwd>, <istream>, and <ostream>.

#define JSON_NO_IO 1
-#include <nlohmann/json.hpp>
+#include <nlohmann/json.hpp>
 
-...
-

Version history

  • Added in version 3.10.0.

Last update: May 17, 2022
\ No newline at end of file +... +

Version history

  • Added in version 3.10.0.

Last update: May 17, 2022
\ No newline at end of file diff --git a/api/macros/json_noexception/index.html b/api/macros/json_noexception/index.html index 796379722..02bddf868 100644 --- a/api/macros/json_noexception/index.html +++ b/api/macros/json_noexception/index.html @@ -1,7 +1,7 @@ - JSON_NOEXCEPTION - JSON for Modern C++
Skip to content

JSON_NOEXCEPTION

#define JSON_NOEXCEPTION
-

Exceptions can be switched off by defining the symbol JSON_NOEXCEPTION. When defining JSON_NOEXCEPTION, try is replaced by if (true), catch is replaced by if (false), and throw is replaced by std::abort().

The same effect is achieved by setting the compiler flag -fno-exceptions.

Default definition

By default, the macro is not defined.

#undef JSON_NOEXCEPTION
+ JSON_NOEXCEPTION - JSON for Modern C++       

JSON_NOEXCEPTION

#define JSON_NOEXCEPTION
+

Exceptions can be switched off by defining the symbol JSON_NOEXCEPTION. When defining JSON_NOEXCEPTION, try is replaced by if (true), catch is replaced by if (false), and throw is replaced by std::abort().

The same effect is achieved by setting the compiler flag -fno-exceptions.

Default definition

By default, the macro is not defined.

#undef JSON_NOEXCEPTION
 

Notes

The explanatory what() string of exceptions is not available for MSVC if exceptions are disabled, see #2824.

Examples

Example

The code below switches off exceptions in the library.

#define JSON_NOEXCEPTION 1
-#include <nlohmann/json.hpp>
+#include <nlohmann/json.hpp>
 
-...
-

See also

Version history

Added in version 2.1.0.


Last update: May 17, 2022
\ No newline at end of file +... +

See also

Version history

Added in version 2.1.0.


Last update: May 17, 2022
\ No newline at end of file diff --git a/api/macros/json_skip_library_version_check/index.html b/api/macros/json_skip_library_version_check/index.html index 6717e5468..c4916bd7e 100644 --- a/api/macros/json_skip_library_version_check/index.html +++ b/api/macros/json_skip_library_version_check/index.html @@ -1,4 +1,4 @@ - JSON_SKIP_LIBRARY_VERSION_CHECK - JSON for Modern C++
Skip to content

JSON_SKIP_LIBRARY_VERSION_CHECK

#define JSON_SKIP_LIBRARY_VERSION_CHECK
+ JSON_SKIP_LIBRARY_VERSION_CHECK - JSON for Modern C++       

JSON_SKIP_LIBRARY_VERSION_CHECK

#define JSON_SKIP_LIBRARY_VERSION_CHECK
 

When defined, the library will not create a compiler warning when a different version of the library was already included.

Default definition

By default, the macro is not defined.

#undef JSON_SKIP_LIBRARY_VERSION_CHECK
 

Notes

ABI compatibility

Mixing different library versions in the same code can be a problem as the different versions may not be ABI compatible.

Examples

Example

The following warning will be shown in case a different version of the library was already included:

Already included a different version of the library!
-

Version history

Added in version 3.11.0.


Last update: May 1, 2022
\ No newline at end of file +

Version history

Added in version 3.11.0.


Last update: May 1, 2022
\ No newline at end of file diff --git a/api/macros/json_skip_unsupported_compiler_check/index.html b/api/macros/json_skip_unsupported_compiler_check/index.html index 1eb43213b..27941e91e 100644 --- a/api/macros/json_skip_unsupported_compiler_check/index.html +++ b/api/macros/json_skip_unsupported_compiler_check/index.html @@ -1,7 +1,7 @@ - JSON_SKIP_UNSUPPORTED_COMPILER_CHECK - JSON for Modern C++
Skip to content

JSON_SKIP_UNSUPPORTED_COMPILER_CHECK

#define JSON_SKIP_UNSUPPORTED_COMPILER_CHECK
+ JSON_SKIP_UNSUPPORTED_COMPILER_CHECK - JSON for Modern C++       

JSON_SKIP_UNSUPPORTED_COMPILER_CHECK

#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.

#undef JSON_SKIP_UNSUPPORTED_COMPILER_CHECK
 

Examples

Example

The code below switches off the check whether the compiler is supported.

#define JSON_SKIP_UNSUPPORTED_COMPILER_CHECK 1
-#include <nlohmann/json.hpp>
+#include <nlohmann/json.hpp>
 
-...
-

Version history

Added in version 3.2.0.


Last update: May 17, 2022
\ No newline at end of file +... +

Version history

Added in version 3.2.0.


Last update: May 17, 2022
\ No newline at end of file diff --git a/api/macros/json_throw_user/index.html b/api/macros/json_throw_user/index.html index adbdd8e57..0674618e1 100644 --- a/api/macros/json_throw_user/index.html +++ b/api/macros/json_throw_user/index.html @@ -1,16 +1,16 @@ - JSON_TRY_USER - JSON for Modern C++
Skip to content

JSON_CATCH_USER, JSON_THROW_USER, JSON_TRY_USER

// (1)
-#define JSON_CATCH_USER(exception) /* value */
+ JSON_TRY_USER - JSON for Modern C++       

JSON_CATCH_USER, JSON_THROW_USER, JSON_TRY_USER

// (1)
+#define JSON_CATCH_USER(exception) /* value */
 // (2)
-#define JSON_THROW_USER(exception) /* value */
+#define JSON_THROW_USER(exception) /* value */
 // (3)
-#define JSON_TRY_USER /* value */
-

Controls how exceptions are handled by the library.

  1. This macro overrides 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 exceptions. The macro is always followed by a scope.
  2. This macro overrides 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 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:

#define JSON_CATCH_USER(exception) catch(exception)
+#define JSON_TRY_USER /* value */
+

Controls how exceptions are handled by the library.

  1. This macro overrides 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 exceptions. The macro is always followed by a scope.
  2. This macro overrides 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 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:

#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 try block is executed unconditionally, and throwing exceptions is replaced by calling std::abort to make reaching the throw branch abort the process.

#define JSON_THROW_USER(exception) std::abort()
+

When exceptions are switched off, the try block is executed unconditionally, and throwing exceptions is replaced by calling std::abort to make reaching the throw branch abort the process.

#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.

#include <iostream>
+

Examples

Example

The code below switches off exceptions and creates a log entry with a detailed error message in case of errors.

#include <iostream>
 
 #define JSON_TRY_USER if(true)
 #define JSON_CATCH_USER(exception) if(false)
@@ -20,5 +20,5 @@
                << (exception).what() << std::endl;           \
      std::abort();}
 
-#include <nlohmann/json.hpp>
-

See also

Version history

  • Added in version 3.1.0.

Last update: May 1, 2022
\ No newline at end of file +#include <nlohmann/json.hpp> +

See also

Version history

  • Added in version 3.1.0.

Last update: November 1, 2023
\ No newline at end of file diff --git a/api/macros/json_use_global_udls/index.html b/api/macros/json_use_global_udls/index.html index 68319f628..e86540eb7 100644 --- a/api/macros/json_use_global_udls/index.html +++ b/api/macros/json_use_global_udls/index.html @@ -1,32 +1,32 @@ - JSON_USE_GLOBAL_UDLS - JSON for Modern C++
Skip to content

JSON_USE_GLOBAL_UDLS

#define JSON_USE_GLOBAL_UDLS /* value */
+ JSON_USE_GLOBAL_UDLS - JSON for Modern C++       

JSON_USE_GLOBAL_UDLS

#define JSON_USE_GLOBAL_UDLS /* value */
 

When defined to 1, the user-defined string literals (UDLs) are placed into the global namespace instead of nlohmann::literals::json_literals.

Default definition

The default value is 1.

#define JSON_USE_GLOBAL_UDLS 1
-

When the macro is not defined, the library will define it to its default value.

Notes

Future behavior change

The user-defined string literals will be removed from the global namespace in the next major release of the library.

To prepare existing code, define JSON_USE_GLOBAL_UDLS to 0 and bring the string literals into scope where needed. Refer to any of the string literals for details.

CMake option

The placement of user-defined string literals can also be controlled with the CMake option JSON_GlobalUDLs (ON by default) which defines JSON_USE_GLOBAL_UDLS accordingly.

Examples

Example 1: Default behavior

The code below shows the default behavior using the _json UDL.

#include <nlohmann/json.hpp>
+

When the macro is not defined, the library will define it to its default value.

Notes

Future behavior change

The user-defined string literals will be removed from the global namespace in the next major release of the library.

To prepare existing code, define JSON_USE_GLOBAL_UDLS to 0 and bring the string literals into scope where needed. Refer to any of the string literals for details.

CMake option

The placement of user-defined string literals can also be controlled with the CMake option JSON_GlobalUDLs (ON by default) which defines JSON_USE_GLOBAL_UDLS accordingly.

Examples

Example 1: Default behavior

The code below shows the default behavior using the _json UDL.

#include <nlohmann/json.hpp>
 
-#include <iostream>
+#include <iostream>
 
-int main()
-{
-    auto j = "42"_json;
+int main()
+{
+    auto j = "42"_json;
 
-    std::cout << j << std::endl;
-}
-

Output:

42
+    std::cout << j << std::endl;
+}
+

Output:

42
 
Example 2: Namespaced UDLs

The code below shows how UDLs need to be brought into scope before using _json when JSON_USE_GLOBAL_UDLS is defined to 0.

#define JSON_USE_GLOBAL_UDLS 0
-#include <nlohmann/json.hpp>
+#include <nlohmann/json.hpp>
 
-#include <iostream>
+#include <iostream>
 
-int main()
-{
+int main()
+{
     // auto j = "42"_json; // This line would fail to compile,
                            // because the UDLs are not in the global namespace
 
     // Bring the UDLs into scope
-    using namespace nlohmann::json_literals;
+    using namespace nlohmann::json_literals;
 
-    auto j = "42"_json;
+    auto j = "42"_json;
 
-    std::cout << j << std::endl;
-}
-

Output:

42
-

See also

Version history

  • Added in version 3.11.0.

Last update: August 5, 2022
\ No newline at end of file + std::cout << j << std::endl; +} +

Output:

42
+

See also

Version history

  • Added in version 3.11.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/macros/json_use_implicit_conversions/index.html b/api/macros/json_use_implicit_conversions/index.html index 70a7deef7..dfa4cce35 100644 --- a/api/macros/json_use_implicit_conversions/index.html +++ b/api/macros/json_use_implicit_conversions/index.html @@ -1,7 +1,7 @@ - JSON_USE_IMPLICIT_CONVERSIONS - JSON for Modern C++
Skip to content

JSON_USE_IMPLICIT_CONVERSIONS

#define JSON_USE_IMPLICIT_CONVERSIONS /* value */
+ JSON_USE_IMPLICIT_CONVERSIONS - JSON for Modern C++       

JSON_USE_IMPLICIT_CONVERSIONS

#define JSON_USE_IMPLICIT_CONVERSIONS /* value */
 

When defined to 0, implicit conversions are switched off. By default, implicit conversions are switched on. The value directly affects operator ValueType.

Default definition

By default, implicit conversions are enabled.

#define JSON_USE_IMPLICIT_CONVERSIONS 1
-

Notes

Future behavior change

Implicit conversions will be switched off by default in the next major release of the library.

You can prepare existing code by already defining JSON_USE_IMPLICIT_CONVERSIONS to 0 and replace any implicit conversions with calls to get.

CMake option

Implicit conversions can also be controlled with the CMake option JSON_ImplicitConversions (ON by default) which defines JSON_USE_IMPLICIT_CONVERSIONS accordingly.

Examples

Example

This is an example for an implicit conversion:

json j = "Hello, world!";
-std::string s = j;
-

When JSON_USE_IMPLICIT_CONVERSIONS is defined to 0, the code above does no longer compile. Instead, it must be written like this:

json j = "Hello, world!";
-auto s = j.template get<std::string>();
-

See also

Version history

  • Added in version 3.9.0.

Last update: June 11, 2023
\ No newline at end of file +

Notes

Future behavior change

Implicit conversions will be switched off by default in the next major release of the library.

You can prepare existing code by already defining JSON_USE_IMPLICIT_CONVERSIONS to 0 and replace any implicit conversions with calls to get.

CMake option

Implicit conversions can also be controlled with the CMake option JSON_ImplicitConversions (ON by default) which defines JSON_USE_IMPLICIT_CONVERSIONS accordingly.

Examples

Example

This is an example for an implicit conversion:

json j = "Hello, world!";
+std::string s = j;
+

When JSON_USE_IMPLICIT_CONVERSIONS is defined to 0, the code above does no longer compile. Instead, it must be written like this:

json j = "Hello, world!";
+auto s = j.template get<std::string>();
+

See also

Version history

  • Added in version 3.9.0.

Last update: June 11, 2023
\ No newline at end of file diff --git a/api/macros/json_use_legacy_discarded_value_comparison/index.html b/api/macros/json_use_legacy_discarded_value_comparison/index.html index a521ddd2e..aa8621867 100644 --- a/api/macros/json_use_legacy_discarded_value_comparison/index.html +++ b/api/macros/json_use_legacy_discarded_value_comparison/index.html @@ -1,7 +1,7 @@ - JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON - JSON for Modern C++
Skip to content

JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON

#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON /* value */
-

This macro enables the (incorrect) legacy comparison behavior of discarded JSON values. Possible values are 1 to enable or 0 to disable (default).

When enabled, comparisons involving at least one discarded JSON value yield results as follows:

Operator Result
== false
!= true
< false
<= true
>= true
> false

Otherwise, comparisons involving at least one discarded JSON value always yield false.

Default definition

The default value is 0.

#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
-

When the macro is not defined, the library will define it to its default value.

Notes

Inconsistent behavior in C++20 and beyond

When targeting C++20 or above, enabling the legacy comparison behavior is strongly discouraged.

  • The 3-way comparison operator (<=>) will always give the correct result (std::partial_ordering::unordered) regardless of the value of JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON.
  • Overloads for the equality and relational operators emulate the legacy behavior.

Code outside your control may use either 3-way comparison or the equality and relational operators, resulting in inconsistent and unpredictable behavior.

See operator<=> for more information on 3-way comparison.

Deprecation

The legacy comparison behavior is deprecated and may be removed in a future major version release.

New code should not depend on it and existing code should try to remove or rewrite expressions relying on it.

CMake option

Legacy comparison can also be controlled with the CMake option JSON_LegacyDiscardedValueComparison (OFF by default) which defines JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON accordingly.

Examples

Example

The code below switches on the legacy discarded value comparison behavior in the library.

#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 1
-#include <nlohmann/json.hpp>
+ JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON - JSON for Modern C++       

JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON

#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON /* value */
+

This macro enables the (incorrect) legacy comparison behavior of discarded JSON values. Possible values are 1 to enable or 0 to disable (default).

When enabled, comparisons involving at least one discarded JSON value yield results as follows:

Operator Result
== false
!= true
< false
<= true
>= true
> false

Otherwise, comparisons involving at least one discarded JSON value always yield false.

Default definition

The default value is 0.

#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
+

When the macro is not defined, the library will define it to its default value.

Notes

Inconsistent behavior in C++20 and beyond

When targeting C++20 or above, enabling the legacy comparison behavior is strongly discouraged.

  • The 3-way comparison operator (<=>) will always give the correct result (std::partial_ordering::unordered) regardless of the value of JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON.
  • Overloads for the equality and relational operators emulate the legacy behavior.

Code outside your control may use either 3-way comparison or the equality and relational operators, resulting in inconsistent and unpredictable behavior.

See operator<=> for more information on 3-way comparison.

Deprecation

The legacy comparison behavior is deprecated and may be removed in a future major version release.

New code should not depend on it and existing code should try to remove or rewrite expressions relying on it.

CMake option

Legacy comparison can also be controlled with the CMake option JSON_LegacyDiscardedValueComparison (OFF by default) which defines JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON accordingly.

Examples

Example

The code below switches on the legacy discarded value comparison behavior in the library.

#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 1
+#include <nlohmann/json.hpp>
 
-...
-

Version history

  • Added in version 3.11.0.

Last update: August 5, 2022
\ No newline at end of file +... +

Version history

  • Added in version 3.11.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/macros/nlohmann_define_type_intrusive/index.html b/api/macros/nlohmann_define_type_intrusive/index.html index c9a52538f..0e0b7e8b3 100644 --- a/api/macros/nlohmann_define_type_intrusive/index.html +++ b/api/macros/nlohmann_define_type_intrusive/index.html @@ -1,214 +1,287 @@ - NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT - JSON for Modern C++
Skip to content

NLOHMANN_DEFINE_TYPE_INTRUSIVE, NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT

#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(type, member...)              // (1)
+ NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT - JSON for Modern C++       

NLOHMANN_DEFINE_TYPE_INTRUSIVE, NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT, NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE

#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(type, member...)              // (1)
 #define NLOHMANN_DEFINE_TYPE_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 inside the class/struct to create code for. Unlike NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE, it can access private members. The first parameter is the name of the class/struct, and all remaining parameters name the members.

  1. Will use at during deserialization and will throw out_of_range.403 if a key is missing in the JSON object.
  2. Will use value 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 member variable to serialize/deserialize; up to 64 members can be given as comma-separated list

Default definition

The macros add two friend functions to the class which take care of the serialization and deserialization:

friend void to_json(nlohmann::json&, const type&);
-friend void from_json(const nlohmann::json&, type&);
-

See examples below for the concrete generated code.

Notes

Prerequisites

  1. The type type must be default constructible. See How can I use get() for non-default constructible/non-copyable types? for how to overcome this limitation.
  2. The macro must be used inside the type (class/struct).

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 type; other specializations such as nlohmann::ordered_json are currently unsupported.

Examples

Example (1): NLOHMANN_DEFINE_TYPE_INTRUSIVE

Consider the following complete example:

#include <iostream>
-#include <nlohmann/json.hpp>
+#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(type, member...) // (3)
+

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 inside the class/struct to create code for. Unlike NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE, it can access private members. The first parameter is the name of the class/struct, and all remaining parameters name the members.

  1. Will use at during deserialization and will throw out_of_range.403 if a key is missing in the JSON object.
  2. Will use value 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.
  3. Only defines the serialization. Useful in cases when the type does not have a default constructor and only serialization in required.

Parameters

type (in)
name of the type (class, struct) to serialize/deserialize
member (in)
name of the member variable to serialize/deserialize; up to 64 members can be given as comma-separated list

Default definition

The macros add two friend functions to the class which take care of the serialization and deserialization:

friend void to_json(nlohmann::json&, const type&);
+friend void from_json(const nlohmann::json&, type&); // except (3)
+

See examples below for the concrete generated code.

Notes

Prerequisites

  1. The type type must be default constructible (except (3)). See How can I use get() for non-default constructible/non-copyable types? for how to overcome this limitation.
  2. The macro must be used inside the type (class/struct).

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 type; other specializations such as nlohmann::ordered_json are currently unsupported.

Examples

Example (1): NLOHMANN_DEFINE_TYPE_INTRUSIVE

Consider the following complete example:

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-namespace ns
-{
-class person
-{
-  private:
-    std::string name = "John Doe";
-    std::string address = "123 Fake St";
-    int age = -1;
+namespace ns
+{
+class person
+{
+  private:
+    std::string name = "John Doe";
+    std::string address = "123 Fake St";
+    int age = -1;
 
-  public:
-    person() = default;
-    person(std::string name_, std::string address_, int age_)
-        : name(std::move(name_)), address(std::move(address_)), age(age_)
-    {}
+  public:
+    person() = default;
+    person(std::string name_, std::string address_, int age_)
+        : name(std::move(name_)), address(std::move(address_)), age(age_)
+    {}
 
-    NLOHMANN_DEFINE_TYPE_INTRUSIVE(person, name, address, age)
-};
+    NLOHMANN_DEFINE_TYPE_INTRUSIVE(person, name, address, age)
+};
 } // namespace ns
 
-int main()
-{
-    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
+int main()
+{
+    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
 
     // serialization: person -> json
-    json j = p;
-    std::cout << "serialization: " << j << std::endl;
+    json j = p;
+    std::cout << "serialization: " << j << std::endl;
 
     // deserialization: json -> person
-    json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
-    auto p2 = j2.template get<ns::person>();
+    json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
+    auto p2 = j2.template get<ns::person>();
 
     // incomplete deserialization:
-    json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
-    try
-    {
-        auto p3 = j3.template get<ns::person>();
-    }
-    catch (const json::exception& e)
-    {
-        std::cout << "deserialization failed: " << e.what() << std::endl;
-    }
-}
-

Output:

serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}
-deserialization failed: [json.exception.out_of_range.403] key 'age' not found
-

Notes:

  • ns::person is default-constructible. This is a requirement for using the macro.
  • ns::person has private member variables. This makes NLOHMANN_DEFINE_TYPE_INTRUSIVE applicable, but not NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE.
  • The macro NLOHMANN_DEFINE_TYPE_INTRUSIVE is used inside the class.
  • A missing key "age" in the deserialization yields an exception. To fall back to the default value, NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT can be used.

The macro is equivalent to:

#include <iostream>
-#include <nlohmann/json.hpp>
+    json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
+    try
+    {
+        auto p3 = j3.template get<ns::person>();
+    }
+    catch (const json::exception& e)
+    {
+        std::cout << "deserialization failed: " << e.what() << std::endl;
+    }
+}
+

Output:

serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}
+deserialization failed: [json.exception.out_of_range.403] key 'age' not found
+

Notes:

  • ns::person is default-constructible. This is a requirement for using the macro.
  • ns::person has private member variables. This makes NLOHMANN_DEFINE_TYPE_INTRUSIVE applicable, but not NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE.
  • The macro NLOHMANN_DEFINE_TYPE_INTRUSIVE is used inside the class.
  • A missing key "age" in the deserialization yields an exception. To fall back to the default value, NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT can be used.

The macro is equivalent to:

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-namespace ns
-{
-class person
-{
-  private:
-    std::string name = "John Doe";
-    std::string address = "123 Fake St";
-    int age = -1;
+namespace ns
+{
+class person
+{
+  private:
+    std::string name = "John Doe";
+    std::string address = "123 Fake St";
+    int age = -1;
 
-  public:
-    person() = default;
-    person(std::string name_, std::string address_, int age_)
-        : name(std::move(name_)), address(std::move(address_)), age(age_)
-    {}
+  public:
+    person() = default;
+    person(std::string name_, std::string address_, int age_)
+        : name(std::move(name_)), address(std::move(address_)), age(age_)
+    {}
 
-    friend void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t)
-    {
-        nlohmann_json_j["name"] = nlohmann_json_t.name;
-        nlohmann_json_j["address"] = nlohmann_json_t.address;
-        nlohmann_json_j["age"] = nlohmann_json_t.age;
-    }
+    friend void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t)
+    {
+        nlohmann_json_j["name"] = nlohmann_json_t.name;
+        nlohmann_json_j["address"] = nlohmann_json_t.address;
+        nlohmann_json_j["age"] = nlohmann_json_t.age;
+    }
 
-    friend void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t)
-    {
-        nlohmann_json_t.name = nlohmann_json_j.at("name");
-        nlohmann_json_t.address = nlohmann_json_j.at("address");
-        nlohmann_json_t.age = nlohmann_json_j.at("age");
-    }
-};
+    friend void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t)
+    {
+        nlohmann_json_t.name = nlohmann_json_j.at("name");
+        nlohmann_json_t.address = nlohmann_json_j.at("address");
+        nlohmann_json_t.age = nlohmann_json_j.at("age");
+    }
+};
 } // namespace ns
 
-int main()
-{
-    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
+int main()
+{
+    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
 
     // serialization: person -> json
-    json j = p;
-    std::cout << "serialization: " << j << std::endl;
+    json j = p;
+    std::cout << "serialization: " << j << std::endl;
 
     // deserialization: json -> person
-    json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
-    auto p2 = j2.template get<ns::person>();
+    json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
+    auto p2 = j2.template get<ns::person>();
 
     // incomplete deserialization:
-    json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
-    try
-    {
-        auto p3 = j3.template get<ns::person>();
-    }
-    catch (const json::exception& e)
-    {
-        std::cout << "deserialization failed: " << e.what() << std::endl;
-    }
-}
-
Example (2): NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT

Consider the following complete example:

#include <iostream>
-#include <nlohmann/json.hpp>
+    json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
+    try
+    {
+        auto p3 = j3.template get<ns::person>();
+    }
+    catch (const json::exception& e)
+    {
+        std::cout << "deserialization failed: " << e.what() << std::endl;
+    }
+}
+
Example (2): NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT

Consider the following complete example:

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-namespace ns
-{
-class person
-{
-  private:
-    std::string name = "John Doe";
-    std::string address = "123 Fake St";
-    int age = -1;
+namespace ns
+{
+class person
+{
+  private:
+    std::string name = "John Doe";
+    std::string address = "123 Fake St";
+    int age = -1;
 
-  public:
-    person() = default;
-    person(std::string name_, std::string address_, int age_)
-        : name(std::move(name_)), address(std::move(address_)), age(age_)
-    {}
+  public:
+    person() = default;
+    person(std::string name_, std::string address_, int age_)
+        : name(std::move(name_)), address(std::move(address_)), age(age_)
+    {}
 
-    NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(person, name, address, age)
-};
+    NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(person, name, address, age)
+};
 } // namespace ns
 
-int main()
-{
-    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
+int main()
+{
+    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
 
     // serialization: person -> json
-    json j = p;
-    std::cout << "serialization: " << j << std::endl;
+    json j = p;
+    std::cout << "serialization: " << j << std::endl;
 
     // deserialization: json -> person
-    json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
-    auto p2 = j2.template get<ns::person>();
+    json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
+    auto p2 = j2.template get<ns::person>();
 
     // incomplete deserialization:
-    json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
-    auto p3 = j3.template get<ns::person>();
-    std::cout << "roundtrip: " << json(p3) << std::endl;
-}
-

Output:

serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}
-roundtrip: {"address":"742 Evergreen Terrace","age":-1,"name":"Maggie Simpson"}
-

Notes:

  • ns::person is default-constructible. This is a requirement for using the macro.
  • ns::person has private member variables. This makes NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT applicable, but not NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT.
  • The macro NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT is used inside the class.
  • A missing key "age" in the deserialization does not yield an exception. Instead, the default value -1 is used.

The macro is equivalent to:

#include <iostream>
-#include <nlohmann/json.hpp>
+    json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
+    auto p3 = j3.template get<ns::person>();
+    std::cout << "roundtrip: " << json(p3) << std::endl;
+}
+

Output:

serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}
+roundtrip: {"address":"742 Evergreen Terrace","age":-1,"name":"Maggie Simpson"}
+

Notes:

  • ns::person is default-constructible. This is a requirement for using the macro.
  • ns::person has private member variables. This makes NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT applicable, but not NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT.
  • The macro NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT is used inside the class.
  • A missing key "age" in the deserialization does not yield an exception. Instead, the default value -1 is used.

The macro is equivalent to:

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-namespace ns
-{
-class person
-{
-  private:
-    std::string name = "John Doe";
-    std::string address = "123 Fake St";
-    int age = -1;
+namespace ns
+{
+class person
+{
+  private:
+    std::string name = "John Doe";
+    std::string address = "123 Fake St";
+    int age = -1;
 
-  public:
-    person() = default;
-    person(std::string name_, std::string address_, int age_)
-        : name(std::move(name_)), address(std::move(address_)), age(age_)
-    {}
-
-    friend void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t)
-    {
-        nlohmann_json_j["name"] = nlohmann_json_t.name;
-        nlohmann_json_j["address"] = nlohmann_json_t.address;
-        nlohmann_json_j["age"] = nlohmann_json_t.age;
-    }
+  public:
+    person() = default;
+    person(std::string name_, std::string address_, int age_)
+        : name(std::move(name_)), address(std::move(address_)), age(age_)
+    {}
+
+    friend void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t)
+    {
+        nlohmann_json_j["name"] = nlohmann_json_t.name;
+        nlohmann_json_j["address"] = nlohmann_json_t.address;
+        nlohmann_json_j["age"] = nlohmann_json_t.age;
+    }
 
-    friend void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t)
-    {
-        person nlohmann_json_default_obj;
-        nlohmann_json_t.name = nlohmann_json_j.value("name", nlohmann_json_default_obj.name);
-        nlohmann_json_t.address = nlohmann_json_j.value("address", nlohmann_json_default_obj.address);
-        nlohmann_json_t.age = nlohmann_json_j.value("age", nlohmann_json_default_obj.age);
-    }
-};
+    friend void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t)
+    {
+        person nlohmann_json_default_obj;
+        nlohmann_json_t.name = nlohmann_json_j.value("name", nlohmann_json_default_obj.name);
+        nlohmann_json_t.address = nlohmann_json_j.value("address", nlohmann_json_default_obj.address);
+        nlohmann_json_t.age = nlohmann_json_j.value("age", nlohmann_json_default_obj.age);
+    }
+};
 } // namespace ns
 
-int main()
-{
-    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
+int main()
+{
+    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
 
     // serialization: person -> json
-    json j = p;
-    std::cout << "serialization: " << j << std::endl;
+    json j = p;
+    std::cout << "serialization: " << j << std::endl;
 
     // deserialization: json -> person
-    json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
-    auto p2 = j2.template get<ns::person>();
+    json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
+    auto p2 = j2.template get<ns::person>();
 
     // incomplete deserialization:
-    json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
-    auto p3 = j3.template get<ns::person>();
-    std::cout << "roundtrip: " << json(p3) << std::endl;
-}
-

Note how a default-initialized person object is used in the from_json to fill missing values.

See also

Version history

  1. Added in version 3.9.0.
  2. Added in version 3.11.0.

Last update: October 2, 2023
\ No newline at end of file + json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; + auto p3 = j3.template get<ns::person>(); + std::cout << "roundtrip: " << json(p3) << std::endl; +} +

Note how a default-initialized person object is used in the from_json to fill missing values.

Example (3): NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE

Consider the following complete example:

#include <iostream>
+#include <nlohmann/json.hpp>
+
+using json = nlohmann::json;
+using namespace nlohmann::literals;
+
+namespace ns
+{
+class person
+{
+  private:
+    std::string name = "John Doe";
+    std::string address = "123 Fake St";
+    int age = -1;
+
+  public:
+    // No default constructor
+    person(std::string name_, std::string address_, int age_)
+        : name(std::move(name_)), address(std::move(address_)), age(age_)
+    {}
+
+    NLOHMANN_DEFINE_TYPE_INTRUSIVE(person, name, address, age)
+};
+} // namespace ns
+
+int main()
+{
+    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
+
+    // serialization: person -> json
+    json j = p;
+    std::cout << "serialization: " << j << std::endl;
+}
+

Output:

serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}
+

Notes:

  • ns::person is non-default-constructible. This allows this macro to be used instead of NLOHMANN_DEFINE_TYPE_INTRUSIVE and NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT.
  • ns::person has private member variables. This makes NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE applicable, but not NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE.
  • The macro NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE is used inside the class.

The macro is equivalent to:

#include <iostream>
+#include <nlohmann/json.hpp>
+
+using json = nlohmann::json;
+using namespace nlohmann::literals;
+
+namespace ns
+{
+class person
+{
+  private:
+    std::string name = "John Doe";
+    std::string address = "123 Fake St";
+    int age = -1;
+
+  public:
+    // No default constructor
+    person(std::string name_, std::string address_, int age_)
+        : name(std::move(name_)), address(std::move(address_)), age(age_)
+    {}
+
+    friend void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t)
+    {
+        nlohmann_json_j["name"] = nlohmann_json_t.name;
+        nlohmann_json_j["address"] = nlohmann_json_t.address;
+        nlohmann_json_j["age"] = nlohmann_json_t.age;
+    }
+};
+} // namespace ns
+
+int main()
+{
+    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
+
+    // serialization: person -> json
+    json j = p;
+    std::cout << "serialization: " << j << std::endl;
+}
+

See also

Version history

  1. Added in version 3.9.0.
  2. Added in version 3.11.0.
  3. Added in version TODO.

Last update: November 26, 2023
\ No newline at end of file diff --git a/api/macros/nlohmann_define_type_non_intrusive/index.html b/api/macros/nlohmann_define_type_non_intrusive/index.html index 87a1d3349..845ecb342 100644 --- a/api/macros/nlohmann_define_type_non_intrusive/index.html +++ b/api/macros/nlohmann_define_type_non_intrusive/index.html @@ -1,196 +1,255 @@ - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT - JSON for Modern C++
Skip to content

NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE, NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT

#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(type, member...)              // (1)
+ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT - JSON for Modern C++       

NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE, NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT, NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE

#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, 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 during deserialization and will throw out_of_range.403 if a key is missing in the JSON object.
  2. Will use value 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:

void to_json(nlohmann::json&, const type&);
-void from_json(const nlohmann::json&, type&);
-

See examples below for the concrete generated code.

Notes

Prerequisites

  1. The type type must be default constructible. See How can I use get() for non-default constructible/non-copyable types? for how to overcome this limitation.
  2. The macro must be used outside the type (class/struct).
  3. The passed members must be public.

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 type; other specializations such as nlohmann::ordered_json are currently unsupported.

Examples

Example (1): NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE

Consider the following complete example:

#include <iostream>
-#include <nlohmann/json.hpp>
+#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(type, member...) // (3)
+

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, 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 during deserialization and will throw out_of_range.403 if a key is missing in the JSON object.
  2. Will use value 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.
  3. Only defines the serialization. Useful in cases when the type does not have a default constructor and only serialization in required.

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:

void to_json(nlohmann::json&, const type&);
+void from_json(const nlohmann::json&, type&); // except (3)
+

See examples below for the concrete generated code.

Notes

Prerequisites

  1. The type type must be default constructible (except (3). See How can I use get() for non-default constructible/non-copyable types? for how to overcome this limitation.
  2. The macro must be used outside the type (class/struct).
  3. The passed members must be public.

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 type; other specializations such as nlohmann::ordered_json are currently unsupported.

Examples

Example (1): NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE

Consider the following complete example:

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-namespace ns
-{
-struct person
-{
-    std::string name;
-    std::string address;
-    int age;
-};
+namespace ns
+{
+struct person
+{
+    std::string name;
+    std::string address;
+    int age;
+};
 
-NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(person, name, address, age)
+NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(person, name, address, age)
 } // namespace ns
 
-int main()
-{
-    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
+int main()
+{
+    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
 
     // serialization: person -> json
-    json j = p;
-    std::cout << "serialization: " << j << std::endl;
+    json j = p;
+    std::cout << "serialization: " << j << std::endl;
 
     // deserialization: json -> person
-    json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
-    auto p2 = j2.template get<ns::person>();
+    json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
+    auto p2 = j2.template get<ns::person>();
 
     // incomplete deserialization:
-    json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
-    try
-    {
-        auto p3 = j3.template get<ns::person>();
-    }
-    catch (const json::exception& e)
-    {
-        std::cout << "deserialization failed: " << e.what() << std::endl;
-    }
-}
-

Output:

serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}
-deserialization failed: [json.exception.out_of_range.403] key 'age' not found
-

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:

#include <iostream>
-#include <nlohmann/json.hpp>
+    json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
+    try
+    {
+        auto p3 = j3.template get<ns::person>();
+    }
+    catch (const json::exception& e)
+    {
+        std::cout << "deserialization failed: " << e.what() << std::endl;
+    }
+}
+

Output:

serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}
+deserialization failed: [json.exception.out_of_range.403] key 'age' not found
+

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:

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-namespace ns
-{
-struct person
-{
-    std::string name;
-    std::string address;
-    int age;
-};
+namespace ns
+{
+struct person
+{
+    std::string name;
+    std::string address;
+    int age;
+};
 
-void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t)
-{
-    nlohmann_json_j["name"] = nlohmann_json_t.name;
-    nlohmann_json_j["address"] = nlohmann_json_t.address;
-    nlohmann_json_j["age"] = nlohmann_json_t.age;
-}
+void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t)
+{
+    nlohmann_json_j["name"] = nlohmann_json_t.name;
+    nlohmann_json_j["address"] = nlohmann_json_t.address;
+    nlohmann_json_j["age"] = nlohmann_json_t.age;
+}
 
-void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t)
-{
-    nlohmann_json_t.name = nlohmann_json_j.at("name");
-    nlohmann_json_t.address = nlohmann_json_j.at("address");
-    nlohmann_json_t.age = nlohmann_json_j.at("age");
-}
+void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t)
+{
+    nlohmann_json_t.name = nlohmann_json_j.at("name");
+    nlohmann_json_t.address = nlohmann_json_j.at("address");
+    nlohmann_json_t.age = nlohmann_json_j.at("age");
+}
 } // namespace ns
 
-int main()
-{
-    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
+int main()
+{
+    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
 
     // serialization: person -> json
-    json j = p;
-    std::cout << "serialization: " << j << std::endl;
+    json j = p;
+    std::cout << "serialization: " << j << std::endl;
 
     // deserialization: json -> person
-    json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
-    auto p2 = j2.template get<ns::person>();
+    json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
+    auto p2 = j2.template get<ns::person>();
 
     // incomplete deserialization:
-    json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
-    try
-    {
-        auto p3 = j3.template get<ns::person>();
-    }
-    catch (const json::exception& e)
-    {
-        std::cout << "deserialization failed: " << e.what() << std::endl;
-    }
-}
-
Example (2): NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT

Consider the following complete example:

#include <iostream>
-#include <nlohmann/json.hpp>
+    json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
+    try
+    {
+        auto p3 = j3.template get<ns::person>();
+    }
+    catch (const json::exception& e)
+    {
+        std::cout << "deserialization failed: " << e.what() << std::endl;
+    }
+}
+
Example (2): NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT

Consider the following complete example:

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-namespace ns
-{
-struct person
-{
-    std::string name = "John Doe";
-    std::string address = "123 Fake St";
-    int age = -1;
+namespace ns
+{
+struct person
+{
+    std::string name = "John Doe";
+    std::string address = "123 Fake St";
+    int age = -1;
 
-    person() = default;
-    person(std::string name_, std::string address_, int age_)
-        : name(std::move(name_)), address(std::move(address_)), age(age_)
-    {}
-};
+    person() = default;
+    person(std::string name_, std::string address_, int age_)
+        : name(std::move(name_)), address(std::move(address_)), age(age_)
+    {}
+};
 
-NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(person, name, address, age)
-} // namespace ns
-
-int main()
-{
-    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
+NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(person, name, address, age)
+} // namespace ns
+
+int main()
+{
+    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
 
     // serialization: person -> json
-    json j = p;
-    std::cout << "serialization: " << j << std::endl;
+    json j = p;
+    std::cout << "serialization: " << j << std::endl;
 
     // deserialization: json -> person
-    json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
-    auto p2 = j2.template get<ns::person>();
+    json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
+    auto p2 = j2.template get<ns::person>();
 
     // incomplete deserialization:
-    json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
-    auto p3 = j3.template get<ns::person>();
-    std::cout << "roundtrip: " << json(p3) << std::endl;
-}
-

Output:

serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}
-roundtrip: {"address":"742 Evergreen Terrace","age":-1,"name":"Maggie Simpson"}
-

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:

#include <iostream>
-#include <nlohmann/json.hpp>
+    json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
+    auto p3 = j3.template get<ns::person>();
+    std::cout << "roundtrip: " << json(p3) << std::endl;
+}
+

Output:

serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}
+roundtrip: {"address":"742 Evergreen Terrace","age":-1,"name":"Maggie Simpson"}
+

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:

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-namespace ns
-{
-struct person
-{
-    std::string name = "John Doe";
-    std::string address = "123 Fake St";
-    int age = -1;
+namespace ns
+{
+struct person
+{
+    std::string name = "John Doe";
+    std::string address = "123 Fake St";
+    int age = -1;
 
-    person() = default;
-    person(std::string name_, std::string address_, int age_)
-        : name(std::move(name_)), address(std::move(address_)), age(age_)
-    {}
-};
+    person() = default;
+    person(std::string name_, std::string address_, int age_)
+        : name(std::move(name_)), address(std::move(address_)), age(age_)
+    {}
+};
 
-void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t)
-{
-    nlohmann_json_j["name"] = nlohmann_json_t.name;
-    nlohmann_json_j["address"] = nlohmann_json_t.address;
-    nlohmann_json_j["age"] = nlohmann_json_t.age;
-}
+void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t)
+{
+    nlohmann_json_j["name"] = nlohmann_json_t.name;
+    nlohmann_json_j["address"] = nlohmann_json_t.address;
+    nlohmann_json_j["age"] = nlohmann_json_t.age;
+}
 
-void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t)
-{
-    person nlohmann_json_default_obj;
-    nlohmann_json_t.name = nlohmann_json_j.value("name", nlohmann_json_default_obj.name);
-    nlohmann_json_t.address = nlohmann_json_j.value("address", nlohmann_json_default_obj.address);
-    nlohmann_json_t.age = nlohmann_json_j.value("age", nlohmann_json_default_obj.age);
-}
-} // namespace ns
-
-int main()
-{
-    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
+void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t)
+{
+    person nlohmann_json_default_obj;
+    nlohmann_json_t.name = nlohmann_json_j.value("name", nlohmann_json_default_obj.name);
+    nlohmann_json_t.address = nlohmann_json_j.value("address", nlohmann_json_default_obj.address);
+    nlohmann_json_t.age = nlohmann_json_j.value("age", nlohmann_json_default_obj.age);
+}
+} // namespace ns
+
+int main()
+{
+    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
 
     // serialization: person -> json
-    json j = p;
-    std::cout << "serialization: " << j << std::endl;
+    json j = p;
+    std::cout << "serialization: " << j << std::endl;
 
     // deserialization: json -> person
-    json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
-    auto p2 = j2.template get<ns::person>();
+    json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
+    auto p2 = j2.template get<ns::person>();
 
     // incomplete deserialization:
-    json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
-    auto p3 = j3.template get<ns::person>();
-    std::cout << "roundtrip: " << json(p3) << std::endl;
-}
-

Note how a default-initialized person object is used in the from_json to fill missing values.

See also

Version history

  1. Added in version 3.9.0.
  2. Added in version 3.11.0.

Last update: October 2, 2023
\ No newline at end of file + json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; + auto p3 = j3.template get<ns::person>(); + std::cout << "roundtrip: " << json(p3) << std::endl; +} +

Note how a default-initialized person object is used in the from_json to fill missing values.

Example (3): NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE

Consider the following complete example:

#include <iostream>
+#include <nlohmann/json.hpp>
+
+using json = nlohmann::json;
+using namespace nlohmann::literals;
+
+namespace ns
+{
+struct person
+{
+    std::string name;
+    std::string address;
+    int age;
+};
+
+NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(person, name, address, age)
+} // namespace ns
+
+int main()
+{
+    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
+
+    // serialization: person -> json
+    json j = p;
+    std::cout << "serialization: " << j << std::endl;
+}
+

Output:

serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}
+

Notes:

  • ns::person is non-default-constructible. This allows this macro to be used instead of NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT.
  • ns::person has only public member variables. This makes NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE applicable.
  • The macro NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE is used outside the class, but inside its namespace ns.

The macro is equivalent to:

#include <iostream>
+#include <nlohmann/json.hpp>
+
+using json = nlohmann::json;
+using namespace nlohmann::literals;
+
+namespace ns
+{
+struct person
+{
+    std::string name;
+    std::string address;
+    int age;
+};
+
+void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t)
+{
+    nlohmann_json_j["name"] = nlohmann_json_t.name;
+    nlohmann_json_j["address"] = nlohmann_json_t.address;
+    nlohmann_json_j["age"] = nlohmann_json_t.age;
+}
+} // namespace ns
+
+int main()
+{
+    ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
+
+    // serialization: person -> json
+    json j = p;
+    std::cout << "serialization: " << j << std::endl;
+}
+

See also

Version history

  1. Added in version 3.9.0.
  2. Added in version 3.11.0.
  3. Added in version TODO.

Last update: November 26, 2023
\ No newline at end of file diff --git a/api/macros/nlohmann_json_namespace/index.html b/api/macros/nlohmann_json_namespace/index.html index c72c4f9eb..41ee9fb87 100644 --- a/api/macros/nlohmann_json_namespace/index.html +++ b/api/macros/nlohmann_json_namespace/index.html @@ -1,17 +1,17 @@ - NLOHMANN_JSON_NAMESPACE - JSON for Modern C++
Skip to content

NLOHMANN_JSON_NAMESPACE

#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 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.

#include <iostream>
-#include <nlohmann/json.hpp>
+ NLOHMANN_JSON_NAMESPACE - JSON for Modern C++       

NLOHMANN_JSON_NAMESPACE

#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 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.

#include <iostream>
+#include <nlohmann/json.hpp>
 
 // possible use case: use NLOHMANN_JSON_NAMESPACE instead of nlohmann
-using json = NLOHMANN_JSON_NAMESPACE::json;
+using json = NLOHMANN_JSON_NAMESPACE::json;
 
 // macro needed to output the NLOHMANN_JSON_NAMESPACE as string literal
 #define Q(x) #x
 #define QUOTE(x) Q(x)
 
-int main()
-{
-    std::cout << QUOTE(NLOHMANN_JSON_NAMESPACE) << std::endl;
-}
-

Output:

nlohmann::json_abi_v3_11_2
-

See also

Version history

  • Added in version 3.11.0. Changed inline namespace name in version 3.11.2.

Last update: August 10, 2022
\ No newline at end of file +int main() +{ + std::cout << QUOTE(NLOHMANN_JSON_NAMESPACE) << std::endl; +} +

Output:

nlohmann::json_abi_v3_11_2
+

See also

Version history

  • Added in version 3.11.0. Changed inline namespace name in version 3.11.2.

Last update: August 10, 2022
\ No newline at end of file diff --git a/api/macros/nlohmann_json_namespace_begin/index.html b/api/macros/nlohmann_json_namespace_begin/index.html index d6ffadd61..cdb8ae282 100644 --- a/api/macros/nlohmann_json_namespace_begin/index.html +++ b/api/macros/nlohmann_json_namespace_begin/index.html @@ -1,43 +1,43 @@ - NLOHMANN_JSON_NAMESPACE_END - JSON for Modern C++
Skip to content

NLOHMANN_JSON_NAMESPACE_BEGIN, NLOHMANN_JSON_NAMESPACE_END

#define NLOHMANN_JSON_NAMESPACE_BEGIN /* value */  // (1)
+ NLOHMANN_JSON_NAMESPACE_END - JSON for Modern C++       

NLOHMANN_JSON_NAMESPACE_BEGIN, NLOHMANN_JSON_NAMESPACE_END

#define NLOHMANN_JSON_NAMESPACE_BEGIN /* value */  // (1)
 #define NLOHMANN_JSON_NAMESPACE_END   /* value */  // (2)
-

These macros can be used to open and close the nlohmann namespace. See nlohmann Namespace for details.

  1. Opens the namespace.
  2. Closes the namespace.

Default definition

The default definitions open and close the nlohmann namespace. The precise definition of [NLOHMANN_JSON_NAMESPACE_BEGIN] varies as described here.

  1. Default definition of NLOHMANN_JSON_NAMESPACE_BEGIN:

    namespace nlohmann
    -{
    -inline namespace json_abi_v3_11_2
    -{
    +

    These macros can be used to open and close the nlohmann namespace. See nlohmann Namespace for details.

    1. Opens the namespace.
    2. Closes the namespace.

    Default definition

    The default definitions open and close the nlohmann namespace. The precise definition of [NLOHMANN_JSON_NAMESPACE_BEGIN] varies as described here.

    1. Default definition of NLOHMANN_JSON_NAMESPACE_BEGIN:

      namespace nlohmann
      +{
      +inline namespace json_abi_v3_11_2
      +{
       
    2. Default definition of NLOHMANN_JSON_NAMESPACE_END:

      }  // namespace json_abi_v3_11_2
       }  // namespace nlohmann
      -

    When these macros are not defined, the library will define them to their default definitions.

    Examples

    Example

    The example shows how to use NLOHMANN_JSON_NAMESPACE_BEGIN/NLOHMANN_JSON_NAMESPACE_END from the How do I convert third-party types? page.

    #include <iostream>
    -#include <optional>
    -#include <nlohmann/json.hpp>
    +

When these macros are not defined, the library will define them to their default definitions.

Examples

Example

The example shows how to use NLOHMANN_JSON_NAMESPACE_BEGIN/NLOHMANN_JSON_NAMESPACE_END from the How do I convert third-party types? page.

#include <iostream>
+#include <optional>
+#include <nlohmann/json.hpp>
 
 // partial specialization (see https://json.nlohmann.me/features/arbitrary_types/)
-NLOHMANN_JSON_NAMESPACE_BEGIN
-template <typename T>
-struct adl_serializer<std::optional<T>>
-{
-    static void to_json(json& j, const std::optional<T>& opt)
-    {
-        if (opt == std::nullopt)
-        {
-            j = nullptr;
-        }
-        else
-        {
-            j = *opt;
-        }
-    }
-};
-NLOHMANN_JSON_NAMESPACE_END
+NLOHMANN_JSON_NAMESPACE_BEGIN
+template <typename T>
+struct adl_serializer<std::optional<T>>
+{
+    static void to_json(json& j, const std::optional<T>& opt)
+    {
+        if (opt == std::nullopt)
+        {
+            j = nullptr;
+        }
+        else
+        {
+            j = *opt;
+        }
+    }
+};
+NLOHMANN_JSON_NAMESPACE_END
 
-int main()
-{
-    std::optional<int> o1 = 1;
-    std::optional<int> o2 = std::nullopt;
+int main()
+{
+    std::optional<int> o1 = 1;
+    std::optional<int> o2 = std::nullopt;
 
-    NLOHMANN_JSON_NAMESPACE::json j;
-    j.push_back(o1);
-    j.push_back(o2);
-    std::cout << j << std::endl;
-}
-

Output:

[1,null]
-

See also

Version history

  • Added in version 3.11.0. Changed inline namespace name in version 3.11.2.

Last update: August 10, 2022
\ No newline at end of file + NLOHMANN_JSON_NAMESPACE::json j; + j.push_back(o1); + j.push_back(o2); + std::cout << j << std::endl; +} +

Output:

[1,null]
+

See also

Version history

  • Added in version 3.11.0. Changed inline namespace name in version 3.11.2.

Last update: August 10, 2022
\ No newline at end of file diff --git a/api/macros/nlohmann_json_namespace_no_version/index.html b/api/macros/nlohmann_json_namespace_no_version/index.html index 606afd276..c8c8575c8 100644 --- a/api/macros/nlohmann_json_namespace_no_version/index.html +++ b/api/macros/nlohmann_json_namespace_no_version/index.html @@ -1,17 +1,17 @@ - NLOHMANN_JSON_NAMESPACE_NO_VERSION - JSON for Modern C++
Skip to content

NLOHMANN_JSON_NAMESPACE_NO_VERSION

#define NLOHMANN_JSON_NAMESPACE_NO_VERSION /* value */
+ NLOHMANN_JSON_NAMESPACE_NO_VERSION - JSON for Modern C++       

NLOHMANN_JSON_NAMESPACE_NO_VERSION

#define NLOHMANN_JSON_NAMESPACE_NO_VERSION /* value */
 

If defined to 1, the version component is omitted from the inline namespace. See nlohmann Namespace for details.

Default definition

The default value is 0.

#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.

#include <iostream>
+

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.

#include <iostream>
 
 #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 1
-#include <nlohmann/json.hpp>
+#include <nlohmann/json.hpp>
 
 // macro needed to output the NLOHMANN_JSON_NAMESPACE as string literal
 #define Q(x) #x
 #define QUOTE(x) Q(x)
 
-int main()
-{
-    std::cout << QUOTE(NLOHMANN_JSON_NAMESPACE) << std::endl;
-}
-

Output:

nlohmann::json_abi
-

See also

Version history

  • Added in version 3.11.2.

Last update: August 10, 2022
\ No newline at end of file +int main() +{ + std::cout << QUOTE(NLOHMANN_JSON_NAMESPACE) << std::endl; +} +

Output:

nlohmann::json_abi
+

See also

Version history

  • Added in version 3.11.2.

Last update: August 10, 2022
\ No newline at end of file diff --git a/api/macros/nlohmann_json_serialize_enum/index.html b/api/macros/nlohmann_json_serialize_enum/index.html index 26de3e68f..a6bb4e9e2 100644 --- a/api/macros/nlohmann_json_serialize_enum/index.html +++ b/api/macros/nlohmann_json_serialize_enum/index.html @@ -1,104 +1,104 @@ - NLOHMANN_JSON_SERIALIZE_ENUM - JSON for Modern C++
Skip to content

NLOHMANN_JSON_SERIALIZE_ENUM

#define NLOHMANN_JSON_SERIALIZE_ENUM(type, conversion...)
-

By default, enum values are serialized to JSON as integers. In some cases this could result in undesired behavior. If an enum is modified or re-ordered after data has been serialized to JSON, the later de-serialized JSON data may be undefined or a different enum value than was originally intended.

The NLOHMANN_JSON_SERIALIZE_ENUM allows to define a user-defined serialization for every enumerator.

Parameters

type (in)
name of the enum to serialize/deserialize
conversion (in)
a pair of an enumerator and a JSON serialization; arbitrary pairs can be given as a comma-separated list

Default definition

The macros add two friend functions to the class which take care of the serialization and deserialization:

template<typename BasicJsonType>
-inline void to_json(BasicJsonType& j, const type& e);
-template<typename BasicJsonType>
-inline void from_json(const BasicJsonType& j, type& e);
-

Notes

Prerequisites

The macro must be used inside the namespace of the enum.

Important notes

  • When using template get<ENUM_TYPE>(), undefined JSON values will default to the first specified conversion. Select this default pair carefully. See example 1 below.
  • If an enum or JSON value is specified in multiple conversions, the first matching conversion from the top of the list will be returned when converting to or from JSON. See example 2 below.

Examples

Example 1: Basic usage

The example shows how NLOHMANN_JSON_SERIALIZE_ENUM can be used to serialize/deserialize both classical enums and C++11 enum classes:

#include <iostream>
-#include <nlohmann/json.hpp>
+ NLOHMANN_JSON_SERIALIZE_ENUM - JSON for Modern C++       

NLOHMANN_JSON_SERIALIZE_ENUM

#define NLOHMANN_JSON_SERIALIZE_ENUM(type, conversion...)
+

By default, enum values are serialized to JSON as integers. In some cases this could result in undesired behavior. If an enum is modified or re-ordered after data has been serialized to JSON, the later de-serialized JSON data may be undefined or a different enum value than was originally intended.

The NLOHMANN_JSON_SERIALIZE_ENUM allows to define a user-defined serialization for every enumerator.

Parameters

type (in)
name of the enum to serialize/deserialize
conversion (in)
a pair of an enumerator and a JSON serialization; arbitrary pairs can be given as a comma-separated list

Default definition

The macros add two friend functions to the class which take care of the serialization and deserialization:

template<typename BasicJsonType>
+inline void to_json(BasicJsonType& j, const type& e);
+template<typename BasicJsonType>
+inline void from_json(const BasicJsonType& j, type& e);
+

Notes

Prerequisites

The macro must be used inside the namespace of the enum.

Important notes

  • When using template get<ENUM_TYPE>(), undefined JSON values will default to the first specified conversion. Select this default pair carefully. See example 1 below.
  • If an enum or JSON value is specified in multiple conversions, the first matching conversion from the top of the list will be returned when converting to or from JSON. See example 2 below.

Examples

Example 1: Basic usage

The example shows how NLOHMANN_JSON_SERIALIZE_ENUM can be used to serialize/deserialize both classical enums and C++11 enum classes:

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-namespace ns
-{
-enum TaskState
-{
-    TS_STOPPED,
-    TS_RUNNING,
-    TS_COMPLETED,
-    TS_INVALID = -1
-};
+namespace ns
+{
+enum TaskState
+{
+    TS_STOPPED,
+    TS_RUNNING,
+    TS_COMPLETED,
+    TS_INVALID = -1
+};
 
-NLOHMANN_JSON_SERIALIZE_ENUM(TaskState,
-{
-    { TS_INVALID, nullptr },
-    { TS_STOPPED, "stopped" },
-    { TS_RUNNING, "running" },
-    { TS_COMPLETED, "completed" }
-})
+NLOHMANN_JSON_SERIALIZE_ENUM(TaskState,
+{
+    { TS_INVALID, nullptr },
+    { TS_STOPPED, "stopped" },
+    { TS_RUNNING, "running" },
+    { TS_COMPLETED, "completed" }
+})
 
-enum class Color
-{
-    red, green, blue, unknown
-};
+enum class Color
+{
+    red, green, blue, unknown
+};
 
-NLOHMANN_JSON_SERIALIZE_ENUM(Color,
-{
-    { Color::unknown, "unknown" }, { Color::red, "red" },
-    { Color::green, "green" }, { Color::blue, "blue" }
-})
+NLOHMANN_JSON_SERIALIZE_ENUM(Color,
+{
+    { Color::unknown, "unknown" }, { Color::red, "red" },
+    { Color::green, "green" }, { Color::blue, "blue" }
+})
 } // namespace ns
 
-int main()
-{
+int main()
+{
     // serialization
-    json j_stopped = ns::TS_STOPPED;
-    json j_red = ns::Color::red;
-    std::cout << "ns::TS_STOPPED -> " << j_stopped
-              << ", ns::Color::red -> " << j_red << std::endl;
+    json j_stopped = ns::TS_STOPPED;
+    json j_red = ns::Color::red;
+    std::cout << "ns::TS_STOPPED -> " << j_stopped
+              << ", ns::Color::red -> " << j_red << std::endl;
 
     // deserialization
-    json j_running = "running";
-    json j_blue = "blue";
-    auto running = j_running.template get<ns::TaskState>();
-    auto blue = j_blue.template get<ns::Color>();
-    std::cout << j_running << " -> " << running
-              << ", " << j_blue << " -> " << static_cast<int>(blue) << std::endl;
+    json j_running = "running";
+    json j_blue = "blue";
+    auto running = j_running.template get<ns::TaskState>();
+    auto blue = j_blue.template get<ns::Color>();
+    std::cout << j_running << " -> " << running
+              << ", " << j_blue << " -> " << static_cast<int>(blue) << std::endl;
 
     // deserializing undefined JSON value to enum
     // (where the first map entry above is the default)
-    json j_pi = 3.14;
-    auto invalid = j_pi.template get<ns::TaskState>();
-    auto unknown = j_pi.template get<ns::Color>();
-    std::cout << j_pi << " -> " << invalid << ", "
-              << j_pi << " -> " << static_cast<int>(unknown) << std::endl;
-}
-

Output:

ns::TS_STOPPED -> "stopped", ns::Color::red -> "red"
-"running" -> 1, "blue" -> 2
-3.14 -> -1, 3.14 -> 3
-
Example 2: Multiple conversions for one enumerator

The example shows how to use multiple conversions for a single enumerator. In the example, Color::red will always be serialized to "red", because the first occurring conversion. The second conversion, however, offers an alternative deserialization from "rot" to Color::red.

#include <iostream>
-#include <nlohmann/json.hpp>
+    json j_pi = 3.14;
+    auto invalid = j_pi.template get<ns::TaskState>();
+    auto unknown = j_pi.template get<ns::Color>();
+    std::cout << j_pi << " -> " << invalid << ", "
+              << j_pi << " -> " << static_cast<int>(unknown) << std::endl;
+}
+

Output:

ns::TS_STOPPED -> "stopped", ns::Color::red -> "red"
+"running" -> 1, "blue" -> 2
+3.14 -> -1, 3.14 -> 3
+
Example 2: Multiple conversions for one enumerator

The example shows how to use multiple conversions for a single enumerator. In the example, Color::red will always be serialized to "red", because the first occurring conversion. The second conversion, however, offers an alternative deserialization from "rot" to Color::red.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-namespace ns
-{
-enum class Color
-{
-    red, green, blue, unknown
-};
+namespace ns
+{
+enum class Color
+{
+    red, green, blue, unknown
+};
 
-NLOHMANN_JSON_SERIALIZE_ENUM(Color,
-{
-    { Color::unknown, "unknown" }, { Color::red, "red" },
-    { Color::green, "green" }, { Color::blue, "blue" },
+NLOHMANN_JSON_SERIALIZE_ENUM(Color,
+{
+    { Color::unknown, "unknown" }, { Color::red, "red" },
+    { Color::green, "green" }, { Color::blue, "blue" },
     { Color::red, "rot" } // a second conversion for Color::red
-})
-}
+})
+}
 
-int main()
-{
+int main()
+{
     // serialization
-    json j_red = ns::Color::red;
-    std::cout << static_cast<int>(ns::Color::red) << " -> " << j_red << std::endl;
+    json j_red = ns::Color::red;
+    std::cout << static_cast<int>(ns::Color::red) << " -> " << j_red << std::endl;
 
     // deserialization
-    json j_rot = "rot";
-    auto rot = j_rot.template get<ns::Color>();
-    auto red = j_red.template get<ns::Color>();
-    std::cout << j_rot << " -> " << static_cast<int>(rot) << std::endl;
-    std::cout << j_red << " -> " << static_cast<int>(red) << std::endl;
-}
-

Output:

0 -> "red"
-"rot" -> 0
-"red" -> 0
-

See also

Version history

Added in version 3.4.0.


Last update: June 11, 2023
\ No newline at end of file + json j_rot = "rot"; + auto rot = j_rot.template get<ns::Color>(); + auto red = j_red.template get<ns::Color>(); + std::cout << j_rot << " -> " << static_cast<int>(rot) << std::endl; + std::cout << j_red << " -> " << static_cast<int>(red) << std::endl; +} +

Output:

0 -> "red"
+"rot" -> 0
+"red" -> 0
+

See also

Version history

Added in version 3.4.0.


Last update: June 11, 2023
\ No newline at end of file diff --git a/api/macros/nlohmann_json_version_major/index.html b/api/macros/nlohmann_json_version_major/index.html index f08210c83..cbac2b5d0 100644 --- a/api/macros/nlohmann_json_version_major/index.html +++ b/api/macros/nlohmann_json_version_major/index.html @@ -1,17 +1,17 @@ - NLOHMANN_JSON_VERSION_PATCH - JSON for Modern C++
Skip to content

NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, NLOHMANN_JSON_VERSION_PATCH

#define NLOHMANN_JSON_VERSION_MAJOR /* value */
-#define NLOHMANN_JSON_VERSION_MINOR /* value */
-#define NLOHMANN_JSON_VERSION_PATCH /* value */
-

These macros are defined by the library and contain the version numbers according to Semantic Versioning 2.0.0.

Default definition

The macros are defined according to the current library version.

Examples

Example

The example below shows how NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, and NLOHMANN_JSON_VERSION_PATCH are defined by the library.

#include <iostream>
-#include <nlohmann/json.hpp>
+ NLOHMANN_JSON_VERSION_PATCH - JSON for Modern C++       

NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, NLOHMANN_JSON_VERSION_PATCH

#define NLOHMANN_JSON_VERSION_MAJOR /* value */
+#define NLOHMANN_JSON_VERSION_MINOR /* value */
+#define NLOHMANN_JSON_VERSION_PATCH /* value */
+

These macros are defined by the library and contain the version numbers according to Semantic Versioning 2.0.0.

Default definition

The macros are defined according to the current library version.

Examples

Example

The example below shows how NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, and NLOHMANN_JSON_VERSION_PATCH are defined by the library.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
-    std::cout << "JSON for Modern C++ version "
-              << NLOHMANN_JSON_VERSION_MAJOR << "."
-              << NLOHMANN_JSON_VERSION_MINOR << "."
-              << NLOHMANN_JSON_VERSION_PATCH << std::endl;
-}
-

Output:

JSON for Modern C++ version 3.11.2
-

See also

Version history

  • Added in version 3.1.0.

Last update: May 17, 2022
\ No newline at end of file +int main() +{ + std::cout << "JSON for Modern C++ version " + << NLOHMANN_JSON_VERSION_MAJOR << "." + << NLOHMANN_JSON_VERSION_MINOR << "." + << NLOHMANN_JSON_VERSION_PATCH << std::endl; +} +

Output:

JSON for Modern C++ version 3.11.2
+

See also

Version history

  • Added in version 3.1.0.

Last update: May 17, 2022
\ No newline at end of file diff --git a/api/operator_gtgt/index.html b/api/operator_gtgt/index.html index 217332bea..4467f26e7 100644 --- a/api/operator_gtgt/index.html +++ b/api/operator_gtgt/index.html @@ -1,41 +1,41 @@ - operator>>(basic_json) - JSON for Modern C++
Skip to content

nlohmann::operator>>(basic_json)

std::istream& operator>>(std::istream& i, basic_json& j);
-

Deserializes an input stream to a JSON value.

Parameters

i (in, out)
input stream to read a serialized JSON value from
j (in, out)
JSON value to write the deserialized input to

Return value

the stream i

Exceptions

Complexity

Linear in the length of the input. The parser is a predictive LL(1) parser.

Notes

A UTF-8 byte order mark is silently ignored.

Deprecation

This function replaces function std::istream& operator<<(basic_json& j, std::istream& i) which has been deprecated in version 3.0.0. It will be removed in version 4.0.0. Please replace calls like j << i; with i >> j;.

Examples

Example

The example below shows how a JSON value is constructed by reading a serialization from a stream.

#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <nlohmann/json.hpp>
+ operator>>(basic_json) - JSON for Modern C++       

nlohmann::operator>>(basic_json)

std::istream& operator>>(std::istream& i, basic_json& j);
+

Deserializes an input stream to a JSON value.

Parameters

i (in, out)
input stream to read a serialized JSON value from
j (in, out)
JSON value to write the deserialized input to

Return value

the stream i

Exceptions

Complexity

Linear in the length of the input. The parser is a predictive LL(1) parser.

Notes

A UTF-8 byte order mark is silently ignored.

Deprecation

This function replaces function std::istream& operator<<(basic_json& j, std::istream& i) which has been deprecated in version 3.0.0. It will be removed in version 4.0.0. Please replace calls like j << i; with i >> j;.

Examples

Example

The example below shows how a JSON value is constructed by reading a serialization from a stream.

#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create stream with serialized JSON
-    std::stringstream ss;
+    std::stringstream ss;
     ss << R"({
         "number": 23,
         "string": "Hello, world!",
         "array": [1, 2, 3, 4, 5],
         "boolean": false,
         "null": null
-    })";
+    })";
 
     // create JSON value and read the serialization from the stream
-    json j;
-    ss >> j;
+    json j;
+    ss >> j;
 
     // serialize JSON
-    std::cout << std::setw(2) << j << '\n';
-}
-

Output:

{
-  "array": [
-    1,
-    2,
-    3,
-    4,
-    5
-  ],
-  "boolean": false,
-  "null": null,
-  "number": 23,
-  "string": "Hello, world!"
-}
-

See also

  • accept - check if the input is valid JSON
  • parse - deserialize from a compatible input

Version history

  • Added in version 1.0.0. Deprecated in version 3.0.0.

Last update: August 5, 2022
\ No newline at end of file + std::cout << std::setw(2) << j << '\n'; +} +

Output:

{
+  "array": [
+    1,
+    2,
+    3,
+    4,
+    5
+  ],
+  "boolean": false,
+  "null": null,
+  "number": 23,
+  "string": "Hello, world!"
+}
+

See also

  • accept - check if the input is valid JSON
  • parse - deserialize from a compatible input

Version history

  • Added in version 1.0.0. Deprecated in version 3.0.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/operator_literal_json/index.html b/api/operator_literal_json/index.html index b162a793a..3c9179113 100644 --- a/api/operator_literal_json/index.html +++ b/api/operator_literal_json/index.html @@ -1,24 +1,24 @@ - operator""_json - JSON for Modern C++
Skip to content

nlohmann::operator""_json

json operator ""_json(const char* s, std::size_t n);
-

This operator implements a user-defined string literal for JSON objects. It can be used by adding _json to a string literal and returns a json object if no parse error occurred.

It is recommended to bring the operator into scope using any of the following lines:

using nlohmann::literals::operator ""_json;
-using namespace nlohmann::literals;
-using namespace nlohmann::json_literals;
-using namespace nlohmann::literals::json_literals;
-using namespace nlohmann;
-

This is suggested to ease migration to the next major version release of the library. See 'JSON_USE_GLOBAL_UDLS` for details.

Parameters

s (in)
a string representation of a JSON object
n (in)
length of string s

Return value

json value parsed from s

Exceptions

The function can throw anything that parse(s, s+n) would throw.

Complexity

Linear.

Examples

Example

The following code shows how to create JSON values from string literals.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+ operator""_json - JSON for Modern C++       

nlohmann::operator""_json

json operator ""_json(const char* s, std::size_t n);
+

This operator implements a user-defined string literal for JSON objects. It can be used by adding _json to a string literal and returns a json object if no parse error occurred.

It is recommended to bring the operator into scope using any of the following lines:

using nlohmann::literals::operator ""_json;
+using namespace nlohmann::literals;
+using namespace nlohmann::json_literals;
+using namespace nlohmann::literals::json_literals;
+using namespace nlohmann;
+

This is suggested to ease migration to the next major version release of the library. See 'JSON_USE_GLOBAL_UDLS` for details.

Parameters

s (in)
a string representation of a JSON object
n (in)
length of string s

Return value

json value parsed from s

Exceptions

The function can throw anything that parse(s, s+n) would throw.

Complexity

Linear.

Examples

Example

The following code shows how to create JSON values from string literals.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
-    json j = R"( {"hello": "world", "answer": 42} )"_json;
+int main()
+{
+    json j = R"( {"hello": "world", "answer": 42} )"_json;
 
-    std::cout << std::setw(2) << j << '\n';
-}
-

Output:

{
-  "answer": 42,
-  "hello": "world"
-}
-

Version history

  • Added in version 1.0.0.
  • Moved to namespace nlohmann::literals::json_literals in 3.11.0.

Last update: September 23, 2023
\ No newline at end of file + std::cout << std::setw(2) << j << '\n'; +} +

Output:

{
+  "answer": 42,
+  "hello": "world"
+}
+

Version history

  • Added in version 1.0.0.
  • Moved to namespace nlohmann::literals::json_literals in 3.11.0.

Last update: September 23, 2023
\ No newline at end of file diff --git a/api/operator_literal_json_pointer/index.html b/api/operator_literal_json_pointer/index.html index 7a6e57713..499d877cd 100644 --- a/api/operator_literal_json_pointer/index.html +++ b/api/operator_literal_json_pointer/index.html @@ -1,22 +1,22 @@ - operator""_json_pointer - JSON for Modern C++
Skip to content

nlohmann::operator""_json_pointer

json_pointer operator ""_json_pointer(const char* s, std::size_t n);
-

This operator implements a user-defined string literal for JSON Pointers. It can be used by adding _json_pointer to a string literal and returns a json_pointer object if no parse error occurred.

It is recommended to bring the operator into scope using any of the following lines:

using nlohmann::literals::operator ""_json_pointer;
-using namespace nlohmann::literals;
-using namespace nlohmann::json_literals;
-using namespace nlohmann::literals::json_literals;
-using namespace nlohmann;
-
This is suggested to ease migration to the next major version release of the library. See 'JSON_USE_GLOBAL_UDLS` for details.

Parameters

s (in)
a string representation of a JSON Pointer
n (in)
length of string s

Return value

json_pointer value parsed from s

Exceptions

The function can throw anything that json_pointer::json_pointer would throw.

Complexity

Linear.

Examples

Example

The following code shows how to create JSON Pointers from string literals.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+ operator""_json_pointer - JSON for Modern C++       

nlohmann::operator""_json_pointer

json_pointer operator ""_json_pointer(const char* s, std::size_t n);
+

This operator implements a user-defined string literal for JSON Pointers. It can be used by adding _json_pointer to a string literal and returns a json_pointer object if no parse error occurred.

It is recommended to bring the operator into scope using any of the following lines:

using nlohmann::literals::operator ""_json_pointer;
+using namespace nlohmann::literals;
+using namespace nlohmann::json_literals;
+using namespace nlohmann::literals::json_literals;
+using namespace nlohmann;
+
This is suggested to ease migration to the next major version release of the library. See 'JSON_USE_GLOBAL_UDLS` for details.

Parameters

s (in)
a string representation of a JSON Pointer
n (in)
length of string s

Return value

json_pointer value parsed from s

Exceptions

The function can throw anything that json_pointer::json_pointer would throw.

Complexity

Linear.

Examples

Example

The following code shows how to create JSON Pointers from string literals.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
-using namespace nlohmann::literals;
+using json = nlohmann::json;
+using namespace nlohmann::literals;
 
-int main()
-{
-    json j = R"( {"hello": "world", "answer": 42} )"_json;
-    auto val = j["/hello"_json_pointer];
+int main()
+{
+    json j = R"( {"hello": "world", "answer": 42} )"_json;
+    auto val = j["/hello"_json_pointer];
 
-    std::cout << std::setw(2) << val << '\n';
-}
-

Output:

"world"
-

See also

Version history

  • Added in version 2.0.0.
  • Moved to namespace nlohmann::literals::json_literals in 3.11.0.

Last update: September 23, 2023
\ No newline at end of file + std::cout << std::setw(2) << val << '\n'; +} +

Output:

"world"
+

See also

Version history

  • Added in version 2.0.0.
  • Moved to namespace nlohmann::literals::json_literals in 3.11.0.

Last update: September 23, 2023
\ No newline at end of file diff --git a/api/operator_ltlt/index.html b/api/operator_ltlt/index.html index c91e36a55..ad9ab2052 100644 --- a/api/operator_ltlt/index.html +++ b/api/operator_ltlt/index.html @@ -1,60 +1,60 @@ - operator<<(json_pointer) - JSON for Modern C++
Skip to content

nlohmann::operator<<(basic_json), nlohmann::operator<<(json_pointer)

std::ostream& operator<<(std::ostream& o, const basic_json& j);      // (1)
+ operator<<(json_pointer) - JSON for Modern C++       

nlohmann::operator<<(basic_json), nlohmann::operator<<(json_pointer)

std::ostream& operator<<(std::ostream& o, const basic_json& j);      // (1)
 
 std::ostream& operator<<(std::ostream& o, const json_pointer& ptr);  // (2)
-
  1. Serialize the given JSON value j to the output stream o. The JSON value will be serialized using the dump member function.
    • The indentation of the output can be controlled with the member variable width of the output stream o. For instance, using the manipulator std::setw(4) on o sets the indentation level to 4 and the serialization result is the same as calling dump(4).
    • The indentation character can be controlled with the member variable fill of the output stream o. For instance, the manipulator std::setfill('\\t') sets indentation to use a tab character rather than the default space character.
  2. Write a string representation of the given JSON pointer ptr to the output stream o. The string representation is obtained using the to_string member function.

Parameters

o (in, out)
stream to write to
j (in)
JSON value to serialize
ptr (in)
JSON pointer to write

Return value

the stream o

Exceptions

  1. Throws type_error.316 if a string stored inside the JSON value is not UTF-8 encoded. Note that unlike the dump member functions, no error_handler can be set.
  2. None.

Complexity

Linear.

Notes

Deprecation

Function std::ostream& operator<<(std::ostream& o, const basic_json& j) replaces function std::ostream& operator>>(const basic_json& j, std::ostream& o) which has been deprecated in version 3.0.0. It will be removed in version 4.0.0. Please replace calls like j >> o; with o << j;.

Examples

Example: (1) serialize JSON value to stream

The example below shows the serialization with different parameters to width to adjust the indentation level.

#include <iostream>
-#include <iomanip>
-#include <nlohmann/json.hpp>
+
  1. Serialize the given JSON value j to the output stream o. The JSON value will be serialized using the dump member function.
    • The indentation of the output can be controlled with the member variable width of the output stream o. For instance, using the manipulator std::setw(4) on o sets the indentation level to 4 and the serialization result is the same as calling dump(4).
    • The indentation character can be controlled with the member variable fill of the output stream o. For instance, the manipulator std::setfill('\\t') sets indentation to use a tab character rather than the default space character.
  2. Write a string representation of the given JSON pointer ptr to the output stream o. The string representation is obtained using the to_string member function.

Parameters

o (in, out)
stream to write to
j (in)
JSON value to serialize
ptr (in)
JSON pointer to write

Return value

the stream o

Exceptions

  1. Throws type_error.316 if a string stored inside the JSON value is not UTF-8 encoded. Note that unlike the dump member functions, no error_handler can be set.
  2. None.

Complexity

Linear.

Notes

Deprecation

Function std::ostream& operator<<(std::ostream& o, const basic_json& j) replaces function std::ostream& operator>>(const basic_json& j, std::ostream& o) which has been deprecated in version 3.0.0. It will be removed in version 4.0.0. Please replace calls like j >> o; with o << j;.

Examples

Example: (1) serialize JSON value to stream

The example below shows the serialization with different parameters to width to adjust the indentation level.

#include <iostream>
+#include <iomanip>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON values
-    json j_object = {{"one", 1}, {"two", 2}};
-    json j_array = {1, 2, 4, 8, 16};
+    json j_object = {{"one", 1}, {"two", 2}};
+    json j_array = {1, 2, 4, 8, 16};
 
     // serialize without indentation
-    std::cout << j_object << "\n\n";
-    std::cout << j_array << "\n\n";
+    std::cout << j_object << "\n\n";
+    std::cout << j_array << "\n\n";
 
     // serialize with indentation
-    std::cout << std::setw(4) << j_object << "\n\n";
-    std::cout << std::setw(2) << j_array << "\n\n";
-    std::cout << std::setw(1) << std::setfill('\t') << j_object << "\n\n";
-}
-

Output:

{"one":1,"two":2}
+    std::cout << std::setw(4) << j_object << "\n\n";
+    std::cout << std::setw(2) << j_array << "\n\n";
+    std::cout << std::setw(1) << std::setfill('\t') << j_object << "\n\n";
+}
+

Output:

{"one":1,"two":2}
 
-[1,2,4,8,16]
+[1,2,4,8,16]
 
-{
-    "one": 1,
-    "two": 2
-}
+{
+    "one": 1,
+    "two": 2
+}
 
-[
-  1,
-  2,
-  4,
-  8,
-  16
-]
+[
+  1,
+  2,
+  4,
+  8,
+  16
+]
 
-{
-    "one": 1,
-    "two": 2
-}
-
Example: (2) write JSON pointer to stream

The example below shows how to write a JSON pointer to a stream.

#include <iostream>
-#include <nlohmann/json.hpp>
+{
+    "one": 1,
+    "two": 2
+}
+
Example: (2) write JSON pointer to stream

The example below shows how to write a JSON pointer to a stream.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using json = nlohmann::json;
+using json = nlohmann::json;
 
-int main()
-{
+int main()
+{
     // create JSON poiner
-    json::json_pointer ptr("/foo/bar/baz");
+    json::json_pointer ptr("/foo/bar/baz");
 
     // write string representation to stream
-    std::cout << ptr << std::endl;
-}
-

Output:

/foo/bar/baz
-

Version history

  1. Added in version 1.0.0. Added support for indentation character and deprecated std::ostream& operator>>(const basic_json& j, std::ostream& o) in version 3.0.0.
  2. Added in version 3.11.0.

Last update: August 5, 2022
\ No newline at end of file + std::cout << ptr << std::endl; +} +

Output:

/foo/bar/baz
+

Version history

  1. Added in version 1.0.0. Added support for indentation character and deprecated std::ostream& operator>>(const basic_json& j, std::ostream& o) in version 3.0.0.
  2. Added in version 3.11.0.

Last update: August 5, 2022
\ No newline at end of file diff --git a/api/ordered_json/index.html b/api/ordered_json/index.html index 08da87463..35db68277 100644 --- a/api/ordered_json/index.html +++ b/api/ordered_json/index.html @@ -1,21 +1,21 @@ - ordered_json - JSON for Modern C++
Skip to content

nlohmann::ordered_json

using ordered_json = basic_json<ordered_map>;
-

This type preserves the insertion order of object keys.

Examples

Example

The example below demonstrates how ordered_json preserves the insertion order of object keys.

#include <iostream>
-#include <nlohmann/json.hpp>
+ ordered_json - JSON for Modern C++       

nlohmann::ordered_json

using ordered_json = basic_json<ordered_map>;
+

This type preserves the insertion order of object keys.

Examples

Example

The example below demonstrates how ordered_json preserves the insertion order of object keys.

#include <iostream>
+#include <nlohmann/json.hpp>
 
-using ordered_json = nlohmann::ordered_json;
+using ordered_json = nlohmann::ordered_json;
 
-int main()
-{
-    ordered_json j;
-    j["one"] = 1;
-    j["two"] = 2;
-    j["three"] = 3;
+int main()
+{
+    ordered_json j;
+    j["one"] = 1;
+    j["two"] = 2;
+    j["three"] = 3;
 
-    std::cout << j.dump(2) << '\n';
-}
-

Output:

{
-  "one": 1,
-  "two": 2,
-  "three": 3
-}
-

See also

Version history

Since version 3.9.0.


Last update: May 17, 2022
\ No newline at end of file + std::cout << j.dump(2) << '\n'; +} +

Output:

{
+  "one": 1,
+  "two": 2,
+  "three": 3
+}
+

See also

Version history

Since version 3.9.0.


Last update: May 17, 2022
\ No newline at end of file diff --git a/api/ordered_map/index.html b/api/ordered_map/index.html index 8960a8b76..2a37414cc 100644 --- a/api/ordered_map/index.html +++ b/api/ordered_map/index.html @@ -1,54 +1,54 @@ - ordered_map - JSON for Modern C++
Skip to content

nlohmann::ordered_map

template<class Key, class T, class IgnoredLess = std::less<Key>,
-         class Allocator = std::allocator<std::pair<const Key, T>>>
-struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>;
-

A minimal map-like container that preserves insertion order for use within nlohmann::ordered_json (nlohmann::basic_json<ordered_map>).

Template parameters

Key
key type
T
mapped type
IgnoredLess
comparison function (ignored and only added to ensure compatibility with std::map)
Allocator
allocator type

Member types

Member functions

  • (constructor)
  • (destructor)
  • emplace
  • operator[]
  • at
  • erase
  • count
  • find
  • insert

Examples

Example

The example shows the different behavior of std::map and nlohmann::ordered_map.

#include <iostream>
+#include <nlohmann/json.hpp>
 
 // simple output function
-template<typename Map>
-void output(const char* prefix, const Map& m)
-{
-    std::cout << prefix << " = { ";
-    for (auto& element : m)
-    {
-        std::cout << element.first << ":" << element.second << ' ';
-    }
-    std::cout << "}" << std::endl;
-}
+template<typename Map>
+void output(const char* prefix, const Map& m)
+{
+    std::cout << prefix << " = { ";
+    for (auto& element : m)
+    {
+        std::cout << element.first << ":" << element.second << ' ';
+    }
+    std::cout << "}" << std::endl;
+}
 
-int main()
-{
+int main()
+{
     // create and fill two maps
-    nlohmann::ordered_map<std::string, std::string> m_ordered;
-    m_ordered["one"] = "eins";
-    m_ordered["two"] = "zwei";
-    m_ordered["three"] = "drei";
+    nlohmann::ordered_map<std::string, std::string> m_ordered;
+    m_ordered["one"] = "eins";
+    m_ordered["two"] = "zwei";
+    m_ordered["three"] = "drei";
 
-    std::map<std::string, std::string> m_std;
-    m_std["one"] = "eins";
-    m_std["two"] = "zwei";
-    m_std["three"] = "drei";
+    std::map<std::string, std::string> m_std;
+    m_std["one"] = "eins";
+    m_std["two"] = "zwei";
+    m_std["three"] = "drei";
 
     // output: m_ordered is ordered by insertion order, m_std is ordered by key
-    output("m_ordered", m_ordered);
-    output("m_std", m_std);
+    output("m_ordered", m_ordered);
+    output("m_std", m_std);
 
     // erase and re-add "one" key
-    m_ordered.erase("one");
-    m_ordered["one"] = "eins";
+    m_ordered.erase("one");
+    m_ordered["one"] = "eins";
 
-    m_std.erase("one");
-    m_std["one"] = "eins";
+    m_std.erase("one");
+    m_std["one"] = "eins";
 
     // output: m_ordered shows newly added key at the end; m_std is again ordered by key
-    output("m_ordered", m_ordered);
-    output("m_std", m_std);
-}
-

Output:

m_ordered = { one:eins two:zwei three:drei }
-m_std = { one:eins three:drei two:zwei }
-m_ordered = { two:zwei three:drei one:eins }
-m_std = { one:eins three:drei two:zwei }
-

See also

Version history


Last update: May 1, 2022
\ No newline at end of file + output("m_ordered", m_ordered); + output("m_std", m_std); +} +

Output:

m_ordered = { one:eins two:zwei three:drei }
+m_std = { one:eins three:drei two:zwei }
+m_ordered = { two:zwei three:drei one:eins }
+m_std = { one:eins three:drei two:zwei }
+

See also

Version history


Last update: May 1, 2022
\ No newline at end of file diff --git a/assets/javascripts/bundle.5a2dcb6a.min.js b/assets/javascripts/bundle.5a2dcb6a.min.js deleted file mode 100644 index 6f9720b67..000000000 --- a/assets/javascripts/bundle.5a2dcb6a.min.js +++ /dev/null @@ -1,29 +0,0 @@ -"use strict";(()=>{var aa=Object.create;var wr=Object.defineProperty;var sa=Object.getOwnPropertyDescriptor;var ca=Object.getOwnPropertyNames,kt=Object.getOwnPropertySymbols,fa=Object.getPrototypeOf,Er=Object.prototype.hasOwnProperty,fn=Object.prototype.propertyIsEnumerable;var cn=(e,t,r)=>t in e?wr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,H=(e,t)=>{for(var r in t||(t={}))Er.call(t,r)&&cn(e,r,t[r]);if(kt)for(var r of kt(t))fn.call(t,r)&&cn(e,r,t[r]);return e};var un=(e,t)=>{var r={};for(var n in e)Er.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&kt)for(var n of kt(e))t.indexOf(n)<0&&fn.call(e,n)&&(r[n]=e[n]);return r};var yt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ua=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ca(t))!Er.call(e,o)&&o!==r&&wr(e,o,{get:()=>t[o],enumerable:!(n=sa(t,o))||n.enumerable});return e};var Ye=(e,t,r)=>(r=e!=null?aa(fa(e)):{},ua(t||!e||!e.__esModule?wr(r,"default",{value:e,enumerable:!0}):r,e));var ln=yt((Sr,pn)=>{(function(e,t){typeof Sr=="object"&&typeof pn!="undefined"?t():typeof define=="function"&&define.amd?define(t):t()})(Sr,function(){"use strict";function e(r){var n=!0,o=!1,i=null,s={text:!0,search:!0,url:!0,tel:!0,email:!0,password:!0,number:!0,date:!0,month:!0,week:!0,time:!0,datetime:!0,"datetime-local":!0};function a(_){return!!(_&&_!==document&&_.nodeName!=="HTML"&&_.nodeName!=="BODY"&&"classList"in _&&"contains"in _.classList)}function c(_){var We=_.type,Fe=_.tagName;return!!(Fe==="INPUT"&&s[We]&&!_.readOnly||Fe==="TEXTAREA"&&!_.readOnly||_.isContentEditable)}function f(_){_.classList.contains("focus-visible")||(_.classList.add("focus-visible"),_.setAttribute("data-focus-visible-added",""))}function u(_){!_.hasAttribute("data-focus-visible-added")||(_.classList.remove("focus-visible"),_.removeAttribute("data-focus-visible-added"))}function p(_){_.metaKey||_.altKey||_.ctrlKey||(a(r.activeElement)&&f(r.activeElement),n=!0)}function l(_){n=!1}function d(_){!a(_.target)||(n||c(_.target))&&f(_.target)}function h(_){!a(_.target)||(_.target.classList.contains("focus-visible")||_.target.hasAttribute("data-focus-visible-added"))&&(o=!0,window.clearTimeout(i),i=window.setTimeout(function(){o=!1},100),u(_.target))}function b(_){document.visibilityState==="hidden"&&(o&&(n=!0),U())}function U(){document.addEventListener("mousemove",W),document.addEventListener("mousedown",W),document.addEventListener("mouseup",W),document.addEventListener("pointermove",W),document.addEventListener("pointerdown",W),document.addEventListener("pointerup",W),document.addEventListener("touchmove",W),document.addEventListener("touchstart",W),document.addEventListener("touchend",W)}function G(){document.removeEventListener("mousemove",W),document.removeEventListener("mousedown",W),document.removeEventListener("mouseup",W),document.removeEventListener("pointermove",W),document.removeEventListener("pointerdown",W),document.removeEventListener("pointerup",W),document.removeEventListener("touchmove",W),document.removeEventListener("touchstart",W),document.removeEventListener("touchend",W)}function W(_){_.target.nodeName&&_.target.nodeName.toLowerCase()==="html"||(n=!1,G())}document.addEventListener("keydown",p,!0),document.addEventListener("mousedown",l,!0),document.addEventListener("pointerdown",l,!0),document.addEventListener("touchstart",l,!0),document.addEventListener("visibilitychange",b,!0),U(),r.addEventListener("focus",d,!0),r.addEventListener("blur",h,!0),r.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&r.host?r.host.setAttribute("data-js-focus-visible",""):r.nodeType===Node.DOCUMENT_NODE&&(document.documentElement.classList.add("js-focus-visible"),document.documentElement.setAttribute("data-js-focus-visible",""))}if(typeof window!="undefined"&&typeof document!="undefined"){window.applyFocusVisiblePolyfill=e;var t;try{t=new CustomEvent("focus-visible-polyfill-ready")}catch(r){t=document.createEvent("CustomEvent"),t.initCustomEvent("focus-visible-polyfill-ready",!1,!1,{})}window.dispatchEvent(t)}typeof document!="undefined"&&e(document)})});var mn=yt(Or=>{(function(e){var t=function(){try{return!!Symbol.iterator}catch(f){return!1}},r=t(),n=function(f){var u={next:function(){var p=f.shift();return{done:p===void 0,value:p}}};return r&&(u[Symbol.iterator]=function(){return u}),u},o=function(f){return encodeURIComponent(f).replace(/%20/g,"+")},i=function(f){return decodeURIComponent(String(f).replace(/\+/g," "))},s=function(){var f=function(p){Object.defineProperty(this,"_entries",{writable:!0,value:{}});var l=typeof p;if(l!=="undefined")if(l==="string")p!==""&&this._fromString(p);else if(p instanceof f){var d=this;p.forEach(function(G,W){d.append(W,G)})}else if(p!==null&&l==="object")if(Object.prototype.toString.call(p)==="[object Array]")for(var h=0;hd[0]?1:0}),f._entries&&(f._entries={});for(var p=0;p1?i(d[1]):"")}})})(typeof global!="undefined"?global:typeof window!="undefined"?window:typeof self!="undefined"?self:Or);(function(e){var t=function(){try{var o=new e.URL("b","http://a");return o.pathname="c d",o.href==="http://a/c%20d"&&o.searchParams}catch(i){return!1}},r=function(){var o=e.URL,i=function(c,f){typeof c!="string"&&(c=String(c)),f&&typeof f!="string"&&(f=String(f));var u=document,p;if(f&&(e.location===void 0||f!==e.location.href)){f=f.toLowerCase(),u=document.implementation.createHTMLDocument(""),p=u.createElement("base"),p.href=f,u.head.appendChild(p);try{if(p.href.indexOf(f)!==0)throw new Error(p.href)}catch(_){throw new Error("URL unable to set base "+f+" due to "+_)}}var l=u.createElement("a");l.href=c,p&&(u.body.appendChild(l),l.href=l.href);var d=u.createElement("input");if(d.type="url",d.value=c,l.protocol===":"||!/:/.test(l.href)||!d.checkValidity()&&!f)throw new TypeError("Invalid URL");Object.defineProperty(this,"_anchorElement",{value:l});var h=new e.URLSearchParams(this.search),b=!0,U=!0,G=this;["append","delete","set"].forEach(function(_){var We=h[_];h[_]=function(){We.apply(h,arguments),b&&(U=!1,G.search=h.toString(),U=!0)}}),Object.defineProperty(this,"searchParams",{value:h,enumerable:!0});var W=void 0;Object.defineProperty(this,"_updateSearchParams",{enumerable:!1,configurable:!1,writable:!1,value:function(){this.search!==W&&(W=this.search,U&&(b=!1,this.searchParams._fromString(this.search),b=!0))}})},s=i.prototype,a=function(c){Object.defineProperty(s,c,{get:function(){return this._anchorElement[c]},set:function(f){this._anchorElement[c]=f},enumerable:!0})};["hash","host","hostname","port","protocol"].forEach(function(c){a(c)}),Object.defineProperty(s,"search",{get:function(){return this._anchorElement.search},set:function(c){this._anchorElement.search=c,this._updateSearchParams()},enumerable:!0}),Object.defineProperties(s,{toString:{get:function(){var c=this;return function(){return c.href}}},href:{get:function(){return this._anchorElement.href.replace(/\?$/,"")},set:function(c){this._anchorElement.href=c,this._updateSearchParams()},enumerable:!0},pathname:{get:function(){return this._anchorElement.pathname.replace(/(^\/?)/,"/")},set:function(c){this._anchorElement.pathname=c},enumerable:!0},origin:{get:function(){var c={"http:":80,"https:":443,"ftp:":21}[this._anchorElement.protocol],f=this._anchorElement.port!=c&&this._anchorElement.port!=="";return this._anchorElement.protocol+"//"+this._anchorElement.hostname+(f?":"+this._anchorElement.port:"")},enumerable:!0},password:{get:function(){return""},set:function(c){},enumerable:!0},username:{get:function(){return""},set:function(c){},enumerable:!0}}),i.createObjectURL=function(c){return o.createObjectURL.apply(o,arguments)},i.revokeObjectURL=function(c){return o.revokeObjectURL.apply(o,arguments)},e.URL=i};if(t()||r(),e.location!==void 0&&!("origin"in e.location)){var n=function(){return e.location.protocol+"//"+e.location.hostname+(e.location.port?":"+e.location.port:"")};try{Object.defineProperty(e.location,"origin",{get:n,enumerable:!0})}catch(o){setInterval(function(){e.location.origin=n()},100)}}})(typeof global!="undefined"?global:typeof window!="undefined"?window:typeof self!="undefined"?self:Or)});var Pn=yt((Ks,$t)=>{/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */var dn,hn,bn,vn,gn,yn,xn,wn,En,Ht,_r,Sn,On,_n,rt,Tn,Mn,Ln,An,Cn,Rn,kn,Hn,Pt;(function(e){var t=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(n){e(r(t,r(n)))}):typeof $t=="object"&&typeof $t.exports=="object"?e(r(t,r($t.exports))):e(r(t));function r(n,o){return n!==t&&(typeof Object.create=="function"?Object.defineProperty(n,"__esModule",{value:!0}):n.__esModule=!0),function(i,s){return n[i]=o?o(i,s):s}}})(function(e){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i])};dn=function(n,o){if(typeof o!="function"&&o!==null)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");t(n,o);function i(){this.constructor=n}n.prototype=o===null?Object.create(o):(i.prototype=o.prototype,new i)},hn=Object.assign||function(n){for(var o,i=1,s=arguments.length;i=0;u--)(f=n[u])&&(c=(a<3?f(c):a>3?f(o,i,c):f(o,i))||c);return a>3&&c&&Object.defineProperty(o,i,c),c},gn=function(n,o){return function(i,s){o(i,s,n)}},yn=function(n,o){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,o)},xn=function(n,o,i,s){function a(c){return c instanceof i?c:new i(function(f){f(c)})}return new(i||(i=Promise))(function(c,f){function u(d){try{l(s.next(d))}catch(h){f(h)}}function p(d){try{l(s.throw(d))}catch(h){f(h)}}function l(d){d.done?c(d.value):a(d.value).then(u,p)}l((s=s.apply(n,o||[])).next())})},wn=function(n,o){var i={label:0,sent:function(){if(c[0]&1)throw c[1];return c[1]},trys:[],ops:[]},s,a,c,f;return f={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(f[Symbol.iterator]=function(){return this}),f;function u(l){return function(d){return p([l,d])}}function p(l){if(s)throw new TypeError("Generator is already executing.");for(;i;)try{if(s=1,a&&(c=l[0]&2?a.return:l[0]?a.throw||((c=a.return)&&c.call(a),0):a.next)&&!(c=c.call(a,l[1])).done)return c;switch(a=0,c&&(l=[l[0]&2,c.value]),l[0]){case 0:case 1:c=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,a=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(c=i.trys,!(c=c.length>0&&c[c.length-1])&&(l[0]===6||l[0]===2)){i=0;continue}if(l[0]===3&&(!c||l[1]>c[0]&&l[1]=n.length&&(n=void 0),{value:n&&n[s++],done:!n}}};throw new TypeError(o?"Object is not iterable.":"Symbol.iterator is not defined.")},_r=function(n,o){var i=typeof Symbol=="function"&&n[Symbol.iterator];if(!i)return n;var s=i.call(n),a,c=[],f;try{for(;(o===void 0||o-- >0)&&!(a=s.next()).done;)c.push(a.value)}catch(u){f={error:u}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(f)throw f.error}}return c},Sn=function(){for(var n=[],o=0;o1||u(b,U)})})}function u(b,U){try{p(s[b](U))}catch(G){h(c[0][3],G)}}function p(b){b.value instanceof rt?Promise.resolve(b.value.v).then(l,d):h(c[0][2],b)}function l(b){u("next",b)}function d(b){u("throw",b)}function h(b,U){b(U),c.shift(),c.length&&u(c[0][0],c[0][1])}},Mn=function(n){var o,i;return o={},s("next"),s("throw",function(a){throw a}),s("return"),o[Symbol.iterator]=function(){return this},o;function s(a,c){o[a]=n[a]?function(f){return(i=!i)?{value:rt(n[a](f)),done:a==="return"}:c?c(f):f}:c}},Ln=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=n[Symbol.asyncIterator],i;return o?o.call(n):(n=typeof Ht=="function"?Ht(n):n[Symbol.iterator](),i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i);function s(c){i[c]=n[c]&&function(f){return new Promise(function(u,p){f=n[c](f),a(u,p,f.done,f.value)})}}function a(c,f,u,p){Promise.resolve(p).then(function(l){c({value:l,done:u})},f)}},An=function(n,o){return Object.defineProperty?Object.defineProperty(n,"raw",{value:o}):n.raw=o,n};var r=Object.create?function(n,o){Object.defineProperty(n,"default",{enumerable:!0,value:o})}:function(n,o){n.default=o};Cn=function(n){if(n&&n.__esModule)return n;var o={};if(n!=null)for(var i in n)i!=="default"&&Object.prototype.hasOwnProperty.call(n,i)&&Pt(o,n,i);return r(o,n),o},Rn=function(n){return n&&n.__esModule?n:{default:n}},kn=function(n,o,i,s){if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof o=="function"?n!==o||!s:!o.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?s:i==="a"?s.call(n):s?s.value:o.get(n)},Hn=function(n,o,i,s,a){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof o=="function"?n!==o||!a:!o.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?a.call(n,i):a?a.value=i:o.set(n,i),i},e("__extends",dn),e("__assign",hn),e("__rest",bn),e("__decorate",vn),e("__param",gn),e("__metadata",yn),e("__awaiter",xn),e("__generator",wn),e("__exportStar",En),e("__createBinding",Pt),e("__values",Ht),e("__read",_r),e("__spread",Sn),e("__spreadArrays",On),e("__spreadArray",_n),e("__await",rt),e("__asyncGenerator",Tn),e("__asyncDelegator",Mn),e("__asyncValues",Ln),e("__makeTemplateObject",An),e("__importStar",Cn),e("__importDefault",Rn),e("__classPrivateFieldGet",kn),e("__classPrivateFieldSet",Hn)})});var Br=yt((At,Yr)=>{/*! - * clipboard.js v2.0.11 - * https://clipboardjs.com/ - * - * Licensed MIT © Zeno Rocha - */(function(t,r){typeof At=="object"&&typeof Yr=="object"?Yr.exports=r():typeof define=="function"&&define.amd?define([],r):typeof At=="object"?At.ClipboardJS=r():t.ClipboardJS=r()})(At,function(){return function(){var e={686:function(n,o,i){"use strict";i.d(o,{default:function(){return ia}});var s=i(279),a=i.n(s),c=i(370),f=i.n(c),u=i(817),p=i.n(u);function l(j){try{return document.execCommand(j)}catch(T){return!1}}var d=function(T){var O=p()(T);return l("cut"),O},h=d;function b(j){var T=document.documentElement.getAttribute("dir")==="rtl",O=document.createElement("textarea");O.style.fontSize="12pt",O.style.border="0",O.style.padding="0",O.style.margin="0",O.style.position="absolute",O.style[T?"right":"left"]="-9999px";var k=window.pageYOffset||document.documentElement.scrollTop;return O.style.top="".concat(k,"px"),O.setAttribute("readonly",""),O.value=j,O}var U=function(T,O){var k=b(T);O.container.appendChild(k);var $=p()(k);return l("copy"),k.remove(),$},G=function(T){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},k="";return typeof T=="string"?k=U(T,O):T instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(T==null?void 0:T.type)?k=U(T.value,O):(k=p()(T),l("copy")),k},W=G;function _(j){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?_=function(O){return typeof O}:_=function(O){return O&&typeof Symbol=="function"&&O.constructor===Symbol&&O!==Symbol.prototype?"symbol":typeof O},_(j)}var We=function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},O=T.action,k=O===void 0?"copy":O,$=T.container,q=T.target,Te=T.text;if(k!=="copy"&&k!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(q!==void 0)if(q&&_(q)==="object"&&q.nodeType===1){if(k==="copy"&&q.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(k==="cut"&&(q.hasAttribute("readonly")||q.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}else throw new Error('Invalid "target" value, use a valid Element');if(Te)return W(Te,{container:$});if(q)return k==="cut"?h(q):W(q,{container:$})},Fe=We;function Pe(j){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Pe=function(O){return typeof O}:Pe=function(O){return O&&typeof Symbol=="function"&&O.constructor===Symbol&&O!==Symbol.prototype?"symbol":typeof O},Pe(j)}function Ji(j,T){if(!(j instanceof T))throw new TypeError("Cannot call a class as a function")}function sn(j,T){for(var O=0;O0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof $.action=="function"?$.action:this.defaultAction,this.target=typeof $.target=="function"?$.target:this.defaultTarget,this.text=typeof $.text=="function"?$.text:this.defaultText,this.container=Pe($.container)==="object"?$.container:document.body}},{key:"listenClick",value:function($){var q=this;this.listener=f()($,"click",function(Te){return q.onClick(Te)})}},{key:"onClick",value:function($){var q=$.delegateTarget||$.currentTarget,Te=this.action(q)||"copy",Rt=Fe({action:Te,container:this.container,target:this.target(q),text:this.text(q)});this.emit(Rt?"success":"error",{action:Te,text:Rt,trigger:q,clearSelection:function(){q&&q.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function($){return xr("action",$)}},{key:"defaultTarget",value:function($){var q=xr("target",$);if(q)return document.querySelector(q)}},{key:"defaultText",value:function($){return xr("text",$)}},{key:"destroy",value:function(){this.listener.destroy()}}],[{key:"copy",value:function($){var q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body};return W($,q)}},{key:"cut",value:function($){return h($)}},{key:"isSupported",value:function(){var $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],q=typeof $=="string"?[$]:$,Te=!!document.queryCommandSupported;return q.forEach(function(Rt){Te=Te&&!!document.queryCommandSupported(Rt)}),Te}}]),O}(a()),ia=oa},828:function(n){var o=9;if(typeof Element!="undefined"&&!Element.prototype.matches){var i=Element.prototype;i.matches=i.matchesSelector||i.mozMatchesSelector||i.msMatchesSelector||i.oMatchesSelector||i.webkitMatchesSelector}function s(a,c){for(;a&&a.nodeType!==o;){if(typeof a.matches=="function"&&a.matches(c))return a;a=a.parentNode}}n.exports=s},438:function(n,o,i){var s=i(828);function a(u,p,l,d,h){var b=f.apply(this,arguments);return u.addEventListener(l,b,h),{destroy:function(){u.removeEventListener(l,b,h)}}}function c(u,p,l,d,h){return typeof u.addEventListener=="function"?a.apply(null,arguments):typeof l=="function"?a.bind(null,document).apply(null,arguments):(typeof u=="string"&&(u=document.querySelectorAll(u)),Array.prototype.map.call(u,function(b){return a(b,p,l,d,h)}))}function f(u,p,l,d){return function(h){h.delegateTarget=s(h.target,p),h.delegateTarget&&d.call(u,h)}}n.exports=c},879:function(n,o){o.node=function(i){return i!==void 0&&i instanceof HTMLElement&&i.nodeType===1},o.nodeList=function(i){var s=Object.prototype.toString.call(i);return i!==void 0&&(s==="[object NodeList]"||s==="[object HTMLCollection]")&&"length"in i&&(i.length===0||o.node(i[0]))},o.string=function(i){return typeof i=="string"||i instanceof String},o.fn=function(i){var s=Object.prototype.toString.call(i);return s==="[object Function]"}},370:function(n,o,i){var s=i(879),a=i(438);function c(l,d,h){if(!l&&!d&&!h)throw new Error("Missing required arguments");if(!s.string(d))throw new TypeError("Second argument must be a String");if(!s.fn(h))throw new TypeError("Third argument must be a Function");if(s.node(l))return f(l,d,h);if(s.nodeList(l))return u(l,d,h);if(s.string(l))return p(l,d,h);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function f(l,d,h){return l.addEventListener(d,h),{destroy:function(){l.removeEventListener(d,h)}}}function u(l,d,h){return Array.prototype.forEach.call(l,function(b){b.addEventListener(d,h)}),{destroy:function(){Array.prototype.forEach.call(l,function(b){b.removeEventListener(d,h)})}}}function p(l,d,h){return a(document.body,l,d,h)}n.exports=c},817:function(n){function o(i){var s;if(i.nodeName==="SELECT")i.focus(),s=i.value;else if(i.nodeName==="INPUT"||i.nodeName==="TEXTAREA"){var a=i.hasAttribute("readonly");a||i.setAttribute("readonly",""),i.select(),i.setSelectionRange(0,i.value.length),a||i.removeAttribute("readonly"),s=i.value}else{i.hasAttribute("contenteditable")&&i.focus();var c=window.getSelection(),f=document.createRange();f.selectNodeContents(i),c.removeAllRanges(),c.addRange(f),s=c.toString()}return s}n.exports=o},279:function(n){function o(){}o.prototype={on:function(i,s,a){var c=this.e||(this.e={});return(c[i]||(c[i]=[])).push({fn:s,ctx:a}),this},once:function(i,s,a){var c=this;function f(){c.off(i,f),s.apply(a,arguments)}return f._=s,this.on(i,f,a)},emit:function(i){var s=[].slice.call(arguments,1),a=((this.e||(this.e={}))[i]||[]).slice(),c=0,f=a.length;for(c;c{"use strict";/*! - * escape-html - * Copyright(c) 2012-2013 TJ Holowaychuk - * Copyright(c) 2015 Andreas Lubbe - * Copyright(c) 2015 Tiancheng "Timothy" Gu - * MIT Licensed - */var Ms=/["'&<>]/;Si.exports=Ls;function Ls(e){var t=""+e,r=Ms.exec(t);if(!r)return t;var n,o="",i=0,s=0;for(i=r.index;i0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var n=this,o=this,i=o.hasError,s=o.isStopped,a=o.observers;return i||s?Tr:(this.currentObservers=null,a.push(r),new $e(function(){n.currentObservers=null,Ue(a,r)}))},t.prototype._checkFinalizedStatuses=function(r){var n=this,o=n.hasError,i=n.thrownError,s=n.isStopped;o?r.error(i):s&&r.complete()},t.prototype.asObservable=function(){var r=new F;return r.source=this,r},t.create=function(r,n){return new Qn(r,n)},t}(F);var Qn=function(e){ne(t,e);function t(r,n){var o=e.call(this)||this;return o.destination=r,o.source=n,o}return t.prototype.next=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,r)},t.prototype.error=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,r)},t.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},t.prototype._subscribe=function(r){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&o!==void 0?o:Tr},t}(E);var wt={now:function(){return(wt.delegate||Date).now()},delegate:void 0};var Et=function(e){ne(t,e);function t(r,n,o){r===void 0&&(r=1/0),n===void 0&&(n=1/0),o===void 0&&(o=wt);var i=e.call(this)||this;return i._bufferSize=r,i._windowTime=n,i._timestampProvider=o,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,r),i._windowTime=Math.max(1,n),i}return t.prototype.next=function(r){var n=this,o=n.isStopped,i=n._buffer,s=n._infiniteTimeWindow,a=n._timestampProvider,c=n._windowTime;o||(i.push(r),!s&&i.push(a.now()+c)),this._trimBuffer(),e.prototype.next.call(this,r)},t.prototype._subscribe=function(r){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(r),o=this,i=o._infiniteTimeWindow,s=o._buffer,a=s.slice(),c=0;c0?e.prototype.requestAsyncId.call(this,r,n,o):(r.actions.push(this),r._scheduled||(r._scheduled=at.requestAnimationFrame(function(){return r.flush(void 0)})))},t.prototype.recycleAsyncId=function(r,n,o){var i;if(o===void 0&&(o=0),o!=null?o>0:this.delay>0)return e.prototype.recycleAsyncId.call(this,r,n,o);var s=r.actions;n!=null&&((i=s[s.length-1])===null||i===void 0?void 0:i.id)!==n&&(at.cancelAnimationFrame(n),r._scheduled=void 0)},t}(zt);var Gn=function(e){ne(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.flush=function(r){this._active=!0;var n=this._scheduled;this._scheduled=void 0;var o=this.actions,i;r=r||o.shift();do if(i=r.execute(r.state,r.delay))break;while((r=o[0])&&r.id===n&&o.shift());if(this._active=!1,i){for(;(r=o[0])&&r.id===n&&o.shift();)r.unsubscribe();throw i}},t}(Nt);var xe=new Gn(Bn);var R=new F(function(e){return e.complete()});function qt(e){return e&&L(e.schedule)}function Hr(e){return e[e.length-1]}function Ve(e){return L(Hr(e))?e.pop():void 0}function Ee(e){return qt(Hr(e))?e.pop():void 0}function Kt(e,t){return typeof Hr(e)=="number"?e.pop():t}var st=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function Qt(e){return L(e==null?void 0:e.then)}function Yt(e){return L(e[it])}function Bt(e){return Symbol.asyncIterator&&L(e==null?void 0:e[Symbol.asyncIterator])}function Gt(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function ya(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Jt=ya();function Xt(e){return L(e==null?void 0:e[Jt])}function Zt(e){return jn(this,arguments,function(){var r,n,o,i;return It(this,function(s){switch(s.label){case 0:r=e.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,jt(r.read())];case 3:return n=s.sent(),o=n.value,i=n.done,i?[4,jt(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,jt(o)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})})}function er(e){return L(e==null?void 0:e.getReader)}function z(e){if(e instanceof F)return e;if(e!=null){if(Yt(e))return xa(e);if(st(e))return wa(e);if(Qt(e))return Ea(e);if(Bt(e))return Jn(e);if(Xt(e))return Sa(e);if(er(e))return Oa(e)}throw Gt(e)}function xa(e){return new F(function(t){var r=e[it]();if(L(r.subscribe))return r.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function wa(e){return new F(function(t){for(var r=0;r=2,!0))}function ie(e){e===void 0&&(e={});var t=e.connector,r=t===void 0?function(){return new E}:t,n=e.resetOnError,o=n===void 0?!0:n,i=e.resetOnComplete,s=i===void 0?!0:i,a=e.resetOnRefCountZero,c=a===void 0?!0:a;return function(f){var u,p,l,d=0,h=!1,b=!1,U=function(){p==null||p.unsubscribe(),p=void 0},G=function(){U(),u=l=void 0,h=b=!1},W=function(){var _=u;G(),_==null||_.unsubscribe()};return g(function(_,We){d++,!b&&!h&&U();var Fe=l=l!=null?l:r();We.add(function(){d--,d===0&&!b&&!h&&(p=Dr(W,c))}),Fe.subscribe(We),!u&&d>0&&(u=new Ge({next:function(Pe){return Fe.next(Pe)},error:function(Pe){b=!0,U(),p=Dr(G,o,Pe),Fe.error(Pe)},complete:function(){h=!0,U(),p=Dr(G,s),Fe.complete()}}),z(_).subscribe(u))})(f)}}function Dr(e,t){for(var r=[],n=2;ne.next(document)),e}function Q(e,t=document){return Array.from(t.querySelectorAll(e))}function K(e,t=document){let r=pe(e,t);if(typeof r=="undefined")throw new ReferenceError(`Missing element: expected "${e}" to be present`);return r}function pe(e,t=document){return t.querySelector(e)||void 0}function Ie(){return document.activeElement instanceof HTMLElement&&document.activeElement||void 0}function nr(e){return A(v(document.body,"focusin"),v(document.body,"focusout")).pipe(Re(1),m(()=>{let t=Ie();return typeof t!="undefined"?e.contains(t):!1}),N(e===Ie()),B())}function qe(e){return{x:e.offsetLeft,y:e.offsetTop}}function yo(e){return A(v(window,"load"),v(window,"resize")).pipe(Ae(0,xe),m(()=>qe(e)),N(qe(e)))}function or(e){return{x:e.scrollLeft,y:e.scrollTop}}function pt(e){return A(v(e,"scroll"),v(window,"resize")).pipe(Ae(0,xe),m(()=>or(e)),N(or(e)))}var wo=function(){if(typeof Map!="undefined")return Map;function e(t,r){var n=-1;return t.some(function(o,i){return o[0]===r?(n=i,!0):!1}),n}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(r){var n=e(this.__entries__,r),o=this.__entries__[n];return o&&o[1]},t.prototype.set=function(r,n){var o=e(this.__entries__,r);~o?this.__entries__[o][1]=n:this.__entries__.push([r,n])},t.prototype.delete=function(r){var n=this.__entries__,o=e(n,r);~o&&n.splice(o,1)},t.prototype.has=function(r){return!!~e(this.__entries__,r)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(r,n){n===void 0&&(n=null);for(var o=0,i=this.__entries__;o0},e.prototype.connect_=function(){!qr||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),Ka?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){!qr||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(t){var r=t.propertyName,n=r===void 0?"":r,o=qa.some(function(i){return!!~n.indexOf(i)});o&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),Eo=function(e,t){for(var r=0,n=Object.keys(t);r0},e}(),Oo=typeof WeakMap!="undefined"?new WeakMap:new wo,_o=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var r=Qa.getInstance(),n=new ns(t,r,this);Oo.set(this,n)}return e}();["observe","unobserve","disconnect"].forEach(function(e){_o.prototype[e]=function(){var t;return(t=Oo.get(this))[e].apply(t,arguments)}});var os=function(){return typeof ir.ResizeObserver!="undefined"?ir.ResizeObserver:_o}(),To=os;var Mo=new E,is=P(()=>I(new To(e=>{for(let t of e)Mo.next(t)}))).pipe(S(e=>A(Se,I(e)).pipe(C(()=>e.disconnect()))),X(1));function he(e){return{width:e.offsetWidth,height:e.offsetHeight}}function ve(e){return is.pipe(w(t=>t.observe(e)),S(t=>Mo.pipe(x(({target:r})=>r===e),C(()=>t.unobserve(e)),m(()=>he(e)))),N(he(e)))}function mt(e){return{width:e.scrollWidth,height:e.scrollHeight}}function cr(e){let t=e.parentElement;for(;t&&(e.scrollWidth<=t.scrollWidth&&e.scrollHeight<=t.scrollHeight);)t=(e=t).parentElement;return t?e:void 0}var Lo=new E,as=P(()=>I(new IntersectionObserver(e=>{for(let t of e)Lo.next(t)},{threshold:0}))).pipe(S(e=>A(Se,I(e)).pipe(C(()=>e.disconnect()))),X(1));function fr(e){return as.pipe(w(t=>t.observe(e)),S(t=>Lo.pipe(x(({target:r})=>r===e),C(()=>t.unobserve(e)),m(({isIntersecting:r})=>r))))}function Ao(e,t=16){return pt(e).pipe(m(({y:r})=>{let n=he(e),o=mt(e);return r>=o.height-n.height-t}),B())}var ur={drawer:K("[data-md-toggle=drawer]"),search:K("[data-md-toggle=search]")};function Co(e){return ur[e].checked}function Ke(e,t){ur[e].checked!==t&&ur[e].click()}function dt(e){let t=ur[e];return v(t,"change").pipe(m(()=>t.checked),N(t.checked))}function ss(e,t){switch(e.constructor){case HTMLInputElement:return e.type==="radio"?/^Arrow/.test(t):!0;case HTMLSelectElement:case HTMLTextAreaElement:return!0;default:return e.isContentEditable}}function Ro(){return v(window,"keydown").pipe(x(e=>!(e.metaKey||e.ctrlKey)),m(e=>({mode:Co("search")?"search":"global",type:e.key,claim(){e.preventDefault(),e.stopPropagation()}})),x(({mode:e,type:t})=>{if(e==="global"){let r=Ie();if(typeof r!="undefined")return!ss(r,t)}return!0}),ie())}function Oe(){return new URL(location.href)}function pr(e){location.href=e.href}function ko(){return new E}function Ho(e,t){if(typeof t=="string"||typeof t=="number")e.innerHTML+=t.toString();else if(t instanceof Node)e.appendChild(t);else if(Array.isArray(t))for(let r of t)Ho(e,r)}function M(e,t,...r){let n=document.createElement(e);if(t)for(let o of Object.keys(t))typeof t[o]!="undefined"&&(typeof t[o]!="boolean"?n.setAttribute(o,t[o]):n.setAttribute(o,""));for(let o of r)Ho(n,o);return n}function Po(e,t){let r=t;if(e.length>r){for(;e[r]!==" "&&--r>0;);return`${e.substring(0,r)}...`}return e}function lr(e){if(e>999){let t=+((e-950)%1e3>99);return`${((e+1e-6)/1e3).toFixed(t)}k`}else return e.toString()}function $o(){return location.hash.substring(1)}function Io(e){let t=M("a",{href:e});t.addEventListener("click",r=>r.stopPropagation()),t.click()}function cs(){return v(window,"hashchange").pipe(m($o),N($o()),x(e=>e.length>0),X(1))}function jo(){return cs().pipe(m(e=>pe(`[id="${e}"]`)),x(e=>typeof e!="undefined"))}function Kr(e){let t=matchMedia(e);return rr(r=>t.addListener(()=>r(t.matches))).pipe(N(t.matches))}function Fo(){let e=matchMedia("print");return A(v(window,"beforeprint").pipe(m(()=>!0)),v(window,"afterprint").pipe(m(()=>!1))).pipe(N(e.matches))}function Qr(e,t){return e.pipe(S(r=>r?t():R))}function mr(e,t={credentials:"same-origin"}){return ue(fetch(`${e}`,t)).pipe(ce(()=>R),S(r=>r.status!==200?Ot(()=>new Error(r.statusText)):I(r)))}function je(e,t){return mr(e,t).pipe(S(r=>r.json()),X(1))}function Uo(e,t){let r=new DOMParser;return mr(e,t).pipe(S(n=>n.text()),m(n=>r.parseFromString(n,"text/xml")),X(1))}function Do(e){let t=M("script",{src:e});return P(()=>(document.head.appendChild(t),A(v(t,"load"),v(t,"error").pipe(S(()=>Ot(()=>new ReferenceError(`Invalid script: ${e}`))))).pipe(m(()=>{}),C(()=>document.head.removeChild(t)),oe(1))))}function Wo(){return{x:Math.max(0,scrollX),y:Math.max(0,scrollY)}}function Vo(){return A(v(window,"scroll",{passive:!0}),v(window,"resize",{passive:!0})).pipe(m(Wo),N(Wo()))}function zo(){return{width:innerWidth,height:innerHeight}}function No(){return v(window,"resize",{passive:!0}).pipe(m(zo),N(zo()))}function qo(){return Y([Vo(),No()]).pipe(m(([e,t])=>({offset:e,size:t})),X(1))}function dr(e,{viewport$:t,header$:r}){let n=t.pipe(J("size")),o=Y([n,r]).pipe(m(()=>qe(e)));return Y([r,t,o]).pipe(m(([{height:i},{offset:s,size:a},{x:c,y:f}])=>({offset:{x:s.x-c,y:s.y-f+i},size:a})))}function Ko(e,{tx$:t}){let r=v(e,"message").pipe(m(({data:n})=>n));return t.pipe(Lt(()=>r,{leading:!0,trailing:!0}),w(n=>e.postMessage(n)),S(()=>r),ie())}var fs=K("#__config"),ht=JSON.parse(fs.textContent);ht.base=`${new URL(ht.base,Oe())}`;function le(){return ht}function Z(e){return ht.features.includes(e)}function re(e,t){return typeof t!="undefined"?ht.translations[e].replace("#",t.toString()):ht.translations[e]}function _e(e,t=document){return K(`[data-md-component=${e}]`,t)}function te(e,t=document){return Q(`[data-md-component=${e}]`,t)}function us(e){let t=K(".md-typeset > :first-child",e);return v(t,"click",{once:!0}).pipe(m(()=>K(".md-typeset",e)),m(r=>({hash:__md_hash(r.innerHTML)})))}function Qo(e){return!Z("announce.dismiss")||!e.childElementCount?R:P(()=>{let t=new E;return t.pipe(N({hash:__md_get("__announce")})).subscribe(({hash:r})=>{var n;r&&r===((n=__md_get("__announce"))!=null?n:r)&&(e.hidden=!0,__md_set("__announce",r))}),us(e).pipe(w(r=>t.next(r)),C(()=>t.complete()),m(r=>H({ref:e},r)))})}function ps(e,{target$:t}){return t.pipe(m(r=>({hidden:r!==e})))}function Yo(e,t){let r=new E;return r.subscribe(({hidden:n})=>{e.hidden=n}),ps(e,t).pipe(w(n=>r.next(n)),C(()=>r.complete()),m(n=>H({ref:e},n)))}var ii=Ye(Br());function Gr(e){return M("div",{class:"md-tooltip",id:e},M("div",{class:"md-tooltip__inner md-typeset"}))}function Bo(e,t){if(t=t?`${t}_annotation_${e}`:void 0,t){let r=t?`#${t}`:void 0;return M("aside",{class:"md-annotation",tabIndex:0},Gr(t),M("a",{href:r,class:"md-annotation__index",tabIndex:-1},M("span",{"data-md-annotation-id":e})))}else return M("aside",{class:"md-annotation",tabIndex:0},Gr(t),M("span",{class:"md-annotation__index",tabIndex:-1},M("span",{"data-md-annotation-id":e})))}function Go(e){return M("button",{class:"md-clipboard md-icon",title:re("clipboard.copy"),"data-clipboard-target":`#${e} > code`})}function Jr(e,t){let r=t&2,n=t&1,o=Object.keys(e.terms).filter(a=>!e.terms[a]).reduce((a,c)=>[...a,M("del",null,c)," "],[]).slice(0,-1),i=new URL(e.location);Z("search.highlight")&&i.searchParams.set("h",Object.entries(e.terms).filter(([,a])=>a).reduce((a,[c])=>`${a} ${c}`.trim(),""));let{tags:s}=le();return M("a",{href:`${i}`,class:"md-search-result__link",tabIndex:-1},M("article",{class:["md-search-result__article",...r?["md-search-result__article--document"]:[]].join(" "),"data-md-score":e.score.toFixed(2)},r>0&&M("div",{class:"md-search-result__icon md-icon"}),M("h1",{class:"md-search-result__title"},e.title),n>0&&e.text.length>0&&M("p",{class:"md-search-result__teaser"},Po(e.text,320)),e.tags&&M("div",{class:"md-typeset"},e.tags.map(a=>{let c=a.replace(/<[^>]+>/g,""),f=s?c in s?`md-tag-icon md-tag-icon--${s[c]}`:"md-tag-icon":"";return M("span",{class:`md-tag ${f}`},a)})),n>0&&o.length>0&&M("p",{class:"md-search-result__terms"},re("search.result.term.missing"),": ",...o)))}function Jo(e){let t=e[0].score,r=[...e],n=r.findIndex(f=>!f.location.includes("#")),[o]=r.splice(n,1),i=r.findIndex(f=>f.scoreJr(f,1)),...a.length?[M("details",{class:"md-search-result__more"},M("summary",{tabIndex:-1},a.length>0&&a.length===1?re("search.result.more.one"):re("search.result.more.other",a.length)),...a.map(f=>Jr(f,1)))]:[]];return M("li",{class:"md-search-result__item"},c)}function Xo(e){return M("ul",{class:"md-source__facts"},Object.entries(e).map(([t,r])=>M("li",{class:`md-source__fact md-source__fact--${t}`},typeof r=="number"?lr(r):r)))}function Xr(e){let t=`tabbed-control tabbed-control--${e}`;return M("div",{class:t,hidden:!0},M("button",{class:"tabbed-button",tabIndex:-1}))}function Zo(e){return M("div",{class:"md-typeset__scrollwrap"},M("div",{class:"md-typeset__table"},e))}function ls(e){let t=le(),r=new URL(`../${e.version}/`,t.base);return M("li",{class:"md-version__item"},M("a",{href:`${r}`,class:"md-version__link"},e.title))}function ei(e,t){return M("div",{class:"md-version"},M("button",{class:"md-version__current","aria-label":re("select.version.title")},t.title),M("ul",{class:"md-version__list"},e.map(ls)))}function ms(e,t){let r=P(()=>Y([yo(e),pt(t)])).pipe(m(([{x:n,y:o},i])=>{let{width:s,height:a}=he(e);return{x:n-i.x+s/2,y:o-i.y+a/2}}));return nr(e).pipe(S(n=>r.pipe(m(o=>({active:n,offset:o})),oe(+!n||1/0))))}function ti(e,t,{target$:r}){let[n,o]=Array.from(e.children);return P(()=>{let i=new E,s=i.pipe(de(1));return i.subscribe({next({offset:a}){e.style.setProperty("--md-tooltip-x",`${a.x}px`),e.style.setProperty("--md-tooltip-y",`${a.y}px`)},complete(){e.style.removeProperty("--md-tooltip-x"),e.style.removeProperty("--md-tooltip-y")}}),fr(e).pipe(ee(s)).subscribe(a=>{e.toggleAttribute("data-md-visible",a)}),A(i.pipe(x(({active:a})=>a)),i.pipe(Re(250),x(({active:a})=>!a))).subscribe({next({active:a}){a?e.prepend(n):n.remove()},complete(){e.prepend(n)}}),i.pipe(Ae(16,xe)).subscribe(({active:a})=>{n.classList.toggle("md-tooltip--active",a)}),i.pipe(zr(125,xe),x(()=>!!e.offsetParent),m(()=>e.offsetParent.getBoundingClientRect()),m(({x:a})=>a)).subscribe({next(a){a?e.style.setProperty("--md-tooltip-0",`${-a}px`):e.style.removeProperty("--md-tooltip-0")},complete(){e.style.removeProperty("--md-tooltip-0")}}),v(o,"click").pipe(ee(s),x(a=>!(a.metaKey||a.ctrlKey))).subscribe(a=>a.preventDefault()),v(o,"mousedown").pipe(ee(s),ae(i)).subscribe(([a,{active:c}])=>{var f;if(a.button!==0||a.metaKey||a.ctrlKey)a.preventDefault();else if(c){a.preventDefault();let u=e.parentElement.closest(".md-annotation");u instanceof HTMLElement?u.focus():(f=Ie())==null||f.blur()}}),r.pipe(ee(s),x(a=>a===n),ke(125)).subscribe(()=>e.focus()),ms(e,t).pipe(w(a=>i.next(a)),C(()=>i.complete()),m(a=>H({ref:e},a)))})}function ds(e){let t=[];for(let r of Q(".c, .c1, .cm",e)){let n=[],o=document.createNodeIterator(r,NodeFilter.SHOW_TEXT);for(let i=o.nextNode();i;i=o.nextNode())n.push(i);for(let i of n){let s;for(;s=/(\(\d+\))(!)?/.exec(i.textContent);){let[,a,c]=s;if(typeof c=="undefined"){let f=i.splitText(s.index);i=f.splitText(a.length),t.push(f)}else{i.textContent=a,t.push(i);break}}}}return t}function ri(e,t){t.append(...Array.from(e.childNodes))}function ni(e,t,{target$:r,print$:n}){let o=t.closest("[id]"),i=o==null?void 0:o.id,s=new Map;for(let a of ds(t)){let[,c]=a.textContent.match(/\((\d+)\)/);pe(`li:nth-child(${c})`,e)&&(s.set(c,Bo(c,i)),a.replaceWith(s.get(c)))}return s.size===0?R:P(()=>{let a=new E,c=[];for(let[f,u]of s)c.push([K(".md-typeset",u),K(`li:nth-child(${f})`,e)]);return n.pipe(ee(a.pipe(de(1)))).subscribe(f=>{e.hidden=!f;for(let[u,p]of c)f?ri(u,p):ri(p,u)}),A(...[...s].map(([,f])=>ti(f,t,{target$:r}))).pipe(C(()=>a.complete()),ie())})}var hs=0;function ai(e){if(e.nextElementSibling){let t=e.nextElementSibling;if(t.tagName==="OL")return t;if(t.tagName==="P"&&!t.children.length)return ai(t)}}function oi(e){return ve(e).pipe(m(({width:t})=>({scrollable:mt(e).width>t})),J("scrollable"))}function si(e,t){let{matches:r}=matchMedia("(hover)"),n=P(()=>{let o=new E;if(o.subscribe(({scrollable:s})=>{s&&r?e.setAttribute("tabindex","0"):e.removeAttribute("tabindex")}),ii.default.isSupported()){let s=e.closest("pre");s.id=`__code_${++hs}`,s.insertBefore(Go(s.id),e)}let i=e.closest(".highlight");if(i instanceof HTMLElement){let s=ai(i);if(typeof s!="undefined"&&(i.classList.contains("annotate")||Z("content.code.annotate"))){let a=ni(s,e,t);return oi(e).pipe(w(c=>o.next(c)),C(()=>o.complete()),m(c=>H({ref:e},c)),et(ve(i).pipe(m(({width:c,height:f})=>c&&f),B(),S(c=>c?a:R))))}}return oi(e).pipe(w(s=>o.next(s)),C(()=>o.complete()),m(s=>H({ref:e},s)))});return Z("content.lazy")?fr(e).pipe(x(o=>o),oe(1),S(()=>n)):n}var ci=".node circle,.node ellipse,.node path,.node polygon,.node rect{fill:var(--md-mermaid-node-bg-color);stroke:var(--md-mermaid-node-fg-color)}marker{fill:var(--md-mermaid-edge-color)!important}.edgeLabel .label rect{fill:#0000}.label{color:var(--md-mermaid-label-fg-color);font-family:var(--md-mermaid-font-family)}.label foreignObject{line-height:normal;overflow:visible}.label div .edgeLabel{color:var(--md-mermaid-label-fg-color)}.edgeLabel,.edgeLabel rect,.label div .edgeLabel{background-color:var(--md-mermaid-label-bg-color)}.edgeLabel,.edgeLabel rect{fill:var(--md-mermaid-label-bg-color);color:var(--md-mermaid-edge-color)}.edgePath .path,.flowchart-link{stroke:var(--md-mermaid-edge-color)}.edgePath .arrowheadPath{fill:var(--md-mermaid-edge-color);stroke:none}.cluster rect{fill:var(--md-default-fg-color--lightest);stroke:var(--md-default-fg-color--lighter)}.cluster span{color:var(--md-mermaid-label-fg-color);font-family:var(--md-mermaid-font-family)}defs #flowchart-circleEnd,defs #flowchart-circleStart,defs #flowchart-crossEnd,defs #flowchart-crossStart,defs #flowchart-pointEnd,defs #flowchart-pointStart{stroke:none}g.classGroup line,g.classGroup rect{fill:var(--md-mermaid-node-bg-color);stroke:var(--md-mermaid-node-fg-color)}g.classGroup text{fill:var(--md-mermaid-label-fg-color);font-family:var(--md-mermaid-font-family)}.classLabel .box{fill:var(--md-mermaid-label-bg-color);background-color:var(--md-mermaid-label-bg-color);opacity:1}.classLabel .label{fill:var(--md-mermaid-label-fg-color);font-family:var(--md-mermaid-font-family)}.node .divider{stroke:var(--md-mermaid-node-fg-color)}.relation{stroke:var(--md-mermaid-edge-color)}.cardinality{fill:var(--md-mermaid-label-fg-color);font-family:var(--md-mermaid-font-family)}.cardinality text{fill:inherit!important}defs #classDiagram-compositionEnd,defs #classDiagram-compositionStart,defs #classDiagram-dependencyEnd,defs #classDiagram-dependencyStart,defs #classDiagram-extensionEnd,defs #classDiagram-extensionStart{fill:var(--md-mermaid-edge-color)!important;stroke:var(--md-mermaid-edge-color)!important}defs #classDiagram-aggregationEnd,defs #classDiagram-aggregationStart{fill:var(--md-mermaid-label-bg-color)!important;stroke:var(--md-mermaid-edge-color)!important}g.stateGroup rect{fill:var(--md-mermaid-node-bg-color);stroke:var(--md-mermaid-node-fg-color)}g.stateGroup .state-title{fill:var(--md-mermaid-label-fg-color)!important;font-family:var(--md-mermaid-font-family)}g.stateGroup .composit{fill:var(--md-mermaid-label-bg-color)}.nodeLabel{color:var(--md-mermaid-label-fg-color);font-family:var(--md-mermaid-font-family)}.node circle.state-end,.node circle.state-start,.start-state{fill:var(--md-mermaid-edge-color);stroke:none}.end-state-inner,.end-state-outer{fill:var(--md-mermaid-edge-color)}.end-state-inner,.node circle.state-end{stroke:var(--md-mermaid-label-bg-color)}.transition{stroke:var(--md-mermaid-edge-color)}[id^=state-fork] rect,[id^=state-join] rect{fill:var(--md-mermaid-edge-color)!important;stroke:none!important}.statediagram-cluster.statediagram-cluster .inner{fill:var(--md-default-bg-color)}.statediagram-cluster rect{fill:var(--md-mermaid-node-bg-color);stroke:var(--md-mermaid-node-fg-color)}.statediagram-state rect.divider{fill:var(--md-default-fg-color--lightest);stroke:var(--md-default-fg-color--lighter)}defs #statediagram-barbEnd{stroke:var(--md-mermaid-edge-color)}.entityBox{fill:var(--md-mermaid-label-bg-color);stroke:var(--md-mermaid-node-fg-color)}.entityLabel{fill:var(--md-mermaid-label-fg-color);font-family:var(--md-mermaid-font-family)}.relationshipLabelBox{fill:var(--md-mermaid-label-bg-color);fill-opacity:1;background-color:var(--md-mermaid-label-bg-color);opacity:1}.relationshipLabel{fill:var(--md-mermaid-label-fg-color)}.relationshipLine{stroke:var(--md-mermaid-edge-color)}defs #ONE_OR_MORE_END *,defs #ONE_OR_MORE_START *,defs #ONLY_ONE_END *,defs #ONLY_ONE_START *,defs #ZERO_OR_MORE_END *,defs #ZERO_OR_MORE_START *,defs #ZERO_OR_ONE_END *,defs #ZERO_OR_ONE_START *{stroke:var(--md-mermaid-edge-color)!important}.actor,defs #ZERO_OR_MORE_END circle,defs #ZERO_OR_MORE_START circle{fill:var(--md-mermaid-label-bg-color)}.actor{stroke:var(--md-mermaid-node-fg-color)}text.actor>tspan{fill:var(--md-mermaid-label-fg-color);font-family:var(--md-mermaid-font-family)}line{stroke:var(--md-default-fg-color--lighter)}.messageLine0,.messageLine1{stroke:var(--md-mermaid-edge-color)}.loopText>tspan,.messageText,.noteText>tspan{fill:var(--md-mermaid-edge-color);stroke:none;font-family:var(--md-mermaid-font-family)!important}.noteText>tspan{fill:#000}#arrowhead path{fill:var(--md-mermaid-edge-color);stroke:none}.loopLine{stroke:var(--md-mermaid-node-fg-color)}.labelBox,.loopLine{fill:var(--md-mermaid-node-bg-color)}.labelBox{stroke:none}.labelText,.labelText>span{fill:var(--md-mermaid-node-fg-color);font-family:var(--md-mermaid-font-family)}";var Zr,vs=0;function gs(){return typeof mermaid=="undefined"||mermaid instanceof Element?Do("https://unpkg.com/mermaid@9.1.7/dist/mermaid.min.js"):I(void 0)}function fi(e){return e.classList.remove("mermaid"),Zr||(Zr=gs().pipe(w(()=>mermaid.initialize({startOnLoad:!1,themeCSS:ci,sequence:{actorFontSize:"16px",messageFontSize:"16px",noteFontSize:"16px"}})),m(()=>{}),X(1))),Zr.subscribe(()=>{e.classList.add("mermaid");let t=`__mermaid_${vs++}`,r=M("div",{class:"mermaid"});mermaid.mermaidAPI.render(t,e.textContent,n=>{let o=r.attachShadow({mode:"closed"});o.innerHTML=n,e.replaceWith(r)})}),Zr.pipe(m(()=>({ref:e})))}function ys(e,{target$:t,print$:r}){let n=!0;return A(t.pipe(m(o=>o.closest("details:not([open])")),x(o=>e===o),m(()=>({action:"open",reveal:!0}))),r.pipe(x(o=>o||!n),w(()=>n=e.open),m(o=>({action:o?"open":"close"}))))}function ui(e,t){return P(()=>{let r=new E;return r.subscribe(({action:n,reveal:o})=>{e.toggleAttribute("open",n==="open"),o&&e.scrollIntoView()}),ys(e,t).pipe(w(n=>r.next(n)),C(()=>r.complete()),m(n=>H({ref:e},n)))})}var pi=M("table");function li(e){return e.replaceWith(pi),pi.replaceWith(Zo(e)),I({ref:e})}function xs(e){let t=Q(":scope > input",e),r=t.find(n=>n.checked)||t[0];return A(...t.map(n=>v(n,"change").pipe(m(()=>K(`label[for="${n.id}"]`))))).pipe(N(K(`label[for="${r.id}"]`)),m(n=>({active:n})))}function mi(e,{viewport$:t}){let r=Xr("prev");e.append(r);let n=Xr("next");e.append(n);let o=K(".tabbed-labels",e);return P(()=>{let i=new E,s=i.pipe(de(1));return Y([i,ve(e)]).pipe(Ae(1,xe),ee(s)).subscribe({next([{active:a},c]){let f=qe(a),{width:u}=he(a);e.style.setProperty("--md-indicator-x",`${f.x}px`),e.style.setProperty("--md-indicator-width",`${u}px`);let p=or(o);(f.xp.x+c.width)&&o.scrollTo({left:Math.max(0,f.x-16),behavior:"smooth"})},complete(){e.style.removeProperty("--md-indicator-x"),e.style.removeProperty("--md-indicator-width")}}),Y([pt(o),ve(o)]).pipe(ee(s)).subscribe(([a,c])=>{let f=mt(o);r.hidden=a.x<16,n.hidden=a.x>f.width-c.width-16}),A(v(r,"click").pipe(m(()=>-1)),v(n,"click").pipe(m(()=>1))).pipe(ee(s)).subscribe(a=>{let{width:c}=he(o);o.scrollBy({left:c*a,behavior:"smooth"})}),Z("content.tabs.link")&&i.pipe(He(1),ae(t)).subscribe(([{active:a},{offset:c}])=>{let f=a.innerText.trim();if(a.hasAttribute("data-md-switching"))a.removeAttribute("data-md-switching");else{let u=e.offsetTop-c.y;for(let l of Q("[data-tabs]"))for(let d of Q(":scope > input",l)){let h=K(`label[for="${d.id}"]`);if(h!==a&&h.innerText.trim()===f){h.setAttribute("data-md-switching",""),d.click();break}}window.scrollTo({top:e.offsetTop-u});let p=__md_get("__tabs")||[];__md_set("__tabs",[...new Set([f,...p])])}}),xs(e).pipe(w(a=>i.next(a)),C(()=>i.complete()),m(a=>H({ref:e},a)))}).pipe(Je(fe))}function di(e,{viewport$:t,target$:r,print$:n}){return A(...Q("pre:not(.mermaid) > code",e).map(o=>si(o,{target$:r,print$:n})),...Q("pre.mermaid",e).map(o=>fi(o)),...Q("table:not([class])",e).map(o=>li(o)),...Q("details",e).map(o=>ui(o,{target$:r,print$:n})),...Q("[data-tabs]",e).map(o=>mi(o,{viewport$:t})))}function ws(e,{alert$:t}){return t.pipe(S(r=>A(I(!0),I(!1).pipe(ke(2e3))).pipe(m(n=>({message:r,active:n})))))}function hi(e,t){let r=K(".md-typeset",e);return P(()=>{let n=new E;return n.subscribe(({message:o,active:i})=>{e.classList.toggle("md-dialog--active",i),r.textContent=o}),ws(e,t).pipe(w(o=>n.next(o)),C(()=>n.complete()),m(o=>H({ref:e},o)))})}function Es({viewport$:e}){if(!Z("header.autohide"))return I(!1);let t=e.pipe(m(({offset:{y:o}})=>o),Ce(2,1),m(([o,i])=>[oMath.abs(i-o.y)>100),m(([,[o]])=>o),B()),n=dt("search");return Y([e,n]).pipe(m(([{offset:o},i])=>o.y>400&&!i),B(),S(o=>o?r:I(!1)),N(!1))}function bi(e,t){return P(()=>Y([ve(e),Es(t)])).pipe(m(([{height:r},n])=>({height:r,hidden:n})),B((r,n)=>r.height===n.height&&r.hidden===n.hidden),X(1))}function vi(e,{header$:t,main$:r}){return P(()=>{let n=new E,o=n.pipe(de(1));return n.pipe(J("active"),Ze(t)).subscribe(([{active:i},{hidden:s}])=>{e.classList.toggle("md-header--shadow",i&&!s),e.hidden=s}),r.subscribe(n),t.pipe(ee(o),m(i=>H({ref:e},i)))})}function Ss(e,{viewport$:t,header$:r}){return dr(e,{viewport$:t,header$:r}).pipe(m(({offset:{y:n}})=>{let{height:o}=he(e);return{active:n>=o}}),J("active"))}function gi(e,t){return P(()=>{let r=new E;r.subscribe(({active:o})=>{e.classList.toggle("md-header__title--active",o)});let n=pe("article h1");return typeof n=="undefined"?R:Ss(n,t).pipe(w(o=>r.next(o)),C(()=>r.complete()),m(o=>H({ref:e},o)))})}function yi(e,{viewport$:t,header$:r}){let n=r.pipe(m(({height:i})=>i),B()),o=n.pipe(S(()=>ve(e).pipe(m(({height:i})=>({top:e.offsetTop,bottom:e.offsetTop+i})),J("bottom"))));return Y([n,o,t]).pipe(m(([i,{top:s,bottom:a},{offset:{y:c},size:{height:f}}])=>(f=Math.max(0,f-Math.max(0,s-c,i)-Math.max(0,f+c-a)),{offset:s-i,height:f,active:s-i<=c})),B((i,s)=>i.offset===s.offset&&i.height===s.height&&i.active===s.active))}function Os(e){let t=__md_get("__palette")||{index:e.findIndex(r=>matchMedia(r.getAttribute("data-md-color-media")).matches)};return I(...e).pipe(se(r=>v(r,"change").pipe(m(()=>r))),N(e[Math.max(0,t.index)]),m(r=>({index:e.indexOf(r),color:{scheme:r.getAttribute("data-md-color-scheme"),primary:r.getAttribute("data-md-color-primary"),accent:r.getAttribute("data-md-color-accent")}})),X(1))}function xi(e){return P(()=>{let t=new E;t.subscribe(n=>{document.body.setAttribute("data-md-color-switching","");for(let[o,i]of Object.entries(n.color))document.body.setAttribute(`data-md-color-${o}`,i);for(let o=0;o{document.body.removeAttribute("data-md-color-switching")});let r=Q("input",e);return Os(r).pipe(w(n=>t.next(n)),C(()=>t.complete()),m(n=>H({ref:e},n)))})}var en=Ye(Br());function _s(e){e.setAttribute("data-md-copying","");let t=e.innerText;return e.removeAttribute("data-md-copying"),t}function wi({alert$:e}){en.default.isSupported()&&new F(t=>{new en.default("[data-clipboard-target], [data-clipboard-text]",{text:r=>r.getAttribute("data-clipboard-text")||_s(K(r.getAttribute("data-clipboard-target")))}).on("success",r=>t.next(r))}).pipe(w(t=>{t.trigger.focus()}),m(()=>re("clipboard.copied"))).subscribe(e)}function Ts(e){if(e.length<2)return[""];let[t,r]=[...e].sort((o,i)=>o.length-i.length).map(o=>o.replace(/[^/]+$/,"")),n=0;if(t===r)n=t.length;else for(;t.charCodeAt(n)===r.charCodeAt(n);)n++;return e.map(o=>o.replace(t.slice(0,n),""))}function hr(e){let t=__md_get("__sitemap",sessionStorage,e);if(t)return I(t);{let r=le();return Uo(new URL("sitemap.xml",e||r.base)).pipe(m(n=>Ts(Q("loc",n).map(o=>o.textContent))),ce(()=>R),De([]),w(n=>__md_set("__sitemap",n,sessionStorage,e)))}}function Ei({document$:e,location$:t,viewport$:r}){let n=le();if(location.protocol==="file:")return;"scrollRestoration"in history&&(history.scrollRestoration="manual",v(window,"beforeunload").subscribe(()=>{history.scrollRestoration="auto"}));let o=pe("link[rel=icon]");typeof o!="undefined"&&(o.href=o.href);let i=hr().pipe(m(f=>f.map(u=>`${new URL(u,n.base)}`)),S(f=>v(document.body,"click").pipe(x(u=>!u.metaKey&&!u.ctrlKey),S(u=>{if(u.target instanceof Element){let p=u.target.closest("a");if(p&&!p.target){let l=new URL(p.href);if(l.search="",l.hash="",l.pathname!==location.pathname&&f.includes(l.toString()))return u.preventDefault(),I({url:new URL(p.href)})}}return Se}))),ie()),s=v(window,"popstate").pipe(x(f=>f.state!==null),m(f=>({url:new URL(location.href),offset:f.state})),ie());A(i,s).pipe(B((f,u)=>f.url.href===u.url.href),m(({url:f})=>f)).subscribe(t);let a=t.pipe(J("pathname"),S(f=>mr(f.href).pipe(ce(()=>(pr(f),Se)))),ie());i.pipe(ut(a)).subscribe(({url:f})=>{history.pushState({},"",`${f}`)});let c=new DOMParser;a.pipe(S(f=>f.text()),m(f=>c.parseFromString(f,"text/html"))).subscribe(e),e.pipe(He(1)).subscribe(f=>{for(let u of["title","link[rel=canonical]","meta[name=author]","meta[name=description]","[data-md-component=announce]","[data-md-component=container]","[data-md-component=header-topic]","[data-md-component=outdated]","[data-md-component=logo]","[data-md-component=skip]",...Z("navigation.tabs.sticky")?["[data-md-component=tabs]"]:[]]){let p=pe(u),l=pe(u,f);typeof p!="undefined"&&typeof l!="undefined"&&p.replaceWith(l)}}),e.pipe(He(1),m(()=>_e("container")),S(f=>Q("script",f)),Ir(f=>{let u=M("script");if(f.src){for(let p of f.getAttributeNames())u.setAttribute(p,f.getAttribute(p));return f.replaceWith(u),new F(p=>{u.onload=()=>p.complete()})}else return u.textContent=f.textContent,f.replaceWith(u),R})).subscribe(),A(i,s).pipe(ut(e)).subscribe(({url:f,offset:u})=>{f.hash&&!u?Io(f.hash):window.scrollTo(0,(u==null?void 0:u.y)||0)}),r.pipe(Mt(i),Re(250),J("offset")).subscribe(({offset:f})=>{history.replaceState(f,"")}),A(i,s).pipe(Ce(2,1),x(([f,u])=>f.url.pathname===u.url.pathname),m(([,f])=>f)).subscribe(({offset:f})=>{window.scrollTo(0,(f==null?void 0:f.y)||0)})}var As=Ye(tn());var Oi=Ye(tn());function rn(e,t){let r=new RegExp(e.separator,"img"),n=(o,i,s)=>`${i}${s}`;return o=>{o=o.replace(/[\s*+\-:~^]+/g," ").trim();let i=new RegExp(`(^|${e.separator})(${o.replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&").replace(r,"|")})`,"img");return s=>(t?(0,Oi.default)(s):s).replace(i,n).replace(/<\/mark>(\s+)]*>/img,"$1")}}function _i(e){return e.split(/"([^"]+)"/g).map((t,r)=>r&1?t.replace(/^\b|^(?![^\x00-\x7F]|$)|\s+/g," +"):t).join("").replace(/"|(?:^|\s+)[*+\-:^~]+(?=\s+|$)/g,"").trim()}function bt(e){return e.type===1}function Ti(e){return e.type===2}function vt(e){return e.type===3}function Rs({config:e,docs:t}){e.lang.length===1&&e.lang[0]==="en"&&(e.lang=[re("search.config.lang")]),e.separator==="[\\s\\-]+"&&(e.separator=re("search.config.separator"));let n={pipeline:re("search.config.pipeline").split(/\s*,\s*/).filter(Boolean),suggestions:Z("search.suggest")};return{config:e,docs:t,options:n}}function Mi(e,t){let r=le(),n=new Worker(e),o=new E,i=Ko(n,{tx$:o}).pipe(m(s=>{if(vt(s))for(let a of s.data.items)for(let c of a)c.location=`${new URL(c.location,r.base)}`;return s}),ie());return ue(t).pipe(m(s=>({type:0,data:Rs(s)}))).subscribe(o.next.bind(o)),{tx$:o,rx$:i}}function Li({document$:e}){let t=le(),r=je(new URL("../versions.json",t.base)).pipe(ce(()=>R)),n=r.pipe(m(o=>{let[,i]=t.base.match(/([^/]+)\/?$/);return o.find(({version:s,aliases:a})=>s===i||a.includes(i))||o[0]}));r.pipe(m(o=>new Map(o.map(i=>[`${new URL(`../${i.version}/`,t.base)}`,i]))),S(o=>v(document.body,"click").pipe(x(i=>!i.metaKey&&!i.ctrlKey),ae(n),S(([i,s])=>{if(i.target instanceof Element){let a=i.target.closest("a");if(a&&!a.target&&o.has(a.href)){let c=a.href;return!i.target.closest(".md-version")&&o.get(c)===s?R:(i.preventDefault(),I(c))}}return R}),S(i=>{let{version:s}=o.get(i);return hr(new URL(i)).pipe(m(a=>{let f=Oe().href.replace(t.base,"");return a.includes(f.split("#")[0])?new URL(`../${s}/${f}`,t.base):new URL(i)}))})))).subscribe(o=>pr(o)),Y([r,n]).subscribe(([o,i])=>{K(".md-header__topic").appendChild(ei(o,i))}),e.pipe(S(()=>n)).subscribe(o=>{var s;let i=__md_get("__outdated",sessionStorage);if(i===null){let a=((s=t.version)==null?void 0:s.default)||"latest";i=!o.aliases.includes(a),__md_set("__outdated",i,sessionStorage)}if(i)for(let a of te("outdated"))a.hidden=!1})}function ks(e,{rx$:t}){let r=(__search==null?void 0:__search.transform)||_i,{searchParams:n}=Oe();n.has("q")&&Ke("search",!0);let o=t.pipe(x(bt),oe(1),m(()=>n.get("q")||""));dt("search").pipe(x(a=>!a),oe(1)).subscribe(()=>{let a=new URL(location.href);a.searchParams.delete("q"),history.replaceState({},"",`${a}`)}),o.subscribe(a=>{a&&(e.value=a,e.focus())});let i=nr(e),s=A(v(e,"keyup"),v(e,"focus").pipe(ke(1)),o).pipe(m(()=>r(e.value)),N(""),B());return Y([s,i]).pipe(m(([a,c])=>({value:a,focus:c})),X(1))}function Ai(e,{tx$:t,rx$:r}){let n=new E,o=n.pipe(de(1));return n.pipe(J("value"),m(({value:i})=>({type:2,data:i}))).subscribe(t.next.bind(t)),n.pipe(J("focus")).subscribe(({focus:i})=>{i?(Ke("search",i),e.placeholder=""):e.placeholder=re("search.placeholder")}),v(e.form,"reset").pipe(ee(o)).subscribe(()=>e.focus()),ks(e,{tx$:t,rx$:r}).pipe(w(i=>n.next(i)),C(()=>n.complete()),m(i=>H({ref:e},i)),ie())}function Ci(e,{rx$:t},{query$:r}){let n=new E,o=Ao(e.parentElement).pipe(x(Boolean)),i=K(":scope > :first-child",e),s=K(":scope > :last-child",e),a=t.pipe(x(bt),oe(1));return n.pipe(ae(r),Mt(a)).subscribe(([{items:f},{value:u}])=>{if(u)switch(f.length){case 0:i.textContent=re("search.result.none");break;case 1:i.textContent=re("search.result.one");break;default:i.textContent=re("search.result.other",lr(f.length))}else i.textContent=re("search.result.placeholder")}),n.pipe(w(()=>s.innerHTML=""),S(({items:f})=>A(I(...f.slice(0,10)),I(...f.slice(10)).pipe(Ce(4),Nr(o),S(([u])=>u))))).subscribe(f=>s.appendChild(Jo(f))),t.pipe(x(vt),m(({data:f})=>f)).pipe(w(f=>n.next(f)),C(()=>n.complete()),m(f=>H({ref:e},f)))}function Hs(e,{query$:t}){return t.pipe(m(({value:r})=>{let n=Oe();return n.hash="",n.searchParams.delete("h"),n.searchParams.set("q",r),{url:n}}))}function Ri(e,t){let r=new E;return r.subscribe(({url:n})=>{e.setAttribute("data-clipboard-text",e.href),e.href=`${n}`}),v(e,"click").subscribe(n=>n.preventDefault()),Hs(e,t).pipe(w(n=>r.next(n)),C(()=>r.complete()),m(n=>H({ref:e},n)))}function ki(e,{rx$:t},{keyboard$:r}){let n=new E,o=_e("search-query"),i=A(v(o,"keydown"),v(o,"focus")).pipe(Le(fe),m(()=>o.value),B());return n.pipe(Ze(i),m(([{suggestions:a},c])=>{let f=c.split(/([\s-]+)/);if((a==null?void 0:a.length)&&f[f.length-1]){let u=a[a.length-1];u.startsWith(f[f.length-1])&&(f[f.length-1]=u)}else f.length=0;return f})).subscribe(a=>e.innerHTML=a.join("").replace(/\s/g," ")),r.pipe(x(({mode:a})=>a==="search")).subscribe(a=>{switch(a.type){case"ArrowRight":e.innerText.length&&o.selectionStart===o.value.length&&(o.value=e.innerText);break}}),t.pipe(x(vt),m(({data:a})=>a)).pipe(w(a=>n.next(a)),C(()=>n.complete()),m(()=>({ref:e})))}function Hi(e,{index$:t,keyboard$:r}){let n=le();try{let o=(__search==null?void 0:__search.worker)||n.search,i=Mi(o,t),s=_e("search-query",e),a=_e("search-result",e),{tx$:c,rx$:f}=i;c.pipe(x(Ti),ut(f.pipe(x(bt))),oe(1)).subscribe(c.next.bind(c)),r.pipe(x(({mode:l})=>l==="search")).subscribe(l=>{let d=Ie();switch(l.type){case"Enter":if(d===s){let h=new Map;for(let b of Q(":first-child [href]",a)){let U=b.firstElementChild;h.set(b,parseFloat(U.getAttribute("data-md-score")))}if(h.size){let[[b]]=[...h].sort(([,U],[,G])=>G-U);b.click()}l.claim()}break;case"Escape":case"Tab":Ke("search",!1),s.blur();break;case"ArrowUp":case"ArrowDown":if(typeof d=="undefined")s.focus();else{let h=[s,...Q(":not(details) > [href], summary, details[open] [href]",a)],b=Math.max(0,(Math.max(0,h.indexOf(d))+h.length+(l.type==="ArrowUp"?-1:1))%h.length);h[b].focus()}l.claim();break;default:s!==Ie()&&s.focus()}}),r.pipe(x(({mode:l})=>l==="global")).subscribe(l=>{switch(l.type){case"f":case"s":case"/":s.focus(),s.select(),l.claim();break}});let u=Ai(s,i),p=Ci(a,i,{query$:u});return A(u,p).pipe(et(...te("search-share",e).map(l=>Ri(l,{query$:u})),...te("search-suggest",e).map(l=>ki(l,i,{keyboard$:r}))))}catch(o){return e.hidden=!0,Se}}function Pi(e,{index$:t,location$:r}){return Y([t,r.pipe(N(Oe()),x(n=>!!n.searchParams.get("h")))]).pipe(m(([n,o])=>rn(n.config,!0)(o.searchParams.get("h"))),m(n=>{var s;let o=new Map,i=document.createNodeIterator(e,NodeFilter.SHOW_TEXT);for(let a=i.nextNode();a;a=i.nextNode())if((s=a.parentElement)!=null&&s.offsetHeight){let c=a.textContent,f=n(c);f.length>c.length&&o.set(a,f)}for(let[a,c]of o){let{childNodes:f}=M("span",null,c);a.replaceWith(...Array.from(f))}return{ref:e,nodes:o}}))}function Ps(e,{viewport$:t,main$:r}){let n=e.parentElement,o=n.offsetTop-n.parentElement.offsetTop;return Y([r,t]).pipe(m(([{offset:i,height:s},{offset:{y:a}}])=>(s=s+Math.min(o,Math.max(0,a-i))-o,{height:s,locked:a>=i+o})),B((i,s)=>i.height===s.height&&i.locked===s.locked))}function nn(e,n){var o=n,{header$:t}=o,r=un(o,["header$"]);let i=K(".md-sidebar__scrollwrap",e),{y:s}=qe(i);return P(()=>{let a=new E;return a.pipe(Ae(0,xe),ae(t)).subscribe({next([{height:c},{height:f}]){i.style.height=`${c-2*s}px`,e.style.top=`${f}px`},complete(){i.style.height="",e.style.top=""}}),a.pipe(Le(xe),oe(1)).subscribe(()=>{for(let c of Q(".md-nav__link--active[href]",e)){let f=cr(c);if(typeof f!="undefined"){let u=c.offsetTop-f.offsetTop,{height:p}=he(f);f.scrollTo({top:u-p/2})}}}),Ps(e,r).pipe(w(c=>a.next(c)),C(()=>a.complete()),m(c=>H({ref:e},c)))})}function $i(e,t){if(typeof t!="undefined"){let r=`https://api.github.com/repos/${e}/${t}`;return _t(je(`${r}/releases/latest`).pipe(ce(()=>R),m(n=>({version:n.tag_name})),De({})),je(r).pipe(ce(()=>R),m(n=>({stars:n.stargazers_count,forks:n.forks_count})),De({}))).pipe(m(([n,o])=>H(H({},n),o)))}else{let r=`https://api.github.com/users/${e}`;return je(r).pipe(m(n=>({repositories:n.public_repos})),De({}))}}function Ii(e,t){let r=`https://${e}/api/v4/projects/${encodeURIComponent(t)}`;return je(r).pipe(ce(()=>R),m(({star_count:n,forks_count:o})=>({stars:n,forks:o})),De({}))}function ji(e){let t=e.match(/^.+github\.com\/([^/]+)\/?([^/]+)?/i);if(t){let[,r,n]=t;return $i(r,n)}if(t=e.match(/^.+?([^/]*gitlab[^/]+)\/(.+?)\/?$/i),t){let[,r,n]=t;return Ii(r,n)}return R}var $s;function Is(e){return $s||($s=P(()=>{let t=__md_get("__source",sessionStorage);if(t)return I(t);if(te("consent").length){let n=__md_get("__consent");if(!(n&&n.github))return R}return ji(e.href).pipe(w(n=>__md_set("__source",n,sessionStorage)))}).pipe(ce(()=>R),x(t=>Object.keys(t).length>0),m(t=>({facts:t})),X(1)))}function Fi(e){let t=K(":scope > :last-child",e);return P(()=>{let r=new E;return r.subscribe(({facts:n})=>{t.appendChild(Xo(n)),t.classList.add("md-source__repository--active")}),Is(e).pipe(w(n=>r.next(n)),C(()=>r.complete()),m(n=>H({ref:e},n)))})}function js(e,{viewport$:t,header$:r}){return ve(document.body).pipe(S(()=>dr(e,{header$:r,viewport$:t})),m(({offset:{y:n}})=>({hidden:n>=10})),J("hidden"))}function Ui(e,t){return P(()=>{let r=new E;return r.subscribe({next({hidden:n}){e.hidden=n},complete(){e.hidden=!1}}),(Z("navigation.tabs.sticky")?I({hidden:!1}):js(e,t)).pipe(w(n=>r.next(n)),C(()=>r.complete()),m(n=>H({ref:e},n)))})}function Fs(e,{viewport$:t,header$:r}){let n=new Map,o=Q("[href^=\\#]",e);for(let a of o){let c=decodeURIComponent(a.hash.substring(1)),f=pe(`[id="${c}"]`);typeof f!="undefined"&&n.set(a,f)}let i=r.pipe(J("height"),m(({height:a})=>{let c=_e("main"),f=K(":scope > :first-child",c);return a+.8*(f.offsetTop-c.offsetTop)}),ie());return ve(document.body).pipe(J("height"),S(a=>P(()=>{let c=[];return I([...n].reduce((f,[u,p])=>{for(;c.length&&n.get(c[c.length-1]).tagName>=p.tagName;)c.pop();let l=p.offsetTop;for(;!l&&p.parentElement;)p=p.parentElement,l=p.offsetTop;return f.set([...c=[...c,u]].reverse(),l)},new Map))}).pipe(m(c=>new Map([...c].sort(([,f],[,u])=>f-u))),Ze(i),S(([c,f])=>t.pipe(Ur(([u,p],{offset:{y:l},size:d})=>{let h=l+d.height>=Math.floor(a.height);for(;p.length;){let[,b]=p[0];if(b-f=l&&!h)p=[u.pop(),...p];else break}return[u,p]},[[],[...c]]),B((u,p)=>u[0]===p[0]&&u[1]===p[1])))))).pipe(m(([a,c])=>({prev:a.map(([f])=>f),next:c.map(([f])=>f)})),N({prev:[],next:[]}),Ce(2,1),m(([a,c])=>a.prev.length{let o=new E,i=o.pipe(de(1));if(o.subscribe(({prev:s,next:a})=>{for(let[c]of a)c.classList.remove("md-nav__link--passed"),c.classList.remove("md-nav__link--active");for(let[c,[f]]of s.entries())f.classList.add("md-nav__link--passed"),f.classList.toggle("md-nav__link--active",c===s.length-1)}),Z("toc.follow")){let s=A(t.pipe(Re(1),m(()=>{})),t.pipe(Re(250),m(()=>"smooth")));o.pipe(x(({prev:a})=>a.length>0),ae(s)).subscribe(([{prev:a},c])=>{let[f]=a[a.length-1];if(f.offsetHeight){let u=cr(f);if(typeof u!="undefined"){let p=f.offsetTop-u.offsetTop,{height:l}=he(u);u.scrollTo({top:p-l/2,behavior:c})}}})}return Z("navigation.tracking")&&t.pipe(ee(i),J("offset"),Re(250),He(1),ee(n.pipe(He(1))),Tt({delay:250}),ae(o)).subscribe(([,{prev:s}])=>{let a=Oe(),c=s[s.length-1];if(c&&c.length){let[f]=c,{hash:u}=new URL(f.href);a.hash!==u&&(a.hash=u,history.replaceState({},"",`${a}`))}else a.hash="",history.replaceState({},"",`${a}`)}),Fs(e,{viewport$:t,header$:r}).pipe(w(s=>o.next(s)),C(()=>o.complete()),m(s=>H({ref:e},s)))})}function Us(e,{viewport$:t,main$:r,target$:n}){let o=t.pipe(m(({offset:{y:s}})=>s),Ce(2,1),m(([s,a])=>s>a&&a>0),B()),i=r.pipe(m(({active:s})=>s));return Y([i,o]).pipe(m(([s,a])=>!(s&&a)),B(),ee(n.pipe(He(1))),Fr(!0),Tt({delay:250}),m(s=>({hidden:s})))}function Wi(e,{viewport$:t,header$:r,main$:n,target$:o}){let i=new E,s=i.pipe(de(1));return i.subscribe({next({hidden:a}){e.hidden=a,a?(e.setAttribute("tabindex","-1"),e.blur()):e.removeAttribute("tabindex")},complete(){e.style.top="",e.hidden=!0,e.removeAttribute("tabindex")}}),r.pipe(ee(s),J("height")).subscribe(({height:a})=>{e.style.top=`${a+16}px`}),Us(e,{viewport$:t,main$:n,target$:o}).pipe(w(a=>i.next(a)),C(()=>i.complete()),m(a=>H({ref:e},a)))}function Vi({document$:e,tablet$:t}){e.pipe(S(()=>Q(".md-toggle--indeterminate, [data-md-state=indeterminate]")),w(r=>{r.indeterminate=!0,r.checked=!1}),se(r=>v(r,"change").pipe(Wr(()=>r.classList.contains("md-toggle--indeterminate")),m(()=>r))),ae(t)).subscribe(([r,n])=>{r.classList.remove("md-toggle--indeterminate"),n&&(r.checked=!1)})}function Ds(){return/(iPad|iPhone|iPod)/.test(navigator.userAgent)}function zi({document$:e}){e.pipe(S(()=>Q("[data-md-scrollfix]")),w(t=>t.removeAttribute("data-md-scrollfix")),x(Ds),se(t=>v(t,"touchstart").pipe(m(()=>t)))).subscribe(t=>{let r=t.scrollTop;r===0?t.scrollTop=1:r+t.offsetHeight===t.scrollHeight&&(t.scrollTop=r-1)})}function Ni({viewport$:e,tablet$:t}){Y([dt("search"),t]).pipe(m(([r,n])=>r&&!n),S(r=>I(r).pipe(ke(r?400:100))),ae(e)).subscribe(([r,{offset:{y:n}}])=>{if(r)document.body.setAttribute("data-md-scrolllock",""),document.body.style.top=`-${n}px`;else{let o=-1*parseInt(document.body.style.top,10);document.body.removeAttribute("data-md-scrolllock"),document.body.style.top="",o&&window.scrollTo(0,o)}})}Object.entries||(Object.entries=function(e){let t=[];for(let r of Object.keys(e))t.push([r,e[r]]);return t});Object.values||(Object.values=function(e){let t=[];for(let r of Object.keys(e))t.push(e[r]);return t});typeof Element!="undefined"&&(Element.prototype.scrollTo||(Element.prototype.scrollTo=function(e,t){typeof e=="object"?(this.scrollLeft=e.left,this.scrollTop=e.top):(this.scrollLeft=e,this.scrollTop=t)}),Element.prototype.replaceWith||(Element.prototype.replaceWith=function(...e){let t=this.parentNode;if(t){e.length===0&&t.removeChild(this);for(let r=e.length-1;r>=0;r--){let n=e[r];typeof n=="string"?n=document.createTextNode(n):n.parentNode&&n.parentNode.removeChild(n),r?t.insertBefore(this.previousSibling,n):t.replaceChild(n,this)}}}));document.documentElement.classList.remove("no-js");document.documentElement.classList.add("js");var tt=go(),vr=ko(),gt=jo(),on=Ro(),we=qo(),gr=Kr("(min-width: 960px)"),Ki=Kr("(min-width: 1220px)"),Qi=Fo(),Yi=le(),Bi=document.forms.namedItem("search")?(__search==null?void 0:__search.index)||je(new URL("search/search_index.json",Yi.base)):Se,an=new E;wi({alert$:an});Z("navigation.instant")&&Ei({document$:tt,location$:vr,viewport$:we});var qi;((qi=Yi.version)==null?void 0:qi.provider)==="mike"&&Li({document$:tt});A(vr,gt).pipe(ke(125)).subscribe(()=>{Ke("drawer",!1),Ke("search",!1)});on.pipe(x(({mode:e})=>e==="global")).subscribe(e=>{switch(e.type){case"p":case",":let t=pe("[href][rel=prev]");typeof t!="undefined"&&t.click();break;case"n":case".":let r=pe("[href][rel=next]");typeof r!="undefined"&&r.click();break}});Vi({document$:tt,tablet$:gr});zi({document$:tt});Ni({viewport$:we,tablet$:gr});var Qe=bi(_e("header"),{viewport$:we}),br=tt.pipe(m(()=>_e("main")),S(e=>yi(e,{viewport$:we,header$:Qe})),X(1)),Ws=A(...te("consent").map(e=>Yo(e,{target$:gt})),...te("dialog").map(e=>hi(e,{alert$:an})),...te("header").map(e=>vi(e,{viewport$:we,header$:Qe,main$:br})),...te("palette").map(e=>xi(e)),...te("search").map(e=>Hi(e,{index$:Bi,keyboard$:on})),...te("source").map(e=>Fi(e))),Vs=P(()=>A(...te("announce").map(e=>Qo(e)),...te("content").map(e=>di(e,{viewport$:we,target$:gt,print$:Qi})),...te("content").map(e=>Z("search.highlight")?Pi(e,{index$:Bi,location$:vr}):R),...te("header-title").map(e=>gi(e,{viewport$:we,header$:Qe})),...te("sidebar").map(e=>e.getAttribute("data-md-type")==="navigation"?Qr(Ki,()=>nn(e,{viewport$:we,header$:Qe,main$:br})):Qr(gr,()=>nn(e,{viewport$:we,header$:Qe,main$:br}))),...te("tabs").map(e=>Ui(e,{viewport$:we,header$:Qe})),...te("toc").map(e=>Di(e,{viewport$:we,header$:Qe,target$:gt})),...te("top").map(e=>Wi(e,{viewport$:we,header$:Qe,main$:br,target$:gt})))),Gi=tt.pipe(S(()=>Vs),et(Ws),X(1));Gi.subscribe();window.document$=tt;window.location$=vr;window.target$=gt;window.keyboard$=on;window.viewport$=we;window.tablet$=gr;window.screen$=Ki;window.print$=Qi;window.alert$=an;window.component$=Gi;})(); -//# sourceMappingURL=bundle.5a2dcb6a.min.js.map - diff --git a/assets/javascripts/bundle.5a2dcb6a.min.js.map b/assets/javascripts/bundle.5a2dcb6a.min.js.map deleted file mode 100644 index 34e26a3ad..000000000 --- a/assets/javascripts/bundle.5a2dcb6a.min.js.map +++ /dev/null @@ -1,8 +0,0 @@ -{ - "version": 3, - "sources": ["node_modules/focus-visible/dist/focus-visible.js", "node_modules/url-polyfill/url-polyfill.js", "node_modules/rxjs/node_modules/tslib/tslib.js", "node_modules/clipboard/dist/clipboard.js", "node_modules/escape-html/index.js", "node_modules/array-flat-polyfill/index.mjs", "src/assets/javascripts/bundle.ts", "node_modules/unfetch/polyfill/index.js", "node_modules/rxjs/node_modules/tslib/modules/index.js", "node_modules/rxjs/src/internal/util/isFunction.ts", "node_modules/rxjs/src/internal/util/createErrorClass.ts", "node_modules/rxjs/src/internal/util/UnsubscriptionError.ts", "node_modules/rxjs/src/internal/util/arrRemove.ts", "node_modules/rxjs/src/internal/Subscription.ts", "node_modules/rxjs/src/internal/config.ts", "node_modules/rxjs/src/internal/scheduler/timeoutProvider.ts", "node_modules/rxjs/src/internal/util/reportUnhandledError.ts", "node_modules/rxjs/src/internal/util/noop.ts", "node_modules/rxjs/src/internal/NotificationFactories.ts", "node_modules/rxjs/src/internal/util/errorContext.ts", "node_modules/rxjs/src/internal/Subscriber.ts", "node_modules/rxjs/src/internal/symbol/observable.ts", "node_modules/rxjs/src/internal/util/identity.ts", "node_modules/rxjs/src/internal/util/pipe.ts", "node_modules/rxjs/src/internal/Observable.ts", "node_modules/rxjs/src/internal/util/lift.ts", "node_modules/rxjs/src/internal/operators/OperatorSubscriber.ts", "node_modules/rxjs/src/internal/scheduler/animationFrameProvider.ts", "node_modules/rxjs/src/internal/util/ObjectUnsubscribedError.ts", "node_modules/rxjs/src/internal/Subject.ts", "node_modules/rxjs/src/internal/scheduler/dateTimestampProvider.ts", "node_modules/rxjs/src/internal/ReplaySubject.ts", "node_modules/rxjs/src/internal/scheduler/Action.ts", "node_modules/rxjs/src/internal/scheduler/intervalProvider.ts", "node_modules/rxjs/src/internal/scheduler/AsyncAction.ts", "node_modules/rxjs/src/internal/Scheduler.ts", "node_modules/rxjs/src/internal/scheduler/AsyncScheduler.ts", "node_modules/rxjs/src/internal/scheduler/async.ts", "node_modules/rxjs/src/internal/scheduler/AnimationFrameAction.ts", "node_modules/rxjs/src/internal/scheduler/AnimationFrameScheduler.ts", "node_modules/rxjs/src/internal/scheduler/animationFrame.ts", "node_modules/rxjs/src/internal/observable/empty.ts", "node_modules/rxjs/src/internal/util/isScheduler.ts", "node_modules/rxjs/src/internal/util/args.ts", "node_modules/rxjs/src/internal/util/isArrayLike.ts", "node_modules/rxjs/src/internal/util/isPromise.ts", "node_modules/rxjs/src/internal/util/isInteropObservable.ts", "node_modules/rxjs/src/internal/util/isAsyncIterable.ts", "node_modules/rxjs/src/internal/util/throwUnobservableError.ts", "node_modules/rxjs/src/internal/symbol/iterator.ts", "node_modules/rxjs/src/internal/util/isIterable.ts", "node_modules/rxjs/src/internal/util/isReadableStreamLike.ts", "node_modules/rxjs/src/internal/observable/innerFrom.ts", "node_modules/rxjs/src/internal/util/executeSchedule.ts", "node_modules/rxjs/src/internal/operators/observeOn.ts", "node_modules/rxjs/src/internal/operators/subscribeOn.ts", "node_modules/rxjs/src/internal/scheduled/scheduleObservable.ts", "node_modules/rxjs/src/internal/scheduled/schedulePromise.ts", "node_modules/rxjs/src/internal/scheduled/scheduleArray.ts", "node_modules/rxjs/src/internal/scheduled/scheduleIterable.ts", "node_modules/rxjs/src/internal/scheduled/scheduleAsyncIterable.ts", "node_modules/rxjs/src/internal/scheduled/scheduleReadableStreamLike.ts", "node_modules/rxjs/src/internal/scheduled/scheduled.ts", "node_modules/rxjs/src/internal/observable/from.ts", "node_modules/rxjs/src/internal/observable/of.ts", "node_modules/rxjs/src/internal/observable/throwError.ts", "node_modules/rxjs/src/internal/util/isDate.ts", "node_modules/rxjs/src/internal/operators/map.ts", "node_modules/rxjs/src/internal/util/mapOneOrManyArgs.ts", "node_modules/rxjs/src/internal/util/argsArgArrayOrObject.ts", "node_modules/rxjs/src/internal/util/createObject.ts", "node_modules/rxjs/src/internal/observable/combineLatest.ts", "node_modules/rxjs/src/internal/operators/mergeInternals.ts", "node_modules/rxjs/src/internal/operators/mergeMap.ts", "node_modules/rxjs/src/internal/operators/mergeAll.ts", "node_modules/rxjs/src/internal/operators/concatAll.ts", "node_modules/rxjs/src/internal/observable/concat.ts", "node_modules/rxjs/src/internal/observable/defer.ts", "node_modules/rxjs/src/internal/observable/fromEvent.ts", "node_modules/rxjs/src/internal/observable/fromEventPattern.ts", "node_modules/rxjs/src/internal/observable/timer.ts", "node_modules/rxjs/src/internal/observable/merge.ts", "node_modules/rxjs/src/internal/observable/never.ts", "node_modules/rxjs/src/internal/util/argsOrArgArray.ts", "node_modules/rxjs/src/internal/operators/filter.ts", "node_modules/rxjs/src/internal/observable/zip.ts", "node_modules/rxjs/src/internal/operators/audit.ts", "node_modules/rxjs/src/internal/operators/auditTime.ts", "node_modules/rxjs/src/internal/operators/bufferCount.ts", "node_modules/rxjs/src/internal/operators/catchError.ts", "node_modules/rxjs/src/internal/operators/scanInternals.ts", "node_modules/rxjs/src/internal/operators/combineLatest.ts", "node_modules/rxjs/src/internal/operators/combineLatestWith.ts", "node_modules/rxjs/src/internal/operators/concatMap.ts", "node_modules/rxjs/src/internal/operators/debounceTime.ts", "node_modules/rxjs/src/internal/operators/defaultIfEmpty.ts", "node_modules/rxjs/src/internal/operators/take.ts", "node_modules/rxjs/src/internal/operators/ignoreElements.ts", "node_modules/rxjs/src/internal/operators/mapTo.ts", "node_modules/rxjs/src/internal/operators/delayWhen.ts", "node_modules/rxjs/src/internal/operators/delay.ts", "node_modules/rxjs/src/internal/operators/distinctUntilChanged.ts", "node_modules/rxjs/src/internal/operators/distinctUntilKeyChanged.ts", "node_modules/rxjs/src/internal/operators/endWith.ts", "node_modules/rxjs/src/internal/operators/finalize.ts", "node_modules/rxjs/src/internal/operators/takeLast.ts", "node_modules/rxjs/src/internal/operators/merge.ts", "node_modules/rxjs/src/internal/operators/mergeWith.ts", "node_modules/rxjs/src/internal/operators/repeat.ts", "node_modules/rxjs/src/internal/operators/sample.ts", "node_modules/rxjs/src/internal/operators/scan.ts", "node_modules/rxjs/src/internal/operators/share.ts", "node_modules/rxjs/src/internal/operators/shareReplay.ts", "node_modules/rxjs/src/internal/operators/skip.ts", "node_modules/rxjs/src/internal/operators/skipUntil.ts", "node_modules/rxjs/src/internal/operators/startWith.ts", "node_modules/rxjs/src/internal/operators/switchMap.ts", "node_modules/rxjs/src/internal/operators/takeUntil.ts", "node_modules/rxjs/src/internal/operators/takeWhile.ts", "node_modules/rxjs/src/internal/operators/tap.ts", "node_modules/rxjs/src/internal/operators/throttle.ts", "node_modules/rxjs/src/internal/operators/throttleTime.ts", "node_modules/rxjs/src/internal/operators/withLatestFrom.ts", "node_modules/rxjs/src/internal/operators/zip.ts", "node_modules/rxjs/src/internal/operators/zipWith.ts", "src/assets/javascripts/browser/document/index.ts", "src/assets/javascripts/browser/element/_/index.ts", "src/assets/javascripts/browser/element/focus/index.ts", "src/assets/javascripts/browser/element/offset/_/index.ts", "src/assets/javascripts/browser/element/offset/content/index.ts", "node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js", "src/assets/javascripts/browser/element/size/_/index.ts", "src/assets/javascripts/browser/element/size/content/index.ts", "src/assets/javascripts/browser/element/visibility/index.ts", "src/assets/javascripts/browser/toggle/index.ts", "src/assets/javascripts/browser/keyboard/index.ts", "src/assets/javascripts/browser/location/_/index.ts", "src/assets/javascripts/utilities/h/index.ts", "src/assets/javascripts/utilities/string/index.ts", "src/assets/javascripts/browser/location/hash/index.ts", "src/assets/javascripts/browser/media/index.ts", "src/assets/javascripts/browser/request/index.ts", "src/assets/javascripts/browser/script/index.ts", "src/assets/javascripts/browser/viewport/offset/index.ts", "src/assets/javascripts/browser/viewport/size/index.ts", "src/assets/javascripts/browser/viewport/_/index.ts", "src/assets/javascripts/browser/viewport/at/index.ts", "src/assets/javascripts/browser/worker/index.ts", "src/assets/javascripts/_/index.ts", "src/assets/javascripts/components/_/index.ts", "src/assets/javascripts/components/announce/index.ts", "src/assets/javascripts/components/consent/index.ts", "src/assets/javascripts/components/content/code/_/index.ts", "src/assets/javascripts/templates/tooltip/index.tsx", "src/assets/javascripts/templates/annotation/index.tsx", "src/assets/javascripts/templates/clipboard/index.tsx", "src/assets/javascripts/templates/search/index.tsx", "src/assets/javascripts/templates/source/index.tsx", "src/assets/javascripts/templates/tabbed/index.tsx", "src/assets/javascripts/templates/table/index.tsx", "src/assets/javascripts/templates/version/index.tsx", "src/assets/javascripts/components/content/annotation/_/index.ts", "src/assets/javascripts/components/content/annotation/list/index.ts", "src/assets/javascripts/components/content/code/mermaid/index.ts", "src/assets/javascripts/components/content/details/index.ts", "src/assets/javascripts/components/content/table/index.ts", "src/assets/javascripts/components/content/tabs/index.ts", "src/assets/javascripts/components/content/_/index.ts", "src/assets/javascripts/components/dialog/index.ts", "src/assets/javascripts/components/header/_/index.ts", "src/assets/javascripts/components/header/title/index.ts", "src/assets/javascripts/components/main/index.ts", "src/assets/javascripts/components/palette/index.ts", "src/assets/javascripts/integrations/clipboard/index.ts", "src/assets/javascripts/integrations/sitemap/index.ts", "src/assets/javascripts/integrations/instant/index.ts", "src/assets/javascripts/integrations/search/document/index.ts", "src/assets/javascripts/integrations/search/highlighter/index.ts", "src/assets/javascripts/integrations/search/query/transform/index.ts", "src/assets/javascripts/integrations/search/worker/message/index.ts", "src/assets/javascripts/integrations/search/worker/_/index.ts", "src/assets/javascripts/integrations/version/index.ts", "src/assets/javascripts/components/search/query/index.ts", "src/assets/javascripts/components/search/result/index.ts", "src/assets/javascripts/components/search/share/index.ts", "src/assets/javascripts/components/search/suggest/index.ts", "src/assets/javascripts/components/search/_/index.ts", "src/assets/javascripts/components/search/highlight/index.ts", "src/assets/javascripts/components/sidebar/index.ts", "src/assets/javascripts/components/source/facts/github/index.ts", "src/assets/javascripts/components/source/facts/gitlab/index.ts", "src/assets/javascripts/components/source/facts/_/index.ts", "src/assets/javascripts/components/source/_/index.ts", "src/assets/javascripts/components/tabs/index.ts", "src/assets/javascripts/components/toc/index.ts", "src/assets/javascripts/components/top/index.ts", "src/assets/javascripts/patches/indeterminate/index.ts", "src/assets/javascripts/patches/scrollfix/index.ts", "src/assets/javascripts/patches/scrolllock/index.ts", "src/assets/javascripts/polyfills/index.ts"], - "sourceRoot": "../../../..", - "sourcesContent": ["(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n (factory());\n}(this, (function () { 'use strict';\n\n /**\n * Applies the :focus-visible polyfill at the given scope.\n * A scope in this case is either the top-level Document or a Shadow Root.\n *\n * @param {(Document|ShadowRoot)} scope\n * @see https://github.com/WICG/focus-visible\n */\n function applyFocusVisiblePolyfill(scope) {\n var hadKeyboardEvent = true;\n var hadFocusVisibleRecently = false;\n var hadFocusVisibleRecentlyTimeout = null;\n\n var inputTypesAllowlist = {\n text: true,\n search: true,\n url: true,\n tel: true,\n email: true,\n password: true,\n number: true,\n date: true,\n month: true,\n week: true,\n time: true,\n datetime: true,\n 'datetime-local': true\n };\n\n /**\n * Helper function for legacy browsers and iframes which sometimes focus\n * elements like document, body, and non-interactive SVG.\n * @param {Element} el\n */\n function isValidFocusTarget(el) {\n if (\n el &&\n el !== document &&\n el.nodeName !== 'HTML' &&\n el.nodeName !== 'BODY' &&\n 'classList' in el &&\n 'contains' in el.classList\n ) {\n return true;\n }\n return false;\n }\n\n /**\n * Computes whether the given element should automatically trigger the\n * `focus-visible` class being added, i.e. whether it should always match\n * `:focus-visible` when focused.\n * @param {Element} el\n * @return {boolean}\n */\n function focusTriggersKeyboardModality(el) {\n var type = el.type;\n var tagName = el.tagName;\n\n if (tagName === 'INPUT' && inputTypesAllowlist[type] && !el.readOnly) {\n return true;\n }\n\n if (tagName === 'TEXTAREA' && !el.readOnly) {\n return true;\n }\n\n if (el.isContentEditable) {\n return true;\n }\n\n return false;\n }\n\n /**\n * Add the `focus-visible` class to the given element if it was not added by\n * the author.\n * @param {Element} el\n */\n function addFocusVisibleClass(el) {\n if (el.classList.contains('focus-visible')) {\n return;\n }\n el.classList.add('focus-visible');\n el.setAttribute('data-focus-visible-added', '');\n }\n\n /**\n * Remove the `focus-visible` class from the given element if it was not\n * originally added by the author.\n * @param {Element} el\n */\n function removeFocusVisibleClass(el) {\n if (!el.hasAttribute('data-focus-visible-added')) {\n return;\n }\n el.classList.remove('focus-visible');\n el.removeAttribute('data-focus-visible-added');\n }\n\n /**\n * If the most recent user interaction was via the keyboard;\n * and the key press did not include a meta, alt/option, or control key;\n * then the modality is keyboard. Otherwise, the modality is not keyboard.\n * Apply `focus-visible` to any current active element and keep track\n * of our keyboard modality state with `hadKeyboardEvent`.\n * @param {KeyboardEvent} e\n */\n function onKeyDown(e) {\n if (e.metaKey || e.altKey || e.ctrlKey) {\n return;\n }\n\n if (isValidFocusTarget(scope.activeElement)) {\n addFocusVisibleClass(scope.activeElement);\n }\n\n hadKeyboardEvent = true;\n }\n\n /**\n * If at any point a user clicks with a pointing device, ensure that we change\n * the modality away from keyboard.\n * This avoids the situation where a user presses a key on an already focused\n * element, and then clicks on a different element, focusing it with a\n * pointing device, while we still think we're in keyboard modality.\n * @param {Event} e\n */\n function onPointerDown(e) {\n hadKeyboardEvent = false;\n }\n\n /**\n * On `focus`, add the `focus-visible` class to the target if:\n * - the target received focus as a result of keyboard navigation, or\n * - the event target is an element that will likely require interaction\n * via the keyboard (e.g. a text box)\n * @param {Event} e\n */\n function onFocus(e) {\n // Prevent IE from focusing the document or HTML element.\n if (!isValidFocusTarget(e.target)) {\n return;\n }\n\n if (hadKeyboardEvent || focusTriggersKeyboardModality(e.target)) {\n addFocusVisibleClass(e.target);\n }\n }\n\n /**\n * On `blur`, remove the `focus-visible` class from the target.\n * @param {Event} e\n */\n function onBlur(e) {\n if (!isValidFocusTarget(e.target)) {\n return;\n }\n\n if (\n e.target.classList.contains('focus-visible') ||\n e.target.hasAttribute('data-focus-visible-added')\n ) {\n // To detect a tab/window switch, we look for a blur event followed\n // rapidly by a visibility change.\n // If we don't see a visibility change within 100ms, it's probably a\n // regular focus change.\n hadFocusVisibleRecently = true;\n window.clearTimeout(hadFocusVisibleRecentlyTimeout);\n hadFocusVisibleRecentlyTimeout = window.setTimeout(function() {\n hadFocusVisibleRecently = false;\n }, 100);\n removeFocusVisibleClass(e.target);\n }\n }\n\n /**\n * If the user changes tabs, keep track of whether or not the previously\n * focused element had .focus-visible.\n * @param {Event} e\n */\n function onVisibilityChange(e) {\n if (document.visibilityState === 'hidden') {\n // If the tab becomes active again, the browser will handle calling focus\n // on the element (Safari actually calls it twice).\n // If this tab change caused a blur on an element with focus-visible,\n // re-apply the class when the user switches back to the tab.\n if (hadFocusVisibleRecently) {\n hadKeyboardEvent = true;\n }\n addInitialPointerMoveListeners();\n }\n }\n\n /**\n * Add a group of listeners to detect usage of any pointing devices.\n * These listeners will be added when the polyfill first loads, and anytime\n * the window is blurred, so that they are active when the window regains\n * focus.\n */\n function addInitialPointerMoveListeners() {\n document.addEventListener('mousemove', onInitialPointerMove);\n document.addEventListener('mousedown', onInitialPointerMove);\n document.addEventListener('mouseup', onInitialPointerMove);\n document.addEventListener('pointermove', onInitialPointerMove);\n document.addEventListener('pointerdown', onInitialPointerMove);\n document.addEventListener('pointerup', onInitialPointerMove);\n document.addEventListener('touchmove', onInitialPointerMove);\n document.addEventListener('touchstart', onInitialPointerMove);\n document.addEventListener('touchend', onInitialPointerMove);\n }\n\n function removeInitialPointerMoveListeners() {\n document.removeEventListener('mousemove', onInitialPointerMove);\n document.removeEventListener('mousedown', onInitialPointerMove);\n document.removeEventListener('mouseup', onInitialPointerMove);\n document.removeEventListener('pointermove', onInitialPointerMove);\n document.removeEventListener('pointerdown', onInitialPointerMove);\n document.removeEventListener('pointerup', onInitialPointerMove);\n document.removeEventListener('touchmove', onInitialPointerMove);\n document.removeEventListener('touchstart', onInitialPointerMove);\n document.removeEventListener('touchend', onInitialPointerMove);\n }\n\n /**\n * When the polfyill first loads, assume the user is in keyboard modality.\n * If any event is received from a pointing device (e.g. mouse, pointer,\n * touch), turn off keyboard modality.\n * This accounts for situations where focus enters the page from the URL bar.\n * @param {Event} e\n */\n function onInitialPointerMove(e) {\n // Work around a Safari quirk that fires a mousemove on whenever the\n // window blurs, even if you're tabbing out of the page. \u00AF\\_(\u30C4)_/\u00AF\n if (e.target.nodeName && e.target.nodeName.toLowerCase() === 'html') {\n return;\n }\n\n hadKeyboardEvent = false;\n removeInitialPointerMoveListeners();\n }\n\n // For some kinds of state, we are interested in changes at the global scope\n // only. For example, global pointer input, global key presses and global\n // visibility change should affect the state at every scope:\n document.addEventListener('keydown', onKeyDown, true);\n document.addEventListener('mousedown', onPointerDown, true);\n document.addEventListener('pointerdown', onPointerDown, true);\n document.addEventListener('touchstart', onPointerDown, true);\n document.addEventListener('visibilitychange', onVisibilityChange, true);\n\n addInitialPointerMoveListeners();\n\n // For focus and blur, we specifically care about state changes in the local\n // scope. This is because focus / blur events that originate from within a\n // shadow root are not re-dispatched from the host element if it was already\n // the active element in its own scope:\n scope.addEventListener('focus', onFocus, true);\n scope.addEventListener('blur', onBlur, true);\n\n // We detect that a node is a ShadowRoot by ensuring that it is a\n // DocumentFragment and also has a host property. This check covers native\n // implementation and polyfill implementation transparently. If we only cared\n // about the native implementation, we could just check if the scope was\n // an instance of a ShadowRoot.\n if (scope.nodeType === Node.DOCUMENT_FRAGMENT_NODE && scope.host) {\n // Since a ShadowRoot is a special kind of DocumentFragment, it does not\n // have a root element to add a class to. So, we add this attribute to the\n // host element instead:\n scope.host.setAttribute('data-js-focus-visible', '');\n } else if (scope.nodeType === Node.DOCUMENT_NODE) {\n document.documentElement.classList.add('js-focus-visible');\n document.documentElement.setAttribute('data-js-focus-visible', '');\n }\n }\n\n // It is important to wrap all references to global window and document in\n // these checks to support server-side rendering use cases\n // @see https://github.com/WICG/focus-visible/issues/199\n if (typeof window !== 'undefined' && typeof document !== 'undefined') {\n // Make the polyfill helper globally available. This can be used as a signal\n // to interested libraries that wish to coordinate with the polyfill for e.g.,\n // applying the polyfill to a shadow root:\n window.applyFocusVisiblePolyfill = applyFocusVisiblePolyfill;\n\n // Notify interested libraries of the polyfill's presence, in case the\n // polyfill was loaded lazily:\n var event;\n\n try {\n event = new CustomEvent('focus-visible-polyfill-ready');\n } catch (error) {\n // IE11 does not support using CustomEvent as a constructor directly:\n event = document.createEvent('CustomEvent');\n event.initCustomEvent('focus-visible-polyfill-ready', false, false, {});\n }\n\n window.dispatchEvent(event);\n }\n\n if (typeof document !== 'undefined') {\n // Apply the polyfill to the global document, so that no JavaScript\n // coordination is required to use the polyfill in the top-level document:\n applyFocusVisiblePolyfill(document);\n }\n\n})));\n", "(function(global) {\r\n /**\r\n * Polyfill URLSearchParams\r\n *\r\n * Inspired from : https://github.com/WebReflection/url-search-params/blob/master/src/url-search-params.js\r\n */\r\n\r\n var checkIfIteratorIsSupported = function() {\r\n try {\r\n return !!Symbol.iterator;\r\n } catch (error) {\r\n return false;\r\n }\r\n };\r\n\r\n\r\n var iteratorSupported = checkIfIteratorIsSupported();\r\n\r\n var createIterator = function(items) {\r\n var iterator = {\r\n next: function() {\r\n var value = items.shift();\r\n return { done: value === void 0, value: value };\r\n }\r\n };\r\n\r\n if (iteratorSupported) {\r\n iterator[Symbol.iterator] = function() {\r\n return iterator;\r\n };\r\n }\r\n\r\n return iterator;\r\n };\r\n\r\n /**\r\n * Search param name and values should be encoded according to https://url.spec.whatwg.org/#urlencoded-serializing\r\n * encodeURIComponent() produces the same result except encoding spaces as `%20` instead of `+`.\r\n */\r\n var serializeParam = function(value) {\r\n return encodeURIComponent(value).replace(/%20/g, '+');\r\n };\r\n\r\n var deserializeParam = function(value) {\r\n return decodeURIComponent(String(value).replace(/\\+/g, ' '));\r\n };\r\n\r\n var polyfillURLSearchParams = function() {\r\n\r\n var URLSearchParams = function(searchString) {\r\n Object.defineProperty(this, '_entries', { writable: true, value: {} });\r\n var typeofSearchString = typeof searchString;\r\n\r\n if (typeofSearchString === 'undefined') {\r\n // do nothing\r\n } else if (typeofSearchString === 'string') {\r\n if (searchString !== '') {\r\n this._fromString(searchString);\r\n }\r\n } else if (searchString instanceof URLSearchParams) {\r\n var _this = this;\r\n searchString.forEach(function(value, name) {\r\n _this.append(name, value);\r\n });\r\n } else if ((searchString !== null) && (typeofSearchString === 'object')) {\r\n if (Object.prototype.toString.call(searchString) === '[object Array]') {\r\n for (var i = 0; i < searchString.length; i++) {\r\n var entry = searchString[i];\r\n if ((Object.prototype.toString.call(entry) === '[object Array]') || (entry.length !== 2)) {\r\n this.append(entry[0], entry[1]);\r\n } else {\r\n throw new TypeError('Expected [string, any] as entry at index ' + i + ' of URLSearchParams\\'s input');\r\n }\r\n }\r\n } else {\r\n for (var key in searchString) {\r\n if (searchString.hasOwnProperty(key)) {\r\n this.append(key, searchString[key]);\r\n }\r\n }\r\n }\r\n } else {\r\n throw new TypeError('Unsupported input\\'s type for URLSearchParams');\r\n }\r\n };\r\n\r\n var proto = URLSearchParams.prototype;\r\n\r\n proto.append = function(name, value) {\r\n if (name in this._entries) {\r\n this._entries[name].push(String(value));\r\n } else {\r\n this._entries[name] = [String(value)];\r\n }\r\n };\r\n\r\n proto.delete = function(name) {\r\n delete this._entries[name];\r\n };\r\n\r\n proto.get = function(name) {\r\n return (name in this._entries) ? this._entries[name][0] : null;\r\n };\r\n\r\n proto.getAll = function(name) {\r\n return (name in this._entries) ? this._entries[name].slice(0) : [];\r\n };\r\n\r\n proto.has = function(name) {\r\n return (name in this._entries);\r\n };\r\n\r\n proto.set = function(name, value) {\r\n this._entries[name] = [String(value)];\r\n };\r\n\r\n proto.forEach = function(callback, thisArg) {\r\n var entries;\r\n for (var name in this._entries) {\r\n if (this._entries.hasOwnProperty(name)) {\r\n entries = this._entries[name];\r\n for (var i = 0; i < entries.length; i++) {\r\n callback.call(thisArg, entries[i], name, this);\r\n }\r\n }\r\n }\r\n };\r\n\r\n proto.keys = function() {\r\n var items = [];\r\n this.forEach(function(value, name) {\r\n items.push(name);\r\n });\r\n return createIterator(items);\r\n };\r\n\r\n proto.values = function() {\r\n var items = [];\r\n this.forEach(function(value) {\r\n items.push(value);\r\n });\r\n return createIterator(items);\r\n };\r\n\r\n proto.entries = function() {\r\n var items = [];\r\n this.forEach(function(value, name) {\r\n items.push([name, value]);\r\n });\r\n return createIterator(items);\r\n };\r\n\r\n if (iteratorSupported) {\r\n proto[Symbol.iterator] = proto.entries;\r\n }\r\n\r\n proto.toString = function() {\r\n var searchArray = [];\r\n this.forEach(function(value, name) {\r\n searchArray.push(serializeParam(name) + '=' + serializeParam(value));\r\n });\r\n return searchArray.join('&');\r\n };\r\n\r\n\r\n global.URLSearchParams = URLSearchParams;\r\n };\r\n\r\n var checkIfURLSearchParamsSupported = function() {\r\n try {\r\n var URLSearchParams = global.URLSearchParams;\r\n\r\n return (\r\n (new URLSearchParams('?a=1').toString() === 'a=1') &&\r\n (typeof URLSearchParams.prototype.set === 'function') &&\r\n (typeof URLSearchParams.prototype.entries === 'function')\r\n );\r\n } catch (e) {\r\n return false;\r\n }\r\n };\r\n\r\n if (!checkIfURLSearchParamsSupported()) {\r\n polyfillURLSearchParams();\r\n }\r\n\r\n var proto = global.URLSearchParams.prototype;\r\n\r\n if (typeof proto.sort !== 'function') {\r\n proto.sort = function() {\r\n var _this = this;\r\n var items = [];\r\n this.forEach(function(value, name) {\r\n items.push([name, value]);\r\n if (!_this._entries) {\r\n _this.delete(name);\r\n }\r\n });\r\n items.sort(function(a, b) {\r\n if (a[0] < b[0]) {\r\n return -1;\r\n } else if (a[0] > b[0]) {\r\n return +1;\r\n } else {\r\n return 0;\r\n }\r\n });\r\n if (_this._entries) { // force reset because IE keeps keys index\r\n _this._entries = {};\r\n }\r\n for (var i = 0; i < items.length; i++) {\r\n this.append(items[i][0], items[i][1]);\r\n }\r\n };\r\n }\r\n\r\n if (typeof proto._fromString !== 'function') {\r\n Object.defineProperty(proto, '_fromString', {\r\n enumerable: false,\r\n configurable: false,\r\n writable: false,\r\n value: function(searchString) {\r\n if (this._entries) {\r\n this._entries = {};\r\n } else {\r\n var keys = [];\r\n this.forEach(function(value, name) {\r\n keys.push(name);\r\n });\r\n for (var i = 0; i < keys.length; i++) {\r\n this.delete(keys[i]);\r\n }\r\n }\r\n\r\n searchString = searchString.replace(/^\\?/, '');\r\n var attributes = searchString.split('&');\r\n var attribute;\r\n for (var i = 0; i < attributes.length; i++) {\r\n attribute = attributes[i].split('=');\r\n this.append(\r\n deserializeParam(attribute[0]),\r\n (attribute.length > 1) ? deserializeParam(attribute[1]) : ''\r\n );\r\n }\r\n }\r\n });\r\n }\r\n\r\n // HTMLAnchorElement\r\n\r\n})(\r\n (typeof global !== 'undefined') ? global\r\n : ((typeof window !== 'undefined') ? window\r\n : ((typeof self !== 'undefined') ? self : this))\r\n);\r\n\r\n(function(global) {\r\n /**\r\n * Polyfill URL\r\n *\r\n * Inspired from : https://github.com/arv/DOM-URL-Polyfill/blob/master/src/url.js\r\n */\r\n\r\n var checkIfURLIsSupported = function() {\r\n try {\r\n var u = new global.URL('b', 'http://a');\r\n u.pathname = 'c d';\r\n return (u.href === 'http://a/c%20d') && u.searchParams;\r\n } catch (e) {\r\n return false;\r\n }\r\n };\r\n\r\n\r\n var polyfillURL = function() {\r\n var _URL = global.URL;\r\n\r\n var URL = function(url, base) {\r\n if (typeof url !== 'string') url = String(url);\r\n if (base && typeof base !== 'string') base = String(base);\r\n\r\n // Only create another document if the base is different from current location.\r\n var doc = document, baseElement;\r\n if (base && (global.location === void 0 || base !== global.location.href)) {\r\n base = base.toLowerCase();\r\n doc = document.implementation.createHTMLDocument('');\r\n baseElement = doc.createElement('base');\r\n baseElement.href = base;\r\n doc.head.appendChild(baseElement);\r\n try {\r\n if (baseElement.href.indexOf(base) !== 0) throw new Error(baseElement.href);\r\n } catch (err) {\r\n throw new Error('URL unable to set base ' + base + ' due to ' + err);\r\n }\r\n }\r\n\r\n var anchorElement = doc.createElement('a');\r\n anchorElement.href = url;\r\n if (baseElement) {\r\n doc.body.appendChild(anchorElement);\r\n anchorElement.href = anchorElement.href; // force href to refresh\r\n }\r\n\r\n var inputElement = doc.createElement('input');\r\n inputElement.type = 'url';\r\n inputElement.value = url;\r\n\r\n if (anchorElement.protocol === ':' || !/:/.test(anchorElement.href) || (!inputElement.checkValidity() && !base)) {\r\n throw new TypeError('Invalid URL');\r\n }\r\n\r\n Object.defineProperty(this, '_anchorElement', {\r\n value: anchorElement\r\n });\r\n\r\n\r\n // create a linked searchParams which reflect its changes on URL\r\n var searchParams = new global.URLSearchParams(this.search);\r\n var enableSearchUpdate = true;\r\n var enableSearchParamsUpdate = true;\r\n var _this = this;\r\n ['append', 'delete', 'set'].forEach(function(methodName) {\r\n var method = searchParams[methodName];\r\n searchParams[methodName] = function() {\r\n method.apply(searchParams, arguments);\r\n if (enableSearchUpdate) {\r\n enableSearchParamsUpdate = false;\r\n _this.search = searchParams.toString();\r\n enableSearchParamsUpdate = true;\r\n }\r\n };\r\n });\r\n\r\n Object.defineProperty(this, 'searchParams', {\r\n value: searchParams,\r\n enumerable: true\r\n });\r\n\r\n var search = void 0;\r\n Object.defineProperty(this, '_updateSearchParams', {\r\n enumerable: false,\r\n configurable: false,\r\n writable: false,\r\n value: function() {\r\n if (this.search !== search) {\r\n search = this.search;\r\n if (enableSearchParamsUpdate) {\r\n enableSearchUpdate = false;\r\n this.searchParams._fromString(this.search);\r\n enableSearchUpdate = true;\r\n }\r\n }\r\n }\r\n });\r\n };\r\n\r\n var proto = URL.prototype;\r\n\r\n var linkURLWithAnchorAttribute = function(attributeName) {\r\n Object.defineProperty(proto, attributeName, {\r\n get: function() {\r\n return this._anchorElement[attributeName];\r\n },\r\n set: function(value) {\r\n this._anchorElement[attributeName] = value;\r\n },\r\n enumerable: true\r\n });\r\n };\r\n\r\n ['hash', 'host', 'hostname', 'port', 'protocol']\r\n .forEach(function(attributeName) {\r\n linkURLWithAnchorAttribute(attributeName);\r\n });\r\n\r\n Object.defineProperty(proto, 'search', {\r\n get: function() {\r\n return this._anchorElement['search'];\r\n },\r\n set: function(value) {\r\n this._anchorElement['search'] = value;\r\n this._updateSearchParams();\r\n },\r\n enumerable: true\r\n });\r\n\r\n Object.defineProperties(proto, {\r\n\r\n 'toString': {\r\n get: function() {\r\n var _this = this;\r\n return function() {\r\n return _this.href;\r\n };\r\n }\r\n },\r\n\r\n 'href': {\r\n get: function() {\r\n return this._anchorElement.href.replace(/\\?$/, '');\r\n },\r\n set: function(value) {\r\n this._anchorElement.href = value;\r\n this._updateSearchParams();\r\n },\r\n enumerable: true\r\n },\r\n\r\n 'pathname': {\r\n get: function() {\r\n return this._anchorElement.pathname.replace(/(^\\/?)/, '/');\r\n },\r\n set: function(value) {\r\n this._anchorElement.pathname = value;\r\n },\r\n enumerable: true\r\n },\r\n\r\n 'origin': {\r\n get: function() {\r\n // get expected port from protocol\r\n var expectedPort = { 'http:': 80, 'https:': 443, 'ftp:': 21 }[this._anchorElement.protocol];\r\n // add port to origin if, expected port is different than actual port\r\n // and it is not empty f.e http://foo:8080\r\n // 8080 != 80 && 8080 != ''\r\n var addPortToOrigin = this._anchorElement.port != expectedPort &&\r\n this._anchorElement.port !== '';\r\n\r\n return this._anchorElement.protocol +\r\n '//' +\r\n this._anchorElement.hostname +\r\n (addPortToOrigin ? (':' + this._anchorElement.port) : '');\r\n },\r\n enumerable: true\r\n },\r\n\r\n 'password': { // TODO\r\n get: function() {\r\n return '';\r\n },\r\n set: function(value) {\r\n },\r\n enumerable: true\r\n },\r\n\r\n 'username': { // TODO\r\n get: function() {\r\n return '';\r\n },\r\n set: function(value) {\r\n },\r\n enumerable: true\r\n },\r\n });\r\n\r\n URL.createObjectURL = function(blob) {\r\n return _URL.createObjectURL.apply(_URL, arguments);\r\n };\r\n\r\n URL.revokeObjectURL = function(url) {\r\n return _URL.revokeObjectURL.apply(_URL, arguments);\r\n };\r\n\r\n global.URL = URL;\r\n\r\n };\r\n\r\n if (!checkIfURLIsSupported()) {\r\n polyfillURL();\r\n }\r\n\r\n if ((global.location !== void 0) && !('origin' in global.location)) {\r\n var getOrigin = function() {\r\n return global.location.protocol + '//' + global.location.hostname + (global.location.port ? (':' + global.location.port) : '');\r\n };\r\n\r\n try {\r\n Object.defineProperty(global.location, 'origin', {\r\n get: getOrigin,\r\n enumerable: true\r\n });\r\n } catch (e) {\r\n setInterval(function() {\r\n global.location.origin = getOrigin();\r\n }, 100);\r\n }\r\n }\r\n\r\n})(\r\n (typeof global !== 'undefined') ? global\r\n : ((typeof window !== 'undefined') ? window\r\n : ((typeof self !== 'undefined') ? self : this))\r\n);\r\n", "/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global global, define, System, Reflect, Promise */\r\nvar __extends;\r\nvar __assign;\r\nvar __rest;\r\nvar __decorate;\r\nvar __param;\r\nvar __metadata;\r\nvar __awaiter;\r\nvar __generator;\r\nvar __exportStar;\r\nvar __values;\r\nvar __read;\r\nvar __spread;\r\nvar __spreadArrays;\r\nvar __spreadArray;\r\nvar __await;\r\nvar __asyncGenerator;\r\nvar __asyncDelegator;\r\nvar __asyncValues;\r\nvar __makeTemplateObject;\r\nvar __importStar;\r\nvar __importDefault;\r\nvar __classPrivateFieldGet;\r\nvar __classPrivateFieldSet;\r\nvar __createBinding;\r\n(function (factory) {\r\n var root = typeof global === \"object\" ? global : typeof self === \"object\" ? self : typeof this === \"object\" ? this : {};\r\n if (typeof define === \"function\" && define.amd) {\r\n define(\"tslib\", [\"exports\"], function (exports) { factory(createExporter(root, createExporter(exports))); });\r\n }\r\n else if (typeof module === \"object\" && typeof module.exports === \"object\") {\r\n factory(createExporter(root, createExporter(module.exports)));\r\n }\r\n else {\r\n factory(createExporter(root));\r\n }\r\n function createExporter(exports, previous) {\r\n if (exports !== root) {\r\n if (typeof Object.create === \"function\") {\r\n Object.defineProperty(exports, \"__esModule\", { value: true });\r\n }\r\n else {\r\n exports.__esModule = true;\r\n }\r\n }\r\n return function (id, v) { return exports[id] = previous ? previous(id, v) : v; };\r\n }\r\n})\r\n(function (exporter) {\r\n var extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n\r\n __extends = function (d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n\r\n __assign = Object.assign || function (t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n\r\n __rest = function (s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n };\r\n\r\n __decorate = function (decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n };\r\n\r\n __param = function (paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n };\r\n\r\n __metadata = function (metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n };\r\n\r\n __awaiter = function (thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n };\r\n\r\n __generator = function (thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n };\r\n\r\n __exportStar = function(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n };\r\n\r\n __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n }) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n });\r\n\r\n __values = function (o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n };\r\n\r\n __read = function (o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n };\r\n\r\n /** @deprecated */\r\n __spread = function () {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n };\r\n\r\n /** @deprecated */\r\n __spreadArrays = function () {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n };\r\n\r\n __spreadArray = function (to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n };\r\n\r\n __await = function (v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n };\r\n\r\n __asyncGenerator = function (thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n };\r\n\r\n __asyncDelegator = function (o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n };\r\n\r\n __asyncValues = function (o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n };\r\n\r\n __makeTemplateObject = function (cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n };\r\n\r\n var __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n }) : function(o, v) {\r\n o[\"default\"] = v;\r\n };\r\n\r\n __importStar = function (mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n };\r\n\r\n __importDefault = function (mod) {\r\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\r\n };\r\n\r\n __classPrivateFieldGet = function (receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n };\r\n\r\n __classPrivateFieldSet = function (receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n };\r\n\r\n exporter(\"__extends\", __extends);\r\n exporter(\"__assign\", __assign);\r\n exporter(\"__rest\", __rest);\r\n exporter(\"__decorate\", __decorate);\r\n exporter(\"__param\", __param);\r\n exporter(\"__metadata\", __metadata);\r\n exporter(\"__awaiter\", __awaiter);\r\n exporter(\"__generator\", __generator);\r\n exporter(\"__exportStar\", __exportStar);\r\n exporter(\"__createBinding\", __createBinding);\r\n exporter(\"__values\", __values);\r\n exporter(\"__read\", __read);\r\n exporter(\"__spread\", __spread);\r\n exporter(\"__spreadArrays\", __spreadArrays);\r\n exporter(\"__spreadArray\", __spreadArray);\r\n exporter(\"__await\", __await);\r\n exporter(\"__asyncGenerator\", __asyncGenerator);\r\n exporter(\"__asyncDelegator\", __asyncDelegator);\r\n exporter(\"__asyncValues\", __asyncValues);\r\n exporter(\"__makeTemplateObject\", __makeTemplateObject);\r\n exporter(\"__importStar\", __importStar);\r\n exporter(\"__importDefault\", __importDefault);\r\n exporter(\"__classPrivateFieldGet\", __classPrivateFieldGet);\r\n exporter(\"__classPrivateFieldSet\", __classPrivateFieldSet);\r\n});\r\n", "/*!\n * clipboard.js v2.0.11\n * https://clipboardjs.com/\n *\n * Licensed MIT \u00A9 Zeno Rocha\n */\n(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"ClipboardJS\"] = factory();\n\telse\n\t\troot[\"ClipboardJS\"] = factory();\n})(this, function() {\nreturn /******/ (function() { // webpackBootstrap\n/******/ \tvar __webpack_modules__ = ({\n\n/***/ 686:\n/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n\n// EXPORTS\n__webpack_require__.d(__webpack_exports__, {\n \"default\": function() { return /* binding */ clipboard; }\n});\n\n// EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js\nvar tiny_emitter = __webpack_require__(279);\nvar tiny_emitter_default = /*#__PURE__*/__webpack_require__.n(tiny_emitter);\n// EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js\nvar listen = __webpack_require__(370);\nvar listen_default = /*#__PURE__*/__webpack_require__.n(listen);\n// EXTERNAL MODULE: ./node_modules/select/src/select.js\nvar src_select = __webpack_require__(817);\nvar select_default = /*#__PURE__*/__webpack_require__.n(src_select);\n;// CONCATENATED MODULE: ./src/common/command.js\n/**\n * Executes a given operation type.\n * @param {String} type\n * @return {Boolean}\n */\nfunction command(type) {\n try {\n return document.execCommand(type);\n } catch (err) {\n return false;\n }\n}\n;// CONCATENATED MODULE: ./src/actions/cut.js\n\n\n/**\n * Cut action wrapper.\n * @param {String|HTMLElement} target\n * @return {String}\n */\n\nvar ClipboardActionCut = function ClipboardActionCut(target) {\n var selectedText = select_default()(target);\n command('cut');\n return selectedText;\n};\n\n/* harmony default export */ var actions_cut = (ClipboardActionCut);\n;// CONCATENATED MODULE: ./src/common/create-fake-element.js\n/**\n * Creates a fake textarea element with a value.\n * @param {String} value\n * @return {HTMLElement}\n */\nfunction createFakeElement(value) {\n var isRTL = document.documentElement.getAttribute('dir') === 'rtl';\n var fakeElement = document.createElement('textarea'); // Prevent zooming on iOS\n\n fakeElement.style.fontSize = '12pt'; // Reset box model\n\n fakeElement.style.border = '0';\n fakeElement.style.padding = '0';\n fakeElement.style.margin = '0'; // Move element out of screen horizontally\n\n fakeElement.style.position = 'absolute';\n fakeElement.style[isRTL ? 'right' : 'left'] = '-9999px'; // Move element to the same position vertically\n\n var yPosition = window.pageYOffset || document.documentElement.scrollTop;\n fakeElement.style.top = \"\".concat(yPosition, \"px\");\n fakeElement.setAttribute('readonly', '');\n fakeElement.value = value;\n return fakeElement;\n}\n;// CONCATENATED MODULE: ./src/actions/copy.js\n\n\n\n/**\n * Create fake copy action wrapper using a fake element.\n * @param {String} target\n * @param {Object} options\n * @return {String}\n */\n\nvar fakeCopyAction = function fakeCopyAction(value, options) {\n var fakeElement = createFakeElement(value);\n options.container.appendChild(fakeElement);\n var selectedText = select_default()(fakeElement);\n command('copy');\n fakeElement.remove();\n return selectedText;\n};\n/**\n * Copy action wrapper.\n * @param {String|HTMLElement} target\n * @param {Object} options\n * @return {String}\n */\n\n\nvar ClipboardActionCopy = function ClipboardActionCopy(target) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {\n container: document.body\n };\n var selectedText = '';\n\n if (typeof target === 'string') {\n selectedText = fakeCopyAction(target, options);\n } else if (target instanceof HTMLInputElement && !['text', 'search', 'url', 'tel', 'password'].includes(target === null || target === void 0 ? void 0 : target.type)) {\n // If input type doesn't support `setSelectionRange`. Simulate it. https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange\n selectedText = fakeCopyAction(target.value, options);\n } else {\n selectedText = select_default()(target);\n command('copy');\n }\n\n return selectedText;\n};\n\n/* harmony default export */ var actions_copy = (ClipboardActionCopy);\n;// CONCATENATED MODULE: ./src/actions/default.js\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\n\n\n/**\n * Inner function which performs selection from either `text` or `target`\n * properties and then executes copy or cut operations.\n * @param {Object} options\n */\n\nvar ClipboardActionDefault = function ClipboardActionDefault() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n // Defines base properties passed from constructor.\n var _options$action = options.action,\n action = _options$action === void 0 ? 'copy' : _options$action,\n container = options.container,\n target = options.target,\n text = options.text; // Sets the `action` to be performed which can be either 'copy' or 'cut'.\n\n if (action !== 'copy' && action !== 'cut') {\n throw new Error('Invalid \"action\" value, use either \"copy\" or \"cut\"');\n } // Sets the `target` property using an element that will be have its content copied.\n\n\n if (target !== undefined) {\n if (target && _typeof(target) === 'object' && target.nodeType === 1) {\n if (action === 'copy' && target.hasAttribute('disabled')) {\n throw new Error('Invalid \"target\" attribute. Please use \"readonly\" instead of \"disabled\" attribute');\n }\n\n if (action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {\n throw new Error('Invalid \"target\" attribute. You can\\'t cut text from elements with \"readonly\" or \"disabled\" attributes');\n }\n } else {\n throw new Error('Invalid \"target\" value, use a valid Element');\n }\n } // Define selection strategy based on `text` property.\n\n\n if (text) {\n return actions_copy(text, {\n container: container\n });\n } // Defines which selection strategy based on `target` property.\n\n\n if (target) {\n return action === 'cut' ? actions_cut(target) : actions_copy(target, {\n container: container\n });\n }\n};\n\n/* harmony default export */ var actions_default = (ClipboardActionDefault);\n;// CONCATENATED MODULE: ./src/clipboard.js\nfunction clipboard_typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { clipboard_typeof = function _typeof(obj) { return typeof obj; }; } else { clipboard_typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return clipboard_typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (clipboard_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n\n\n/**\n * Helper function to retrieve attribute value.\n * @param {String} suffix\n * @param {Element} element\n */\n\nfunction getAttributeValue(suffix, element) {\n var attribute = \"data-clipboard-\".concat(suffix);\n\n if (!element.hasAttribute(attribute)) {\n return;\n }\n\n return element.getAttribute(attribute);\n}\n/**\n * Base class which takes one or more elements, adds event listeners to them,\n * and instantiates a new `ClipboardAction` on each click.\n */\n\n\nvar Clipboard = /*#__PURE__*/function (_Emitter) {\n _inherits(Clipboard, _Emitter);\n\n var _super = _createSuper(Clipboard);\n\n /**\n * @param {String|HTMLElement|HTMLCollection|NodeList} trigger\n * @param {Object} options\n */\n function Clipboard(trigger, options) {\n var _this;\n\n _classCallCheck(this, Clipboard);\n\n _this = _super.call(this);\n\n _this.resolveOptions(options);\n\n _this.listenClick(trigger);\n\n return _this;\n }\n /**\n * Defines if attributes would be resolved using internal setter functions\n * or custom functions that were passed in the constructor.\n * @param {Object} options\n */\n\n\n _createClass(Clipboard, [{\n key: \"resolveOptions\",\n value: function resolveOptions() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.action = typeof options.action === 'function' ? options.action : this.defaultAction;\n this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;\n this.text = typeof options.text === 'function' ? options.text : this.defaultText;\n this.container = clipboard_typeof(options.container) === 'object' ? options.container : document.body;\n }\n /**\n * Adds a click event listener to the passed trigger.\n * @param {String|HTMLElement|HTMLCollection|NodeList} trigger\n */\n\n }, {\n key: \"listenClick\",\n value: function listenClick(trigger) {\n var _this2 = this;\n\n this.listener = listen_default()(trigger, 'click', function (e) {\n return _this2.onClick(e);\n });\n }\n /**\n * Defines a new `ClipboardAction` on each click event.\n * @param {Event} e\n */\n\n }, {\n key: \"onClick\",\n value: function onClick(e) {\n var trigger = e.delegateTarget || e.currentTarget;\n var action = this.action(trigger) || 'copy';\n var text = actions_default({\n action: action,\n container: this.container,\n target: this.target(trigger),\n text: this.text(trigger)\n }); // Fires an event based on the copy operation result.\n\n this.emit(text ? 'success' : 'error', {\n action: action,\n text: text,\n trigger: trigger,\n clearSelection: function clearSelection() {\n if (trigger) {\n trigger.focus();\n }\n\n window.getSelection().removeAllRanges();\n }\n });\n }\n /**\n * Default `action` lookup function.\n * @param {Element} trigger\n */\n\n }, {\n key: \"defaultAction\",\n value: function defaultAction(trigger) {\n return getAttributeValue('action', trigger);\n }\n /**\n * Default `target` lookup function.\n * @param {Element} trigger\n */\n\n }, {\n key: \"defaultTarget\",\n value: function defaultTarget(trigger) {\n var selector = getAttributeValue('target', trigger);\n\n if (selector) {\n return document.querySelector(selector);\n }\n }\n /**\n * Allow fire programmatically a copy action\n * @param {String|HTMLElement} target\n * @param {Object} options\n * @returns Text copied.\n */\n\n }, {\n key: \"defaultText\",\n\n /**\n * Default `text` lookup function.\n * @param {Element} trigger\n */\n value: function defaultText(trigger) {\n return getAttributeValue('text', trigger);\n }\n /**\n * Destroy lifecycle.\n */\n\n }, {\n key: \"destroy\",\n value: function destroy() {\n this.listener.destroy();\n }\n }], [{\n key: \"copy\",\n value: function copy(target) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {\n container: document.body\n };\n return actions_copy(target, options);\n }\n /**\n * Allow fire programmatically a cut action\n * @param {String|HTMLElement} target\n * @returns Text cutted.\n */\n\n }, {\n key: \"cut\",\n value: function cut(target) {\n return actions_cut(target);\n }\n /**\n * Returns the support of the given action, or all actions if no action is\n * given.\n * @param {String} [action]\n */\n\n }, {\n key: \"isSupported\",\n value: function isSupported() {\n var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];\n var actions = typeof action === 'string' ? [action] : action;\n var support = !!document.queryCommandSupported;\n actions.forEach(function (action) {\n support = support && !!document.queryCommandSupported(action);\n });\n return support;\n }\n }]);\n\n return Clipboard;\n}((tiny_emitter_default()));\n\n/* harmony default export */ var clipboard = (Clipboard);\n\n/***/ }),\n\n/***/ 828:\n/***/ (function(module) {\n\nvar DOCUMENT_NODE_TYPE = 9;\n\n/**\n * A polyfill for Element.matches()\n */\nif (typeof Element !== 'undefined' && !Element.prototype.matches) {\n var proto = Element.prototype;\n\n proto.matches = proto.matchesSelector ||\n proto.mozMatchesSelector ||\n proto.msMatchesSelector ||\n proto.oMatchesSelector ||\n proto.webkitMatchesSelector;\n}\n\n/**\n * Finds the closest parent that matches a selector.\n *\n * @param {Element} element\n * @param {String} selector\n * @return {Function}\n */\nfunction closest (element, selector) {\n while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {\n if (typeof element.matches === 'function' &&\n element.matches(selector)) {\n return element;\n }\n element = element.parentNode;\n }\n}\n\nmodule.exports = closest;\n\n\n/***/ }),\n\n/***/ 438:\n/***/ (function(module, __unused_webpack_exports, __webpack_require__) {\n\nvar closest = __webpack_require__(828);\n\n/**\n * Delegates event to a selector.\n *\n * @param {Element} element\n * @param {String} selector\n * @param {String} type\n * @param {Function} callback\n * @param {Boolean} useCapture\n * @return {Object}\n */\nfunction _delegate(element, selector, type, callback, useCapture) {\n var listenerFn = listener.apply(this, arguments);\n\n element.addEventListener(type, listenerFn, useCapture);\n\n return {\n destroy: function() {\n element.removeEventListener(type, listenerFn, useCapture);\n }\n }\n}\n\n/**\n * Delegates event to a selector.\n *\n * @param {Element|String|Array} [elements]\n * @param {String} selector\n * @param {String} type\n * @param {Function} callback\n * @param {Boolean} useCapture\n * @return {Object}\n */\nfunction delegate(elements, selector, type, callback, useCapture) {\n // Handle the regular Element usage\n if (typeof elements.addEventListener === 'function') {\n return _delegate.apply(null, arguments);\n }\n\n // Handle Element-less usage, it defaults to global delegation\n if (typeof type === 'function') {\n // Use `document` as the first parameter, then apply arguments\n // This is a short way to .unshift `arguments` without running into deoptimizations\n return _delegate.bind(null, document).apply(null, arguments);\n }\n\n // Handle Selector-based usage\n if (typeof elements === 'string') {\n elements = document.querySelectorAll(elements);\n }\n\n // Handle Array-like based usage\n return Array.prototype.map.call(elements, function (element) {\n return _delegate(element, selector, type, callback, useCapture);\n });\n}\n\n/**\n * Finds closest match and invokes callback.\n *\n * @param {Element} element\n * @param {String} selector\n * @param {String} type\n * @param {Function} callback\n * @return {Function}\n */\nfunction listener(element, selector, type, callback) {\n return function(e) {\n e.delegateTarget = closest(e.target, selector);\n\n if (e.delegateTarget) {\n callback.call(element, e);\n }\n }\n}\n\nmodule.exports = delegate;\n\n\n/***/ }),\n\n/***/ 879:\n/***/ (function(__unused_webpack_module, exports) {\n\n/**\n * Check if argument is a HTML element.\n *\n * @param {Object} value\n * @return {Boolean}\n */\nexports.node = function(value) {\n return value !== undefined\n && value instanceof HTMLElement\n && value.nodeType === 1;\n};\n\n/**\n * Check if argument is a list of HTML elements.\n *\n * @param {Object} value\n * @return {Boolean}\n */\nexports.nodeList = function(value) {\n var type = Object.prototype.toString.call(value);\n\n return value !== undefined\n && (type === '[object NodeList]' || type === '[object HTMLCollection]')\n && ('length' in value)\n && (value.length === 0 || exports.node(value[0]));\n};\n\n/**\n * Check if argument is a string.\n *\n * @param {Object} value\n * @return {Boolean}\n */\nexports.string = function(value) {\n return typeof value === 'string'\n || value instanceof String;\n};\n\n/**\n * Check if argument is a function.\n *\n * @param {Object} value\n * @return {Boolean}\n */\nexports.fn = function(value) {\n var type = Object.prototype.toString.call(value);\n\n return type === '[object Function]';\n};\n\n\n/***/ }),\n\n/***/ 370:\n/***/ (function(module, __unused_webpack_exports, __webpack_require__) {\n\nvar is = __webpack_require__(879);\nvar delegate = __webpack_require__(438);\n\n/**\n * Validates all params and calls the right\n * listener function based on its target type.\n *\n * @param {String|HTMLElement|HTMLCollection|NodeList} target\n * @param {String} type\n * @param {Function} callback\n * @return {Object}\n */\nfunction listen(target, type, callback) {\n if (!target && !type && !callback) {\n throw new Error('Missing required arguments');\n }\n\n if (!is.string(type)) {\n throw new TypeError('Second argument must be a String');\n }\n\n if (!is.fn(callback)) {\n throw new TypeError('Third argument must be a Function');\n }\n\n if (is.node(target)) {\n return listenNode(target, type, callback);\n }\n else if (is.nodeList(target)) {\n return listenNodeList(target, type, callback);\n }\n else if (is.string(target)) {\n return listenSelector(target, type, callback);\n }\n else {\n throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');\n }\n}\n\n/**\n * Adds an event listener to a HTML element\n * and returns a remove listener function.\n *\n * @param {HTMLElement} node\n * @param {String} type\n * @param {Function} callback\n * @return {Object}\n */\nfunction listenNode(node, type, callback) {\n node.addEventListener(type, callback);\n\n return {\n destroy: function() {\n node.removeEventListener(type, callback);\n }\n }\n}\n\n/**\n * Add an event listener to a list of HTML elements\n * and returns a remove listener function.\n *\n * @param {NodeList|HTMLCollection} nodeList\n * @param {String} type\n * @param {Function} callback\n * @return {Object}\n */\nfunction listenNodeList(nodeList, type, callback) {\n Array.prototype.forEach.call(nodeList, function(node) {\n node.addEventListener(type, callback);\n });\n\n return {\n destroy: function() {\n Array.prototype.forEach.call(nodeList, function(node) {\n node.removeEventListener(type, callback);\n });\n }\n }\n}\n\n/**\n * Add an event listener to a selector\n * and returns a remove listener function.\n *\n * @param {String} selector\n * @param {String} type\n * @param {Function} callback\n * @return {Object}\n */\nfunction listenSelector(selector, type, callback) {\n return delegate(document.body, selector, type, callback);\n}\n\nmodule.exports = listen;\n\n\n/***/ }),\n\n/***/ 817:\n/***/ (function(module) {\n\nfunction select(element) {\n var selectedText;\n\n if (element.nodeName === 'SELECT') {\n element.focus();\n\n selectedText = element.value;\n }\n else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {\n var isReadOnly = element.hasAttribute('readonly');\n\n if (!isReadOnly) {\n element.setAttribute('readonly', '');\n }\n\n element.select();\n element.setSelectionRange(0, element.value.length);\n\n if (!isReadOnly) {\n element.removeAttribute('readonly');\n }\n\n selectedText = element.value;\n }\n else {\n if (element.hasAttribute('contenteditable')) {\n element.focus();\n }\n\n var selection = window.getSelection();\n var range = document.createRange();\n\n range.selectNodeContents(element);\n selection.removeAllRanges();\n selection.addRange(range);\n\n selectedText = selection.toString();\n }\n\n return selectedText;\n}\n\nmodule.exports = select;\n\n\n/***/ }),\n\n/***/ 279:\n/***/ (function(module) {\n\nfunction E () {\n // Keep this empty so it's easier to inherit from\n // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)\n}\n\nE.prototype = {\n on: function (name, callback, ctx) {\n var e = this.e || (this.e = {});\n\n (e[name] || (e[name] = [])).push({\n fn: callback,\n ctx: ctx\n });\n\n return this;\n },\n\n once: function (name, callback, ctx) {\n var self = this;\n function listener () {\n self.off(name, listener);\n callback.apply(ctx, arguments);\n };\n\n listener._ = callback\n return this.on(name, listener, ctx);\n },\n\n emit: function (name) {\n var data = [].slice.call(arguments, 1);\n var evtArr = ((this.e || (this.e = {}))[name] || []).slice();\n var i = 0;\n var len = evtArr.length;\n\n for (i; i < len; i++) {\n evtArr[i].fn.apply(evtArr[i].ctx, data);\n }\n\n return this;\n },\n\n off: function (name, callback) {\n var e = this.e || (this.e = {});\n var evts = e[name];\n var liveEvents = [];\n\n if (evts && callback) {\n for (var i = 0, len = evts.length; i < len; i++) {\n if (evts[i].fn !== callback && evts[i].fn._ !== callback)\n liveEvents.push(evts[i]);\n }\n }\n\n // Remove event from queue to prevent memory leak\n // Suggested by https://github.com/lazd\n // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910\n\n (liveEvents.length)\n ? e[name] = liveEvents\n : delete e[name];\n\n return this;\n }\n};\n\nmodule.exports = E;\nmodule.exports.TinyEmitter = E;\n\n\n/***/ })\n\n/******/ \t});\n/************************************************************************/\n/******/ \t// The module cache\n/******/ \tvar __webpack_module_cache__ = {};\n/******/ \t\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(__webpack_module_cache__[moduleId]) {\n/******/ \t\t\treturn __webpack_module_cache__[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = __webpack_module_cache__[moduleId] = {\n/******/ \t\t\t// no module.id needed\n/******/ \t\t\t// no module.loaded needed\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/ \t\n/******/ \t\t// Execute the module function\n/******/ \t\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n/******/ \t\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/ \t\n/************************************************************************/\n/******/ \t/* webpack/runtime/compat get default export */\n/******/ \t!function() {\n/******/ \t\t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t\t__webpack_require__.n = function(module) {\n/******/ \t\t\tvar getter = module && module.__esModule ?\n/******/ \t\t\t\tfunction() { return module['default']; } :\n/******/ \t\t\t\tfunction() { return module; };\n/******/ \t\t\t__webpack_require__.d(getter, { a: getter });\n/******/ \t\t\treturn getter;\n/******/ \t\t};\n/******/ \t}();\n/******/ \t\n/******/ \t/* webpack/runtime/define property getters */\n/******/ \t!function() {\n/******/ \t\t// define getter functions for harmony exports\n/******/ \t\t__webpack_require__.d = function(exports, definition) {\n/******/ \t\t\tfor(var key in definition) {\n/******/ \t\t\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n/******/ \t\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n/******/ \t\t\t\t}\n/******/ \t\t\t}\n/******/ \t\t};\n/******/ \t}();\n/******/ \t\n/******/ \t/* webpack/runtime/hasOwnProperty shorthand */\n/******/ \t!function() {\n/******/ \t\t__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }\n/******/ \t}();\n/******/ \t\n/************************************************************************/\n/******/ \t// module exports must be returned from runtime so entry inlining is disabled\n/******/ \t// startup\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(686);\n/******/ })()\n.default;\n});", "/*!\n * escape-html\n * Copyright(c) 2012-2013 TJ Holowaychuk\n * Copyright(c) 2015 Andreas Lubbe\n * Copyright(c) 2015 Tiancheng \"Timothy\" Gu\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module variables.\n * @private\n */\n\nvar matchHtmlRegExp = /[\"'&<>]/;\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = escapeHtml;\n\n/**\n * Escape special characters in the given string of html.\n *\n * @param {string} string The string to escape for inserting into HTML\n * @return {string}\n * @public\n */\n\nfunction escapeHtml(string) {\n var str = '' + string;\n var match = matchHtmlRegExp.exec(str);\n\n if (!match) {\n return str;\n }\n\n var escape;\n var html = '';\n var index = 0;\n var lastIndex = 0;\n\n for (index = match.index; index < str.length; index++) {\n switch (str.charCodeAt(index)) {\n case 34: // \"\n escape = '"';\n break;\n case 38: // &\n escape = '&';\n break;\n case 39: // '\n escape = ''';\n break;\n case 60: // <\n escape = '<';\n break;\n case 62: // >\n escape = '>';\n break;\n default:\n continue;\n }\n\n if (lastIndex !== index) {\n html += str.substring(lastIndex, index);\n }\n\n lastIndex = index + 1;\n html += escape;\n }\n\n return lastIndex !== index\n ? html + str.substring(lastIndex, index)\n : html;\n}\n", "Array.prototype.flat||Object.defineProperty(Array.prototype,\"flat\",{configurable:!0,value:function r(){var t=isNaN(arguments[0])?1:Number(arguments[0]);return t?Array.prototype.reduce.call(this,function(a,e){return Array.isArray(e)?a.push.apply(a,r.call(e,t-1)):a.push(e),a},[]):Array.prototype.slice.call(this)},writable:!0}),Array.prototype.flatMap||Object.defineProperty(Array.prototype,\"flatMap\",{configurable:!0,value:function(r){return Array.prototype.map.apply(this,arguments).flat()},writable:!0})\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport \"array-flat-polyfill\"\nimport \"focus-visible\"\nimport \"unfetch/polyfill\"\nimport \"url-polyfill\"\n\nimport {\n EMPTY,\n NEVER,\n Subject,\n defer,\n delay,\n filter,\n map,\n merge,\n mergeWith,\n shareReplay,\n switchMap\n} from \"rxjs\"\n\nimport { configuration, feature } from \"./_\"\nimport {\n at,\n getOptionalElement,\n requestJSON,\n setToggle,\n watchDocument,\n watchKeyboard,\n watchLocation,\n watchLocationTarget,\n watchMedia,\n watchPrint,\n watchViewport\n} from \"./browser\"\nimport {\n getComponentElement,\n getComponentElements,\n mountAnnounce,\n mountBackToTop,\n mountConsent,\n mountContent,\n mountDialog,\n mountHeader,\n mountHeaderTitle,\n mountPalette,\n mountSearch,\n mountSearchHiglight,\n mountSidebar,\n mountSource,\n mountTableOfContents,\n mountTabs,\n watchHeader,\n watchMain\n} from \"./components\"\nimport {\n SearchIndex,\n setupClipboardJS,\n setupInstantLoading,\n setupVersionSelector\n} from \"./integrations\"\nimport {\n patchIndeterminate,\n patchScrollfix,\n patchScrolllock\n} from \"./patches\"\nimport \"./polyfills\"\n\n/* ----------------------------------------------------------------------------\n * Application\n * ------------------------------------------------------------------------- */\n\n/* Yay, JavaScript is available */\ndocument.documentElement.classList.remove(\"no-js\")\ndocument.documentElement.classList.add(\"js\")\n\n/* Set up navigation observables and subjects */\nconst document$ = watchDocument()\nconst location$ = watchLocation()\nconst target$ = watchLocationTarget()\nconst keyboard$ = watchKeyboard()\n\n/* Set up media observables */\nconst viewport$ = watchViewport()\nconst tablet$ = watchMedia(\"(min-width: 960px)\")\nconst screen$ = watchMedia(\"(min-width: 1220px)\")\nconst print$ = watchPrint()\n\n/* Retrieve search index, if search is enabled */\nconst config = configuration()\nconst index$ = document.forms.namedItem(\"search\")\n ? __search?.index || requestJSON(\n new URL(\"search/search_index.json\", config.base)\n )\n : NEVER\n\n/* Set up Clipboard.js integration */\nconst alert$ = new Subject()\nsetupClipboardJS({ alert$ })\n\n/* Set up instant loading, if enabled */\nif (feature(\"navigation.instant\"))\n setupInstantLoading({ document$, location$, viewport$ })\n\n/* Set up version selector */\nif (config.version?.provider === \"mike\")\n setupVersionSelector({ document$ })\n\n/* Always close drawer and search on navigation */\nmerge(location$, target$)\n .pipe(\n delay(125)\n )\n .subscribe(() => {\n setToggle(\"drawer\", false)\n setToggle(\"search\", false)\n })\n\n/* Set up global keyboard handlers */\nkeyboard$\n .pipe(\n filter(({ mode }) => mode === \"global\")\n )\n .subscribe(key => {\n switch (key.type) {\n\n /* Go to previous page */\n case \"p\":\n case \",\":\n const prev = getOptionalElement(\"[href][rel=prev]\")\n if (typeof prev !== \"undefined\")\n prev.click()\n break\n\n /* Go to next page */\n case \"n\":\n case \".\":\n const next = getOptionalElement(\"[href][rel=next]\")\n if (typeof next !== \"undefined\")\n next.click()\n break\n }\n })\n\n/* Set up patches */\npatchIndeterminate({ document$, tablet$ })\npatchScrollfix({ document$ })\npatchScrolllock({ viewport$, tablet$ })\n\n/* Set up header and main area observable */\nconst header$ = watchHeader(getComponentElement(\"header\"), { viewport$ })\nconst main$ = document$\n .pipe(\n map(() => getComponentElement(\"main\")),\n switchMap(el => watchMain(el, { viewport$, header$ })),\n shareReplay(1)\n )\n\n/* Set up control component observables */\nconst control$ = merge(\n\n /* Consent */\n ...getComponentElements(\"consent\")\n .map(el => mountConsent(el, { target$ })),\n\n /* Dialog */\n ...getComponentElements(\"dialog\")\n .map(el => mountDialog(el, { alert$ })),\n\n /* Header */\n ...getComponentElements(\"header\")\n .map(el => mountHeader(el, { viewport$, header$, main$ })),\n\n /* Color palette */\n ...getComponentElements(\"palette\")\n .map(el => mountPalette(el)),\n\n /* Search */\n ...getComponentElements(\"search\")\n .map(el => mountSearch(el, { index$, keyboard$ })),\n\n /* Repository information */\n ...getComponentElements(\"source\")\n .map(el => mountSource(el))\n)\n\n/* Set up content component observables */\nconst content$ = defer(() => merge(\n\n /* Announcement bar */\n ...getComponentElements(\"announce\")\n .map(el => mountAnnounce(el)),\n\n /* Content */\n ...getComponentElements(\"content\")\n .map(el => mountContent(el, { viewport$, target$, print$ })),\n\n /* Search highlighting */\n ...getComponentElements(\"content\")\n .map(el => feature(\"search.highlight\")\n ? mountSearchHiglight(el, { index$, location$ })\n : EMPTY\n ),\n\n /* Header title */\n ...getComponentElements(\"header-title\")\n .map(el => mountHeaderTitle(el, { viewport$, header$ })),\n\n /* Sidebar */\n ...getComponentElements(\"sidebar\")\n .map(el => el.getAttribute(\"data-md-type\") === \"navigation\"\n ? at(screen$, () => mountSidebar(el, { viewport$, header$, main$ }))\n : at(tablet$, () => mountSidebar(el, { viewport$, header$, main$ }))\n ),\n\n /* Navigation tabs */\n ...getComponentElements(\"tabs\")\n .map(el => mountTabs(el, { viewport$, header$ })),\n\n /* Table of contents */\n ...getComponentElements(\"toc\")\n .map(el => mountTableOfContents(el, { viewport$, header$, target$ })),\n\n /* Back-to-top button */\n ...getComponentElements(\"top\")\n .map(el => mountBackToTop(el, { viewport$, header$, main$, target$ }))\n))\n\n/* Set up component observables */\nconst component$ = document$\n .pipe(\n switchMap(() => content$),\n mergeWith(control$),\n shareReplay(1)\n )\n\n/* Subscribe to all components */\ncomponent$.subscribe()\n\n/* ----------------------------------------------------------------------------\n * Exports\n * ------------------------------------------------------------------------- */\n\nwindow.document$ = document$ /* Document observable */\nwindow.location$ = location$ /* Location subject */\nwindow.target$ = target$ /* Location target observable */\nwindow.keyboard$ = keyboard$ /* Keyboard observable */\nwindow.viewport$ = viewport$ /* Viewport observable */\nwindow.tablet$ = tablet$ /* Media tablet observable */\nwindow.screen$ = screen$ /* Media screen observable */\nwindow.print$ = print$ /* Media print observable */\nwindow.alert$ = alert$ /* Alert subject */\nwindow.component$ = component$ /* Component observable */\n", "self.fetch||(self.fetch=function(e,n){return n=n||{},new Promise(function(t,s){var r=new XMLHttpRequest,o=[],u=[],i={},a=function(){return{ok:2==(r.status/100|0),statusText:r.statusText,status:r.status,url:r.responseURL,text:function(){return Promise.resolve(r.responseText)},json:function(){return Promise.resolve(r.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([r.response]))},clone:a,headers:{keys:function(){return o},entries:function(){return u},get:function(e){return i[e.toLowerCase()]},has:function(e){return e.toLowerCase()in i}}}};for(var c in r.open(n.method||\"get\",e,!0),r.onload=function(){r.getAllResponseHeaders().replace(/^(.*?):[^\\S\\n]*([\\s\\S]*?)$/gm,function(e,n,t){o.push(n=n.toLowerCase()),u.push([n,t]),i[n]=i[n]?i[n]+\",\"+t:t}),t(a())},r.onerror=s,r.withCredentials=\"include\"==n.credentials,n.headers)r.setRequestHeader(c,n.headers[c]);r.send(n.body||null)})});\n", "import tslib from '../tslib.js';\r\nconst {\r\n __extends,\r\n __assign,\r\n __rest,\r\n __decorate,\r\n __param,\r\n __metadata,\r\n __awaiter,\r\n __generator,\r\n __exportStar,\r\n __createBinding,\r\n __values,\r\n __read,\r\n __spread,\r\n __spreadArrays,\r\n __spreadArray,\r\n __await,\r\n __asyncGenerator,\r\n __asyncDelegator,\r\n __asyncValues,\r\n __makeTemplateObject,\r\n __importStar,\r\n __importDefault,\r\n __classPrivateFieldGet,\r\n __classPrivateFieldSet,\r\n} = tslib;\r\nexport {\r\n __extends,\r\n __assign,\r\n __rest,\r\n __decorate,\r\n __param,\r\n __metadata,\r\n __awaiter,\r\n __generator,\r\n __exportStar,\r\n __createBinding,\r\n __values,\r\n __read,\r\n __spread,\r\n __spreadArrays,\r\n __spreadArray,\r\n __await,\r\n __asyncGenerator,\r\n __asyncDelegator,\r\n __asyncValues,\r\n __makeTemplateObject,\r\n __importStar,\r\n __importDefault,\r\n __classPrivateFieldGet,\r\n __classPrivateFieldSet,\r\n};\r\n", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n ReplaySubject,\n Subject,\n fromEvent\n} from \"rxjs\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch document\n *\n * Documents are implemented as subjects, so all downstream observables are\n * automatically updated when a new document is emitted.\n *\n * @returns Document subject\n */\nexport function watchDocument(): Subject {\n const document$ = new ReplaySubject(1)\n fromEvent(document, \"DOMContentLoaded\", { once: true })\n .subscribe(() => document$.next(document))\n\n /* Return document */\n return document$\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve all elements matching the query selector\n *\n * @template T - Element type\n *\n * @param selector - Query selector\n * @param node - Node of reference\n *\n * @returns Elements\n */\nexport function getElements(\n selector: T, node?: ParentNode\n): HTMLElementTagNameMap[T][]\n\nexport function getElements(\n selector: string, node?: ParentNode\n): T[]\n\nexport function getElements(\n selector: string, node: ParentNode = document\n): T[] {\n return Array.from(node.querySelectorAll(selector))\n}\n\n/**\n * Retrieve an element matching a query selector or throw a reference error\n *\n * Note that this function assumes that the element is present. If unsure if an\n * element is existent, use the `getOptionalElement` function instead.\n *\n * @template T - Element type\n *\n * @param selector - Query selector\n * @param node - Node of reference\n *\n * @returns Element\n */\nexport function getElement(\n selector: T, node?: ParentNode\n): HTMLElementTagNameMap[T]\n\nexport function getElement(\n selector: string, node?: ParentNode\n): T\n\nexport function getElement(\n selector: string, node: ParentNode = document\n): T {\n const el = getOptionalElement(selector, node)\n if (typeof el === \"undefined\")\n throw new ReferenceError(\n `Missing element: expected \"${selector}\" to be present`\n )\n\n /* Return element */\n return el\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Retrieve an optional element matching the query selector\n *\n * @template T - Element type\n *\n * @param selector - Query selector\n * @param node - Node of reference\n *\n * @returns Element or nothing\n */\nexport function getOptionalElement(\n selector: T, node?: ParentNode\n): HTMLElementTagNameMap[T] | undefined\n\nexport function getOptionalElement(\n selector: string, node?: ParentNode\n): T | undefined\n\nexport function getOptionalElement(\n selector: string, node: ParentNode = document\n): T | undefined {\n return node.querySelector(selector) || undefined\n}\n\n/**\n * Retrieve the currently active element\n *\n * @returns Element or nothing\n */\nexport function getActiveElement(): HTMLElement | undefined {\n return document.activeElement instanceof HTMLElement\n ? document.activeElement || undefined\n : undefined\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n debounceTime,\n distinctUntilChanged,\n fromEvent,\n map,\n merge,\n startWith\n} from \"rxjs\"\n\nimport { getActiveElement } from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch element focus\n *\n * Previously, this function used `focus` and `blur` events to determine whether\n * an element is focused, but this doesn't work if there are focusable elements\n * within the elements itself. A better solutions are `focusin` and `focusout`\n * events, which bubble up the tree and allow for more fine-grained control.\n *\n * `debounceTime` is necessary, because when a focus change happens inside an\n * element, the observable would first emit `false` and then `true` again.\n *\n * @param el - Element\n *\n * @returns Element focus observable\n */\nexport function watchElementFocus(\n el: HTMLElement\n): Observable {\n return merge(\n fromEvent(document.body, \"focusin\"),\n fromEvent(document.body, \"focusout\")\n )\n .pipe(\n debounceTime(1),\n map(() => {\n const active = getActiveElement()\n return typeof active !== \"undefined\"\n ? el.contains(active)\n : false\n }),\n startWith(el === getActiveElement()),\n distinctUntilChanged()\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n animationFrameScheduler,\n auditTime,\n fromEvent,\n map,\n merge,\n startWith\n} from \"rxjs\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Element offset\n */\nexport interface ElementOffset {\n x: number /* Horizontal offset */\n y: number /* Vertical offset */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve element offset\n *\n * @param el - Element\n *\n * @returns Element offset\n */\nexport function getElementOffset(\n el: HTMLElement\n): ElementOffset {\n return {\n x: el.offsetLeft,\n y: el.offsetTop\n }\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Watch element offset\n *\n * @param el - Element\n *\n * @returns Element offset observable\n */\nexport function watchElementOffset(\n el: HTMLElement\n): Observable {\n return merge(\n fromEvent(window, \"load\"),\n fromEvent(window, \"resize\")\n )\n .pipe(\n auditTime(0, animationFrameScheduler),\n map(() => getElementOffset(el)),\n startWith(getElementOffset(el))\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n animationFrameScheduler,\n auditTime,\n fromEvent,\n map,\n merge,\n startWith\n} from \"rxjs\"\n\nimport { ElementOffset } from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve element content offset (= scroll offset)\n *\n * @param el - Element\n *\n * @returns Element content offset\n */\nexport function getElementContentOffset(\n el: HTMLElement\n): ElementOffset {\n return {\n x: el.scrollLeft,\n y: el.scrollTop\n }\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Watch element content offset\n *\n * @param el - Element\n *\n * @returns Element content offset observable\n */\nexport function watchElementContentOffset(\n el: HTMLElement\n): Observable {\n return merge(\n fromEvent(el, \"scroll\"),\n fromEvent(window, \"resize\")\n )\n .pipe(\n auditTime(0, animationFrameScheduler),\n map(() => getElementContentOffset(el)),\n startWith(getElementContentOffset(el))\n )\n}\n", "/**\r\n * A collection of shims that provide minimal functionality of the ES6 collections.\r\n *\r\n * These implementations are not meant to be used outside of the ResizeObserver\r\n * modules as they cover only a limited range of use cases.\r\n */\r\n/* eslint-disable require-jsdoc, valid-jsdoc */\r\nvar MapShim = (function () {\r\n if (typeof Map !== 'undefined') {\r\n return Map;\r\n }\r\n /**\r\n * Returns index in provided array that matches the specified key.\r\n *\r\n * @param {Array} arr\r\n * @param {*} key\r\n * @returns {number}\r\n */\r\n function getIndex(arr, key) {\r\n var result = -1;\r\n arr.some(function (entry, index) {\r\n if (entry[0] === key) {\r\n result = index;\r\n return true;\r\n }\r\n return false;\r\n });\r\n return result;\r\n }\r\n return /** @class */ (function () {\r\n function class_1() {\r\n this.__entries__ = [];\r\n }\r\n Object.defineProperty(class_1.prototype, \"size\", {\r\n /**\r\n * @returns {boolean}\r\n */\r\n get: function () {\r\n return this.__entries__.length;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * @param {*} key\r\n * @returns {*}\r\n */\r\n class_1.prototype.get = function (key) {\r\n var index = getIndex(this.__entries__, key);\r\n var entry = this.__entries__[index];\r\n return entry && entry[1];\r\n };\r\n /**\r\n * @param {*} key\r\n * @param {*} value\r\n * @returns {void}\r\n */\r\n class_1.prototype.set = function (key, value) {\r\n var index = getIndex(this.__entries__, key);\r\n if (~index) {\r\n this.__entries__[index][1] = value;\r\n }\r\n else {\r\n this.__entries__.push([key, value]);\r\n }\r\n };\r\n /**\r\n * @param {*} key\r\n * @returns {void}\r\n */\r\n class_1.prototype.delete = function (key) {\r\n var entries = this.__entries__;\r\n var index = getIndex(entries, key);\r\n if (~index) {\r\n entries.splice(index, 1);\r\n }\r\n };\r\n /**\r\n * @param {*} key\r\n * @returns {void}\r\n */\r\n class_1.prototype.has = function (key) {\r\n return !!~getIndex(this.__entries__, key);\r\n };\r\n /**\r\n * @returns {void}\r\n */\r\n class_1.prototype.clear = function () {\r\n this.__entries__.splice(0);\r\n };\r\n /**\r\n * @param {Function} callback\r\n * @param {*} [ctx=null]\r\n * @returns {void}\r\n */\r\n class_1.prototype.forEach = function (callback, ctx) {\r\n if (ctx === void 0) { ctx = null; }\r\n for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {\r\n var entry = _a[_i];\r\n callback.call(ctx, entry[1], entry[0]);\r\n }\r\n };\r\n return class_1;\r\n }());\r\n})();\n\n/**\r\n * Detects whether window and document objects are available in current environment.\r\n */\r\nvar isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && window.document === document;\n\n// Returns global object of a current environment.\r\nvar global$1 = (function () {\r\n if (typeof global !== 'undefined' && global.Math === Math) {\r\n return global;\r\n }\r\n if (typeof self !== 'undefined' && self.Math === Math) {\r\n return self;\r\n }\r\n if (typeof window !== 'undefined' && window.Math === Math) {\r\n return window;\r\n }\r\n // eslint-disable-next-line no-new-func\r\n return Function('return this')();\r\n})();\n\n/**\r\n * A shim for the requestAnimationFrame which falls back to the setTimeout if\r\n * first one is not supported.\r\n *\r\n * @returns {number} Requests' identifier.\r\n */\r\nvar requestAnimationFrame$1 = (function () {\r\n if (typeof requestAnimationFrame === 'function') {\r\n // It's required to use a bounded function because IE sometimes throws\r\n // an \"Invalid calling object\" error if rAF is invoked without the global\r\n // object on the left hand side.\r\n return requestAnimationFrame.bind(global$1);\r\n }\r\n return function (callback) { return setTimeout(function () { return callback(Date.now()); }, 1000 / 60); };\r\n})();\n\n// Defines minimum timeout before adding a trailing call.\r\nvar trailingTimeout = 2;\r\n/**\r\n * Creates a wrapper function which ensures that provided callback will be\r\n * invoked only once during the specified delay period.\r\n *\r\n * @param {Function} callback - Function to be invoked after the delay period.\r\n * @param {number} delay - Delay after which to invoke callback.\r\n * @returns {Function}\r\n */\r\nfunction throttle (callback, delay) {\r\n var leadingCall = false, trailingCall = false, lastCallTime = 0;\r\n /**\r\n * Invokes the original callback function and schedules new invocation if\r\n * the \"proxy\" was called during current request.\r\n *\r\n * @returns {void}\r\n */\r\n function resolvePending() {\r\n if (leadingCall) {\r\n leadingCall = false;\r\n callback();\r\n }\r\n if (trailingCall) {\r\n proxy();\r\n }\r\n }\r\n /**\r\n * Callback invoked after the specified delay. It will further postpone\r\n * invocation of the original function delegating it to the\r\n * requestAnimationFrame.\r\n *\r\n * @returns {void}\r\n */\r\n function timeoutCallback() {\r\n requestAnimationFrame$1(resolvePending);\r\n }\r\n /**\r\n * Schedules invocation of the original function.\r\n *\r\n * @returns {void}\r\n */\r\n function proxy() {\r\n var timeStamp = Date.now();\r\n if (leadingCall) {\r\n // Reject immediately following calls.\r\n if (timeStamp - lastCallTime < trailingTimeout) {\r\n return;\r\n }\r\n // Schedule new call to be in invoked when the pending one is resolved.\r\n // This is important for \"transitions\" which never actually start\r\n // immediately so there is a chance that we might miss one if change\r\n // happens amids the pending invocation.\r\n trailingCall = true;\r\n }\r\n else {\r\n leadingCall = true;\r\n trailingCall = false;\r\n setTimeout(timeoutCallback, delay);\r\n }\r\n lastCallTime = timeStamp;\r\n }\r\n return proxy;\r\n}\n\n// Minimum delay before invoking the update of observers.\r\nvar REFRESH_DELAY = 20;\r\n// A list of substrings of CSS properties used to find transition events that\r\n// might affect dimensions of observed elements.\r\nvar transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight'];\r\n// Check if MutationObserver is available.\r\nvar mutationObserverSupported = typeof MutationObserver !== 'undefined';\r\n/**\r\n * Singleton controller class which handles updates of ResizeObserver instances.\r\n */\r\nvar ResizeObserverController = /** @class */ (function () {\r\n /**\r\n * Creates a new instance of ResizeObserverController.\r\n *\r\n * @private\r\n */\r\n function ResizeObserverController() {\r\n /**\r\n * Indicates whether DOM listeners have been added.\r\n *\r\n * @private {boolean}\r\n */\r\n this.connected_ = false;\r\n /**\r\n * Tells that controller has subscribed for Mutation Events.\r\n *\r\n * @private {boolean}\r\n */\r\n this.mutationEventsAdded_ = false;\r\n /**\r\n * Keeps reference to the instance of MutationObserver.\r\n *\r\n * @private {MutationObserver}\r\n */\r\n this.mutationsObserver_ = null;\r\n /**\r\n * A list of connected observers.\r\n *\r\n * @private {Array}\r\n */\r\n this.observers_ = [];\r\n this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);\r\n this.refresh = throttle(this.refresh.bind(this), REFRESH_DELAY);\r\n }\r\n /**\r\n * Adds observer to observers list.\r\n *\r\n * @param {ResizeObserverSPI} observer - Observer to be added.\r\n * @returns {void}\r\n */\r\n ResizeObserverController.prototype.addObserver = function (observer) {\r\n if (!~this.observers_.indexOf(observer)) {\r\n this.observers_.push(observer);\r\n }\r\n // Add listeners if they haven't been added yet.\r\n if (!this.connected_) {\r\n this.connect_();\r\n }\r\n };\r\n /**\r\n * Removes observer from observers list.\r\n *\r\n * @param {ResizeObserverSPI} observer - Observer to be removed.\r\n * @returns {void}\r\n */\r\n ResizeObserverController.prototype.removeObserver = function (observer) {\r\n var observers = this.observers_;\r\n var index = observers.indexOf(observer);\r\n // Remove observer if it's present in registry.\r\n if (~index) {\r\n observers.splice(index, 1);\r\n }\r\n // Remove listeners if controller has no connected observers.\r\n if (!observers.length && this.connected_) {\r\n this.disconnect_();\r\n }\r\n };\r\n /**\r\n * Invokes the update of observers. It will continue running updates insofar\r\n * it detects changes.\r\n *\r\n * @returns {void}\r\n */\r\n ResizeObserverController.prototype.refresh = function () {\r\n var changesDetected = this.updateObservers_();\r\n // Continue running updates if changes have been detected as there might\r\n // be future ones caused by CSS transitions.\r\n if (changesDetected) {\r\n this.refresh();\r\n }\r\n };\r\n /**\r\n * Updates every observer from observers list and notifies them of queued\r\n * entries.\r\n *\r\n * @private\r\n * @returns {boolean} Returns \"true\" if any observer has detected changes in\r\n * dimensions of it's elements.\r\n */\r\n ResizeObserverController.prototype.updateObservers_ = function () {\r\n // Collect observers that have active observations.\r\n var activeObservers = this.observers_.filter(function (observer) {\r\n return observer.gatherActive(), observer.hasActive();\r\n });\r\n // Deliver notifications in a separate cycle in order to avoid any\r\n // collisions between observers, e.g. when multiple instances of\r\n // ResizeObserver are tracking the same element and the callback of one\r\n // of them changes content dimensions of the observed target. Sometimes\r\n // this may result in notifications being blocked for the rest of observers.\r\n activeObservers.forEach(function (observer) { return observer.broadcastActive(); });\r\n return activeObservers.length > 0;\r\n };\r\n /**\r\n * Initializes DOM listeners.\r\n *\r\n * @private\r\n * @returns {void}\r\n */\r\n ResizeObserverController.prototype.connect_ = function () {\r\n // Do nothing if running in a non-browser environment or if listeners\r\n // have been already added.\r\n if (!isBrowser || this.connected_) {\r\n return;\r\n }\r\n // Subscription to the \"Transitionend\" event is used as a workaround for\r\n // delayed transitions. This way it's possible to capture at least the\r\n // final state of an element.\r\n document.addEventListener('transitionend', this.onTransitionEnd_);\r\n window.addEventListener('resize', this.refresh);\r\n if (mutationObserverSupported) {\r\n this.mutationsObserver_ = new MutationObserver(this.refresh);\r\n this.mutationsObserver_.observe(document, {\r\n attributes: true,\r\n childList: true,\r\n characterData: true,\r\n subtree: true\r\n });\r\n }\r\n else {\r\n document.addEventListener('DOMSubtreeModified', this.refresh);\r\n this.mutationEventsAdded_ = true;\r\n }\r\n this.connected_ = true;\r\n };\r\n /**\r\n * Removes DOM listeners.\r\n *\r\n * @private\r\n * @returns {void}\r\n */\r\n ResizeObserverController.prototype.disconnect_ = function () {\r\n // Do nothing if running in a non-browser environment or if listeners\r\n // have been already removed.\r\n if (!isBrowser || !this.connected_) {\r\n return;\r\n }\r\n document.removeEventListener('transitionend', this.onTransitionEnd_);\r\n window.removeEventListener('resize', this.refresh);\r\n if (this.mutationsObserver_) {\r\n this.mutationsObserver_.disconnect();\r\n }\r\n if (this.mutationEventsAdded_) {\r\n document.removeEventListener('DOMSubtreeModified', this.refresh);\r\n }\r\n this.mutationsObserver_ = null;\r\n this.mutationEventsAdded_ = false;\r\n this.connected_ = false;\r\n };\r\n /**\r\n * \"Transitionend\" event handler.\r\n *\r\n * @private\r\n * @param {TransitionEvent} event\r\n * @returns {void}\r\n */\r\n ResizeObserverController.prototype.onTransitionEnd_ = function (_a) {\r\n var _b = _a.propertyName, propertyName = _b === void 0 ? '' : _b;\r\n // Detect whether transition may affect dimensions of an element.\r\n var isReflowProperty = transitionKeys.some(function (key) {\r\n return !!~propertyName.indexOf(key);\r\n });\r\n if (isReflowProperty) {\r\n this.refresh();\r\n }\r\n };\r\n /**\r\n * Returns instance of the ResizeObserverController.\r\n *\r\n * @returns {ResizeObserverController}\r\n */\r\n ResizeObserverController.getInstance = function () {\r\n if (!this.instance_) {\r\n this.instance_ = new ResizeObserverController();\r\n }\r\n return this.instance_;\r\n };\r\n /**\r\n * Holds reference to the controller's instance.\r\n *\r\n * @private {ResizeObserverController}\r\n */\r\n ResizeObserverController.instance_ = null;\r\n return ResizeObserverController;\r\n}());\n\n/**\r\n * Defines non-writable/enumerable properties of the provided target object.\r\n *\r\n * @param {Object} target - Object for which to define properties.\r\n * @param {Object} props - Properties to be defined.\r\n * @returns {Object} Target object.\r\n */\r\nvar defineConfigurable = (function (target, props) {\r\n for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {\r\n var key = _a[_i];\r\n Object.defineProperty(target, key, {\r\n value: props[key],\r\n enumerable: false,\r\n writable: false,\r\n configurable: true\r\n });\r\n }\r\n return target;\r\n});\n\n/**\r\n * Returns the global object associated with provided element.\r\n *\r\n * @param {Object} target\r\n * @returns {Object}\r\n */\r\nvar getWindowOf = (function (target) {\r\n // Assume that the element is an instance of Node, which means that it\r\n // has the \"ownerDocument\" property from which we can retrieve a\r\n // corresponding global object.\r\n var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;\r\n // Return the local global object if it's not possible extract one from\r\n // provided element.\r\n return ownerGlobal || global$1;\r\n});\n\n// Placeholder of an empty content rectangle.\r\nvar emptyRect = createRectInit(0, 0, 0, 0);\r\n/**\r\n * Converts provided string to a number.\r\n *\r\n * @param {number|string} value\r\n * @returns {number}\r\n */\r\nfunction toFloat(value) {\r\n return parseFloat(value) || 0;\r\n}\r\n/**\r\n * Extracts borders size from provided styles.\r\n *\r\n * @param {CSSStyleDeclaration} styles\r\n * @param {...string} positions - Borders positions (top, right, ...)\r\n * @returns {number}\r\n */\r\nfunction getBordersSize(styles) {\r\n var positions = [];\r\n for (var _i = 1; _i < arguments.length; _i++) {\r\n positions[_i - 1] = arguments[_i];\r\n }\r\n return positions.reduce(function (size, position) {\r\n var value = styles['border-' + position + '-width'];\r\n return size + toFloat(value);\r\n }, 0);\r\n}\r\n/**\r\n * Extracts paddings sizes from provided styles.\r\n *\r\n * @param {CSSStyleDeclaration} styles\r\n * @returns {Object} Paddings box.\r\n */\r\nfunction getPaddings(styles) {\r\n var positions = ['top', 'right', 'bottom', 'left'];\r\n var paddings = {};\r\n for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {\r\n var position = positions_1[_i];\r\n var value = styles['padding-' + position];\r\n paddings[position] = toFloat(value);\r\n }\r\n return paddings;\r\n}\r\n/**\r\n * Calculates content rectangle of provided SVG element.\r\n *\r\n * @param {SVGGraphicsElement} target - Element content rectangle of which needs\r\n * to be calculated.\r\n * @returns {DOMRectInit}\r\n */\r\nfunction getSVGContentRect(target) {\r\n var bbox = target.getBBox();\r\n return createRectInit(0, 0, bbox.width, bbox.height);\r\n}\r\n/**\r\n * Calculates content rectangle of provided HTMLElement.\r\n *\r\n * @param {HTMLElement} target - Element for which to calculate the content rectangle.\r\n * @returns {DOMRectInit}\r\n */\r\nfunction getHTMLElementContentRect(target) {\r\n // Client width & height properties can't be\r\n // used exclusively as they provide rounded values.\r\n var clientWidth = target.clientWidth, clientHeight = target.clientHeight;\r\n // By this condition we can catch all non-replaced inline, hidden and\r\n // detached elements. Though elements with width & height properties less\r\n // than 0.5 will be discarded as well.\r\n //\r\n // Without it we would need to implement separate methods for each of\r\n // those cases and it's not possible to perform a precise and performance\r\n // effective test for hidden elements. E.g. even jQuery's ':visible' filter\r\n // gives wrong results for elements with width & height less than 0.5.\r\n if (!clientWidth && !clientHeight) {\r\n return emptyRect;\r\n }\r\n var styles = getWindowOf(target).getComputedStyle(target);\r\n var paddings = getPaddings(styles);\r\n var horizPad = paddings.left + paddings.right;\r\n var vertPad = paddings.top + paddings.bottom;\r\n // Computed styles of width & height are being used because they are the\r\n // only dimensions available to JS that contain non-rounded values. It could\r\n // be possible to utilize the getBoundingClientRect if only it's data wasn't\r\n // affected by CSS transformations let alone paddings, borders and scroll bars.\r\n var width = toFloat(styles.width), height = toFloat(styles.height);\r\n // Width & height include paddings and borders when the 'border-box' box\r\n // model is applied (except for IE).\r\n if (styles.boxSizing === 'border-box') {\r\n // Following conditions are required to handle Internet Explorer which\r\n // doesn't include paddings and borders to computed CSS dimensions.\r\n //\r\n // We can say that if CSS dimensions + paddings are equal to the \"client\"\r\n // properties then it's either IE, and thus we don't need to subtract\r\n // anything, or an element merely doesn't have paddings/borders styles.\r\n if (Math.round(width + horizPad) !== clientWidth) {\r\n width -= getBordersSize(styles, 'left', 'right') + horizPad;\r\n }\r\n if (Math.round(height + vertPad) !== clientHeight) {\r\n height -= getBordersSize(styles, 'top', 'bottom') + vertPad;\r\n }\r\n }\r\n // Following steps can't be applied to the document's root element as its\r\n // client[Width/Height] properties represent viewport area of the window.\r\n // Besides, it's as well not necessary as the itself neither has\r\n // rendered scroll bars nor it can be clipped.\r\n if (!isDocumentElement(target)) {\r\n // In some browsers (only in Firefox, actually) CSS width & height\r\n // include scroll bars size which can be removed at this step as scroll\r\n // bars are the only difference between rounded dimensions + paddings\r\n // and \"client\" properties, though that is not always true in Chrome.\r\n var vertScrollbar = Math.round(width + horizPad) - clientWidth;\r\n var horizScrollbar = Math.round(height + vertPad) - clientHeight;\r\n // Chrome has a rather weird rounding of \"client\" properties.\r\n // E.g. for an element with content width of 314.2px it sometimes gives\r\n // the client width of 315px and for the width of 314.7px it may give\r\n // 314px. And it doesn't happen all the time. So just ignore this delta\r\n // as a non-relevant.\r\n if (Math.abs(vertScrollbar) !== 1) {\r\n width -= vertScrollbar;\r\n }\r\n if (Math.abs(horizScrollbar) !== 1) {\r\n height -= horizScrollbar;\r\n }\r\n }\r\n return createRectInit(paddings.left, paddings.top, width, height);\r\n}\r\n/**\r\n * Checks whether provided element is an instance of the SVGGraphicsElement.\r\n *\r\n * @param {Element} target - Element to be checked.\r\n * @returns {boolean}\r\n */\r\nvar isSVGGraphicsElement = (function () {\r\n // Some browsers, namely IE and Edge, don't have the SVGGraphicsElement\r\n // interface.\r\n if (typeof SVGGraphicsElement !== 'undefined') {\r\n return function (target) { return target instanceof getWindowOf(target).SVGGraphicsElement; };\r\n }\r\n // If it's so, then check that element is at least an instance of the\r\n // SVGElement and that it has the \"getBBox\" method.\r\n // eslint-disable-next-line no-extra-parens\r\n return function (target) { return (target instanceof getWindowOf(target).SVGElement &&\r\n typeof target.getBBox === 'function'); };\r\n})();\r\n/**\r\n * Checks whether provided element is a document element ().\r\n *\r\n * @param {Element} target - Element to be checked.\r\n * @returns {boolean}\r\n */\r\nfunction isDocumentElement(target) {\r\n return target === getWindowOf(target).document.documentElement;\r\n}\r\n/**\r\n * Calculates an appropriate content rectangle for provided html or svg element.\r\n *\r\n * @param {Element} target - Element content rectangle of which needs to be calculated.\r\n * @returns {DOMRectInit}\r\n */\r\nfunction getContentRect(target) {\r\n if (!isBrowser) {\r\n return emptyRect;\r\n }\r\n if (isSVGGraphicsElement(target)) {\r\n return getSVGContentRect(target);\r\n }\r\n return getHTMLElementContentRect(target);\r\n}\r\n/**\r\n * Creates rectangle with an interface of the DOMRectReadOnly.\r\n * Spec: https://drafts.fxtf.org/geometry/#domrectreadonly\r\n *\r\n * @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions.\r\n * @returns {DOMRectReadOnly}\r\n */\r\nfunction createReadOnlyRect(_a) {\r\n var x = _a.x, y = _a.y, width = _a.width, height = _a.height;\r\n // If DOMRectReadOnly is available use it as a prototype for the rectangle.\r\n var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object;\r\n var rect = Object.create(Constr.prototype);\r\n // Rectangle's properties are not writable and non-enumerable.\r\n defineConfigurable(rect, {\r\n x: x, y: y, width: width, height: height,\r\n top: y,\r\n right: x + width,\r\n bottom: height + y,\r\n left: x\r\n });\r\n return rect;\r\n}\r\n/**\r\n * Creates DOMRectInit object based on the provided dimensions and the x/y coordinates.\r\n * Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit\r\n *\r\n * @param {number} x - X coordinate.\r\n * @param {number} y - Y coordinate.\r\n * @param {number} width - Rectangle's width.\r\n * @param {number} height - Rectangle's height.\r\n * @returns {DOMRectInit}\r\n */\r\nfunction createRectInit(x, y, width, height) {\r\n return { x: x, y: y, width: width, height: height };\r\n}\n\n/**\r\n * Class that is responsible for computations of the content rectangle of\r\n * provided DOM element and for keeping track of it's changes.\r\n */\r\nvar ResizeObservation = /** @class */ (function () {\r\n /**\r\n * Creates an instance of ResizeObservation.\r\n *\r\n * @param {Element} target - Element to be observed.\r\n */\r\n function ResizeObservation(target) {\r\n /**\r\n * Broadcasted width of content rectangle.\r\n *\r\n * @type {number}\r\n */\r\n this.broadcastWidth = 0;\r\n /**\r\n * Broadcasted height of content rectangle.\r\n *\r\n * @type {number}\r\n */\r\n this.broadcastHeight = 0;\r\n /**\r\n * Reference to the last observed content rectangle.\r\n *\r\n * @private {DOMRectInit}\r\n */\r\n this.contentRect_ = createRectInit(0, 0, 0, 0);\r\n this.target = target;\r\n }\r\n /**\r\n * Updates content rectangle and tells whether it's width or height properties\r\n * have changed since the last broadcast.\r\n *\r\n * @returns {boolean}\r\n */\r\n ResizeObservation.prototype.isActive = function () {\r\n var rect = getContentRect(this.target);\r\n this.contentRect_ = rect;\r\n return (rect.width !== this.broadcastWidth ||\r\n rect.height !== this.broadcastHeight);\r\n };\r\n /**\r\n * Updates 'broadcastWidth' and 'broadcastHeight' properties with a data\r\n * from the corresponding properties of the last observed content rectangle.\r\n *\r\n * @returns {DOMRectInit} Last observed content rectangle.\r\n */\r\n ResizeObservation.prototype.broadcastRect = function () {\r\n var rect = this.contentRect_;\r\n this.broadcastWidth = rect.width;\r\n this.broadcastHeight = rect.height;\r\n return rect;\r\n };\r\n return ResizeObservation;\r\n}());\n\nvar ResizeObserverEntry = /** @class */ (function () {\r\n /**\r\n * Creates an instance of ResizeObserverEntry.\r\n *\r\n * @param {Element} target - Element that is being observed.\r\n * @param {DOMRectInit} rectInit - Data of the element's content rectangle.\r\n */\r\n function ResizeObserverEntry(target, rectInit) {\r\n var contentRect = createReadOnlyRect(rectInit);\r\n // According to the specification following properties are not writable\r\n // and are also not enumerable in the native implementation.\r\n //\r\n // Property accessors are not being used as they'd require to define a\r\n // private WeakMap storage which may cause memory leaks in browsers that\r\n // don't support this type of collections.\r\n defineConfigurable(this, { target: target, contentRect: contentRect });\r\n }\r\n return ResizeObserverEntry;\r\n}());\n\nvar ResizeObserverSPI = /** @class */ (function () {\r\n /**\r\n * Creates a new instance of ResizeObserver.\r\n *\r\n * @param {ResizeObserverCallback} callback - Callback function that is invoked\r\n * when one of the observed elements changes it's content dimensions.\r\n * @param {ResizeObserverController} controller - Controller instance which\r\n * is responsible for the updates of observer.\r\n * @param {ResizeObserver} callbackCtx - Reference to the public\r\n * ResizeObserver instance which will be passed to callback function.\r\n */\r\n function ResizeObserverSPI(callback, controller, callbackCtx) {\r\n /**\r\n * Collection of resize observations that have detected changes in dimensions\r\n * of elements.\r\n *\r\n * @private {Array}\r\n */\r\n this.activeObservations_ = [];\r\n /**\r\n * Registry of the ResizeObservation instances.\r\n *\r\n * @private {Map}\r\n */\r\n this.observations_ = new MapShim();\r\n if (typeof callback !== 'function') {\r\n throw new TypeError('The callback provided as parameter 1 is not a function.');\r\n }\r\n this.callback_ = callback;\r\n this.controller_ = controller;\r\n this.callbackCtx_ = callbackCtx;\r\n }\r\n /**\r\n * Starts observing provided element.\r\n *\r\n * @param {Element} target - Element to be observed.\r\n * @returns {void}\r\n */\r\n ResizeObserverSPI.prototype.observe = function (target) {\r\n if (!arguments.length) {\r\n throw new TypeError('1 argument required, but only 0 present.');\r\n }\r\n // Do nothing if current environment doesn't have the Element interface.\r\n if (typeof Element === 'undefined' || !(Element instanceof Object)) {\r\n return;\r\n }\r\n if (!(target instanceof getWindowOf(target).Element)) {\r\n throw new TypeError('parameter 1 is not of type \"Element\".');\r\n }\r\n var observations = this.observations_;\r\n // Do nothing if element is already being observed.\r\n if (observations.has(target)) {\r\n return;\r\n }\r\n observations.set(target, new ResizeObservation(target));\r\n this.controller_.addObserver(this);\r\n // Force the update of observations.\r\n this.controller_.refresh();\r\n };\r\n /**\r\n * Stops observing provided element.\r\n *\r\n * @param {Element} target - Element to stop observing.\r\n * @returns {void}\r\n */\r\n ResizeObserverSPI.prototype.unobserve = function (target) {\r\n if (!arguments.length) {\r\n throw new TypeError('1 argument required, but only 0 present.');\r\n }\r\n // Do nothing if current environment doesn't have the Element interface.\r\n if (typeof Element === 'undefined' || !(Element instanceof Object)) {\r\n return;\r\n }\r\n if (!(target instanceof getWindowOf(target).Element)) {\r\n throw new TypeError('parameter 1 is not of type \"Element\".');\r\n }\r\n var observations = this.observations_;\r\n // Do nothing if element is not being observed.\r\n if (!observations.has(target)) {\r\n return;\r\n }\r\n observations.delete(target);\r\n if (!observations.size) {\r\n this.controller_.removeObserver(this);\r\n }\r\n };\r\n /**\r\n * Stops observing all elements.\r\n *\r\n * @returns {void}\r\n */\r\n ResizeObserverSPI.prototype.disconnect = function () {\r\n this.clearActive();\r\n this.observations_.clear();\r\n this.controller_.removeObserver(this);\r\n };\r\n /**\r\n * Collects observation instances the associated element of which has changed\r\n * it's content rectangle.\r\n *\r\n * @returns {void}\r\n */\r\n ResizeObserverSPI.prototype.gatherActive = function () {\r\n var _this = this;\r\n this.clearActive();\r\n this.observations_.forEach(function (observation) {\r\n if (observation.isActive()) {\r\n _this.activeObservations_.push(observation);\r\n }\r\n });\r\n };\r\n /**\r\n * Invokes initial callback function with a list of ResizeObserverEntry\r\n * instances collected from active resize observations.\r\n *\r\n * @returns {void}\r\n */\r\n ResizeObserverSPI.prototype.broadcastActive = function () {\r\n // Do nothing if observer doesn't have active observations.\r\n if (!this.hasActive()) {\r\n return;\r\n }\r\n var ctx = this.callbackCtx_;\r\n // Create ResizeObserverEntry instance for every active observation.\r\n var entries = this.activeObservations_.map(function (observation) {\r\n return new ResizeObserverEntry(observation.target, observation.broadcastRect());\r\n });\r\n this.callback_.call(ctx, entries, ctx);\r\n this.clearActive();\r\n };\r\n /**\r\n * Clears the collection of active observations.\r\n *\r\n * @returns {void}\r\n */\r\n ResizeObserverSPI.prototype.clearActive = function () {\r\n this.activeObservations_.splice(0);\r\n };\r\n /**\r\n * Tells whether observer has active observations.\r\n *\r\n * @returns {boolean}\r\n */\r\n ResizeObserverSPI.prototype.hasActive = function () {\r\n return this.activeObservations_.length > 0;\r\n };\r\n return ResizeObserverSPI;\r\n}());\n\n// Registry of internal observers. If WeakMap is not available use current shim\r\n// for the Map collection as it has all required methods and because WeakMap\r\n// can't be fully polyfilled anyway.\r\nvar observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();\r\n/**\r\n * ResizeObserver API. Encapsulates the ResizeObserver SPI implementation\r\n * exposing only those methods and properties that are defined in the spec.\r\n */\r\nvar ResizeObserver = /** @class */ (function () {\r\n /**\r\n * Creates a new instance of ResizeObserver.\r\n *\r\n * @param {ResizeObserverCallback} callback - Callback that is invoked when\r\n * dimensions of the observed elements change.\r\n */\r\n function ResizeObserver(callback) {\r\n if (!(this instanceof ResizeObserver)) {\r\n throw new TypeError('Cannot call a class as a function.');\r\n }\r\n if (!arguments.length) {\r\n throw new TypeError('1 argument required, but only 0 present.');\r\n }\r\n var controller = ResizeObserverController.getInstance();\r\n var observer = new ResizeObserverSPI(callback, controller, this);\r\n observers.set(this, observer);\r\n }\r\n return ResizeObserver;\r\n}());\r\n// Expose public methods of ResizeObserver.\r\n[\r\n 'observe',\r\n 'unobserve',\r\n 'disconnect'\r\n].forEach(function (method) {\r\n ResizeObserver.prototype[method] = function () {\r\n var _a;\r\n return (_a = observers.get(this))[method].apply(_a, arguments);\r\n };\r\n});\n\nvar index = (function () {\r\n // Export existing implementation if available.\r\n if (typeof global$1.ResizeObserver !== 'undefined') {\r\n return global$1.ResizeObserver;\r\n }\r\n return ResizeObserver;\r\n})();\n\nexport default index;\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport ResizeObserver from \"resize-observer-polyfill\"\nimport {\n NEVER,\n Observable,\n Subject,\n defer,\n filter,\n finalize,\n map,\n merge,\n of,\n shareReplay,\n startWith,\n switchMap,\n tap\n} from \"rxjs\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Element offset\n */\nexport interface ElementSize {\n width: number /* Element width */\n height: number /* Element height */\n}\n\n/* ----------------------------------------------------------------------------\n * Data\n * ------------------------------------------------------------------------- */\n\n/**\n * Resize observer entry subject\n */\nconst entry$ = new Subject()\n\n/**\n * Resize observer observable\n *\n * This observable will create a `ResizeObserver` on the first subscription\n * and will automatically terminate it when there are no more subscribers.\n * It's quite important to centralize observation in a single `ResizeObserver`,\n * as the performance difference can be quite dramatic, as the link shows.\n *\n * @see https://bit.ly/3iIYfEm - Google Groups on performance\n */\nconst observer$ = defer(() => of(\n new ResizeObserver(entries => {\n for (const entry of entries)\n entry$.next(entry)\n })\n))\n .pipe(\n switchMap(observer => merge(NEVER, of(observer))\n .pipe(\n finalize(() => observer.disconnect())\n )\n ),\n shareReplay(1)\n )\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve element size\n *\n * @param el - Element\n *\n * @returns Element size\n */\nexport function getElementSize(\n el: HTMLElement\n): ElementSize {\n return {\n width: el.offsetWidth,\n height: el.offsetHeight\n }\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Watch element size\n *\n * This function returns an observable that subscribes to a single internal\n * instance of `ResizeObserver` upon subscription, and emit resize events until\n * termination. Note that this function should not be called with the same\n * element twice, as the first unsubscription will terminate observation.\n *\n * Sadly, we can't use the `DOMRect` objects returned by the observer, because\n * we need the emitted values to be consistent with `getElementSize`, which will\n * return the used values (rounded) and not actual values (unrounded). Thus, we\n * use the `offset*` properties. See the linked GitHub issue.\n *\n * @see https://bit.ly/3m0k3he - GitHub issue\n *\n * @param el - Element\n *\n * @returns Element size observable\n */\nexport function watchElementSize(\n el: HTMLElement\n): Observable {\n return observer$\n .pipe(\n tap(observer => observer.observe(el)),\n switchMap(observer => entry$\n .pipe(\n filter(({ target }) => target === el),\n finalize(() => observer.unobserve(el)),\n map(() => getElementSize(el))\n )\n ),\n startWith(getElementSize(el))\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { ElementSize } from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve element content size (= scroll width and height)\n *\n * @param el - Element\n *\n * @returns Element content size\n */\nexport function getElementContentSize(\n el: HTMLElement\n): ElementSize {\n return {\n width: el.scrollWidth,\n height: el.scrollHeight\n }\n}\n\n/**\n * Retrieve the overflowing container of an element, if any\n *\n * @param el - Element\n *\n * @returns Overflowing container or nothing\n */\nexport function getElementContainer(\n el: HTMLElement\n): HTMLElement | undefined {\n let parent = el.parentElement\n while (parent)\n if (\n el.scrollWidth <= parent.scrollWidth &&\n el.scrollHeight <= parent.scrollHeight\n )\n parent = (el = parent).parentElement\n else\n break\n\n /* Return overflowing container */\n return parent ? el : undefined\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n NEVER,\n Observable,\n Subject,\n defer,\n distinctUntilChanged,\n filter,\n finalize,\n map,\n merge,\n of,\n shareReplay,\n switchMap,\n tap\n} from \"rxjs\"\n\nimport {\n getElementContentSize,\n getElementSize,\n watchElementContentOffset\n} from \"~/browser\"\n\n/* ----------------------------------------------------------------------------\n * Data\n * ------------------------------------------------------------------------- */\n\n/**\n * Intersection observer entry subject\n */\nconst entry$ = new Subject()\n\n/**\n * Intersection observer observable\n *\n * This observable will create an `IntersectionObserver` on first subscription\n * and will automatically terminate it when there are no more subscribers.\n *\n * @see https://bit.ly/3iIYfEm - Google Groups on performance\n */\nconst observer$ = defer(() => of(\n new IntersectionObserver(entries => {\n for (const entry of entries)\n entry$.next(entry)\n }, {\n threshold: 0\n })\n))\n .pipe(\n switchMap(observer => merge(NEVER, of(observer))\n .pipe(\n finalize(() => observer.disconnect())\n )\n ),\n shareReplay(1)\n )\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch element visibility\n *\n * @param el - Element\n *\n * @returns Element visibility observable\n */\nexport function watchElementVisibility(\n el: HTMLElement\n): Observable {\n return observer$\n .pipe(\n tap(observer => observer.observe(el)),\n switchMap(observer => entry$\n .pipe(\n filter(({ target }) => target === el),\n finalize(() => observer.unobserve(el)),\n map(({ isIntersecting }) => isIntersecting)\n )\n )\n )\n}\n\n/**\n * Watch element boundary\n *\n * This function returns an observable which emits whether the bottom content\n * boundary (= scroll offset) of an element is within a certain threshold.\n *\n * @param el - Element\n * @param threshold - Threshold\n *\n * @returns Element boundary observable\n */\nexport function watchElementBoundary(\n el: HTMLElement, threshold = 16\n): Observable {\n return watchElementContentOffset(el)\n .pipe(\n map(({ y }) => {\n const visible = getElementSize(el)\n const content = getElementContentSize(el)\n return y >= (\n content.height - visible.height - threshold\n )\n }),\n distinctUntilChanged()\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n fromEvent,\n map,\n startWith\n} from \"rxjs\"\n\nimport { getElement } from \"../element\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Toggle\n */\nexport type Toggle =\n | \"drawer\" /* Toggle for drawer */\n | \"search\" /* Toggle for search */\n\n/* ----------------------------------------------------------------------------\n * Data\n * ------------------------------------------------------------------------- */\n\n/**\n * Toggle map\n */\nconst toggles: Record = {\n drawer: getElement(\"[data-md-toggle=drawer]\"),\n search: getElement(\"[data-md-toggle=search]\")\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve the value of a toggle\n *\n * @param name - Toggle\n *\n * @returns Toggle value\n */\nexport function getToggle(name: Toggle): boolean {\n return toggles[name].checked\n}\n\n/**\n * Set toggle\n *\n * Simulating a click event seems to be the most cross-browser compatible way\n * of changing the value while also emitting a `change` event. Before, Material\n * used `CustomEvent` to programmatically change the value of a toggle, but this\n * is a much simpler and cleaner solution which doesn't require a polyfill.\n *\n * @param name - Toggle\n * @param value - Toggle value\n */\nexport function setToggle(name: Toggle, value: boolean): void {\n if (toggles[name].checked !== value)\n toggles[name].click()\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Watch toggle\n *\n * @param name - Toggle\n *\n * @returns Toggle value observable\n */\nexport function watchToggle(name: Toggle): Observable {\n const el = toggles[name]\n return fromEvent(el, \"change\")\n .pipe(\n map(() => el.checked),\n startWith(el.checked)\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n filter,\n fromEvent,\n map,\n share\n} from \"rxjs\"\n\nimport { getActiveElement } from \"../element\"\nimport { getToggle } from \"../toggle\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Keyboard mode\n */\nexport type KeyboardMode =\n | \"global\" /* Global */\n | \"search\" /* Search is open */\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Keyboard\n */\nexport interface Keyboard {\n mode: KeyboardMode /* Keyboard mode */\n type: string /* Key type */\n claim(): void /* Key claim */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Check whether an element may receive keyboard input\n *\n * @param el - Element\n * @param type - Key type\n *\n * @returns Test result\n */\nfunction isSusceptibleToKeyboard(\n el: HTMLElement, type: string\n): boolean {\n switch (el.constructor) {\n\n /* Input elements */\n case HTMLInputElement:\n /* @ts-expect-error - omit unnecessary type cast */\n if (el.type === \"radio\")\n return /^Arrow/.test(type)\n else\n return true\n\n /* Select element and textarea */\n case HTMLSelectElement:\n case HTMLTextAreaElement:\n return true\n\n /* Everything else */\n default:\n return el.isContentEditable\n }\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch keyboard\n *\n * @returns Keyboard observable\n */\nexport function watchKeyboard(): Observable {\n return fromEvent(window, \"keydown\")\n .pipe(\n filter(ev => !(ev.metaKey || ev.ctrlKey)),\n map(ev => ({\n mode: getToggle(\"search\") ? \"search\" : \"global\",\n type: ev.key,\n claim() {\n ev.preventDefault()\n ev.stopPropagation()\n }\n } as Keyboard)),\n filter(({ mode, type }) => {\n if (mode === \"global\") {\n const active = getActiveElement()\n if (typeof active !== \"undefined\")\n return !isSusceptibleToKeyboard(active, type)\n }\n return true\n }),\n share()\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Subject } from \"rxjs\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve location\n *\n * This function returns a `URL` object (and not `Location`) to normalize the\n * typings across the application. Furthermore, locations need to be tracked\n * without setting them and `Location` is a singleton which represents the\n * current location.\n *\n * @returns URL\n */\nexport function getLocation(): URL {\n return new URL(location.href)\n}\n\n/**\n * Set location\n *\n * @param url - URL to change to\n */\nexport function setLocation(url: URL): void {\n location.href = url.href\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Watch location\n *\n * @returns Location subject\n */\nexport function watchLocation(): Subject {\n return new Subject()\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { JSX as JSXInternal } from \"preact\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * HTML attributes\n */\ntype Attributes =\n & JSXInternal.HTMLAttributes\n & JSXInternal.SVGAttributes\n & Record\n\n/**\n * Child element\n */\ntype Child =\n | HTMLElement\n | Text\n | string\n | number\n\n/* ----------------------------------------------------------------------------\n * Helper functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Append a child node to an element\n *\n * @param el - Element\n * @param child - Child node(s)\n */\nfunction appendChild(el: HTMLElement, child: Child | Child[]): void {\n\n /* Handle primitive types (including raw HTML) */\n if (typeof child === \"string\" || typeof child === \"number\") {\n el.innerHTML += child.toString()\n\n /* Handle nodes */\n } else if (child instanceof Node) {\n el.appendChild(child)\n\n /* Handle nested children */\n } else if (Array.isArray(child)) {\n for (const node of child)\n appendChild(el, node)\n }\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * JSX factory\n *\n * @template T - Element type\n *\n * @param tag - HTML tag\n * @param attributes - HTML attributes\n * @param children - Child elements\n *\n * @returns Element\n */\nexport function h(\n tag: T, attributes?: Attributes | null, ...children: Child[]\n): HTMLElementTagNameMap[T]\n\nexport function h(\n tag: string, attributes?: Attributes | null, ...children: Child[]\n): T\n\nexport function h(\n tag: string, attributes?: Attributes | null, ...children: Child[]\n): T {\n const el = document.createElement(tag)\n\n /* Set attributes, if any */\n if (attributes)\n for (const attr of Object.keys(attributes)) {\n if (typeof attributes[attr] === \"undefined\")\n continue\n\n /* Set default attribute or boolean */\n if (typeof attributes[attr] !== \"boolean\")\n el.setAttribute(attr, attributes[attr])\n else\n el.setAttribute(attr, \"\")\n }\n\n /* Append child nodes */\n for (const child of children)\n appendChild(el, child)\n\n /* Return element */\n return el as T\n}\n\n/* ----------------------------------------------------------------------------\n * Namespace\n * ------------------------------------------------------------------------- */\n\nexport declare namespace h {\n namespace JSX {\n type Element = HTMLElement\n type IntrinsicElements = JSXInternal.IntrinsicElements\n }\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Truncate a string after the given number of characters\n *\n * This is not a very reasonable approach, since the summaries kind of suck.\n * It would be better to create something more intelligent, highlighting the\n * search occurrences and making a better summary out of it, but this note was\n * written three years ago, so who knows if we'll ever fix it.\n *\n * @param value - Value to be truncated\n * @param n - Number of characters\n *\n * @returns Truncated value\n */\nexport function truncate(value: string, n: number): string {\n let i = n\n if (value.length > i) {\n while (value[i] !== \" \" && --i > 0) { /* keep eating */ }\n return `${value.substring(0, i)}...`\n }\n return value\n}\n\n/**\n * Round a number for display with repository facts\n *\n * This is a reverse-engineered version of GitHub's weird rounding algorithm\n * for stars, forks and all other numbers. While all numbers below `1,000` are\n * returned as-is, bigger numbers are converted to fixed numbers:\n *\n * - `1,049` => `1k`\n * - `1,050` => `1.1k`\n * - `1,949` => `1.9k`\n * - `1,950` => `2k`\n *\n * @param value - Original value\n *\n * @returns Rounded value\n */\nexport function round(value: number): string {\n if (value > 999) {\n const digits = +((value - 950) % 1000 > 99)\n return `${((value + 0.000001) / 1000).toFixed(digits)}k`\n } else {\n return value.toString()\n }\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n filter,\n fromEvent,\n map,\n shareReplay,\n startWith\n} from \"rxjs\"\n\nimport { getOptionalElement } from \"~/browser\"\nimport { h } from \"~/utilities\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve location hash\n *\n * @returns Location hash\n */\nexport function getLocationHash(): string {\n return location.hash.substring(1)\n}\n\n/**\n * Set location hash\n *\n * Setting a new fragment identifier via `location.hash` will have no effect\n * if the value doesn't change. When a new fragment identifier is set, we want\n * the browser to target the respective element at all times, which is why we\n * use this dirty little trick.\n *\n * @param hash - Location hash\n */\nexport function setLocationHash(hash: string): void {\n const el = h(\"a\", { href: hash })\n el.addEventListener(\"click\", ev => ev.stopPropagation())\n el.click()\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Watch location hash\n *\n * @returns Location hash observable\n */\nexport function watchLocationHash(): Observable {\n return fromEvent(window, \"hashchange\")\n .pipe(\n map(getLocationHash),\n startWith(getLocationHash()),\n filter(hash => hash.length > 0),\n shareReplay(1)\n )\n}\n\n/**\n * Watch location target\n *\n * @returns Location target observable\n */\nexport function watchLocationTarget(): Observable {\n return watchLocationHash()\n .pipe(\n map(id => getOptionalElement(`[id=\"${id}\"]`)!),\n filter(el => typeof el !== \"undefined\")\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n EMPTY,\n Observable,\n fromEvent,\n fromEventPattern,\n map,\n merge,\n startWith,\n switchMap\n} from \"rxjs\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch media query\n *\n * Note that although `MediaQueryList.addListener` is deprecated we have to\n * use it, because it's the only way to ensure proper downward compatibility.\n *\n * @see https://bit.ly/3dUBH2m - GitHub issue\n *\n * @param query - Media query\n *\n * @returns Media observable\n */\nexport function watchMedia(query: string): Observable {\n const media = matchMedia(query)\n return fromEventPattern(next => (\n media.addListener(() => next(media.matches))\n ))\n .pipe(\n startWith(media.matches)\n )\n}\n\n/**\n * Watch print mode\n *\n * @returns Print observable\n */\nexport function watchPrint(): Observable {\n const media = matchMedia(\"print\")\n return merge(\n fromEvent(window, \"beforeprint\").pipe(map(() => true)),\n fromEvent(window, \"afterprint\").pipe(map(() => false))\n )\n .pipe(\n startWith(media.matches)\n )\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Toggle an observable with a media observable\n *\n * @template T - Data type\n *\n * @param query$ - Media observable\n * @param factory - Observable factory\n *\n * @returns Toggled observable\n */\nexport function at(\n query$: Observable, factory: () => Observable\n): Observable {\n return query$\n .pipe(\n switchMap(active => active ? factory() : EMPTY)\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n EMPTY,\n Observable,\n catchError,\n from,\n map,\n of,\n shareReplay,\n switchMap,\n throwError\n} from \"rxjs\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Fetch the given URL\n *\n * If the request fails (e.g. when dispatched from `file://` locations), the\n * observable will complete without emitting a value.\n *\n * @param url - Request URL\n * @param options - Options\n *\n * @returns Response observable\n */\nexport function request(\n url: URL | string, options: RequestInit = { credentials: \"same-origin\" }\n): Observable {\n return from(fetch(`${url}`, options))\n .pipe(\n catchError(() => EMPTY),\n switchMap(res => res.status !== 200\n ? throwError(() => new Error(res.statusText))\n : of(res)\n )\n )\n}\n\n/**\n * Fetch JSON from the given URL\n *\n * @template T - Data type\n *\n * @param url - Request URL\n * @param options - Options\n *\n * @returns Data observable\n */\nexport function requestJSON(\n url: URL | string, options?: RequestInit\n): Observable {\n return request(url, options)\n .pipe(\n switchMap(res => res.json()),\n shareReplay(1)\n )\n}\n\n/**\n * Fetch XML from the given URL\n *\n * @param url - Request URL\n * @param options - Options\n *\n * @returns Data observable\n */\nexport function requestXML(\n url: URL | string, options?: RequestInit\n): Observable {\n const dom = new DOMParser()\n return request(url, options)\n .pipe(\n switchMap(res => res.text()),\n map(res => dom.parseFromString(res, \"text/xml\")),\n shareReplay(1)\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n defer,\n finalize,\n fromEvent,\n map,\n merge,\n switchMap,\n take,\n throwError\n} from \"rxjs\"\n\nimport { h } from \"~/utilities\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Create and load a `script` element\n *\n * This function returns an observable that will emit when the script was\n * successfully loaded, or throw an error if it didn't.\n *\n * @param src - Script URL\n *\n * @returns Script observable\n */\nexport function watchScript(src: string): Observable {\n const script = h(\"script\", { src })\n return defer(() => {\n document.head.appendChild(script)\n return merge(\n fromEvent(script, \"load\"),\n fromEvent(script, \"error\")\n .pipe(\n switchMap(() => (\n throwError(() => new ReferenceError(`Invalid script: ${src}`))\n ))\n )\n )\n .pipe(\n map(() => undefined),\n finalize(() => document.head.removeChild(script)),\n take(1)\n )\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n fromEvent,\n map,\n merge,\n startWith\n} from \"rxjs\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Viewport offset\n */\nexport interface ViewportOffset {\n x: number /* Horizontal offset */\n y: number /* Vertical offset */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve viewport offset\n *\n * On iOS Safari, viewport offset can be negative due to overflow scrolling.\n * As this may induce strange behaviors downstream, we'll just limit it to 0.\n *\n * @returns Viewport offset\n */\nexport function getViewportOffset(): ViewportOffset {\n return {\n x: Math.max(0, scrollX),\n y: Math.max(0, scrollY)\n }\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Watch viewport offset\n *\n * @returns Viewport offset observable\n */\nexport function watchViewportOffset(): Observable {\n return merge(\n fromEvent(window, \"scroll\", { passive: true }),\n fromEvent(window, \"resize\", { passive: true })\n )\n .pipe(\n map(getViewportOffset),\n startWith(getViewportOffset())\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n fromEvent,\n map,\n startWith\n} from \"rxjs\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Viewport size\n */\nexport interface ViewportSize {\n width: number /* Viewport width */\n height: number /* Viewport height */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve viewport size\n *\n * @returns Viewport size\n */\nexport function getViewportSize(): ViewportSize {\n return {\n width: innerWidth,\n height: innerHeight\n }\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Watch viewport size\n *\n * @returns Viewport size observable\n */\nexport function watchViewportSize(): Observable {\n return fromEvent(window, \"resize\", { passive: true })\n .pipe(\n map(getViewportSize),\n startWith(getViewportSize())\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n combineLatest,\n map,\n shareReplay\n} from \"rxjs\"\n\nimport {\n ViewportOffset,\n watchViewportOffset\n} from \"../offset\"\nimport {\n ViewportSize,\n watchViewportSize\n} from \"../size\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Viewport\n */\nexport interface Viewport {\n offset: ViewportOffset /* Viewport offset */\n size: ViewportSize /* Viewport size */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch viewport\n *\n * @returns Viewport observable\n */\nexport function watchViewport(): Observable {\n return combineLatest([\n watchViewportOffset(),\n watchViewportSize()\n ])\n .pipe(\n map(([offset, size]) => ({ offset, size })),\n shareReplay(1)\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n combineLatest,\n distinctUntilKeyChanged,\n map\n} from \"rxjs\"\n\nimport { Header } from \"~/components\"\n\nimport { getElementOffset } from \"../../element\"\nimport { Viewport } from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n viewport$: Observable /* Viewport observable */\n header$: Observable
/* Header observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch viewport relative to element\n *\n * @param el - Element\n * @param options - Options\n *\n * @returns Viewport observable\n */\nexport function watchViewportAt(\n el: HTMLElement, { viewport$, header$ }: WatchOptions\n): Observable {\n const size$ = viewport$\n .pipe(\n distinctUntilKeyChanged(\"size\")\n )\n\n /* Compute element offset */\n const offset$ = combineLatest([size$, header$])\n .pipe(\n map(() => getElementOffset(el))\n )\n\n /* Compute relative viewport, return hot observable */\n return combineLatest([header$, viewport$, offset$])\n .pipe(\n map(([{ height }, { offset, size }, { x, y }]) => ({\n offset: {\n x: offset.x - x,\n y: offset.y - y + height\n },\n size\n }))\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n Subject,\n fromEvent,\n map,\n share,\n switchMap,\n tap,\n throttle\n} from \"rxjs\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Worker message\n */\nexport interface WorkerMessage {\n type: unknown /* Message type */\n data?: unknown /* Message data */\n}\n\n/**\n * Worker handler\n *\n * @template T - Message type\n */\nexport interface WorkerHandler<\n T extends WorkerMessage\n> {\n tx$: Subject /* Message transmission subject */\n rx$: Observable /* Message receive observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n *\n * @template T - Worker message type\n */\ninterface WatchOptions {\n tx$: Observable /* Message transmission observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch a web worker\n *\n * This function returns an observable that sends all values emitted by the\n * message observable to the web worker. Web worker communication is expected\n * to be bidirectional (request-response) and synchronous. Messages that are\n * emitted during a pending request are throttled, the last one is emitted.\n *\n * @param worker - Web worker\n * @param options - Options\n *\n * @returns Worker message observable\n */\nexport function watchWorker(\n worker: Worker, { tx$ }: WatchOptions\n): Observable {\n\n /* Intercept messages from worker-like objects */\n const rx$ = fromEvent(worker, \"message\")\n .pipe(\n map(({ data }) => data as T)\n )\n\n /* Send and receive messages, return hot observable */\n return tx$\n .pipe(\n throttle(() => rx$, { leading: true, trailing: true }),\n tap(message => worker.postMessage(message)),\n switchMap(() => rx$),\n share()\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { getElement, getLocation } from \"~/browser\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Feature flag\n */\nexport type Flag =\n | \"announce.dismiss\" /* Dismissable announcement bar */\n | \"content.code.annotate\" /* Code annotations */\n | \"content.lazy\" /* Lazy content elements */\n | \"content.tabs.link\" /* Link content tabs */\n | \"header.autohide\" /* Hide header */\n | \"navigation.expand\" /* Automatic expansion */\n | \"navigation.indexes\" /* Section pages */\n | \"navigation.instant\" /* Instant loading */\n | \"navigation.sections\" /* Section navigation */\n | \"navigation.tabs\" /* Tabs navigation */\n | \"navigation.tabs.sticky\" /* Tabs navigation (sticky) */\n | \"navigation.top\" /* Back-to-top button */\n | \"navigation.tracking\" /* Anchor tracking */\n | \"search.highlight\" /* Search highlighting */\n | \"search.share\" /* Search sharing */\n | \"search.suggest\" /* Search suggestions */\n | \"toc.follow\" /* Following table of contents */\n | \"toc.integrate\" /* Integrated table of contents */\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Translation\n */\nexport type Translation =\n | \"clipboard.copy\" /* Copy to clipboard */\n | \"clipboard.copied\" /* Copied to clipboard */\n | \"search.config.lang\" /* Search language */\n | \"search.config.pipeline\" /* Search pipeline */\n | \"search.config.separator\" /* Search separator */\n | \"search.placeholder\" /* Search */\n | \"search.result.placeholder\" /* Type to start searching */\n | \"search.result.none\" /* No matching documents */\n | \"search.result.one\" /* 1 matching document */\n | \"search.result.other\" /* # matching documents */\n | \"search.result.more.one\" /* 1 more on this page */\n | \"search.result.more.other\" /* # more on this page */\n | \"search.result.term.missing\" /* Missing */\n | \"select.version.title\" /* Version selector */\n\n/**\n * Translations\n */\nexport type Translations = Record\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Versioning\n */\nexport interface Versioning {\n provider: \"mike\" /* Version provider */\n default?: string /* Default version */\n}\n\n/**\n * Configuration\n */\nexport interface Config {\n base: string /* Base URL */\n features: Flag[] /* Feature flags */\n translations: Translations /* Translations */\n search: string /* Search worker URL */\n tags?: Record /* Tags mapping */\n version?: Versioning /* Versioning */\n}\n\n/* ----------------------------------------------------------------------------\n * Data\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve global configuration and make base URL absolute\n */\nconst script = getElement(\"#__config\")\nconst config: Config = JSON.parse(script.textContent!)\nconfig.base = `${new URL(config.base, getLocation())}`\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve global configuration\n *\n * @returns Global configuration\n */\nexport function configuration(): Config {\n return config\n}\n\n/**\n * Check whether a feature flag is enabled\n *\n * @param flag - Feature flag\n *\n * @returns Test result\n */\nexport function feature(flag: Flag): boolean {\n return config.features.includes(flag)\n}\n\n/**\n * Retrieve the translation for the given key\n *\n * @param key - Key to be translated\n * @param value - Positional value, if any\n *\n * @returns Translation\n */\nexport function translation(\n key: Translation, value?: string | number\n): string {\n return typeof value !== \"undefined\"\n ? config.translations[key].replace(\"#\", value.toString())\n : config.translations[key]\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { getElement, getElements } from \"~/browser\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Component type\n */\nexport type ComponentType =\n | \"announce\" /* Announcement bar */\n | \"container\" /* Container */\n | \"consent\" /* Consent */\n | \"content\" /* Content */\n | \"dialog\" /* Dialog */\n | \"header\" /* Header */\n | \"header-title\" /* Header title */\n | \"header-topic\" /* Header topic */\n | \"main\" /* Main area */\n | \"outdated\" /* Version warning */\n | \"palette\" /* Color palette */\n | \"search\" /* Search */\n | \"search-query\" /* Search input */\n | \"search-result\" /* Search results */\n | \"search-share\" /* Search sharing */\n | \"search-suggest\" /* Search suggestions */\n | \"sidebar\" /* Sidebar */\n | \"skip\" /* Skip link */\n | \"source\" /* Repository information */\n | \"tabs\" /* Navigation tabs */\n | \"toc\" /* Table of contents */\n | \"top\" /* Back-to-top button */\n\n/**\n * Component\n *\n * @template T - Component type\n * @template U - Reference type\n */\nexport type Component<\n T extends {} = {},\n U extends HTMLElement = HTMLElement\n> =\n T & {\n ref: U /* Component reference */\n }\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Component type map\n */\ninterface ComponentTypeMap {\n \"announce\": HTMLElement /* Announcement bar */\n \"container\": HTMLElement /* Container */\n \"consent\": HTMLElement /* Consent */\n \"content\": HTMLElement /* Content */\n \"dialog\": HTMLElement /* Dialog */\n \"header\": HTMLElement /* Header */\n \"header-title\": HTMLElement /* Header title */\n \"header-topic\": HTMLElement /* Header topic */\n \"main\": HTMLElement /* Main area */\n \"outdated\": HTMLElement /* Version warning */\n \"palette\": HTMLElement /* Color palette */\n \"search\": HTMLElement /* Search */\n \"search-query\": HTMLInputElement /* Search input */\n \"search-result\": HTMLElement /* Search results */\n \"search-share\": HTMLAnchorElement /* Search sharing */\n \"search-suggest\": HTMLElement /* Search suggestions */\n \"sidebar\": HTMLElement /* Sidebar */\n \"skip\": HTMLAnchorElement /* Skip link */\n \"source\": HTMLAnchorElement /* Repository information */\n \"tabs\": HTMLElement /* Navigation tabs */\n \"toc\": HTMLElement /* Table of contents */\n \"top\": HTMLAnchorElement /* Back-to-top button */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve the element for a given component or throw a reference error\n *\n * @template T - Component type\n *\n * @param type - Component type\n * @param node - Node of reference\n *\n * @returns Element\n */\nexport function getComponentElement(\n type: T, node: ParentNode = document\n): ComponentTypeMap[T] {\n return getElement(`[data-md-component=${type}]`, node)\n}\n\n/**\n * Retrieve all elements for a given component\n *\n * @template T - Component type\n *\n * @param type - Component type\n * @param node - Node of reference\n *\n * @returns Elements\n */\nexport function getComponentElements(\n type: T, node: ParentNode = document\n): ComponentTypeMap[T][] {\n return getElements(`[data-md-component=${type}]`, node)\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n EMPTY,\n Observable,\n Subject,\n defer,\n finalize,\n fromEvent,\n map,\n startWith,\n tap\n} from \"rxjs\"\n\nimport { feature } from \"~/_\"\nimport { getElement } from \"~/browser\"\n\nimport { Component } from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Announcement bar\n */\nexport interface Announce {\n hash: number /* Content hash */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch announcement bar\n *\n * @param el - Announcement bar element\n *\n * @returns Announcement bar observable\n */\nexport function watchAnnounce(\n el: HTMLElement\n): Observable {\n const button = getElement(\".md-typeset > :first-child\", el)\n return fromEvent(button, \"click\", { once: true })\n .pipe(\n map(() => getElement(\".md-typeset\", el)),\n map(content => ({ hash: __md_hash(content.innerHTML) }))\n )\n}\n\n/**\n * Mount announcement bar\n *\n * @param el - Announcement bar element\n *\n * @returns Announcement bar component observable\n */\nexport function mountAnnounce(\n el: HTMLElement\n): Observable> {\n if (!feature(\"announce.dismiss\") || !el.childElementCount)\n return EMPTY\n\n /* Mount component on subscription */\n return defer(() => {\n const push$ = new Subject()\n push$\n .pipe(\n startWith({ hash: __md_get(\"__announce\") })\n )\n .subscribe(({ hash }) => {\n if (hash && hash === (__md_get(\"__announce\") ?? hash)) {\n el.hidden = true\n\n /* Persist preference in local storage */\n __md_set(\"__announce\", hash)\n }\n })\n\n /* Create and return component */\n return watchAnnounce(el)\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state }))\n )\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n Subject,\n finalize,\n map,\n tap\n} from \"rxjs\"\n\nimport { Component } from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Consent\n */\nexport interface Consent {\n hidden: boolean /* Consent is hidden */\n}\n\n/**\n * Consent defaults\n */\nexport interface ConsentDefaults {\n analytics?: boolean /* Consent for Analytics */\n github?: boolean /* Consent for GitHub */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n target$: Observable /* Target observable */\n}\n\n/**\n * Mount options\n */\ninterface MountOptions {\n target$: Observable /* Target observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch consent\n *\n * @param el - Consent element\n * @param options - Options\n *\n * @returns Consent observable\n */\nexport function watchConsent(\n el: HTMLElement, { target$ }: WatchOptions\n): Observable {\n return target$\n .pipe(\n map(target => ({ hidden: target !== el }))\n )\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Mount consent\n *\n * @param el - Consent element\n * @param options - Options\n *\n * @returns Consent component observable\n */\nexport function mountConsent(\n el: HTMLElement, options: MountOptions\n): Observable> {\n const internal$ = new Subject()\n internal$.subscribe(({ hidden }) => {\n el.hidden = hidden\n })\n\n /* Create and return component */\n return watchConsent(el, options)\n .pipe(\n tap(state => internal$.next(state)),\n finalize(() => internal$.complete()),\n map(state => ({ ref: el, ...state }))\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport ClipboardJS from \"clipboard\"\nimport {\n EMPTY,\n Observable,\n Subject,\n defer,\n distinctUntilChanged,\n distinctUntilKeyChanged,\n filter,\n finalize,\n map,\n mergeWith,\n switchMap,\n take,\n tap\n} from \"rxjs\"\n\nimport { feature } from \"~/_\"\nimport {\n getElementContentSize,\n watchElementSize,\n watchElementVisibility\n} from \"~/browser\"\nimport { renderClipboardButton } from \"~/templates\"\n\nimport { Component } from \"../../../_\"\nimport {\n Annotation,\n mountAnnotationList\n} from \"../../annotation\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Code block\n */\nexport interface CodeBlock {\n scrollable: boolean /* Code block overflows */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n target$: Observable /* Location target observable */\n print$: Observable /* Media print observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Data\n * ------------------------------------------------------------------------- */\n\n/**\n * Global sequence number for code blocks\n */\nlet sequence = 0\n\n/* ----------------------------------------------------------------------------\n * Helper functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Find candidate list element directly following a code block\n *\n * @param el - Code block element\n *\n * @returns List element or nothing\n */\nfunction findCandidateList(el: HTMLElement): HTMLElement | undefined {\n if (el.nextElementSibling) {\n const sibling = el.nextElementSibling as HTMLElement\n if (sibling.tagName === \"OL\")\n return sibling\n\n /* Skip empty paragraphs - see https://bit.ly/3r4ZJ2O */\n else if (sibling.tagName === \"P\" && !sibling.children.length)\n return findCandidateList(sibling)\n }\n\n /* Everything else */\n return undefined\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch code block\n *\n * This function monitors size changes of the viewport, as well as switches of\n * content tabs with embedded code blocks, as both may trigger overflow.\n *\n * @param el - Code block element\n *\n * @returns Code block observable\n */\nexport function watchCodeBlock(\n el: HTMLElement\n): Observable {\n return watchElementSize(el)\n .pipe(\n map(({ width }) => {\n const content = getElementContentSize(el)\n return {\n scrollable: content.width > width\n }\n }),\n distinctUntilKeyChanged(\"scrollable\")\n )\n}\n\n/**\n * Mount code block\n *\n * This function ensures that an overflowing code block is focusable through\n * keyboard, so it can be scrolled without a mouse to improve on accessibility.\n * Furthermore, if code annotations are enabled, they are mounted if and only\n * if the code block is currently visible, e.g., not in a hidden content tab.\n *\n * Note that code blocks may be mounted eagerly or lazily. If they're mounted\n * lazily (on first visibility), code annotation anchor links will not work,\n * as they are evaluated on initial page load, and code annotations in general\n * might feel a little bumpier.\n *\n * @param el - Code block element\n * @param options - Options\n *\n * @returns Code block and annotation component observable\n */\nexport function mountCodeBlock(\n el: HTMLElement, options: MountOptions\n): Observable> {\n const { matches: hover } = matchMedia(\"(hover)\")\n\n /* Defer mounting of code block - see https://bit.ly/3vHVoVD */\n const factory$ = defer(() => {\n const push$ = new Subject()\n push$.subscribe(({ scrollable }) => {\n if (scrollable && hover)\n el.setAttribute(\"tabindex\", \"0\")\n else\n el.removeAttribute(\"tabindex\")\n })\n\n /* Render button for Clipboard.js integration */\n if (ClipboardJS.isSupported()) {\n const parent = el.closest(\"pre\")!\n parent.id = `__code_${++sequence}`\n parent.insertBefore(\n renderClipboardButton(parent.id),\n el\n )\n }\n\n /* Handle code annotations */\n const container = el.closest(\".highlight\")\n if (container instanceof HTMLElement) {\n const list = findCandidateList(container)\n\n /* Mount code annotations, if enabled */\n if (typeof list !== \"undefined\" && (\n container.classList.contains(\"annotate\") ||\n feature(\"content.code.annotate\")\n )) {\n const annotations$ = mountAnnotationList(list, el, options)\n\n /* Create and return component */\n return watchCodeBlock(el)\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state })),\n mergeWith(\n watchElementSize(container)\n .pipe(\n map(({ width, height }) => width && height),\n distinctUntilChanged(),\n switchMap(active => active ? annotations$ : EMPTY)\n )\n )\n )\n }\n }\n\n /* Create and return component */\n return watchCodeBlock(el)\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state }))\n )\n })\n\n /* Mount code block lazily */\n if (feature(\"content.lazy\"))\n return watchElementVisibility(el)\n .pipe(\n filter(visible => visible),\n take(1),\n switchMap(() => factory$)\n )\n\n /* Mount code block */\n return factory$\n}\n", "/*\n * Copyright (c) 2016-2021 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { h } from \"~/utilities\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Render a tooltip\n *\n * @param id - Tooltip identifier\n *\n * @returns Element\n */\nexport function renderTooltip(id?: string): HTMLElement {\n return (\n
\n
\n
\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { h } from \"~/utilities\"\n\nimport { renderTooltip } from \"../tooltip\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Render an annotation\n *\n * @param id - Annotation identifier\n * @param prefix - Tooltip identifier prefix\n *\n * @returns Element\n */\nexport function renderAnnotation(\n id: string | number, prefix?: string\n): HTMLElement {\n prefix = prefix ? `${prefix}_annotation_${id}` : undefined\n\n /* Render tooltip with anchor, if given */\n if (prefix) {\n const anchor = prefix ? `#${prefix}` : undefined\n return (\n \n )\n } else {\n return (\n \n )\n }\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { translation } from \"~/_\"\nimport { h } from \"~/utilities\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Render a 'copy-to-clipboard' button\n *\n * @param id - Unique identifier\n *\n * @returns Element\n */\nexport function renderClipboardButton(id: string): HTMLElement {\n return (\n code`}\n >\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { ComponentChild } from \"preact\"\n\nimport { configuration, feature, translation } from \"~/_\"\nimport {\n SearchDocument,\n SearchMetadata,\n SearchResultItem\n} from \"~/integrations/search\"\nimport { h, truncate } from \"~/utilities\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Render flag\n */\nconst enum Flag {\n TEASER = 1, /* Render teaser */\n PARENT = 2 /* Render as parent */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper function\n * ------------------------------------------------------------------------- */\n\n/**\n * Render a search document\n *\n * @param document - Search document\n * @param flag - Render flags\n *\n * @returns Element\n */\nfunction renderSearchDocument(\n document: SearchDocument & SearchMetadata, flag: Flag\n): HTMLElement {\n const parent = flag & Flag.PARENT\n const teaser = flag & Flag.TEASER\n\n /* Render missing query terms */\n const missing = Object.keys(document.terms)\n .filter(key => !document.terms[key])\n .reduce((list, key) => [\n ...list, {key}, \" \"\n ], [])\n .slice(0, -1)\n\n /* Assemble query string for highlighting */\n const url = new URL(document.location)\n if (feature(\"search.highlight\"))\n url.searchParams.set(\"h\", Object.entries(document.terms)\n .filter(([, match]) => match)\n .reduce((highlight, [value]) => `${highlight} ${value}`.trim(), \"\")\n )\n\n /* Render article or section, depending on flags */\n const { tags } = configuration()\n return (\n \n \n {parent > 0 &&
}\n

{document.title}

\n {teaser > 0 && document.text.length > 0 &&\n

\n {truncate(document.text, 320)}\n

\n }\n {document.tags && (\n
\n {document.tags.map(tag => {\n const id = tag.replace(/<[^>]+>/g, \"\")\n const type = tags\n ? id in tags\n ? `md-tag-icon md-tag-icon--${tags[id]}`\n : \"md-tag-icon\"\n : \"\"\n return (\n {tag}\n )\n })}\n
\n )}\n {teaser > 0 && missing.length > 0 &&\n

\n {translation(\"search.result.term.missing\")}: {...missing}\n

\n }\n \n
\n )\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Render a search result\n *\n * @param result - Search result\n *\n * @returns Element\n */\nexport function renderSearchResultItem(\n result: SearchResultItem\n): HTMLElement {\n const threshold = result[0].score\n const docs = [...result]\n\n /* Find and extract parent article */\n const parent = docs.findIndex(doc => !doc.location.includes(\"#\"))\n const [article] = docs.splice(parent, 1)\n\n /* Determine last index above threshold */\n let index = docs.findIndex(doc => doc.score < threshold)\n if (index === -1)\n index = docs.length\n\n /* Partition sections */\n const best = docs.slice(0, index)\n const more = docs.slice(index)\n\n /* Render children */\n const children = [\n renderSearchDocument(article, Flag.PARENT | +(!parent && index === 0)),\n ...best.map(section => renderSearchDocument(section, Flag.TEASER)),\n ...more.length ? [\n
\n \n {more.length > 0 && more.length === 1\n ? translation(\"search.result.more.one\")\n : translation(\"search.result.more.other\", more.length)\n }\n \n {...more.map(section => renderSearchDocument(section, Flag.TEASER))}\n
\n ] : []\n ]\n\n /* Render search result */\n return (\n
  • \n {children}\n
  • \n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { SourceFacts } from \"~/components\"\nimport { h, round } from \"~/utilities\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Render repository facts\n *\n * @param facts - Repository facts\n *\n * @returns Element\n */\nexport function renderSourceFacts(facts: SourceFacts): HTMLElement {\n return (\n
      \n {Object.entries(facts).map(([key, value]) => (\n
    • \n {typeof value === \"number\" ? round(value) : value}\n
    • \n ))}\n
    \n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { h } from \"~/utilities\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Tabbed control type\n */\ntype TabbedControlType =\n | \"prev\"\n | \"next\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Render control for content tabs\n *\n * @param type - Control type\n *\n * @returns Element\n */\nexport function renderTabbedControl(\n type: TabbedControlType\n): HTMLElement {\n const classes = `tabbed-control tabbed-control--${type}`\n return (\n \n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { h } from \"~/utilities\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Render a table inside a wrapper to improve scrolling on mobile\n *\n * @param table - Table element\n *\n * @returns Element\n */\nexport function renderTable(table: HTMLElement): HTMLElement {\n return (\n
    \n
    \n {table}\n
    \n
    \n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { configuration, translation } from \"~/_\"\nimport { h } from \"~/utilities\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Version\n */\nexport interface Version {\n version: string /* Version identifier */\n title: string /* Version title */\n aliases: string[] /* Version aliases */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Render a version\n *\n * @param version - Version\n *\n * @returns Element\n */\nfunction renderVersion(version: Version): HTMLElement {\n const config = configuration()\n\n /* Ensure trailing slash - see https://bit.ly/3rL5u3f */\n const url = new URL(`../${version.version}/`, config.base)\n return (\n
  • \n \n {version.title}\n \n
  • \n )\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Render a version selector\n *\n * @param versions - Versions\n * @param active - Active version\n *\n * @returns Element\n */\nexport function renderVersionSelector(\n versions: Version[], active: Version\n): HTMLElement {\n return (\n
    \n \n {active.title}\n \n
      \n {versions.map(renderVersion)}\n
    \n
    \n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n Subject,\n animationFrameScheduler,\n auditTime,\n combineLatest,\n debounceTime,\n defer,\n delay,\n filter,\n finalize,\n fromEvent,\n map,\n merge,\n switchMap,\n take,\n takeLast,\n takeUntil,\n tap,\n throttleTime,\n withLatestFrom\n} from \"rxjs\"\n\nimport {\n ElementOffset,\n getActiveElement,\n getElementSize,\n watchElementContentOffset,\n watchElementFocus,\n watchElementOffset,\n watchElementVisibility\n} from \"~/browser\"\n\nimport { Component } from \"../../../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Annotation\n */\nexport interface Annotation {\n active: boolean /* Annotation is active */\n offset: ElementOffset /* Annotation offset */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n target$: Observable /* Location target observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch annotation\n *\n * @param el - Annotation element\n * @param container - Containing element\n *\n * @returns Annotation observable\n */\nexport function watchAnnotation(\n el: HTMLElement, container: HTMLElement\n): Observable {\n const offset$ = defer(() => combineLatest([\n watchElementOffset(el),\n watchElementContentOffset(container)\n ]))\n .pipe(\n map(([{ x, y }, scroll]): ElementOffset => {\n const { width, height } = getElementSize(el)\n return ({\n x: x - scroll.x + width / 2,\n y: y - scroll.y + height / 2\n })\n })\n )\n\n /* Actively watch annotation on focus */\n return watchElementFocus(el)\n .pipe(\n switchMap(active => offset$\n .pipe(\n map(offset => ({ active, offset })),\n take(+!active || Infinity)\n )\n )\n )\n}\n\n/**\n * Mount annotation\n *\n * @param el - Annotation element\n * @param container - Containing element\n * @param options - Options\n *\n * @returns Annotation component observable\n */\nexport function mountAnnotation(\n el: HTMLElement, container: HTMLElement, { target$ }: MountOptions\n): Observable> {\n const [tooltip, index] = Array.from(el.children)\n\n /* Mount component on subscription */\n return defer(() => {\n const push$ = new Subject()\n const done$ = push$.pipe(takeLast(1))\n push$.subscribe({\n\n /* Handle emission */\n next({ offset }) {\n el.style.setProperty(\"--md-tooltip-x\", `${offset.x}px`)\n el.style.setProperty(\"--md-tooltip-y\", `${offset.y}px`)\n },\n\n /* Handle complete */\n complete() {\n el.style.removeProperty(\"--md-tooltip-x\")\n el.style.removeProperty(\"--md-tooltip-y\")\n }\n })\n\n /* Start animation only when annotation is visible */\n watchElementVisibility(el)\n .pipe(\n takeUntil(done$)\n )\n .subscribe(visible => {\n el.toggleAttribute(\"data-md-visible\", visible)\n })\n\n /* Toggle tooltip presence to mitigate empty lines when copying */\n merge(\n push$.pipe(filter(({ active }) => active)),\n push$.pipe(debounceTime(250), filter(({ active }) => !active))\n )\n .subscribe({\n\n /* Handle emission */\n next({ active }) {\n if (active)\n el.prepend(tooltip)\n else\n tooltip.remove()\n },\n\n /* Handle complete */\n complete() {\n el.prepend(tooltip)\n }\n })\n\n /* Toggle tooltip visibility */\n push$\n .pipe(\n auditTime(16, animationFrameScheduler)\n )\n .subscribe(({ active }) => {\n tooltip.classList.toggle(\"md-tooltip--active\", active)\n })\n\n /* Track relative origin of tooltip */\n push$\n .pipe(\n throttleTime(125, animationFrameScheduler),\n filter(() => !!el.offsetParent),\n map(() => el.offsetParent!.getBoundingClientRect()),\n map(({ x }) => x)\n )\n .subscribe({\n\n /* Handle emission */\n next(origin) {\n if (origin)\n el.style.setProperty(\"--md-tooltip-0\", `${-origin}px`)\n else\n el.style.removeProperty(\"--md-tooltip-0\")\n },\n\n /* Handle complete */\n complete() {\n el.style.removeProperty(\"--md-tooltip-0\")\n }\n })\n\n /* Allow to copy link without scrolling to anchor */\n fromEvent(index, \"click\")\n .pipe(\n takeUntil(done$),\n filter(ev => !(ev.metaKey || ev.ctrlKey))\n )\n .subscribe(ev => ev.preventDefault())\n\n /* Allow to open link in new tab or blur on close */\n fromEvent(index, \"mousedown\")\n .pipe(\n takeUntil(done$),\n withLatestFrom(push$)\n )\n .subscribe(([ev, { active }]) => {\n\n /* Open in new tab */\n if (ev.button !== 0 || ev.metaKey || ev.ctrlKey) {\n ev.preventDefault()\n\n /* Close annotation */\n } else if (active) {\n ev.preventDefault()\n\n /* Focus parent annotation, if any */\n const parent = el.parentElement!.closest(\".md-annotation\")\n if (parent instanceof HTMLElement)\n parent.focus()\n else\n getActiveElement()?.blur()\n }\n })\n\n /* Open and focus annotation on location target */\n target$\n .pipe(\n takeUntil(done$),\n filter(target => target === tooltip),\n delay(125)\n )\n .subscribe(() => el.focus())\n\n /* Create and return component */\n return watchAnnotation(el, container)\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state }))\n )\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n EMPTY,\n Observable,\n Subject,\n defer,\n finalize,\n merge,\n share,\n takeLast,\n takeUntil\n} from \"rxjs\"\n\nimport {\n getElement,\n getElements,\n getOptionalElement\n} from \"~/browser\"\nimport { renderAnnotation } from \"~/templates\"\n\nimport { Component } from \"../../../_\"\nimport {\n Annotation,\n mountAnnotation\n} from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n target$: Observable /* Location target observable */\n print$: Observable /* Media print observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Find all annotation markers in the given code block\n *\n * @param container - Containing element\n *\n * @returns Annotation markers\n */\nfunction findAnnotationMarkers(container: HTMLElement): Text[] {\n const markers: Text[] = []\n for (const el of getElements(\".c, .c1, .cm\", container)) {\n const nodes: Text[] = []\n\n /* Find all text nodes in current element */\n const it = document.createNodeIterator(el, NodeFilter.SHOW_TEXT)\n for (let node = it.nextNode(); node; node = it.nextNode())\n nodes.push(node as Text)\n\n /* Find all markers in each text node */\n for (let text of nodes) {\n let match: RegExpExecArray | null\n\n /* Split text at marker and add to list */\n while ((match = /(\\(\\d+\\))(!)?/.exec(text.textContent!))) {\n const [, id, force] = match\n if (typeof force === \"undefined\") {\n const marker = text.splitText(match.index)\n text = marker.splitText(id.length)\n markers.push(marker)\n\n /* Replace entire text with marker */\n } else {\n text.textContent = id\n markers.push(text)\n break\n }\n }\n }\n }\n return markers\n}\n\n/**\n * Swap the child nodes of two elements\n *\n * @param source - Source element\n * @param target - Target element\n */\nfunction swap(source: HTMLElement, target: HTMLElement): void {\n target.append(...Array.from(source.childNodes))\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount annotation list\n *\n * This function analyzes the containing code block and checks for markers\n * referring to elements in the given annotation list. If no markers are found,\n * the list is left untouched. Otherwise, list elements are rendered as\n * annotations inside the code block.\n *\n * @param el - Annotation list element\n * @param container - Containing element\n * @param options - Options\n *\n * @returns Annotation component observable\n */\nexport function mountAnnotationList(\n el: HTMLElement, container: HTMLElement, { target$, print$ }: MountOptions\n): Observable> {\n\n /* Compute prefix for tooltip anchors */\n const parent = container.closest(\"[id]\")\n const prefix = parent?.id\n\n /* Find and replace all markers with empty annotations */\n const annotations = new Map()\n for (const marker of findAnnotationMarkers(container)) {\n const [, id] = marker.textContent!.match(/\\((\\d+)\\)/)!\n if (getOptionalElement(`li:nth-child(${id})`, el)) {\n annotations.set(id, renderAnnotation(id, prefix))\n marker.replaceWith(annotations.get(id)!)\n }\n }\n\n /* Keep list if there are no annotations to render */\n if (annotations.size === 0)\n return EMPTY\n\n /* Mount component on subscription */\n return defer(() => {\n const done$ = new Subject()\n\n /* Retrieve container pairs for swapping */\n const pairs: [HTMLElement, HTMLElement][] = []\n for (const [id, annotation] of annotations)\n pairs.push([\n getElement(\".md-typeset\", annotation),\n getElement(`li:nth-child(${id})`, el)\n ])\n\n /* Handle print mode - see https://bit.ly/3rgPdpt */\n print$\n .pipe(\n takeUntil(done$.pipe(takeLast(1)))\n )\n .subscribe(active => {\n el.hidden = !active\n\n /* Show annotations in code block or list (print) */\n for (const [inner, child] of pairs)\n if (!active)\n swap(child, inner)\n else\n swap(inner, child)\n })\n\n /* Create and return component */\n return merge(...[...annotations]\n .map(([, annotation]) => (\n mountAnnotation(annotation, container, { target$ })\n ))\n )\n .pipe(\n finalize(() => done$.complete()),\n share()\n )\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n map,\n of,\n shareReplay,\n tap\n} from \"rxjs\"\n\nimport { watchScript } from \"~/browser\"\nimport { h } from \"~/utilities\"\n\nimport { Component } from \"../../../_\"\n\nimport themeCSS from \"./index.css\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mermaid diagram\n */\nexport interface Mermaid {}\n\n/* ----------------------------------------------------------------------------\n * Data\n * ------------------------------------------------------------------------- */\n\n/**\n * Mermaid instance observable\n */\nlet mermaid$: Observable\n\n/**\n * Global sequence number for diagrams\n */\nlet sequence = 0\n\n/* ----------------------------------------------------------------------------\n * Helper functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Fetch Mermaid script\n *\n * @returns Mermaid scripts observable\n */\nfunction fetchScripts(): Observable {\n return typeof mermaid === \"undefined\" || mermaid instanceof Element\n ? watchScript(\"https://unpkg.com/mermaid@9.1.7/dist/mermaid.min.js\")\n : of(undefined)\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount Mermaid diagram\n *\n * @param el - Code block element\n *\n * @returns Mermaid diagram component observable\n */\nexport function mountMermaid(\n el: HTMLElement\n): Observable> {\n el.classList.remove(\"mermaid\") // Hack: mitigate https://bit.ly/3CiN6Du\n mermaid$ ||= fetchScripts()\n .pipe(\n tap(() => mermaid.initialize({\n startOnLoad: false,\n themeCSS,\n sequence: {\n actorFontSize: \"16px\", // Hack: mitigate https://bit.ly/3y0NEi3\n messageFontSize: \"16px\",\n noteFontSize: \"16px\"\n }\n })),\n map(() => undefined),\n shareReplay(1)\n )\n\n /* Render diagram */\n mermaid$.subscribe(() => {\n el.classList.add(\"mermaid\") // Hack: mitigate https://bit.ly/3CiN6Du\n const id = `__mermaid_${sequence++}`\n const host = h(\"div\", { class: \"mermaid\" })\n mermaid.mermaidAPI.render(id, el.textContent, (svg: string) => {\n\n /* Create a shadow root and inject diagram */\n const shadow = host.attachShadow({ mode: \"closed\" })\n shadow.innerHTML = svg\n\n /* Replace code block with diagram */\n el.replaceWith(host)\n })\n })\n\n /* Create and return component */\n return mermaid$\n .pipe(\n map(() => ({ ref: el }))\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n Subject,\n defer,\n filter,\n finalize,\n map,\n merge,\n tap\n} from \"rxjs\"\n\nimport { Component } from \"../../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Details\n */\nexport interface Details {\n action: \"open\" | \"close\" /* Details state */\n reveal?: boolean /* Details is revealed */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n target$: Observable /* Location target observable */\n print$: Observable /* Media print observable */\n}\n\n/**\n * Mount options\n */\ninterface MountOptions {\n target$: Observable /* Location target observable */\n print$: Observable /* Media print observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch details\n *\n * @param el - Details element\n * @param options - Options\n *\n * @returns Details observable\n */\nexport function watchDetails(\n el: HTMLDetailsElement, { target$, print$ }: WatchOptions\n): Observable
    {\n let open = true\n return merge(\n\n /* Open and focus details on location target */\n target$\n .pipe(\n map(target => target.closest(\"details:not([open])\")!),\n filter(details => el === details),\n map(() => ({\n action: \"open\", reveal: true\n }) as Details)\n ),\n\n /* Open details on print and close afterwards */\n print$\n .pipe(\n filter(active => active || !open),\n tap(() => open = el.open),\n map(active => ({\n action: active ? \"open\" : \"close\"\n }) as Details)\n )\n )\n}\n\n/**\n * Mount details\n *\n * This function ensures that `details` tags are opened on anchor jumps and\n * prior to printing, so the whole content of the page is visible.\n *\n * @param el - Details element\n * @param options - Options\n *\n * @returns Details component observable\n */\nexport function mountDetails(\n el: HTMLDetailsElement, options: MountOptions\n): Observable> {\n return defer(() => {\n const push$ = new Subject
    ()\n push$.subscribe(({ action, reveal }) => {\n el.toggleAttribute(\"open\", action === \"open\")\n if (reveal)\n el.scrollIntoView()\n })\n\n /* Create and return component */\n return watchDetails(el, options)\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state }))\n )\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, of } from \"rxjs\"\n\nimport { renderTable } from \"~/templates\"\nimport { h } from \"~/utilities\"\n\nimport { Component } from \"../../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Data table\n */\nexport interface DataTable {}\n\n/* ----------------------------------------------------------------------------\n * Data\n * ------------------------------------------------------------------------- */\n\n/**\n * Sentinel for replacement\n */\nconst sentinel = h(\"table\")\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount data table\n *\n * This function wraps a data table in another scrollable container, so it can\n * be smoothly scrolled on smaller screen sizes and won't break the layout.\n *\n * @param el - Data table element\n *\n * @returns Data table component observable\n */\nexport function mountDataTable(\n el: HTMLElement\n): Observable> {\n el.replaceWith(sentinel)\n sentinel.replaceWith(renderTable(el))\n\n /* Create and return component */\n return of({ ref: el })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n Subject,\n animationFrameScheduler,\n asyncScheduler,\n auditTime,\n combineLatest,\n defer,\n finalize,\n fromEvent,\n map,\n merge,\n skip,\n startWith,\n subscribeOn,\n takeLast,\n takeUntil,\n tap,\n withLatestFrom\n} from \"rxjs\"\n\nimport { feature } from \"~/_\"\nimport {\n Viewport,\n getElement,\n getElementContentOffset,\n getElementContentSize,\n getElementOffset,\n getElementSize,\n getElements,\n watchElementContentOffset,\n watchElementSize\n} from \"~/browser\"\nimport { renderTabbedControl } from \"~/templates\"\n\nimport { Component } from \"../../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Content tabs\n */\nexport interface ContentTabs {\n active: HTMLLabelElement /* Active tab label */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n viewport$: Observable /* Viewport observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch content tabs\n *\n * @param el - Content tabs element\n *\n * @returns Content tabs observable\n */\nexport function watchContentTabs(\n el: HTMLElement\n): Observable {\n const inputs = getElements(\":scope > input\", el)\n const initial = inputs.find(input => input.checked) || inputs[0]\n return merge(...inputs.map(input => fromEvent(input, \"change\")\n .pipe(\n map(() => getElement(`label[for=\"${input.id}\"]`))\n )\n ))\n .pipe(\n startWith(getElement(`label[for=\"${initial.id}\"]`)),\n map(active => ({ active }))\n )\n}\n\n/**\n * Mount content tabs\n *\n * This function scrolls the active tab into view. While this functionality is\n * provided by browsers as part of `scrollInfoView`, browsers will always also\n * scroll the vertical axis, which we do not want. Thus, we decided to provide\n * this functionality ourselves.\n *\n * @param el - Content tabs element\n * @param options - Options\n *\n * @returns Content tabs component observable\n */\nexport function mountContentTabs(\n el: HTMLElement, { viewport$ }: MountOptions\n): Observable> {\n\n /* Render content tab previous button for pagination */\n const prev = renderTabbedControl(\"prev\")\n el.append(prev)\n\n /* Render content tab next button for pagination */\n const next = renderTabbedControl(\"next\")\n el.append(next)\n\n /* Mount component on subscription */\n const container = getElement(\".tabbed-labels\", el)\n return defer(() => {\n const push$ = new Subject()\n const done$ = push$.pipe(takeLast(1))\n combineLatest([push$, watchElementSize(el)])\n .pipe(\n auditTime(1, animationFrameScheduler),\n takeUntil(done$)\n )\n .subscribe({\n\n /* Handle emission */\n next([{ active }, size]) {\n const offset = getElementOffset(active)\n const { width } = getElementSize(active)\n\n /* Set tab indicator offset and width */\n el.style.setProperty(\"--md-indicator-x\", `${offset.x}px`)\n el.style.setProperty(\"--md-indicator-width\", `${width}px`)\n\n /* Scroll container to active content tab */\n const content = getElementContentOffset(container)\n if (\n offset.x < content.x ||\n offset.x + width > content.x + size.width\n )\n container.scrollTo({\n left: Math.max(0, offset.x - 16),\n behavior: \"smooth\"\n })\n },\n\n /* Handle complete */\n complete() {\n el.style.removeProperty(\"--md-indicator-x\")\n el.style.removeProperty(\"--md-indicator-width\")\n }\n })\n\n /* Hide content tab buttons on borders */\n combineLatest([\n watchElementContentOffset(container),\n watchElementSize(container)\n ])\n .pipe(\n takeUntil(done$)\n )\n .subscribe(([offset, size]) => {\n const content = getElementContentSize(container)\n prev.hidden = offset.x < 16\n next.hidden = offset.x > content.width - size.width - 16\n })\n\n /* Paginate content tab container on click */\n merge(\n fromEvent(prev, \"click\").pipe(map(() => -1)),\n fromEvent(next, \"click\").pipe(map(() => +1))\n )\n .pipe(\n takeUntil(done$)\n )\n .subscribe(direction => {\n const { width } = getElementSize(container)\n container.scrollBy({\n left: width * direction,\n behavior: \"smooth\"\n })\n })\n\n /* Set up linking of content tabs, if enabled */\n if (feature(\"content.tabs.link\"))\n push$.pipe(\n skip(1),\n withLatestFrom(viewport$)\n )\n .subscribe(([{ active }, { offset }]) => {\n const tab = active.innerText.trim()\n if (active.hasAttribute(\"data-md-switching\")) {\n active.removeAttribute(\"data-md-switching\")\n\n /* Determine viewport offset of active tab */\n } else {\n const y = el.offsetTop - offset.y\n\n /* Passively activate other tabs */\n for (const set of getElements(\"[data-tabs]\"))\n for (const input of getElements(\n \":scope > input\", set\n )) {\n const label = getElement(`label[for=\"${input.id}\"]`)\n if (\n label !== active &&\n label.innerText.trim() === tab\n ) {\n label.setAttribute(\"data-md-switching\", \"\")\n input.click()\n break\n }\n }\n\n /* Bring active tab into view */\n window.scrollTo({\n top: el.offsetTop - y\n })\n\n /* Persist active tabs in local storage */\n const tabs = __md_get(\"__tabs\") || []\n __md_set(\"__tabs\", [...new Set([tab, ...tabs])])\n }\n })\n\n /* Create and return component */\n return watchContentTabs(el)\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state }))\n )\n })\n .pipe(\n subscribeOn(asyncScheduler)\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, merge } from \"rxjs\"\n\nimport { Viewport, getElements } from \"~/browser\"\n\nimport { Component } from \"../../_\"\nimport { Annotation } from \"../annotation\"\nimport {\n CodeBlock,\n Mermaid,\n mountCodeBlock,\n mountMermaid\n} from \"../code\"\nimport {\n Details,\n mountDetails\n} from \"../details\"\nimport {\n DataTable,\n mountDataTable\n} from \"../table\"\nimport {\n ContentTabs,\n mountContentTabs\n} from \"../tabs\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Content\n */\nexport type Content =\n | Annotation\n | ContentTabs\n | CodeBlock\n | Mermaid\n | DataTable\n | Details\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n viewport$: Observable /* Viewport observable */\n target$: Observable /* Location target observable */\n print$: Observable /* Media print observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount content\n *\n * This function mounts all components that are found in the content of the\n * actual article, including code blocks, data tables and details.\n *\n * @param el - Content element\n * @param options - Options\n *\n * @returns Content component observable\n */\nexport function mountContent(\n el: HTMLElement, { viewport$, target$, print$ }: MountOptions\n): Observable> {\n return merge(\n\n /* Code blocks */\n ...getElements(\"pre:not(.mermaid) > code\", el)\n .map(child => mountCodeBlock(child, { target$, print$ })),\n\n /* Mermaid diagrams */\n ...getElements(\"pre.mermaid\", el)\n .map(child => mountMermaid(child)),\n\n /* Data tables */\n ...getElements(\"table:not([class])\", el)\n .map(child => mountDataTable(child)),\n\n /* Details */\n ...getElements(\"details\", el)\n .map(child => mountDetails(child, { target$, print$ })),\n\n /* Content tabs */\n ...getElements(\"[data-tabs]\", el)\n .map(child => mountContentTabs(child, { viewport$ }))\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n Subject,\n defer,\n delay,\n finalize,\n map,\n merge,\n of,\n switchMap,\n tap\n} from \"rxjs\"\n\nimport { getElement } from \"~/browser\"\n\nimport { Component } from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Dialog\n */\nexport interface Dialog {\n message: string /* Dialog message */\n active: boolean /* Dialog is active */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n alert$: Subject /* Alert subject */\n}\n\n/**\n * Mount options\n */\ninterface MountOptions {\n alert$: Subject /* Alert subject */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch dialog\n *\n * @param _el - Dialog element\n * @param options - Options\n *\n * @returns Dialog observable\n */\nexport function watchDialog(\n _el: HTMLElement, { alert$ }: WatchOptions\n): Observable {\n return alert$\n .pipe(\n switchMap(message => merge(\n of(true),\n of(false).pipe(delay(2000))\n )\n .pipe(\n map(active => ({ message, active }))\n )\n )\n )\n}\n\n/**\n * Mount dialog\n *\n * This function reveals the dialog in the right corner when a new alert is\n * emitted through the subject that is passed as part of the options.\n *\n * @param el - Dialog element\n * @param options - Options\n *\n * @returns Dialog component observable\n */\nexport function mountDialog(\n el: HTMLElement, options: MountOptions\n): Observable> {\n const inner = getElement(\".md-typeset\", el)\n return defer(() => {\n const push$ = new Subject()\n push$.subscribe(({ message, active }) => {\n el.classList.toggle(\"md-dialog--active\", active)\n inner.textContent = message\n })\n\n /* Create and return component */\n return watchDialog(el, options)\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state }))\n )\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n Subject,\n bufferCount,\n combineLatest,\n combineLatestWith,\n defer,\n distinctUntilChanged,\n distinctUntilKeyChanged,\n filter,\n map,\n of,\n shareReplay,\n startWith,\n switchMap,\n takeLast,\n takeUntil\n} from \"rxjs\"\n\nimport { feature } from \"~/_\"\nimport {\n Viewport,\n watchElementSize,\n watchToggle\n} from \"~/browser\"\n\nimport { Component } from \"../../_\"\nimport { Main } from \"../../main\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Header\n */\nexport interface Header {\n height: number /* Header visible height */\n hidden: boolean /* Header is hidden */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n viewport$: Observable /* Viewport observable */\n}\n\n/**\n * Mount options\n */\ninterface MountOptions {\n viewport$: Observable /* Viewport observable */\n header$: Observable
    /* Header observable */\n main$: Observable
    /* Main area observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Compute whether the header is hidden\n *\n * If the user scrolls past a certain threshold, the header can be hidden when\n * scrolling down, and shown when scrolling up.\n *\n * @param options - Options\n *\n * @returns Toggle observable\n */\nfunction isHidden({ viewport$ }: WatchOptions): Observable {\n if (!feature(\"header.autohide\"))\n return of(false)\n\n /* Compute direction and turning point */\n const direction$ = viewport$\n .pipe(\n map(({ offset: { y } }) => y),\n bufferCount(2, 1),\n map(([a, b]) => [a < b, b] as const),\n distinctUntilKeyChanged(0)\n )\n\n /* Compute whether header should be hidden */\n const hidden$ = combineLatest([viewport$, direction$])\n .pipe(\n filter(([{ offset }, [, y]]) => Math.abs(y - offset.y) > 100),\n map(([, [direction]]) => direction),\n distinctUntilChanged()\n )\n\n /* Compute threshold for hiding */\n const search$ = watchToggle(\"search\")\n return combineLatest([viewport$, search$])\n .pipe(\n map(([{ offset }, search]) => offset.y > 400 && !search),\n distinctUntilChanged(),\n switchMap(active => active ? hidden$ : of(false)),\n startWith(false)\n )\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch header\n *\n * @param el - Header element\n * @param options - Options\n *\n * @returns Header observable\n */\nexport function watchHeader(\n el: HTMLElement, options: WatchOptions\n): Observable
    {\n return defer(() => combineLatest([\n watchElementSize(el),\n isHidden(options)\n ]))\n .pipe(\n map(([{ height }, hidden]) => ({\n height,\n hidden\n })),\n distinctUntilChanged((a, b) => (\n a.height === b.height &&\n a.hidden === b.hidden\n )),\n shareReplay(1)\n )\n}\n\n/**\n * Mount header\n *\n * This function manages the different states of the header, i.e. whether it's\n * hidden or rendered with a shadow. This depends heavily on the main area.\n *\n * @param el - Header element\n * @param options - Options\n *\n * @returns Header component observable\n */\nexport function mountHeader(\n el: HTMLElement, { header$, main$ }: MountOptions\n): Observable> {\n return defer(() => {\n const push$ = new Subject
    ()\n const done$ = push$.pipe(takeLast(1))\n push$\n .pipe(\n distinctUntilKeyChanged(\"active\"),\n combineLatestWith(header$)\n )\n .subscribe(([{ active }, { hidden }]) => {\n el.classList.toggle(\"md-header--shadow\", active && !hidden)\n el.hidden = hidden\n })\n\n /* Link to main area */\n main$.subscribe(push$)\n\n /* Create and return component */\n return header$\n .pipe(\n takeUntil(done$),\n map(state => ({ ref: el, ...state }))\n )\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n EMPTY,\n Observable,\n Subject,\n defer,\n distinctUntilKeyChanged,\n finalize,\n map,\n tap\n} from \"rxjs\"\n\nimport {\n Viewport,\n getElementSize,\n getOptionalElement,\n watchViewportAt\n} from \"~/browser\"\n\nimport { Component } from \"../../_\"\nimport { Header } from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Header\n */\nexport interface HeaderTitle {\n active: boolean /* Header title is active */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n viewport$: Observable /* Viewport observable */\n header$: Observable
    /* Header observable */\n}\n\n/**\n * Mount options\n */\ninterface MountOptions {\n viewport$: Observable /* Viewport observable */\n header$: Observable
    /* Header observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch header title\n *\n * @param el - Heading element\n * @param options - Options\n *\n * @returns Header title observable\n */\nexport function watchHeaderTitle(\n el: HTMLElement, { viewport$, header$ }: WatchOptions\n): Observable {\n return watchViewportAt(el, { viewport$, header$ })\n .pipe(\n map(({ offset: { y } }) => {\n const { height } = getElementSize(el)\n return {\n active: y >= height\n }\n }),\n distinctUntilKeyChanged(\"active\")\n )\n}\n\n/**\n * Mount header title\n *\n * This function swaps the header title from the site title to the title of the\n * current page when the user scrolls past the first headline.\n *\n * @param el - Header title element\n * @param options - Options\n *\n * @returns Header title component observable\n */\nexport function mountHeaderTitle(\n el: HTMLElement, options: MountOptions\n): Observable> {\n return defer(() => {\n const push$ = new Subject()\n push$.subscribe(({ active }) => {\n el.classList.toggle(\"md-header__title--active\", active)\n })\n\n /* Obtain headline, if any */\n const heading = getOptionalElement(\"article h1\")\n if (typeof heading === \"undefined\")\n return EMPTY\n\n /* Create and return component */\n return watchHeaderTitle(heading, options)\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state }))\n )\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n combineLatest,\n distinctUntilChanged,\n distinctUntilKeyChanged,\n map,\n switchMap\n} from \"rxjs\"\n\nimport {\n Viewport,\n watchElementSize\n} from \"~/browser\"\n\nimport { Header } from \"../header\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Main area\n */\nexport interface Main {\n offset: number /* Main area top offset */\n height: number /* Main area visible height */\n active: boolean /* Main area is active */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n viewport$: Observable /* Viewport observable */\n header$: Observable
    /* Header observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch main area\n *\n * This function returns an observable that computes the visual parameters of\n * the main area which depends on the viewport vertical offset and height, as\n * well as the height of the header element, if the header is fixed.\n *\n * @param el - Main area element\n * @param options - Options\n *\n * @returns Main area observable\n */\nexport function watchMain(\n el: HTMLElement, { viewport$, header$ }: WatchOptions\n): Observable
    {\n\n /* Compute necessary adjustment for header */\n const adjust$ = header$\n .pipe(\n map(({ height }) => height),\n distinctUntilChanged()\n )\n\n /* Compute the main area's top and bottom borders */\n const border$ = adjust$\n .pipe(\n switchMap(() => watchElementSize(el)\n .pipe(\n map(({ height }) => ({\n top: el.offsetTop,\n bottom: el.offsetTop + height\n })),\n distinctUntilKeyChanged(\"bottom\")\n )\n )\n )\n\n /* Compute the main area's offset, visible height and if we scrolled past */\n return combineLatest([adjust$, border$, viewport$])\n .pipe(\n map(([header, { top, bottom }, { offset: { y }, size: { height } }]) => {\n height = Math.max(0, height\n - Math.max(0, top - y, header)\n - Math.max(0, height + y - bottom)\n )\n return {\n offset: top - header,\n height,\n active: top - header <= y\n }\n }),\n distinctUntilChanged((a, b) => (\n a.offset === b.offset &&\n a.height === b.height &&\n a.active === b.active\n ))\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n Subject,\n asyncScheduler,\n defer,\n finalize,\n fromEvent,\n map,\n mergeMap,\n observeOn,\n of,\n shareReplay,\n startWith,\n tap\n} from \"rxjs\"\n\nimport { getElements } from \"~/browser\"\n\nimport { Component } from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Palette colors\n */\nexport interface PaletteColor {\n scheme?: string /* Color scheme */\n primary?: string /* Primary color */\n accent?: string /* Accent color */\n}\n\n/**\n * Palette\n */\nexport interface Palette {\n index: number /* Palette index */\n color: PaletteColor /* Palette colors */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch color palette\n *\n * @param inputs - Color palette element\n *\n * @returns Color palette observable\n */\nexport function watchPalette(\n inputs: HTMLInputElement[]\n): Observable {\n const current = __md_get(\"__palette\") || {\n index: inputs.findIndex(input => matchMedia(\n input.getAttribute(\"data-md-color-media\")!\n ).matches)\n }\n\n /* Emit changes in color palette */\n return of(...inputs)\n .pipe(\n mergeMap(input => fromEvent(input, \"change\")\n .pipe(\n map(() => input)\n )\n ),\n startWith(inputs[Math.max(0, current.index)]),\n map(input => ({\n index: inputs.indexOf(input),\n color: {\n scheme: input.getAttribute(\"data-md-color-scheme\"),\n primary: input.getAttribute(\"data-md-color-primary\"),\n accent: input.getAttribute(\"data-md-color-accent\")\n }\n } as Palette)),\n shareReplay(1)\n )\n}\n\n/**\n * Mount color palette\n *\n * @param el - Color palette element\n *\n * @returns Color palette component observable\n */\nexport function mountPalette(\n el: HTMLElement\n): Observable> {\n return defer(() => {\n const push$ = new Subject()\n push$.subscribe(palette => {\n document.body.setAttribute(\"data-md-color-switching\", \"\")\n\n /* Set color palette */\n for (const [key, value] of Object.entries(palette.color))\n document.body.setAttribute(`data-md-color-${key}`, value)\n\n /* Toggle visibility */\n for (let index = 0; index < inputs.length; index++) {\n const label = inputs[index].nextElementSibling\n if (label instanceof HTMLElement)\n label.hidden = palette.index !== index\n }\n\n /* Persist preference in local storage */\n __md_set(\"__palette\", palette)\n })\n\n /* Revert transition durations after color switch */\n push$.pipe(observeOn(asyncScheduler))\n .subscribe(() => {\n document.body.removeAttribute(\"data-md-color-switching\")\n })\n\n /* Create and return component */\n const inputs = getElements(\"input\", el)\n return watchPalette(inputs)\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state }))\n )\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport ClipboardJS from \"clipboard\"\nimport {\n Observable,\n Subject,\n map,\n tap\n} from \"rxjs\"\n\nimport { translation } from \"~/_\"\nimport { getElement } from \"~/browser\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Setup options\n */\ninterface SetupOptions {\n alert$: Subject /* Alert subject */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Extract text to copy\n *\n * @param el - HTML element\n *\n * @returns Extracted text\n */\nfunction extract(el: HTMLElement): string {\n el.setAttribute(\"data-md-copying\", \"\")\n const text = el.innerText\n el.removeAttribute(\"data-md-copying\")\n return text\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set up Clipboard.js integration\n *\n * @param options - Options\n */\nexport function setupClipboardJS(\n { alert$ }: SetupOptions\n): void {\n if (ClipboardJS.isSupported()) {\n new Observable(subscriber => {\n new ClipboardJS(\"[data-clipboard-target], [data-clipboard-text]\", {\n text: el => (\n el.getAttribute(\"data-clipboard-text\")! ||\n extract(getElement(\n el.getAttribute(\"data-clipboard-target\")!\n ))\n )\n })\n .on(\"success\", ev => subscriber.next(ev))\n })\n .pipe(\n tap(ev => {\n const trigger = ev.trigger as HTMLElement\n trigger.focus()\n }),\n map(() => translation(\"clipboard.copied\"))\n )\n .subscribe(alert$)\n }\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n EMPTY,\n Observable,\n catchError,\n defaultIfEmpty,\n map,\n of,\n tap\n} from \"rxjs\"\n\nimport { configuration } from \"~/_\"\nimport { getElements, requestXML } from \"~/browser\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Sitemap, i.e. a list of URLs\n */\nexport type Sitemap = string[]\n\n/* ----------------------------------------------------------------------------\n * Helper functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Preprocess a list of URLs\n *\n * This function replaces the `site_url` in the sitemap with the actual base\n * URL, to allow instant loading to work in occasions like Netlify previews.\n *\n * @param urls - URLs\n *\n * @returns URL path parts\n */\nfunction preprocess(urls: Sitemap): Sitemap {\n if (urls.length < 2)\n return [\"\"]\n\n /* Take the first two URLs and remove everything after the last slash */\n const [root, next] = [...urls]\n .sort((a, b) => a.length - b.length)\n .map(url => url.replace(/[^/]+$/, \"\"))\n\n /* Compute common prefix */\n let index = 0\n if (root === next)\n index = root.length\n else\n while (root.charCodeAt(index) === next.charCodeAt(index))\n index++\n\n /* Remove common prefix and return in original order */\n return urls.map(url => url.replace(root.slice(0, index), \"\"))\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Fetch the sitemap for the given base URL\n *\n * @param base - Base URL\n *\n * @returns Sitemap observable\n */\nexport function fetchSitemap(base?: URL): Observable {\n const cached = __md_get(\"__sitemap\", sessionStorage, base)\n if (cached) {\n return of(cached)\n } else {\n const config = configuration()\n return requestXML(new URL(\"sitemap.xml\", base || config.base))\n .pipe(\n map(sitemap => preprocess(getElements(\"loc\", sitemap)\n .map(node => node.textContent!)\n )),\n catchError(() => EMPTY), // @todo refactor instant loading\n defaultIfEmpty([]),\n tap(sitemap => __md_set(\"__sitemap\", sitemap, sessionStorage, base))\n )\n }\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n EMPTY,\n NEVER,\n Observable,\n Subject,\n bufferCount,\n catchError,\n concatMap,\n debounceTime,\n distinctUntilChanged,\n distinctUntilKeyChanged,\n filter,\n fromEvent,\n map,\n merge,\n of,\n sample,\n share,\n skip,\n skipUntil,\n switchMap\n} from \"rxjs\"\n\nimport { configuration, feature } from \"~/_\"\nimport {\n Viewport,\n ViewportOffset,\n getElements,\n getOptionalElement,\n request,\n setLocation,\n setLocationHash\n} from \"~/browser\"\nimport { getComponentElement } from \"~/components\"\nimport { h } from \"~/utilities\"\n\nimport { fetchSitemap } from \"../sitemap\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * History state\n */\nexport interface HistoryState {\n url: URL /* State URL */\n offset?: ViewportOffset /* State viewport offset */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Setup options\n */\ninterface SetupOptions {\n document$: Subject /* Document subject */\n location$: Subject /* Location subject */\n viewport$: Observable /* Viewport observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set up instant loading\n *\n * When fetching, theoretically, we could use `responseType: \"document\"`, but\n * since all MkDocs links are relative, we need to make sure that the current\n * location matches the document we just loaded. Otherwise any relative links\n * in the document could use the old location.\n *\n * This is the reason why we need to synchronize history events and the process\n * of fetching the document for navigation changes (except `popstate` events):\n *\n * 1. Fetch document via `XMLHTTPRequest`\n * 2. Set new location via `history.pushState`\n * 3. Parse and emit fetched document\n *\n * For `popstate` events, we must not use `history.pushState`, or the forward\n * history will be irreversibly overwritten. In case the request fails, the\n * location change is dispatched regularly.\n *\n * @param options - Options\n */\nexport function setupInstantLoading(\n { document$, location$, viewport$ }: SetupOptions\n): void {\n const config = configuration()\n if (location.protocol === \"file:\")\n return\n\n /* Disable automatic scroll restoration */\n if (\"scrollRestoration\" in history) {\n history.scrollRestoration = \"manual\"\n\n /* Hack: ensure that reloads restore viewport offset */\n fromEvent(window, \"beforeunload\")\n .subscribe(() => {\n history.scrollRestoration = \"auto\"\n })\n }\n\n /* Hack: ensure absolute favicon link to omit 404s when switching */\n const favicon = getOptionalElement(\"link[rel=icon]\")\n if (typeof favicon !== \"undefined\")\n favicon.href = favicon.href\n\n /* Intercept internal navigation */\n const push$ = fetchSitemap()\n .pipe(\n map(paths => paths.map(path => `${new URL(path, config.base)}`)),\n switchMap(urls => fromEvent(document.body, \"click\")\n .pipe(\n filter(ev => !ev.metaKey && !ev.ctrlKey),\n switchMap(ev => {\n if (ev.target instanceof Element) {\n const el = ev.target.closest(\"a\")\n if (el && !el.target) {\n const url = new URL(el.href)\n\n /* Canonicalize URL */\n url.search = \"\"\n url.hash = \"\"\n\n /* Check if URL should be intercepted */\n if (\n url.pathname !== location.pathname &&\n urls.includes(url.toString())\n ) {\n ev.preventDefault()\n return of({\n url: new URL(el.href)\n })\n }\n }\n }\n return NEVER\n })\n )\n ),\n share()\n )\n\n /* Intercept history back and forward */\n const pop$ = fromEvent(window, \"popstate\")\n .pipe(\n filter(ev => ev.state !== null),\n map(ev => ({\n url: new URL(location.href),\n offset: ev.state\n })),\n share()\n )\n\n /* Emit location change */\n merge(push$, pop$)\n .pipe(\n distinctUntilChanged((a, b) => a.url.href === b.url.href),\n map(({ url }) => url)\n )\n .subscribe(location$)\n\n /* Fetch document via `XMLHTTPRequest` */\n const response$ = location$\n .pipe(\n distinctUntilKeyChanged(\"pathname\"),\n switchMap(url => request(url.href)\n .pipe(\n catchError(() => {\n setLocation(url)\n return NEVER\n })\n )\n ),\n share()\n )\n\n /* Set new location via `history.pushState` */\n push$\n .pipe(\n sample(response$)\n )\n .subscribe(({ url }) => {\n history.pushState({}, \"\", `${url}`)\n })\n\n /* Parse and emit fetched document */\n const dom = new DOMParser()\n response$\n .pipe(\n switchMap(res => res.text()),\n map(res => dom.parseFromString(res, \"text/html\"))\n )\n .subscribe(document$)\n\n /* Replace meta tags and components */\n document$\n .pipe(\n skip(1)\n )\n .subscribe(replacement => {\n for (const selector of [\n\n /* Meta tags */\n \"title\",\n \"link[rel=canonical]\",\n \"meta[name=author]\",\n \"meta[name=description]\",\n\n /* Components */\n \"[data-md-component=announce]\",\n \"[data-md-component=container]\",\n \"[data-md-component=header-topic]\",\n \"[data-md-component=outdated]\",\n \"[data-md-component=logo]\",\n \"[data-md-component=skip]\",\n ...feature(\"navigation.tabs.sticky\")\n ? [\"[data-md-component=tabs]\"]\n : []\n ]) {\n const source = getOptionalElement(selector)\n const target = getOptionalElement(selector, replacement)\n if (\n typeof source !== \"undefined\" &&\n typeof target !== \"undefined\"\n ) {\n source.replaceWith(target)\n }\n }\n })\n\n /* Re-evaluate scripts */\n document$\n .pipe(\n skip(1),\n map(() => getComponentElement(\"container\")),\n switchMap(el => getElements(\"script\", el)),\n concatMap(el => {\n const script = h(\"script\")\n if (el.src) {\n for (const name of el.getAttributeNames())\n script.setAttribute(name, el.getAttribute(name)!)\n el.replaceWith(script)\n\n /* Complete when script is loaded */\n return new Observable(observer => {\n script.onload = () => observer.complete()\n })\n\n /* Complete immediately */\n } else {\n script.textContent = el.textContent\n el.replaceWith(script)\n return EMPTY\n }\n })\n )\n .subscribe()\n\n /* Emit history state change */\n merge(push$, pop$)\n .pipe(\n sample(document$)\n )\n .subscribe(({ url, offset }) => {\n if (url.hash && !offset) {\n setLocationHash(url.hash)\n } else {\n window.scrollTo(0, offset?.y || 0)\n }\n })\n\n /* Debounce update of viewport offset */\n viewport$\n .pipe(\n skipUntil(push$),\n debounceTime(250),\n distinctUntilKeyChanged(\"offset\")\n )\n .subscribe(({ offset }) => {\n history.replaceState(offset, \"\")\n })\n\n /* Set viewport offset from history */\n merge(push$, pop$)\n .pipe(\n bufferCount(2, 1),\n filter(([a, b]) => a.url.pathname === b.url.pathname),\n map(([, state]) => state)\n )\n .subscribe(({ offset }) => {\n window.scrollTo(0, offset?.y || 0)\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport escapeHTML from \"escape-html\"\n\nimport { SearchIndexDocument } from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Search document\n */\nexport interface SearchDocument extends SearchIndexDocument {\n parent?: SearchIndexDocument /* Parent article */\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Search document mapping\n */\nexport type SearchDocumentMap = Map\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Create a search document mapping\n *\n * @param docs - Search index documents\n *\n * @returns Search document map\n */\nexport function setupSearchDocumentMap(\n docs: SearchIndexDocument[]\n): SearchDocumentMap {\n const documents = new Map()\n const parents = new Set()\n for (const doc of docs) {\n const [path, hash] = doc.location.split(\"#\")\n\n /* Extract location, title and tags */\n const location = doc.location\n const title = doc.title\n const tags = doc.tags\n\n /* Escape and cleanup text */\n const text = escapeHTML(doc.text)\n .replace(/\\s+(?=[,.:;!?])/g, \"\")\n .replace(/\\s+/g, \" \")\n\n /* Handle section */\n if (hash) {\n const parent = documents.get(path)!\n\n /* Ignore first section, override article */\n if (!parents.has(parent)) {\n parent.title = doc.title\n parent.text = text\n\n /* Remember that we processed the article */\n parents.add(parent)\n\n /* Add subsequent section */\n } else {\n documents.set(location, {\n location,\n title,\n text,\n parent\n })\n }\n\n /* Add article */\n } else {\n documents.set(location, {\n location,\n title,\n text,\n ...tags && { tags }\n })\n }\n }\n return documents\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport escapeHTML from \"escape-html\"\n\nimport { SearchIndexConfig } from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Search highlight function\n *\n * @param value - Value\n *\n * @returns Highlighted value\n */\nexport type SearchHighlightFn = (value: string) => string\n\n/**\n * Search highlight factory function\n *\n * @param query - Query value\n *\n * @returns Search highlight function\n */\nexport type SearchHighlightFactoryFn = (query: string) => SearchHighlightFn\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Create a search highlighter\n *\n * @param config - Search index configuration\n * @param escape - Whether to escape HTML\n *\n * @returns Search highlight factory function\n */\nexport function setupSearchHighlighter(\n config: SearchIndexConfig, escape: boolean\n): SearchHighlightFactoryFn {\n const separator = new RegExp(config.separator, \"img\")\n const highlight = (_: unknown, data: string, term: string) => {\n return `${data}${term}`\n }\n\n /* Return factory function */\n return (query: string) => {\n query = query\n .replace(/[\\s*+\\-:~^]+/g, \" \")\n .trim()\n\n /* Create search term match expression */\n const match = new RegExp(`(^|${config.separator})(${\n query\n .replace(/[|\\\\{}()[\\]^$+*?.-]/g, \"\\\\$&\")\n .replace(separator, \"|\")\n })`, \"img\")\n\n /* Highlight string value */\n return value => (\n escape\n ? escapeHTML(value)\n : value\n )\n .replace(match, highlight)\n .replace(/<\\/mark>(\\s+)]*>/img, \"$1\")\n }\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Search transformation function\n *\n * @param value - Query value\n *\n * @returns Transformed query value\n */\nexport type SearchTransformFn = (value: string) => string\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Default transformation function\n *\n * 1. Search for terms in quotation marks and prepend a `+` modifier to denote\n * that the resulting document must contain all terms, converting the query\n * to an `AND` query (as opposed to the default `OR` behavior). While users\n * may expect terms enclosed in quotation marks to map to span queries, i.e.\n * for which order is important, Lunr.js doesn't support them, so the best\n * we can do is to convert the terms to an `AND` query.\n *\n * 2. Replace control characters which are not located at the beginning of the\n * query or preceded by white space, or are not followed by a non-whitespace\n * character or are at the end of the query string. Furthermore, filter\n * unmatched quotation marks.\n *\n * 3. Trim excess whitespace from left and right.\n *\n * @param query - Query value\n *\n * @returns Transformed query value\n */\nexport function defaultTransform(query: string): string {\n return query\n .split(/\"([^\"]+)\"/g) /* => 1 */\n .map((terms, index) => index & 1\n ? terms.replace(/^\\b|^(?![^\\x00-\\x7F]|$)|\\s+/g, \" +\")\n : terms\n )\n .join(\"\")\n .replace(/\"|(?:^|\\s+)[*+\\-:^~]+(?=\\s+|$)/g, \"\") /* => 2 */\n .trim() /* => 3 */\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A RTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { SearchIndex, SearchResult } from \"../../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Search message type\n */\nexport const enum SearchMessageType {\n SETUP, /* Search index setup */\n READY, /* Search index ready */\n QUERY, /* Search query */\n RESULT /* Search results */\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Message containing the data necessary to setup the search index\n */\nexport interface SearchSetupMessage {\n type: SearchMessageType.SETUP /* Message type */\n data: SearchIndex /* Message data */\n}\n\n/**\n * Message indicating the search index is ready\n */\nexport interface SearchReadyMessage {\n type: SearchMessageType.READY /* Message type */\n}\n\n/**\n * Message containing a search query\n */\nexport interface SearchQueryMessage {\n type: SearchMessageType.QUERY /* Message type */\n data: string /* Message data */\n}\n\n/**\n * Message containing results for a search query\n */\nexport interface SearchResultMessage {\n type: SearchMessageType.RESULT /* Message type */\n data: SearchResult /* Message data */\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Message exchanged with the search worker\n */\nexport type SearchMessage =\n | SearchSetupMessage\n | SearchReadyMessage\n | SearchQueryMessage\n | SearchResultMessage\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Type guard for search setup messages\n *\n * @param message - Search worker message\n *\n * @returns Test result\n */\nexport function isSearchSetupMessage(\n message: SearchMessage\n): message is SearchSetupMessage {\n return message.type === SearchMessageType.SETUP\n}\n\n/**\n * Type guard for search ready messages\n *\n * @param message - Search worker message\n *\n * @returns Test result\n */\nexport function isSearchReadyMessage(\n message: SearchMessage\n): message is SearchReadyMessage {\n return message.type === SearchMessageType.READY\n}\n\n/**\n * Type guard for search query messages\n *\n * @param message - Search worker message\n *\n * @returns Test result\n */\nexport function isSearchQueryMessage(\n message: SearchMessage\n): message is SearchQueryMessage {\n return message.type === SearchMessageType.QUERY\n}\n\n/**\n * Type guard for search result messages\n *\n * @param message - Search worker message\n *\n * @returns Test result\n */\nexport function isSearchResultMessage(\n message: SearchMessage\n): message is SearchResultMessage {\n return message.type === SearchMessageType.RESULT\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A RTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n ObservableInput,\n Subject,\n from,\n map,\n share\n} from \"rxjs\"\n\nimport { configuration, feature, translation } from \"~/_\"\nimport { WorkerHandler, watchWorker } from \"~/browser\"\n\nimport { SearchIndex } from \"../../_\"\nimport {\n SearchOptions,\n SearchPipeline\n} from \"../../options\"\nimport {\n SearchMessage,\n SearchMessageType,\n SearchSetupMessage,\n isSearchResultMessage\n} from \"../message\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Search worker\n */\nexport type SearchWorker = WorkerHandler\n\n/* ----------------------------------------------------------------------------\n * Helper functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set up search index\n *\n * @param data - Search index\n *\n * @returns Search index\n */\nfunction setupSearchIndex({ config, docs }: SearchIndex): SearchIndex {\n\n /* Override default language with value from translation */\n if (config.lang.length === 1 && config.lang[0] === \"en\")\n config.lang = [\n translation(\"search.config.lang\")\n ]\n\n /* Override default separator with value from translation */\n if (config.separator === \"[\\\\s\\\\-]+\")\n config.separator = translation(\"search.config.separator\")\n\n /* Set pipeline from translation */\n const pipeline = translation(\"search.config.pipeline\")\n .split(/\\s*,\\s*/)\n .filter(Boolean) as SearchPipeline\n\n /* Determine search options */\n const options: SearchOptions = {\n pipeline,\n suggestions: feature(\"search.suggest\")\n }\n\n /* Return search index after defaulting */\n return { config, docs, options }\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set up search worker\n *\n * This function creates a web worker to set up and query the search index,\n * which is done using Lunr.js. The index must be passed as an observable to\n * enable hacks like _localsearch_ via search index embedding as JSON.\n *\n * @param url - Worker URL\n * @param index - Search index observable input\n *\n * @returns Search worker\n */\nexport function setupSearchWorker(\n url: string, index: ObservableInput\n): SearchWorker {\n const config = configuration()\n const worker = new Worker(url)\n\n /* Create communication channels and resolve relative links */\n const tx$ = new Subject()\n const rx$ = watchWorker(worker, { tx$ })\n .pipe(\n map(message => {\n if (isSearchResultMessage(message)) {\n for (const result of message.data.items)\n for (const document of result)\n document.location = `${new URL(document.location, config.base)}`\n }\n return message\n }),\n share()\n )\n\n /* Set up search index */\n from(index)\n .pipe(\n map(data => ({\n type: SearchMessageType.SETUP,\n data: setupSearchIndex(data)\n } as SearchSetupMessage))\n )\n .subscribe(tx$.next.bind(tx$))\n\n /* Return search worker */\n return { tx$, rx$ }\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n EMPTY,\n Subject,\n catchError,\n combineLatest,\n filter,\n fromEvent,\n map,\n of,\n switchMap,\n withLatestFrom\n} from \"rxjs\"\n\nimport { configuration } from \"~/_\"\nimport {\n getElement,\n getLocation,\n requestJSON,\n setLocation\n} from \"~/browser\"\nimport { getComponentElements } from \"~/components\"\nimport {\n Version,\n renderVersionSelector\n} from \"~/templates\"\n\nimport { fetchSitemap } from \"../sitemap\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Setup options\n */\ninterface SetupOptions {\n document$: Subject /* Document subject */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set up version selector\n *\n * @param options - Options\n */\nexport function setupVersionSelector(\n { document$ }: SetupOptions\n): void {\n const config = configuration()\n const versions$ = requestJSON(\n new URL(\"../versions.json\", config.base)\n )\n .pipe(\n catchError(() => EMPTY) // @todo refactor instant loading\n )\n\n /* Determine current version */\n const current$ = versions$\n .pipe(\n map(versions => {\n const [, current] = config.base.match(/([^/]+)\\/?$/)!\n return versions.find(({ version, aliases }) => (\n version === current || aliases.includes(current)\n )) || versions[0]\n })\n )\n\n /* Intercept inter-version navigation */\n versions$\n .pipe(\n map(versions => new Map(versions.map(version => [\n `${new URL(`../${version.version}/`, config.base)}`,\n version\n ]))),\n switchMap(urls => fromEvent(document.body, \"click\")\n .pipe(\n filter(ev => !ev.metaKey && !ev.ctrlKey),\n withLatestFrom(current$),\n switchMap(([ev, current]) => {\n if (ev.target instanceof Element) {\n const el = ev.target.closest(\"a\")\n if (el && !el.target && urls.has(el.href)) {\n const url = el.href\n // This is a temporary hack to detect if a version inside the\n // version selector or on another part of the site was clicked.\n // If we're inside the version selector, we definitely want to\n // find the same page, as we might have different deployments\n // due to aliases. However, if we're outside the version\n // selector, we must abort here, because we might otherwise\n // interfere with instant loading. We need to refactor this\n // at some point together with instant loading.\n //\n // See https://github.com/squidfunk/mkdocs-material/issues/4012\n if (!ev.target.closest(\".md-version\")) {\n const version = urls.get(url)!\n if (version === current)\n return EMPTY\n }\n ev.preventDefault()\n return of(url)\n }\n }\n return EMPTY\n }),\n switchMap(url => {\n const { version } = urls.get(url)!\n return fetchSitemap(new URL(url))\n .pipe(\n map(sitemap => {\n const location = getLocation()\n const path = location.href.replace(config.base, \"\")\n return sitemap.includes(path.split(\"#\")[0])\n ? new URL(`../${version}/${path}`, config.base)\n : new URL(url)\n })\n )\n })\n )\n )\n )\n .subscribe(url => setLocation(url))\n\n /* Render version selector and warning */\n combineLatest([versions$, current$])\n .subscribe(([versions, current]) => {\n const topic = getElement(\".md-header__topic\")\n topic.appendChild(renderVersionSelector(versions, current))\n })\n\n /* Integrate outdated version banner with instant loading */\n document$.pipe(switchMap(() => current$))\n .subscribe(current => {\n\n /* Check if version state was already determined */\n let outdated = __md_get(\"__outdated\", sessionStorage)\n if (outdated === null) {\n const latest = config.version?.default || \"latest\"\n outdated = !current.aliases.includes(latest)\n\n /* Persist version state in session storage */\n __md_set(\"__outdated\", outdated, sessionStorage)\n }\n\n /* Unhide outdated version banner */\n if (outdated)\n for (const warning of getComponentElements(\"outdated\"))\n warning.hidden = false\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n Subject,\n combineLatest,\n delay,\n distinctUntilChanged,\n distinctUntilKeyChanged,\n filter,\n finalize,\n fromEvent,\n map,\n merge,\n share,\n shareReplay,\n startWith,\n take,\n takeLast,\n takeUntil,\n tap\n} from \"rxjs\"\n\nimport { translation } from \"~/_\"\nimport {\n getLocation,\n setToggle,\n watchElementFocus,\n watchToggle\n} from \"~/browser\"\nimport {\n SearchMessageType,\n SearchQueryMessage,\n SearchWorker,\n defaultTransform,\n isSearchReadyMessage\n} from \"~/integrations\"\n\nimport { Component } from \"../../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Search query\n */\nexport interface SearchQuery {\n value: string /* Query value */\n focus: boolean /* Query focus */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch search query\n *\n * Note that the focus event which triggers re-reading the current query value\n * is delayed by `1ms` so the input's empty state is allowed to propagate.\n *\n * @param el - Search query element\n * @param worker - Search worker\n *\n * @returns Search query observable\n */\nexport function watchSearchQuery(\n el: HTMLInputElement, { rx$ }: SearchWorker\n): Observable {\n const fn = __search?.transform || defaultTransform\n\n /* Immediately show search dialog */\n const { searchParams } = getLocation()\n if (searchParams.has(\"q\"))\n setToggle(\"search\", true)\n\n /* Intercept query parameter (deep link) */\n const param$ = rx$\n .pipe(\n filter(isSearchReadyMessage),\n take(1),\n map(() => searchParams.get(\"q\") || \"\")\n )\n\n /* Remove query parameter when search is closed */\n watchToggle(\"search\")\n .pipe(\n filter(active => !active),\n take(1)\n )\n .subscribe(() => {\n const url = new URL(location.href)\n url.searchParams.delete(\"q\")\n history.replaceState({}, \"\", `${url}`)\n })\n\n /* Set query from parameter */\n param$.subscribe(value => { // TODO: not ideal - find a better way\n if (value) {\n el.value = value\n el.focus()\n }\n })\n\n /* Intercept focus and input events */\n const focus$ = watchElementFocus(el)\n const value$ = merge(\n fromEvent(el, \"keyup\"),\n fromEvent(el, \"focus\").pipe(delay(1)),\n param$\n )\n .pipe(\n map(() => fn(el.value)),\n startWith(\"\"),\n distinctUntilChanged(),\n )\n\n /* Combine into single observable */\n return combineLatest([value$, focus$])\n .pipe(\n map(([value, focus]) => ({ value, focus })),\n shareReplay(1)\n )\n}\n\n/**\n * Mount search query\n *\n * @param el - Search query element\n * @param worker - Search worker\n *\n * @returns Search query component observable\n */\nexport function mountSearchQuery(\n el: HTMLInputElement, { tx$, rx$ }: SearchWorker\n): Observable> {\n const push$ = new Subject()\n const done$ = push$.pipe(takeLast(1))\n\n /* Handle value changes */\n push$\n .pipe(\n distinctUntilKeyChanged(\"value\"),\n map(({ value }): SearchQueryMessage => ({\n type: SearchMessageType.QUERY,\n data: value\n }))\n )\n .subscribe(tx$.next.bind(tx$))\n\n /* Handle focus changes */\n push$\n .pipe(\n distinctUntilKeyChanged(\"focus\")\n )\n .subscribe(({ focus }) => {\n if (focus) {\n setToggle(\"search\", focus)\n el.placeholder = \"\"\n } else {\n el.placeholder = translation(\"search.placeholder\")\n }\n })\n\n /* Handle reset */\n fromEvent(el.form!, \"reset\")\n .pipe(\n takeUntil(done$)\n )\n .subscribe(() => el.focus())\n\n /* Create and return component */\n return watchSearchQuery(el, { tx$, rx$ })\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state })),\n share()\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n Subject,\n bufferCount,\n filter,\n finalize,\n map,\n merge,\n of,\n skipUntil,\n switchMap,\n take,\n tap,\n withLatestFrom,\n zipWith\n} from \"rxjs\"\n\nimport { translation } from \"~/_\"\nimport {\n getElement,\n watchElementBoundary\n} from \"~/browser\"\nimport {\n SearchResult,\n SearchWorker,\n isSearchReadyMessage,\n isSearchResultMessage\n} from \"~/integrations\"\nimport { renderSearchResultItem } from \"~/templates\"\nimport { round } from \"~/utilities\"\n\nimport { Component } from \"../../_\"\nimport { SearchQuery } from \"../query\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n query$: Observable /* Search query observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount search result list\n *\n * This function performs a lazy rendering of the search results, depending on\n * the vertical offset of the search result container.\n *\n * @param el - Search result list element\n * @param worker - Search worker\n * @param options - Options\n *\n * @returns Search result list component observable\n */\nexport function mountSearchResult(\n el: HTMLElement, { rx$ }: SearchWorker, { query$ }: MountOptions\n): Observable> {\n const push$ = new Subject()\n const boundary$ = watchElementBoundary(el.parentElement!)\n .pipe(\n filter(Boolean)\n )\n\n /* Retrieve nested components */\n const meta = getElement(\":scope > :first-child\", el)\n const list = getElement(\":scope > :last-child\", el)\n\n /* Wait until search is ready */\n const ready$ = rx$\n .pipe(\n filter(isSearchReadyMessage),\n take(1)\n )\n\n /* Update search result metadata */\n push$\n .pipe(\n withLatestFrom(query$),\n skipUntil(ready$)\n )\n .subscribe(([{ items }, { value }]) => {\n if (value) {\n switch (items.length) {\n\n /* No results */\n case 0:\n meta.textContent = translation(\"search.result.none\")\n break\n\n /* One result */\n case 1:\n meta.textContent = translation(\"search.result.one\")\n break\n\n /* Multiple result */\n default:\n meta.textContent = translation(\n \"search.result.other\",\n round(items.length)\n )\n }\n } else {\n meta.textContent = translation(\"search.result.placeholder\")\n }\n })\n\n /* Update search result list */\n push$\n .pipe(\n tap(() => list.innerHTML = \"\"),\n switchMap(({ items }) => merge(\n of(...items.slice(0, 10)),\n of(...items.slice(10))\n .pipe(\n bufferCount(4),\n zipWith(boundary$),\n switchMap(([chunk]) => chunk)\n )\n ))\n )\n .subscribe(result => list.appendChild(\n renderSearchResultItem(result)\n ))\n\n /* Filter search result message */\n const result$ = rx$\n .pipe(\n filter(isSearchResultMessage),\n map(({ data }) => data)\n )\n\n /* Create and return component */\n return result$\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state }))\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n Subject,\n finalize,\n fromEvent,\n map,\n tap\n} from \"rxjs\"\n\nimport { getLocation } from \"~/browser\"\n\nimport { Component } from \"../../_\"\nimport { SearchQuery } from \"../query\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Search sharing\n */\nexport interface SearchShare {\n url: URL /* Deep link for sharing */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n query$: Observable /* Search query observable */\n}\n\n/**\n * Mount options\n */\ninterface MountOptions {\n query$: Observable /* Search query observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount search sharing\n *\n * @param _el - Search sharing element\n * @param options - Options\n *\n * @returns Search sharing observable\n */\nexport function watchSearchShare(\n _el: HTMLElement, { query$ }: WatchOptions\n): Observable {\n return query$\n .pipe(\n map(({ value }) => {\n const url = getLocation()\n url.hash = \"\"\n url.searchParams.delete(\"h\")\n url.searchParams.set(\"q\", value)\n return { url }\n })\n )\n}\n\n/**\n * Mount search sharing\n *\n * @param el - Search sharing element\n * @param options - Options\n *\n * @returns Search sharing component observable\n */\nexport function mountSearchShare(\n el: HTMLAnchorElement, options: MountOptions\n): Observable> {\n const push$ = new Subject()\n push$.subscribe(({ url }) => {\n el.setAttribute(\"data-clipboard-text\", el.href)\n el.href = `${url}`\n })\n\n /* Prevent following of link */\n fromEvent(el, \"click\")\n .subscribe(ev => ev.preventDefault())\n\n /* Create and return component */\n return watchSearchShare(el, options)\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state }))\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n Subject,\n asyncScheduler,\n combineLatestWith,\n distinctUntilChanged,\n filter,\n finalize,\n fromEvent,\n map,\n merge,\n observeOn,\n tap\n} from \"rxjs\"\n\nimport { Keyboard } from \"~/browser\"\nimport {\n SearchResult,\n SearchWorker,\n isSearchResultMessage\n} from \"~/integrations\"\n\nimport { Component, getComponentElement } from \"../../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Search suggestions\n */\nexport interface SearchSuggest {}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n keyboard$: Observable /* Keyboard observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount search suggestions\n *\n * This function will perform a lazy rendering of the search results, depending\n * on the vertical offset of the search result container.\n *\n * @param el - Search result list element\n * @param worker - Search worker\n * @param options - Options\n *\n * @returns Search result list component observable\n */\nexport function mountSearchSuggest(\n el: HTMLElement, { rx$ }: SearchWorker, { keyboard$ }: MountOptions\n): Observable> {\n const push$ = new Subject()\n\n /* Retrieve query component and track all changes */\n const query = getComponentElement(\"search-query\")\n const query$ = merge(\n fromEvent(query, \"keydown\"),\n fromEvent(query, \"focus\")\n )\n .pipe(\n observeOn(asyncScheduler),\n map(() => query.value),\n distinctUntilChanged(),\n )\n\n /* Update search suggestions */\n push$\n .pipe(\n combineLatestWith(query$),\n map(([{ suggestions }, value]) => {\n const words = value.split(/([\\s-]+)/)\n if (suggestions?.length && words[words.length - 1]) {\n const last = suggestions[suggestions.length - 1]\n if (last.startsWith(words[words.length - 1]))\n words[words.length - 1] = last\n } else {\n words.length = 0\n }\n return words\n })\n )\n .subscribe(words => el.innerHTML = words\n .join(\"\")\n .replace(/\\s/g, \" \")\n )\n\n /* Set up search keyboard handlers */\n keyboard$\n .pipe(\n filter(({ mode }) => mode === \"search\")\n )\n .subscribe(key => {\n switch (key.type) {\n\n /* Right arrow: accept current suggestion */\n case \"ArrowRight\":\n if (\n el.innerText.length &&\n query.selectionStart === query.value.length\n )\n query.value = el.innerText\n break\n }\n })\n\n /* Filter search result message */\n const result$ = rx$\n .pipe(\n filter(isSearchResultMessage),\n map(({ data }) => data)\n )\n\n /* Create and return component */\n return result$\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(() => ({ ref: el }))\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n NEVER,\n Observable,\n ObservableInput,\n filter,\n merge,\n mergeWith,\n sample,\n take\n} from \"rxjs\"\n\nimport { configuration } from \"~/_\"\nimport {\n Keyboard,\n getActiveElement,\n getElements,\n setToggle\n} from \"~/browser\"\nimport {\n SearchIndex,\n SearchResult,\n isSearchQueryMessage,\n isSearchReadyMessage,\n setupSearchWorker\n} from \"~/integrations\"\n\nimport {\n Component,\n getComponentElement,\n getComponentElements\n} from \"../../_\"\nimport {\n SearchQuery,\n mountSearchQuery\n} from \"../query\"\nimport { mountSearchResult } from \"../result\"\nimport {\n SearchShare,\n mountSearchShare\n} from \"../share\"\nimport {\n SearchSuggest,\n mountSearchSuggest\n} from \"../suggest\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Search\n */\nexport type Search =\n | SearchQuery\n | SearchResult\n | SearchShare\n | SearchSuggest\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n index$: ObservableInput /* Search index observable */\n keyboard$: Observable /* Keyboard observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount search\n *\n * This function sets up the search functionality, including the underlying\n * web worker and all keyboard bindings.\n *\n * @param el - Search element\n * @param options - Options\n *\n * @returns Search component observable\n */\nexport function mountSearch(\n el: HTMLElement, { index$, keyboard$ }: MountOptions\n): Observable> {\n const config = configuration()\n try {\n const url = __search?.worker || config.search\n const worker = setupSearchWorker(url, index$)\n\n /* Retrieve query and result components */\n const query = getComponentElement(\"search-query\", el)\n const result = getComponentElement(\"search-result\", el)\n\n /* Re-emit query when search is ready */\n const { tx$, rx$ } = worker\n tx$\n .pipe(\n filter(isSearchQueryMessage),\n sample(rx$.pipe(filter(isSearchReadyMessage))),\n take(1)\n )\n .subscribe(tx$.next.bind(tx$))\n\n /* Set up search keyboard handlers */\n keyboard$\n .pipe(\n filter(({ mode }) => mode === \"search\")\n )\n .subscribe(key => {\n const active = getActiveElement()\n switch (key.type) {\n\n /* Enter: go to first (best) result */\n case \"Enter\":\n if (active === query) {\n const anchors = new Map()\n for (const anchor of getElements(\n \":first-child [href]\", result\n )) {\n const article = anchor.firstElementChild!\n anchors.set(anchor, parseFloat(\n article.getAttribute(\"data-md-score\")!\n ))\n }\n\n /* Go to result with highest score, if any */\n if (anchors.size) {\n const [[best]] = [...anchors].sort(([, a], [, b]) => b - a)\n best.click()\n }\n\n /* Otherwise omit form submission */\n key.claim()\n }\n break\n\n /* Escape or Tab: close search */\n case \"Escape\":\n case \"Tab\":\n setToggle(\"search\", false)\n query.blur()\n break\n\n /* Vertical arrows: select previous or next search result */\n case \"ArrowUp\":\n case \"ArrowDown\":\n if (typeof active === \"undefined\") {\n query.focus()\n } else {\n const els = [query, ...getElements(\n \":not(details) > [href], summary, details[open] [href]\",\n result\n )]\n const i = Math.max(0, (\n Math.max(0, els.indexOf(active)) + els.length + (\n key.type === \"ArrowUp\" ? -1 : +1\n )\n ) % els.length)\n els[i].focus()\n }\n\n /* Prevent scrolling of page */\n key.claim()\n break\n\n /* All other keys: hand to search query */\n default:\n if (query !== getActiveElement())\n query.focus()\n }\n })\n\n /* Set up global keyboard handlers */\n keyboard$\n .pipe(\n filter(({ mode }) => mode === \"global\"),\n )\n .subscribe(key => {\n switch (key.type) {\n\n /* Open search and select query */\n case \"f\":\n case \"s\":\n case \"/\":\n query.focus()\n query.select()\n\n /* Prevent scrolling of page */\n key.claim()\n break\n }\n })\n\n /* Create and return component */\n const query$ = mountSearchQuery(query, worker)\n const result$ = mountSearchResult(result, worker, { query$ })\n return merge(query$, result$)\n .pipe(\n mergeWith(\n\n /* Search sharing */\n ...getComponentElements(\"search-share\", el)\n .map(child => mountSearchShare(child, { query$ })),\n\n /* Search suggestions */\n ...getComponentElements(\"search-suggest\", el)\n .map(child => mountSearchSuggest(child, worker, { keyboard$ }))\n )\n )\n\n /* Gracefully handle broken search */\n } catch (err) {\n el.hidden = true\n return NEVER\n }\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n ObservableInput,\n combineLatest,\n filter,\n map,\n startWith\n} from \"rxjs\"\n\nimport { getLocation } from \"~/browser\"\nimport {\n SearchIndex,\n setupSearchHighlighter\n} from \"~/integrations\"\nimport { h } from \"~/utilities\"\n\nimport { Component } from \"../../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Search highlighting\n */\nexport interface SearchHighlight {\n nodes: Map /* Map of replacements */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n index$: ObservableInput /* Search index observable */\n location$: Observable /* Location observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount search highlighting\n *\n * @param el - Content element\n * @param options - Options\n *\n * @returns Search highlighting component observable\n */\nexport function mountSearchHiglight(\n el: HTMLElement, { index$, location$ }: MountOptions\n): Observable> {\n return combineLatest([\n index$,\n location$\n .pipe(\n startWith(getLocation()),\n filter(url => !!url.searchParams.get(\"h\"))\n )\n ])\n .pipe(\n map(([index, url]) => setupSearchHighlighter(index.config, true)(\n url.searchParams.get(\"h\")!\n )),\n map(fn => {\n const nodes = new Map()\n\n /* Traverse text nodes and collect matches */\n const it = document.createNodeIterator(el, NodeFilter.SHOW_TEXT)\n for (let node = it.nextNode(); node; node = it.nextNode()) {\n if (node.parentElement?.offsetHeight) {\n const original = node.textContent!\n const replaced = fn(original)\n if (replaced.length > original.length)\n nodes.set(node as ChildNode, replaced)\n }\n }\n\n /* Replace original nodes with matches */\n for (const [node, text] of nodes) {\n const { childNodes } = h(\"span\", null, text)\n node.replaceWith(...Array.from(childNodes))\n }\n\n /* Return component */\n return { ref: el, nodes }\n })\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n Subject,\n animationFrameScheduler,\n auditTime,\n combineLatest,\n defer,\n distinctUntilChanged,\n finalize,\n map,\n observeOn,\n take,\n tap,\n withLatestFrom\n} from \"rxjs\"\n\nimport {\n Viewport,\n getElement,\n getElementContainer,\n getElementOffset,\n getElementSize,\n getElements\n} from \"~/browser\"\n\nimport { Component } from \"../_\"\nimport { Header } from \"../header\"\nimport { Main } from \"../main\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Sidebar\n */\nexport interface Sidebar {\n height: number /* Sidebar height */\n locked: boolean /* Sidebar is locked */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n viewport$: Observable /* Viewport observable */\n main$: Observable
    /* Main area observable */\n}\n\n/**\n * Mount options\n */\ninterface MountOptions {\n viewport$: Observable /* Viewport observable */\n header$: Observable
    /* Header observable */\n main$: Observable
    /* Main area observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch sidebar\n *\n * This function returns an observable that computes the visual parameters of\n * the sidebar which depends on the vertical viewport offset, as well as the\n * height of the main area. When the page is scrolled beyond the header, the\n * sidebar is locked and fills the remaining space.\n *\n * @param el - Sidebar element\n * @param options - Options\n *\n * @returns Sidebar observable\n */\nexport function watchSidebar(\n el: HTMLElement, { viewport$, main$ }: WatchOptions\n): Observable {\n const parent = el.parentElement!\n const adjust =\n parent.offsetTop -\n parent.parentElement!.offsetTop\n\n /* Compute the sidebar's available height and if it should be locked */\n return combineLatest([main$, viewport$])\n .pipe(\n map(([{ offset, height }, { offset: { y } }]) => {\n height = height\n + Math.min(adjust, Math.max(0, y - offset))\n - adjust\n return {\n height,\n locked: y >= offset + adjust\n }\n }),\n distinctUntilChanged((a, b) => (\n a.height === b.height &&\n a.locked === b.locked\n ))\n )\n}\n\n/**\n * Mount sidebar\n *\n * This function doesn't set the height of the actual sidebar, but of its first\n * child \u2013 the `.md-sidebar__scrollwrap` element in order to mitigiate jittery\n * sidebars when the footer is scrolled into view. At some point we switched\n * from `absolute` / `fixed` positioning to `sticky` positioning, significantly\n * reducing jitter in some browsers (respectively Firefox and Safari) when\n * scrolling from the top. However, top-aligned sticky positioning means that\n * the sidebar snaps to the bottom when the end of the container is reached.\n * This is what leads to the mentioned jitter, as the sidebar's height may be\n * updated too slowly.\n *\n * This behaviour can be mitigiated by setting the height of the sidebar to `0`\n * while preserving the padding, and the height on its first element.\n *\n * @param el - Sidebar element\n * @param options - Options\n *\n * @returns Sidebar component observable\n */\nexport function mountSidebar(\n el: HTMLElement, { header$, ...options }: MountOptions\n): Observable> {\n const inner = getElement(\".md-sidebar__scrollwrap\", el)\n const { y } = getElementOffset(inner)\n return defer(() => {\n const push$ = new Subject()\n push$\n .pipe(\n auditTime(0, animationFrameScheduler),\n withLatestFrom(header$)\n )\n .subscribe({\n\n /* Handle emission */\n next([{ height }, { height: offset }]) {\n inner.style.height = `${height - 2 * y}px`\n el.style.top = `${offset}px`\n },\n\n /* Handle complete */\n complete() {\n inner.style.height = \"\"\n el.style.top = \"\"\n }\n })\n\n /* Bring active item into view on initial load */\n push$\n .pipe(\n observeOn(animationFrameScheduler),\n take(1)\n )\n .subscribe(() => {\n for (const item of getElements(\".md-nav__link--active[href]\", el)) {\n const container = getElementContainer(item)\n if (typeof container !== \"undefined\") {\n const offset = item.offsetTop - container.offsetTop\n const { height } = getElementSize(container)\n container.scrollTo({\n top: offset - height / 2\n })\n }\n }\n })\n\n /* Create and return component */\n return watchSidebar(el, options)\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state }))\n )\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Repo, User } from \"github-types\"\nimport {\n EMPTY,\n Observable,\n catchError,\n defaultIfEmpty,\n map,\n zip\n} from \"rxjs\"\n\nimport { requestJSON } from \"~/browser\"\n\nimport { SourceFacts } from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * GitHub release (partial)\n */\ninterface Release {\n tag_name: string /* Tag name */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Fetch GitHub repository facts\n *\n * @param user - GitHub user or organization\n * @param repo - GitHub repository\n *\n * @returns Repository facts observable\n */\nexport function fetchSourceFactsFromGitHub(\n user: string, repo?: string\n): Observable {\n if (typeof repo !== \"undefined\") {\n const url = `https://api.github.com/repos/${user}/${repo}`\n return zip(\n\n /* Fetch version */\n requestJSON(`${url}/releases/latest`)\n .pipe(\n catchError(() => EMPTY), // @todo refactor instant loading\n map(release => ({\n version: release.tag_name\n })),\n defaultIfEmpty({})\n ),\n\n /* Fetch stars and forks */\n requestJSON(url)\n .pipe(\n catchError(() => EMPTY), // @todo refactor instant loading\n map(info => ({\n stars: info.stargazers_count,\n forks: info.forks_count\n })),\n defaultIfEmpty({})\n )\n )\n .pipe(\n map(([release, info]) => ({ ...release, ...info }))\n )\n\n /* User or organization */\n } else {\n const url = `https://api.github.com/users/${user}`\n return requestJSON(url)\n .pipe(\n map(info => ({\n repositories: info.public_repos\n })),\n defaultIfEmpty({})\n )\n }\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { ProjectSchema } from \"gitlab\"\nimport {\n EMPTY,\n Observable,\n catchError,\n defaultIfEmpty,\n map\n} from \"rxjs\"\n\nimport { requestJSON } from \"~/browser\"\n\nimport { SourceFacts } from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Fetch GitLab repository facts\n *\n * @param base - GitLab base\n * @param project - GitLab project\n *\n * @returns Repository facts observable\n */\nexport function fetchSourceFactsFromGitLab(\n base: string, project: string\n): Observable {\n const url = `https://${base}/api/v4/projects/${encodeURIComponent(project)}`\n return requestJSON(url)\n .pipe(\n catchError(() => EMPTY), // @todo refactor instant loading\n map(({ star_count, forks_count }) => ({\n stars: star_count,\n forks: forks_count\n })),\n defaultIfEmpty({})\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { EMPTY, Observable } from \"rxjs\"\n\nimport { fetchSourceFactsFromGitHub } from \"../github\"\nimport { fetchSourceFactsFromGitLab } from \"../gitlab\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Repository facts for repositories\n */\nexport interface RepositoryFacts {\n stars?: number /* Number of stars */\n forks?: number /* Number of forks */\n version?: string /* Latest version */\n}\n\n/**\n * Repository facts for organizations\n */\nexport interface OrganizationFacts {\n repositories?: number /* Number of repositories */\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Repository facts\n */\nexport type SourceFacts =\n | RepositoryFacts\n | OrganizationFacts\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Fetch repository facts\n *\n * @param url - Repository URL\n *\n * @returns Repository facts observable\n */\nexport function fetchSourceFacts(\n url: string\n): Observable {\n\n /* Try to match GitHub repository */\n let match = url.match(/^.+github\\.com\\/([^/]+)\\/?([^/]+)?/i)\n if (match) {\n const [, user, repo] = match\n return fetchSourceFactsFromGitHub(user, repo)\n }\n\n /* Try to match GitLab repository */\n match = url.match(/^.+?([^/]*gitlab[^/]+)\\/(.+?)\\/?$/i)\n if (match) {\n const [, base, slug] = match\n return fetchSourceFactsFromGitLab(base, slug)\n }\n\n /* Fallback */\n return EMPTY\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n EMPTY,\n Observable,\n Subject,\n catchError,\n defer,\n filter,\n finalize,\n map,\n of,\n shareReplay,\n tap\n} from \"rxjs\"\n\nimport { getElement } from \"~/browser\"\nimport { ConsentDefaults } from \"~/components/consent\"\nimport { renderSourceFacts } from \"~/templates\"\n\nimport {\n Component,\n getComponentElements\n} from \"../../_\"\nimport {\n SourceFacts,\n fetchSourceFacts\n} from \"../facts\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Repository information\n */\nexport interface Source {\n facts: SourceFacts /* Repository facts */\n}\n\n/* ----------------------------------------------------------------------------\n * Data\n * ------------------------------------------------------------------------- */\n\n/**\n * Repository information observable\n */\nlet fetch$: Observable\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch repository information\n *\n * This function tries to read the repository facts from session storage, and\n * if unsuccessful, fetches them from the underlying provider.\n *\n * @param el - Repository information element\n *\n * @returns Repository information observable\n */\nexport function watchSource(\n el: HTMLAnchorElement\n): Observable {\n return fetch$ ||= defer(() => {\n const cached = __md_get(\"__source\", sessionStorage)\n if (cached) {\n return of(cached)\n } else {\n\n /* Check if consent is configured and was given */\n const els = getComponentElements(\"consent\")\n if (els.length) {\n const consent = __md_get(\"__consent\")\n if (!(consent && consent.github))\n return EMPTY\n }\n\n /* Fetch repository facts */\n return fetchSourceFacts(el.href)\n .pipe(\n tap(facts => __md_set(\"__source\", facts, sessionStorage))\n )\n }\n })\n .pipe(\n catchError(() => EMPTY),\n filter(facts => Object.keys(facts).length > 0),\n map(facts => ({ facts })),\n shareReplay(1)\n )\n}\n\n/**\n * Mount repository information\n *\n * @param el - Repository information element\n *\n * @returns Repository information component observable\n */\nexport function mountSource(\n el: HTMLAnchorElement\n): Observable> {\n const inner = getElement(\":scope > :last-child\", el)\n return defer(() => {\n const push$ = new Subject()\n push$.subscribe(({ facts }) => {\n inner.appendChild(renderSourceFacts(facts))\n inner.classList.add(\"md-source__repository--active\")\n })\n\n /* Create and return component */\n return watchSource(el)\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state }))\n )\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n Subject,\n defer,\n distinctUntilKeyChanged,\n finalize,\n map,\n of,\n switchMap,\n tap\n} from \"rxjs\"\n\nimport { feature } from \"~/_\"\nimport {\n Viewport,\n watchElementSize,\n watchViewportAt\n} from \"~/browser\"\n\nimport { Component } from \"../_\"\nimport { Header } from \"../header\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Navigation tabs\n */\nexport interface Tabs {\n hidden: boolean /* Navigation tabs are hidden */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n viewport$: Observable /* Viewport observable */\n header$: Observable
    /* Header observable */\n}\n\n/**\n * Mount options\n */\ninterface MountOptions {\n viewport$: Observable /* Viewport observable */\n header$: Observable
    /* Header observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch navigation tabs\n *\n * @param el - Navigation tabs element\n * @param options - Options\n *\n * @returns Navigation tabs observable\n */\nexport function watchTabs(\n el: HTMLElement, { viewport$, header$ }: WatchOptions\n): Observable {\n return watchElementSize(document.body)\n .pipe(\n switchMap(() => watchViewportAt(el, { header$, viewport$ })),\n map(({ offset: { y } }) => {\n return {\n hidden: y >= 10\n }\n }),\n distinctUntilKeyChanged(\"hidden\")\n )\n}\n\n/**\n * Mount navigation tabs\n *\n * This function hides the navigation tabs when scrolling past the threshold\n * and makes them reappear in a nice CSS animation when scrolling back up.\n *\n * @param el - Navigation tabs element\n * @param options - Options\n *\n * @returns Navigation tabs component observable\n */\nexport function mountTabs(\n el: HTMLElement, options: MountOptions\n): Observable> {\n return defer(() => {\n const push$ = new Subject()\n push$.subscribe({\n\n /* Handle emission */\n next({ hidden }) {\n el.hidden = hidden\n },\n\n /* Handle complete */\n complete() {\n el.hidden = false\n }\n })\n\n /* Create and return component */\n return (\n feature(\"navigation.tabs.sticky\")\n ? of({ hidden: false })\n : watchTabs(el, options)\n )\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state }))\n )\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n Subject,\n bufferCount,\n combineLatestWith,\n debounceTime,\n defer,\n distinctUntilChanged,\n distinctUntilKeyChanged,\n filter,\n finalize,\n map,\n merge,\n of,\n repeat,\n scan,\n share,\n skip,\n startWith,\n switchMap,\n takeLast,\n takeUntil,\n tap,\n withLatestFrom\n} from \"rxjs\"\n\nimport { feature } from \"~/_\"\nimport {\n Viewport,\n getElement,\n getElementContainer,\n getElementSize,\n getElements,\n getLocation,\n getOptionalElement,\n watchElementSize\n} from \"~/browser\"\n\nimport {\n Component,\n getComponentElement\n} from \"../_\"\nimport { Header } from \"../header\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Table of contents\n */\nexport interface TableOfContents {\n prev: HTMLAnchorElement[][] /* Anchors (previous) */\n next: HTMLAnchorElement[][] /* Anchors (next) */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n viewport$: Observable /* Viewport observable */\n header$: Observable
    /* Header observable */\n}\n\n/**\n * Mount options\n */\ninterface MountOptions {\n viewport$: Observable /* Viewport observable */\n header$: Observable
    /* Header observable */\n target$: Observable /* Location target observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch table of contents\n *\n * This is effectively a scroll spy implementation which will account for the\n * fixed header and automatically re-calculate anchor offsets when the viewport\n * is resized. The returned observable will only emit if the table of contents\n * needs to be repainted.\n *\n * This implementation tracks an anchor element's entire path starting from its\n * level up to the top-most anchor element, e.g. `[h3, h2, h1]`. Although the\n * Material theme currently doesn't make use of this information, it enables\n * the styling of the entire hierarchy through customization.\n *\n * Note that the current anchor is the last item of the `prev` anchor list.\n *\n * @param el - Table of contents element\n * @param options - Options\n *\n * @returns Table of contents observable\n */\nexport function watchTableOfContents(\n el: HTMLElement, { viewport$, header$ }: WatchOptions\n): Observable {\n const table = new Map()\n\n /* Compute anchor-to-target mapping */\n const anchors = getElements(\"[href^=\\\\#]\", el)\n for (const anchor of anchors) {\n const id = decodeURIComponent(anchor.hash.substring(1))\n const target = getOptionalElement(`[id=\"${id}\"]`)\n if (typeof target !== \"undefined\")\n table.set(anchor, target)\n }\n\n /* Compute necessary adjustment for header */\n const adjust$ = header$\n .pipe(\n distinctUntilKeyChanged(\"height\"),\n map(({ height }) => {\n const main = getComponentElement(\"main\")\n const grid = getElement(\":scope > :first-child\", main)\n return height + 0.8 * (\n grid.offsetTop -\n main.offsetTop\n )\n }),\n share()\n )\n\n /* Compute partition of previous and next anchors */\n const partition$ = watchElementSize(document.body)\n .pipe(\n distinctUntilKeyChanged(\"height\"),\n\n /* Build index to map anchor paths to vertical offsets */\n switchMap(body => defer(() => {\n let path: HTMLAnchorElement[] = []\n return of([...table].reduce((index, [anchor, target]) => {\n while (path.length) {\n const last = table.get(path[path.length - 1])!\n if (last.tagName >= target.tagName) {\n path.pop()\n } else {\n break\n }\n }\n\n /* If the current anchor is hidden, continue with its parent */\n let offset = target.offsetTop\n while (!offset && target.parentElement) {\n target = target.parentElement\n offset = target.offsetTop\n }\n\n /* Map reversed anchor path to vertical offset */\n return index.set(\n [...path = [...path, anchor]].reverse(),\n offset\n )\n }, new Map()))\n })\n .pipe(\n\n /* Sort index by vertical offset (see https://bit.ly/30z6QSO) */\n map(index => new Map([...index].sort(([, a], [, b]) => a - b))),\n combineLatestWith(adjust$),\n\n /* Re-compute partition when viewport offset changes */\n switchMap(([index, adjust]) => viewport$\n .pipe(\n scan(([prev, next], { offset: { y }, size }) => {\n const last = y + size.height >= Math.floor(body.height)\n\n /* Look forward */\n while (next.length) {\n const [, offset] = next[0]\n if (offset - adjust < y || last) {\n prev = [...prev, next.shift()!]\n } else {\n break\n }\n }\n\n /* Look backward */\n while (prev.length) {\n const [, offset] = prev[prev.length - 1]\n if (offset - adjust >= y && !last) {\n next = [prev.pop()!, ...next]\n } else {\n break\n }\n }\n\n /* Return partition */\n return [prev, next]\n }, [[], [...index]]),\n distinctUntilChanged((a, b) => (\n a[0] === b[0] &&\n a[1] === b[1]\n ))\n )\n )\n )\n )\n )\n\n /* Compute and return anchor list migrations */\n return partition$\n .pipe(\n map(([prev, next]) => ({\n prev: prev.map(([path]) => path),\n next: next.map(([path]) => path)\n })),\n\n /* Extract anchor list migrations */\n startWith({ prev: [], next: [] }),\n bufferCount(2, 1),\n map(([a, b]) => {\n\n /* Moving down */\n if (a.prev.length < b.prev.length) {\n return {\n prev: b.prev.slice(Math.max(0, a.prev.length - 1), b.prev.length),\n next: []\n }\n\n /* Moving up */\n } else {\n return {\n prev: b.prev.slice(-1),\n next: b.next.slice(0, b.next.length - a.next.length)\n }\n }\n })\n )\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Mount table of contents\n *\n * @param el - Table of contents element\n * @param options - Options\n *\n * @returns Table of contents component observable\n */\nexport function mountTableOfContents(\n el: HTMLElement, { viewport$, header$, target$ }: MountOptions\n): Observable> {\n return defer(() => {\n const push$ = new Subject()\n const done$ = push$.pipe(takeLast(1))\n push$.subscribe(({ prev, next }) => {\n\n /* Look forward */\n for (const [anchor] of next) {\n anchor.classList.remove(\"md-nav__link--passed\")\n anchor.classList.remove(\"md-nav__link--active\")\n }\n\n /* Look backward */\n for (const [index, [anchor]] of prev.entries()) {\n anchor.classList.add(\"md-nav__link--passed\")\n anchor.classList.toggle(\n \"md-nav__link--active\",\n index === prev.length - 1\n )\n }\n })\n\n /* Set up following, if enabled */\n if (feature(\"toc.follow\")) {\n\n /* Toggle smooth scrolling only for anchor clicks */\n const smooth$ = merge(\n viewport$.pipe(debounceTime(1), map(() => undefined)),\n viewport$.pipe(debounceTime(250), map(() => \"smooth\" as const))\n )\n\n /* Bring active anchor into view */\n push$\n .pipe(\n filter(({ prev }) => prev.length > 0),\n withLatestFrom(smooth$)\n )\n .subscribe(([{ prev }, behavior]) => {\n const [anchor] = prev[prev.length - 1]\n if (anchor.offsetHeight) {\n\n /* Retrieve overflowing container and scroll */\n const container = getElementContainer(anchor)\n if (typeof container !== \"undefined\") {\n const offset = anchor.offsetTop - container.offsetTop\n const { height } = getElementSize(container)\n container.scrollTo({\n top: offset - height / 2,\n behavior\n })\n }\n }\n })\n }\n\n /* Set up anchor tracking, if enabled */\n if (feature(\"navigation.tracking\"))\n viewport$\n .pipe(\n takeUntil(done$),\n distinctUntilKeyChanged(\"offset\"),\n debounceTime(250),\n skip(1),\n takeUntil(target$.pipe(skip(1))),\n repeat({ delay: 250 }),\n withLatestFrom(push$)\n )\n .subscribe(([, { prev }]) => {\n const url = getLocation()\n\n /* Set hash fragment to active anchor */\n const anchor = prev[prev.length - 1]\n if (anchor && anchor.length) {\n const [active] = anchor\n const { hash } = new URL(active.href)\n if (url.hash !== hash) {\n url.hash = hash\n history.replaceState({}, \"\", `${url}`)\n }\n\n /* Reset anchor when at the top */\n } else {\n url.hash = \"\"\n history.replaceState({}, \"\", `${url}`)\n }\n })\n\n /* Create and return component */\n return watchTableOfContents(el, { viewport$, header$ })\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state }))\n )\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n Subject,\n bufferCount,\n combineLatest,\n distinctUntilChanged,\n distinctUntilKeyChanged,\n endWith,\n finalize,\n map,\n repeat,\n skip,\n takeLast,\n takeUntil,\n tap\n} from \"rxjs\"\n\nimport { Viewport } from \"~/browser\"\n\nimport { Component } from \"../_\"\nimport { Header } from \"../header\"\nimport { Main } from \"../main\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Back-to-top button\n */\nexport interface BackToTop {\n hidden: boolean /* Back-to-top button is hidden */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n viewport$: Observable /* Viewport observable */\n main$: Observable
    /* Main area observable */\n target$: Observable /* Location target observable */\n}\n\n/**\n * Mount options\n */\ninterface MountOptions {\n viewport$: Observable /* Viewport observable */\n header$: Observable
    /* Header observable */\n main$: Observable
    /* Main area observable */\n target$: Observable /* Location target observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch back-to-top\n *\n * @param _el - Back-to-top element\n * @param options - Options\n *\n * @returns Back-to-top observable\n */\nexport function watchBackToTop(\n _el: HTMLElement, { viewport$, main$, target$ }: WatchOptions\n): Observable {\n\n /* Compute direction */\n const direction$ = viewport$\n .pipe(\n map(({ offset: { y } }) => y),\n bufferCount(2, 1),\n map(([a, b]) => a > b && b > 0),\n distinctUntilChanged()\n )\n\n /* Compute whether main area is active */\n const active$ = main$\n .pipe(\n map(({ active }) => active)\n )\n\n /* Compute threshold for hiding */\n return combineLatest([active$, direction$])\n .pipe(\n map(([active, direction]) => !(active && direction)),\n distinctUntilChanged(),\n takeUntil(target$.pipe(skip(1))),\n endWith(true),\n repeat({ delay: 250 }),\n map(hidden => ({ hidden }))\n )\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Mount back-to-top\n *\n * @param el - Back-to-top element\n * @param options - Options\n *\n * @returns Back-to-top component observable\n */\nexport function mountBackToTop(\n el: HTMLElement, { viewport$, header$, main$, target$ }: MountOptions\n): Observable> {\n const push$ = new Subject()\n const done$ = push$.pipe(takeLast(1))\n push$.subscribe({\n\n /* Handle emission */\n next({ hidden }) {\n el.hidden = hidden\n if (hidden) {\n el.setAttribute(\"tabindex\", \"-1\")\n el.blur()\n } else {\n el.removeAttribute(\"tabindex\")\n }\n },\n\n /* Handle complete */\n complete() {\n el.style.top = \"\"\n el.hidden = true\n el.removeAttribute(\"tabindex\")\n }\n })\n\n /* Watch header height */\n header$\n .pipe(\n takeUntil(done$),\n distinctUntilKeyChanged(\"height\")\n )\n .subscribe(({ height }) => {\n el.style.top = `${height + 16}px`\n })\n\n /* Create and return component */\n return watchBackToTop(el, { viewport$, main$, target$ })\n .pipe(\n tap(state => push$.next(state)),\n finalize(() => push$.complete()),\n map(state => ({ ref: el, ...state }))\n )\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n fromEvent,\n map,\n mergeMap,\n switchMap,\n takeWhile,\n tap,\n withLatestFrom\n} from \"rxjs\"\n\nimport { getElements } from \"~/browser\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Patch options\n */\ninterface PatchOptions {\n document$: Observable /* Document observable */\n tablet$: Observable /* Media tablet observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Patch indeterminate checkboxes\n *\n * This function replaces the indeterminate \"pseudo state\" with the actual\n * indeterminate state, which is used to keep navigation always expanded.\n *\n * @param options - Options\n */\nexport function patchIndeterminate(\n { document$, tablet$ }: PatchOptions\n): void {\n document$\n .pipe(\n switchMap(() => getElements(\n // @todo `data-md-state` is deprecated and removed in v9\n \".md-toggle--indeterminate, [data-md-state=indeterminate]\"\n )),\n tap(el => {\n el.indeterminate = true\n el.checked = false\n }),\n mergeMap(el => fromEvent(el, \"change\")\n .pipe(\n takeWhile(() => el.classList.contains(\"md-toggle--indeterminate\")),\n map(() => el)\n )\n ),\n withLatestFrom(tablet$)\n )\n .subscribe(([el, tablet]) => {\n el.classList.remove(\"md-toggle--indeterminate\")\n if (tablet)\n el.checked = false\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n filter,\n fromEvent,\n map,\n mergeMap,\n switchMap,\n tap\n} from \"rxjs\"\n\nimport { getElements } from \"~/browser\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Patch options\n */\ninterface PatchOptions {\n document$: Observable /* Document observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Check whether the given device is an Apple device\n *\n * @returns Test result\n */\nfunction isAppleDevice(): boolean {\n return /(iPad|iPhone|iPod)/.test(navigator.userAgent)\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Patch all elements with `data-md-scrollfix` attributes\n *\n * This is a year-old patch which ensures that overflow scrolling works at the\n * top and bottom of containers on iOS by ensuring a `1px` scroll offset upon\n * the start of a touch event.\n *\n * @see https://bit.ly/2SCtAOO - Original source\n *\n * @param options - Options\n */\nexport function patchScrollfix(\n { document$ }: PatchOptions\n): void {\n document$\n .pipe(\n switchMap(() => getElements(\"[data-md-scrollfix]\")),\n tap(el => el.removeAttribute(\"data-md-scrollfix\")),\n filter(isAppleDevice),\n mergeMap(el => fromEvent(el, \"touchstart\")\n .pipe(\n map(() => el)\n )\n )\n )\n .subscribe(el => {\n const top = el.scrollTop\n\n /* We're at the top of the container */\n if (top === 0) {\n el.scrollTop = 1\n\n /* We're at the bottom of the container */\n } else if (top + el.offsetHeight === el.scrollHeight) {\n el.scrollTop = top - 1\n }\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n combineLatest,\n delay,\n map,\n of,\n switchMap,\n withLatestFrom\n} from \"rxjs\"\n\nimport {\n Viewport,\n watchToggle\n} from \"~/browser\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Patch options\n */\ninterface PatchOptions {\n viewport$: Observable /* Viewport observable */\n tablet$: Observable /* Media tablet observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Patch the document body to lock when search is open\n *\n * For mobile and tablet viewports, the search is rendered full screen, which\n * leads to scroll leaking when at the top or bottom of the search result. This\n * function locks the body when the search is in full screen mode, and restores\n * the scroll position when leaving.\n *\n * @param options - Options\n */\nexport function patchScrolllock(\n { viewport$, tablet$ }: PatchOptions\n): void {\n combineLatest([watchToggle(\"search\"), tablet$])\n .pipe(\n map(([active, tablet]) => active && !tablet),\n switchMap(active => of(active)\n .pipe(\n delay(active ? 400 : 100)\n )\n ),\n withLatestFrom(viewport$)\n )\n .subscribe(([active, { offset: { y }}]) => {\n if (active) {\n document.body.setAttribute(\"data-md-scrolllock\", \"\")\n document.body.style.top = `-${y}px`\n } else {\n const value = -1 * parseInt(document.body.style.top, 10)\n document.body.removeAttribute(\"data-md-scrolllock\")\n document.body.style.top = \"\"\n if (value)\n window.scrollTo(0, value)\n }\n })\n}\n", "/*\n * Copyright (c) 2016-2022 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/* ----------------------------------------------------------------------------\n * Polyfills\n * ------------------------------------------------------------------------- */\n\n/* Polyfill `Object.entries` */\nif (!Object.entries)\n Object.entries = function (obj: object) {\n const data: [string, string][] = []\n for (const key of Object.keys(obj))\n // @ts-expect-error - ignore property access warning\n data.push([key, obj[key]])\n\n /* Return entries */\n return data\n }\n\n/* Polyfill `Object.values` */\nif (!Object.values)\n Object.values = function (obj: object) {\n const data: string[] = []\n for (const key of Object.keys(obj))\n // @ts-expect-error - ignore property access warning\n data.push(obj[key])\n\n /* Return values */\n return data\n }\n\n/* ------------------------------------------------------------------------- */\n\n/* Polyfills for `Element` */\nif (typeof Element !== \"undefined\") {\n\n /* Polyfill `Element.scrollTo` */\n if (!Element.prototype.scrollTo)\n Element.prototype.scrollTo = function (\n x?: ScrollToOptions | number, y?: number\n ): void {\n if (typeof x === \"object\") {\n this.scrollLeft = x.left!\n this.scrollTop = x.top!\n } else {\n this.scrollLeft = x!\n this.scrollTop = y!\n }\n }\n\n /* Polyfill `Element.replaceWith` */\n if (!Element.prototype.replaceWith)\n Element.prototype.replaceWith = function (\n ...nodes: Array\n ): void {\n const parent = this.parentNode\n if (parent) {\n if (nodes.length === 0)\n parent.removeChild(this)\n\n /* Replace children and create text nodes */\n for (let i = nodes.length - 1; i >= 0; i--) {\n let node = nodes[i]\n if (typeof node === \"string\")\n node = document.createTextNode(node)\n else if (node.parentNode)\n node.parentNode.removeChild(node)\n\n /* Replace child or insert before previous sibling */\n if (!i)\n parent.replaceChild(node, this)\n else\n parent.insertBefore(this.previousSibling!, node)\n }\n }\n }\n}\n"], - "mappings": "6+BAAA,IAAAA,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IAAMsD,GAAanB,EAAI,CAAE,UAAArC,GAAW,QAAA+B,GAAS,MAAAG,EAAM,CAAC,CAAC,CACrE,EAGF,GAAGO,GAAqB,MAAM,EAC3B,IAAIJ,GAAMoB,GAAUpB,EAAI,CAAE,UAAArC,GAAW,QAAA+B,EAAQ,CAAC,CAAC,EAGlD,GAAGU,GAAqB,KAAK,EAC1B,IAAIJ,GAAMqB,GAAqBrB,EAAI,CAAE,UAAArC,GAAW,QAAA+B,GAAS,QAAAnC,EAAQ,CAAC,CAAC,EAGtE,GAAG6C,GAAqB,KAAK,EAC1B,IAAIJ,GAAMsB,GAAetB,EAAI,CAAE,UAAArC,GAAW,QAAA+B,GAAS,MAAAG,GAAO,QAAAtC,EAAQ,CAAC,CAAC,CACzE,CAAC,EAGKgE,GAAapE,GAChB,KACC4C,EAAU,IAAMY,EAAQ,EACxBa,GAAUrB,EAAQ,EAClBD,EAAY,CAAC,CACf,EAGFqB,GAAW,UAAU,EAMrB,OAAO,UAAapE,GACpB,OAAO,UAAaE,GACpB,OAAO,QAAaE,GACpB,OAAO,UAAaE,GACpB,OAAO,UAAaE,GACpB,OAAO,QAAaE,GACpB,OAAO,QAAaE,GACpB,OAAO,OAAaC,GACpB,OAAO,OAAaO,GACpB,OAAO,WAAagD", - "names": ["require_focus_visible", "__commonJSMin", "exports", "module", "global", "factory", "applyFocusVisiblePolyfill", "scope", "hadKeyboardEvent", "hadFocusVisibleRecently", "hadFocusVisibleRecentlyTimeout", "inputTypesAllowlist", "isValidFocusTarget", "el", "focusTriggersKeyboardModality", "type", "tagName", "addFocusVisibleClass", "removeFocusVisibleClass", "onKeyDown", "e", "onPointerDown", "onFocus", "onBlur", "onVisibilityChange", "addInitialPointerMoveListeners", "onInitialPointerMove", "removeInitialPointerMoveListeners", "event", "error", "require_url_polyfill", "__commonJSMin", "exports", "global", "checkIfIteratorIsSupported", "error", "iteratorSupported", "createIterator", "items", "iterator", "value", "serializeParam", "deserializeParam", "polyfillURLSearchParams", "URLSearchParams", "searchString", "typeofSearchString", "_this", "name", "i", "entry", "key", "proto", "callback", "thisArg", "entries", "searchArray", "checkIfURLSearchParamsSupported", "e", "a", "b", "keys", "attributes", "attribute", "checkIfURLIsSupported", "u", "polyfillURL", "_URL", "URL", "url", "base", "doc", "baseElement", "err", "anchorElement", "inputElement", "searchParams", "enableSearchUpdate", "enableSearchParamsUpdate", "methodName", "method", "search", "linkURLWithAnchorAttribute", "attributeName", "expectedPort", "addPortToOrigin", "blob", "getOrigin", "require_tslib", "__commonJSMin", "exports", "module", "__extends", "__assign", "__rest", "__decorate", "__param", "__metadata", "__awaiter", "__generator", "__exportStar", "__values", "__read", "__spread", "__spreadArrays", "__spreadArray", "__await", "__asyncGenerator", "__asyncDelegator", "__asyncValues", "__makeTemplateObject", "__importStar", "__importDefault", "__classPrivateFieldGet", "__classPrivateFieldSet", "__createBinding", "factory", "root", "createExporter", "previous", "id", "v", "exporter", "extendStatics", "d", "b", "p", "__", "t", "s", "n", "e", "i", "decorators", "target", "key", "desc", "c", "r", "paramIndex", "decorator", "metadataKey", "metadataValue", "thisArg", "_arguments", "P", "generator", "adopt", "value", "resolve", "reject", "fulfilled", "step", "rejected", "result", "body", "_", "f", "y", "g", "verb", "op", "m", "o", "k", "k2", "ar", "error", "il", "a", "j", "jl", "to", "from", "pack", "l", "q", "resume", "settle", "fulfill", "cooked", "raw", "__setModuleDefault", "mod", "receiver", "state", "kind", "require_clipboard", "__commonJSMin", "exports", "module", "root", "factory", "__webpack_modules__", "__unused_webpack_module", "__webpack_exports__", "__webpack_require__", "clipboard", "tiny_emitter", "tiny_emitter_default", "listen", "listen_default", "src_select", "select_default", "command", "type", "err", "ClipboardActionCut", "target", "selectedText", "actions_cut", "createFakeElement", "value", "isRTL", "fakeElement", "yPosition", "fakeCopyAction", "options", "ClipboardActionCopy", "actions_copy", "_typeof", "obj", "ClipboardActionDefault", "_options$action", "action", "container", "text", "actions_default", "clipboard_typeof", "_classCallCheck", "instance", "Constructor", "_defineProperties", "props", "i", "descriptor", "_createClass", "protoProps", "staticProps", "_inherits", "subClass", "superClass", "_setPrototypeOf", "o", "p", "_createSuper", "Derived", "hasNativeReflectConstruct", "_isNativeReflectConstruct", "Super", "_getPrototypeOf", "result", "NewTarget", "_possibleConstructorReturn", "self", "call", "_assertThisInitialized", "e", "getAttributeValue", "suffix", "element", "attribute", "Clipboard", "_Emitter", "_super", "trigger", "_this", "_this2", "selector", "actions", "support", "DOCUMENT_NODE_TYPE", "proto", "closest", "__unused_webpack_exports", "_delegate", "callback", "useCapture", "listenerFn", "listener", "delegate", "elements", "is", "listenNode", "listenNodeList", "listenSelector", "node", "nodeList", "select", "isReadOnly", "selection", "range", "E", "name", "ctx", "data", "evtArr", "len", "evts", "liveEvents", "__webpack_module_cache__", "moduleId", "getter", "definition", "key", "prop", "require_escape_html", "__commonJSMin", "exports", "module", "matchHtmlRegExp", "escapeHtml", "string", "str", "match", "escape", "html", "index", "lastIndex", "r", "a", "e", "import_focus_visible", "n", "t", "s", "r", "o", "u", "i", "a", "e", "c", "import_url_polyfill", "import_tslib", "__extends", "__assign", "__rest", "__decorate", "__param", "__metadata", "__awaiter", "__generator", "__exportStar", "__createBinding", "__values", "__read", "__spread", "__spreadArrays", "__spreadArray", "__await", "__asyncGenerator", "__asyncDelegator", "__asyncValues", "__makeTemplateObject", "__importStar", "__importDefault", "__classPrivateFieldGet", "__classPrivateFieldSet", "tslib", "isFunction", "value", "createErrorClass", "createImpl", "_super", "instance", "ctorFunc", "UnsubscriptionError", "createErrorClass", "_super", "errors", "err", "i", "arrRemove", "arr", "item", "index", "Subscription", "initialTeardown", "errors", "_parentage", "_parentage_1", "__values", "_parentage_1_1", "parent_1", "initialFinalizer", "isFunction", "e", "UnsubscriptionError", "_finalizers", "_finalizers_1", "_finalizers_1_1", "finalizer", "execFinalizer", "err", "__spreadArray", "__read", "teardown", "_a", "parent", "arrRemove", "empty", "EMPTY_SUBSCRIPTION", "Subscription", "isSubscription", "value", "isFunction", "execFinalizer", "finalizer", "config", "timeoutProvider", "handler", "timeout", "args", "_i", "delegate", "__spreadArray", "__read", "handle", "reportUnhandledError", "err", "timeoutProvider", "onUnhandledError", "config", "noop", "COMPLETE_NOTIFICATION", "createNotification", "errorNotification", "error", "nextNotification", "value", "kind", "context", "errorContext", "cb", "config", "isRoot", "_a", "errorThrown", "error", "captureError", "err", "Subscriber", "_super", "__extends", "destination", "_this", "isSubscription", "EMPTY_OBSERVER", "next", "error", "complete", "SafeSubscriber", "value", "handleStoppedNotification", "nextNotification", "err", "errorNotification", "COMPLETE_NOTIFICATION", "Subscription", "_bind", "bind", "fn", "thisArg", "ConsumerObserver", "partialObserver", "value", "error", "handleUnhandledError", "err", "SafeSubscriber", "_super", "__extends", "observerOrNext", "complete", "_this", "isFunction", "context_1", "config", "Subscriber", "handleUnhandledError", "error", "config", "captureError", "reportUnhandledError", "defaultErrorHandler", "err", "handleStoppedNotification", "notification", "subscriber", "onStoppedNotification", "timeoutProvider", "EMPTY_OBSERVER", "noop", "observable", "identity", "x", "pipe", "fns", "_i", "pipeFromArray", "identity", "input", "prev", "fn", "Observable", "subscribe", "operator", "observable", "observerOrNext", "error", "complete", "_this", "subscriber", "isSubscriber", "SafeSubscriber", "errorContext", "_a", "source", "sink", "err", "next", "promiseCtor", "getPromiseCtor", "resolve", "reject", "value", "operations", "_i", "pipeFromArray", "x", "getPromiseCtor", "promiseCtor", "_a", "config", "isObserver", "value", "isFunction", "isSubscriber", "Subscriber", "isSubscription", "hasLift", "source", "isFunction", "operate", "init", "liftedSource", "err", "createOperatorSubscriber", "destination", "onNext", "onComplete", "onError", "onFinalize", "OperatorSubscriber", "_super", "__extends", "shouldUnsubscribe", "_this", "value", "err", "closed_1", "_a", "Subscriber", "animationFrameProvider", "callback", "request", "cancel", "delegate", "handle", "timestamp", "Subscription", "args", "_i", "__spreadArray", "__read", "ObjectUnsubscribedError", "createErrorClass", "_super", "Subject", "_super", "__extends", "_this", "operator", "subject", "AnonymousSubject", "ObjectUnsubscribedError", "value", "errorContext", "_b", "__values", "_c", "observer", "err", "observers", "_a", "subscriber", "hasError", "isStopped", "EMPTY_SUBSCRIPTION", "Subscription", "arrRemove", "thrownError", "observable", "Observable", "destination", "source", "AnonymousSubject", "_super", "__extends", "destination", "source", "_this", "value", "_b", "_a", "err", "subscriber", "EMPTY_SUBSCRIPTION", "Subject", "dateTimestampProvider", "ReplaySubject", "_super", "__extends", "_bufferSize", "_windowTime", "_timestampProvider", "dateTimestampProvider", "_this", "value", "_a", "isStopped", "_buffer", "_infiniteTimeWindow", "subscriber", "subscription", "copy", "i", "adjustedBufferSize", "now", "last", "Subject", "Action", "_super", "__extends", "scheduler", "work", "state", "delay", "Subscription", "intervalProvider", "handler", "timeout", "args", "_i", "delegate", "__spreadArray", "__read", "handle", "AsyncAction", "_super", "__extends", "scheduler", "work", "_this", "state", "delay", "id", "_a", "_id", "intervalProvider", "_scheduler", "error", "_delay", "errored", "errorValue", "e", "actions", "arrRemove", "Action", "Scheduler", "schedulerActionCtor", "now", "work", "delay", "state", "dateTimestampProvider", "AsyncScheduler", "_super", "__extends", "SchedulerAction", "now", "Scheduler", "_this", "action", "actions", "error", "asyncScheduler", "AsyncScheduler", "AsyncAction", "async", "AnimationFrameAction", "_super", "__extends", "scheduler", "work", "_this", "id", "delay", "animationFrameProvider", "actions", "_a", "AsyncAction", "AnimationFrameScheduler", "_super", "__extends", "action", "flushId", "actions", "error", "AsyncScheduler", "animationFrameScheduler", "AnimationFrameScheduler", "AnimationFrameAction", "EMPTY", "Observable", "subscriber", "isScheduler", "value", "isFunction", "last", "arr", "popResultSelector", "args", "isFunction", "popScheduler", "isScheduler", "popNumber", "defaultValue", "isArrayLike", "x", "isPromise", "value", "isFunction", "isInteropObservable", "input", "isFunction", "observable", "isAsyncIterable", "obj", "isFunction", "createInvalidObservableTypeError", "input", "getSymbolIterator", "iterator", "isIterable", "input", "isFunction", "iterator", "readableStreamLikeToAsyncGenerator", "readableStream", "reader", "__await", "_a", "_b", "value", "done", "isReadableStreamLike", "obj", "isFunction", "innerFrom", "input", "Observable", "isInteropObservable", "fromInteropObservable", "isArrayLike", "fromArrayLike", "isPromise", "fromPromise", "isAsyncIterable", "fromAsyncIterable", "isIterable", "fromIterable", "isReadableStreamLike", "fromReadableStreamLike", "createInvalidObservableTypeError", "obj", "subscriber", "obs", "observable", "isFunction", "array", "i", "promise", "value", "err", "reportUnhandledError", "iterable", "iterable_1", "__values", "iterable_1_1", "asyncIterable", "process", "readableStream", "readableStreamLikeToAsyncGenerator", "asyncIterable_1", "__asyncValues", "asyncIterable_1_1", "executeSchedule", "parentSubscription", "scheduler", "work", "delay", "repeat", "scheduleSubscription", "observeOn", "scheduler", "delay", "operate", "source", "subscriber", "createOperatorSubscriber", "value", "executeSchedule", "err", "subscribeOn", "scheduler", "delay", "operate", "source", "subscriber", "scheduleObservable", "input", "scheduler", "innerFrom", "subscribeOn", "observeOn", "schedulePromise", "input", "scheduler", "innerFrom", "subscribeOn", "observeOn", "scheduleArray", "input", "scheduler", "Observable", "subscriber", "i", "scheduleIterable", "input", "scheduler", "Observable", "subscriber", "iterator", "executeSchedule", "value", "done", "_a", "err", "isFunction", "scheduleAsyncIterable", "input", "scheduler", "Observable", "subscriber", "executeSchedule", "iterator", "result", "scheduleReadableStreamLike", "input", "scheduler", "scheduleAsyncIterable", "readableStreamLikeToAsyncGenerator", "scheduled", "input", "scheduler", "isInteropObservable", "scheduleObservable", "isArrayLike", "scheduleArray", "isPromise", "schedulePromise", "isAsyncIterable", "scheduleAsyncIterable", "isIterable", "scheduleIterable", "isReadableStreamLike", "scheduleReadableStreamLike", "createInvalidObservableTypeError", "from", "input", "scheduler", "scheduled", "innerFrom", "of", "args", "_i", "scheduler", "popScheduler", "from", "throwError", "errorOrErrorFactory", "scheduler", "errorFactory", "isFunction", "init", "subscriber", "Observable", "isValidDate", "value", "map", "project", "thisArg", "operate", "source", "subscriber", "index", "createOperatorSubscriber", "value", "isArray", "callOrApply", "fn", "args", "__spreadArray", "__read", "mapOneOrManyArgs", "map", "isArray", "getPrototypeOf", "objectProto", "getKeys", "argsArgArrayOrObject", "args", "first_1", "isPOJO", "keys", "key", "obj", "createObject", "keys", "values", "result", "key", "i", "combineLatest", "args", "_i", "scheduler", "popScheduler", "resultSelector", "popResultSelector", "_a", "argsArgArrayOrObject", "observables", "keys", "from", "result", "Observable", "combineLatestInit", "values", "createObject", "identity", "mapOneOrManyArgs", "valueTransform", "subscriber", "maybeSchedule", "length", "active", "remainingFirstValues", "i", "source", "hasFirstValue", "createOperatorSubscriber", "value", "execute", "subscription", "executeSchedule", "mergeInternals", "source", "subscriber", "project", "concurrent", "onBeforeNext", "expand", "innerSubScheduler", "additionalFinalizer", "buffer", "active", "index", "isComplete", "checkComplete", "outerNext", "value", "doInnerSub", "innerComplete", "innerFrom", "createOperatorSubscriber", "innerValue", "bufferedValue", "executeSchedule", "err", "mergeMap", "project", "resultSelector", "concurrent", "isFunction", "a", "i", "map", "b", "ii", "innerFrom", "operate", "source", "subscriber", "mergeInternals", "mergeAll", "concurrent", "mergeMap", "identity", "concatAll", "mergeAll", "concat", "args", "_i", "concatAll", "from", "popScheduler", "defer", "observableFactory", "Observable", "subscriber", "innerFrom", "nodeEventEmitterMethods", "eventTargetMethods", "jqueryMethods", "fromEvent", "target", "eventName", "options", "resultSelector", "isFunction", "mapOneOrManyArgs", "_a", "__read", "isEventTarget", "methodName", "handler", "isNodeStyleEventEmitter", "toCommonHandlerRegistry", "isJQueryStyleEventEmitter", "add", "remove", "isArrayLike", "mergeMap", "subTarget", "innerFrom", "Observable", "subscriber", "args", "_i", "fromEventPattern", "addHandler", "removeHandler", "resultSelector", "mapOneOrManyArgs", "Observable", "subscriber", "handler", "e", "_i", "retValue", "isFunction", "timer", "dueTime", "intervalOrScheduler", "scheduler", "async", "intervalDuration", "isScheduler", "Observable", "subscriber", "due", "isValidDate", "n", "merge", "args", "_i", "scheduler", "popScheduler", "concurrent", "popNumber", "sources", "innerFrom", "mergeAll", "from", "EMPTY", "NEVER", "Observable", "noop", "isArray", "argsOrArgArray", "args", "filter", "predicate", "thisArg", "operate", "source", "subscriber", "index", "createOperatorSubscriber", "value", "zip", "args", "_i", "resultSelector", "popResultSelector", "sources", "argsOrArgArray", "Observable", "subscriber", "buffers", "completed", "sourceIndex", "innerFrom", "createOperatorSubscriber", "value", "buffer", "result", "__spreadArray", "__read", "i", "EMPTY", "audit", "durationSelector", "operate", "source", "subscriber", "hasValue", "lastValue", "durationSubscriber", "isComplete", "endDuration", "value", "cleanupDuration", "createOperatorSubscriber", "innerFrom", "auditTime", "duration", "scheduler", "asyncScheduler", "audit", "timer", "bufferCount", "bufferSize", "startBufferEvery", "operate", "source", "subscriber", "buffers", "count", "createOperatorSubscriber", "value", "toEmit", "buffers_1", "__values", "buffers_1_1", "buffer", "toEmit_1", "toEmit_1_1", "arrRemove", "buffers_2", "buffers_2_1", "catchError", "selector", "operate", "source", "subscriber", "innerSub", "syncUnsub", "handledResult", "createOperatorSubscriber", "err", "innerFrom", "scanInternals", "accumulator", "seed", "hasSeed", "emitOnNext", "emitBeforeComplete", "source", "subscriber", "hasState", "state", "index", "createOperatorSubscriber", "value", "i", "combineLatest", "args", "_i", "resultSelector", "popResultSelector", "pipe", "__spreadArray", "__read", "mapOneOrManyArgs", "operate", "source", "subscriber", "combineLatestInit", "argsOrArgArray", "combineLatestWith", "otherSources", "_i", "combineLatest", "__spreadArray", "__read", "concatMap", "project", "resultSelector", "isFunction", "mergeMap", "debounceTime", "dueTime", "scheduler", "asyncScheduler", "operate", "source", "subscriber", "activeTask", "lastValue", "lastTime", "emit", "value", "emitWhenIdle", "targetTime", "now", "createOperatorSubscriber", "defaultIfEmpty", "defaultValue", "operate", "source", "subscriber", "hasValue", "createOperatorSubscriber", "value", "take", "count", "EMPTY", "operate", "source", "subscriber", "seen", "createOperatorSubscriber", "value", "ignoreElements", "operate", "source", "subscriber", "createOperatorSubscriber", "noop", "mapTo", "value", "map", "delayWhen", "delayDurationSelector", "subscriptionDelay", "source", "concat", "take", "ignoreElements", "mergeMap", "value", "index", "mapTo", "delay", "due", "scheduler", "asyncScheduler", "duration", "timer", "delayWhen", "distinctUntilChanged", "comparator", "keySelector", "identity", "defaultCompare", "operate", "source", "subscriber", "previousKey", "first", "createOperatorSubscriber", "value", "currentKey", "a", "b", "distinctUntilKeyChanged", "key", "compare", "distinctUntilChanged", "x", "y", "endWith", "values", "_i", "source", "concat", "of", "__spreadArray", "__read", "finalize", "callback", "operate", "source", "subscriber", "takeLast", "count", "EMPTY", "operate", "source", "subscriber", "buffer", "createOperatorSubscriber", "value", "buffer_1", "__values", "buffer_1_1", "merge", "args", "_i", "scheduler", "popScheduler", "concurrent", "popNumber", "argsOrArgArray", "operate", "source", "subscriber", "mergeAll", "from", "__spreadArray", "__read", "mergeWith", "otherSources", "_i", "merge", "__spreadArray", "__read", "repeat", "countOrConfig", "count", "delay", "_a", "EMPTY", "operate", "source", "subscriber", "soFar", "sourceSub", "resubscribe", "notifier", "timer", "innerFrom", "notifierSubscriber_1", "createOperatorSubscriber", "subscribeToSource", "syncUnsub", "sample", "notifier", "operate", "source", "subscriber", "hasValue", "lastValue", "createOperatorSubscriber", "value", "noop", "scan", "accumulator", "seed", "operate", "scanInternals", "share", "options", "_a", "connector", "Subject", "_b", "resetOnError", "_c", "resetOnComplete", "_d", "resetOnRefCountZero", "wrapperSource", "connection", "resetConnection", "subject", "refCount", "hasCompleted", "hasErrored", "cancelReset", "reset", "resetAndUnsubscribe", "conn", "operate", "source", "subscriber", "dest", "handleReset", "SafeSubscriber", "value", "err", "innerFrom", "on", "args", "_i", "onSubscriber", "__spreadArray", "__read", "shareReplay", "configOrBufferSize", "windowTime", "scheduler", "bufferSize", "refCount", "_a", "_b", "_c", "share", "ReplaySubject", "skip", "count", "filter", "_", "index", "skipUntil", "notifier", "operate", "source", "subscriber", "taking", "skipSubscriber", "createOperatorSubscriber", "noop", "innerFrom", "value", "startWith", "values", "_i", "scheduler", "popScheduler", "operate", "source", "subscriber", "concat", "switchMap", "project", "resultSelector", "operate", "source", "subscriber", "innerSubscriber", "index", "isComplete", "checkComplete", "createOperatorSubscriber", "value", "innerIndex", "outerIndex", "innerFrom", "innerValue", "takeUntil", "notifier", "operate", "source", "subscriber", "innerFrom", "createOperatorSubscriber", "noop", "takeWhile", "predicate", "inclusive", "operate", "source", "subscriber", "index", "createOperatorSubscriber", "value", "result", "tap", "observerOrNext", "error", "complete", "tapObserver", "isFunction", "operate", "source", "subscriber", "_a", "isUnsub", "createOperatorSubscriber", "value", "err", "_b", "identity", "defaultThrottleConfig", "throttle", "durationSelector", "config", "operate", "source", "subscriber", "leading", "trailing", "hasValue", "sendValue", "throttled", "isComplete", "endThrottling", "send", "cleanupThrottling", "startThrottle", "value", "innerFrom", "createOperatorSubscriber", "throttleTime", "duration", "scheduler", "config", "asyncScheduler", "defaultThrottleConfig", "duration$", "timer", "throttle", "withLatestFrom", "inputs", "_i", "project", "popResultSelector", "operate", "source", "subscriber", "len", "otherValues", "hasValue", "ready", "i", "innerFrom", "createOperatorSubscriber", "value", "identity", "noop", "values", "__spreadArray", "__read", "zip", "sources", "_i", "operate", "source", "subscriber", "__spreadArray", "__read", "zipWith", "otherInputs", "_i", "zip", "__spreadArray", "__read", "watchDocument", "document$", "ReplaySubject", "fromEvent", "getElements", "selector", "node", "getElement", "el", "getOptionalElement", "getActiveElement", "watchElementFocus", "el", "merge", "fromEvent", "debounceTime", "map", "active", "getActiveElement", "startWith", "distinctUntilChanged", "getElementOffset", "el", "watchElementOffset", "merge", "fromEvent", "auditTime", "animationFrameScheduler", "map", "startWith", "getElementContentOffset", "el", "watchElementContentOffset", "merge", "fromEvent", "auditTime", "animationFrameScheduler", "map", "startWith", "MapShim", "getIndex", "arr", "key", "result", "entry", "index", "class_1", "value", "entries", "callback", "ctx", "_i", "_a", "isBrowser", "global$1", "requestAnimationFrame$1", "trailingTimeout", "throttle", "delay", "leadingCall", "trailingCall", "lastCallTime", "resolvePending", "proxy", "timeoutCallback", "timeStamp", "REFRESH_DELAY", "transitionKeys", "mutationObserverSupported", "ResizeObserverController", "observer", "observers", "changesDetected", "activeObservers", "_b", "propertyName", "isReflowProperty", "defineConfigurable", "target", "props", "getWindowOf", "ownerGlobal", "emptyRect", "createRectInit", "toFloat", "getBordersSize", "styles", "positions", "size", "position", "getPaddings", "paddings", "positions_1", "getSVGContentRect", "bbox", "getHTMLElementContentRect", "clientWidth", "clientHeight", "horizPad", "vertPad", "width", "height", "isDocumentElement", "vertScrollbar", "horizScrollbar", "isSVGGraphicsElement", "getContentRect", "createReadOnlyRect", "x", "y", "Constr", "rect", "ResizeObservation", "ResizeObserverEntry", "rectInit", "contentRect", "ResizeObserverSPI", "controller", "callbackCtx", "observations", "_this", "observation", "ResizeObserver", "method", "ResizeObserver_es_default", "entry$", "Subject", "observer$", "defer", "of", "ResizeObserver_es_default", "entries", "entry", "switchMap", "observer", "merge", "NEVER", "finalize", "shareReplay", "getElementSize", "el", "watchElementSize", "tap", "filter", "target", "map", "startWith", "getElementContentSize", "el", "getElementContainer", "parent", "entry$", "Subject", "observer$", "defer", "of", "entries", "entry", "switchMap", "observer", "merge", "NEVER", "finalize", "shareReplay", "watchElementVisibility", "el", "tap", "filter", "target", "map", "isIntersecting", "watchElementBoundary", "threshold", "watchElementContentOffset", "y", "visible", "getElementSize", "content", "getElementContentSize", "distinctUntilChanged", "toggles", "getElement", "getToggle", "name", "setToggle", "value", "watchToggle", "el", "fromEvent", "map", "startWith", "isSusceptibleToKeyboard", "el", "type", "watchKeyboard", "fromEvent", "filter", "ev", "map", "getToggle", "mode", "active", "getActiveElement", "share", "getLocation", "setLocation", "url", "watchLocation", "Subject", "appendChild", "el", "child", "node", "h", "tag", "attributes", "children", "attr", "truncate", "value", "n", "i", "round", "digits", "getLocationHash", "setLocationHash", "hash", "el", "h", "ev", "watchLocationHash", "fromEvent", "map", "startWith", "filter", "shareReplay", "watchLocationTarget", "id", "getOptionalElement", "watchMedia", "query", "media", "fromEventPattern", "next", "startWith", "watchPrint", "merge", "fromEvent", "map", "at", "query$", "factory", "switchMap", "active", "EMPTY", "request", "url", "options", "from", "catchError", "EMPTY", "switchMap", "res", "throwError", "of", "requestJSON", "shareReplay", "requestXML", "dom", "map", "watchScript", "src", "script", "h", "defer", "merge", "fromEvent", "switchMap", "throwError", "map", "finalize", "take", "getViewportOffset", "watchViewportOffset", "merge", "fromEvent", "map", "startWith", "getViewportSize", "watchViewportSize", "fromEvent", "map", "startWith", "watchViewport", "combineLatest", "watchViewportOffset", "watchViewportSize", "map", "offset", "size", "shareReplay", "watchViewportAt", "el", "viewport$", "header$", "size$", "distinctUntilKeyChanged", "offset$", "combineLatest", "map", "getElementOffset", "height", "offset", "size", "x", "y", "watchWorker", "worker", "tx$", "rx$", "fromEvent", "map", "data", "throttle", "tap", "message", "switchMap", "share", "script", "getElement", "config", "getLocation", "configuration", "feature", "flag", "translation", "key", "value", "getComponentElement", "type", "node", "getElement", "getComponentElements", "getElements", "watchAnnounce", "el", "button", "getElement", "fromEvent", "map", "content", "mountAnnounce", "feature", "EMPTY", "defer", "push$", "Subject", "startWith", "hash", "_a", "tap", "state", "finalize", "__spreadValues", "watchConsent", "el", "target$", "map", "target", "mountConsent", "options", "internal$", "Subject", "hidden", "tap", "state", "finalize", "__spreadValues", "import_clipboard", "renderTooltip", "id", "h", "renderAnnotation", "id", "prefix", "anchor", "h", "renderTooltip", "renderClipboardButton", "id", "h", "translation", "renderSearchDocument", "document", "flag", "parent", "teaser", "missing", "key", "list", "h", "url", "feature", "match", "highlight", "value", "tags", "configuration", "truncate", "tag", "id", "type", "translation", "renderSearchResultItem", "result", "threshold", "docs", "doc", "article", "index", "best", "more", "children", "section", "renderSourceFacts", "facts", "h", "key", "value", "round", "renderTabbedControl", "type", "classes", "h", "renderTable", "table", "h", "renderVersion", "version", "config", "configuration", "url", "h", "renderVersionSelector", "versions", "active", "translation", "watchAnnotation", "el", "container", "offset$", "defer", "combineLatest", "watchElementOffset", "watchElementContentOffset", "map", "x", "y", "scroll", "width", "height", "getElementSize", "watchElementFocus", "switchMap", "active", "offset", "take", "mountAnnotation", "target$", "tooltip", "index", "push$", "Subject", "done$", "takeLast", "watchElementVisibility", "takeUntil", "visible", "merge", "filter", "debounceTime", "auditTime", "animationFrameScheduler", "throttleTime", "origin", "fromEvent", "ev", "withLatestFrom", "_a", "parent", "getActiveElement", "target", "delay", "tap", "state", "finalize", "__spreadValues", "findAnnotationMarkers", "container", "markers", "el", "getElements", "nodes", "it", "node", "text", "match", "id", "force", "marker", "swap", "source", "target", "mountAnnotationList", "target$", "print$", "parent", "prefix", "annotations", "getOptionalElement", "renderAnnotation", "EMPTY", "defer", "done$", "Subject", "pairs", "annotation", "getElement", "takeUntil", "takeLast", "active", "inner", "child", "merge", "mountAnnotation", "finalize", "share", "sequence", "findCandidateList", "el", "sibling", "watchCodeBlock", "watchElementSize", "map", "width", "getElementContentSize", "distinctUntilKeyChanged", "mountCodeBlock", "options", "hover", "factory$", "defer", "push$", "Subject", "scrollable", "ClipboardJS", "parent", "renderClipboardButton", "container", "list", "feature", "annotations$", "mountAnnotationList", "tap", "state", "finalize", "__spreadValues", "mergeWith", "height", "distinctUntilChanged", "switchMap", "active", "EMPTY", "watchElementVisibility", "filter", "visible", "take", "mermaid$", "sequence", "fetchScripts", "watchScript", "of", "mountMermaid", "el", "tap", "mermaid_default", "map", "shareReplay", "id", "host", "h", "svg", "shadow", "watchDetails", "el", "target$", "print$", "open", "merge", "map", "target", "filter", "details", "active", "tap", "mountDetails", "options", "defer", "push$", "Subject", "action", "reveal", "state", "finalize", "__spreadValues", "sentinel", "h", "mountDataTable", "el", "renderTable", "of", "watchContentTabs", "el", "inputs", "getElements", "initial", "input", "merge", "fromEvent", "map", "getElement", "startWith", "active", "mountContentTabs", "viewport$", "prev", "renderTabbedControl", "next", "container", "defer", "push$", "Subject", "done$", "takeLast", "combineLatest", "watchElementSize", "auditTime", "animationFrameScheduler", "takeUntil", "size", "offset", "getElementOffset", "width", "getElementSize", "content", "getElementContentOffset", "watchElementContentOffset", "getElementContentSize", "direction", "feature", "skip", "withLatestFrom", "tab", "y", "set", "label", "tabs", "tap", "state", "finalize", "__spreadValues", "subscribeOn", "asyncScheduler", "mountContent", "el", "viewport$", "target$", "print$", "merge", "getElements", "child", "mountCodeBlock", "mountMermaid", "mountDataTable", "mountDetails", "mountContentTabs", "watchDialog", "_el", "alert$", "switchMap", "message", "merge", "of", "delay", "map", "active", "mountDialog", "el", "options", "inner", "getElement", "defer", "push$", "Subject", "tap", "state", "finalize", "__spreadValues", "isHidden", "viewport$", "feature", "of", "direction$", "map", "y", "bufferCount", "a", "b", "distinctUntilKeyChanged", "hidden$", "combineLatest", "filter", "offset", "direction", "distinctUntilChanged", "search$", "watchToggle", "search", "switchMap", "active", "startWith", "watchHeader", "el", "options", "defer", "watchElementSize", "height", "hidden", "shareReplay", "mountHeader", "header$", "main$", "push$", "Subject", "done$", "takeLast", "combineLatestWith", "takeUntil", "state", "__spreadValues", "watchHeaderTitle", "el", "viewport$", "header$", "watchViewportAt", "map", "y", "height", "getElementSize", "distinctUntilKeyChanged", "mountHeaderTitle", "options", "defer", "push$", "Subject", "active", "heading", "getOptionalElement", "EMPTY", "tap", "state", "finalize", "__spreadValues", "watchMain", "el", "viewport$", "header$", "adjust$", "map", "height", "distinctUntilChanged", "border$", "switchMap", "watchElementSize", "distinctUntilKeyChanged", "combineLatest", "header", "top", "bottom", "y", "a", "b", "watchPalette", "inputs", "current", "input", "of", "mergeMap", "fromEvent", "map", "startWith", "shareReplay", "mountPalette", "el", "defer", "push$", "Subject", "palette", "key", "value", "index", "label", "observeOn", "asyncScheduler", "getElements", "tap", "state", "finalize", "__spreadValues", "import_clipboard", "extract", "el", "text", "setupClipboardJS", "alert$", "ClipboardJS", "Observable", "subscriber", "getElement", "ev", "tap", "map", "translation", "preprocess", "urls", "root", "next", "a", "b", "url", "index", "fetchSitemap", "base", "cached", "of", "config", "configuration", "requestXML", "map", "sitemap", "getElements", "node", "catchError", "EMPTY", "defaultIfEmpty", "tap", "setupInstantLoading", "document$", "location$", "viewport$", "config", "configuration", "fromEvent", "favicon", "getOptionalElement", "push$", "fetchSitemap", "map", "paths", "path", "switchMap", "urls", "filter", "ev", "el", "url", "of", "NEVER", "share", "pop$", "merge", "distinctUntilChanged", "a", "b", "response$", "distinctUntilKeyChanged", "request", "catchError", "setLocation", "sample", "dom", "res", "skip", "replacement", "selector", "feature", "source", "target", "getComponentElement", "getElements", "concatMap", "script", "h", "name", "Observable", "observer", "EMPTY", "offset", "setLocationHash", "skipUntil", "debounceTime", "bufferCount", "state", "import_escape_html", "import_escape_html", "setupSearchHighlighter", "config", "escape", "separator", "highlight", "_", "data", "term", "query", "match", "value", "escapeHTML", "defaultTransform", "query", "terms", "index", "isSearchReadyMessage", "message", "isSearchQueryMessage", "isSearchResultMessage", "setupSearchIndex", "config", "docs", "translation", "options", "feature", "setupSearchWorker", "url", "index", "configuration", "worker", "tx$", "Subject", "rx$", "watchWorker", "map", "message", "isSearchResultMessage", "result", "document", "share", "from", "data", "setupVersionSelector", "document$", "config", "configuration", "versions$", "requestJSON", "catchError", "EMPTY", "current$", "map", "versions", "current", "version", "aliases", "switchMap", "urls", "fromEvent", "filter", "ev", "withLatestFrom", "el", "url", "of", "fetchSitemap", "sitemap", "path", "getLocation", "setLocation", "combineLatest", "getElement", "renderVersionSelector", "_a", "outdated", "latest", "warning", "getComponentElements", "watchSearchQuery", "el", "rx$", "fn", "defaultTransform", "searchParams", "getLocation", "setToggle", "param$", "filter", "isSearchReadyMessage", "take", "map", "watchToggle", "active", "url", "value", "focus$", "watchElementFocus", "value$", "merge", "fromEvent", "delay", "startWith", "distinctUntilChanged", "combineLatest", "focus", "shareReplay", "mountSearchQuery", "tx$", "push$", "Subject", "done$", "takeLast", "distinctUntilKeyChanged", "translation", "takeUntil", "tap", "state", "finalize", "__spreadValues", "share", "mountSearchResult", "el", "rx$", "query$", "push$", "Subject", "boundary$", "watchElementBoundary", "filter", "meta", "getElement", "list", "ready$", "isSearchReadyMessage", "take", "withLatestFrom", "skipUntil", "items", "value", "translation", "round", "tap", "switchMap", "merge", "of", "bufferCount", "zipWith", "chunk", "result", "renderSearchResultItem", "isSearchResultMessage", "map", "data", "state", "finalize", "__spreadValues", "watchSearchShare", "_el", "query$", "map", "value", "url", "getLocation", "mountSearchShare", "el", "options", "push$", "Subject", "fromEvent", "ev", "tap", "state", "finalize", "__spreadValues", "mountSearchSuggest", "el", "rx$", "keyboard$", "push$", "Subject", "query", "getComponentElement", "query$", "merge", "fromEvent", "observeOn", "asyncScheduler", "map", "distinctUntilChanged", "combineLatestWith", "suggestions", "value", "words", "last", "filter", "mode", "key", "isSearchResultMessage", "data", "tap", "state", "finalize", "mountSearch", "el", "index$", "keyboard$", "config", "configuration", "url", "worker", "setupSearchWorker", "query", "getComponentElement", "result", "tx$", "rx$", "filter", "isSearchQueryMessage", "sample", "isSearchReadyMessage", "take", "mode", "key", "active", "getActiveElement", "anchors", "anchor", "getElements", "article", "best", "a", "b", "setToggle", "els", "i", "query$", "mountSearchQuery", "result$", "mountSearchResult", "merge", "mergeWith", "getComponentElements", "child", "mountSearchShare", "mountSearchSuggest", "err", "NEVER", "mountSearchHiglight", "el", "index$", "location$", "combineLatest", "startWith", "getLocation", "filter", "url", "map", "index", "setupSearchHighlighter", "fn", "_a", "nodes", "it", "node", "original", "replaced", "text", "childNodes", "h", "watchSidebar", "el", "viewport$", "main$", "parent", "adjust", "combineLatest", "map", "offset", "height", "y", "distinctUntilChanged", "a", "b", "mountSidebar", "_a", "_b", "header$", "options", "__objRest", "inner", "getElement", "getElementOffset", "defer", "push$", "Subject", "auditTime", "animationFrameScheduler", "withLatestFrom", "observeOn", "take", "item", "getElements", "container", "getElementContainer", "getElementSize", "tap", "state", "finalize", "__spreadValues", "fetchSourceFactsFromGitHub", "user", "repo", "url", "zip", "requestJSON", "catchError", "EMPTY", "map", "release", "defaultIfEmpty", "info", "__spreadValues", "fetchSourceFactsFromGitLab", "base", "project", "url", "requestJSON", "catchError", "EMPTY", "map", "star_count", "forks_count", "defaultIfEmpty", "fetchSourceFacts", "url", "match", "user", "repo", "fetchSourceFactsFromGitHub", "base", "slug", "fetchSourceFactsFromGitLab", "EMPTY", "fetch$", "watchSource", "el", "defer", "cached", "of", "getComponentElements", "consent", "EMPTY", "fetchSourceFacts", "tap", "facts", "catchError", "filter", "map", "shareReplay", "mountSource", "inner", "getElement", "push$", "Subject", "renderSourceFacts", "state", "finalize", "__spreadValues", "watchTabs", "el", "viewport$", "header$", "watchElementSize", "switchMap", "watchViewportAt", "map", "y", "distinctUntilKeyChanged", "mountTabs", "options", "defer", "push$", "Subject", "hidden", "feature", "of", "tap", "state", "finalize", "__spreadValues", "watchTableOfContents", "el", "viewport$", "header$", "table", "anchors", "getElements", "anchor", "id", "target", "getOptionalElement", "adjust$", "distinctUntilKeyChanged", "map", "height", "main", "getComponentElement", "grid", "getElement", "share", "watchElementSize", "switchMap", "body", "defer", "path", "of", "index", "offset", "a", "b", "combineLatestWith", "adjust", "scan", "prev", "next", "y", "size", "last", "distinctUntilChanged", "startWith", "bufferCount", "mountTableOfContents", "target$", "push$", "Subject", "done$", "takeLast", "feature", "smooth$", "merge", "debounceTime", "filter", "withLatestFrom", "behavior", "container", "getElementContainer", "getElementSize", "takeUntil", "skip", "repeat", "url", "getLocation", "active", "hash", "tap", "state", "finalize", "__spreadValues", "watchBackToTop", "_el", "viewport$", "main$", "target$", "direction$", "map", "y", "bufferCount", "a", "b", "distinctUntilChanged", "active$", "active", "combineLatest", "direction", "takeUntil", "skip", "endWith", "repeat", "hidden", "mountBackToTop", "el", "header$", "push$", "Subject", "done$", "takeLast", "distinctUntilKeyChanged", "height", "tap", "state", "finalize", "__spreadValues", "patchIndeterminate", "document$", "tablet$", "switchMap", "getElements", "tap", "el", "mergeMap", "fromEvent", "takeWhile", "map", "withLatestFrom", "tablet", "isAppleDevice", "patchScrollfix", "document$", "switchMap", "getElements", "tap", "el", "filter", "mergeMap", "fromEvent", "map", "top", "patchScrolllock", "viewport$", "tablet$", "combineLatest", "watchToggle", "map", "active", "tablet", "switchMap", "of", "delay", "withLatestFrom", "y", "value", "obj", "data", "key", "x", "y", "nodes", "parent", "i", "node", "document$", "watchDocument", "location$", "watchLocation", "target$", "watchLocationTarget", "keyboard$", "watchKeyboard", "viewport$", "watchViewport", "tablet$", "watchMedia", "screen$", "print$", "watchPrint", "config", "configuration", "index$", "requestJSON", "NEVER", "alert$", "Subject", "setupClipboardJS", "feature", "setupInstantLoading", "_a", "setupVersionSelector", "merge", "delay", "setToggle", "filter", "mode", "key", "prev", "getOptionalElement", "next", "patchIndeterminate", "patchScrollfix", "patchScrolllock", "header$", "watchHeader", "getComponentElement", "main$", "map", "switchMap", "el", "watchMain", "shareReplay", "control$", "getComponentElements", "mountConsent", "mountDialog", "mountHeader", "mountPalette", "mountSearch", "mountSource", "content$", "defer", "mountAnnounce", "mountContent", "mountSearchHiglight", "EMPTY", "mountHeaderTitle", "at", "mountSidebar", "mountTabs", "mountTableOfContents", "mountBackToTop", "component$", "mergeWith"] -} diff --git a/assets/javascripts/bundle.aecac24b.min.js b/assets/javascripts/bundle.aecac24b.min.js new file mode 100644 index 000000000..464603d80 --- /dev/null +++ b/assets/javascripts/bundle.aecac24b.min.js @@ -0,0 +1,29 @@ +"use strict";(()=>{var wi=Object.create;var ur=Object.defineProperty;var Si=Object.getOwnPropertyDescriptor;var Ti=Object.getOwnPropertyNames,kt=Object.getOwnPropertySymbols,Oi=Object.getPrototypeOf,dr=Object.prototype.hasOwnProperty,Zr=Object.prototype.propertyIsEnumerable;var Xr=(e,t,r)=>t in e?ur(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,R=(e,t)=>{for(var r in t||(t={}))dr.call(t,r)&&Xr(e,r,t[r]);if(kt)for(var r of kt(t))Zr.call(t,r)&&Xr(e,r,t[r]);return e};var eo=(e,t)=>{var r={};for(var o in e)dr.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&kt)for(var o of kt(e))t.indexOf(o)<0&&Zr.call(e,o)&&(r[o]=e[o]);return r};var hr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Mi=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ti(t))!dr.call(e,n)&&n!==r&&ur(e,n,{get:()=>t[n],enumerable:!(o=Si(t,n))||o.enumerable});return e};var Ht=(e,t,r)=>(r=e!=null?wi(Oi(e)):{},Mi(t||!e||!e.__esModule?ur(r,"default",{value:e,enumerable:!0}):r,e));var ro=hr((br,to)=>{(function(e,t){typeof br=="object"&&typeof to!="undefined"?t():typeof define=="function"&&define.amd?define(t):t()})(br,function(){"use strict";function e(r){var o=!0,n=!1,i=null,s={text:!0,search:!0,url:!0,tel:!0,email:!0,password:!0,number:!0,date:!0,month:!0,week:!0,time:!0,datetime:!0,"datetime-local":!0};function a(C){return!!(C&&C!==document&&C.nodeName!=="HTML"&&C.nodeName!=="BODY"&&"classList"in C&&"contains"in C.classList)}function c(C){var it=C.type,Ne=C.tagName;return!!(Ne==="INPUT"&&s[it]&&!C.readOnly||Ne==="TEXTAREA"&&!C.readOnly||C.isContentEditable)}function p(C){C.classList.contains("focus-visible")||(C.classList.add("focus-visible"),C.setAttribute("data-focus-visible-added",""))}function l(C){C.hasAttribute("data-focus-visible-added")&&(C.classList.remove("focus-visible"),C.removeAttribute("data-focus-visible-added"))}function f(C){C.metaKey||C.altKey||C.ctrlKey||(a(r.activeElement)&&p(r.activeElement),o=!0)}function u(C){o=!1}function d(C){a(C.target)&&(o||c(C.target))&&p(C.target)}function v(C){a(C.target)&&(C.target.classList.contains("focus-visible")||C.target.hasAttribute("data-focus-visible-added"))&&(n=!0,window.clearTimeout(i),i=window.setTimeout(function(){n=!1},100),l(C.target))}function b(C){document.visibilityState==="hidden"&&(n&&(o=!0),z())}function z(){document.addEventListener("mousemove",G),document.addEventListener("mousedown",G),document.addEventListener("mouseup",G),document.addEventListener("pointermove",G),document.addEventListener("pointerdown",G),document.addEventListener("pointerup",G),document.addEventListener("touchmove",G),document.addEventListener("touchstart",G),document.addEventListener("touchend",G)}function K(){document.removeEventListener("mousemove",G),document.removeEventListener("mousedown",G),document.removeEventListener("mouseup",G),document.removeEventListener("pointermove",G),document.removeEventListener("pointerdown",G),document.removeEventListener("pointerup",G),document.removeEventListener("touchmove",G),document.removeEventListener("touchstart",G),document.removeEventListener("touchend",G)}function G(C){C.target.nodeName&&C.target.nodeName.toLowerCase()==="html"||(o=!1,K())}document.addEventListener("keydown",f,!0),document.addEventListener("mousedown",u,!0),document.addEventListener("pointerdown",u,!0),document.addEventListener("touchstart",u,!0),document.addEventListener("visibilitychange",b,!0),z(),r.addEventListener("focus",d,!0),r.addEventListener("blur",v,!0),r.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&r.host?r.host.setAttribute("data-js-focus-visible",""):r.nodeType===Node.DOCUMENT_NODE&&(document.documentElement.classList.add("js-focus-visible"),document.documentElement.setAttribute("data-js-focus-visible",""))}if(typeof window!="undefined"&&typeof document!="undefined"){window.applyFocusVisiblePolyfill=e;var t;try{t=new CustomEvent("focus-visible-polyfill-ready")}catch(r){t=document.createEvent("CustomEvent"),t.initCustomEvent("focus-visible-polyfill-ready",!1,!1,{})}window.dispatchEvent(t)}typeof document!="undefined"&&e(document)})});var Vr=hr((Ot,Dr)=>{/*! + * clipboard.js v2.0.11 + * https://clipboardjs.com/ + * + * Licensed MIT © Zeno Rocha + */(function(t,r){typeof Ot=="object"&&typeof Dr=="object"?Dr.exports=r():typeof define=="function"&&define.amd?define([],r):typeof Ot=="object"?Ot.ClipboardJS=r():t.ClipboardJS=r()})(Ot,function(){return function(){var e={686:function(o,n,i){"use strict";i.d(n,{default:function(){return Ei}});var s=i(279),a=i.n(s),c=i(370),p=i.n(c),l=i(817),f=i.n(l);function u(U){try{return document.execCommand(U)}catch(O){return!1}}var d=function(O){var S=f()(O);return u("cut"),S},v=d;function b(U){var O=document.documentElement.getAttribute("dir")==="rtl",S=document.createElement("textarea");S.style.fontSize="12pt",S.style.border="0",S.style.padding="0",S.style.margin="0",S.style.position="absolute",S.style[O?"right":"left"]="-9999px";var $=window.pageYOffset||document.documentElement.scrollTop;return S.style.top="".concat($,"px"),S.setAttribute("readonly",""),S.value=U,S}var z=function(O,S){var $=b(O);S.container.appendChild($);var F=f()($);return u("copy"),$.remove(),F},K=function(O){var S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},$="";return typeof O=="string"?$=z(O,S):O instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(O==null?void 0:O.type)?$=z(O.value,S):($=f()(O),u("copy")),$},G=K;function C(U){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?C=function(S){return typeof S}:C=function(S){return S&&typeof Symbol=="function"&&S.constructor===Symbol&&S!==Symbol.prototype?"symbol":typeof S},C(U)}var it=function(){var O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},S=O.action,$=S===void 0?"copy":S,F=O.container,Q=O.target,_e=O.text;if($!=="copy"&&$!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(Q!==void 0)if(Q&&C(Q)==="object"&&Q.nodeType===1){if($==="copy"&&Q.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if($==="cut"&&(Q.hasAttribute("readonly")||Q.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}else throw new Error('Invalid "target" value, use a valid Element');if(_e)return G(_e,{container:F});if(Q)return $==="cut"?v(Q):G(Q,{container:F})},Ne=it;function Pe(U){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Pe=function(S){return typeof S}:Pe=function(S){return S&&typeof Symbol=="function"&&S.constructor===Symbol&&S!==Symbol.prototype?"symbol":typeof S},Pe(U)}function ui(U,O){if(!(U instanceof O))throw new TypeError("Cannot call a class as a function")}function Jr(U,O){for(var S=0;S0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof F.action=="function"?F.action:this.defaultAction,this.target=typeof F.target=="function"?F.target:this.defaultTarget,this.text=typeof F.text=="function"?F.text:this.defaultText,this.container=Pe(F.container)==="object"?F.container:document.body}},{key:"listenClick",value:function(F){var Q=this;this.listener=p()(F,"click",function(_e){return Q.onClick(_e)})}},{key:"onClick",value:function(F){var Q=F.delegateTarget||F.currentTarget,_e=this.action(Q)||"copy",Ct=Ne({action:_e,container:this.container,target:this.target(Q),text:this.text(Q)});this.emit(Ct?"success":"error",{action:_e,text:Ct,trigger:Q,clearSelection:function(){Q&&Q.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(F){return fr("action",F)}},{key:"defaultTarget",value:function(F){var Q=fr("target",F);if(Q)return document.querySelector(Q)}},{key:"defaultText",value:function(F){return fr("text",F)}},{key:"destroy",value:function(){this.listener.destroy()}}],[{key:"copy",value:function(F){var Q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body};return G(F,Q)}},{key:"cut",value:function(F){return v(F)}},{key:"isSupported",value:function(){var F=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],Q=typeof F=="string"?[F]:F,_e=!!document.queryCommandSupported;return Q.forEach(function(Ct){_e=_e&&!!document.queryCommandSupported(Ct)}),_e}}]),S}(a()),Ei=yi},828:function(o){var n=9;if(typeof Element!="undefined"&&!Element.prototype.matches){var i=Element.prototype;i.matches=i.matchesSelector||i.mozMatchesSelector||i.msMatchesSelector||i.oMatchesSelector||i.webkitMatchesSelector}function s(a,c){for(;a&&a.nodeType!==n;){if(typeof a.matches=="function"&&a.matches(c))return a;a=a.parentNode}}o.exports=s},438:function(o,n,i){var s=i(828);function a(l,f,u,d,v){var b=p.apply(this,arguments);return l.addEventListener(u,b,v),{destroy:function(){l.removeEventListener(u,b,v)}}}function c(l,f,u,d,v){return typeof l.addEventListener=="function"?a.apply(null,arguments):typeof u=="function"?a.bind(null,document).apply(null,arguments):(typeof l=="string"&&(l=document.querySelectorAll(l)),Array.prototype.map.call(l,function(b){return a(b,f,u,d,v)}))}function p(l,f,u,d){return function(v){v.delegateTarget=s(v.target,f),v.delegateTarget&&d.call(l,v)}}o.exports=c},879:function(o,n){n.node=function(i){return i!==void 0&&i instanceof HTMLElement&&i.nodeType===1},n.nodeList=function(i){var s=Object.prototype.toString.call(i);return i!==void 0&&(s==="[object NodeList]"||s==="[object HTMLCollection]")&&"length"in i&&(i.length===0||n.node(i[0]))},n.string=function(i){return typeof i=="string"||i instanceof String},n.fn=function(i){var s=Object.prototype.toString.call(i);return s==="[object Function]"}},370:function(o,n,i){var s=i(879),a=i(438);function c(u,d,v){if(!u&&!d&&!v)throw new Error("Missing required arguments");if(!s.string(d))throw new TypeError("Second argument must be a String");if(!s.fn(v))throw new TypeError("Third argument must be a Function");if(s.node(u))return p(u,d,v);if(s.nodeList(u))return l(u,d,v);if(s.string(u))return f(u,d,v);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function p(u,d,v){return u.addEventListener(d,v),{destroy:function(){u.removeEventListener(d,v)}}}function l(u,d,v){return Array.prototype.forEach.call(u,function(b){b.addEventListener(d,v)}),{destroy:function(){Array.prototype.forEach.call(u,function(b){b.removeEventListener(d,v)})}}}function f(u,d,v){return a(document.body,u,d,v)}o.exports=c},817:function(o){function n(i){var s;if(i.nodeName==="SELECT")i.focus(),s=i.value;else if(i.nodeName==="INPUT"||i.nodeName==="TEXTAREA"){var a=i.hasAttribute("readonly");a||i.setAttribute("readonly",""),i.select(),i.setSelectionRange(0,i.value.length),a||i.removeAttribute("readonly"),s=i.value}else{i.hasAttribute("contenteditable")&&i.focus();var c=window.getSelection(),p=document.createRange();p.selectNodeContents(i),c.removeAllRanges(),c.addRange(p),s=c.toString()}return s}o.exports=n},279:function(o){function n(){}n.prototype={on:function(i,s,a){var c=this.e||(this.e={});return(c[i]||(c[i]=[])).push({fn:s,ctx:a}),this},once:function(i,s,a){var c=this;function p(){c.off(i,p),s.apply(a,arguments)}return p._=s,this.on(i,p,a)},emit:function(i){var s=[].slice.call(arguments,1),a=((this.e||(this.e={}))[i]||[]).slice(),c=0,p=a.length;for(c;c{"use strict";/*! + * escape-html + * Copyright(c) 2012-2013 TJ Holowaychuk + * Copyright(c) 2015 Andreas Lubbe + * Copyright(c) 2015 Tiancheng "Timothy" Gu + * MIT Licensed + */var Ha=/["'&<>]/;Un.exports=$a;function $a(e){var t=""+e,r=Ha.exec(t);if(!r)return t;var o,n="",i=0,s=0;for(i=r.index;i0&&i[i.length-1])&&(p[0]===6||p[0]===2)){r=0;continue}if(p[0]===3&&(!i||p[1]>i[0]&&p[1]=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function N(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),n,i=[],s;try{for(;(t===void 0||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(a){s={error:a}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(s)throw s.error}}return i}function D(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o1||a(u,d)})})}function a(u,d){try{c(o[u](d))}catch(v){f(i[0][3],v)}}function c(u){u.value instanceof Ze?Promise.resolve(u.value.v).then(p,l):f(i[0][2],u)}function p(u){a("next",u)}function l(u){a("throw",u)}function f(u,d){u(d),i.shift(),i.length&&a(i[0][0],i[0][1])}}function io(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof we=="function"?we(e):e[Symbol.iterator](),r={},o("next"),o("throw"),o("return"),r[Symbol.asyncIterator]=function(){return this},r);function o(i){r[i]=e[i]&&function(s){return new Promise(function(a,c){s=e[i](s),n(a,c,s.done,s.value)})}}function n(i,s,a,c){Promise.resolve(c).then(function(p){i({value:p,done:a})},s)}}function k(e){return typeof e=="function"}function at(e){var t=function(o){Error.call(o),o.stack=new Error().stack},r=e(t);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var Rt=at(function(e){return function(r){e(this),this.message=r?r.length+` errors occurred during unsubscription: +`+r.map(function(o,n){return n+1+") "+o.toString()}).join(` + `):"",this.name="UnsubscriptionError",this.errors=r}});function De(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var Ie=function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,o,n,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=we(s),c=a.next();!c.done;c=a.next()){var p=c.value;p.remove(this)}}catch(b){t={error:b}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}else s.remove(this);var l=this.initialTeardown;if(k(l))try{l()}catch(b){i=b instanceof Rt?b.errors:[b]}var f=this._finalizers;if(f){this._finalizers=null;try{for(var u=we(f),d=u.next();!d.done;d=u.next()){var v=d.value;try{ao(v)}catch(b){i=i!=null?i:[],b instanceof Rt?i=D(D([],N(i)),N(b.errors)):i.push(b)}}}catch(b){o={error:b}}finally{try{d&&!d.done&&(n=u.return)&&n.call(u)}finally{if(o)throw o.error}}}if(i)throw new Rt(i)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)ao(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&De(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&De(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}();var gr=Ie.EMPTY;function Pt(e){return e instanceof Ie||e&&"closed"in e&&k(e.remove)&&k(e.add)&&k(e.unsubscribe)}function ao(e){k(e)?e():e.unsubscribe()}var Ae={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var st={setTimeout:function(e,t){for(var r=[],o=2;o0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var o=this,n=this,i=n.hasError,s=n.isStopped,a=n.observers;return i||s?gr:(this.currentObservers=null,a.push(r),new Ie(function(){o.currentObservers=null,De(a,r)}))},t.prototype._checkFinalizedStatuses=function(r){var o=this,n=o.hasError,i=o.thrownError,s=o.isStopped;n?r.error(i):s&&r.complete()},t.prototype.asObservable=function(){var r=new P;return r.source=this,r},t.create=function(r,o){return new ho(r,o)},t}(P);var ho=function(e){ie(t,e);function t(r,o){var n=e.call(this)||this;return n.destination=r,n.source=o,n}return t.prototype.next=function(r){var o,n;(n=(o=this.destination)===null||o===void 0?void 0:o.next)===null||n===void 0||n.call(o,r)},t.prototype.error=function(r){var o,n;(n=(o=this.destination)===null||o===void 0?void 0:o.error)===null||n===void 0||n.call(o,r)},t.prototype.complete=function(){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||o===void 0||o.call(r)},t.prototype._subscribe=function(r){var o,n;return(n=(o=this.source)===null||o===void 0?void 0:o.subscribe(r))!==null&&n!==void 0?n:gr},t}(x);var yt={now:function(){return(yt.delegate||Date).now()},delegate:void 0};var Et=function(e){ie(t,e);function t(r,o,n){r===void 0&&(r=1/0),o===void 0&&(o=1/0),n===void 0&&(n=yt);var i=e.call(this)||this;return i._bufferSize=r,i._windowTime=o,i._timestampProvider=n,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=o===1/0,i._bufferSize=Math.max(1,r),i._windowTime=Math.max(1,o),i}return t.prototype.next=function(r){var o=this,n=o.isStopped,i=o._buffer,s=o._infiniteTimeWindow,a=o._timestampProvider,c=o._windowTime;n||(i.push(r),!s&&i.push(a.now()+c)),this._trimBuffer(),e.prototype.next.call(this,r)},t.prototype._subscribe=function(r){this._throwIfClosed(),this._trimBuffer();for(var o=this._innerSubscribe(r),n=this,i=n._infiniteTimeWindow,s=n._buffer,a=s.slice(),c=0;c0?e.prototype.requestAsyncId.call(this,r,o,n):(r.actions.push(this),r._scheduled||(r._scheduled=lt.requestAnimationFrame(function(){return r.flush(void 0)})))},t.prototype.recycleAsyncId=function(r,o,n){var i;if(n===void 0&&(n=0),n!=null?n>0:this.delay>0)return e.prototype.recycleAsyncId.call(this,r,o,n);var s=r.actions;o!=null&&((i=s[s.length-1])===null||i===void 0?void 0:i.id)!==o&&(lt.cancelAnimationFrame(o),r._scheduled=void 0)},t}(jt);var go=function(e){ie(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.flush=function(r){this._active=!0;var o=this._scheduled;this._scheduled=void 0;var n=this.actions,i;r=r||n.shift();do if(i=r.execute(r.state,r.delay))break;while((r=n[0])&&r.id===o&&n.shift());if(this._active=!1,i){for(;(r=n[0])&&r.id===o&&n.shift();)r.unsubscribe();throw i}},t}(Wt);var Oe=new go(vo);var L=new P(function(e){return e.complete()});function Ut(e){return e&&k(e.schedule)}function Or(e){return e[e.length-1]}function Qe(e){return k(Or(e))?e.pop():void 0}function Me(e){return Ut(Or(e))?e.pop():void 0}function Nt(e,t){return typeof Or(e)=="number"?e.pop():t}var mt=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function Dt(e){return k(e==null?void 0:e.then)}function Vt(e){return k(e[pt])}function zt(e){return Symbol.asyncIterator&&k(e==null?void 0:e[Symbol.asyncIterator])}function qt(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Pi(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Kt=Pi();function Qt(e){return k(e==null?void 0:e[Kt])}function Yt(e){return no(this,arguments,function(){var r,o,n,i;return $t(this,function(s){switch(s.label){case 0:r=e.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,Ze(r.read())];case 3:return o=s.sent(),n=o.value,i=o.done,i?[4,Ze(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,Ze(n)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})})}function Bt(e){return k(e==null?void 0:e.getReader)}function I(e){if(e instanceof P)return e;if(e!=null){if(Vt(e))return Ii(e);if(mt(e))return Fi(e);if(Dt(e))return ji(e);if(zt(e))return xo(e);if(Qt(e))return Wi(e);if(Bt(e))return Ui(e)}throw qt(e)}function Ii(e){return new P(function(t){var r=e[pt]();if(k(r.subscribe))return r.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Fi(e){return new P(function(t){for(var r=0;r=2;return function(o){return o.pipe(e?M(function(n,i){return e(n,i,o)}):ue,xe(1),r?He(t):Io(function(){return new Jt}))}}function Fo(){for(var e=[],t=0;t=2,!0))}function le(e){e===void 0&&(e={});var t=e.connector,r=t===void 0?function(){return new x}:t,o=e.resetOnError,n=o===void 0?!0:o,i=e.resetOnComplete,s=i===void 0?!0:i,a=e.resetOnRefCountZero,c=a===void 0?!0:a;return function(p){var l,f,u,d=0,v=!1,b=!1,z=function(){f==null||f.unsubscribe(),f=void 0},K=function(){z(),l=u=void 0,v=b=!1},G=function(){var C=l;K(),C==null||C.unsubscribe()};return g(function(C,it){d++,!b&&!v&&z();var Ne=u=u!=null?u:r();it.add(function(){d--,d===0&&!b&&!v&&(f=Hr(G,c))}),Ne.subscribe(it),!l&&d>0&&(l=new tt({next:function(Pe){return Ne.next(Pe)},error:function(Pe){b=!0,z(),f=Hr(K,n,Pe),Ne.error(Pe)},complete:function(){v=!0,z(),f=Hr(K,s),Ne.complete()}}),I(C).subscribe(l))})(p)}}function Hr(e,t){for(var r=[],o=2;oe.next(document)),e}function q(e,t=document){return Array.from(t.querySelectorAll(e))}function W(e,t=document){let r=ce(e,t);if(typeof r=="undefined")throw new ReferenceError(`Missing element: expected "${e}" to be present`);return r}function ce(e,t=document){return t.querySelector(e)||void 0}function Re(){return document.activeElement instanceof HTMLElement&&document.activeElement||void 0}var na=_(h(document.body,"focusin"),h(document.body,"focusout")).pipe(ke(1),V(void 0),m(()=>Re()||document.body),J(1));function Zt(e){return na.pipe(m(t=>e.contains(t)),X())}function Je(e){return{x:e.offsetLeft,y:e.offsetTop}}function No(e){return _(h(window,"load"),h(window,"resize")).pipe(Ce(0,Oe),m(()=>Je(e)),V(Je(e)))}function er(e){return{x:e.scrollLeft,y:e.scrollTop}}function dt(e){return _(h(e,"scroll"),h(window,"resize")).pipe(Ce(0,Oe),m(()=>er(e)),V(er(e)))}function Do(e,t){if(typeof t=="string"||typeof t=="number")e.innerHTML+=t.toString();else if(t instanceof Node)e.appendChild(t);else if(Array.isArray(t))for(let r of t)Do(e,r)}function T(e,t,...r){let o=document.createElement(e);if(t)for(let n of Object.keys(t))typeof t[n]!="undefined"&&(typeof t[n]!="boolean"?o.setAttribute(n,t[n]):o.setAttribute(n,""));for(let n of r)Do(o,n);return o}function tr(e){if(e>999){let t=+((e-950)%1e3>99);return`${((e+1e-6)/1e3).toFixed(t)}k`}else return e.toString()}function ht(e){let t=T("script",{src:e});return H(()=>(document.head.appendChild(t),_(h(t,"load"),h(t,"error").pipe(E(()=>Mr(()=>new ReferenceError(`Invalid script: ${e}`))))).pipe(m(()=>{}),A(()=>document.head.removeChild(t)),xe(1))))}var Vo=new x,ia=H(()=>typeof ResizeObserver=="undefined"?ht("https://unpkg.com/resize-observer-polyfill"):j(void 0)).pipe(m(()=>new ResizeObserver(e=>{for(let t of e)Vo.next(t)})),E(e=>_(Ve,j(e)).pipe(A(()=>e.disconnect()))),J(1));function he(e){return{width:e.offsetWidth,height:e.offsetHeight}}function ye(e){return ia.pipe(w(t=>t.observe(e)),E(t=>Vo.pipe(M(({target:r})=>r===e),A(()=>t.unobserve(e)),m(()=>he(e)))),V(he(e)))}function bt(e){return{width:e.scrollWidth,height:e.scrollHeight}}function zo(e){let t=e.parentElement;for(;t&&(e.scrollWidth<=t.scrollWidth&&e.scrollHeight<=t.scrollHeight);)t=(e=t).parentElement;return t?e:void 0}var qo=new x,aa=H(()=>j(new IntersectionObserver(e=>{for(let t of e)qo.next(t)},{threshold:0}))).pipe(E(e=>_(Ve,j(e)).pipe(A(()=>e.disconnect()))),J(1));function rr(e){return aa.pipe(w(t=>t.observe(e)),E(t=>qo.pipe(M(({target:r})=>r===e),A(()=>t.unobserve(e)),m(({isIntersecting:r})=>r))))}function Ko(e,t=16){return dt(e).pipe(m(({y:r})=>{let o=he(e),n=bt(e);return r>=n.height-o.height-t}),X())}var or={drawer:W("[data-md-toggle=drawer]"),search:W("[data-md-toggle=search]")};function Qo(e){return or[e].checked}function Ke(e,t){or[e].checked!==t&&or[e].click()}function We(e){let t=or[e];return h(t,"change").pipe(m(()=>t.checked),V(t.checked))}function sa(e,t){switch(e.constructor){case HTMLInputElement:return e.type==="radio"?/^Arrow/.test(t):!0;case HTMLSelectElement:case HTMLTextAreaElement:return!0;default:return e.isContentEditable}}function ca(){return _(h(window,"compositionstart").pipe(m(()=>!0)),h(window,"compositionend").pipe(m(()=>!1))).pipe(V(!1))}function Yo(){let e=h(window,"keydown").pipe(M(t=>!(t.metaKey||t.ctrlKey)),m(t=>({mode:Qo("search")?"search":"global",type:t.key,claim(){t.preventDefault(),t.stopPropagation()}})),M(({mode:t,type:r})=>{if(t==="global"){let o=Re();if(typeof o!="undefined")return!sa(o,r)}return!0}),le());return ca().pipe(E(t=>t?L:e))}function pe(){return new URL(location.href)}function ot(e,t=!1){if(te("navigation.instant")&&!t){let r=T("a",{href:e.href});document.body.appendChild(r),r.click(),r.remove()}else location.href=e.href}function Bo(){return new x}function Go(){return location.hash.slice(1)}function nr(e){let t=T("a",{href:e});t.addEventListener("click",r=>r.stopPropagation()),t.click()}function pa(e){return _(h(window,"hashchange"),e).pipe(m(Go),V(Go()),M(t=>t.length>0),J(1))}function Jo(e){return pa(e).pipe(m(t=>ce(`[id="${t}"]`)),M(t=>typeof t!="undefined"))}function Fr(e){let t=matchMedia(e);return Xt(r=>t.addListener(()=>r(t.matches))).pipe(V(t.matches))}function Xo(){let e=matchMedia("print");return _(h(window,"beforeprint").pipe(m(()=>!0)),h(window,"afterprint").pipe(m(()=>!1))).pipe(V(e.matches))}function jr(e,t){return e.pipe(E(r=>r?t():L))}function ir(e,t){return new P(r=>{let o=new XMLHttpRequest;o.open("GET",`${e}`),o.responseType="blob",o.addEventListener("load",()=>{o.status>=200&&o.status<300?(r.next(o.response),r.complete()):r.error(new Error(o.statusText))}),o.addEventListener("error",()=>{r.error(new Error("Network Error"))}),o.addEventListener("abort",()=>{r.error(new Error("Request aborted"))}),typeof(t==null?void 0:t.progress$)!="undefined"&&(o.addEventListener("progress",n=>{t.progress$.next(n.loaded/n.total*100)}),t.progress$.next(5)),o.send()})}function Ue(e,t){return ir(e,t).pipe(E(r=>r.text()),m(r=>JSON.parse(r)),J(1))}function Zo(e,t){let r=new DOMParser;return ir(e,t).pipe(E(o=>o.text()),m(o=>r.parseFromString(o,"text/xml")),J(1))}function en(){return{x:Math.max(0,scrollX),y:Math.max(0,scrollY)}}function tn(){return _(h(window,"scroll",{passive:!0}),h(window,"resize",{passive:!0})).pipe(m(en),V(en()))}function rn(){return{width:innerWidth,height:innerHeight}}function on(){return h(window,"resize",{passive:!0}).pipe(m(rn),V(rn()))}function nn(){return B([tn(),on()]).pipe(m(([e,t])=>({offset:e,size:t})),J(1))}function ar(e,{viewport$:t,header$:r}){let o=t.pipe(ee("size")),n=B([o,r]).pipe(m(()=>Je(e)));return B([r,t,n]).pipe(m(([{height:i},{offset:s,size:a},{x:c,y:p}])=>({offset:{x:s.x-c,y:s.y-p+i},size:a})))}function la(e){return h(e,"message",t=>t.data)}function ma(e){let t=new x;return t.subscribe(r=>e.postMessage(r)),t}function an(e,t=new Worker(e)){let r=la(t),o=ma(t),n=new x;n.subscribe(o);let i=o.pipe(Z(),re(!0));return n.pipe(Z(),qe(r.pipe(Y(i))),le())}var fa=W("#__config"),vt=JSON.parse(fa.textContent);vt.base=`${new URL(vt.base,pe())}`;function me(){return vt}function te(e){return vt.features.includes(e)}function be(e,t){return typeof t!="undefined"?vt.translations[e].replace("#",t.toString()):vt.translations[e]}function Ee(e,t=document){return W(`[data-md-component=${e}]`,t)}function oe(e,t=document){return q(`[data-md-component=${e}]`,t)}function ua(e){let t=W(".md-typeset > :first-child",e);return h(t,"click",{once:!0}).pipe(m(()=>W(".md-typeset",e)),m(r=>({hash:__md_hash(r.innerHTML)})))}function sn(e){if(!te("announce.dismiss")||!e.childElementCount)return L;if(!e.hidden){let t=W(".md-typeset",e);__md_hash(t.innerHTML)===__md_get("__announce")&&(e.hidden=!0)}return H(()=>{let t=new x;return t.subscribe(({hash:r})=>{e.hidden=!0,__md_set("__announce",r)}),ua(e).pipe(w(r=>t.next(r)),A(()=>t.complete()),m(r=>R({ref:e},r)))})}function da(e,{target$:t}){return t.pipe(m(r=>({hidden:r!==e})))}function cn(e,t){let r=new x;return r.subscribe(({hidden:o})=>{e.hidden=o}),da(e,t).pipe(w(o=>r.next(o)),A(()=>r.complete()),m(o=>R({ref:e},o)))}function ha(e,t){let r=H(()=>B([No(e),dt(t)])).pipe(m(([{x:o,y:n},i])=>{let{width:s,height:a}=he(e);return{x:o-i.x+s/2,y:n-i.y+a/2}}));return Zt(e).pipe(E(o=>r.pipe(m(n=>({active:o,offset:n})),xe(+!o||1/0))))}function pn(e,t,{target$:r}){let[o,n]=Array.from(e.children);return H(()=>{let i=new x,s=i.pipe(Z(),re(!0));return i.subscribe({next({offset:a}){e.style.setProperty("--md-tooltip-x",`${a.x}px`),e.style.setProperty("--md-tooltip-y",`${a.y}px`)},complete(){e.style.removeProperty("--md-tooltip-x"),e.style.removeProperty("--md-tooltip-y")}}),rr(e).pipe(Y(s)).subscribe(a=>{e.toggleAttribute("data-md-visible",a)}),_(i.pipe(M(({active:a})=>a)),i.pipe(ke(250),M(({active:a})=>!a))).subscribe({next({active:a}){a?e.prepend(o):o.remove()},complete(){e.prepend(o)}}),i.pipe(Ce(16,Oe)).subscribe(({active:a})=>{o.classList.toggle("md-tooltip--active",a)}),i.pipe(Pr(125,Oe),M(()=>!!e.offsetParent),m(()=>e.offsetParent.getBoundingClientRect()),m(({x:a})=>a)).subscribe({next(a){a?e.style.setProperty("--md-tooltip-0",`${-a}px`):e.style.removeProperty("--md-tooltip-0")},complete(){e.style.removeProperty("--md-tooltip-0")}}),h(n,"click").pipe(Y(s),M(a=>!(a.metaKey||a.ctrlKey))).subscribe(a=>{a.stopPropagation(),a.preventDefault()}),h(n,"mousedown").pipe(Y(s),ne(i)).subscribe(([a,{active:c}])=>{var p;if(a.button!==0||a.metaKey||a.ctrlKey)a.preventDefault();else if(c){a.preventDefault();let l=e.parentElement.closest(".md-annotation");l instanceof HTMLElement?l.focus():(p=Re())==null||p.blur()}}),r.pipe(Y(s),M(a=>a===o),ze(125)).subscribe(()=>e.focus()),ha(e,t).pipe(w(a=>i.next(a)),A(()=>i.complete()),m(a=>R({ref:e},a)))})}function Wr(e){return T("div",{class:"md-tooltip",id:e},T("div",{class:"md-tooltip__inner md-typeset"}))}function ln(e,t){if(t=t?`${t}_annotation_${e}`:void 0,t){let r=t?`#${t}`:void 0;return T("aside",{class:"md-annotation",tabIndex:0},Wr(t),T("a",{href:r,class:"md-annotation__index",tabIndex:-1},T("span",{"data-md-annotation-id":e})))}else return T("aside",{class:"md-annotation",tabIndex:0},Wr(t),T("span",{class:"md-annotation__index",tabIndex:-1},T("span",{"data-md-annotation-id":e})))}function mn(e){return T("button",{class:"md-clipboard md-icon",title:be("clipboard.copy"),"data-clipboard-target":`#${e} > code`})}function Ur(e,t){let r=t&2,o=t&1,n=Object.keys(e.terms).filter(c=>!e.terms[c]).reduce((c,p)=>[...c,T("del",null,p)," "],[]).slice(0,-1),i=me(),s=new URL(e.location,i.base);te("search.highlight")&&s.searchParams.set("h",Object.entries(e.terms).filter(([,c])=>c).reduce((c,[p])=>`${c} ${p}`.trim(),""));let{tags:a}=me();return T("a",{href:`${s}`,class:"md-search-result__link",tabIndex:-1},T("article",{class:"md-search-result__article md-typeset","data-md-score":e.score.toFixed(2)},r>0&&T("div",{class:"md-search-result__icon md-icon"}),r>0&&T("h1",null,e.title),r<=0&&T("h2",null,e.title),o>0&&e.text.length>0&&e.text,e.tags&&e.tags.map(c=>{let p=a?c in a?`md-tag-icon md-tag--${a[c]}`:"md-tag-icon":"";return T("span",{class:`md-tag ${p}`},c)}),o>0&&n.length>0&&T("p",{class:"md-search-result__terms"},be("search.result.term.missing"),": ",...n)))}function fn(e){let t=e[0].score,r=[...e],o=me(),n=r.findIndex(l=>!`${new URL(l.location,o.base)}`.includes("#")),[i]=r.splice(n,1),s=r.findIndex(l=>l.scoreUr(l,1)),...c.length?[T("details",{class:"md-search-result__more"},T("summary",{tabIndex:-1},T("div",null,c.length>0&&c.length===1?be("search.result.more.one"):be("search.result.more.other",c.length))),...c.map(l=>Ur(l,1)))]:[]];return T("li",{class:"md-search-result__item"},p)}function un(e){return T("ul",{class:"md-source__facts"},Object.entries(e).map(([t,r])=>T("li",{class:`md-source__fact md-source__fact--${t}`},typeof r=="number"?tr(r):r)))}function Nr(e){let t=`tabbed-control tabbed-control--${e}`;return T("div",{class:t,hidden:!0},T("button",{class:"tabbed-button",tabIndex:-1,"aria-hidden":"true"}))}function dn(e){return T("div",{class:"md-typeset__scrollwrap"},T("div",{class:"md-typeset__table"},e))}function ba(e){let t=me(),r=new URL(`../${e.version}/`,t.base);return T("li",{class:"md-version__item"},T("a",{href:`${r}`,class:"md-version__link"},e.title))}function hn(e,t){return T("div",{class:"md-version"},T("button",{class:"md-version__current","aria-label":be("select.version")},t.title),T("ul",{class:"md-version__list"},e.map(ba)))}function va(e){return e.tagName==="CODE"?q(".c, .c1, .cm",e):[e]}function ga(e){let t=[];for(let r of va(e)){let o=[],n=document.createNodeIterator(r,NodeFilter.SHOW_TEXT);for(let i=n.nextNode();i;i=n.nextNode())o.push(i);for(let i of o){let s;for(;s=/(\(\d+\))(!)?/.exec(i.textContent);){let[,a,c]=s;if(typeof c=="undefined"){let p=i.splitText(s.index);i=p.splitText(a.length),t.push(p)}else{i.textContent=a,t.push(i);break}}}}return t}function bn(e,t){t.append(...Array.from(e.childNodes))}function sr(e,t,{target$:r,print$:o}){let n=t.closest("[id]"),i=n==null?void 0:n.id,s=new Map;for(let a of ga(t)){let[,c]=a.textContent.match(/\((\d+)\)/);ce(`:scope > li:nth-child(${c})`,e)&&(s.set(c,ln(c,i)),a.replaceWith(s.get(c)))}return s.size===0?L:H(()=>{let a=new x,c=a.pipe(Z(),re(!0)),p=[];for(let[l,f]of s)p.push([W(".md-typeset",f),W(`:scope > li:nth-child(${l})`,e)]);return o.pipe(Y(c)).subscribe(l=>{e.hidden=!l,e.classList.toggle("md-annotation-list",l);for(let[f,u]of p)l?bn(f,u):bn(u,f)}),_(...[...s].map(([,l])=>pn(l,t,{target$:r}))).pipe(A(()=>a.complete()),le())})}function vn(e){if(e.nextElementSibling){let t=e.nextElementSibling;if(t.tagName==="OL")return t;if(t.tagName==="P"&&!t.children.length)return vn(t)}}function gn(e,t){return H(()=>{let r=vn(e);return typeof r!="undefined"?sr(r,e,t):L})}var yn=Ht(Vr());var xa=0;function En(e){if(e.nextElementSibling){let t=e.nextElementSibling;if(t.tagName==="OL")return t;if(t.tagName==="P"&&!t.children.length)return En(t)}}function xn(e){return ye(e).pipe(m(({width:t})=>({scrollable:bt(e).width>t})),ee("scrollable"))}function wn(e,t){let{matches:r}=matchMedia("(hover)"),o=H(()=>{let n=new x;if(n.subscribe(({scrollable:s})=>{s&&r?e.setAttribute("tabindex","0"):e.removeAttribute("tabindex")}),yn.default.isSupported()&&(e.closest(".copy")||te("content.code.copy")&&!e.closest(".no-copy"))){let s=e.closest("pre");s.id=`__code_${xa++}`,s.insertBefore(mn(s.id),e)}let i=e.closest(".highlight");if(i instanceof HTMLElement){let s=En(i);if(typeof s!="undefined"&&(i.classList.contains("annotate")||te("content.code.annotate"))){let a=sr(s,e,t);return xn(e).pipe(w(c=>n.next(c)),A(()=>n.complete()),m(c=>R({ref:e},c)),qe(ye(i).pipe(m(({width:c,height:p})=>c&&p),X(),E(c=>c?a:L))))}}return xn(e).pipe(w(s=>n.next(s)),A(()=>n.complete()),m(s=>R({ref:e},s)))});return te("content.lazy")?rr(e).pipe(M(n=>n),xe(1),E(()=>o)):o}function ya(e,{target$:t,print$:r}){let o=!0;return _(t.pipe(m(n=>n.closest("details:not([open])")),M(n=>e===n),m(()=>({action:"open",reveal:!0}))),r.pipe(M(n=>n||!o),w(()=>o=e.open),m(n=>({action:n?"open":"close"}))))}function Sn(e,t){return H(()=>{let r=new x;return r.subscribe(({action:o,reveal:n})=>{e.toggleAttribute("open",o==="open"),n&&e.scrollIntoView()}),ya(e,t).pipe(w(o=>r.next(o)),A(()=>r.complete()),m(o=>R({ref:e},o)))})}var Tn=".node circle,.node ellipse,.node path,.node polygon,.node rect{fill:var(--md-mermaid-node-bg-color);stroke:var(--md-mermaid-node-fg-color)}marker{fill:var(--md-mermaid-edge-color)!important}.edgeLabel .label rect{fill:#0000}.label{color:var(--md-mermaid-label-fg-color);font-family:var(--md-mermaid-font-family)}.label foreignObject{line-height:normal;overflow:visible}.label div .edgeLabel{color:var(--md-mermaid-label-fg-color)}.edgeLabel,.edgeLabel rect,.label div .edgeLabel{background-color:var(--md-mermaid-label-bg-color)}.edgeLabel,.edgeLabel rect{fill:var(--md-mermaid-label-bg-color);color:var(--md-mermaid-edge-color)}.edgePath .path,.flowchart-link{stroke:var(--md-mermaid-edge-color);stroke-width:.05rem}.edgePath .arrowheadPath{fill:var(--md-mermaid-edge-color);stroke:none}.cluster rect{fill:var(--md-default-fg-color--lightest);stroke:var(--md-default-fg-color--lighter)}.cluster span{color:var(--md-mermaid-label-fg-color);font-family:var(--md-mermaid-font-family)}g #flowchart-circleEnd,g #flowchart-circleStart,g #flowchart-crossEnd,g #flowchart-crossStart,g #flowchart-pointEnd,g #flowchart-pointStart{stroke:none}g.classGroup line,g.classGroup rect{fill:var(--md-mermaid-node-bg-color);stroke:var(--md-mermaid-node-fg-color)}g.classGroup text{fill:var(--md-mermaid-label-fg-color);font-family:var(--md-mermaid-font-family)}.classLabel .box{fill:var(--md-mermaid-label-bg-color);background-color:var(--md-mermaid-label-bg-color);opacity:1}.classLabel .label{fill:var(--md-mermaid-label-fg-color);font-family:var(--md-mermaid-font-family)}.node .divider{stroke:var(--md-mermaid-node-fg-color)}.relation{stroke:var(--md-mermaid-edge-color)}.cardinality{fill:var(--md-mermaid-label-fg-color);font-family:var(--md-mermaid-font-family)}.cardinality text{fill:inherit!important}defs #classDiagram-compositionEnd,defs #classDiagram-compositionStart,defs #classDiagram-dependencyEnd,defs #classDiagram-dependencyStart,defs #classDiagram-extensionEnd,defs #classDiagram-extensionStart{fill:var(--md-mermaid-edge-color)!important;stroke:var(--md-mermaid-edge-color)!important}defs #classDiagram-aggregationEnd,defs #classDiagram-aggregationStart{fill:var(--md-mermaid-label-bg-color)!important;stroke:var(--md-mermaid-edge-color)!important}g.stateGroup rect{fill:var(--md-mermaid-node-bg-color);stroke:var(--md-mermaid-node-fg-color)}g.stateGroup .state-title{fill:var(--md-mermaid-label-fg-color)!important;font-family:var(--md-mermaid-font-family)}g.stateGroup .composit{fill:var(--md-mermaid-label-bg-color)}.nodeLabel{color:var(--md-mermaid-label-fg-color);font-family:var(--md-mermaid-font-family)}.node circle.state-end,.node circle.state-start,.start-state{fill:var(--md-mermaid-edge-color);stroke:none}.end-state-inner,.end-state-outer{fill:var(--md-mermaid-edge-color)}.end-state-inner,.node circle.state-end{stroke:var(--md-mermaid-label-bg-color)}.transition{stroke:var(--md-mermaid-edge-color)}[id^=state-fork] rect,[id^=state-join] rect{fill:var(--md-mermaid-edge-color)!important;stroke:none!important}.statediagram-cluster.statediagram-cluster .inner{fill:var(--md-default-bg-color)}.statediagram-cluster rect{fill:var(--md-mermaid-node-bg-color);stroke:var(--md-mermaid-node-fg-color)}.statediagram-state rect.divider{fill:var(--md-default-fg-color--lightest);stroke:var(--md-default-fg-color--lighter)}defs #statediagram-barbEnd{stroke:var(--md-mermaid-edge-color)}.attributeBoxEven,.attributeBoxOdd{fill:var(--md-mermaid-node-bg-color);stroke:var(--md-mermaid-node-fg-color)}.entityBox{fill:var(--md-mermaid-label-bg-color);stroke:var(--md-mermaid-node-fg-color)}.entityLabel{fill:var(--md-mermaid-label-fg-color);font-family:var(--md-mermaid-font-family)}.relationshipLabelBox{fill:var(--md-mermaid-label-bg-color);fill-opacity:1;background-color:var(--md-mermaid-label-bg-color);opacity:1}.relationshipLabel{fill:var(--md-mermaid-label-fg-color)}.relationshipLine{stroke:var(--md-mermaid-edge-color)}defs #ONE_OR_MORE_END *,defs #ONE_OR_MORE_START *,defs #ONLY_ONE_END *,defs #ONLY_ONE_START *,defs #ZERO_OR_MORE_END *,defs #ZERO_OR_MORE_START *,defs #ZERO_OR_ONE_END *,defs #ZERO_OR_ONE_START *{stroke:var(--md-mermaid-edge-color)!important}defs #ZERO_OR_MORE_END circle,defs #ZERO_OR_MORE_START circle{fill:var(--md-mermaid-label-bg-color)}.actor{fill:var(--md-mermaid-sequence-actor-bg-color);stroke:var(--md-mermaid-sequence-actor-border-color)}text.actor>tspan{fill:var(--md-mermaid-sequence-actor-fg-color);font-family:var(--md-mermaid-font-family)}line{stroke:var(--md-mermaid-sequence-actor-line-color)}.actor-man circle,.actor-man line{fill:var(--md-mermaid-sequence-actorman-bg-color);stroke:var(--md-mermaid-sequence-actorman-line-color)}.messageLine0,.messageLine1{stroke:var(--md-mermaid-sequence-message-line-color)}.note{fill:var(--md-mermaid-sequence-note-bg-color);stroke:var(--md-mermaid-sequence-note-border-color)}.loopText,.loopText>tspan,.messageText,.noteText>tspan{stroke:none;font-family:var(--md-mermaid-font-family)!important}.messageText{fill:var(--md-mermaid-sequence-message-fg-color)}.loopText,.loopText>tspan{fill:var(--md-mermaid-sequence-loop-fg-color)}.noteText>tspan{fill:var(--md-mermaid-sequence-note-fg-color)}#arrowhead path{fill:var(--md-mermaid-sequence-message-line-color);stroke:none}.loopLine{fill:var(--md-mermaid-sequence-loop-bg-color);stroke:var(--md-mermaid-sequence-loop-border-color)}.labelBox{fill:var(--md-mermaid-sequence-label-bg-color);stroke:none}.labelText,.labelText>span{fill:var(--md-mermaid-sequence-label-fg-color);font-family:var(--md-mermaid-font-family)}.sequenceNumber{fill:var(--md-mermaid-sequence-number-fg-color)}rect.rect{fill:var(--md-mermaid-sequence-box-bg-color);stroke:none}rect.rect+text.text{fill:var(--md-mermaid-sequence-box-fg-color)}defs #sequencenumber{fill:var(--md-mermaid-sequence-number-bg-color)!important}";var zr,wa=0;function Sa(){return typeof mermaid=="undefined"||mermaid instanceof Element?ht("https://unpkg.com/mermaid@9.4.3/dist/mermaid.min.js"):j(void 0)}function On(e){return e.classList.remove("mermaid"),zr||(zr=Sa().pipe(w(()=>mermaid.initialize({startOnLoad:!1,themeCSS:Tn,sequence:{actorFontSize:"16px",messageFontSize:"16px",noteFontSize:"16px"}})),m(()=>{}),J(1))),zr.subscribe(()=>{e.classList.add("mermaid");let t=`__mermaid_${wa++}`,r=T("div",{class:"mermaid"}),o=e.textContent;mermaid.mermaidAPI.render(t,o,(n,i)=>{let s=r.attachShadow({mode:"closed"});s.innerHTML=n,e.replaceWith(r),i==null||i(s)})}),zr.pipe(m(()=>({ref:e})))}var Mn=T("table");function Ln(e){return e.replaceWith(Mn),Mn.replaceWith(dn(e)),j({ref:e})}function Ta(e){let t=q(":scope > input",e),r=t.find(o=>o.checked)||t[0];return _(...t.map(o=>h(o,"change").pipe(m(()=>W(`label[for="${o.id}"]`))))).pipe(V(W(`label[for="${r.id}"]`)),m(o=>({active:o})))}function _n(e,{viewport$:t}){let r=Nr("prev");e.append(r);let o=Nr("next");e.append(o);let n=W(".tabbed-labels",e);return H(()=>{let i=new x,s=i.pipe(Z(),re(!0));return B([i,ye(e)]).pipe(Ce(1,Oe),Y(s)).subscribe({next([{active:a},c]){let p=Je(a),{width:l}=he(a);e.style.setProperty("--md-indicator-x",`${p.x}px`),e.style.setProperty("--md-indicator-width",`${l}px`);let f=er(n);(p.xf.x+c.width)&&n.scrollTo({left:Math.max(0,p.x-16),behavior:"smooth"})},complete(){e.style.removeProperty("--md-indicator-x"),e.style.removeProperty("--md-indicator-width")}}),B([dt(n),ye(n)]).pipe(Y(s)).subscribe(([a,c])=>{let p=bt(n);r.hidden=a.x<16,o.hidden=a.x>p.width-c.width-16}),_(h(r,"click").pipe(m(()=>-1)),h(o,"click").pipe(m(()=>1))).pipe(Y(s)).subscribe(a=>{let{width:c}=he(n);n.scrollBy({left:c*a,behavior:"smooth"})}),te("content.tabs.link")&&i.pipe(je(1),ne(t)).subscribe(([{active:a},{offset:c}])=>{let p=a.innerText.trim();if(a.hasAttribute("data-md-switching"))a.removeAttribute("data-md-switching");else{let l=e.offsetTop-c.y;for(let u of q("[data-tabs]"))for(let d of q(":scope > input",u)){let v=W(`label[for="${d.id}"]`);if(v!==a&&v.innerText.trim()===p){v.setAttribute("data-md-switching",""),d.click();break}}window.scrollTo({top:e.offsetTop-l});let f=__md_get("__tabs")||[];__md_set("__tabs",[...new Set([p,...f])])}}),i.pipe(Y(s)).subscribe(()=>{for(let a of q("audio, video",e))a.pause()}),Ta(e).pipe(w(a=>i.next(a)),A(()=>i.complete()),m(a=>R({ref:e},a)))}).pipe(rt(ae))}function An(e,{viewport$:t,target$:r,print$:o}){return _(...q(".annotate:not(.highlight)",e).map(n=>gn(n,{target$:r,print$:o})),...q("pre:not(.mermaid) > code",e).map(n=>wn(n,{target$:r,print$:o})),...q("pre.mermaid",e).map(n=>On(n)),...q("table:not([class])",e).map(n=>Ln(n)),...q("details",e).map(n=>Sn(n,{target$:r,print$:o})),...q("[data-tabs]",e).map(n=>_n(n,{viewport$:t})))}function Oa(e,{alert$:t}){return t.pipe(E(r=>_(j(!0),j(!1).pipe(ze(2e3))).pipe(m(o=>({message:r,active:o})))))}function Cn(e,t){let r=W(".md-typeset",e);return H(()=>{let o=new x;return o.subscribe(({message:n,active:i})=>{e.classList.toggle("md-dialog--active",i),r.textContent=n}),Oa(e,t).pipe(w(n=>o.next(n)),A(()=>o.complete()),m(n=>R({ref:e},n)))})}function Ma({viewport$:e}){if(!te("header.autohide"))return j(!1);let t=e.pipe(m(({offset:{y:n}})=>n),Le(2,1),m(([n,i])=>[nMath.abs(i-n.y)>100),m(([,[n]])=>n),X()),o=We("search");return B([e,o]).pipe(m(([{offset:n},i])=>n.y>400&&!i),X(),E(n=>n?r:j(!1)),V(!1))}function kn(e,t){return H(()=>B([ye(e),Ma(t)])).pipe(m(([{height:r},o])=>({height:r,hidden:o})),X((r,o)=>r.height===o.height&&r.hidden===o.hidden),J(1))}function Hn(e,{header$:t,main$:r}){return H(()=>{let o=new x,n=o.pipe(Z(),re(!0));return o.pipe(ee("active"),Ge(t)).subscribe(([{active:i},{hidden:s}])=>{e.classList.toggle("md-header--shadow",i&&!s),e.hidden=s}),r.subscribe(o),t.pipe(Y(n),m(i=>R({ref:e},i)))})}function La(e,{viewport$:t,header$:r}){return ar(e,{viewport$:t,header$:r}).pipe(m(({offset:{y:o}})=>{let{height:n}=he(e);return{active:o>=n}}),ee("active"))}function $n(e,t){return H(()=>{let r=new x;r.subscribe({next({active:n}){e.classList.toggle("md-header__title--active",n)},complete(){e.classList.remove("md-header__title--active")}});let o=ce(".md-content h1");return typeof o=="undefined"?L:La(o,t).pipe(w(n=>r.next(n)),A(()=>r.complete()),m(n=>R({ref:e},n)))})}function Rn(e,{viewport$:t,header$:r}){let o=r.pipe(m(({height:i})=>i),X()),n=o.pipe(E(()=>ye(e).pipe(m(({height:i})=>({top:e.offsetTop,bottom:e.offsetTop+i})),ee("bottom"))));return B([o,n,t]).pipe(m(([i,{top:s,bottom:a},{offset:{y:c},size:{height:p}}])=>(p=Math.max(0,p-Math.max(0,s-c,i)-Math.max(0,p+c-a)),{offset:s-i,height:p,active:s-i<=c})),X((i,s)=>i.offset===s.offset&&i.height===s.height&&i.active===s.active))}function _a(e){let t=__md_get("__palette")||{index:e.findIndex(r=>matchMedia(r.getAttribute("data-md-color-media")).matches)};return j(...e).pipe(se(r=>h(r,"change").pipe(m(()=>r))),V(e[Math.max(0,t.index)]),m(r=>({index:e.indexOf(r),color:{scheme:r.getAttribute("data-md-color-scheme"),primary:r.getAttribute("data-md-color-primary"),accent:r.getAttribute("data-md-color-accent")}})),J(1))}function Pn(e){let t=T("meta",{name:"theme-color"});document.head.appendChild(t);let r=T("meta",{name:"color-scheme"});return document.head.appendChild(r),H(()=>{let o=new x;o.subscribe(i=>{document.body.setAttribute("data-md-color-switching","");for(let[s,a]of Object.entries(i.color))document.body.setAttribute(`data-md-color-${s}`,a);for(let s=0;s{let i=Ee("header"),s=window.getComputedStyle(i);return r.content=s.colorScheme,s.backgroundColor.match(/\d+/g).map(a=>(+a).toString(16).padStart(2,"0")).join("")})).subscribe(i=>t.content=`#${i}`),o.pipe(Se(ae)).subscribe(()=>{document.body.removeAttribute("data-md-color-switching")});let n=q("input",e);return _a(n).pipe(w(i=>o.next(i)),A(()=>o.complete()),m(i=>R({ref:e},i)))})}function In(e,{progress$:t}){return H(()=>{let r=new x;return r.subscribe(({value:o})=>{e.style.setProperty("--md-progress-value",`${o}`)}),t.pipe(w(o=>r.next({value:o})),A(()=>r.complete()),m(o=>({ref:e,value:o})))})}var qr=Ht(Vr());function Aa(e){e.setAttribute("data-md-copying","");let t=e.closest("[data-copy]"),r=t?t.getAttribute("data-copy"):e.innerText;return e.removeAttribute("data-md-copying"),r}function Fn({alert$:e}){qr.default.isSupported()&&new P(t=>{new qr.default("[data-clipboard-target], [data-clipboard-text]",{text:r=>r.getAttribute("data-clipboard-text")||Aa(W(r.getAttribute("data-clipboard-target")))}).on("success",r=>t.next(r))}).pipe(w(t=>{t.trigger.focus()}),m(()=>be("clipboard.copied"))).subscribe(e)}function Ca(e){if(e.length<2)return[""];let[t,r]=[...e].sort((n,i)=>n.length-i.length).map(n=>n.replace(/[^/]+$/,"")),o=0;if(t===r)o=t.length;else for(;t.charCodeAt(o)===r.charCodeAt(o);)o++;return e.map(n=>n.replace(t.slice(0,o),""))}function cr(e){let t=__md_get("__sitemap",sessionStorage,e);if(t)return j(t);{let r=me();return Zo(new URL("sitemap.xml",e||r.base)).pipe(m(o=>Ca(q("loc",o).map(n=>n.textContent))),de(()=>L),He([]),w(o=>__md_set("__sitemap",o,sessionStorage,e)))}}function jn(e){let t=W("[rel=canonical]",e);t.href=t.href.replace("//localhost:","//127.0.0.1");let r=new Map;for(let o of q(":scope > *",e)){let n=o.outerHTML;for(let i of["href","src"]){let s=o.getAttribute(i);if(s===null)continue;let a=new URL(s,t.href),c=o.cloneNode();c.setAttribute(i,`${a}`),n=c.outerHTML;break}r.set(n,o)}return r}function Wn({location$:e,viewport$:t,progress$:r}){let o=me();if(location.protocol==="file:")return L;let n=cr().pipe(m(l=>l.map(f=>`${new URL(f,o.base)}`))),i=h(document.body,"click").pipe(ne(n),E(([l,f])=>{if(!(l.target instanceof Element))return L;let u=l.target.closest("a");if(u===null)return L;if(u.target||l.metaKey||l.ctrlKey)return L;let d=new URL(u.href);return d.search=d.hash="",f.includes(`${d}`)?(l.preventDefault(),j(new URL(u.href))):L}),le());i.pipe(xe(1)).subscribe(()=>{let l=ce("link[rel=icon]");typeof l!="undefined"&&(l.href=l.href)}),h(window,"beforeunload").subscribe(()=>{history.scrollRestoration="auto"}),i.pipe(ne(t)).subscribe(([l,{offset:f}])=>{history.scrollRestoration="manual",history.replaceState(f,""),history.pushState(null,"",l)}),i.subscribe(e);let s=e.pipe(V(pe()),ee("pathname"),je(1),E(l=>ir(l,{progress$:r}).pipe(de(()=>(ot(l,!0),L))))),a=new DOMParser,c=s.pipe(E(l=>l.text()),E(l=>{let f=a.parseFromString(l,"text/html");for(let b of["[data-md-component=announce]","[data-md-component=container]","[data-md-component=header-topic]","[data-md-component=outdated]","[data-md-component=logo]","[data-md-component=skip]",...te("navigation.tabs.sticky")?["[data-md-component=tabs]"]:[]]){let z=ce(b),K=ce(b,f);typeof z!="undefined"&&typeof K!="undefined"&&z.replaceWith(K)}let u=jn(document.head),d=jn(f.head);for(let[b,z]of d)z.getAttribute("rel")==="stylesheet"||z.hasAttribute("src")||(u.has(b)?u.delete(b):document.head.appendChild(z));for(let b of u.values())b.getAttribute("rel")==="stylesheet"||b.hasAttribute("src")||b.remove();let v=Ee("container");return Fe(q("script",v)).pipe(E(b=>{let z=f.createElement("script");if(b.src){for(let K of b.getAttributeNames())z.setAttribute(K,b.getAttribute(K));return b.replaceWith(z),new P(K=>{z.onload=()=>K.complete()})}else return z.textContent=b.textContent,b.replaceWith(z),L}),Z(),re(f))}),le());return h(window,"popstate").pipe(m(pe)).subscribe(e),e.pipe(V(pe()),Le(2,1),M(([l,f])=>l.pathname===f.pathname&&l.hash!==f.hash),m(([,l])=>l)).subscribe(l=>{var f,u;history.state!==null||!l.hash?window.scrollTo(0,(u=(f=history.state)==null?void 0:f.y)!=null?u:0):(history.scrollRestoration="auto",nr(l.hash),history.scrollRestoration="manual")}),e.pipe(Cr(i),V(pe()),Le(2,1),M(([l,f])=>l.pathname===f.pathname&&l.hash===f.hash),m(([,l])=>l)).subscribe(l=>{history.scrollRestoration="auto",nr(l.hash),history.scrollRestoration="manual",history.back()}),c.pipe(ne(e)).subscribe(([,l])=>{var f,u;history.state!==null||!l.hash?window.scrollTo(0,(u=(f=history.state)==null?void 0:f.y)!=null?u:0):nr(l.hash)}),t.pipe(ee("offset"),ke(100)).subscribe(({offset:l})=>{history.replaceState(l,"")}),c}var Dn=Ht(Nn());function Vn(e){let t=e.separator.split("|").map(n=>n.replace(/(\(\?[!=<][^)]+\))/g,"").length===0?"\uFFFD":n).join("|"),r=new RegExp(t,"img"),o=(n,i,s)=>`${i}${s}`;return n=>{n=n.replace(/[\s*+\-:~^]+/g," ").trim();let i=new RegExp(`(^|${e.separator}|)(${n.replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&").replace(r,"|")})`,"img");return s=>(0,Dn.default)(s).replace(i,o).replace(/<\/mark>(\s+)]*>/img,"$1")}}function Mt(e){return e.type===1}function pr(e){return e.type===3}function zn(e,t){let r=an(e);return _(j(location.protocol!=="file:"),We("search")).pipe($e(o=>o),E(()=>t)).subscribe(({config:o,docs:n})=>r.next({type:0,data:{config:o,docs:n,options:{suggest:te("search.suggest")}}})),r}function qn({document$:e}){let t=me(),r=Ue(new URL("../versions.json",t.base)).pipe(de(()=>L)),o=r.pipe(m(n=>{let[,i]=t.base.match(/([^/]+)\/?$/);return n.find(({version:s,aliases:a})=>s===i||a.includes(i))||n[0]}));r.pipe(m(n=>new Map(n.map(i=>[`${new URL(`../${i.version}/`,t.base)}`,i]))),E(n=>h(document.body,"click").pipe(M(i=>!i.metaKey&&!i.ctrlKey),ne(o),E(([i,s])=>{if(i.target instanceof Element){let a=i.target.closest("a");if(a&&!a.target&&n.has(a.href)){let c=a.href;return!i.target.closest(".md-version")&&n.get(c)===s?L:(i.preventDefault(),j(c))}}return L}),E(i=>{let{version:s}=n.get(i);return cr(new URL(i)).pipe(m(a=>{let p=pe().href.replace(t.base,"");return a.includes(p.split("#")[0])?new URL(`../${s}/${p}`,t.base):new URL(i)}))})))).subscribe(n=>ot(n,!0)),B([r,o]).subscribe(([n,i])=>{W(".md-header__topic").appendChild(hn(n,i))}),e.pipe(E(()=>o)).subscribe(n=>{var s;let i=__md_get("__outdated",sessionStorage);if(i===null){i=!0;let a=((s=t.version)==null?void 0:s.default)||"latest";Array.isArray(a)||(a=[a]);e:for(let c of a)for(let p of n.aliases)if(new RegExp(c,"i").test(p)){i=!1;break e}__md_set("__outdated",i,sessionStorage)}if(i)for(let a of oe("outdated"))a.hidden=!1})}function Pa(e,{worker$:t}){let{searchParams:r}=pe();r.has("q")&&(Ke("search",!0),e.value=r.get("q"),e.focus(),We("search").pipe($e(i=>!i)).subscribe(()=>{let i=pe();i.searchParams.delete("q"),history.replaceState({},"",`${i}`)}));let o=Zt(e),n=_(t.pipe($e(Mt)),h(e,"keyup"),o).pipe(m(()=>e.value),X());return B([n,o]).pipe(m(([i,s])=>({value:i,focus:s})),J(1))}function Kn(e,{worker$:t}){let r=new x,o=r.pipe(Z(),re(!0));B([t.pipe($e(Mt)),r],(i,s)=>s).pipe(ee("value")).subscribe(({value:i})=>t.next({type:2,data:i})),r.pipe(ee("focus")).subscribe(({focus:i})=>{i&&Ke("search",i)}),h(e.form,"reset").pipe(Y(o)).subscribe(()=>e.focus());let n=W("header [for=__search]");return h(n,"click").subscribe(()=>e.focus()),Pa(e,{worker$:t}).pipe(w(i=>r.next(i)),A(()=>r.complete()),m(i=>R({ref:e},i)),J(1))}function Qn(e,{worker$:t,query$:r}){let o=new x,n=Ko(e.parentElement).pipe(M(Boolean)),i=e.parentElement,s=W(":scope > :first-child",e),a=W(":scope > :last-child",e);We("search").subscribe(l=>a.setAttribute("role",l?"list":"presentation")),o.pipe(ne(r),$r(t.pipe($e(Mt)))).subscribe(([{items:l},{value:f}])=>{switch(l.length){case 0:s.textContent=f.length?be("search.result.none"):be("search.result.placeholder");break;case 1:s.textContent=be("search.result.one");break;default:let u=tr(l.length);s.textContent=be("search.result.other",u)}});let c=o.pipe(w(()=>a.innerHTML=""),E(({items:l})=>_(j(...l.slice(0,10)),j(...l.slice(10)).pipe(Le(4),Ir(n),E(([f])=>f)))),m(fn),le());return c.subscribe(l=>a.appendChild(l)),c.pipe(se(l=>{let f=ce("details",l);return typeof f=="undefined"?L:h(f,"toggle").pipe(Y(o),m(()=>f))})).subscribe(l=>{l.open===!1&&l.offsetTop<=i.scrollTop&&i.scrollTo({top:l.offsetTop})}),t.pipe(M(pr),m(({data:l})=>l)).pipe(w(l=>o.next(l)),A(()=>o.complete()),m(l=>R({ref:e},l)))}function Ia(e,{query$:t}){return t.pipe(m(({value:r})=>{let o=pe();return o.hash="",r=r.replace(/\s+/g,"+").replace(/&/g,"%26").replace(/=/g,"%3D"),o.search=`q=${r}`,{url:o}}))}function Yn(e,t){let r=new x,o=r.pipe(Z(),re(!0));return r.subscribe(({url:n})=>{e.setAttribute("data-clipboard-text",e.href),e.href=`${n}`}),h(e,"click").pipe(Y(o)).subscribe(n=>n.preventDefault()),Ia(e,t).pipe(w(n=>r.next(n)),A(()=>r.complete()),m(n=>R({ref:e},n)))}function Bn(e,{worker$:t,keyboard$:r}){let o=new x,n=Ee("search-query"),i=_(h(n,"keydown"),h(n,"focus")).pipe(Se(ae),m(()=>n.value),X());return o.pipe(Ge(i),m(([{suggest:a},c])=>{let p=c.split(/([\s-]+)/);if(a!=null&&a.length&&p[p.length-1]){let l=a[a.length-1];l.startsWith(p[p.length-1])&&(p[p.length-1]=l)}else p.length=0;return p})).subscribe(a=>e.innerHTML=a.join("").replace(/\s/g," ")),r.pipe(M(({mode:a})=>a==="search")).subscribe(a=>{switch(a.type){case"ArrowRight":e.innerText.length&&n.selectionStart===n.value.length&&(n.value=e.innerText);break}}),t.pipe(M(pr),m(({data:a})=>a)).pipe(w(a=>o.next(a)),A(()=>o.complete()),m(()=>({ref:e})))}function Gn(e,{index$:t,keyboard$:r}){let o=me();try{let n=zn(o.search,t),i=Ee("search-query",e),s=Ee("search-result",e);h(e,"click").pipe(M(({target:c})=>c instanceof Element&&!!c.closest("a"))).subscribe(()=>Ke("search",!1)),r.pipe(M(({mode:c})=>c==="search")).subscribe(c=>{let p=Re();switch(c.type){case"Enter":if(p===i){let l=new Map;for(let f of q(":first-child [href]",s)){let u=f.firstElementChild;l.set(f,parseFloat(u.getAttribute("data-md-score")))}if(l.size){let[[f]]=[...l].sort(([,u],[,d])=>d-u);f.click()}c.claim()}break;case"Escape":case"Tab":Ke("search",!1),i.blur();break;case"ArrowUp":case"ArrowDown":if(typeof p=="undefined")i.focus();else{let l=[i,...q(":not(details) > [href], summary, details[open] [href]",s)],f=Math.max(0,(Math.max(0,l.indexOf(p))+l.length+(c.type==="ArrowUp"?-1:1))%l.length);l[f].focus()}c.claim();break;default:i!==Re()&&i.focus()}}),r.pipe(M(({mode:c})=>c==="global")).subscribe(c=>{switch(c.type){case"f":case"s":case"/":i.focus(),i.select(),c.claim();break}});let a=Kn(i,{worker$:n});return _(a,Qn(s,{worker$:n,query$:a})).pipe(qe(...oe("search-share",e).map(c=>Yn(c,{query$:a})),...oe("search-suggest",e).map(c=>Bn(c,{worker$:n,keyboard$:r}))))}catch(n){return e.hidden=!0,Ve}}function Jn(e,{index$:t,location$:r}){return B([t,r.pipe(V(pe()),M(o=>!!o.searchParams.get("h")))]).pipe(m(([o,n])=>Vn(o.config)(n.searchParams.get("h"))),m(o=>{var s;let n=new Map,i=document.createNodeIterator(e,NodeFilter.SHOW_TEXT);for(let a=i.nextNode();a;a=i.nextNode())if((s=a.parentElement)!=null&&s.offsetHeight){let c=a.textContent,p=o(c);p.length>c.length&&n.set(a,p)}for(let[a,c]of n){let{childNodes:p}=T("span",null,c);a.replaceWith(...Array.from(p))}return{ref:e,nodes:n}}))}function Fa(e,{viewport$:t,main$:r}){let o=e.closest(".md-grid"),n=o.offsetTop-o.parentElement.offsetTop;return B([r,t]).pipe(m(([{offset:i,height:s},{offset:{y:a}}])=>(s=s+Math.min(n,Math.max(0,a-i))-n,{height:s,locked:a>=i+n})),X((i,s)=>i.height===s.height&&i.locked===s.locked))}function Kr(e,o){var n=o,{header$:t}=n,r=eo(n,["header$"]);let i=W(".md-sidebar__scrollwrap",e),{y:s}=Je(i);return H(()=>{let a=new x,c=a.pipe(Z(),re(!0)),p=a.pipe(Ce(0,Oe));return p.pipe(ne(t)).subscribe({next([{height:l},{height:f}]){i.style.height=`${l-2*s}px`,e.style.top=`${f}px`},complete(){i.style.height="",e.style.top=""}}),p.pipe($e()).subscribe(()=>{for(let l of q(".md-nav__link--active[href]",e)){if(!l.clientHeight)continue;let f=l.closest(".md-sidebar__scrollwrap");if(typeof f!="undefined"){let u=l.offsetTop-f.offsetTop,{height:d}=he(f);f.scrollTo({top:u-d/2})}}}),ge(q("label[tabindex]",e)).pipe(se(l=>h(l,"click").pipe(Se(ae),m(()=>l),Y(c)))).subscribe(l=>{let f=W(`[id="${l.htmlFor}"]`);W(`[aria-labelledby="${l.id}"]`).setAttribute("aria-expanded",`${f.checked}`)}),Fa(e,r).pipe(w(l=>a.next(l)),A(()=>a.complete()),m(l=>R({ref:e},l)))})}function Xn(e,t){if(typeof t!="undefined"){let r=`https://api.github.com/repos/${e}/${t}`;return St(Ue(`${r}/releases/latest`).pipe(de(()=>L),m(o=>({version:o.tag_name})),He({})),Ue(r).pipe(de(()=>L),m(o=>({stars:o.stargazers_count,forks:o.forks_count})),He({}))).pipe(m(([o,n])=>R(R({},o),n)))}else{let r=`https://api.github.com/users/${e}`;return Ue(r).pipe(m(o=>({repositories:o.public_repos})),He({}))}}function Zn(e,t){let r=`https://${e}/api/v4/projects/${encodeURIComponent(t)}`;return Ue(r).pipe(de(()=>L),m(({star_count:o,forks_count:n})=>({stars:o,forks:n})),He({}))}function ei(e){let t=e.match(/^.+github\.com\/([^/]+)\/?([^/]+)?/i);if(t){let[,r,o]=t;return Xn(r,o)}if(t=e.match(/^.+?([^/]*gitlab[^/]+)\/(.+?)\/?$/i),t){let[,r,o]=t;return Zn(r,o)}return L}var ja;function Wa(e){return ja||(ja=H(()=>{let t=__md_get("__source",sessionStorage);if(t)return j(t);if(oe("consent").length){let o=__md_get("__consent");if(!(o&&o.github))return L}return ei(e.href).pipe(w(o=>__md_set("__source",o,sessionStorage)))}).pipe(de(()=>L),M(t=>Object.keys(t).length>0),m(t=>({facts:t})),J(1)))}function ti(e){let t=W(":scope > :last-child",e);return H(()=>{let r=new x;return r.subscribe(({facts:o})=>{t.appendChild(un(o)),t.classList.add("md-source__repository--active")}),Wa(e).pipe(w(o=>r.next(o)),A(()=>r.complete()),m(o=>R({ref:e},o)))})}function Ua(e,{viewport$:t,header$:r}){return ye(document.body).pipe(E(()=>ar(e,{header$:r,viewport$:t})),m(({offset:{y:o}})=>({hidden:o>=10})),ee("hidden"))}function ri(e,t){return H(()=>{let r=new x;return r.subscribe({next({hidden:o}){e.hidden=o},complete(){e.hidden=!1}}),(te("navigation.tabs.sticky")?j({hidden:!1}):Ua(e,t)).pipe(w(o=>r.next(o)),A(()=>r.complete()),m(o=>R({ref:e},o)))})}function Na(e,{viewport$:t,header$:r}){let o=new Map,n=q("[href^=\\#]",e);for(let a of n){let c=decodeURIComponent(a.hash.substring(1)),p=ce(`[id="${c}"]`);typeof p!="undefined"&&o.set(a,p)}let i=r.pipe(ee("height"),m(({height:a})=>{let c=Ee("main"),p=W(":scope > :first-child",c);return a+.8*(p.offsetTop-c.offsetTop)}),le());return ye(document.body).pipe(ee("height"),E(a=>H(()=>{let c=[];return j([...o].reduce((p,[l,f])=>{for(;c.length&&o.get(c[c.length-1]).tagName>=f.tagName;)c.pop();let u=f.offsetTop;for(;!u&&f.parentElement;)f=f.parentElement,u=f.offsetTop;let d=f.offsetParent;for(;d;d=d.offsetParent)u+=d.offsetTop;return p.set([...c=[...c,l]].reverse(),u)},new Map))}).pipe(m(c=>new Map([...c].sort(([,p],[,l])=>p-l))),Ge(i),E(([c,p])=>t.pipe(kr(([l,f],{offset:{y:u},size:d})=>{let v=u+d.height>=Math.floor(a.height);for(;f.length;){let[,b]=f[0];if(b-p=u&&!v)f=[l.pop(),...f];else break}return[l,f]},[[],[...c]]),X((l,f)=>l[0]===f[0]&&l[1]===f[1])))))).pipe(m(([a,c])=>({prev:a.map(([p])=>p),next:c.map(([p])=>p)})),V({prev:[],next:[]}),Le(2,1),m(([a,c])=>a.prev.length{let i=new x,s=i.pipe(Z(),re(!0));if(i.subscribe(({prev:a,next:c})=>{for(let[p]of c)p.classList.remove("md-nav__link--passed"),p.classList.remove("md-nav__link--active");for(let[p,[l]]of a.entries())l.classList.add("md-nav__link--passed"),l.classList.toggle("md-nav__link--active",p===a.length-1)}),te("toc.follow")){let a=_(t.pipe(ke(1),m(()=>{})),t.pipe(ke(250),m(()=>"smooth")));i.pipe(M(({prev:c})=>c.length>0),Ge(o.pipe(Se(ae))),ne(a)).subscribe(([[{prev:c}],p])=>{let[l]=c[c.length-1];if(l.offsetHeight){let f=zo(l);if(typeof f!="undefined"){let u=l.offsetTop-f.offsetTop,{height:d}=he(f);f.scrollTo({top:u-d/2,behavior:p})}}})}return te("navigation.tracking")&&t.pipe(Y(s),ee("offset"),ke(250),je(1),Y(n.pipe(je(1))),Tt({delay:250}),ne(i)).subscribe(([,{prev:a}])=>{let c=pe(),p=a[a.length-1];if(p&&p.length){let[l]=p,{hash:f}=new URL(l.href);c.hash!==f&&(c.hash=f,history.replaceState({},"",`${c}`))}else c.hash="",history.replaceState({},"",`${c}`)}),Na(e,{viewport$:t,header$:r}).pipe(w(a=>i.next(a)),A(()=>i.complete()),m(a=>R({ref:e},a)))})}function Da(e,{viewport$:t,main$:r,target$:o}){let n=t.pipe(m(({offset:{y:s}})=>s),Le(2,1),m(([s,a])=>s>a&&a>0),X()),i=r.pipe(m(({active:s})=>s));return B([i,n]).pipe(m(([s,a])=>!(s&&a)),X(),Y(o.pipe(je(1))),re(!0),Tt({delay:250}),m(s=>({hidden:s})))}function ni(e,{viewport$:t,header$:r,main$:o,target$:n}){let i=new x,s=i.pipe(Z(),re(!0));return i.subscribe({next({hidden:a}){e.hidden=a,a?(e.setAttribute("tabindex","-1"),e.blur()):e.removeAttribute("tabindex")},complete(){e.style.top="",e.hidden=!0,e.removeAttribute("tabindex")}}),r.pipe(Y(s),ee("height")).subscribe(({height:a})=>{e.style.top=`${a+16}px`}),h(e,"click").subscribe(a=>{a.preventDefault(),window.scrollTo({top:0})}),Da(e,{viewport$:t,main$:o,target$:n}).pipe(w(a=>i.next(a)),A(()=>i.complete()),m(a=>R({ref:e},a)))}function ii({document$:e,tablet$:t}){e.pipe(E(()=>q(".md-toggle--indeterminate")),w(r=>{r.indeterminate=!0,r.checked=!1}),se(r=>h(r,"change").pipe(Rr(()=>r.classList.contains("md-toggle--indeterminate")),m(()=>r))),ne(t)).subscribe(([r,o])=>{r.classList.remove("md-toggle--indeterminate"),o&&(r.checked=!1)})}function Va(){return/(iPad|iPhone|iPod)/.test(navigator.userAgent)}function ai({document$:e}){e.pipe(E(()=>q("[data-md-scrollfix]")),w(t=>t.removeAttribute("data-md-scrollfix")),M(Va),se(t=>h(t,"touchstart").pipe(m(()=>t)))).subscribe(t=>{let r=t.scrollTop;r===0?t.scrollTop=1:r+t.offsetHeight===t.scrollHeight&&(t.scrollTop=r-1)})}function si({viewport$:e,tablet$:t}){B([We("search"),t]).pipe(m(([r,o])=>r&&!o),E(r=>j(r).pipe(ze(r?400:100))),ne(e)).subscribe(([r,{offset:{y:o}}])=>{if(r)document.body.setAttribute("data-md-scrolllock",""),document.body.style.top=`-${o}px`;else{let n=-1*parseInt(document.body.style.top,10);document.body.removeAttribute("data-md-scrolllock"),document.body.style.top="",n&&window.scrollTo(0,n)}})}Object.entries||(Object.entries=function(e){let t=[];for(let r of Object.keys(e))t.push([r,e[r]]);return t});Object.values||(Object.values=function(e){let t=[];for(let r of Object.keys(e))t.push(e[r]);return t});typeof Element!="undefined"&&(Element.prototype.scrollTo||(Element.prototype.scrollTo=function(e,t){typeof e=="object"?(this.scrollLeft=e.left,this.scrollTop=e.top):(this.scrollLeft=e,this.scrollTop=t)}),Element.prototype.replaceWith||(Element.prototype.replaceWith=function(...e){let t=this.parentNode;if(t){e.length===0&&t.removeChild(this);for(let r=e.length-1;r>=0;r--){let o=e[r];typeof o=="string"?o=document.createTextNode(o):o.parentNode&&o.parentNode.removeChild(o),r?t.insertBefore(this.previousSibling,o):t.replaceChild(o,this)}}}));function za(){return location.protocol==="file:"?ht(`${new URL("search/search_index.js",Qr.base)}`).pipe(m(()=>__index),J(1)):Ue(new URL("search/search_index.json",Qr.base))}document.documentElement.classList.remove("no-js");document.documentElement.classList.add("js");var nt=Uo(),_t=Bo(),gt=Jo(_t),Yr=Yo(),Te=nn(),lr=Fr("(min-width: 960px)"),pi=Fr("(min-width: 1220px)"),li=Xo(),Qr=me(),mi=document.forms.namedItem("search")?za():Ve,Br=new x;Fn({alert$:Br});var Gr=new x;te("navigation.instant")&&Wn({location$:_t,viewport$:Te,progress$:Gr}).subscribe(nt);var ci;((ci=Qr.version)==null?void 0:ci.provider)==="mike"&&qn({document$:nt});_(_t,gt).pipe(ze(125)).subscribe(()=>{Ke("drawer",!1),Ke("search",!1)});Yr.pipe(M(({mode:e})=>e==="global")).subscribe(e=>{switch(e.type){case"p":case",":let t=ce("link[rel=prev]");typeof t!="undefined"&&ot(t);break;case"n":case".":let r=ce("link[rel=next]");typeof r!="undefined"&&ot(r);break;case"Enter":let o=Re();o instanceof HTMLLabelElement&&o.click()}});ii({document$:nt,tablet$:lr});ai({document$:nt});si({viewport$:Te,tablet$:lr});var Xe=kn(Ee("header"),{viewport$:Te}),Lt=nt.pipe(m(()=>Ee("main")),E(e=>Rn(e,{viewport$:Te,header$:Xe})),J(1)),qa=_(...oe("consent").map(e=>cn(e,{target$:gt})),...oe("dialog").map(e=>Cn(e,{alert$:Br})),...oe("header").map(e=>Hn(e,{viewport$:Te,header$:Xe,main$:Lt})),...oe("palette").map(e=>Pn(e)),...oe("progress").map(e=>In(e,{progress$:Gr})),...oe("search").map(e=>Gn(e,{index$:mi,keyboard$:Yr})),...oe("source").map(e=>ti(e))),Ka=H(()=>_(...oe("announce").map(e=>sn(e)),...oe("content").map(e=>An(e,{viewport$:Te,target$:gt,print$:li})),...oe("content").map(e=>te("search.highlight")?Jn(e,{index$:mi,location$:_t}):L),...oe("header-title").map(e=>$n(e,{viewport$:Te,header$:Xe})),...oe("sidebar").map(e=>e.getAttribute("data-md-type")==="navigation"?jr(pi,()=>Kr(e,{viewport$:Te,header$:Xe,main$:Lt})):jr(lr,()=>Kr(e,{viewport$:Te,header$:Xe,main$:Lt}))),...oe("tabs").map(e=>ri(e,{viewport$:Te,header$:Xe})),...oe("toc").map(e=>oi(e,{viewport$:Te,header$:Xe,main$:Lt,target$:gt})),...oe("top").map(e=>ni(e,{viewport$:Te,header$:Xe,main$:Lt,target$:gt})))),fi=nt.pipe(E(()=>Ka),qe(qa),J(1));fi.subscribe();window.document$=nt;window.location$=_t;window.target$=gt;window.keyboard$=Yr;window.viewport$=Te;window.tablet$=lr;window.screen$=pi;window.print$=li;window.alert$=Br;window.progress$=Gr;window.component$=fi;})(); +//# sourceMappingURL=bundle.aecac24b.min.js.map + diff --git a/assets/javascripts/bundle.aecac24b.min.js.map b/assets/javascripts/bundle.aecac24b.min.js.map new file mode 100644 index 000000000..b1534de53 --- /dev/null +++ b/assets/javascripts/bundle.aecac24b.min.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["node_modules/focus-visible/dist/focus-visible.js", "node_modules/clipboard/dist/clipboard.js", "node_modules/escape-html/index.js", "src/templates/assets/javascripts/bundle.ts", "node_modules/rxjs/node_modules/tslib/tslib.es6.js", "node_modules/rxjs/src/internal/util/isFunction.ts", "node_modules/rxjs/src/internal/util/createErrorClass.ts", "node_modules/rxjs/src/internal/util/UnsubscriptionError.ts", "node_modules/rxjs/src/internal/util/arrRemove.ts", "node_modules/rxjs/src/internal/Subscription.ts", "node_modules/rxjs/src/internal/config.ts", "node_modules/rxjs/src/internal/scheduler/timeoutProvider.ts", "node_modules/rxjs/src/internal/util/reportUnhandledError.ts", "node_modules/rxjs/src/internal/util/noop.ts", "node_modules/rxjs/src/internal/NotificationFactories.ts", "node_modules/rxjs/src/internal/util/errorContext.ts", "node_modules/rxjs/src/internal/Subscriber.ts", "node_modules/rxjs/src/internal/symbol/observable.ts", "node_modules/rxjs/src/internal/util/identity.ts", "node_modules/rxjs/src/internal/util/pipe.ts", "node_modules/rxjs/src/internal/Observable.ts", "node_modules/rxjs/src/internal/util/lift.ts", "node_modules/rxjs/src/internal/operators/OperatorSubscriber.ts", "node_modules/rxjs/src/internal/scheduler/animationFrameProvider.ts", "node_modules/rxjs/src/internal/util/ObjectUnsubscribedError.ts", "node_modules/rxjs/src/internal/Subject.ts", "node_modules/rxjs/src/internal/scheduler/dateTimestampProvider.ts", "node_modules/rxjs/src/internal/ReplaySubject.ts", "node_modules/rxjs/src/internal/scheduler/Action.ts", "node_modules/rxjs/src/internal/scheduler/intervalProvider.ts", "node_modules/rxjs/src/internal/scheduler/AsyncAction.ts", "node_modules/rxjs/src/internal/Scheduler.ts", "node_modules/rxjs/src/internal/scheduler/AsyncScheduler.ts", "node_modules/rxjs/src/internal/scheduler/async.ts", "node_modules/rxjs/src/internal/scheduler/AnimationFrameAction.ts", "node_modules/rxjs/src/internal/scheduler/AnimationFrameScheduler.ts", "node_modules/rxjs/src/internal/scheduler/animationFrame.ts", "node_modules/rxjs/src/internal/observable/empty.ts", "node_modules/rxjs/src/internal/util/isScheduler.ts", "node_modules/rxjs/src/internal/util/args.ts", "node_modules/rxjs/src/internal/util/isArrayLike.ts", "node_modules/rxjs/src/internal/util/isPromise.ts", "node_modules/rxjs/src/internal/util/isInteropObservable.ts", "node_modules/rxjs/src/internal/util/isAsyncIterable.ts", "node_modules/rxjs/src/internal/util/throwUnobservableError.ts", "node_modules/rxjs/src/internal/symbol/iterator.ts", "node_modules/rxjs/src/internal/util/isIterable.ts", "node_modules/rxjs/src/internal/util/isReadableStreamLike.ts", "node_modules/rxjs/src/internal/observable/innerFrom.ts", "node_modules/rxjs/src/internal/util/executeSchedule.ts", "node_modules/rxjs/src/internal/operators/observeOn.ts", "node_modules/rxjs/src/internal/operators/subscribeOn.ts", "node_modules/rxjs/src/internal/scheduled/scheduleObservable.ts", "node_modules/rxjs/src/internal/scheduled/schedulePromise.ts", "node_modules/rxjs/src/internal/scheduled/scheduleArray.ts", "node_modules/rxjs/src/internal/scheduled/scheduleIterable.ts", "node_modules/rxjs/src/internal/scheduled/scheduleAsyncIterable.ts", "node_modules/rxjs/src/internal/scheduled/scheduleReadableStreamLike.ts", "node_modules/rxjs/src/internal/scheduled/scheduled.ts", "node_modules/rxjs/src/internal/observable/from.ts", "node_modules/rxjs/src/internal/observable/of.ts", "node_modules/rxjs/src/internal/observable/throwError.ts", "node_modules/rxjs/src/internal/util/EmptyError.ts", "node_modules/rxjs/src/internal/util/isDate.ts", "node_modules/rxjs/src/internal/operators/map.ts", "node_modules/rxjs/src/internal/util/mapOneOrManyArgs.ts", "node_modules/rxjs/src/internal/util/argsArgArrayOrObject.ts", "node_modules/rxjs/src/internal/util/createObject.ts", "node_modules/rxjs/src/internal/observable/combineLatest.ts", "node_modules/rxjs/src/internal/operators/mergeInternals.ts", "node_modules/rxjs/src/internal/operators/mergeMap.ts", "node_modules/rxjs/src/internal/operators/mergeAll.ts", "node_modules/rxjs/src/internal/operators/concatAll.ts", "node_modules/rxjs/src/internal/observable/concat.ts", "node_modules/rxjs/src/internal/observable/defer.ts", "node_modules/rxjs/src/internal/observable/fromEvent.ts", "node_modules/rxjs/src/internal/observable/fromEventPattern.ts", "node_modules/rxjs/src/internal/observable/timer.ts", "node_modules/rxjs/src/internal/observable/merge.ts", "node_modules/rxjs/src/internal/observable/never.ts", "node_modules/rxjs/src/internal/util/argsOrArgArray.ts", "node_modules/rxjs/src/internal/operators/filter.ts", "node_modules/rxjs/src/internal/observable/zip.ts", "node_modules/rxjs/src/internal/operators/audit.ts", "node_modules/rxjs/src/internal/operators/auditTime.ts", "node_modules/rxjs/src/internal/operators/bufferCount.ts", "node_modules/rxjs/src/internal/operators/catchError.ts", "node_modules/rxjs/src/internal/operators/scanInternals.ts", "node_modules/rxjs/src/internal/operators/combineLatest.ts", "node_modules/rxjs/src/internal/operators/combineLatestWith.ts", "node_modules/rxjs/src/internal/operators/debounceTime.ts", "node_modules/rxjs/src/internal/operators/defaultIfEmpty.ts", "node_modules/rxjs/src/internal/operators/take.ts", "node_modules/rxjs/src/internal/operators/ignoreElements.ts", "node_modules/rxjs/src/internal/operators/mapTo.ts", "node_modules/rxjs/src/internal/operators/delayWhen.ts", "node_modules/rxjs/src/internal/operators/delay.ts", "node_modules/rxjs/src/internal/operators/distinctUntilChanged.ts", "node_modules/rxjs/src/internal/operators/distinctUntilKeyChanged.ts", "node_modules/rxjs/src/internal/operators/throwIfEmpty.ts", "node_modules/rxjs/src/internal/operators/endWith.ts", "node_modules/rxjs/src/internal/operators/finalize.ts", "node_modules/rxjs/src/internal/operators/first.ts", "node_modules/rxjs/src/internal/operators/merge.ts", "node_modules/rxjs/src/internal/operators/mergeWith.ts", "node_modules/rxjs/src/internal/operators/repeat.ts", "node_modules/rxjs/src/internal/operators/sample.ts", "node_modules/rxjs/src/internal/operators/scan.ts", "node_modules/rxjs/src/internal/operators/share.ts", "node_modules/rxjs/src/internal/operators/shareReplay.ts", "node_modules/rxjs/src/internal/operators/skip.ts", "node_modules/rxjs/src/internal/operators/skipUntil.ts", "node_modules/rxjs/src/internal/operators/startWith.ts", "node_modules/rxjs/src/internal/operators/switchMap.ts", "node_modules/rxjs/src/internal/operators/takeUntil.ts", "node_modules/rxjs/src/internal/operators/takeWhile.ts", "node_modules/rxjs/src/internal/operators/tap.ts", "node_modules/rxjs/src/internal/operators/throttle.ts", "node_modules/rxjs/src/internal/operators/throttleTime.ts", "node_modules/rxjs/src/internal/operators/withLatestFrom.ts", "node_modules/rxjs/src/internal/operators/zip.ts", "node_modules/rxjs/src/internal/operators/zipWith.ts", "src/templates/assets/javascripts/browser/document/index.ts", "src/templates/assets/javascripts/browser/element/_/index.ts", "src/templates/assets/javascripts/browser/element/focus/index.ts", "src/templates/assets/javascripts/browser/element/offset/_/index.ts", "src/templates/assets/javascripts/browser/element/offset/content/index.ts", "src/templates/assets/javascripts/utilities/h/index.ts", "src/templates/assets/javascripts/utilities/round/index.ts", "src/templates/assets/javascripts/browser/script/index.ts", "src/templates/assets/javascripts/browser/element/size/_/index.ts", "src/templates/assets/javascripts/browser/element/size/content/index.ts", "src/templates/assets/javascripts/browser/element/visibility/index.ts", "src/templates/assets/javascripts/browser/toggle/index.ts", "src/templates/assets/javascripts/browser/keyboard/index.ts", "src/templates/assets/javascripts/browser/location/_/index.ts", "src/templates/assets/javascripts/browser/location/hash/index.ts", "src/templates/assets/javascripts/browser/media/index.ts", "src/templates/assets/javascripts/browser/request/index.ts", "src/templates/assets/javascripts/browser/viewport/offset/index.ts", "src/templates/assets/javascripts/browser/viewport/size/index.ts", "src/templates/assets/javascripts/browser/viewport/_/index.ts", "src/templates/assets/javascripts/browser/viewport/at/index.ts", "src/templates/assets/javascripts/browser/worker/index.ts", "src/templates/assets/javascripts/_/index.ts", "src/templates/assets/javascripts/components/_/index.ts", "src/templates/assets/javascripts/components/announce/index.ts", "src/templates/assets/javascripts/components/consent/index.ts", "src/templates/assets/javascripts/components/content/annotation/_/index.ts", "src/templates/assets/javascripts/templates/tooltip/index.tsx", "src/templates/assets/javascripts/templates/annotation/index.tsx", "src/templates/assets/javascripts/templates/clipboard/index.tsx", "src/templates/assets/javascripts/templates/search/index.tsx", "src/templates/assets/javascripts/templates/source/index.tsx", "src/templates/assets/javascripts/templates/tabbed/index.tsx", "src/templates/assets/javascripts/templates/table/index.tsx", "src/templates/assets/javascripts/templates/version/index.tsx", "src/templates/assets/javascripts/components/content/annotation/list/index.ts", "src/templates/assets/javascripts/components/content/annotation/block/index.ts", "src/templates/assets/javascripts/components/content/code/_/index.ts", "src/templates/assets/javascripts/components/content/details/index.ts", "src/templates/assets/javascripts/components/content/mermaid/index.css", "src/templates/assets/javascripts/components/content/mermaid/index.ts", "src/templates/assets/javascripts/components/content/table/index.ts", "src/templates/assets/javascripts/components/content/tabs/index.ts", "src/templates/assets/javascripts/components/content/_/index.ts", "src/templates/assets/javascripts/components/dialog/index.ts", "src/templates/assets/javascripts/components/header/_/index.ts", "src/templates/assets/javascripts/components/header/title/index.ts", "src/templates/assets/javascripts/components/main/index.ts", "src/templates/assets/javascripts/components/palette/index.ts", "src/templates/assets/javascripts/components/progress/index.ts", "src/templates/assets/javascripts/integrations/clipboard/index.ts", "src/templates/assets/javascripts/integrations/sitemap/index.ts", "src/templates/assets/javascripts/integrations/instant/index.ts", "src/templates/assets/javascripts/integrations/search/highlighter/index.ts", "src/templates/assets/javascripts/integrations/search/worker/message/index.ts", "src/templates/assets/javascripts/integrations/search/worker/_/index.ts", "src/templates/assets/javascripts/integrations/version/index.ts", "src/templates/assets/javascripts/components/search/query/index.ts", "src/templates/assets/javascripts/components/search/result/index.ts", "src/templates/assets/javascripts/components/search/share/index.ts", "src/templates/assets/javascripts/components/search/suggest/index.ts", "src/templates/assets/javascripts/components/search/_/index.ts", "src/templates/assets/javascripts/components/search/highlight/index.ts", "src/templates/assets/javascripts/components/sidebar/index.ts", "src/templates/assets/javascripts/components/source/facts/github/index.ts", "src/templates/assets/javascripts/components/source/facts/gitlab/index.ts", "src/templates/assets/javascripts/components/source/facts/_/index.ts", "src/templates/assets/javascripts/components/source/_/index.ts", "src/templates/assets/javascripts/components/tabs/index.ts", "src/templates/assets/javascripts/components/toc/index.ts", "src/templates/assets/javascripts/components/top/index.ts", "src/templates/assets/javascripts/patches/indeterminate/index.ts", "src/templates/assets/javascripts/patches/scrollfix/index.ts", "src/templates/assets/javascripts/patches/scrolllock/index.ts", "src/templates/assets/javascripts/polyfills/index.ts"], + "sourcesContent": ["(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n (factory());\n}(this, (function () { 'use strict';\n\n /**\n * Applies the :focus-visible polyfill at the given scope.\n * A scope in this case is either the top-level Document or a Shadow Root.\n *\n * @param {(Document|ShadowRoot)} scope\n * @see https://github.com/WICG/focus-visible\n */\n function applyFocusVisiblePolyfill(scope) {\n var hadKeyboardEvent = true;\n var hadFocusVisibleRecently = false;\n var hadFocusVisibleRecentlyTimeout = null;\n\n var inputTypesAllowlist = {\n text: true,\n search: true,\n url: true,\n tel: true,\n email: true,\n password: true,\n number: true,\n date: true,\n month: true,\n week: true,\n time: true,\n datetime: true,\n 'datetime-local': true\n };\n\n /**\n * Helper function for legacy browsers and iframes which sometimes focus\n * elements like document, body, and non-interactive SVG.\n * @param {Element} el\n */\n function isValidFocusTarget(el) {\n if (\n el &&\n el !== document &&\n el.nodeName !== 'HTML' &&\n el.nodeName !== 'BODY' &&\n 'classList' in el &&\n 'contains' in el.classList\n ) {\n return true;\n }\n return false;\n }\n\n /**\n * Computes whether the given element should automatically trigger the\n * `focus-visible` class being added, i.e. whether it should always match\n * `:focus-visible` when focused.\n * @param {Element} el\n * @return {boolean}\n */\n function focusTriggersKeyboardModality(el) {\n var type = el.type;\n var tagName = el.tagName;\n\n if (tagName === 'INPUT' && inputTypesAllowlist[type] && !el.readOnly) {\n return true;\n }\n\n if (tagName === 'TEXTAREA' && !el.readOnly) {\n return true;\n }\n\n if (el.isContentEditable) {\n return true;\n }\n\n return false;\n }\n\n /**\n * Add the `focus-visible` class to the given element if it was not added by\n * the author.\n * @param {Element} el\n */\n function addFocusVisibleClass(el) {\n if (el.classList.contains('focus-visible')) {\n return;\n }\n el.classList.add('focus-visible');\n el.setAttribute('data-focus-visible-added', '');\n }\n\n /**\n * Remove the `focus-visible` class from the given element if it was not\n * originally added by the author.\n * @param {Element} el\n */\n function removeFocusVisibleClass(el) {\n if (!el.hasAttribute('data-focus-visible-added')) {\n return;\n }\n el.classList.remove('focus-visible');\n el.removeAttribute('data-focus-visible-added');\n }\n\n /**\n * If the most recent user interaction was via the keyboard;\n * and the key press did not include a meta, alt/option, or control key;\n * then the modality is keyboard. Otherwise, the modality is not keyboard.\n * Apply `focus-visible` to any current active element and keep track\n * of our keyboard modality state with `hadKeyboardEvent`.\n * @param {KeyboardEvent} e\n */\n function onKeyDown(e) {\n if (e.metaKey || e.altKey || e.ctrlKey) {\n return;\n }\n\n if (isValidFocusTarget(scope.activeElement)) {\n addFocusVisibleClass(scope.activeElement);\n }\n\n hadKeyboardEvent = true;\n }\n\n /**\n * If at any point a user clicks with a pointing device, ensure that we change\n * the modality away from keyboard.\n * This avoids the situation where a user presses a key on an already focused\n * element, and then clicks on a different element, focusing it with a\n * pointing device, while we still think we're in keyboard modality.\n * @param {Event} e\n */\n function onPointerDown(e) {\n hadKeyboardEvent = false;\n }\n\n /**\n * On `focus`, add the `focus-visible` class to the target if:\n * - the target received focus as a result of keyboard navigation, or\n * - the event target is an element that will likely require interaction\n * via the keyboard (e.g. a text box)\n * @param {Event} e\n */\n function onFocus(e) {\n // Prevent IE from focusing the document or HTML element.\n if (!isValidFocusTarget(e.target)) {\n return;\n }\n\n if (hadKeyboardEvent || focusTriggersKeyboardModality(e.target)) {\n addFocusVisibleClass(e.target);\n }\n }\n\n /**\n * On `blur`, remove the `focus-visible` class from the target.\n * @param {Event} e\n */\n function onBlur(e) {\n if (!isValidFocusTarget(e.target)) {\n return;\n }\n\n if (\n e.target.classList.contains('focus-visible') ||\n e.target.hasAttribute('data-focus-visible-added')\n ) {\n // To detect a tab/window switch, we look for a blur event followed\n // rapidly by a visibility change.\n // If we don't see a visibility change within 100ms, it's probably a\n // regular focus change.\n hadFocusVisibleRecently = true;\n window.clearTimeout(hadFocusVisibleRecentlyTimeout);\n hadFocusVisibleRecentlyTimeout = window.setTimeout(function() {\n hadFocusVisibleRecently = false;\n }, 100);\n removeFocusVisibleClass(e.target);\n }\n }\n\n /**\n * If the user changes tabs, keep track of whether or not the previously\n * focused element had .focus-visible.\n * @param {Event} e\n */\n function onVisibilityChange(e) {\n if (document.visibilityState === 'hidden') {\n // If the tab becomes active again, the browser will handle calling focus\n // on the element (Safari actually calls it twice).\n // If this tab change caused a blur on an element with focus-visible,\n // re-apply the class when the user switches back to the tab.\n if (hadFocusVisibleRecently) {\n hadKeyboardEvent = true;\n }\n addInitialPointerMoveListeners();\n }\n }\n\n /**\n * Add a group of listeners to detect usage of any pointing devices.\n * These listeners will be added when the polyfill first loads, and anytime\n * the window is blurred, so that they are active when the window regains\n * focus.\n */\n function addInitialPointerMoveListeners() {\n document.addEventListener('mousemove', onInitialPointerMove);\n document.addEventListener('mousedown', onInitialPointerMove);\n document.addEventListener('mouseup', onInitialPointerMove);\n document.addEventListener('pointermove', onInitialPointerMove);\n document.addEventListener('pointerdown', onInitialPointerMove);\n document.addEventListener('pointerup', onInitialPointerMove);\n document.addEventListener('touchmove', onInitialPointerMove);\n document.addEventListener('touchstart', onInitialPointerMove);\n document.addEventListener('touchend', onInitialPointerMove);\n }\n\n function removeInitialPointerMoveListeners() {\n document.removeEventListener('mousemove', onInitialPointerMove);\n document.removeEventListener('mousedown', onInitialPointerMove);\n document.removeEventListener('mouseup', onInitialPointerMove);\n document.removeEventListener('pointermove', onInitialPointerMove);\n document.removeEventListener('pointerdown', onInitialPointerMove);\n document.removeEventListener('pointerup', onInitialPointerMove);\n document.removeEventListener('touchmove', onInitialPointerMove);\n document.removeEventListener('touchstart', onInitialPointerMove);\n document.removeEventListener('touchend', onInitialPointerMove);\n }\n\n /**\n * When the polfyill first loads, assume the user is in keyboard modality.\n * If any event is received from a pointing device (e.g. mouse, pointer,\n * touch), turn off keyboard modality.\n * This accounts for situations where focus enters the page from the URL bar.\n * @param {Event} e\n */\n function onInitialPointerMove(e) {\n // Work around a Safari quirk that fires a mousemove on whenever the\n // window blurs, even if you're tabbing out of the page. \u00AF\\_(\u30C4)_/\u00AF\n if (e.target.nodeName && e.target.nodeName.toLowerCase() === 'html') {\n return;\n }\n\n hadKeyboardEvent = false;\n removeInitialPointerMoveListeners();\n }\n\n // For some kinds of state, we are interested in changes at the global scope\n // only. For example, global pointer input, global key presses and global\n // visibility change should affect the state at every scope:\n document.addEventListener('keydown', onKeyDown, true);\n document.addEventListener('mousedown', onPointerDown, true);\n document.addEventListener('pointerdown', onPointerDown, true);\n document.addEventListener('touchstart', onPointerDown, true);\n document.addEventListener('visibilitychange', onVisibilityChange, true);\n\n addInitialPointerMoveListeners();\n\n // For focus and blur, we specifically care about state changes in the local\n // scope. This is because focus / blur events that originate from within a\n // shadow root are not re-dispatched from the host element if it was already\n // the active element in its own scope:\n scope.addEventListener('focus', onFocus, true);\n scope.addEventListener('blur', onBlur, true);\n\n // We detect that a node is a ShadowRoot by ensuring that it is a\n // DocumentFragment and also has a host property. This check covers native\n // implementation and polyfill implementation transparently. If we only cared\n // about the native implementation, we could just check if the scope was\n // an instance of a ShadowRoot.\n if (scope.nodeType === Node.DOCUMENT_FRAGMENT_NODE && scope.host) {\n // Since a ShadowRoot is a special kind of DocumentFragment, it does not\n // have a root element to add a class to. So, we add this attribute to the\n // host element instead:\n scope.host.setAttribute('data-js-focus-visible', '');\n } else if (scope.nodeType === Node.DOCUMENT_NODE) {\n document.documentElement.classList.add('js-focus-visible');\n document.documentElement.setAttribute('data-js-focus-visible', '');\n }\n }\n\n // It is important to wrap all references to global window and document in\n // these checks to support server-side rendering use cases\n // @see https://github.com/WICG/focus-visible/issues/199\n if (typeof window !== 'undefined' && typeof document !== 'undefined') {\n // Make the polyfill helper globally available. This can be used as a signal\n // to interested libraries that wish to coordinate with the polyfill for e.g.,\n // applying the polyfill to a shadow root:\n window.applyFocusVisiblePolyfill = applyFocusVisiblePolyfill;\n\n // Notify interested libraries of the polyfill's presence, in case the\n // polyfill was loaded lazily:\n var event;\n\n try {\n event = new CustomEvent('focus-visible-polyfill-ready');\n } catch (error) {\n // IE11 does not support using CustomEvent as a constructor directly:\n event = document.createEvent('CustomEvent');\n event.initCustomEvent('focus-visible-polyfill-ready', false, false, {});\n }\n\n window.dispatchEvent(event);\n }\n\n if (typeof document !== 'undefined') {\n // Apply the polyfill to the global document, so that no JavaScript\n // coordination is required to use the polyfill in the top-level document:\n applyFocusVisiblePolyfill(document);\n }\n\n})));\n", "/*!\n * clipboard.js v2.0.11\n * https://clipboardjs.com/\n *\n * Licensed MIT \u00A9 Zeno Rocha\n */\n(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"ClipboardJS\"] = factory();\n\telse\n\t\troot[\"ClipboardJS\"] = factory();\n})(this, function() {\nreturn /******/ (function() { // webpackBootstrap\n/******/ \tvar __webpack_modules__ = ({\n\n/***/ 686:\n/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n\n// EXPORTS\n__webpack_require__.d(__webpack_exports__, {\n \"default\": function() { return /* binding */ clipboard; }\n});\n\n// EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js\nvar tiny_emitter = __webpack_require__(279);\nvar tiny_emitter_default = /*#__PURE__*/__webpack_require__.n(tiny_emitter);\n// EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js\nvar listen = __webpack_require__(370);\nvar listen_default = /*#__PURE__*/__webpack_require__.n(listen);\n// EXTERNAL MODULE: ./node_modules/select/src/select.js\nvar src_select = __webpack_require__(817);\nvar select_default = /*#__PURE__*/__webpack_require__.n(src_select);\n;// CONCATENATED MODULE: ./src/common/command.js\n/**\n * Executes a given operation type.\n * @param {String} type\n * @return {Boolean}\n */\nfunction command(type) {\n try {\n return document.execCommand(type);\n } catch (err) {\n return false;\n }\n}\n;// CONCATENATED MODULE: ./src/actions/cut.js\n\n\n/**\n * Cut action wrapper.\n * @param {String|HTMLElement} target\n * @return {String}\n */\n\nvar ClipboardActionCut = function ClipboardActionCut(target) {\n var selectedText = select_default()(target);\n command('cut');\n return selectedText;\n};\n\n/* harmony default export */ var actions_cut = (ClipboardActionCut);\n;// CONCATENATED MODULE: ./src/common/create-fake-element.js\n/**\n * Creates a fake textarea element with a value.\n * @param {String} value\n * @return {HTMLElement}\n */\nfunction createFakeElement(value) {\n var isRTL = document.documentElement.getAttribute('dir') === 'rtl';\n var fakeElement = document.createElement('textarea'); // Prevent zooming on iOS\n\n fakeElement.style.fontSize = '12pt'; // Reset box model\n\n fakeElement.style.border = '0';\n fakeElement.style.padding = '0';\n fakeElement.style.margin = '0'; // Move element out of screen horizontally\n\n fakeElement.style.position = 'absolute';\n fakeElement.style[isRTL ? 'right' : 'left'] = '-9999px'; // Move element to the same position vertically\n\n var yPosition = window.pageYOffset || document.documentElement.scrollTop;\n fakeElement.style.top = \"\".concat(yPosition, \"px\");\n fakeElement.setAttribute('readonly', '');\n fakeElement.value = value;\n return fakeElement;\n}\n;// CONCATENATED MODULE: ./src/actions/copy.js\n\n\n\n/**\n * Create fake copy action wrapper using a fake element.\n * @param {String} target\n * @param {Object} options\n * @return {String}\n */\n\nvar fakeCopyAction = function fakeCopyAction(value, options) {\n var fakeElement = createFakeElement(value);\n options.container.appendChild(fakeElement);\n var selectedText = select_default()(fakeElement);\n command('copy');\n fakeElement.remove();\n return selectedText;\n};\n/**\n * Copy action wrapper.\n * @param {String|HTMLElement} target\n * @param {Object} options\n * @return {String}\n */\n\n\nvar ClipboardActionCopy = function ClipboardActionCopy(target) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {\n container: document.body\n };\n var selectedText = '';\n\n if (typeof target === 'string') {\n selectedText = fakeCopyAction(target, options);\n } else if (target instanceof HTMLInputElement && !['text', 'search', 'url', 'tel', 'password'].includes(target === null || target === void 0 ? void 0 : target.type)) {\n // If input type doesn't support `setSelectionRange`. Simulate it. https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange\n selectedText = fakeCopyAction(target.value, options);\n } else {\n selectedText = select_default()(target);\n command('copy');\n }\n\n return selectedText;\n};\n\n/* harmony default export */ var actions_copy = (ClipboardActionCopy);\n;// CONCATENATED MODULE: ./src/actions/default.js\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\n\n\n/**\n * Inner function which performs selection from either `text` or `target`\n * properties and then executes copy or cut operations.\n * @param {Object} options\n */\n\nvar ClipboardActionDefault = function ClipboardActionDefault() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n // Defines base properties passed from constructor.\n var _options$action = options.action,\n action = _options$action === void 0 ? 'copy' : _options$action,\n container = options.container,\n target = options.target,\n text = options.text; // Sets the `action` to be performed which can be either 'copy' or 'cut'.\n\n if (action !== 'copy' && action !== 'cut') {\n throw new Error('Invalid \"action\" value, use either \"copy\" or \"cut\"');\n } // Sets the `target` property using an element that will be have its content copied.\n\n\n if (target !== undefined) {\n if (target && _typeof(target) === 'object' && target.nodeType === 1) {\n if (action === 'copy' && target.hasAttribute('disabled')) {\n throw new Error('Invalid \"target\" attribute. Please use \"readonly\" instead of \"disabled\" attribute');\n }\n\n if (action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {\n throw new Error('Invalid \"target\" attribute. You can\\'t cut text from elements with \"readonly\" or \"disabled\" attributes');\n }\n } else {\n throw new Error('Invalid \"target\" value, use a valid Element');\n }\n } // Define selection strategy based on `text` property.\n\n\n if (text) {\n return actions_copy(text, {\n container: container\n });\n } // Defines which selection strategy based on `target` property.\n\n\n if (target) {\n return action === 'cut' ? actions_cut(target) : actions_copy(target, {\n container: container\n });\n }\n};\n\n/* harmony default export */ var actions_default = (ClipboardActionDefault);\n;// CONCATENATED MODULE: ./src/clipboard.js\nfunction clipboard_typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { clipboard_typeof = function _typeof(obj) { return typeof obj; }; } else { clipboard_typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return clipboard_typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (clipboard_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n\n\n/**\n * Helper function to retrieve attribute value.\n * @param {String} suffix\n * @param {Element} element\n */\n\nfunction getAttributeValue(suffix, element) {\n var attribute = \"data-clipboard-\".concat(suffix);\n\n if (!element.hasAttribute(attribute)) {\n return;\n }\n\n return element.getAttribute(attribute);\n}\n/**\n * Base class which takes one or more elements, adds event listeners to them,\n * and instantiates a new `ClipboardAction` on each click.\n */\n\n\nvar Clipboard = /*#__PURE__*/function (_Emitter) {\n _inherits(Clipboard, _Emitter);\n\n var _super = _createSuper(Clipboard);\n\n /**\n * @param {String|HTMLElement|HTMLCollection|NodeList} trigger\n * @param {Object} options\n */\n function Clipboard(trigger, options) {\n var _this;\n\n _classCallCheck(this, Clipboard);\n\n _this = _super.call(this);\n\n _this.resolveOptions(options);\n\n _this.listenClick(trigger);\n\n return _this;\n }\n /**\n * Defines if attributes would be resolved using internal setter functions\n * or custom functions that were passed in the constructor.\n * @param {Object} options\n */\n\n\n _createClass(Clipboard, [{\n key: \"resolveOptions\",\n value: function resolveOptions() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n this.action = typeof options.action === 'function' ? options.action : this.defaultAction;\n this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;\n this.text = typeof options.text === 'function' ? options.text : this.defaultText;\n this.container = clipboard_typeof(options.container) === 'object' ? options.container : document.body;\n }\n /**\n * Adds a click event listener to the passed trigger.\n * @param {String|HTMLElement|HTMLCollection|NodeList} trigger\n */\n\n }, {\n key: \"listenClick\",\n value: function listenClick(trigger) {\n var _this2 = this;\n\n this.listener = listen_default()(trigger, 'click', function (e) {\n return _this2.onClick(e);\n });\n }\n /**\n * Defines a new `ClipboardAction` on each click event.\n * @param {Event} e\n */\n\n }, {\n key: \"onClick\",\n value: function onClick(e) {\n var trigger = e.delegateTarget || e.currentTarget;\n var action = this.action(trigger) || 'copy';\n var text = actions_default({\n action: action,\n container: this.container,\n target: this.target(trigger),\n text: this.text(trigger)\n }); // Fires an event based on the copy operation result.\n\n this.emit(text ? 'success' : 'error', {\n action: action,\n text: text,\n trigger: trigger,\n clearSelection: function clearSelection() {\n if (trigger) {\n trigger.focus();\n }\n\n window.getSelection().removeAllRanges();\n }\n });\n }\n /**\n * Default `action` lookup function.\n * @param {Element} trigger\n */\n\n }, {\n key: \"defaultAction\",\n value: function defaultAction(trigger) {\n return getAttributeValue('action', trigger);\n }\n /**\n * Default `target` lookup function.\n * @param {Element} trigger\n */\n\n }, {\n key: \"defaultTarget\",\n value: function defaultTarget(trigger) {\n var selector = getAttributeValue('target', trigger);\n\n if (selector) {\n return document.querySelector(selector);\n }\n }\n /**\n * Allow fire programmatically a copy action\n * @param {String|HTMLElement} target\n * @param {Object} options\n * @returns Text copied.\n */\n\n }, {\n key: \"defaultText\",\n\n /**\n * Default `text` lookup function.\n * @param {Element} trigger\n */\n value: function defaultText(trigger) {\n return getAttributeValue('text', trigger);\n }\n /**\n * Destroy lifecycle.\n */\n\n }, {\n key: \"destroy\",\n value: function destroy() {\n this.listener.destroy();\n }\n }], [{\n key: \"copy\",\n value: function copy(target) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {\n container: document.body\n };\n return actions_copy(target, options);\n }\n /**\n * Allow fire programmatically a cut action\n * @param {String|HTMLElement} target\n * @returns Text cutted.\n */\n\n }, {\n key: \"cut\",\n value: function cut(target) {\n return actions_cut(target);\n }\n /**\n * Returns the support of the given action, or all actions if no action is\n * given.\n * @param {String} [action]\n */\n\n }, {\n key: \"isSupported\",\n value: function isSupported() {\n var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];\n var actions = typeof action === 'string' ? [action] : action;\n var support = !!document.queryCommandSupported;\n actions.forEach(function (action) {\n support = support && !!document.queryCommandSupported(action);\n });\n return support;\n }\n }]);\n\n return Clipboard;\n}((tiny_emitter_default()));\n\n/* harmony default export */ var clipboard = (Clipboard);\n\n/***/ }),\n\n/***/ 828:\n/***/ (function(module) {\n\nvar DOCUMENT_NODE_TYPE = 9;\n\n/**\n * A polyfill for Element.matches()\n */\nif (typeof Element !== 'undefined' && !Element.prototype.matches) {\n var proto = Element.prototype;\n\n proto.matches = proto.matchesSelector ||\n proto.mozMatchesSelector ||\n proto.msMatchesSelector ||\n proto.oMatchesSelector ||\n proto.webkitMatchesSelector;\n}\n\n/**\n * Finds the closest parent that matches a selector.\n *\n * @param {Element} element\n * @param {String} selector\n * @return {Function}\n */\nfunction closest (element, selector) {\n while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {\n if (typeof element.matches === 'function' &&\n element.matches(selector)) {\n return element;\n }\n element = element.parentNode;\n }\n}\n\nmodule.exports = closest;\n\n\n/***/ }),\n\n/***/ 438:\n/***/ (function(module, __unused_webpack_exports, __webpack_require__) {\n\nvar closest = __webpack_require__(828);\n\n/**\n * Delegates event to a selector.\n *\n * @param {Element} element\n * @param {String} selector\n * @param {String} type\n * @param {Function} callback\n * @param {Boolean} useCapture\n * @return {Object}\n */\nfunction _delegate(element, selector, type, callback, useCapture) {\n var listenerFn = listener.apply(this, arguments);\n\n element.addEventListener(type, listenerFn, useCapture);\n\n return {\n destroy: function() {\n element.removeEventListener(type, listenerFn, useCapture);\n }\n }\n}\n\n/**\n * Delegates event to a selector.\n *\n * @param {Element|String|Array} [elements]\n * @param {String} selector\n * @param {String} type\n * @param {Function} callback\n * @param {Boolean} useCapture\n * @return {Object}\n */\nfunction delegate(elements, selector, type, callback, useCapture) {\n // Handle the regular Element usage\n if (typeof elements.addEventListener === 'function') {\n return _delegate.apply(null, arguments);\n }\n\n // Handle Element-less usage, it defaults to global delegation\n if (typeof type === 'function') {\n // Use `document` as the first parameter, then apply arguments\n // This is a short way to .unshift `arguments` without running into deoptimizations\n return _delegate.bind(null, document).apply(null, arguments);\n }\n\n // Handle Selector-based usage\n if (typeof elements === 'string') {\n elements = document.querySelectorAll(elements);\n }\n\n // Handle Array-like based usage\n return Array.prototype.map.call(elements, function (element) {\n return _delegate(element, selector, type, callback, useCapture);\n });\n}\n\n/**\n * Finds closest match and invokes callback.\n *\n * @param {Element} element\n * @param {String} selector\n * @param {String} type\n * @param {Function} callback\n * @return {Function}\n */\nfunction listener(element, selector, type, callback) {\n return function(e) {\n e.delegateTarget = closest(e.target, selector);\n\n if (e.delegateTarget) {\n callback.call(element, e);\n }\n }\n}\n\nmodule.exports = delegate;\n\n\n/***/ }),\n\n/***/ 879:\n/***/ (function(__unused_webpack_module, exports) {\n\n/**\n * Check if argument is a HTML element.\n *\n * @param {Object} value\n * @return {Boolean}\n */\nexports.node = function(value) {\n return value !== undefined\n && value instanceof HTMLElement\n && value.nodeType === 1;\n};\n\n/**\n * Check if argument is a list of HTML elements.\n *\n * @param {Object} value\n * @return {Boolean}\n */\nexports.nodeList = function(value) {\n var type = Object.prototype.toString.call(value);\n\n return value !== undefined\n && (type === '[object NodeList]' || type === '[object HTMLCollection]')\n && ('length' in value)\n && (value.length === 0 || exports.node(value[0]));\n};\n\n/**\n * Check if argument is a string.\n *\n * @param {Object} value\n * @return {Boolean}\n */\nexports.string = function(value) {\n return typeof value === 'string'\n || value instanceof String;\n};\n\n/**\n * Check if argument is a function.\n *\n * @param {Object} value\n * @return {Boolean}\n */\nexports.fn = function(value) {\n var type = Object.prototype.toString.call(value);\n\n return type === '[object Function]';\n};\n\n\n/***/ }),\n\n/***/ 370:\n/***/ (function(module, __unused_webpack_exports, __webpack_require__) {\n\nvar is = __webpack_require__(879);\nvar delegate = __webpack_require__(438);\n\n/**\n * Validates all params and calls the right\n * listener function based on its target type.\n *\n * @param {String|HTMLElement|HTMLCollection|NodeList} target\n * @param {String} type\n * @param {Function} callback\n * @return {Object}\n */\nfunction listen(target, type, callback) {\n if (!target && !type && !callback) {\n throw new Error('Missing required arguments');\n }\n\n if (!is.string(type)) {\n throw new TypeError('Second argument must be a String');\n }\n\n if (!is.fn(callback)) {\n throw new TypeError('Third argument must be a Function');\n }\n\n if (is.node(target)) {\n return listenNode(target, type, callback);\n }\n else if (is.nodeList(target)) {\n return listenNodeList(target, type, callback);\n }\n else if (is.string(target)) {\n return listenSelector(target, type, callback);\n }\n else {\n throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');\n }\n}\n\n/**\n * Adds an event listener to a HTML element\n * and returns a remove listener function.\n *\n * @param {HTMLElement} node\n * @param {String} type\n * @param {Function} callback\n * @return {Object}\n */\nfunction listenNode(node, type, callback) {\n node.addEventListener(type, callback);\n\n return {\n destroy: function() {\n node.removeEventListener(type, callback);\n }\n }\n}\n\n/**\n * Add an event listener to a list of HTML elements\n * and returns a remove listener function.\n *\n * @param {NodeList|HTMLCollection} nodeList\n * @param {String} type\n * @param {Function} callback\n * @return {Object}\n */\nfunction listenNodeList(nodeList, type, callback) {\n Array.prototype.forEach.call(nodeList, function(node) {\n node.addEventListener(type, callback);\n });\n\n return {\n destroy: function() {\n Array.prototype.forEach.call(nodeList, function(node) {\n node.removeEventListener(type, callback);\n });\n }\n }\n}\n\n/**\n * Add an event listener to a selector\n * and returns a remove listener function.\n *\n * @param {String} selector\n * @param {String} type\n * @param {Function} callback\n * @return {Object}\n */\nfunction listenSelector(selector, type, callback) {\n return delegate(document.body, selector, type, callback);\n}\n\nmodule.exports = listen;\n\n\n/***/ }),\n\n/***/ 817:\n/***/ (function(module) {\n\nfunction select(element) {\n var selectedText;\n\n if (element.nodeName === 'SELECT') {\n element.focus();\n\n selectedText = element.value;\n }\n else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {\n var isReadOnly = element.hasAttribute('readonly');\n\n if (!isReadOnly) {\n element.setAttribute('readonly', '');\n }\n\n element.select();\n element.setSelectionRange(0, element.value.length);\n\n if (!isReadOnly) {\n element.removeAttribute('readonly');\n }\n\n selectedText = element.value;\n }\n else {\n if (element.hasAttribute('contenteditable')) {\n element.focus();\n }\n\n var selection = window.getSelection();\n var range = document.createRange();\n\n range.selectNodeContents(element);\n selection.removeAllRanges();\n selection.addRange(range);\n\n selectedText = selection.toString();\n }\n\n return selectedText;\n}\n\nmodule.exports = select;\n\n\n/***/ }),\n\n/***/ 279:\n/***/ (function(module) {\n\nfunction E () {\n // Keep this empty so it's easier to inherit from\n // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)\n}\n\nE.prototype = {\n on: function (name, callback, ctx) {\n var e = this.e || (this.e = {});\n\n (e[name] || (e[name] = [])).push({\n fn: callback,\n ctx: ctx\n });\n\n return this;\n },\n\n once: function (name, callback, ctx) {\n var self = this;\n function listener () {\n self.off(name, listener);\n callback.apply(ctx, arguments);\n };\n\n listener._ = callback\n return this.on(name, listener, ctx);\n },\n\n emit: function (name) {\n var data = [].slice.call(arguments, 1);\n var evtArr = ((this.e || (this.e = {}))[name] || []).slice();\n var i = 0;\n var len = evtArr.length;\n\n for (i; i < len; i++) {\n evtArr[i].fn.apply(evtArr[i].ctx, data);\n }\n\n return this;\n },\n\n off: function (name, callback) {\n var e = this.e || (this.e = {});\n var evts = e[name];\n var liveEvents = [];\n\n if (evts && callback) {\n for (var i = 0, len = evts.length; i < len; i++) {\n if (evts[i].fn !== callback && evts[i].fn._ !== callback)\n liveEvents.push(evts[i]);\n }\n }\n\n // Remove event from queue to prevent memory leak\n // Suggested by https://github.com/lazd\n // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910\n\n (liveEvents.length)\n ? e[name] = liveEvents\n : delete e[name];\n\n return this;\n }\n};\n\nmodule.exports = E;\nmodule.exports.TinyEmitter = E;\n\n\n/***/ })\n\n/******/ \t});\n/************************************************************************/\n/******/ \t// The module cache\n/******/ \tvar __webpack_module_cache__ = {};\n/******/ \t\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(__webpack_module_cache__[moduleId]) {\n/******/ \t\t\treturn __webpack_module_cache__[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = __webpack_module_cache__[moduleId] = {\n/******/ \t\t\t// no module.id needed\n/******/ \t\t\t// no module.loaded needed\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/ \t\n/******/ \t\t// Execute the module function\n/******/ \t\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n/******/ \t\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/ \t\n/************************************************************************/\n/******/ \t/* webpack/runtime/compat get default export */\n/******/ \t!function() {\n/******/ \t\t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t\t__webpack_require__.n = function(module) {\n/******/ \t\t\tvar getter = module && module.__esModule ?\n/******/ \t\t\t\tfunction() { return module['default']; } :\n/******/ \t\t\t\tfunction() { return module; };\n/******/ \t\t\t__webpack_require__.d(getter, { a: getter });\n/******/ \t\t\treturn getter;\n/******/ \t\t};\n/******/ \t}();\n/******/ \t\n/******/ \t/* webpack/runtime/define property getters */\n/******/ \t!function() {\n/******/ \t\t// define getter functions for harmony exports\n/******/ \t\t__webpack_require__.d = function(exports, definition) {\n/******/ \t\t\tfor(var key in definition) {\n/******/ \t\t\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n/******/ \t\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n/******/ \t\t\t\t}\n/******/ \t\t\t}\n/******/ \t\t};\n/******/ \t}();\n/******/ \t\n/******/ \t/* webpack/runtime/hasOwnProperty shorthand */\n/******/ \t!function() {\n/******/ \t\t__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }\n/******/ \t}();\n/******/ \t\n/************************************************************************/\n/******/ \t// module exports must be returned from runtime so entry inlining is disabled\n/******/ \t// startup\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(686);\n/******/ })()\n.default;\n});", "/*!\n * escape-html\n * Copyright(c) 2012-2013 TJ Holowaychuk\n * Copyright(c) 2015 Andreas Lubbe\n * Copyright(c) 2015 Tiancheng \"Timothy\" Gu\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module variables.\n * @private\n */\n\nvar matchHtmlRegExp = /[\"'&<>]/;\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = escapeHtml;\n\n/**\n * Escape special characters in the given string of html.\n *\n * @param {string} string The string to escape for inserting into HTML\n * @return {string}\n * @public\n */\n\nfunction escapeHtml(string) {\n var str = '' + string;\n var match = matchHtmlRegExp.exec(str);\n\n if (!match) {\n return str;\n }\n\n var escape;\n var html = '';\n var index = 0;\n var lastIndex = 0;\n\n for (index = match.index; index < str.length; index++) {\n switch (str.charCodeAt(index)) {\n case 34: // \"\n escape = '"';\n break;\n case 38: // &\n escape = '&';\n break;\n case 39: // '\n escape = ''';\n break;\n case 60: // <\n escape = '<';\n break;\n case 62: // >\n escape = '>';\n break;\n default:\n continue;\n }\n\n if (lastIndex !== index) {\n html += str.substring(lastIndex, index);\n }\n\n lastIndex = index + 1;\n html += escape;\n }\n\n return lastIndex !== index\n ? html + str.substring(lastIndex, index)\n : html;\n}\n", "/*\n * Copyright (c) 2016-2023 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport \"focus-visible\"\n\nimport {\n EMPTY,\n NEVER,\n Observable,\n Subject,\n defer,\n delay,\n filter,\n map,\n merge,\n mergeWith,\n shareReplay,\n switchMap\n} from \"rxjs\"\n\nimport { configuration, feature } from \"./_\"\nimport {\n at,\n getActiveElement,\n getOptionalElement,\n requestJSON,\n setLocation,\n setToggle,\n watchDocument,\n watchKeyboard,\n watchLocation,\n watchLocationTarget,\n watchMedia,\n watchPrint,\n watchScript,\n watchViewport\n} from \"./browser\"\nimport {\n getComponentElement,\n getComponentElements,\n mountAnnounce,\n mountBackToTop,\n mountConsent,\n mountContent,\n mountDialog,\n mountHeader,\n mountHeaderTitle,\n mountPalette,\n mountProgress,\n mountSearch,\n mountSearchHiglight,\n mountSidebar,\n mountSource,\n mountTableOfContents,\n mountTabs,\n watchHeader,\n watchMain\n} from \"./components\"\nimport {\n SearchIndex,\n setupClipboardJS,\n setupInstantNavigation,\n setupVersionSelector\n} from \"./integrations\"\nimport {\n patchIndeterminate,\n patchScrollfix,\n patchScrolllock\n} from \"./patches\"\nimport \"./polyfills\"\n\n/* ----------------------------------------------------------------------------\n * Functions - @todo refactor\n * ------------------------------------------------------------------------- */\n\n/**\n * Fetch search index\n *\n * @returns Search index observable\n */\nfunction fetchSearchIndex(): Observable {\n if (location.protocol === \"file:\") {\n return watchScript(\n `${new URL(\"search/search_index.js\", config.base)}`\n )\n .pipe(\n // @ts-ignore - @todo fix typings\n map(() => __index),\n shareReplay(1)\n )\n } else {\n return requestJSON(\n new URL(\"search/search_index.json\", config.base)\n )\n }\n}\n\n/* ----------------------------------------------------------------------------\n * Application\n * ------------------------------------------------------------------------- */\n\n/* Yay, JavaScript is available */\ndocument.documentElement.classList.remove(\"no-js\")\ndocument.documentElement.classList.add(\"js\")\n\n/* Set up navigation observables and subjects */\nconst document$ = watchDocument()\nconst location$ = watchLocation()\nconst target$ = watchLocationTarget(location$)\nconst keyboard$ = watchKeyboard()\n\n/* Set up media observables */\nconst viewport$ = watchViewport()\nconst tablet$ = watchMedia(\"(min-width: 960px)\")\nconst screen$ = watchMedia(\"(min-width: 1220px)\")\nconst print$ = watchPrint()\n\n/* Retrieve search index, if search is enabled */\nconst config = configuration()\nconst index$ = document.forms.namedItem(\"search\")\n ? fetchSearchIndex()\n : NEVER\n\n/* Set up Clipboard.js integration */\nconst alert$ = new Subject()\nsetupClipboardJS({ alert$ })\n\n/* Set up progress indicator */\nconst progress$ = new Subject()\n\n/* Set up instant navigation, if enabled */\nif (feature(\"navigation.instant\"))\n setupInstantNavigation({ location$, viewport$, progress$ })\n .subscribe(document$)\n\n/* Set up version selector */\nif (config.version?.provider === \"mike\")\n setupVersionSelector({ document$ })\n\n/* Always close drawer and search on navigation */\nmerge(location$, target$)\n .pipe(\n delay(125)\n )\n .subscribe(() => {\n setToggle(\"drawer\", false)\n setToggle(\"search\", false)\n })\n\n/* Set up global keyboard handlers */\nkeyboard$\n .pipe(\n filter(({ mode }) => mode === \"global\")\n )\n .subscribe(key => {\n switch (key.type) {\n\n /* Go to previous page */\n case \"p\":\n case \",\":\n const prev = getOptionalElement(\"link[rel=prev]\")\n if (typeof prev !== \"undefined\")\n setLocation(prev)\n break\n\n /* Go to next page */\n case \"n\":\n case \".\":\n const next = getOptionalElement(\"link[rel=next]\")\n if (typeof next !== \"undefined\")\n setLocation(next)\n break\n\n /* Expand navigation, see https://bit.ly/3ZjG5io */\n case \"Enter\":\n const active = getActiveElement()\n if (active instanceof HTMLLabelElement)\n active.click()\n }\n })\n\n/* Set up patches */\npatchIndeterminate({ document$, tablet$ })\npatchScrollfix({ document$ })\npatchScrolllock({ viewport$, tablet$ })\n\n/* Set up header and main area observable */\nconst header$ = watchHeader(getComponentElement(\"header\"), { viewport$ })\nconst main$ = document$\n .pipe(\n map(() => getComponentElement(\"main\")),\n switchMap(el => watchMain(el, { viewport$, header$ })),\n shareReplay(1)\n )\n\n/* Set up control component observables */\nconst control$ = merge(\n\n /* Consent */\n ...getComponentElements(\"consent\")\n .map(el => mountConsent(el, { target$ })),\n\n /* Dialog */\n ...getComponentElements(\"dialog\")\n .map(el => mountDialog(el, { alert$ })),\n\n /* Header */\n ...getComponentElements(\"header\")\n .map(el => mountHeader(el, { viewport$, header$, main$ })),\n\n /* Color palette */\n ...getComponentElements(\"palette\")\n .map(el => mountPalette(el)),\n\n /* Progress bar */\n ...getComponentElements(\"progress\")\n .map(el => mountProgress(el, { progress$ })),\n\n /* Search */\n ...getComponentElements(\"search\")\n .map(el => mountSearch(el, { index$, keyboard$ })),\n\n /* Repository information */\n ...getComponentElements(\"source\")\n .map(el => mountSource(el))\n)\n\n/* Set up content component observables */\nconst content$ = defer(() => merge(\n\n /* Announcement bar */\n ...getComponentElements(\"announce\")\n .map(el => mountAnnounce(el)),\n\n /* Content */\n ...getComponentElements(\"content\")\n .map(el => mountContent(el, { viewport$, target$, print$ })),\n\n /* Search highlighting */\n ...getComponentElements(\"content\")\n .map(el => feature(\"search.highlight\")\n ? mountSearchHiglight(el, { index$, location$ })\n : EMPTY\n ),\n\n /* Header title */\n ...getComponentElements(\"header-title\")\n .map(el => mountHeaderTitle(el, { viewport$, header$ })),\n\n /* Sidebar */\n ...getComponentElements(\"sidebar\")\n .map(el => el.getAttribute(\"data-md-type\") === \"navigation\"\n ? at(screen$, () => mountSidebar(el, { viewport$, header$, main$ }))\n : at(tablet$, () => mountSidebar(el, { viewport$, header$, main$ }))\n ),\n\n /* Navigation tabs */\n ...getComponentElements(\"tabs\")\n .map(el => mountTabs(el, { viewport$, header$ })),\n\n /* Table of contents */\n ...getComponentElements(\"toc\")\n .map(el => mountTableOfContents(el, {\n viewport$, header$, main$, target$\n })),\n\n /* Back-to-top button */\n ...getComponentElements(\"top\")\n .map(el => mountBackToTop(el, { viewport$, header$, main$, target$ }))\n))\n\n/* Set up component observables */\nconst component$ = document$\n .pipe(\n switchMap(() => content$),\n mergeWith(control$),\n shareReplay(1)\n )\n\n/* Subscribe to all components */\ncomponent$.subscribe()\n\n/* ----------------------------------------------------------------------------\n * Exports\n * ------------------------------------------------------------------------- */\n\nwindow.document$ = document$ /* Document observable */\nwindow.location$ = location$ /* Location subject */\nwindow.target$ = target$ /* Location target observable */\nwindow.keyboard$ = keyboard$ /* Keyboard observable */\nwindow.viewport$ = viewport$ /* Viewport observable */\nwindow.tablet$ = tablet$ /* Media tablet observable */\nwindow.screen$ = screen$ /* Media screen observable */\nwindow.print$ = print$ /* Media print observable */\nwindow.alert$ = alert$ /* Alert subject */\nwindow.progress$ = progress$ /* Progress indicator subject */\nwindow.component$ = component$ /* Component observable */\n", "/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n", "/**\n * Returns true if the object is a function.\n * @param value The value to check\n */\nexport function isFunction(value: any): value is (...args: any[]) => any {\n return typeof value === 'function';\n}\n", "/**\n * Used to create Error subclasses until the community moves away from ES5.\n *\n * This is because compiling from TypeScript down to ES5 has issues with subclassing Errors\n * as well as other built-in types: https://github.com/Microsoft/TypeScript/issues/12123\n *\n * @param createImpl A factory function to create the actual constructor implementation. The returned\n * function should be a named function that calls `_super` internally.\n */\nexport function createErrorClass(createImpl: (_super: any) => any): T {\n const _super = (instance: any) => {\n Error.call(instance);\n instance.stack = new Error().stack;\n };\n\n const ctorFunc = createImpl(_super);\n ctorFunc.prototype = Object.create(Error.prototype);\n ctorFunc.prototype.constructor = ctorFunc;\n return ctorFunc;\n}\n", "import { createErrorClass } from './createErrorClass';\n\nexport interface UnsubscriptionError extends Error {\n readonly errors: any[];\n}\n\nexport interface UnsubscriptionErrorCtor {\n /**\n * @deprecated Internal implementation detail. Do not construct error instances.\n * Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269\n */\n new (errors: any[]): UnsubscriptionError;\n}\n\n/**\n * An error thrown when one or more errors have occurred during the\n * `unsubscribe` of a {@link Subscription}.\n */\nexport const UnsubscriptionError: UnsubscriptionErrorCtor = createErrorClass(\n (_super) =>\n function UnsubscriptionErrorImpl(this: any, errors: (Error | string)[]) {\n _super(this);\n this.message = errors\n ? `${errors.length} errors occurred during unsubscription:\n${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\\n ')}`\n : '';\n this.name = 'UnsubscriptionError';\n this.errors = errors;\n }\n);\n", "/**\n * Removes an item from an array, mutating it.\n * @param arr The array to remove the item from\n * @param item The item to remove\n */\nexport function arrRemove(arr: T[] | undefined | null, item: T) {\n if (arr) {\n const index = arr.indexOf(item);\n 0 <= index && arr.splice(index, 1);\n }\n}\n", "import { isFunction } from './util/isFunction';\nimport { UnsubscriptionError } from './util/UnsubscriptionError';\nimport { SubscriptionLike, TeardownLogic, Unsubscribable } from './types';\nimport { arrRemove } from './util/arrRemove';\n\n/**\n * Represents a disposable resource, such as the execution of an Observable. A\n * Subscription has one important method, `unsubscribe`, that takes no argument\n * and just disposes the resource held by the subscription.\n *\n * Additionally, subscriptions may be grouped together through the `add()`\n * method, which will attach a child Subscription to the current Subscription.\n * When a Subscription is unsubscribed, all its children (and its grandchildren)\n * will be unsubscribed as well.\n *\n * @class Subscription\n */\nexport class Subscription implements SubscriptionLike {\n /** @nocollapse */\n public static EMPTY = (() => {\n const empty = new Subscription();\n empty.closed = true;\n return empty;\n })();\n\n /**\n * A flag to indicate whether this Subscription has already been unsubscribed.\n */\n public closed = false;\n\n private _parentage: Subscription[] | Subscription | null = null;\n\n /**\n * The list of registered finalizers to execute upon unsubscription. Adding and removing from this\n * list occurs in the {@link #add} and {@link #remove} methods.\n */\n private _finalizers: Exclude[] | null = null;\n\n /**\n * @param initialTeardown A function executed first as part of the finalization\n * process that is kicked off when {@link #unsubscribe} is called.\n */\n constructor(private initialTeardown?: () => void) {}\n\n /**\n * Disposes the resources held by the subscription. May, for instance, cancel\n * an ongoing Observable execution or cancel any other type of work that\n * started when the Subscription was created.\n * @return {void}\n */\n unsubscribe(): void {\n let errors: any[] | undefined;\n\n if (!this.closed) {\n this.closed = true;\n\n // Remove this from it's parents.\n const { _parentage } = this;\n if (_parentage) {\n this._parentage = null;\n if (Array.isArray(_parentage)) {\n for (const parent of _parentage) {\n parent.remove(this);\n }\n } else {\n _parentage.remove(this);\n }\n }\n\n const { initialTeardown: initialFinalizer } = this;\n if (isFunction(initialFinalizer)) {\n try {\n initialFinalizer();\n } catch (e) {\n errors = e instanceof UnsubscriptionError ? e.errors : [e];\n }\n }\n\n const { _finalizers } = this;\n if (_finalizers) {\n this._finalizers = null;\n for (const finalizer of _finalizers) {\n try {\n execFinalizer(finalizer);\n } catch (err) {\n errors = errors ?? [];\n if (err instanceof UnsubscriptionError) {\n errors = [...errors, ...err.errors];\n } else {\n errors.push(err);\n }\n }\n }\n }\n\n if (errors) {\n throw new UnsubscriptionError(errors);\n }\n }\n }\n\n /**\n * Adds a finalizer to this subscription, so that finalization will be unsubscribed/called\n * when this subscription is unsubscribed. If this subscription is already {@link #closed},\n * because it has already been unsubscribed, then whatever finalizer is passed to it\n * will automatically be executed (unless the finalizer itself is also a closed subscription).\n *\n * Closed Subscriptions cannot be added as finalizers to any subscription. Adding a closed\n * subscription to a any subscription will result in no operation. (A noop).\n *\n * Adding a subscription to itself, or adding `null` or `undefined` will not perform any\n * operation at all. (A noop).\n *\n * `Subscription` instances that are added to this instance will automatically remove themselves\n * if they are unsubscribed. Functions and {@link Unsubscribable} objects that you wish to remove\n * will need to be removed manually with {@link #remove}\n *\n * @param teardown The finalization logic to add to this subscription.\n */\n add(teardown: TeardownLogic): void {\n // Only add the finalizer if it's not undefined\n // and don't add a subscription to itself.\n if (teardown && teardown !== this) {\n if (this.closed) {\n // If this subscription is already closed,\n // execute whatever finalizer is handed to it automatically.\n execFinalizer(teardown);\n } else {\n if (teardown instanceof Subscription) {\n // We don't add closed subscriptions, and we don't add the same subscription\n // twice. Subscription unsubscribe is idempotent.\n if (teardown.closed || teardown._hasParent(this)) {\n return;\n }\n teardown._addParent(this);\n }\n (this._finalizers = this._finalizers ?? []).push(teardown);\n }\n }\n }\n\n /**\n * Checks to see if a this subscription already has a particular parent.\n * This will signal that this subscription has already been added to the parent in question.\n * @param parent the parent to check for\n */\n private _hasParent(parent: Subscription) {\n const { _parentage } = this;\n return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));\n }\n\n /**\n * Adds a parent to this subscription so it can be removed from the parent if it\n * unsubscribes on it's own.\n *\n * NOTE: THIS ASSUMES THAT {@link _hasParent} HAS ALREADY BEEN CHECKED.\n * @param parent The parent subscription to add\n */\n private _addParent(parent: Subscription) {\n const { _parentage } = this;\n this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;\n }\n\n /**\n * Called on a child when it is removed via {@link #remove}.\n * @param parent The parent to remove\n */\n private _removeParent(parent: Subscription) {\n const { _parentage } = this;\n if (_parentage === parent) {\n this._parentage = null;\n } else if (Array.isArray(_parentage)) {\n arrRemove(_parentage, parent);\n }\n }\n\n /**\n * Removes a finalizer from this subscription that was previously added with the {@link #add} method.\n *\n * Note that `Subscription` instances, when unsubscribed, will automatically remove themselves\n * from every other `Subscription` they have been added to. This means that using the `remove` method\n * is not a common thing and should be used thoughtfully.\n *\n * If you add the same finalizer instance of a function or an unsubscribable object to a `Subscription` instance\n * more than once, you will need to call `remove` the same number of times to remove all instances.\n *\n * All finalizer instances are removed to free up memory upon unsubscription.\n *\n * @param teardown The finalizer to remove from this subscription\n */\n remove(teardown: Exclude): void {\n const { _finalizers } = this;\n _finalizers && arrRemove(_finalizers, teardown);\n\n if (teardown instanceof Subscription) {\n teardown._removeParent(this);\n }\n }\n}\n\nexport const EMPTY_SUBSCRIPTION = Subscription.EMPTY;\n\nexport function isSubscription(value: any): value is Subscription {\n return (\n value instanceof Subscription ||\n (value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe))\n );\n}\n\nfunction execFinalizer(finalizer: Unsubscribable | (() => void)) {\n if (isFunction(finalizer)) {\n finalizer();\n } else {\n finalizer.unsubscribe();\n }\n}\n", "import { Subscriber } from './Subscriber';\nimport { ObservableNotification } from './types';\n\n/**\n * The {@link GlobalConfig} object for RxJS. It is used to configure things\n * like how to react on unhandled errors.\n */\nexport const config: GlobalConfig = {\n onUnhandledError: null,\n onStoppedNotification: null,\n Promise: undefined,\n useDeprecatedSynchronousErrorHandling: false,\n useDeprecatedNextContext: false,\n};\n\n/**\n * The global configuration object for RxJS, used to configure things\n * like how to react on unhandled errors. Accessible via {@link config}\n * object.\n */\nexport interface GlobalConfig {\n /**\n * A registration point for unhandled errors from RxJS. These are errors that\n * cannot were not handled by consuming code in the usual subscription path. For\n * example, if you have this configured, and you subscribe to an observable without\n * providing an error handler, errors from that subscription will end up here. This\n * will _always_ be called asynchronously on another job in the runtime. This is because\n * we do not want errors thrown in this user-configured handler to interfere with the\n * behavior of the library.\n */\n onUnhandledError: ((err: any) => void) | null;\n\n /**\n * A registration point for notifications that cannot be sent to subscribers because they\n * have completed, errored or have been explicitly unsubscribed. By default, next, complete\n * and error notifications sent to stopped subscribers are noops. However, sometimes callers\n * might want a different behavior. For example, with sources that attempt to report errors\n * to stopped subscribers, a caller can configure RxJS to throw an unhandled error instead.\n * This will _always_ be called asynchronously on another job in the runtime. This is because\n * we do not want errors thrown in this user-configured handler to interfere with the\n * behavior of the library.\n */\n onStoppedNotification: ((notification: ObservableNotification, subscriber: Subscriber) => void) | null;\n\n /**\n * The promise constructor used by default for {@link Observable#toPromise toPromise} and {@link Observable#forEach forEach}\n * methods.\n *\n * @deprecated As of version 8, RxJS will no longer support this sort of injection of a\n * Promise constructor. If you need a Promise implementation other than native promises,\n * please polyfill/patch Promise as you see appropriate. Will be removed in v8.\n */\n Promise?: PromiseConstructorLike;\n\n /**\n * If true, turns on synchronous error rethrowing, which is a deprecated behavior\n * in v6 and higher. This behavior enables bad patterns like wrapping a subscribe\n * call in a try/catch block. It also enables producer interference, a nasty bug\n * where a multicast can be broken for all observers by a downstream consumer with\n * an unhandled error. DO NOT USE THIS FLAG UNLESS IT'S NEEDED TO BUY TIME\n * FOR MIGRATION REASONS.\n *\n * @deprecated As of version 8, RxJS will no longer support synchronous throwing\n * of unhandled errors. All errors will be thrown on a separate call stack to prevent bad\n * behaviors described above. Will be removed in v8.\n */\n useDeprecatedSynchronousErrorHandling: boolean;\n\n /**\n * If true, enables an as-of-yet undocumented feature from v5: The ability to access\n * `unsubscribe()` via `this` context in `next` functions created in observers passed\n * to `subscribe`.\n *\n * This is being removed because the performance was severely problematic, and it could also cause\n * issues when types other than POJOs are passed to subscribe as subscribers, as they will likely have\n * their `this` context overwritten.\n *\n * @deprecated As of version 8, RxJS will no longer support altering the\n * context of next functions provided as part of an observer to Subscribe. Instead,\n * you will have access to a subscription or a signal or token that will allow you to do things like\n * unsubscribe and test closed status. Will be removed in v8.\n */\n useDeprecatedNextContext: boolean;\n}\n", "import type { TimerHandle } from './timerHandle';\ntype SetTimeoutFunction = (handler: () => void, timeout?: number, ...args: any[]) => TimerHandle;\ntype ClearTimeoutFunction = (handle: TimerHandle) => void;\n\ninterface TimeoutProvider {\n setTimeout: SetTimeoutFunction;\n clearTimeout: ClearTimeoutFunction;\n delegate:\n | {\n setTimeout: SetTimeoutFunction;\n clearTimeout: ClearTimeoutFunction;\n }\n | undefined;\n}\n\nexport const timeoutProvider: TimeoutProvider = {\n // When accessing the delegate, use the variable rather than `this` so that\n // the functions can be called without being bound to the provider.\n setTimeout(handler: () => void, timeout?: number, ...args) {\n const { delegate } = timeoutProvider;\n if (delegate?.setTimeout) {\n return delegate.setTimeout(handler, timeout, ...args);\n }\n return setTimeout(handler, timeout, ...args);\n },\n clearTimeout(handle) {\n const { delegate } = timeoutProvider;\n return (delegate?.clearTimeout || clearTimeout)(handle as any);\n },\n delegate: undefined,\n};\n", "import { config } from '../config';\nimport { timeoutProvider } from '../scheduler/timeoutProvider';\n\n/**\n * Handles an error on another job either with the user-configured {@link onUnhandledError},\n * or by throwing it on that new job so it can be picked up by `window.onerror`, `process.on('error')`, etc.\n *\n * This should be called whenever there is an error that is out-of-band with the subscription\n * or when an error hits a terminal boundary of the subscription and no error handler was provided.\n *\n * @param err the error to report\n */\nexport function reportUnhandledError(err: any) {\n timeoutProvider.setTimeout(() => {\n const { onUnhandledError } = config;\n if (onUnhandledError) {\n // Execute the user-configured error handler.\n onUnhandledError(err);\n } else {\n // Throw so it is picked up by the runtime's uncaught error mechanism.\n throw err;\n }\n });\n}\n", "/* tslint:disable:no-empty */\nexport function noop() { }\n", "import { CompleteNotification, NextNotification, ErrorNotification } from './types';\n\n/**\n * A completion object optimized for memory use and created to be the\n * same \"shape\" as other notifications in v8.\n * @internal\n */\nexport const COMPLETE_NOTIFICATION = (() => createNotification('C', undefined, undefined) as CompleteNotification)();\n\n/**\n * Internal use only. Creates an optimized error notification that is the same \"shape\"\n * as other notifications.\n * @internal\n */\nexport function errorNotification(error: any): ErrorNotification {\n return createNotification('E', undefined, error) as any;\n}\n\n/**\n * Internal use only. Creates an optimized next notification that is the same \"shape\"\n * as other notifications.\n * @internal\n */\nexport function nextNotification(value: T) {\n return createNotification('N', value, undefined) as NextNotification;\n}\n\n/**\n * Ensures that all notifications created internally have the same \"shape\" in v8.\n *\n * TODO: This is only exported to support a crazy legacy test in `groupBy`.\n * @internal\n */\nexport function createNotification(kind: 'N' | 'E' | 'C', value: any, error: any) {\n return {\n kind,\n value,\n error,\n };\n}\n", "import { config } from '../config';\n\nlet context: { errorThrown: boolean; error: any } | null = null;\n\n/**\n * Handles dealing with errors for super-gross mode. Creates a context, in which\n * any synchronously thrown errors will be passed to {@link captureError}. Which\n * will record the error such that it will be rethrown after the call back is complete.\n * TODO: Remove in v8\n * @param cb An immediately executed function.\n */\nexport function errorContext(cb: () => void) {\n if (config.useDeprecatedSynchronousErrorHandling) {\n const isRoot = !context;\n if (isRoot) {\n context = { errorThrown: false, error: null };\n }\n cb();\n if (isRoot) {\n const { errorThrown, error } = context!;\n context = null;\n if (errorThrown) {\n throw error;\n }\n }\n } else {\n // This is the general non-deprecated path for everyone that\n // isn't crazy enough to use super-gross mode (useDeprecatedSynchronousErrorHandling)\n cb();\n }\n}\n\n/**\n * Captures errors only in super-gross mode.\n * @param err the error to capture\n */\nexport function captureError(err: any) {\n if (config.useDeprecatedSynchronousErrorHandling && context) {\n context.errorThrown = true;\n context.error = err;\n }\n}\n", "import { isFunction } from './util/isFunction';\nimport { Observer, ObservableNotification } from './types';\nimport { isSubscription, Subscription } from './Subscription';\nimport { config } from './config';\nimport { reportUnhandledError } from './util/reportUnhandledError';\nimport { noop } from './util/noop';\nimport { nextNotification, errorNotification, COMPLETE_NOTIFICATION } from './NotificationFactories';\nimport { timeoutProvider } from './scheduler/timeoutProvider';\nimport { captureError } from './util/errorContext';\n\n/**\n * Implements the {@link Observer} interface and extends the\n * {@link Subscription} class. While the {@link Observer} is the public API for\n * consuming the values of an {@link Observable}, all Observers get converted to\n * a Subscriber, in order to provide Subscription-like capabilities such as\n * `unsubscribe`. Subscriber is a common type in RxJS, and crucial for\n * implementing operators, but it is rarely used as a public API.\n *\n * @class Subscriber\n */\nexport class Subscriber extends Subscription implements Observer {\n /**\n * A static factory for a Subscriber, given a (potentially partial) definition\n * of an Observer.\n * @param next The `next` callback of an Observer.\n * @param error The `error` callback of an\n * Observer.\n * @param complete The `complete` callback of an\n * Observer.\n * @return A Subscriber wrapping the (partially defined)\n * Observer represented by the given arguments.\n * @nocollapse\n * @deprecated Do not use. Will be removed in v8. There is no replacement for this\n * method, and there is no reason to be creating instances of `Subscriber` directly.\n * If you have a specific use case, please file an issue.\n */\n static create(next?: (x?: T) => void, error?: (e?: any) => void, complete?: () => void): Subscriber {\n return new SafeSubscriber(next, error, complete);\n }\n\n /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */\n protected isStopped: boolean = false;\n /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */\n protected destination: Subscriber | Observer; // this `any` is the escape hatch to erase extra type param (e.g. R)\n\n /**\n * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.\n * There is no reason to directly create an instance of Subscriber. This type is exported for typings reasons.\n */\n constructor(destination?: Subscriber | Observer) {\n super();\n if (destination) {\n this.destination = destination;\n // Automatically chain subscriptions together here.\n // if destination is a Subscription, then it is a Subscriber.\n if (isSubscription(destination)) {\n destination.add(this);\n }\n } else {\n this.destination = EMPTY_OBSERVER;\n }\n }\n\n /**\n * The {@link Observer} callback to receive notifications of type `next` from\n * the Observable, with a value. The Observable may call this method 0 or more\n * times.\n * @param {T} [value] The `next` value.\n * @return {void}\n */\n next(value?: T): void {\n if (this.isStopped) {\n handleStoppedNotification(nextNotification(value), this);\n } else {\n this._next(value!);\n }\n }\n\n /**\n * The {@link Observer} callback to receive notifications of type `error` from\n * the Observable, with an attached `Error`. Notifies the Observer that\n * the Observable has experienced an error condition.\n * @param {any} [err] The `error` exception.\n * @return {void}\n */\n error(err?: any): void {\n if (this.isStopped) {\n handleStoppedNotification(errorNotification(err), this);\n } else {\n this.isStopped = true;\n this._error(err);\n }\n }\n\n /**\n * The {@link Observer} callback to receive a valueless notification of type\n * `complete` from the Observable. Notifies the Observer that the Observable\n * has finished sending push-based notifications.\n * @return {void}\n */\n complete(): void {\n if (this.isStopped) {\n handleStoppedNotification(COMPLETE_NOTIFICATION, this);\n } else {\n this.isStopped = true;\n this._complete();\n }\n }\n\n unsubscribe(): void {\n if (!this.closed) {\n this.isStopped = true;\n super.unsubscribe();\n this.destination = null!;\n }\n }\n\n protected _next(value: T): void {\n this.destination.next(value);\n }\n\n protected _error(err: any): void {\n try {\n this.destination.error(err);\n } finally {\n this.unsubscribe();\n }\n }\n\n protected _complete(): void {\n try {\n this.destination.complete();\n } finally {\n this.unsubscribe();\n }\n }\n}\n\n/**\n * This bind is captured here because we want to be able to have\n * compatibility with monoid libraries that tend to use a method named\n * `bind`. In particular, a library called Monio requires this.\n */\nconst _bind = Function.prototype.bind;\n\nfunction bind any>(fn: Fn, thisArg: any): Fn {\n return _bind.call(fn, thisArg);\n}\n\n/**\n * Internal optimization only, DO NOT EXPOSE.\n * @internal\n */\nclass ConsumerObserver implements Observer {\n constructor(private partialObserver: Partial>) {}\n\n next(value: T): void {\n const { partialObserver } = this;\n if (partialObserver.next) {\n try {\n partialObserver.next(value);\n } catch (error) {\n handleUnhandledError(error);\n }\n }\n }\n\n error(err: any): void {\n const { partialObserver } = this;\n if (partialObserver.error) {\n try {\n partialObserver.error(err);\n } catch (error) {\n handleUnhandledError(error);\n }\n } else {\n handleUnhandledError(err);\n }\n }\n\n complete(): void {\n const { partialObserver } = this;\n if (partialObserver.complete) {\n try {\n partialObserver.complete();\n } catch (error) {\n handleUnhandledError(error);\n }\n }\n }\n}\n\nexport class SafeSubscriber extends Subscriber {\n constructor(\n observerOrNext?: Partial> | ((value: T) => void) | null,\n error?: ((e?: any) => void) | null,\n complete?: (() => void) | null\n ) {\n super();\n\n let partialObserver: Partial>;\n if (isFunction(observerOrNext) || !observerOrNext) {\n // The first argument is a function, not an observer. The next\n // two arguments *could* be observers, or they could be empty.\n partialObserver = {\n next: (observerOrNext ?? undefined) as (((value: T) => void) | undefined),\n error: error ?? undefined,\n complete: complete ?? undefined,\n };\n } else {\n // The first argument is a partial observer.\n let context: any;\n if (this && config.useDeprecatedNextContext) {\n // This is a deprecated path that made `this.unsubscribe()` available in\n // next handler functions passed to subscribe. This only exists behind a flag\n // now, as it is *very* slow.\n context = Object.create(observerOrNext);\n context.unsubscribe = () => this.unsubscribe();\n partialObserver = {\n next: observerOrNext.next && bind(observerOrNext.next, context),\n error: observerOrNext.error && bind(observerOrNext.error, context),\n complete: observerOrNext.complete && bind(observerOrNext.complete, context),\n };\n } else {\n // The \"normal\" path. Just use the partial observer directly.\n partialObserver = observerOrNext;\n }\n }\n\n // Wrap the partial observer to ensure it's a full observer, and\n // make sure proper error handling is accounted for.\n this.destination = new ConsumerObserver(partialObserver);\n }\n}\n\nfunction handleUnhandledError(error: any) {\n if (config.useDeprecatedSynchronousErrorHandling) {\n captureError(error);\n } else {\n // Ideal path, we report this as an unhandled error,\n // which is thrown on a new call stack.\n reportUnhandledError(error);\n }\n}\n\n/**\n * An error handler used when no error handler was supplied\n * to the SafeSubscriber -- meaning no error handler was supplied\n * do the `subscribe` call on our observable.\n * @param err The error to handle\n */\nfunction defaultErrorHandler(err: any) {\n throw err;\n}\n\n/**\n * A handler for notifications that cannot be sent to a stopped subscriber.\n * @param notification The notification being sent\n * @param subscriber The stopped subscriber\n */\nfunction handleStoppedNotification(notification: ObservableNotification, subscriber: Subscriber) {\n const { onStoppedNotification } = config;\n onStoppedNotification && timeoutProvider.setTimeout(() => onStoppedNotification(notification, subscriber));\n}\n\n/**\n * The observer used as a stub for subscriptions where the user did not\n * pass any arguments to `subscribe`. Comes with the default error handling\n * behavior.\n */\nexport const EMPTY_OBSERVER: Readonly> & { closed: true } = {\n closed: true,\n next: noop,\n error: defaultErrorHandler,\n complete: noop,\n};\n", "/**\n * Symbol.observable or a string \"@@observable\". Used for interop\n *\n * @deprecated We will no longer be exporting this symbol in upcoming versions of RxJS.\n * Instead polyfill and use Symbol.observable directly *or* use https://www.npmjs.com/package/symbol-observable\n */\nexport const observable: string | symbol = (() => (typeof Symbol === 'function' && Symbol.observable) || '@@observable')();\n", "/**\n * This function takes one parameter and just returns it. Simply put,\n * this is like `(x: T): T => x`.\n *\n * ## Examples\n *\n * This is useful in some cases when using things like `mergeMap`\n *\n * ```ts\n * import { interval, take, map, range, mergeMap, identity } from 'rxjs';\n *\n * const source$ = interval(1000).pipe(take(5));\n *\n * const result$ = source$.pipe(\n * map(i => range(i)),\n * mergeMap(identity) // same as mergeMap(x => x)\n * );\n *\n * result$.subscribe({\n * next: console.log\n * });\n * ```\n *\n * Or when you want to selectively apply an operator\n *\n * ```ts\n * import { interval, take, identity } from 'rxjs';\n *\n * const shouldLimit = () => Math.random() < 0.5;\n *\n * const source$ = interval(1000);\n *\n * const result$ = source$.pipe(shouldLimit() ? take(5) : identity);\n *\n * result$.subscribe({\n * next: console.log\n * });\n * ```\n *\n * @param x Any value that is returned by this function\n * @returns The value passed as the first parameter to this function\n */\nexport function identity(x: T): T {\n return x;\n}\n", "import { identity } from './identity';\nimport { UnaryFunction } from '../types';\n\nexport function pipe(): typeof identity;\nexport function pipe(fn1: UnaryFunction): UnaryFunction;\nexport function pipe(fn1: UnaryFunction, fn2: UnaryFunction): UnaryFunction;\nexport function pipe(fn1: UnaryFunction, fn2: UnaryFunction, fn3: UnaryFunction): UnaryFunction;\nexport function pipe(\n fn1: UnaryFunction,\n fn2: UnaryFunction,\n fn3: UnaryFunction,\n fn4: UnaryFunction\n): UnaryFunction;\nexport function pipe(\n fn1: UnaryFunction,\n fn2: UnaryFunction,\n fn3: UnaryFunction,\n fn4: UnaryFunction,\n fn5: UnaryFunction\n): UnaryFunction;\nexport function pipe(\n fn1: UnaryFunction,\n fn2: UnaryFunction,\n fn3: UnaryFunction,\n fn4: UnaryFunction,\n fn5: UnaryFunction,\n fn6: UnaryFunction\n): UnaryFunction;\nexport function pipe(\n fn1: UnaryFunction,\n fn2: UnaryFunction,\n fn3: UnaryFunction,\n fn4: UnaryFunction,\n fn5: UnaryFunction,\n fn6: UnaryFunction,\n fn7: UnaryFunction\n): UnaryFunction;\nexport function pipe(\n fn1: UnaryFunction,\n fn2: UnaryFunction,\n fn3: UnaryFunction,\n fn4: UnaryFunction,\n fn5: UnaryFunction,\n fn6: UnaryFunction,\n fn7: UnaryFunction,\n fn8: UnaryFunction\n): UnaryFunction;\nexport function pipe(\n fn1: UnaryFunction,\n fn2: UnaryFunction,\n fn3: UnaryFunction,\n fn4: UnaryFunction,\n fn5: UnaryFunction,\n fn6: UnaryFunction,\n fn7: UnaryFunction,\n fn8: UnaryFunction,\n fn9: UnaryFunction\n): UnaryFunction;\nexport function pipe(\n fn1: UnaryFunction,\n fn2: UnaryFunction,\n fn3: UnaryFunction,\n fn4: UnaryFunction,\n fn5: UnaryFunction,\n fn6: UnaryFunction,\n fn7: UnaryFunction,\n fn8: UnaryFunction,\n fn9: UnaryFunction,\n ...fns: UnaryFunction[]\n): UnaryFunction;\n\n/**\n * pipe() can be called on one or more functions, each of which can take one argument (\"UnaryFunction\")\n * and uses it to return a value.\n * It returns a function that takes one argument, passes it to the first UnaryFunction, and then\n * passes the result to the next one, passes that result to the next one, and so on. \n */\nexport function pipe(...fns: Array>): UnaryFunction {\n return pipeFromArray(fns);\n}\n\n/** @internal */\nexport function pipeFromArray(fns: Array>): UnaryFunction {\n if (fns.length === 0) {\n return identity as UnaryFunction;\n }\n\n if (fns.length === 1) {\n return fns[0];\n }\n\n return function piped(input: T): R {\n return fns.reduce((prev: any, fn: UnaryFunction) => fn(prev), input as any);\n };\n}\n", "import { Operator } from './Operator';\nimport { SafeSubscriber, Subscriber } from './Subscriber';\nimport { isSubscription, Subscription } from './Subscription';\nimport { TeardownLogic, OperatorFunction, Subscribable, Observer } from './types';\nimport { observable as Symbol_observable } from './symbol/observable';\nimport { pipeFromArray } from './util/pipe';\nimport { config } from './config';\nimport { isFunction } from './util/isFunction';\nimport { errorContext } from './util/errorContext';\n\n/**\n * A representation of any set of values over any amount of time. This is the most basic building block\n * of RxJS.\n *\n * @class Observable\n */\nexport class Observable implements Subscribable {\n /**\n * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.\n */\n source: Observable | undefined;\n\n /**\n * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.\n */\n operator: Operator | undefined;\n\n /**\n * @constructor\n * @param {Function} subscribe the function that is called when the Observable is\n * initially subscribed to. This function is given a Subscriber, to which new values\n * can be `next`ed, or an `error` method can be called to raise an error, or\n * `complete` can be called to notify of a successful completion.\n */\n constructor(subscribe?: (this: Observable, subscriber: Subscriber) => TeardownLogic) {\n if (subscribe) {\n this._subscribe = subscribe;\n }\n }\n\n // HACK: Since TypeScript inherits static properties too, we have to\n // fight against TypeScript here so Subject can have a different static create signature\n /**\n * Creates a new Observable by calling the Observable constructor\n * @owner Observable\n * @method create\n * @param {Function} subscribe? the subscriber function to be passed to the Observable constructor\n * @return {Observable} a new observable\n * @nocollapse\n * @deprecated Use `new Observable()` instead. Will be removed in v8.\n */\n static create: (...args: any[]) => any = (subscribe?: (subscriber: Subscriber) => TeardownLogic) => {\n return new Observable(subscribe);\n };\n\n /**\n * Creates a new Observable, with this Observable instance as the source, and the passed\n * operator defined as the new observable's operator.\n * @method lift\n * @param operator the operator defining the operation to take on the observable\n * @return a new observable with the Operator applied\n * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.\n * If you have implemented an operator using `lift`, it is recommended that you create an\n * operator by simply returning `new Observable()` directly. See \"Creating new operators from\n * scratch\" section here: https://rxjs.dev/guide/operators\n */\n lift(operator?: Operator): Observable {\n const observable = new Observable();\n observable.source = this;\n observable.operator = operator;\n return observable;\n }\n\n subscribe(observerOrNext?: Partial> | ((value: T) => void)): Subscription;\n /** @deprecated Instead of passing separate callback arguments, use an observer argument. Signatures taking separate callback arguments will be removed in v8. Details: https://rxjs.dev/deprecations/subscribe-arguments */\n subscribe(next?: ((value: T) => void) | null, error?: ((error: any) => void) | null, complete?: (() => void) | null): Subscription;\n /**\n * Invokes an execution of an Observable and registers Observer handlers for notifications it will emit.\n *\n * Use it when you have all these Observables, but still nothing is happening.\n *\n * `subscribe` is not a regular operator, but a method that calls Observable's internal `subscribe` function. It\n * might be for example a function that you passed to Observable's constructor, but most of the time it is\n * a library implementation, which defines what will be emitted by an Observable, and when it be will emitted. This means\n * that calling `subscribe` is actually the moment when Observable starts its work, not when it is created, as it is often\n * the thought.\n *\n * Apart from starting the execution of an Observable, this method allows you to listen for values\n * that an Observable emits, as well as for when it completes or errors. You can achieve this in two\n * of the following ways.\n *\n * The first way is creating an object that implements {@link Observer} interface. It should have methods\n * defined by that interface, but note that it should be just a regular JavaScript object, which you can create\n * yourself in any way you want (ES6 class, classic function constructor, object literal etc.). In particular, do\n * not attempt to use any RxJS implementation details to create Observers - you don't need them. Remember also\n * that your object does not have to implement all methods. If you find yourself creating a method that doesn't\n * do anything, you can simply omit it. Note however, if the `error` method is not provided and an error happens,\n * it will be thrown asynchronously. Errors thrown asynchronously cannot be caught using `try`/`catch`. Instead,\n * use the {@link onUnhandledError} configuration option or use a runtime handler (like `window.onerror` or\n * `process.on('error)`) to be notified of unhandled errors. Because of this, it's recommended that you provide\n * an `error` method to avoid missing thrown errors.\n *\n * The second way is to give up on Observer object altogether and simply provide callback functions in place of its methods.\n * This means you can provide three functions as arguments to `subscribe`, where the first function is equivalent\n * of a `next` method, the second of an `error` method and the third of a `complete` method. Just as in case of an Observer,\n * if you do not need to listen for something, you can omit a function by passing `undefined` or `null`,\n * since `subscribe` recognizes these functions by where they were placed in function call. When it comes\n * to the `error` function, as with an Observer, if not provided, errors emitted by an Observable will be thrown asynchronously.\n *\n * You can, however, subscribe with no parameters at all. This may be the case where you're not interested in terminal events\n * and you also handled emissions internally by using operators (e.g. using `tap`).\n *\n * Whichever style of calling `subscribe` you use, in both cases it returns a Subscription object.\n * This object allows you to call `unsubscribe` on it, which in turn will stop the work that an Observable does and will clean\n * up all resources that an Observable used. Note that cancelling a subscription will not call `complete` callback\n * provided to `subscribe` function, which is reserved for a regular completion signal that comes from an Observable.\n *\n * Remember that callbacks provided to `subscribe` are not guaranteed to be called asynchronously.\n * It is an Observable itself that decides when these functions will be called. For example {@link of}\n * by default emits all its values synchronously. Always check documentation for how given Observable\n * will behave when subscribed and if its default behavior can be modified with a `scheduler`.\n *\n * #### Examples\n *\n * Subscribe with an {@link guide/observer Observer}\n *\n * ```ts\n * import { of } from 'rxjs';\n *\n * const sumObserver = {\n * sum: 0,\n * next(value) {\n * console.log('Adding: ' + value);\n * this.sum = this.sum + value;\n * },\n * error() {\n * // We actually could just remove this method,\n * // since we do not really care about errors right now.\n * },\n * complete() {\n * console.log('Sum equals: ' + this.sum);\n * }\n * };\n *\n * of(1, 2, 3) // Synchronously emits 1, 2, 3 and then completes.\n * .subscribe(sumObserver);\n *\n * // Logs:\n * // 'Adding: 1'\n * // 'Adding: 2'\n * // 'Adding: 3'\n * // 'Sum equals: 6'\n * ```\n *\n * Subscribe with functions ({@link deprecations/subscribe-arguments deprecated})\n *\n * ```ts\n * import { of } from 'rxjs'\n *\n * let sum = 0;\n *\n * of(1, 2, 3).subscribe(\n * value => {\n * console.log('Adding: ' + value);\n * sum = sum + value;\n * },\n * undefined,\n * () => console.log('Sum equals: ' + sum)\n * );\n *\n * // Logs:\n * // 'Adding: 1'\n * // 'Adding: 2'\n * // 'Adding: 3'\n * // 'Sum equals: 6'\n * ```\n *\n * Cancel a subscription\n *\n * ```ts\n * import { interval } from 'rxjs';\n *\n * const subscription = interval(1000).subscribe({\n * next(num) {\n * console.log(num)\n * },\n * complete() {\n * // Will not be called, even when cancelling subscription.\n * console.log('completed!');\n * }\n * });\n *\n * setTimeout(() => {\n * subscription.unsubscribe();\n * console.log('unsubscribed!');\n * }, 2500);\n *\n * // Logs:\n * // 0 after 1s\n * // 1 after 2s\n * // 'unsubscribed!' after 2.5s\n * ```\n *\n * @param {Observer|Function} observerOrNext (optional) Either an observer with methods to be called,\n * or the first of three possible handlers, which is the handler for each value emitted from the subscribed\n * Observable.\n * @param {Function} error (optional) A handler for a terminal event resulting from an error. If no error handler is provided,\n * the error will be thrown asynchronously as unhandled.\n * @param {Function} complete (optional) A handler for a terminal event resulting from successful completion.\n * @return {Subscription} a subscription reference to the registered handlers\n * @method subscribe\n */\n subscribe(\n observerOrNext?: Partial> | ((value: T) => void) | null,\n error?: ((error: any) => void) | null,\n complete?: (() => void) | null\n ): Subscription {\n const subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);\n\n errorContext(() => {\n const { operator, source } = this;\n subscriber.add(\n operator\n ? // We're dealing with a subscription in the\n // operator chain to one of our lifted operators.\n operator.call(subscriber, source)\n : source\n ? // If `source` has a value, but `operator` does not, something that\n // had intimate knowledge of our API, like our `Subject`, must have\n // set it. We're going to just call `_subscribe` directly.\n this._subscribe(subscriber)\n : // In all other cases, we're likely wrapping a user-provided initializer\n // function, so we need to catch errors and handle them appropriately.\n this._trySubscribe(subscriber)\n );\n });\n\n return subscriber;\n }\n\n /** @internal */\n protected _trySubscribe(sink: Subscriber): TeardownLogic {\n try {\n return this._subscribe(sink);\n } catch (err) {\n // We don't need to return anything in this case,\n // because it's just going to try to `add()` to a subscription\n // above.\n sink.error(err);\n }\n }\n\n /**\n * Used as a NON-CANCELLABLE means of subscribing to an observable, for use with\n * APIs that expect promises, like `async/await`. You cannot unsubscribe from this.\n *\n * **WARNING**: Only use this with observables you *know* will complete. If the source\n * observable does not complete, you will end up with a promise that is hung up, and\n * potentially all of the state of an async function hanging out in memory. To avoid\n * this situation, look into adding something like {@link timeout}, {@link take},\n * {@link takeWhile}, or {@link takeUntil} amongst others.\n *\n * #### Example\n *\n * ```ts\n * import { interval, take } from 'rxjs';\n *\n * const source$ = interval(1000).pipe(take(4));\n *\n * async function getTotal() {\n * let total = 0;\n *\n * await source$.forEach(value => {\n * total += value;\n * console.log('observable -> ' + value);\n * });\n *\n * return total;\n * }\n *\n * getTotal().then(\n * total => console.log('Total: ' + total)\n * );\n *\n * // Expected:\n * // 'observable -> 0'\n * // 'observable -> 1'\n * // 'observable -> 2'\n * // 'observable -> 3'\n * // 'Total: 6'\n * ```\n *\n * @param next a handler for each value emitted by the observable\n * @return a promise that either resolves on observable completion or\n * rejects with the handled error\n */\n forEach(next: (value: T) => void): Promise;\n\n /**\n * @param next a handler for each value emitted by the observable\n * @param promiseCtor a constructor function used to instantiate the Promise\n * @return a promise that either resolves on observable completion or\n * rejects with the handled error\n * @deprecated Passing a Promise constructor will no longer be available\n * in upcoming versions of RxJS. This is because it adds weight to the library, for very\n * little benefit. If you need this functionality, it is recommended that you either\n * polyfill Promise, or you create an adapter to convert the returned native promise\n * to whatever promise implementation you wanted. Will be removed in v8.\n */\n forEach(next: (value: T) => void, promiseCtor: PromiseConstructorLike): Promise;\n\n forEach(next: (value: T) => void, promiseCtor?: PromiseConstructorLike): Promise {\n promiseCtor = getPromiseCtor(promiseCtor);\n\n return new promiseCtor((resolve, reject) => {\n const subscriber = new SafeSubscriber({\n next: (value) => {\n try {\n next(value);\n } catch (err) {\n reject(err);\n subscriber.unsubscribe();\n }\n },\n error: reject,\n complete: resolve,\n });\n this.subscribe(subscriber);\n }) as Promise;\n }\n\n /** @internal */\n protected _subscribe(subscriber: Subscriber): TeardownLogic {\n return this.source?.subscribe(subscriber);\n }\n\n /**\n * An interop point defined by the es7-observable spec https://github.com/zenparsing/es-observable\n * @method Symbol.observable\n * @return {Observable} this instance of the observable\n */\n [Symbol_observable]() {\n return this;\n }\n\n /* tslint:disable:max-line-length */\n pipe(): Observable;\n pipe(op1: OperatorFunction): Observable;\n pipe(op1: OperatorFunction, op2: OperatorFunction): Observable;\n pipe(op1: OperatorFunction, op2: OperatorFunction, op3: OperatorFunction): Observable;\n pipe(\n op1: OperatorFunction,\n op2: OperatorFunction,\n op3: OperatorFunction,\n op4: OperatorFunction\n ): Observable;\n pipe(\n op1: OperatorFunction,\n op2: OperatorFunction,\n op3: OperatorFunction,\n op4: OperatorFunction,\n op5: OperatorFunction\n ): Observable;\n pipe(\n op1: OperatorFunction,\n op2: OperatorFunction,\n op3: OperatorFunction,\n op4: OperatorFunction,\n op5: OperatorFunction,\n op6: OperatorFunction\n ): Observable;\n pipe(\n op1: OperatorFunction,\n op2: OperatorFunction,\n op3: OperatorFunction,\n op4: OperatorFunction,\n op5: OperatorFunction,\n op6: OperatorFunction,\n op7: OperatorFunction\n ): Observable;\n pipe(\n op1: OperatorFunction,\n op2: OperatorFunction,\n op3: OperatorFunction,\n op4: OperatorFunction,\n op5: OperatorFunction,\n op6: OperatorFunction,\n op7: OperatorFunction,\n op8: OperatorFunction\n ): Observable;\n pipe(\n op1: OperatorFunction,\n op2: OperatorFunction,\n op3: OperatorFunction,\n op4: OperatorFunction,\n op5: OperatorFunction,\n op6: OperatorFunction,\n op7: OperatorFunction,\n op8: OperatorFunction,\n op9: OperatorFunction\n ): Observable;\n pipe(\n op1: OperatorFunction,\n op2: OperatorFunction,\n op3: OperatorFunction,\n op4: OperatorFunction,\n op5: OperatorFunction,\n op6: OperatorFunction,\n op7: OperatorFunction,\n op8: OperatorFunction,\n op9: OperatorFunction,\n ...operations: OperatorFunction[]\n ): Observable;\n /* tslint:enable:max-line-length */\n\n /**\n * Used to stitch together functional operators into a chain.\n * @method pipe\n * @return {Observable} the Observable result of all of the operators having\n * been called in the order they were passed in.\n *\n * ## Example\n *\n * ```ts\n * import { interval, filter, map, scan } from 'rxjs';\n *\n * interval(1000)\n * .pipe(\n * filter(x => x % 2 === 0),\n * map(x => x + x),\n * scan((acc, x) => acc + x)\n * )\n * .subscribe(x => console.log(x));\n * ```\n */\n pipe(...operations: OperatorFunction[]): Observable {\n return pipeFromArray(operations)(this);\n }\n\n /* tslint:disable:max-line-length */\n /** @deprecated Replaced with {@link firstValueFrom} and {@link lastValueFrom}. Will be removed in v8. Details: https://rxjs.dev/deprecations/to-promise */\n toPromise(): Promise;\n /** @deprecated Replaced with {@link firstValueFrom} and {@link lastValueFrom}. Will be removed in v8. Details: https://rxjs.dev/deprecations/to-promise */\n toPromise(PromiseCtor: typeof Promise): Promise;\n /** @deprecated Replaced with {@link firstValueFrom} and {@link lastValueFrom}. Will be removed in v8. Details: https://rxjs.dev/deprecations/to-promise */\n toPromise(PromiseCtor: PromiseConstructorLike): Promise;\n /* tslint:enable:max-line-length */\n\n /**\n * Subscribe to this Observable and get a Promise resolving on\n * `complete` with the last emission (if any).\n *\n * **WARNING**: Only use this with observables you *know* will complete. If the source\n * observable does not complete, you will end up with a promise that is hung up, and\n * potentially all of the state of an async function hanging out in memory. To avoid\n * this situation, look into adding something like {@link timeout}, {@link take},\n * {@link takeWhile}, or {@link takeUntil} amongst others.\n *\n * @method toPromise\n * @param [promiseCtor] a constructor function used to instantiate\n * the Promise\n * @return A Promise that resolves with the last value emit, or\n * rejects on an error. If there were no emissions, Promise\n * resolves with undefined.\n * @deprecated Replaced with {@link firstValueFrom} and {@link lastValueFrom}. Will be removed in v8. Details: https://rxjs.dev/deprecations/to-promise\n */\n toPromise(promiseCtor?: PromiseConstructorLike): Promise {\n promiseCtor = getPromiseCtor(promiseCtor);\n\n return new promiseCtor((resolve, reject) => {\n let value: T | undefined;\n this.subscribe(\n (x: T) => (value = x),\n (err: any) => reject(err),\n () => resolve(value)\n );\n }) as Promise;\n }\n}\n\n/**\n * Decides between a passed promise constructor from consuming code,\n * A default configured promise constructor, and the native promise\n * constructor and returns it. If nothing can be found, it will throw\n * an error.\n * @param promiseCtor The optional promise constructor to passed by consuming code\n */\nfunction getPromiseCtor(promiseCtor: PromiseConstructorLike | undefined) {\n return promiseCtor ?? config.Promise ?? Promise;\n}\n\nfunction isObserver(value: any): value is Observer {\n return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);\n}\n\nfunction isSubscriber(value: any): value is Subscriber {\n return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));\n}\n", "import { Observable } from '../Observable';\nimport { Subscriber } from '../Subscriber';\nimport { OperatorFunction } from '../types';\nimport { isFunction } from './isFunction';\n\n/**\n * Used to determine if an object is an Observable with a lift function.\n */\nexport function hasLift(source: any): source is { lift: InstanceType['lift'] } {\n return isFunction(source?.lift);\n}\n\n/**\n * Creates an `OperatorFunction`. Used to define operators throughout the library in a concise way.\n * @param init The logic to connect the liftedSource to the subscriber at the moment of subscription.\n */\nexport function operate(\n init: (liftedSource: Observable, subscriber: Subscriber) => (() => void) | void\n): OperatorFunction {\n return (source: Observable) => {\n if (hasLift(source)) {\n return source.lift(function (this: Subscriber, liftedSource: Observable) {\n try {\n return init(liftedSource, this);\n } catch (err) {\n this.error(err);\n }\n });\n }\n throw new TypeError('Unable to lift unknown Observable type');\n };\n}\n", "import { Subscriber } from '../Subscriber';\n\n/**\n * Creates an instance of an `OperatorSubscriber`.\n * @param destination The downstream subscriber.\n * @param onNext Handles next values, only called if this subscriber is not stopped or closed. Any\n * error that occurs in this function is caught and sent to the `error` method of this subscriber.\n * @param onError Handles errors from the subscription, any errors that occur in this handler are caught\n * and send to the `destination` error handler.\n * @param onComplete Handles completion notification from the subscription. Any errors that occur in\n * this handler are sent to the `destination` error handler.\n * @param onFinalize Additional teardown logic here. This will only be called on teardown if the\n * subscriber itself is not already closed. This is called after all other teardown logic is executed.\n */\nexport function createOperatorSubscriber(\n destination: Subscriber,\n onNext?: (value: T) => void,\n onComplete?: () => void,\n onError?: (err: any) => void,\n onFinalize?: () => void\n): Subscriber {\n return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);\n}\n\n/**\n * A generic helper for allowing operators to be created with a Subscriber and\n * use closures to capture necessary state from the operator function itself.\n */\nexport class OperatorSubscriber extends Subscriber {\n /**\n * Creates an instance of an `OperatorSubscriber`.\n * @param destination The downstream subscriber.\n * @param onNext Handles next values, only called if this subscriber is not stopped or closed. Any\n * error that occurs in this function is caught and sent to the `error` method of this subscriber.\n * @param onError Handles errors from the subscription, any errors that occur in this handler are caught\n * and send to the `destination` error handler.\n * @param onComplete Handles completion notification from the subscription. Any errors that occur in\n * this handler are sent to the `destination` error handler.\n * @param onFinalize Additional finalization logic here. This will only be called on finalization if the\n * subscriber itself is not already closed. This is called after all other finalization logic is executed.\n * @param shouldUnsubscribe An optional check to see if an unsubscribe call should truly unsubscribe.\n * NOTE: This currently **ONLY** exists to support the strange behavior of {@link groupBy}, where unsubscription\n * to the resulting observable does not actually disconnect from the source if there are active subscriptions\n * to any grouped observable. (DO NOT EXPOSE OR USE EXTERNALLY!!!)\n */\n constructor(\n destination: Subscriber,\n onNext?: (value: T) => void,\n onComplete?: () => void,\n onError?: (err: any) => void,\n private onFinalize?: () => void,\n private shouldUnsubscribe?: () => boolean\n ) {\n // It's important - for performance reasons - that all of this class's\n // members are initialized and that they are always initialized in the same\n // order. This will ensure that all OperatorSubscriber instances have the\n // same hidden class in V8. This, in turn, will help keep the number of\n // hidden classes involved in property accesses within the base class as\n // low as possible. If the number of hidden classes involved exceeds four,\n // the property accesses will become megamorphic and performance penalties\n // will be incurred - i.e. inline caches won't be used.\n //\n // The reasons for ensuring all instances have the same hidden class are\n // further discussed in this blog post from Benedikt Meurer:\n // https://benediktmeurer.de/2018/03/23/impact-of-polymorphism-on-component-based-frameworks-like-react/\n super(destination);\n this._next = onNext\n ? function (this: OperatorSubscriber, value: T) {\n try {\n onNext(value);\n } catch (err) {\n destination.error(err);\n }\n }\n : super._next;\n this._error = onError\n ? function (this: OperatorSubscriber, err: any) {\n try {\n onError(err);\n } catch (err) {\n // Send any errors that occur down stream.\n destination.error(err);\n } finally {\n // Ensure finalization.\n this.unsubscribe();\n }\n }\n : super._error;\n this._complete = onComplete\n ? function (this: OperatorSubscriber) {\n try {\n onComplete();\n } catch (err) {\n // Send any errors that occur down stream.\n destination.error(err);\n } finally {\n // Ensure finalization.\n this.unsubscribe();\n }\n }\n : super._complete;\n }\n\n unsubscribe() {\n if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {\n const { closed } = this;\n super.unsubscribe();\n // Execute additional teardown if we have any and we didn't already do so.\n !closed && this.onFinalize?.();\n }\n }\n}\n", "import { Subscription } from '../Subscription';\n\ninterface AnimationFrameProvider {\n schedule(callback: FrameRequestCallback): Subscription;\n requestAnimationFrame: typeof requestAnimationFrame;\n cancelAnimationFrame: typeof cancelAnimationFrame;\n delegate:\n | {\n requestAnimationFrame: typeof requestAnimationFrame;\n cancelAnimationFrame: typeof cancelAnimationFrame;\n }\n | undefined;\n}\n\nexport const animationFrameProvider: AnimationFrameProvider = {\n // When accessing the delegate, use the variable rather than `this` so that\n // the functions can be called without being bound to the provider.\n schedule(callback) {\n let request = requestAnimationFrame;\n let cancel: typeof cancelAnimationFrame | undefined = cancelAnimationFrame;\n const { delegate } = animationFrameProvider;\n if (delegate) {\n request = delegate.requestAnimationFrame;\n cancel = delegate.cancelAnimationFrame;\n }\n const handle = request((timestamp) => {\n // Clear the cancel function. The request has been fulfilled, so\n // attempting to cancel the request upon unsubscription would be\n // pointless.\n cancel = undefined;\n callback(timestamp);\n });\n return new Subscription(() => cancel?.(handle));\n },\n requestAnimationFrame(...args) {\n const { delegate } = animationFrameProvider;\n return (delegate?.requestAnimationFrame || requestAnimationFrame)(...args);\n },\n cancelAnimationFrame(...args) {\n const { delegate } = animationFrameProvider;\n return (delegate?.cancelAnimationFrame || cancelAnimationFrame)(...args);\n },\n delegate: undefined,\n};\n", "import { createErrorClass } from './createErrorClass';\n\nexport interface ObjectUnsubscribedError extends Error {}\n\nexport interface ObjectUnsubscribedErrorCtor {\n /**\n * @deprecated Internal implementation detail. Do not construct error instances.\n * Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269\n */\n new (): ObjectUnsubscribedError;\n}\n\n/**\n * An error thrown when an action is invalid because the object has been\n * unsubscribed.\n *\n * @see {@link Subject}\n * @see {@link BehaviorSubject}\n *\n * @class ObjectUnsubscribedError\n */\nexport const ObjectUnsubscribedError: ObjectUnsubscribedErrorCtor = createErrorClass(\n (_super) =>\n function ObjectUnsubscribedErrorImpl(this: any) {\n _super(this);\n this.name = 'ObjectUnsubscribedError';\n this.message = 'object unsubscribed';\n }\n);\n", "import { Operator } from './Operator';\nimport { Observable } from './Observable';\nimport { Subscriber } from './Subscriber';\nimport { Subscription, EMPTY_SUBSCRIPTION } from './Subscription';\nimport { Observer, SubscriptionLike, TeardownLogic } from './types';\nimport { ObjectUnsubscribedError } from './util/ObjectUnsubscribedError';\nimport { arrRemove } from './util/arrRemove';\nimport { errorContext } from './util/errorContext';\n\n/**\n * A Subject is a special type of Observable that allows values to be\n * multicasted to many Observers. Subjects are like EventEmitters.\n *\n * Every Subject is an Observable and an Observer. You can subscribe to a\n * Subject, and you can call next to feed values as well as error and complete.\n */\nexport class Subject extends Observable implements SubscriptionLike {\n closed = false;\n\n private currentObservers: Observer[] | null = null;\n\n /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */\n observers: Observer[] = [];\n /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */\n isStopped = false;\n /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */\n hasError = false;\n /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */\n thrownError: any = null;\n\n /**\n * Creates a \"subject\" by basically gluing an observer to an observable.\n *\n * @nocollapse\n * @deprecated Recommended you do not use. Will be removed at some point in the future. Plans for replacement still under discussion.\n */\n static create: (...args: any[]) => any = (destination: Observer, source: Observable): AnonymousSubject => {\n return new AnonymousSubject(destination, source);\n };\n\n constructor() {\n // NOTE: This must be here to obscure Observable's constructor.\n super();\n }\n\n /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */\n lift(operator: Operator): Observable {\n const subject = new AnonymousSubject(this, this);\n subject.operator = operator as any;\n return subject as any;\n }\n\n /** @internal */\n protected _throwIfClosed() {\n if (this.closed) {\n throw new ObjectUnsubscribedError();\n }\n }\n\n next(value: T) {\n errorContext(() => {\n this._throwIfClosed();\n if (!this.isStopped) {\n if (!this.currentObservers) {\n this.currentObservers = Array.from(this.observers);\n }\n for (const observer of this.currentObservers) {\n observer.next(value);\n }\n }\n });\n }\n\n error(err: any) {\n errorContext(() => {\n this._throwIfClosed();\n if (!this.isStopped) {\n this.hasError = this.isStopped = true;\n this.thrownError = err;\n const { observers } = this;\n while (observers.length) {\n observers.shift()!.error(err);\n }\n }\n });\n }\n\n complete() {\n errorContext(() => {\n this._throwIfClosed();\n if (!this.isStopped) {\n this.isStopped = true;\n const { observers } = this;\n while (observers.length) {\n observers.shift()!.complete();\n }\n }\n });\n }\n\n unsubscribe() {\n this.isStopped = this.closed = true;\n this.observers = this.currentObservers = null!;\n }\n\n get observed() {\n return this.observers?.length > 0;\n }\n\n /** @internal */\n protected _trySubscribe(subscriber: Subscriber): TeardownLogic {\n this._throwIfClosed();\n return super._trySubscribe(subscriber);\n }\n\n /** @internal */\n protected _subscribe(subscriber: Subscriber): Subscription {\n this._throwIfClosed();\n this._checkFinalizedStatuses(subscriber);\n return this._innerSubscribe(subscriber);\n }\n\n /** @internal */\n protected _innerSubscribe(subscriber: Subscriber) {\n const { hasError, isStopped, observers } = this;\n if (hasError || isStopped) {\n return EMPTY_SUBSCRIPTION;\n }\n this.currentObservers = null;\n observers.push(subscriber);\n return new Subscription(() => {\n this.currentObservers = null;\n arrRemove(observers, subscriber);\n });\n }\n\n /** @internal */\n protected _checkFinalizedStatuses(subscriber: Subscriber) {\n const { hasError, thrownError, isStopped } = this;\n if (hasError) {\n subscriber.error(thrownError);\n } else if (isStopped) {\n subscriber.complete();\n }\n }\n\n /**\n * Creates a new Observable with this Subject as the source. You can do this\n * to create custom Observer-side logic of the Subject and conceal it from\n * code that uses the Observable.\n * @return {Observable} Observable that the Subject casts to\n */\n asObservable(): Observable {\n const observable: any = new Observable();\n observable.source = this;\n return observable;\n }\n}\n\n/**\n * @class AnonymousSubject\n */\nexport class AnonymousSubject extends Subject {\n constructor(\n /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */\n public destination?: Observer,\n source?: Observable\n ) {\n super();\n this.source = source;\n }\n\n next(value: T) {\n this.destination?.next?.(value);\n }\n\n error(err: any) {\n this.destination?.error?.(err);\n }\n\n complete() {\n this.destination?.complete?.();\n }\n\n /** @internal */\n protected _subscribe(subscriber: Subscriber): Subscription {\n return this.source?.subscribe(subscriber) ?? EMPTY_SUBSCRIPTION;\n }\n}\n", "import { TimestampProvider } from '../types';\n\ninterface DateTimestampProvider extends TimestampProvider {\n delegate: TimestampProvider | undefined;\n}\n\nexport const dateTimestampProvider: DateTimestampProvider = {\n now() {\n // Use the variable rather than `this` so that the function can be called\n // without being bound to the provider.\n return (dateTimestampProvider.delegate || Date).now();\n },\n delegate: undefined,\n};\n", "import { Subject } from './Subject';\nimport { TimestampProvider } from './types';\nimport { Subscriber } from './Subscriber';\nimport { Subscription } from './Subscription';\nimport { dateTimestampProvider } from './scheduler/dateTimestampProvider';\n\n/**\n * A variant of {@link Subject} that \"replays\" old values to new subscribers by emitting them when they first subscribe.\n *\n * `ReplaySubject` has an internal buffer that will store a specified number of values that it has observed. Like `Subject`,\n * `ReplaySubject` \"observes\" values by having them passed to its `next` method. When it observes a value, it will store that\n * value for a time determined by the configuration of the `ReplaySubject`, as passed to its constructor.\n *\n * When a new subscriber subscribes to the `ReplaySubject` instance, it will synchronously emit all values in its buffer in\n * a First-In-First-Out (FIFO) manner. The `ReplaySubject` will also complete, if it has observed completion; and it will\n * error if it has observed an error.\n *\n * There are two main configuration items to be concerned with:\n *\n * 1. `bufferSize` - This will determine how many items are stored in the buffer, defaults to infinite.\n * 2. `windowTime` - The amount of time to hold a value in the buffer before removing it from the buffer.\n *\n * Both configurations may exist simultaneously. So if you would like to buffer a maximum of 3 values, as long as the values\n * are less than 2 seconds old, you could do so with a `new ReplaySubject(3, 2000)`.\n *\n * ### Differences with BehaviorSubject\n *\n * `BehaviorSubject` is similar to `new ReplaySubject(1)`, with a couple of exceptions:\n *\n * 1. `BehaviorSubject` comes \"primed\" with a single value upon construction.\n * 2. `ReplaySubject` will replay values, even after observing an error, where `BehaviorSubject` will not.\n *\n * @see {@link Subject}\n * @see {@link BehaviorSubject}\n * @see {@link shareReplay}\n */\nexport class ReplaySubject extends Subject {\n private _buffer: (T | number)[] = [];\n private _infiniteTimeWindow = true;\n\n /**\n * @param bufferSize The size of the buffer to replay on subscription\n * @param windowTime The amount of time the buffered items will stay buffered\n * @param timestampProvider An object with a `now()` method that provides the current timestamp. This is used to\n * calculate the amount of time something has been buffered.\n */\n constructor(\n private _bufferSize = Infinity,\n private _windowTime = Infinity,\n private _timestampProvider: TimestampProvider = dateTimestampProvider\n ) {\n super();\n this._infiniteTimeWindow = _windowTime === Infinity;\n this._bufferSize = Math.max(1, _bufferSize);\n this._windowTime = Math.max(1, _windowTime);\n }\n\n next(value: T): void {\n const { isStopped, _buffer, _infiniteTimeWindow, _timestampProvider, _windowTime } = this;\n if (!isStopped) {\n _buffer.push(value);\n !_infiniteTimeWindow && _buffer.push(_timestampProvider.now() + _windowTime);\n }\n this._trimBuffer();\n super.next(value);\n }\n\n /** @internal */\n protected _subscribe(subscriber: Subscriber): Subscription {\n this._throwIfClosed();\n this._trimBuffer();\n\n const subscription = this._innerSubscribe(subscriber);\n\n const { _infiniteTimeWindow, _buffer } = this;\n // We use a copy here, so reentrant code does not mutate our array while we're\n // emitting it to a new subscriber.\n const copy = _buffer.slice();\n for (let i = 0; i < copy.length && !subscriber.closed; i += _infiniteTimeWindow ? 1 : 2) {\n subscriber.next(copy[i] as T);\n }\n\n this._checkFinalizedStatuses(subscriber);\n\n return subscription;\n }\n\n private _trimBuffer() {\n const { _bufferSize, _timestampProvider, _buffer, _infiniteTimeWindow } = this;\n // If we don't have an infinite buffer size, and we're over the length,\n // use splice to truncate the old buffer values off. Note that we have to\n // double the size for instances where we're not using an infinite time window\n // because we're storing the values and the timestamps in the same array.\n const adjustedBufferSize = (_infiniteTimeWindow ? 1 : 2) * _bufferSize;\n _bufferSize < Infinity && adjustedBufferSize < _buffer.length && _buffer.splice(0, _buffer.length - adjustedBufferSize);\n\n // Now, if we're not in an infinite time window, remove all values where the time is\n // older than what is allowed.\n if (!_infiniteTimeWindow) {\n const now = _timestampProvider.now();\n let last = 0;\n // Search the array for the first timestamp that isn't expired and\n // truncate the buffer up to that point.\n for (let i = 1; i < _buffer.length && (_buffer[i] as number) <= now; i += 2) {\n last = i;\n }\n last && _buffer.splice(0, last + 1);\n }\n }\n}\n", "import { Scheduler } from '../Scheduler';\nimport { Subscription } from '../Subscription';\nimport { SchedulerAction } from '../types';\n\n/**\n * A unit of work to be executed in a `scheduler`. An action is typically\n * created from within a {@link SchedulerLike} and an RxJS user does not need to concern\n * themselves about creating and manipulating an Action.\n *\n * ```ts\n * class Action extends Subscription {\n * new (scheduler: Scheduler, work: (state?: T) => void);\n * schedule(state?: T, delay: number = 0): Subscription;\n * }\n * ```\n *\n * @class Action\n */\nexport class Action extends Subscription {\n constructor(scheduler: Scheduler, work: (this: SchedulerAction, state?: T) => void) {\n super();\n }\n /**\n * Schedules this action on its parent {@link SchedulerLike} for execution. May be passed\n * some context object, `state`. May happen at some point in the future,\n * according to the `delay` parameter, if specified.\n * @param {T} [state] Some contextual data that the `work` function uses when\n * called by the Scheduler.\n * @param {number} [delay] Time to wait before executing the work, where the\n * time unit is implicit and defined by the Scheduler.\n * @return {void}\n */\n public schedule(state?: T, delay: number = 0): Subscription {\n return this;\n }\n}\n", "import type { TimerHandle } from './timerHandle';\ntype SetIntervalFunction = (handler: () => void, timeout?: number, ...args: any[]) => TimerHandle;\ntype ClearIntervalFunction = (handle: TimerHandle) => void;\n\ninterface IntervalProvider {\n setInterval: SetIntervalFunction;\n clearInterval: ClearIntervalFunction;\n delegate:\n | {\n setInterval: SetIntervalFunction;\n clearInterval: ClearIntervalFunction;\n }\n | undefined;\n}\n\nexport const intervalProvider: IntervalProvider = {\n // When accessing the delegate, use the variable rather than `this` so that\n // the functions can be called without being bound to the provider.\n setInterval(handler: () => void, timeout?: number, ...args) {\n const { delegate } = intervalProvider;\n if (delegate?.setInterval) {\n return delegate.setInterval(handler, timeout, ...args);\n }\n return setInterval(handler, timeout, ...args);\n },\n clearInterval(handle) {\n const { delegate } = intervalProvider;\n return (delegate?.clearInterval || clearInterval)(handle as any);\n },\n delegate: undefined,\n};\n", "import { Action } from './Action';\nimport { SchedulerAction } from '../types';\nimport { Subscription } from '../Subscription';\nimport { AsyncScheduler } from './AsyncScheduler';\nimport { intervalProvider } from './intervalProvider';\nimport { arrRemove } from '../util/arrRemove';\nimport { TimerHandle } from './timerHandle';\n\nexport class AsyncAction extends Action {\n public id: TimerHandle | undefined;\n public state?: T;\n // @ts-ignore: Property has no initializer and is not definitely assigned\n public delay: number;\n protected pending: boolean = false;\n\n constructor(protected scheduler: AsyncScheduler, protected work: (this: SchedulerAction, state?: T) => void) {\n super(scheduler, work);\n }\n\n public schedule(state?: T, delay: number = 0): Subscription {\n if (this.closed) {\n return this;\n }\n\n // Always replace the current state with the new state.\n this.state = state;\n\n const id = this.id;\n const scheduler = this.scheduler;\n\n //\n // Important implementation note:\n //\n // Actions only execute once by default, unless rescheduled from within the\n // scheduled callback. This allows us to implement single and repeat\n // actions via the same code path, without adding API surface area, as well\n // as mimic traditional recursion but across asynchronous boundaries.\n //\n // However, JS runtimes and timers distinguish between intervals achieved by\n // serial `setTimeout` calls vs. a single `setInterval` call. An interval of\n // serial `setTimeout` calls can be individually delayed, which delays\n // scheduling the next `setTimeout`, and so on. `setInterval` attempts to\n // guarantee the interval callback will be invoked more precisely to the\n // interval period, regardless of load.\n //\n // Therefore, we use `setInterval` to schedule single and repeat actions.\n // If the action reschedules itself with the same delay, the interval is not\n // canceled. If the action doesn't reschedule, or reschedules with a\n // different delay, the interval will be canceled after scheduled callback\n // execution.\n //\n if (id != null) {\n this.id = this.recycleAsyncId(scheduler, id, delay);\n }\n\n // Set the pending flag indicating that this action has been scheduled, or\n // has recursively rescheduled itself.\n this.pending = true;\n\n this.delay = delay;\n // If this action has already an async Id, don't request a new one.\n this.id = this.id ?? this.requestAsyncId(scheduler, this.id, delay);\n\n return this;\n }\n\n protected requestAsyncId(scheduler: AsyncScheduler, _id?: TimerHandle, delay: number = 0): TimerHandle {\n return intervalProvider.setInterval(scheduler.flush.bind(scheduler, this), delay);\n }\n\n protected recycleAsyncId(_scheduler: AsyncScheduler, id?: TimerHandle, delay: number | null = 0): TimerHandle | undefined {\n // If this action is rescheduled with the same delay time, don't clear the interval id.\n if (delay != null && this.delay === delay && this.pending === false) {\n return id;\n }\n // Otherwise, if the action's delay time is different from the current delay,\n // or the action has been rescheduled before it's executed, clear the interval id\n if (id != null) {\n intervalProvider.clearInterval(id);\n }\n\n return undefined;\n }\n\n /**\n * Immediately executes this action and the `work` it contains.\n * @return {any}\n */\n public execute(state: T, delay: number): any {\n if (this.closed) {\n return new Error('executing a cancelled action');\n }\n\n this.pending = false;\n const error = this._execute(state, delay);\n if (error) {\n return error;\n } else if (this.pending === false && this.id != null) {\n // Dequeue if the action didn't reschedule itself. Don't call\n // unsubscribe(), because the action could reschedule later.\n // For example:\n // ```\n // scheduler.schedule(function doWork(counter) {\n // /* ... I'm a busy worker bee ... */\n // var originalAction = this;\n // /* wait 100ms before rescheduling the action */\n // setTimeout(function () {\n // originalAction.schedule(counter + 1);\n // }, 100);\n // }, 1000);\n // ```\n this.id = this.recycleAsyncId(this.scheduler, this.id, null);\n }\n }\n\n protected _execute(state: T, _delay: number): any {\n let errored: boolean = false;\n let errorValue: any;\n try {\n this.work(state);\n } catch (e) {\n errored = true;\n // HACK: Since code elsewhere is relying on the \"truthiness\" of the\n // return here, we can't have it return \"\" or 0 or false.\n // TODO: Clean this up when we refactor schedulers mid-version-8 or so.\n errorValue = e ? e : new Error('Scheduled action threw falsy error');\n }\n if (errored) {\n this.unsubscribe();\n return errorValue;\n }\n }\n\n unsubscribe() {\n if (!this.closed) {\n const { id, scheduler } = this;\n const { actions } = scheduler;\n\n this.work = this.state = this.scheduler = null!;\n this.pending = false;\n\n arrRemove(actions, this);\n if (id != null) {\n this.id = this.recycleAsyncId(scheduler, id, null);\n }\n\n this.delay = null!;\n super.unsubscribe();\n }\n }\n}\n", "import { Action } from './scheduler/Action';\nimport { Subscription } from './Subscription';\nimport { SchedulerLike, SchedulerAction } from './types';\nimport { dateTimestampProvider } from './scheduler/dateTimestampProvider';\n\n/**\n * An execution context and a data structure to order tasks and schedule their\n * execution. Provides a notion of (potentially virtual) time, through the\n * `now()` getter method.\n *\n * Each unit of work in a Scheduler is called an `Action`.\n *\n * ```ts\n * class Scheduler {\n * now(): number;\n * schedule(work, delay?, state?): Subscription;\n * }\n * ```\n *\n * @class Scheduler\n * @deprecated Scheduler is an internal implementation detail of RxJS, and\n * should not be used directly. Rather, create your own class and implement\n * {@link SchedulerLike}. Will be made internal in v8.\n */\nexport class Scheduler implements SchedulerLike {\n public static now: () => number = dateTimestampProvider.now;\n\n constructor(private schedulerActionCtor: typeof Action, now: () => number = Scheduler.now) {\n this.now = now;\n }\n\n /**\n * A getter method that returns a number representing the current time\n * (at the time this function was called) according to the scheduler's own\n * internal clock.\n * @return {number} A number that represents the current time. May or may not\n * have a relation to wall-clock time. May or may not refer to a time unit\n * (e.g. milliseconds).\n */\n public now: () => number;\n\n /**\n * Schedules a function, `work`, for execution. May happen at some point in\n * the future, according to the `delay` parameter, if specified. May be passed\n * some context object, `state`, which will be passed to the `work` function.\n *\n * The given arguments will be processed an stored as an Action object in a\n * queue of actions.\n *\n * @param {function(state: ?T): ?Subscription} work A function representing a\n * task, or some unit of work to be executed by the Scheduler.\n * @param {number} [delay] Time to wait before executing the work, where the\n * time unit is implicit and defined by the Scheduler itself.\n * @param {T} [state] Some contextual data that the `work` function uses when\n * called by the Scheduler.\n * @return {Subscription} A subscription in order to be able to unsubscribe\n * the scheduled work.\n */\n public schedule(work: (this: SchedulerAction, state?: T) => void, delay: number = 0, state?: T): Subscription {\n return new this.schedulerActionCtor(this, work).schedule(state, delay);\n }\n}\n", "import { Scheduler } from '../Scheduler';\nimport { Action } from './Action';\nimport { AsyncAction } from './AsyncAction';\nimport { TimerHandle } from './timerHandle';\n\nexport class AsyncScheduler extends Scheduler {\n public actions: Array> = [];\n /**\n * A flag to indicate whether the Scheduler is currently executing a batch of\n * queued actions.\n * @type {boolean}\n * @internal\n */\n public _active: boolean = false;\n /**\n * An internal ID used to track the latest asynchronous task such as those\n * coming from `setTimeout`, `setInterval`, `requestAnimationFrame`, and\n * others.\n * @type {any}\n * @internal\n */\n public _scheduled: TimerHandle | undefined;\n\n constructor(SchedulerAction: typeof Action, now: () => number = Scheduler.now) {\n super(SchedulerAction, now);\n }\n\n public flush(action: AsyncAction): void {\n const { actions } = this;\n\n if (this._active) {\n actions.push(action);\n return;\n }\n\n let error: any;\n this._active = true;\n\n do {\n if ((error = action.execute(action.state, action.delay))) {\n break;\n }\n } while ((action = actions.shift()!)); // exhaust the scheduler queue\n\n this._active = false;\n\n if (error) {\n while ((action = actions.shift()!)) {\n action.unsubscribe();\n }\n throw error;\n }\n }\n}\n", "import { AsyncAction } from './AsyncAction';\nimport { AsyncScheduler } from './AsyncScheduler';\n\n/**\n *\n * Async Scheduler\n *\n * Schedule task as if you used setTimeout(task, duration)\n *\n * `async` scheduler schedules tasks asynchronously, by putting them on the JavaScript\n * event loop queue. It is best used to delay tasks in time or to schedule tasks repeating\n * in intervals.\n *\n * If you just want to \"defer\" task, that is to perform it right after currently\n * executing synchronous code ends (commonly achieved by `setTimeout(deferredTask, 0)`),\n * better choice will be the {@link asapScheduler} scheduler.\n *\n * ## Examples\n * Use async scheduler to delay task\n * ```ts\n * import { asyncScheduler } from 'rxjs';\n *\n * const task = () => console.log('it works!');\n *\n * asyncScheduler.schedule(task, 2000);\n *\n * // After 2 seconds logs:\n * // \"it works!\"\n * ```\n *\n * Use async scheduler to repeat task in intervals\n * ```ts\n * import { asyncScheduler } from 'rxjs';\n *\n * function task(state) {\n * console.log(state);\n * this.schedule(state + 1, 1000); // `this` references currently executing Action,\n * // which we reschedule with new state and delay\n * }\n *\n * asyncScheduler.schedule(task, 3000, 0);\n *\n * // Logs:\n * // 0 after 3s\n * // 1 after 4s\n * // 2 after 5s\n * // 3 after 6s\n * ```\n */\n\nexport const asyncScheduler = new AsyncScheduler(AsyncAction);\n\n/**\n * @deprecated Renamed to {@link asyncScheduler}. Will be removed in v8.\n */\nexport const async = asyncScheduler;\n", "import { AsyncAction } from './AsyncAction';\nimport { AnimationFrameScheduler } from './AnimationFrameScheduler';\nimport { SchedulerAction } from '../types';\nimport { animationFrameProvider } from './animationFrameProvider';\nimport { TimerHandle } from './timerHandle';\n\nexport class AnimationFrameAction extends AsyncAction {\n constructor(protected scheduler: AnimationFrameScheduler, protected work: (this: SchedulerAction, state?: T) => void) {\n super(scheduler, work);\n }\n\n protected requestAsyncId(scheduler: AnimationFrameScheduler, id?: TimerHandle, delay: number = 0): TimerHandle {\n // If delay is greater than 0, request as an async action.\n if (delay !== null && delay > 0) {\n return super.requestAsyncId(scheduler, id, delay);\n }\n // Push the action to the end of the scheduler queue.\n scheduler.actions.push(this);\n // If an animation frame has already been requested, don't request another\n // one. If an animation frame hasn't been requested yet, request one. Return\n // the current animation frame request id.\n return scheduler._scheduled || (scheduler._scheduled = animationFrameProvider.requestAnimationFrame(() => scheduler.flush(undefined)));\n }\n\n protected recycleAsyncId(scheduler: AnimationFrameScheduler, id?: TimerHandle, delay: number = 0): TimerHandle | undefined {\n // If delay exists and is greater than 0, or if the delay is null (the\n // action wasn't rescheduled) but was originally scheduled as an async\n // action, then recycle as an async action.\n if (delay != null ? delay > 0 : this.delay > 0) {\n return super.recycleAsyncId(scheduler, id, delay);\n }\n // If the scheduler queue has no remaining actions with the same async id,\n // cancel the requested animation frame and set the scheduled flag to\n // undefined so the next AnimationFrameAction will request its own.\n const { actions } = scheduler;\n if (id != null && actions[actions.length - 1]?.id !== id) {\n animationFrameProvider.cancelAnimationFrame(id as number);\n scheduler._scheduled = undefined;\n }\n // Return undefined so the action knows to request a new async id if it's rescheduled.\n return undefined;\n }\n}\n", "import { AsyncAction } from './AsyncAction';\nimport { AsyncScheduler } from './AsyncScheduler';\n\nexport class AnimationFrameScheduler extends AsyncScheduler {\n public flush(action?: AsyncAction): void {\n this._active = true;\n // The async id that effects a call to flush is stored in _scheduled.\n // Before executing an action, it's necessary to check the action's async\n // id to determine whether it's supposed to be executed in the current\n // flush.\n // Previous implementations of this method used a count to determine this,\n // but that was unsound, as actions that are unsubscribed - i.e. cancelled -\n // are removed from the actions array and that can shift actions that are\n // scheduled to be executed in a subsequent flush into positions at which\n // they are executed within the current flush.\n const flushId = this._scheduled;\n this._scheduled = undefined;\n\n const { actions } = this;\n let error: any;\n action = action || actions.shift()!;\n\n do {\n if ((error = action.execute(action.state, action.delay))) {\n break;\n }\n } while ((action = actions[0]) && action.id === flushId && actions.shift());\n\n this._active = false;\n\n if (error) {\n while ((action = actions[0]) && action.id === flushId && actions.shift()) {\n action.unsubscribe();\n }\n throw error;\n }\n }\n}\n", "import { AnimationFrameAction } from './AnimationFrameAction';\nimport { AnimationFrameScheduler } from './AnimationFrameScheduler';\n\n/**\n *\n * Animation Frame Scheduler\n *\n * Perform task when `window.requestAnimationFrame` would fire\n *\n * When `animationFrame` scheduler is used with delay, it will fall back to {@link asyncScheduler} scheduler\n * behaviour.\n *\n * Without delay, `animationFrame` scheduler can be used to create smooth browser animations.\n * It makes sure scheduled task will happen just before next browser content repaint,\n * thus performing animations as efficiently as possible.\n *\n * ## Example\n * Schedule div height animation\n * ```ts\n * // html:
    \n * import { animationFrameScheduler } from 'rxjs';\n *\n * const div = document.querySelector('div');\n *\n * animationFrameScheduler.schedule(function(height) {\n * div.style.height = height + \"px\";\n *\n * this.schedule(height + 1); // `this` references currently executing Action,\n * // which we reschedule with new state\n * }, 0, 0);\n *\n * // You will see a div element growing in height\n * ```\n */\n\nexport const animationFrameScheduler = new AnimationFrameScheduler(AnimationFrameAction);\n\n/**\n * @deprecated Renamed to {@link animationFrameScheduler}. Will be removed in v8.\n */\nexport const animationFrame = animationFrameScheduler;\n", "import { Observable } from '../Observable';\nimport { SchedulerLike } from '../types';\n\n/**\n * A simple Observable that emits no items to the Observer and immediately\n * emits a complete notification.\n *\n * Just emits 'complete', and nothing else.\n *\n * ![](empty.png)\n *\n * A simple Observable that only emits the complete notification. It can be used\n * for composing with other Observables, such as in a {@link mergeMap}.\n *\n * ## Examples\n *\n * Log complete notification\n *\n * ```ts\n * import { EMPTY } from 'rxjs';\n *\n * EMPTY.subscribe({\n * next: () => console.log('Next'),\n * complete: () => console.log('Complete!')\n * });\n *\n * // Outputs\n * // Complete!\n * ```\n *\n * Emit the number 7, then complete\n *\n * ```ts\n * import { EMPTY, startWith } from 'rxjs';\n *\n * const result = EMPTY.pipe(startWith(7));\n * result.subscribe(x => console.log(x));\n *\n * // Outputs\n * // 7\n * ```\n *\n * Map and flatten only odd numbers to the sequence `'a'`, `'b'`, `'c'`\n *\n * ```ts\n * import { interval, mergeMap, of, EMPTY } from 'rxjs';\n *\n * const interval$ = interval(1000);\n * const result = interval$.pipe(\n * mergeMap(x => x % 2 === 1 ? of('a', 'b', 'c') : EMPTY),\n * );\n * result.subscribe(x => console.log(x));\n *\n * // Results in the following to the console:\n * // x is equal to the count on the interval, e.g. (0, 1, 2, 3, ...)\n * // x will occur every 1000ms\n * // if x % 2 is equal to 1, print a, b, c (each on its own)\n * // if x % 2 is not equal to 1, nothing will be output\n * ```\n *\n * @see {@link Observable}\n * @see {@link NEVER}\n * @see {@link of}\n * @see {@link throwError}\n */\nexport const EMPTY = new Observable((subscriber) => subscriber.complete());\n\n/**\n * @param scheduler A {@link SchedulerLike} to use for scheduling\n * the emission of the complete notification.\n * @deprecated Replaced with the {@link EMPTY} constant or {@link scheduled} (e.g. `scheduled([], scheduler)`). Will be removed in v8.\n */\nexport function empty(scheduler?: SchedulerLike) {\n return scheduler ? emptyScheduled(scheduler) : EMPTY;\n}\n\nfunction emptyScheduled(scheduler: SchedulerLike) {\n return new Observable((subscriber) => scheduler.schedule(() => subscriber.complete()));\n}\n", "import { SchedulerLike } from '../types';\nimport { isFunction } from './isFunction';\n\nexport function isScheduler(value: any): value is SchedulerLike {\n return value && isFunction(value.schedule);\n}\n", "import { SchedulerLike } from '../types';\nimport { isFunction } from './isFunction';\nimport { isScheduler } from './isScheduler';\n\nfunction last(arr: T[]): T | undefined {\n return arr[arr.length - 1];\n}\n\nexport function popResultSelector(args: any[]): ((...args: unknown[]) => unknown) | undefined {\n return isFunction(last(args)) ? args.pop() : undefined;\n}\n\nexport function popScheduler(args: any[]): SchedulerLike | undefined {\n return isScheduler(last(args)) ? args.pop() : undefined;\n}\n\nexport function popNumber(args: any[], defaultValue: number): number {\n return typeof last(args) === 'number' ? args.pop()! : defaultValue;\n}\n", "export const isArrayLike = ((x: any): x is ArrayLike => x && typeof x.length === 'number' && typeof x !== 'function');", "import { isFunction } from \"./isFunction\";\n\n/**\n * Tests to see if the object is \"thennable\".\n * @param value the object to test\n */\nexport function isPromise(value: any): value is PromiseLike {\n return isFunction(value?.then);\n}\n", "import { InteropObservable } from '../types';\nimport { observable as Symbol_observable } from '../symbol/observable';\nimport { isFunction } from './isFunction';\n\n/** Identifies an input as being Observable (but not necessary an Rx Observable) */\nexport function isInteropObservable(input: any): input is InteropObservable {\n return isFunction(input[Symbol_observable]);\n}\n", "import { isFunction } from './isFunction';\n\nexport function isAsyncIterable(obj: any): obj is AsyncIterable {\n return Symbol.asyncIterator && isFunction(obj?.[Symbol.asyncIterator]);\n}\n", "/**\n * Creates the TypeError to throw if an invalid object is passed to `from` or `scheduled`.\n * @param input The object that was passed.\n */\nexport function createInvalidObservableTypeError(input: any) {\n // TODO: We should create error codes that can be looked up, so this can be less verbose.\n return new TypeError(\n `You provided ${\n input !== null && typeof input === 'object' ? 'an invalid object' : `'${input}'`\n } where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`\n );\n}\n", "export function getSymbolIterator(): symbol {\n if (typeof Symbol !== 'function' || !Symbol.iterator) {\n return '@@iterator' as any;\n }\n\n return Symbol.iterator;\n}\n\nexport const iterator = getSymbolIterator();\n", "import { iterator as Symbol_iterator } from '../symbol/iterator';\nimport { isFunction } from './isFunction';\n\n/** Identifies an input as being an Iterable */\nexport function isIterable(input: any): input is Iterable {\n return isFunction(input?.[Symbol_iterator]);\n}\n", "import { ReadableStreamLike } from '../types';\nimport { isFunction } from './isFunction';\n\nexport async function* readableStreamLikeToAsyncGenerator(readableStream: ReadableStreamLike): AsyncGenerator {\n const reader = readableStream.getReader();\n try {\n while (true) {\n const { value, done } = await reader.read();\n if (done) {\n return;\n }\n yield value!;\n }\n } finally {\n reader.releaseLock();\n }\n}\n\nexport function isReadableStreamLike(obj: any): obj is ReadableStreamLike {\n // We don't want to use instanceof checks because they would return\n // false for instances from another Realm, like an