#include </data/code/userver/libraries/proto-structs/include/userver/proto-structs/any.hpp>
Wrapper for google.protobuf.Any
which provides interface to access stored message as compatible struct.
Definition at line 19 of file any.hpp.
|
| Any () noexcept=default |
| Creates empty Any .
|
|
| Any (google::protobuf::Any proto_any) |
| Creates wrapper initializing its underlying storage with proto_any.
|
|
template<typename TStruct >
requires traits::CompatibleStruct<std::remove_cvref_t<TStruct>> |
| Any (TStruct &&obj) |
| Creates Any holding obj.
|
|
template<typename TStruct >
requires traits::CompatibleStruct<std::remove_cvref_t<TStruct>> |
Any & | operator= (TStruct &&obj) |
| Packs obj in Any
|
|
template<traits::CompatibleStruct TStruct> |
bool | Is () const noexcept |
| Returns true if Any contains TStruct
|
|
template<traits::ProtoMessage TMessage> |
bool | Is () const noexcept |
| Returns true if underlying google.protobuf.Any contains TMessage
|
|
template<traits::CompatibleStruct TStruct> |
TStruct | Unpack () |
| Unpacks Any to TStruct struct.
|
|
template<traits::ProtoMessage TMessage> |
TMessage | Unpack () |
| Unpacks underlying google.protobuf.Any to TMessage message.
|
|
template<typename TStruct >
requires traits::CompatibleStruct<std::remove_cvref_t<TStruct>> |
void | Pack (TStruct &&obj) |
| Packs obj to Any
|
|
template<traits::ProtoMessage TMessage> |
void | Pack (const TMessage &message) |
| Packs message to underlying google.protobuf.Any
|
|
const ::google::protobuf::Any & | GetProtobufAny () const &noexcept |
| Returns underlying google.protobuf.Any
|
|
::google::protobuf::Any | GetProtobufAny () &&noexcept |
| Returns underlying google.protobuf.Any
|
|
◆ Any() [1/2]
proto_structs::Any::Any |
( |
google::protobuf::Any |
proto_any | ) |
|
|
inline |
Creates wrapper initializing its underlying storage with proto_any.
Definition at line 25 of file any.hpp.
◆ Any() [2/2]
template<typename TStruct >
requires traits::CompatibleStruct<std::remove_cvref_t<TStruct>>
proto_structs::Any::Any |
( |
TStruct && |
obj | ) |
|
|
inline |
Creates Any
holding obj.
- Template Parameters
-
TStruct | struct with defined compatability |
- Exceptions
-
ConversionError | if obj can't be converted to its compatible protobuf message |
AnyPackError | if compatible protobuf message can not be packed to google.protobuf.Any |
- Note
- This overload only works for structs for which compatability is defined using proto_structs::CompatibleMessageTrait
Definition at line 35 of file any.hpp.
◆ GetProtobufAny() [1/2]
::google::protobuf::Any proto_structs::Any::GetProtobufAny |
( |
| ) |
&& |
|
inlinenoexcept |
Returns underlying google.protobuf.Any
Definition at line 124 of file any.hpp.
◆ GetProtobufAny() [2/2]
const ::google::protobuf::Any & proto_structs::Any::GetProtobufAny |
( |
| ) |
const & |
|
inlinenoexcept |
Returns underlying google.protobuf.Any
Definition at line 121 of file any.hpp.
◆ Is() [1/2]
template<traits::CompatibleStruct TStruct>
bool proto_structs::Any::Is |
( |
| ) |
const |
|
inlinenoexcept |
Returns true
if Any
contains TStruct
- Template Parameters
-
TStruct | struct with defined compatability |
- Note
- This method only works for structs for which compatability is defined using proto_structs::CompatibleMessageTrait
Definition at line 58 of file any.hpp.
◆ Is() [2/2]
template<traits::ProtoMessage TMessage>
bool proto_structs::Any::Is |
( |
| ) |
const |
|
inlinenoexcept |
Returns true
if underlying google.protobuf.Any
contains TMessage
- Template Parameters
-
TMessage | protobuf message type |
Definition at line 66 of file any.hpp.
◆ operator=()
template<typename TStruct >
requires traits::CompatibleStruct<std::remove_cvref_t<TStruct>>
Any & proto_structs::Any::operator= |
( |
TStruct && |
obj | ) |
|
|
inline |
Packs obj in Any
- Template Parameters
-
TStruct | struct with defined compatability |
- Exceptions
-
ConversionError | if obj can't be converted to its compatible protobuf message |
AnyPackError | if compatible protobuf message can not be packed to google.protobuf.Any |
- Note
- This overload only works for structs for which compatability is defined using proto_structs::CompatibleMessageTrait
-
Method caches obj and later calls to Get will not trigger unpacking
Definition at line 48 of file any.hpp.
◆ Pack() [1/2]
template<traits::ProtoMessage TMessage>
void proto_structs::Any::Pack |
( |
const TMessage & |
message | ) |
|
|
inline |
Packs message to underlying google.protobuf.Any
- Template Parameters
-
TMessage | protobuf message type |
- Exceptions
-
AnyPackError | if packing of protobuf message to google.protobuf.Any had failed |
Definition at line 114 of file any.hpp.
◆ Pack() [2/2]
template<typename TStruct >
requires traits::CompatibleStruct<std::remove_cvref_t<TStruct>>
void proto_structs::Any::Pack |
( |
TStruct && |
obj | ) |
|
|
inline |
Packs obj to Any
- Template Parameters
-
TStruct | struct with defined compatability |
- Exceptions
-
ConversionError | if obj can't be converted to its compatible protobuf message |
AnyPackError | if packing of compatible protobuf message to google.protobuf.Any had failed |
- Note
- This method only works for structs for which compatability is defined using proto_structs::CompatibleMessageTrait
-
Method caches obj and later calls to Get will not trigger unpacking
Definition at line 105 of file any.hpp.
◆ Unpack() [1/2]
template<traits::CompatibleStruct TStruct>
TStruct proto_structs::Any::Unpack |
( |
| ) |
|
|
inline |
Unpacks Any
to TStruct
struct.
- Template Parameters
-
TStruct | struct with defined compatability |
- Exceptions
-
AnyUnpackError | if underlying google.protobuf.Any does not contain message compatible to TStruct |
ConversionError | if struct can be converted from its compatible message |
- Note
- This method only works for structs for which compatability is defined using proto_structs::CompatibleMessageTrait
Definition at line 77 of file any.hpp.
◆ Unpack() [2/2]
template<traits::ProtoMessage TMessage>
TMessage proto_structs::Any::Unpack |
( |
| ) |
|
|
inline |
Unpacks underlying google.protobuf.Any
to TMessage
message.
- Template Parameters
-
TMessage | protobuf message type |
- Exceptions
-
AnyUnpackError | if underlying google.protobuf.Any does not contain TMessage type message |
Definition at line 86 of file any.hpp.
The documentation for this class was generated from the following file:
- /data/code/userver/libraries/proto-structs/include/userver/proto-structs/any.hpp