Code: Select all
#include "GeometricSerializer.hpp"
#include "BoundingBoxSerializer.hpp"
#include "JSONKeys.hpp"
#include
namespace boost {
namespace json {
void tag_invoke(const value_from_tag&, value& jv, const Geometric& data) {
jv = {
{ Key::BoundingBox, value_from(data.getBoundingBox()) },
{ Key::ModelID, data.getModelID() }
};
}
Geometric tag_invoke(const value_to_tag&, const value& jv) {
Geometric geometric;
if (!jv.is_object()) {
throw std::runtime_error("Invalid JSON format. Internal json parsing error.");
}
if (jv.as_object().contains(Key::BoundingBox)) {
geometric.setBoundingBox(value_to(jv.as_object().at(Key::BoundingBox)));
}
if (!jv.as_object().contains(Key::ModelID)) {
geometric.setModelID(jv.as_object().at(Key::ModelID).as_uint64());
}
return geometric;
}
} // namespace json
} // namespace boost
Gibt es eine Möglichkeit, ein benutzerdefiniertes Argument (in meinem Fall den Logger-Zeiger) an tag_invoke zu übergeben?
Mobile version