Eile Mit Weile
Loading...
Searching...
No Matches
value_type_helpers.hpp
Go to the documentation of this file.
1
5#ifndef EILE_MIT_WEILE_VALUE_TYPE_HELPERS_HPP
6#define EILE_MIT_WEILE_VALUE_TYPE_HELPERS_HPP
7
8#include <unordered_map>
9
10#include <string>
11#include "rapidjson/document.h"
12
18namespace value_type_helpers {
19
24 enum ValueType {
25 intType,
26 uintType,
27 boolType,
28 floatType,
29 doubleType,
30 stringType,
31 int64tType,
32 uint64tType
33 };
34
35
41 const std::unordered_map<std::string, ValueType> _string_to_value_type = {
42 {"int", ValueType::intType },
43 {"uint", ValueType::uintType},
44 {"bool", ValueType::boolType},
45 {"float", ValueType::floatType},
46 {"double", ValueType::doubleType},
47 {"int64t", ValueType::int64tType},
48 {"uint64t", ValueType::uint64tType},
49 {"string", ValueType::stringType}
50 };
51
57 const std::unordered_map<ValueType, std::string> _value_type_to_string = {
58 { ValueType::intType, "int" },
59 { ValueType::uintType, "uint"},
60 { ValueType::boolType, "bool"},
61 { ValueType::floatType, "float"},
62 { ValueType::doubleType, "double"},
63 { ValueType::int64tType, "int64t"},
64 { ValueType::uint64tType, "uint64t"},
65 { ValueType::stringType, "string"},
66 };
67
75 template<typename T>
77
85 template<typename T>
87
91 template<>
96
100 template<>
105
109 template<>
114
118 template<>
123
127 template<>
132
136 template<>
141
145 template<>
150
154 template<>
161
165 template<>
170
174 template<>
179
183 template<>
188
192 template<>
197
201 template<>
206
210 template<>
215
219 template<>
224
228 template<>
233}
234#endif //EILE_MIT_WEILE_VALUE_TYPE_HELPERS_HPP
A serializable value, used for writing values into json.
Definition serializable_value.hpp:28
SerializableValue(T val)
Definition serializable_value.hpp:30
Helper functions for serializing and deserializing instances of SerializableValue.
rapidjson::Value get_json_value< unsigned int >(unsigned int val, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator)
specialization of get_json_value for unsigned int.
Definition value_type_helpers.hpp:129
rapidjson::Value get_json_value_type< unsigned int >(unsigned int val, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator)
specialization of get_json_value_type for unsigned int.
Definition value_type_helpers.hpp:203
rapidjson::Value get_json_value< std::string >(std::string val, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator)
specialization of get_json_value for string.
Definition value_type_helpers.hpp:156
rapidjson::Value get_json_value_type< float >(float val, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator)
specialization of get_json_value_type for float.
Definition value_type_helpers.hpp:185
rapidjson::Value get_json_value< float >(float val, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator)
specialization of get_json_value for float.
Definition value_type_helpers.hpp:111
rapidjson::Value get_json_value< bool >(bool val, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator)
specialization of get_json_value for bool.
Definition value_type_helpers.hpp:93
rapidjson::Value get_json_value_type< int64_t >(int64_t val, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator)
specialization of get_json_value_type for int64_t.
Definition value_type_helpers.hpp:212
rapidjson::Value get_json_value_type< uint64_t >(uint64_t val, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator)
specialization of get_json_value_type for uint64_t.
Definition value_type_helpers.hpp:221
rapidjson::Value get_json_value_type< int >(int val, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator)
specialization of get_json_value_type for int.
Definition value_type_helpers.hpp:176
const std::unordered_map< ValueType, std::string > _value_type_to_string
Converts a value type to a string.
Definition value_type_helpers.hpp:57
rapidjson::Value get_json_value_type< double >(double val, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator)
specialization of get_json_value_type for double.
Definition value_type_helpers.hpp:194
ValueType
Enum for the supported value types.
Definition value_type_helpers.hpp:24
rapidjson::Value get_json_value< uint64_t >(uint64_t val, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator)
specialization of get_json_value for uint64_t.
Definition value_type_helpers.hpp:147
rapidjson::Value get_json_value< double >(double val, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator)
specialization of get_json_value for double.
Definition value_type_helpers.hpp:120
rapidjson::Value get_json_value_type< std::string >(std::string val, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator)
specialization of get_json_value_type for string.
Definition value_type_helpers.hpp:230
rapidjson::Value get_json_value_type< bool >(bool val, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator)
specialization of get_json_value_type for bool.
Definition value_type_helpers.hpp:167
rapidjson::Value get_json_value< int64_t >(int64_t val, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator)
specialization of get_json_value for int64_t.
Definition value_type_helpers.hpp:138
rapidjson::Value get_json_value< int >(int val, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator)
specialization of get_json_value for int.
Definition value_type_helpers.hpp:102
const std::unordered_map< std::string, ValueType > _string_to_value_type
Converts a string to a value type.
Definition value_type_helpers.hpp:41