Go to the source code of this file.
|
#define | FARM_PROTO_CONV_TRAIT(TCpp, TProto) |
| Convenience macro to define the ToProtoTrait and FromProtoTrait as well as the toProt and fromProt function templates instantiation declarations for a given C++ type TCpp and a given proto type TProto . Hence, this macro is typically used in a header file. More...
|
|
|
template<class TProto > |
auto | farm_ng::fromProt (TProto const &proto) -> Expected< typename FromProtoTrait< TProto >::CppType > |
| Function template to convert a C++ object to a proto object. More...
|
|
template<class TCpp > |
auto | farm_ng::toProt (TCpp const &cpp) -> typename ToProtoTrait< TCpp >::ProtoType |
| Function template to convert a proto object to a C++ object. More...
|
|
◆ FARM_PROTO_CONV_TRAIT
#define FARM_PROTO_CONV_TRAIT |
( |
|
TCpp, |
|
|
|
TProto |
|
) |
| |
Value: template <> \
struct ToProtoTrait<TCpp> { \
using ProtoType = TProto; \
}; \
template <> \
struct FromProtoTrait<TProto> { \
using CppType = TCpp; \
}; \
template <> \
auto fromProt<TProto>(TProto const& proto)->Expected<TCpp>; \
\
template <> \
auto toProt<TCpp>(TCpp const& cpp)->TProto
Convenience macro to define the ToProtoTrait
and FromProtoTrait
as well as the toProt
and fromProt
function templates instantiation declarations for a given C++ type TCpp
and a given proto type TProto
. Hence, this macro is typically used in a header file.
Example:
FARM_PROTO_CONV_TRAIT(Eigen::Vector3d, proto::Vec3F64);
produces the following code:
template <>
struct ToProtoTrait<Eigen::Vector3d> {
using ProtoType = proto::Vec3F64;
};
template <>
struct FromProtoTrait<proto::Vec3F64> {
using CppType = Eigen::Vector3d;
};
template <>
auto fromProt<proto::Vec3F64>(proto::Vec3F64 const& proto)
-> Expected<Eigen::Vector3d>;
template <>
auto toProt<Eigen::Vector3d>(Eigen::Vector3d const& cpp)
-> proto::Vec3F64;