veriblock-pop-cpp
C++11 Libraries for leveraging VeriBlock Proof-Of-Proof blockchain technology.
json.hpp
1// Copyright (c) 2019-2022 Xenios SEZC
2// https://www.veriblock.org
3// Distributed under the MIT software license, see the accompanying
4// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef VERIBLOCK_POP_CPP_JSON_HPP
7#define VERIBLOCK_POP_CPP_JSON_HPP
8
9#include <string>
10
11namespace altintegration {
12
19template <typename Value, typename T>
20Value ToJSON(const T& /*entity*/) {
21 static_assert(sizeof(T) == 0, "Undefined function for this type");
22}
23
30namespace json {
31
33
39template <typename Object>
40Object makeEmptyObject() {
41 static_assert(sizeof(Object) == 0, "Undefined function for this type");
42}
43
49template <typename Array>
50Array makeEmptyArray() {
51 static_assert(sizeof(Array) == 0, "Undefined function for this type");
52}
53
58template <typename Value>
59void putKV(Value& /*object*/,
60 const std::string& /*key*/,
61 const Value& /*value*/) {
62 static_assert(sizeof(Value) == 0, "Undefined function for this type");
63}
64
69template <typename Object>
70void putStringKV(Object& /*object to modify*/,
71 const std::string& /*key*/,
72 const std::string& /*value*/) {
73 static_assert(sizeof(Object) == 0, "Undefined function for this type");
74}
75
80template <typename Object>
81void putIntKV(Object& /*object to modify*/,
82 const std::string& /*key*/,
83 int64_t /*value*/) {
84 static_assert(sizeof(Object) == 0, "Undefined function for this type");
85}
86
91template <typename Object>
92void putDoubleKV(Object& object, const std::string& key, double value) {
93 json::putKV(object, key, ToJSON<Object>(value));
94}
95
100template <typename Object>
101void putNullKV(Object& /*object to modify*/, const std::string& /*key*/) {
102 static_assert(sizeof(Object) == 0, "Undefined function for this type");
103}
104
109template <typename Value>
110void arrayPushBack(Value& /*array to modify*/, const Value& /*element*/) {
111 static_assert(sizeof(Value) == 0, "Undefined function for this type");
112}
113
118template <typename Object>
119void putBoolKV(Object& /*object to modify*/,
120 const std::string& /*key*/,
121 bool /*value*/) {
122 static_assert(sizeof(Object) == 0, "Undefined function for this type");
123}
124
126
127template <typename Value, typename Iterable>
128void putArrayKV(Value& object, const std::string& key, const Iterable& val) {
129 auto arr = makeEmptyArray<Value>();
130 for (const auto& it : val) {
131 arrayPushBack(arr, ToJSON<Value>(it));
132 }
133 putKV(object, key, arr);
134}
135
136} // namespace json
137} // namespace altintegration
138
139#endif // VERIBLOCK_POP_CPP_JSON_HPP
Defines logging helpers.
Definition: block.hpp:14