serdes#

namespace heph
namespace serdes
class DynamicDeserializer#

Public Functions

void registerSchema(const TypeInfo &type_info)#
std::string toJson(const std::string &type, std::span<const std::byte> data)#
std::string toText(const std::string &type, std::span<const std::byte> data)#
namespace heph
namespace serdes
namespace protobuf
namespace heph
namespace serdes

Functions

template<class T>
std::string serializeToJSON(const T &data)#

Serialize data to JSON. This is achieved by checking at compile time what serialization capabilities are provided for the input data. In order of priority, the following serialization methods are checked:

template<class T>
void deserializeFromJSON(std::string_view json, T &data)#

Deserialize data from JSON. See serializeToJSON for more details.

template<protobuf::ProtobufSerializable T>
std::string serializeToJSON(const T &data)#

Serialize data to JSON. This is achieved by checking at compile time what serialization capabilities are provided for the input data. In order of priority, the following serialization methods are checked:

template<JSONSerializable T>
std::string serializeToJSON(const T &data)#

Serialize data to JSON. This is achieved by checking at compile time what serialization capabilities are provided for the input data. In order of priority, the following serialization methods are checked:

template<NlohmannJSONSerializable T>
std::string serializeToJSON(const T &data)#

Serialize data to JSON. This is achieved by checking at compile time what serialization capabilities are provided for the input data. In order of priority, the following serialization methods are checked:

template<protobuf::ProtobufSerializable T>
void deserializeFromJSON(std::string_view json, T &data)#

Deserialize data from JSON. See serializeToJSON for more details.

template<JSONDeserializable T>
void deserializeFromJSON(std::string_view json, T &data)#

Deserialize data from JSON. See serializeToJSON for more details.

template<NlohmannJSONSerializable T>
void deserializeFromJSON(std::string_view json, T &data)#

Deserialize data from JSON. See serializeToJSON for more details.

namespace heph
namespace serdes
namespace protobuf

Functions

template<class T>
std::vector<std::byte> serialize(const T &data)#
template<class T>
std::string serializeToJSON(const T &data)#
template<class T>
std::string serializeToText(const T &data)#
template<class T>
void deserialize(std::span<const std::byte> buffer, T &data)#
template<class T>
void deserializeFromJSON(std::string_view buffer, T &data)#
template<class T>
void deserializeFromText(std::string_view buffer, T &data)#
template<class T>
TypeInfo getTypeInfo()#

Create the type info for the serialized type associated with T.

namespace heph
namespace serdes
namespace protobuf
namespace heph
namespace serdes
namespace protobuf
class DeserializerBuffer#

Public Functions

inline explicit DeserializerBuffer(std::span<const std::byte> buffer)#
template<ProtobufMessage Proto>
inline bool deserialize(Proto &proto) const#
class SerializerBuffer#

Public Functions

template<ProtobufMessage Proto>
inline void serialize(const Proto &proto)#
inline std::vector<std::byte> &&extractSerializedData() &&#
namespace heph
namespace serdes
namespace protobuf

Functions

template<Arithmetic T, typename ProtoT>
void toProto(ProtoT &proto_value, const T value)#
template<Arithmetic T, typename ProtoT>
void fromProto(const ProtoT &proto_value, T &value)#
template<Arithmetic T, typename ProtoT>
void toProto(google::protobuf::RepeatedField<ProtoT> &proto_repeated_field, const std::vector<T> &vec)#
template<typename T, typename ProtoT>
void toProto(google::protobuf::RepeatedPtrField<ProtoT> &proto_repeated_ptr_field, const std::vector<T> &vec)#
template<Arithmetic T, typename ProtoT>
void fromProto(const google::protobuf::RepeatedField<ProtoT> &proto_repeated_field, std::vector<T> &vec)#
template<typename T, typename ProtoT>
void fromProto(const google::protobuf::RepeatedPtrField<ProtoT> &proto_repeated_ptr_field, std::vector<T> &vec)#
template<Arithmetic T, typename ProtoT, std::size_t N>
void toProto(google::protobuf::RepeatedField<ProtoT> &proto_repeated_field, const std::array<T, N> &arr)#
template<typename T, typename ProtoT, std::size_t N>
void toProto(google::protobuf::RepeatedPtrField<ProtoT> &proto_repeated_ptr_field, const std::array<T, N> &arr)#
template<Arithmetic T, typename ProtoT, std::size_t N>
void fromProto(const google::protobuf::RepeatedField<ProtoT> &proto_repeated_field, std::array<T, N> &arr)#
template<typename T, typename ProtoT, std::size_t N>
void fromProto(const google::protobuf::RepeatedPtrField<ProtoT> &proto_repeated_ptr_field, std::array<T, N> &arr)#
template<typename K, typename V, typename ProtoK, typename ProtoV>
void toProto(google::protobuf::Map<ProtoK, ProtoV> &proto_map, const std::unordered_map<K, V> &umap)#
template<typename K, typename V, typename ProtoK, typename ProtoV>
void fromProto(const google::protobuf::Map<ProtoK, ProtoV> &proto_map, std::unordered_map<K, V> &umap)#
namespace heph
namespace serdes
namespace protobuf

Functions

template<EnumType ProtoT, EnumType T>
ProtoT toProtoEnum(const T &enum_value)#
template<EnumType ProtoT, EnumType T>
void fromProto(const ProtoT &proto_enum_value, T &enum_value)#
namespace heph
namespace serdes
namespace protobuf
class DynamicDeserializer#

Public Functions

void registerSchema(const TypeInfo &type_info)#
std::string toJson(const std::string &type, std::span<const std::byte> data)#
std::string toText(const std::string &type, std::span<const std::byte> data)#
namespace heph
namespace serdes

Functions

template<typename T>
std::vector<std::byte> serialize(const T &data)#
template<typename T>
std::string serializeToText(const T &data)#
template<typename T>
void deserialize(std::span<const std::byte> buffer, T &data)#
template<typename T>
void deserializeFromText(std::string_view buffer, T &data)#
template<typename T>
TypeInfo getSerializedTypeInfo()#

Variables

template<typename T>
static bool NOT_SERIALIZABLE = false#

Serdes module provides generic support for serialization and deserialization of data types. It is built to support any serialization library via template specialization. Right now it only support Protobuf, but can be easily extended to support other libraries by simply writing a new concept for your serialization library.

namespace heph
namespace serdes
struct ActionServerTypeInfo#

Public Members

TypeInfo request#
TypeInfo reply#
TypeInfo status#

Public Functions

std::string toJson() const#
bool=default operator== (const ActionServerTypeInfo &) const

Public Static Functions

static ActionServerTypeInfo fromJson(const std::string &info)#
struct ServiceTypeInfo#

Public Members

TypeInfo request#
TypeInfo reply#

Public Functions

std::string toJson() const#
bool isValid() const#
bool=default operator== (const ServiceTypeInfo &) const

Public Static Functions

static ServiceTypeInfo fromJson(const std::string &info)#
struct TypeInfo#

Public Types

enum class Serialization : uint8_t#

Values:

enumerator TEXT#
enumerator JSON#
enumerator PROTOBUF#

Public Members

std::string name#
std::vector<std::byte> schema#
Serialization serialization = Serialization::TEXT#
std::string original_type#

Public Functions

std::string toJson() const#

The type that is serialized by this.

bool isValid() const#
bool=default operator== (const TypeInfo &) const

Public Static Functions

static TypeInfo fromJson(const std::string &info)#