Falcon
Toggle main menu visibility
Loading...
Searching...
No Matches
serialization.hpp
1
// ---------------------------------------------------------------------
2
// This file is part of falcon-core.
3
//
4
// Copyright (C) 2015, 2016, 2017 Neuro-Electronics Research Flanders
5
//
6
// Falcon-server is free software: you can redistribute it and/or modify
7
// it under the terms of the GNU General Public License as published by
8
// the Free Software Foundation, either version 3 of the License, or
9
// (at your option) any later version.
10
//
11
// Falcon-server is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
// GNU General Public License for more details.
15
//
16
// You should have received a copy of the GNU General Public License
17
// along with falcon-core. If not, see <http://www.gnu.org/licenses/>.
18
// ---------------------------------------------------------------------
19
20
#pragma once
21
#include <string>
22
#include "yaml-cpp/yaml.h"
23
24
namespace
Serialization {
25
26
static
const
uint8_t VERSION = 1;
27
31
enum class
Format : std::int8_t {
33
NONE = -1,
34
36
FULL,
37
39
COMPACT,
40
42
HEADERONLY,
43
45
STREAMHEADER
46
};
47
48
std::string format_to_string(Format fmt);
49
Format string_to_format(std::string s);
50
51
enum class
Encoding : std::uint8_t { BINARY = 0, YAML, FLATBUFFER };
52
53
std::string encoding_to_string(Encoding fmt);
54
Encoding string_to_encoding(std::string s);
55
56
}
// namespace Serialization
57
58
namespace
YAML {
59
60
template
<>
61
struct
convert<Serialization::Format> {
62
static
Node encode(
const
Serialization::Format& rhs) {
63
Node node;
64
node = Serialization::format_to_string(rhs);
65
return
node;
66
}
67
68
static
bool
decode(
const
Node& node, Serialization::Format& rhs) {
69
rhs = Serialization::string_to_format(node.as<std::string>());
70
return
true
;
71
}
72
};
73
74
template
<>
75
struct
convert<Serialization::Encoding> {
76
static
Node encode(
const
Serialization::Encoding& rhs) {
77
Node node;
78
node = Serialization::encoding_to_string(rhs);
79
return
node;
80
}
81
82
static
bool
decode(
const
Node& node, Serialization::Encoding& rhs) {
83
rhs = Serialization::string_to_encoding(node.as<std::string>());
84
return
true
;
85
}
86
};
87
}
// namespace YAML
falcon
serialization.hpp
Generated by
1.18.0