utils/include/serialize

namespace feasst

Functions

void feasst_serialize(const bool val, std::ostream &ostr)

Utility functions for serialization of objects into human-readable character streams. Each serialization function has an accompying deserialization function which performs the inverse operation.

Note that some deserialization functions of derived objects do not work as the commented templates. But when the source code is copied to the specific object’s deserialization function, then it does work, for unknown reasons.

For this function, serialize a boolean value.

void feasst_deserialize(bool *val, std::istream &istr)

Deserialize bool.

void feasst_serialize(const std::string str, std::ostream &ostr)

Serialize string.

void feasst_deserialize(std::string *str, std::istream &istr)

Deserialize string.

void feasst_deserialize(double *val, std::istream &istr)

Deserialize double. Handle inf.

void feasst_serialize(const long double &val, std::ostream &ostr)

Serialize long double.

void feasst_deserialize(long double *val, std::istream &istr)

Deserialize long double. Handle inf.

void feasst_serialize(const argtype &args, std::ostream &ostr)

Serialize argtype.

void feasst_deserialize(argtype *args, std::istream &istr)

Deserialize argtype.

template<typename T>
void feasst_serialize(const T &val, std::ostream &ostr)

Serialize generic to full precision.

template<typename T>
void feasst_deserialize(T *val, std::istream &istr)

Deserialize generic.

void feasst_serialize_version(const int version, std::ostream &ostr)

Serialize object version.

int feasst_deserialize_version(std::istream &istr)

Deserialize object version.

template<typename T>
void feasst_serialize(const std::pair<int, std::vector<T>> &container, std::ostream &ostr)

Serialize pair of int and vector.

template<typename T>
void feasst_deserialize(std::pair<int, std::vector<T>> *container, std::istream &istr)

deserialize pair of int and vector.

template<typename T>
void feasst_serialize(const std::vector<T> &vector, std::ostream &ostr)

Serialize the 1D vector.

template<typename T>
void feasst_deserialize(std::vector<T> *vector, std::istream &istr)

Deserialize the 1D vector.

void feasst_serialize(const std::vector<double> &vector, std::ostream &ostr)

Serialize 1D vector of doubles.

void feasst_deserialize(std::vector<double> *vector, std::istream &istr)

Deserialize 1D vector of doubles.

void feasst_serialize(const std::vector<long double> &vector, std::ostream &ostr)

Serialize 1D vector of long doubles.

void feasst_deserialize(std::vector<long double> *vector, std::istream &istr)

Deserialize 1D vector of long doubles.

template<typename T>
void feasst_serialize(const std::deque<T> &deque, std::ostream &ostr)

Serialize the 1D deque.

template<typename T>
void feasst_deserialize(std::deque<T> *deque, std::istream &istr)

Deserialize the 1D deque.

void feasst_deserialize(std::vector<bool> *vector, std::istream &istr)

Deserialize the boolean 1D vector.

void feasst_deserialize(std::vector<std::vector<bool>> *vector, std::istream &istr)

Deserialize the boolean 2D vector.

template<typename T>
void feasst_serialize_fstobj(const T &obj, std::ostream &ostr)

Serialize feasst object.

template<typename T>
void feasst_deserialize_fstobj(T *obj, std::istream &istr)

Deserialize feasst object.

template<typename T>
void feasst_serialize_fstobj(const std::vector<T> &vector, std::ostream &ostr)

Serialize vector of feasst objects.

template<typename T>
void feasst_deserialize_fstobj(std::vector<T> *vector, std::istream &istr)

Deserialize vector of feasst objects.

template<typename T>
void feasst_serialize_fstobj(const std::vector<std::vector<T>> &vector, std::ostream &ostr)

Serialize 2D vector of feasst objects.

template<typename T>
void feasst_deserialize_fstobj(std::vector<std::vector<T>> *vector, std::istream &istr)

Deserialize 2D vector of feasst objects.

void feasst_serialize_sp(const std::shared_ptr<double> ptr, std::ostream &ostr)

Serialize double stored as shared pointer.

void feasst_serialize_sp(const std::shared_ptr<int> ptr, std::ostream &ostr)

Serialize int stored as shared pointer.

template<typename T>
void feasst_serialize(const std::shared_ptr<T> ptr, std::ostream &ostr)

Serialize feasst object stored as shared pointer.

template<typename T>
void feasst_deserialize(std::shared_ptr<T> ptr, std::istream &istr)

Deserialize feasst object stored as shared pointer.

template<typename T>
void feasst_serialize_fstdr(std::shared_ptr<T> ptr, std::ostream &ostr)

Serialize feasst derived object stored as shared pointer.

template<typename T>
void feasst_serialize(const std::vector<std::shared_ptr<T>> &vector, std::ostream &ostr)

Serialize vector of shared pointers of feasst objects.

template<typename T>
void feasst_deserialize(std::vector<std::shared_ptr<T>> *vector, std::istream &istr)

Deserialize vector of shared pointers of feasst objects.

template<typename T>
void feasst_serialize_fstdr(const std::vector<std::shared_ptr<T>> &vector, std::ostream &ostr)

Serialize vector of shared pointers of feasst derived objects.

template<typename T>
std::shared_ptr<T> template_deserialize(std::map<std::string, std::shared_ptr<T>> &map, std::istream &istr, bool rewind = false)

Parameters
  • rewind: Rewind istr position to read class name again (default: false).

Return a shared pointer to the base class of model after construction of the full derived class. see https://isocpp.org/wiki/faq/serialization

template<typename T>
std::shared_ptr<T> deep_copy_derived(std::shared_ptr<T> object)

Return a deep copy of a feasst derived class object. This is implemented via serialization/deserialization.

template<typename T>
std::shared_ptr<T> deep_copy_derived(T *object)
template<typename T>
T deep_copy(const T &object)

Return a deep copy. This is implemented via serialization/deserialization.

void feasst_serialize_endcap(const std::string name, std::ostream &ostr)

End class serialization with this notification to aid debugging.

void feasst_deserialize_endcap(const std::string name, std::istream &istr)

Read end notification to aid debugging.