#ifndef LIB4NEURO_EXPRTKWRAPPERSERIALIZATION_H #define LIB4NEURO_EXPRTKWRAPPERSERIALIZATION_H #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/serialization/export.hpp> #include <boost/serialization/serialization.hpp> //TODO check different order of headers - possible bug #include "ExprtkWrapper.h" #include "exprtk.hpp" //BOOST_CLASS_EXPORT_KEY(ExprtkWrapper); /** * Class implementing the private properties * of ExprtkWrapper class. */ //class ExprtkWrapper::ExprtkWrapperImpl { // //public: // // /** // * Struct used to access private properties from // * the serialization function // */ // struct access; // // /** // * // */ // expression_t* expression = nullptr; // // /** // * // */ // symbol_table_t* symbol_table = nullptr; // // /** // * // */ // parser_t* parser = nullptr; // // /** // * variables // */ // double x, y, z, t, f; // // /** // * referential expression string // */ // std::string expression_str; //}; struct ExprtkWrapper::access { template<class Archive> static void serialize(Archive& ar, ExprtkWrapper& w, const unsigned int version) {} template<class Archive> static void save_construct_data(Archive & ar, const ExprtkWrapper* w, const unsigned long int file_version){ ar << w->expression_str; ar << w->x; ar << w->y; ar << w->z; ar << w->t; ar << w->f; } template<class Archive> static void load_construct_data(Archive & ar, ExprtkWrapper* w, const unsigned long int file_version) { expression_t* expression; symbol_table_t* symbol_table; parser_t* parser; double x, y, z, t, f; std::string expression_str; ar >> expression_str; ar >> x; ar >> y; ar >> z; ar >> t; ar >> f; ::new(w)ExprtkWrapper(expression, symbol_table, parser, x, y, z, t, f, expression_str); } }; namespace boost::serialization { template<class Archive> inline void load_construct_data(Archive & ar, ExprtkWrapper* w, const unsigned long int file_version) { ExprtkWrapper::access::load_construct_data(ar, w, file_version); } template<class Archive> inline void save_construct_data(Archive & ar, const ExprtkWrapper* w, const unsigned long int file_version) { ExprtkWrapper::access::save_construct_data(ar, w, file_version); } /** * Serialization function * @tparam Archive Boost library template * @param ar Boost parameter - filled automatically during serialization! * @param n ExprtkWrapper instance * @param version Boost parameter - filled automatically during serialization! */ template<class Archive> void serialize(Archive& ar, ExprtkWrapper& n, const unsigned int version) {} } // namespace boost::serialization #endif //LIB4NEURO_EXPRTKWRAPPERSERIALIZATION_H