Generic parsers and converters.
Generic parsing helpers (formats::parse::To and friends).
Classes | |
| struct | To |
Functions | |
| template<impl::RangeNotMap T, common::IsFormatValue Value> | |
| T | Parse (const Value &value, To< T >) |
| template<meta::IsMap T, common::IsFormatValue Value> | |
| T | Parse (const Value &value, To< T >) |
| template<typename T, typename Value> | |
| std::optional< decltype(Parse(std::declval< Value >(), To< T >{}))> | Parse (const Value &value, To< std::optional< T > >) |
| template<class Value> | |
| std::optional< std::nullptr_t > | Parse (const Value &, To< std::optional< std::nullptr_t > >) |
| template<impl::RangeNotMap T, typename Value> | |
| T | Convert (const Value &value, To< T >) |
| template<meta::IsMap T, typename Value> | |
| T | Convert (const Value &value, To< T >) |
| template<typename T, typename Value> | |
| std::optional< T > | Convert (const Value &value, To< std::optional< T > >) |
| template<class Value> | |
| std::optional< std::nullptr_t > | Convert (const Value &, To< std::optional< std::nullptr_t > >) |
| template<typename TMessage, typename = std::enable_if_t< std::is_base_of_v<::google::protobuf::Message, TMessage> && !std::is_same_v<::google::protobuf::Message, TMessage>>> | |
| TMessage | Parse (const json::Value &value, To< TMessage >) |
| Conversion from formats::json::Value to google::protobuf::Message. Uses the ProtoJSON format in the same way as protobuf::JsonToMessage called with a default options. | |
| template<typename TStruct> requires proto_structs::traits::ProtoStruct<std::remove_cvref_t<TStruct>> | |
| TStruct | Parse (const json::Value &json, To< TStruct >) |
| Converts json to protobuf struct of type TStruct. Conversion is performed by applying proto_structs::JsonToStruct to json with default protobuf::json::ParseOptions. | |
| template<typename Value> | |
| float | Parse (const Value &value, To< float >) |
| template<common::IsFormatValue Value, meta::IsInteger T> | |
| T | Parse (const Value &value, To< T >) |
| template<common::IsFormatValue Value, typename Period> | |
| std::chrono::duration< double, Period > | Parse (const Value &n, To< std::chrono::duration< double, Period > >) |
| template<common::IsFormatValue Value> | |
| std::chrono::seconds | Parse (const Value &n, To< std::chrono::seconds >) |
| template<class Value, class Duration> | |
| std::chrono::time_point< std::chrono::system_clock, Duration > | Parse (const Value &n, To< std::chrono::time_point< std::chrono::system_clock, Duration > >) |
| template<class Value> | |
| float | Convert (const Value &value, To< float >) |
| template<typename Value, meta::IsInteger T> | |
| T | Convert (const Value &value, To< T >) |
| template<typename Value> | |
| std::chrono::seconds | Convert (const Value &n, To< std::chrono::seconds >) |
| template<class Value, typename T> | |
| boost::optional< T > | Parse (const Value &value, To< boost::optional< T > >) |
| template<class Value> | |
| boost::optional< std::nullptr_t > | Parse (const Value &, To< boost::optional< std::nullptr_t > >) |
| template<class Value, typename T> | |
| boost::optional< T > | Convert (const Value &value, To< boost::optional< T > >) |
| template<class Value> | |
| boost::optional< std::nullptr_t > | Convert (const Value &, To< boost::optional< std::nullptr_t > >) |
| template<common::IsFormatValue Value> | |
| boost::uuids::uuid | Parse (const Value &value, To< boost::uuids::uuid >) |
| template<typename Value, typename T> | |
| bool | MayParseAs (const Value &, To< T >) noexcept |
| Fallback for types without a check: returns true, so the value has to be parsed. | |
| bool | MayParseAs (const formats::json::Value &value, To< std::string >) |
| Built-in check for std::string: returns false if the JSON value is not a string. | |
| bool | MayParseAs (const formats::json::Value &value, To< bool >) |
| Built-in check for bool: returns false if the JSON value is not a boolean. | |
| template<typename T> requires (meta::IsInteger<T> || std::is_floating_point_v<T>) | |
| bool | MayParseAs (const formats::json::Value &value, To< T >) |
| Built-in check for integer and floating point types: returns false if the JSON value is not a number. | |
| template<typename T, typename Value> | |
| bool | MayParseAs (const Value &value) |
| Cheap necessary condition for value.As<T>() to succeed. | |
| template<common::IsFormatValue Value, typename Duration> | |
| utils::datetime::TimeOfDay< Duration > | Parse (const Value &value, To< utils::datetime::TimeOfDay< Duration > >) |
| template<typename ParseException, typename Variant, typename TypeA> | |
| void | ThrowVariantAmbiguousParse (std::string_view path, std::type_index type_b) |
| template<class ParseException, typename Variant> | |
| void | ThrowVariantParseException (std::string_view path, std::string_view errors) |
| template<class Value, typename... Types> | |
| std::variant< decltype(Parse(std::declval< Value >(), To< Types >{}))... > | Parse (const Value &value, formats::parse::To< std::variant< Types... > >) |
| formats::json::Value | Parse (const formats::yaml::Value &yaml, formats::parse::To< formats::json::Value >) |
| Converts a YAML value to JSON format. | |
| formats::yaml::Value | Parse (const formats::json::Value &json, formats::parse::To< formats::yaml::Value >) |
| Converts a JSON value to YAML format. | |
| formats::json::RawString | Parse (const formats::yaml::Value &value, formats::parse::To< formats::json::RawString >) |
| Converts a YAML value to JSON string format. | |
| formats::json::Value | Convert (const formats::bson::Value &bson, formats::parse::To< formats::json::Value >) |
| Converts a BSON value to JSON format with type conversions. | |
| formats::bson::Value | Convert (const formats::json::Value &json, formats::parse::To< formats::bson::Value >) |
| Converts a JSON value to BSON format. | |
| formats::json::Value | Parse (const formats::bson::Value &bson, formats::parse::To< formats::json::Value >) |
| Converts a BSON value to JSON format (minimal conversion). | |
| formats::bson::Value | Parse (const formats::json::Value &json, formats::parse::To< formats::bson::Value >) |
| Converts a JSON value to BSON format (minimal conversion). | |
| google::protobuf::Timestamp | Parse (const formats::json::Value &json, formats::parse::To< google::protobuf::Timestamp >) |
| google::type::Date | Parse (const formats::json::Value &json, formats::parse::To< google::type::Date >) |
| grpc::StatusCode | Parse (const yaml_config::YamlConfig &value, To< grpc::StatusCode >) |
| yaml_config::YamlConfig parsing support for grpc::StatusCode. | |
| grpc::StatusCode | Parse (std::string_view value, To< grpc::StatusCode >) |
| Support for parsing grpc::StatusCode from string. Used for headers and map keys. | |
| ydb::DistLockSettings | Parse (const yaml_config::YamlConfig &config, To< ydb::DistLockSettings >) |
| ydb::OperationSettings | Parse (const yaml_config::YamlConfig &config, To< ydb::OperationSettings >) |
| formats::json::Value formats::parse::Convert | ( | const formats::bson::Value & | bson, |
| formats::parse::To< formats::json::Value > | ) |
Converts a BSON value to JSON format with type conversions.
Performs format conversion with special handling for BSON-specific types:
| formats::bson::ConversionException | if the BSON value contains an unknown type that cannot be converted to JSON |
| formats::bson::Value formats::parse::Convert | ( | const formats::json::Value & | json, |
| formats::parse::To< formats::bson::Value > | ) |
Converts a JSON value to BSON format.
Performs a minimal format conversion that preserves basic types (bool, int, int64, uint64, double, string, null, arrays, objects). Missing JSON values are converted to BSON null.
| boost::optional< std::nullptr_t > formats::parse::Convert | ( | const Value & | , |
| To< boost::optional< std::nullptr_t > > | ) |
Definition at line 39 of file boost_optional.hpp.
| std::optional< std::nullptr_t > formats::parse::Convert | ( | const Value & | , |
| To< std::optional< std::nullptr_t > > | ) |
Definition at line 148 of file common_containers.hpp.
| std::chrono::seconds formats::parse::Convert | ( | const Value & | n, |
| To< std::chrono::seconds > | ) |
Definition at line 133 of file common.hpp.
| boost::optional< T > formats::parse::Convert | ( | const Value & | value, |
| To< boost::optional< T > > | ) |
Definition at line 31 of file boost_optional.hpp.
| float formats::parse::Convert | ( | const Value & | value, |
| To< float > | ) |
Definition at line 122 of file common.hpp.
| std::optional< T > formats::parse::Convert | ( | const Value & | value, |
| To< std::optional< T > > | ) |
Definition at line 140 of file common_containers.hpp.
| T formats::parse::Convert | ( | const Value & | value, |
| To< T > | ) |
Definition at line 127 of file common.hpp.
| T formats::parse::Convert | ( | const Value & | value, |
| To< T > | ) |
Definition at line 132 of file common_containers.hpp.
| T formats::parse::Convert | ( | const Value & | value, |
| To< T > | ) |
Definition at line 124 of file common_containers.hpp.
| bool formats::parse::MayParseAs | ( | const formats::json::Value & | value, |
| To< T > | ) |
Built-in check for integer and floating point types: returns false if the JSON value is not a number.
Definition at line 49 of file may_parse.hpp.
|
noexcept |
Fallback for types without a check: returns true, so the value has to be parsed.
Definition at line 33 of file may_parse.hpp.
| bool formats::parse::MayParseAs | ( | const Value & | value | ) |
Cheap necessary condition for value.As<T>() to succeed.
Calls MayParseAs(value, formats::parse::To<T>{}): a built-in overload from this header, an overload found by ADL in the namespace of T, usually declared next to the Parse function of T, or the fallback that returns true. An overload must return false only if value.As<T>() is certain to throw. It should not throw itself: an exception derived from std::exception is treated as true, and the value is parsed as usual.
An overload should look only at the value itself, for example at its type, the presence of required members or the enum value, and should not check nested values: a recursive check repeats the work of parsing, especially for nested std::variant.
Definition at line 70 of file may_parse.hpp.
| formats::json::Value formats::parse::Parse | ( | const formats::bson::Value & | bson, |
| formats::parse::To< formats::json::Value > | ) |
Converts a BSON value to JSON format (minimal conversion).
Performs a minimal format conversion that only handles basic types common to both BSON and JSON (bool, int, int64, uint64, double, string, null, arrays, objects).
| formats::bson::Exception | if the BSON value is missing or contains an unknown/unsupported node type (e.g., BSON-specific types like Timestamp, Oid, Binary, etc.) |
| formats::bson::Value formats::parse::Parse | ( | const formats::json::Value & | json, |
| formats::parse::To< formats::bson::Value > | ) |
Converts a JSON value to BSON format (minimal conversion).
Performs a minimal format conversion that preserves the structure and basic types (bool, int, int64, uint64, double, string, null, arrays, objects).
| formats::json::Exception | if the JSON value is missing or contains an unknown node type that cannot be converted to BSON |
| formats::yaml::Value formats::parse::Parse | ( | const formats::json::Value & | json, |
| formats::parse::To< formats::yaml::Value > | ) |
Converts a JSON value to YAML format.
| formats::json::Exception | if the JSON value is missing or contains an unknown node type that cannot be converted to YAML |
| formats::json::RawString formats::parse::Parse | ( | const formats::yaml::Value & | value, |
| formats::parse::To< formats::json::RawString > | ) |
Converts a YAML value to JSON string format.
| formats::yaml::Exception | if the YAML value is missing or contains an unknown node type that cannot be converted to JSON |
| formats::json::Value formats::parse::Parse | ( | const formats::yaml::Value & | yaml, |
| formats::parse::To< formats::json::Value > | ) |
Converts a YAML value to JSON format.
| formats::yaml::Exception | if the YAML value is missing or contains an unknown node type that cannot be converted to JSON |
| TStruct formats::parse::Parse | ( | const json::Value & | json, |
| To< TStruct > | ) |
Converts json to protobuf struct of type TStruct. Conversion is performed by applying proto_structs::JsonToStruct to json with default protobuf::json::ParseOptions.
| TMessage formats::parse::Parse | ( | const json::Value & | value, |
| To< TMessage > | ) |
Conversion from formats::json::Value to google::protobuf::Message. Uses the ProtoJSON format in the same way as protobuf::JsonToMessage called with a default options.
Use as:
Definition at line 190 of file convert.hpp.
| boost::optional< std::nullptr_t > formats::parse::Parse | ( | const Value & | , |
| To< boost::optional< std::nullptr_t > > | ) |
Definition at line 25 of file boost_optional.hpp.
| std::optional< std::nullptr_t > formats::parse::Parse | ( | const Value & | , |
| To< std::optional< std::nullptr_t > > | ) |
Definition at line 118 of file common_containers.hpp.
| std::chrono::duration< double, Period > formats::parse::Parse | ( | const Value & | n, |
| To< std::chrono::duration< double, Period > > | ) |
Definition at line 105 of file common.hpp.
| std::chrono::seconds formats::parse::Parse | ( | const Value & | n, |
| To< std::chrono::seconds > | ) |
Definition at line 110 of file common.hpp.
| std::chrono::time_point< std::chrono::system_clock, Duration > formats::parse::Parse | ( | const Value & | n, |
| To< std::chrono::time_point< std::chrono::system_clock, Duration > > | ) |
Definition at line 117 of file common.hpp.
| std::variant< decltype(Parse(std::declval< Value >(), To< Types >{}))... > formats::parse::Parse | ( | const Value & | value, |
| formats::parse::To< std::variant< Types... > > | ) |
Definition at line 120 of file variant.hpp.
| boost::optional< T > formats::parse::Parse | ( | const Value & | value, |
| To< boost::optional< T > > | ) |
Definition at line 17 of file boost_optional.hpp.
| boost::uuids::uuid formats::parse::Parse | ( | const Value & | value, |
| To< boost::uuids::uuid > | ) |
Valid uuid strings: 0123456789abcdef0123456789abcdef 01234567-89ab-cdef-0123-456789abcdef {01234567-89ab-cdef-0123-456789abcdef} {0123456789abcdef0123456789abcdef}
Definition at line 28 of file boost_uuid.hpp.
| float formats::parse::Parse | ( | const Value & | value, |
| To< float > | ) |
Definition at line 94 of file common.hpp.
| std::optional< decltype(Parse(std::declval< Value >(), To< T >{}))> formats::parse::Parse | ( | const Value & | value, |
| To< std::optional< T > > | ) |
Definition at line 110 of file common_containers.hpp.
| T formats::parse::Parse | ( | const Value & | value, |
| To< T > | ) |
Definition at line 99 of file common.hpp.
| T formats::parse::Parse | ( | const Value & | value, |
| To< T > | ) |
Definition at line 105 of file common_containers.hpp.
| T formats::parse::Parse | ( | const Value & | value, |
| To< T > | ) |
Definition at line 100 of file common_containers.hpp.
| utils::datetime::TimeOfDay< Duration > formats::parse::Parse | ( | const Value & | value, |
| To< utils::datetime::TimeOfDay< Duration > > | ) |
Definition at line 18 of file time_of_day.hpp.
| void formats::parse::ThrowVariantAmbiguousParse | ( | std::string_view | path, |
| std::type_index | type_b ) |
Definition at line 37 of file variant.hpp.
| void formats::parse::ThrowVariantParseException | ( | std::string_view | path, |
| std::string_view | errors ) |
Definition at line 48 of file variant.hpp.