1 #ifndef BOOSTANYSERIALIZER_H
2 #define BOOSTANYSERIALIZER_H
4 #include "cereal/cereal.hpp"
6 #include "parcer/Eigen.h"
7 #include <boost/any.hpp>
8 #include <cereal/types/string.hpp>
18 boost::any
const&
any;
27 template<
class Archive>
34 template<
typename BaseType>
35 static boost::any
load(Archive & ar)
39 return boost::any(temp);
42 template<
typename BaseType>
43 static void save(boost::any obj, Archive & ar)
46 const std::string& typeName = obj.type().name();
50 BaseType
const& val = boost::any_cast<const BaseType&>(obj);
58 template<
class Archive>
61 if(obj.
any.type() ==
typeid(
bool)){
63 }
else if(obj.
any.type() ==
typeid(
double)){
65 }
else if(obj.
any.type() ==
typeid(
float)){
67 }
else if(obj.
any.type() ==
typeid(std::string)){
69 }
else if(obj.
any.type() ==
typeid(
int)){
71 }
else if(obj.
any.type() ==
typeid(
unsigned int)){
74 }
else if(obj.
any.type() ==
typeid(Eigen::Vector2d)){
76 }
else if(obj.
any.type() ==
typeid(Eigen::Vector3d)){
78 }
else if(obj.
any.type() ==
typeid(Eigen::Vector4d)){
80 }
else if(obj.
any.type() ==
typeid(Eigen::VectorXd)){
83 }
else if(obj.
any.type() ==
typeid(Eigen::Vector2f)){
85 }
else if(obj.
any.type() ==
typeid(Eigen::Vector3f)){
87 }
else if(obj.
any.type() ==
typeid(Eigen::Vector4f)){
89 }
else if(obj.
any.type() ==
typeid(Eigen::VectorXf)){
92 }
else if(obj.
any.type() ==
typeid(Eigen::Vector2i)){
94 }
else if(obj.
any.type() ==
typeid(Eigen::Vector3i)){
96 }
else if(obj.
any.type() ==
typeid(Eigen::Vector4i)){
98 }
else if(obj.
any.type() ==
typeid(Eigen::VectorXi)){
101 }
else if(obj.
any.type() ==
typeid(Eigen::Matrix2d)){
103 }
else if(obj.
any.type() ==
typeid(Eigen::Matrix3d)){
105 }
else if(obj.
any.type() ==
typeid(Eigen::Matrix4d)){
107 }
else if(obj.
any.type() ==
typeid(Eigen::MatrixXd)){
110 }
else if(obj.
any.type() ==
typeid(Eigen::Matrix2f)){
112 }
else if(obj.
any.type() ==
typeid(Eigen::Matrix3f)){
114 }
else if(obj.
any.type() ==
typeid(Eigen::Matrix4f)){
116 }
else if(obj.
any.type() ==
typeid(Eigen::MatrixXf)){
119 }
else if(obj.
any.type() ==
typeid(Eigen::Matrix2i)){
121 }
else if(obj.
any.type() ==
typeid(Eigen::Matrix3i)){
123 }
else if(obj.
any.type() ==
typeid(Eigen::Matrix4i)){
125 }
else if(obj.
any.type() ==
typeid(Eigen::MatrixXi)){
128 std::cout<<
"ERROR: Could not interpret type " << obj.
any.type().name() << std::endl;
136 template<
class Archive>
137 void load(Archive & ar, boost::any & obj)
140 std::string typeName;
144 if(typeName ==
typeid(
bool).name()){
146 }
else if(typeName ==
typeid(
double).name()){
148 }
else if(typeName ==
typeid(
float).name()){
150 }
else if(typeName ==
typeid(std::string).name()){
152 }
else if(typeName ==
typeid(
int).name()){
154 }
else if(typeName ==
typeid(
unsigned int).name()){
157 }
else if(typeName ==
typeid(Eigen::Vector2d).name()){
159 }
else if(typeName ==
typeid(Eigen::Vector3d).name()){
161 }
else if(typeName ==
typeid(Eigen::Vector4d).name()){
163 }
else if(typeName ==
typeid(Eigen::VectorXd).name()){
166 }
else if(typeName ==
typeid(Eigen::Vector2f).name()){
168 }
else if(typeName ==
typeid(Eigen::Vector3f).name()){
170 }
else if(typeName ==
typeid(Eigen::Vector4f).name()){
172 }
else if(typeName ==
typeid(Eigen::VectorXf).name()){
175 }
else if(typeName ==
typeid(Eigen::Vector2i).name()){
177 }
else if(typeName ==
typeid(Eigen::Vector3i).name()){
179 }
else if(typeName ==
typeid(Eigen::Vector4i).name()){
181 }
else if(typeName ==
typeid(Eigen::VectorXi).name()){
184 }
else if(typeName ==
typeid(Eigen::Matrix2d).name()){
186 }
else if(typeName ==
typeid(Eigen::Matrix3d).name()){
188 }
else if(typeName ==
typeid(Eigen::Matrix4d).name()){
190 }
else if(typeName ==
typeid(Eigen::MatrixXd).name()){
193 }
else if(typeName ==
typeid(Eigen::Matrix2f).name()){
195 }
else if(typeName ==
typeid(Eigen::Matrix3f).name()){
197 }
else if(typeName ==
typeid(Eigen::Matrix4f).name()){
199 }
else if(typeName ==
typeid(Eigen::MatrixXf).name()){
202 }
else if(typeName ==
typeid(Eigen::Matrix2i).name()){
204 }
else if(typeName ==
typeid(Eigen::Matrix3i).name()){
206 }
else if(typeName ==
typeid(Eigen::Matrix4i).name()){
208 }
else if(typeName ==
typeid(Eigen::MatrixXi).name()){
static boost::any load(Archive &ar)
static void save(boost::any obj, Archive &ar)
void save(Archive &ar, TemporaryBoostAnyConst const &obj)
void load(Archive &ar, boost::any &obj)
TemporaryBoostAnyConst(boost::any const &anyIn)
TemporaryBoostAny(boost::any &anyIn)
TemporaryBoostAny()=default