24#ifndef GOBY_MIDDLEWARE_MARSHALLING_INTERFACE_H
25#define GOBY_MIDDLEWARE_MARSHALLING_INTERFACE_H
69 auto it = e2s.find(e);
70 return it != e2s.end() ? it->second : std::to_string(e);
79 auto it = s2e.find(s);
80 return it != s2e.end() ? it->second : std::stoi(s);
84 static const std::map<int, std::string> e2s;
85 static const std::map<std::string, int> s2e;
102 static_assert(std::is_void<Enable>::value,
"SerializerParserHelper must be specialized");
103 return std::vector<char>();
109 static_assert(std::is_void<Enable>::value,
"SerializerParserHelper must be specialized");
110 return std::string();
116 static_assert(std::is_void<Enable>::value,
"SerializerParserHelper must be specialized");
117 return std::string();
128 template <
typename CharIterator>
129 static std::shared_ptr<DataType>
parse(CharIterator bytes_begin, CharIterator bytes_end,
130 CharIterator& actual_end,
133 static_assert(std::is_void<Enable>::value,
"SerializerParserHelper must be specialized");
134 return std::shared_ptr<DataType>();
150 return Transporter::template scheme<typename primitive_type<DataType>::type>();
167template <
typename DataType,
168 typename std::enable_if<std::is_same<DataType, void>::value>::type* =
nullptr>
171 static_assert(std::is_same<DataType, void>::value,
"Null scheme instantiated");
constexpr int transporter_scheme()
Helper function for calling a particular transporter's scheme method.
constexpr int scheme()
Placeholder to provide an interface for the scheme() function family.
The global namespace for the Goby project.
Enumeration and helper functions for marshalling scheme identification.
static int from_string(const std::string &s)
Convert from a string to a marshalling scheme id.
MarshallingSchemeEnum
Marshalilng schemes implemented in Goby.
static std::string to_string(int e)
Convert a known marshalling scheme to a human-readable string or an unknown scheme to the string repr...
Class for parsing and serializing a given marshalling scheme. Must be specialized for a particular sc...
static std::string type_name()
The marshalling scheme specific string name for this type.
static std::vector< char > serialize(const DataType &)
Given data, produce a vector of bytes.
static std::shared_ptr< DataType > parse(CharIterator bytes_begin, CharIterator bytes_end, CharIterator &actual_end, const std::string &type=type_name())
Given a beginning and end iterator to bytes, parse the data and return it.
static std::string type_name(const DataType &)
The marshalling scheme specific string name for this type, given a instantiation of the type (useful ...