Serialization
How to serialize a custom type can be seen in the seralization example.
typeType is a container for something you want to serialize. It holds the information how to serialize the object you created the type from, and a pointer to this object (void* obj). |
||
Name | abmt::serialize::type | |
Header | #include <abmt/serialize.h> | |
Attributes |
||
type_id | id | |
void* | obj | |
serialize_type_info | serialize_info | |
Methods |
||
type() | ||
type(bool& o) | ||
type(T& o) | ||
type(float& o) | ||
type(double& o) | ||
type(std::string& o) | ||
type(member_list lst) | ||
type(abmt::blob& blk) | ||
type(abmt::blob_shared& blk) | ||
type(const member(&ptr)[N]) | ||
type(C& o, std::enable_if_t< obj_has_define_type< C >::value& &!std::is_integral< C >::value >* =0) | Construct type from a class that has a define_type method. | |
type(C& o, std::enable_if_t< obj_serializes_to_json< C >::value& &!std::is_integral< C >::value >* =0) | Construct type from a class that has a to_- / from_json method. | |
type(C& o, std::enable_if_t< obj_serializes_to_string< C >::value& &!std::is_integral< C >::value >* =0) | Construct type from a class that has a to_- / from_string method. | |
type(C& o, std::enable_if_t<!obj_has_define_type< C >::value& &!std::is_integral< C >::value >* =0, std::enable_if_t<!obj_serializes_to_string< C >::value& &!std::is_integral< C >::value >* =0, std::enable_if_t<!obj_serializes_to_json< C >::value& &!std::is_integral< C >::value >* =0) | When no other constructor works, this one is used. It utilizes define_type. When no implementation is found it defaults to "UNDEFINDED". | |
type(blob_type r) | ||
type(string_type s) | ||
type(scene_2d_type s) | ||
type(scene_3d_type s) | ||
type(const abmt::serialize::type& e)=default | ||
type(abmt::serialize::type& e)=default | ||
size_t | get_def_size() | |
size_t | get_def(void* def_buff, size_t def_size) | |
size_t | get_size() | |
void | serialize(void* data, size_t data_size) | |
void | deserialize(void* data, size_t data_size) | |
void | deserialize(void* data, size_t data_size, void* def_buff, size_t def_size) | |
double | to_double(void* data_ptr, size_t data_len) | |
void | from_double(double d) | |
Operators |
||
type& | operator=(T& rhs) |
decoder |
||
Name | abmt::serialize::decoder | |
Header | #include <abmt/serialize.h> | |
Attributes |
||
abmt::blob | data | raw data. Can also be used to convert to string. |
abmt::blob | def | |
Methods |
||
decoder(const decoder& )=delete | ||
std::string | to_string() | This method returns "(cast me)". If you don't want to use the cast, you can access the raw data via the data member. obj.data.str() creates a string out of the raw data. |
void | from_string(std::string) | not used |
Operators |
||
operator | T() | copy is not allowed because of the ownership of the underling pointers. (You may have forgot to set the type in your cast expression.) Deserializes data and def to the type T. |
...