8#ifndef PROXSUITE_SERIALIZATION_ARCHIVE_HPP
9#define PROXSUITE_SERIALIZATION_ARCHIVE_HPP
14#include <cereal/cereal.hpp>
15#include <cereal/archives/binary.hpp>
16#include <cereal/archives/json.hpp>
17#include <cereal/archives/xml.hpp>
20namespace serialization {
35 cereal::JSONInputArchive ia(is);
52 cereal::JSONOutputArchive oa(ss);
68 std::istringstream is(str);
102 std::ifstream ifs(filename.c_str(), std::ios::binary);
104 cereal::BinaryInputArchive ia(ifs);
107 const std::string exception_message(filename +
108 " does not seem to be a valid file.");
109 throw std::invalid_argument(exception_message);
125 std::ofstream ofs(filename.c_str(), std::ios::binary);
127 cereal::BinaryOutputArchive oa(ofs);
130 const std::string exception_message(filename +
131 " does not seem to be a valid file.");
132 throw std::invalid_argument(exception_message);
148 std::ifstream ifs(filename.c_str());
150 cereal::JSONInputArchive ia(ifs);
153 const std::string exception_message(filename +
154 " does not seem to be a valid file.");
155 throw std::invalid_argument(exception_message);
171 std::ofstream ofs(filename.c_str());
173 cereal::JSONOutputArchive oa(ofs);
176 const std::string exception_message(filename +
177 " does not seem to be a valid file.");
178 throw std::invalid_argument(exception_message);
194 std::ifstream ifs(filename.c_str());
196 cereal::XMLInputArchive ia(ifs);
199 const std::string exception_message(filename +
200 " does not seem to be a valid file.");
201 throw std::invalid_argument(exception_message);
217 std::ofstream ofs(filename.c_str());
219 cereal::XMLOutputArchive oa(ofs);
222 const std::string exception_message(filename +
223 " does not seem to be a valid file.");
224 throw std::invalid_argument(exception_message);
void loadFromBinary(T &object, const std::string &filename)
Loads an object from a binary file.
void saveToXML(const T &object, const std::string &filename)
Saves an object inside a XML file.
void saveToJSON(const T &object, const std::string &filename)
Saves an object inside a JSON file.
void saveToBinary(const T &object, const std::string &filename)
Saves an object inside a binary file.
void loadFromString(T &object, const std::string &str)
Loads an object from a std::string.
void loadFromXML(T &object, const std::string &filename)
Loads an object from a XML file.
std::string saveToString(const T &object)
Saves an object inside a std::string.
void loadFromJSON(T &object, const std::string &filename)
Loads an object from a JSON file.
void loadFromStringStream(T &object, std::istringstream &is)
Loads an object from a std::stringstream.
void saveToStringStream(const T &object, std::stringstream &ss)
Saves an object inside a std::stringstream.