Top namespace for the proto-structs library.
Namespaces | |
| namespace | io |
| Namespace for conversion utilities and predefined proto-structs conversion hooks for well-known std/userver types. | |
| namespace | traits |
| Namespace contains types for obtaining meta information (traits, concepts, etc.). | |
Classes | |
| class | Any |
Wrapper for google.protobuf.Any which provides interface to access stored message as compatible struct. More... | |
| class | AnyPackError |
| Error packing protobuf message to proto_structs::Any underlying storage. More... | |
| class | AnyUnpackError |
| Error unpacking protobuf message from proto_structs::Any underlying storage. More... | |
| class | ConversionError |
| Conversion error base class. More... | |
| class | Date |
Type to represent google.type.Date in proto structs. More... | |
| class | Duration |
Type to represent google.protobuf.Duration in proto structs. More... | |
| class | Error |
| Library basic exception type. All other proto-structs exceptions are derived from this type. More... | |
| class | Oneof |
Wrapper for oneof protobuf message fields. More... | |
| class | OneofAccessError |
| Invalid attempt to access unset proto_structs::Oneof field. More... | |
| class | ReadError |
| Error reading proto struct from protobuf message or binary data. More... | |
| class | TimeOfDay |
Type to represent google.type.TimeOfDay in proto structs. More... | |
| class | Timestamp |
Type to represent google.protobuf.Timestamp in proto structs. More... | |
| struct | UnbreakableDependencyCycle |
| A type that is generated for a field that participates in an unbreakable dependency cycle. More... | |
| class | ValueError |
| Incorrect value error. More... | |
| class | WriteError |
| Error writing proto struct to protobuf message or binary data. More... | |
Typedefs | |
| template<typename Key, typename Value> | |
| using | HashMap |
| The hash map container used in userver proto structs by default. | |
| template<std::size_t Index, traits::Oneof TOneof> | |
| using | OneofAlternativeTrait = impl::OneofAlternativeTrait<Index, typename TOneof::Base> |
Provides information about proto_structs::Oneof field type at position Index. | |
| template<std::size_t Index, typename TOneof> | |
| using | OneofAlternativeType = OneofAlternativeTrait<Index, TOneof>::Type |
Functions | |
| template<traits::ProtoMessage TMessage, traits::ProtoStruct TStruct> | |
| void | MessageToStruct (const TMessage &msg, TStruct &obj) |
| Converts protobuf message msg to proto struct obj. | |
| template<traits::ProtoStruct TStruct, traits::ProtoMessage TMessage> | |
| TStruct | MessageToStruct (const TMessage &msg) |
| Converts protobuf message msg to specified proto struct type. | |
| template<typename TStruct, traits::ProtoMessage TMessage> requires traits::ProtoStruct<std::remove_cvref_t<TStruct>> | |
| void | StructToMessage (TStruct &&obj, TMessage &msg) |
| Converts proto struct obj to protobuf message msg. | |
| template<typename TStruct> requires traits::ProtoStruct<std::remove_cvref_t<TStruct>> | |
| traits::CompatibleMessageType< std::remove_cvref_t< TStruct > > | StructToMessage (TStruct &&obj) |
| Converts proto struct obj to it's compatible protobuf message type. | |
| template<typename TStruct> requires traits::ProtoStruct<std::remove_cvref_t<TStruct>> | |
| void | BinaryToStruct (std::string_view binary_data, TStruct &obj) |
| Converts binary data binary_data to proto struct obj. | |
| template<typename TStruct> requires traits::ProtoStruct<std::remove_cvref_t<TStruct>> | |
| TStruct | BinaryToStruct (std::string_view binary_data) |
| Converts binary data binary_data to specified proto struct type. | |
| template<typename TStruct> requires traits::ProtoStruct<std::remove_cvref_t<TStruct>> | |
| std::string | StructToBinary (TStruct &&obj) |
| Converts proto struct obj to it's compatible binary data. | |
| template<typename TStruct> requires traits::ProtoStruct<std::remove_cvref_t<TStruct>> | |
| formats::json::Value | StructToJson (TStruct &&obj, const protobuf::json::PrintOptions &options) |
| Converts protobuf struct obj to formats::json::Value. Conversion is performed by converting the protobuf struct to an intermediate protobuf message and then converting the message to formats::json::Value. | |
| template<typename TStruct> requires traits::ProtoStruct<std::remove_cvref_t<TStruct>> | |
| std::string | StructToJsonString (TStruct &&obj, const protobuf::json::PrintOptions &options) |
| Converts protobuf struct obj to an std::string, containing the JSON representation of the struct. Conversion is performed by converting the protobuf struct to an intermediate protobuf message, then converting the message to formats::json::Value, and finally converting the value to a string. | |
| template<typename TStruct> requires traits::ProtoStruct<std::remove_cvref_t<TStruct>> | |
| TStruct | JsonToStruct (const formats::json::Value &json, const protobuf::json::ParseOptions &options) |
Converts json to protobuf struct of type TStruct. Conversion is performed by converting the formats::json::Value to an intermediate protobuf message and then converting the message to a protobuf struct. | |
| template<typename TStruct> requires traits::ProtoStruct<std::remove_cvref_t<TStruct>> | |
| TStruct | JsonStringToStruct (std::string_view json_string, const protobuf::json::ParseOptions &options) |
Converts json_string to protobuf struct of type TStruct. Conversion is performed by first converting the string to formats::json::Value, then converting the value to an intermediate protobuf message, and finally converting the message to a protobuf struct. | |
Variables | |
| constexpr std::size_t | kOneofNpos = -1 |
Special index value used to indicate oneof without any field set. | |
| using proto_structs::HashMap |
The hash map container used in userver proto structs by default.
Currently implemented as just std::unordered_map. Please don't assume it! For example:
std::unordered_map, use proto_structs::HashMap instead;std::unordered_map with these fields. Definition at line 23 of file hash_map.hpp.
| using proto_structs::OneofAlternativeTrait = impl::OneofAlternativeTrait<Index, typename TOneof::Base> |
Provides information about proto_structs::Oneof field type at position Index.
Definition at line 134 of file type_mapping.hpp.
| using proto_structs::OneofAlternativeType = OneofAlternativeTrait<Index, TOneof>::Type |
Definition at line 137 of file type_mapping.hpp.
|
nodiscard |
Converts binary data binary_data to specified proto struct type.
| TStruct | proto struct type |
| ReadError | if conversion has failed. |
Definition at line 117 of file convert.hpp.
| void proto_structs::BinaryToStruct | ( | std::string_view | binary_data, |
| TStruct & | obj ) |
Converts binary data binary_data to proto struct obj.
| TStruct | proto struct type |
| ReadError | if conversion has failed. |
Definition at line 103 of file convert.hpp.
|
nodiscard |
Converts json_string to protobuf struct of type TStruct. Conversion is performed by first converting the string to formats::json::Value, then converting the value to an intermediate protobuf message, and finally converting the message to a protobuf struct.
| TStruct | protobuf struct type |
| ParseError | if JSON to message conversion has failed. |
| MemberMissingException | is json holds nothing. |
| ReadError | if message to struct conversion has failed. The conversion is perfomed according to ProtoJSON specification. |
proto2 syntax is not fully supported and tested (at least extension fields are not supported).
|
nodiscard |
Converts json to protobuf struct of type TStruct. Conversion is performed by converting the formats::json::Value to an intermediate protobuf message and then converting the message to a protobuf struct.
| TStruct | protobuf struct type |
| ParseError | if JSON to message conversion has failed. |
| MemberMissingException | is json holds nothing. |
| ReadError | if message to struct conversion has failed. The conversion is perfomed according to ProtoJSON specification. |
proto2 syntax is not fully supported and tested (at least extension fields are not supported).
|
nodiscard |
Converts protobuf message msg to specified proto struct type.
| TStruct | proto struct type |
| TMessage | protobuf message type |
| ReadError | if conversion has failed. |
Definition at line 58 of file convert.hpp.
| void proto_structs::MessageToStruct | ( | const TMessage & | msg, |
| TStruct & | obj ) |
Converts protobuf message msg to proto struct obj.
| TMessage | protobuf message type |
| TStruct | proto struct type |
| ReadError | if conversion has failed. |
Definition at line 38 of file convert.hpp.
|
nodiscard |
Converts proto struct obj to it's compatible binary data.
| TStruct | proto struct type |
| WriteError | if conversion has failed. |
Definition at line 128 of file convert.hpp.
|
nodiscard |
Converts protobuf struct obj to formats::json::Value. Conversion is performed by converting the protobuf struct to an intermediate protobuf message and then converting the message to formats::json::Value.
| TStruct | protobuf struct type |
| WriteError | if struct to message conversion has failed. |
| PrintError | if message to JSON conversion has failed. |
|
nodiscard |
Converts protobuf struct obj to an std::string, containing the JSON representation of the struct. Conversion is performed by converting the protobuf struct to an intermediate protobuf message, then converting the message to formats::json::Value, and finally converting the value to a string.
| TStruct | protobuf struct type |
| WriteError | if struct to message conversion has failed. |
| PrintError | if message to JSON conversion has failed. |
|
nodiscard |
Converts proto struct obj to it's compatible protobuf message type.
| TStruct | proto struct type |
| WriteError | if conversion has failed. |
Definition at line 91 of file convert.hpp.
| void proto_structs::StructToMessage | ( | TStruct && | obj, |
| TMessage & | msg ) |
Converts proto struct obj to protobuf message msg.
| TStruct | proto struct type |
| TMessage | protobuf message type |
| WriteError | if conversion has failed. |
Definition at line 71 of file convert.hpp.
|
inlineconstexpr |
Special index value used to indicate oneof without any field set.
Definition at line 130 of file type_mapping.hpp.