serialization
51 строка · 961.0 Байт
1#include <bitset>
2#include <cstdint>
3#include <format>
4#include <fstream>
5#include <iostream>
6#include <istream>
7#include <memory>
8#include <vector>
9
10#include "serialization/serialization.hpp"
11
12int main(int argc, char** argv) {
13using namespace object_model;
14using namespace utilities;
15using namespace serialization;
16
17{
18serialization::Serialization ser;
19
20int i = 5;
21ser.addField("i", i);
22
23std::vector v = {1, 2, 3, 4};
24ser.addField("v", v);
25
26std::string s = "str";
27ser.addField("s", s);
28
29std::ofstream ofs("ser.abc");
30ser.save(ofs);
31}
32
33{
34serialization::Deserialization dser;
35std::ifstream ifs("ser.abc");
36dser.load(ifs);
37
38std::string s;
39dser.getField("s", s);
40
41std::vector<int> v;
42dser.getField("v", v);
43
44int i = 0;
45dser.getField("i", i);
46}
47
48(void)argc;
49(void)argv;
50return 0;
51}
52