fpmas 1.6
breakpoint.h
Go to the documentation of this file.
1#ifndef FPMAS_BREAKPOINT_H
2#define FPMAS_BREAKPOINT_H
3
10#include <iostream>
11
13#include "nlohmann/json.hpp"
14
15namespace fpmas { namespace io {
16
25 template<typename T>
26 class Breakpoint : public api::io::Breakpoint<T> {
27 public:
39 void dump(std::ostream& stream, const T& object) override {
40 nlohmann::json j;
41 nlohmann::json::json_serializer<T, void>::to_json(j, object);
42 std::vector<uint8_t> data = nlohmann::json::to_msgpack(j);
43 for(auto i : data)
44 // Conversion from uint8_t to char
45 stream.put(i);
46 }
47
66 void load(std::istream& stream, T& object) override {
67 std::vector<uint8_t> data;
68 // Conversion from char to uint8_t
69 for(char i; stream.get(i);)
70 data.push_back(i);
71
72 nlohmann::json j = nlohmann::json::from_msgpack(data);
73 nlohmann::json::json_serializer<T, void>::from_json(j, object);
74 }
75 };
76}}
77#endif
Definition: breakpoint.h:26
Definition: breakpoint.h:26
void dump(std::ostream &stream, const T &object) override
Definition: breakpoint.h:39
void load(std::istream &stream, T &object) override
Definition: breakpoint.h:66
Definition: fpmas.cpp:3