Top namespace for the proto-structs library.
Namespaces | |
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 |
Failed to pack struct's compatible message to proto_structs::Any underlying storage. More... | |
class | AnyUnpackError |
Failed to unpack struct's compatible message from proto_structs::Any underlying storage. More... | |
class | ConversionError |
Conversion error Exception is thrown if protobuf message field can't be converted to/from struct field. 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 |
Trying to access unset proto_structs::Oneof field. More... | |
struct | To |
An ADL helper which allows locating functions to read structs from protobuf messages inside struct-specific namespaces. More... | |
Typedefs | |
template<std::size_t Index, typename T > | |
using | OneofAlternativeTrait = impl::OneofAlternativeTrait< Index, std::remove_cv_t< T > > |
Provides information about proto_structs::Oneof field type at position Index | |
template<std::size_t Index, typename T > | |
using | OneofAlternativeType = OneofAlternativeTrait< Index, T >::Type |
template<typename Key , typename Value > | |
using | HashMap = std::unordered_map< Key, Value, std::conditional_t< std::is_convertible_v< Key, std::string_view >, utils::StrCaseHash, std::hash< Key > > > |
The hash map container used in userver proto structs by default. | |
Functions | |
template<traits::ProtoMessage TMessage, traits::ProtoStruct TStruct> | |
void | MessageToStruct (const TMessage &msg, TStruct &obj) |
Converts protobuf message msg to struct obj. | |
template<traits::ProtoStruct TStruct, traits::ProtoMessage TMessage> | |
TStruct | MessageToStruct (const TMessage &msg) |
Converts protobuf message msg to specified structure type. | |
template<typename TStruct , traits::ProtoMessage TMessage> requires traits::ProtoStruct<std::remove_cvref_t<TStruct>> | |
void | StructToMessage (TStruct &&obj, TMessage &msg) |
Converts struct instance obj to protobuf message msg. | |
template<traits::ProtoMessage TMessage, typename TStruct > requires traits::ProtoStruct<std::remove_cvref_t<TStruct>> | |
TMessage | StructToMessage (TStruct &&obj) |
Converts struct instance obj to protobuf message msg of the specified type. | |
template<typename TStruct > requires traits::CompatibleStruct<std::remove_cvref_t<TStruct>> | |
traits::CompatibleMessageType< std::remove_cvref_t< TStruct > > | StructToMessage (TStruct &&obj) |
Converts struct instance obj to it's compatible protobuf message. | |
Variables | |
constexpr std::size_t | kOneofNpos = -1 |
Special index value used to indicate oneof without any field set. | |
using proto_structs::HashMap = typedef std::unordered_map< Key, Value, std::conditional_t<std::is_convertible_v<Key, std::string_view>, utils::StrCaseHash, std::hash<Key> >> |
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 22 of file hash_map.hpp.
using proto_structs::OneofAlternativeTrait = typedef impl::OneofAlternativeTrait<Index, std::remove_cv_t<T> > |
Provides information about proto_structs::Oneof field type at position Index
using proto_structs::OneofAlternativeType = typedef OneofAlternativeTrait<Index, T>::Type |
TStruct proto_structs::MessageToStruct | ( | const TMessage & | msg | ) |
Converts protobuf message msg to specified structure type.
TStruct | struct type |
TMessage | protobuf message type |
ConversionError | if conversion failed |
Function calls ReadStruct(obj, msg)
under the hood which should be foundable by argument-dependent lookup.
Definition at line 39 of file convert.hpp.
void proto_structs::MessageToStruct | ( | const TMessage & | msg, |
TStruct & | obj | ||
) |
Converts protobuf message msg to struct obj.
TMessage | protobuf message type |
TStruct | struct type |
ConversionError | if conversion failed (in that case obj is not modified) |
Function calls ReadStruct(obj, msg)
under the hood which should be foundable by argument-dependent lookup.
Definition at line 26 of file convert.hpp.
TMessage proto_structs::StructToMessage | ( | TStruct && | obj | ) |
Converts struct instance obj to protobuf message msg of the specified type.
TStruct | struct type |
TMessage | protobuf message type |
ConversionError | if conversion failed |
Function calls WriteStruct(std::forward<TStruct>(obj), msg)
under the hood which should be foundable by argument-dependent lookup.
Definition at line 70 of file convert.hpp.
traits::CompatibleMessageType< std::remove_cvref_t< TStruct > > proto_structs::StructToMessage | ( | TStruct && | obj | ) |
Converts struct instance obj to it's compatible protobuf message.
TStruct | struct type |
ConversionError | if conversion failed |
Compatability information should be provided for TStruct
with proto_structs::compatible_message, otherwise compilation will fail.
Function calls WriteStruct(std::forward<TStruct>(obj), msg)
under the hood which should be foundable by argument-dependent lookup.
Definition at line 87 of file convert.hpp.
void proto_structs::StructToMessage | ( | TStruct && | obj, |
TMessage & | msg | ||
) |
Converts struct instance obj to protobuf message msg.
TStruct | struct type |
TMessage | protobuf message type |
ConversionError | if conversion failed (in that case msg is not modified) |
Function calls WriteStruct(std::forward<TStruct>(obj), msg)
under the hood which should be foundable by argument-dependent lookup.
Definition at line 55 of file convert.hpp.