Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
Types.hpp
1#pragma once
2
3#include "util/UnsupportedType.hpp"
4
5#include <fmt/format.h>
6
7#include <cstdint>
8#include <expected>
9#include <ostream>
10#include <string>
11#include <variant>
12
13namespace util::config {
14
18enum class ConfigType { Integer, String, Double, Boolean };
19
27std::ostream&
28operator<<(std::ostream& stream, ConfigType type);
29
33using Value = std::variant<int64_t, std::string, bool, double>;
34
42std::ostream&
43operator<<(std::ostream& stream, Value value);
44
51template <typename Type>
52constexpr ConfigType
53getType()
54{
55 if constexpr (std::is_same_v<Type, int64_t>) {
56 return ConfigType::Integer;
57 } else if constexpr (std::is_same_v<Type, std::string>) {
58 return ConfigType::String;
59 } else if constexpr (std::is_same_v<Type, double>) {
60 return ConfigType::Double;
61 } else if constexpr (std::is_same_v<Type, bool>) {
62 return ConfigType::Boolean;
63 } else {
64 static_assert(util::Unsupported<Type>, "Wrong config type");
65 }
66}
67
68} // namespace util::config
static constexpr bool Unsupported
used for compile time checking of unsupported types
Definition UnsupportedType.hpp:9