Utilities
Utilities header only library
utils::Serializer< Type, SerializableType > Class Template Reference

Serialization utility class. Can perform automatic read and write. More...

Public Member Functions

 Serializer (const std::string &root_name)
 
std::vector< Type > FromJsonString (const std::string &json_string) const
 Read JSON string.
 
std::vector< std::shared_ptr< Type > > FromJsonStringAsPtr (const std::string &json_string) const
 Read JSON string, return as shared pointers.
 
std::string ToJsonString (const std::vector< Type > &objects) const
 Serialize to JSON string.
 
std::vector< Type > FromJsonFile (const std::string &file_path) const
 Read from JSON file by path.
 
std::vector< std::shared_ptr< Type > > FromJsonFileAsPtr (const std::string &file_path) const
 Read from JSON file by path, return as shared pointers.
 
bool ToJsonFile (const std::vector< Type > &objects, const std::string &file_path) const
 Serialize to JSON string and save to file.
 

Detailed Description

template<typename Type, typename SerializableType>
class utils::Serializer< Type, SerializableType >

Serialization utility class. Can perform automatic read and write.

Uses the "cereal" serialization library - https://uscilab.github.io/cereal/index.html. Cereal allows the possibility to save-load in formats:

  • Binary
  • JSON
  • XML So far this library only makes use of the "JSON" option.