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
16enum class ConfigType { Integer, String, Double, Boolean };
17
25std::ostream&
26operator<<(std::ostream& stream, ConfigType type);
27
29using Value = std::variant<int64_t, std::string, bool, double>;
30
38std::ostream&
39operator<<(std::ostream& stream, Value value);
40
47template <typename Type>
48constexpr ConfigType
49getType()
50{
51 if constexpr (std::is_same_v<Type, int64_t>) {
52 return ConfigType::Integer;
53 } else if constexpr (std::is_same_v<Type, std::string>) {
54 return ConfigType::String;
55 } else if constexpr (std::is_same_v<Type, double>) {
56 return ConfigType::Double;
57 } else if constexpr (std::is_same_v<Type, bool>) {
58 return ConfigType::Boolean;
59 } else {
60 static_assert(util::Unsupported<Type>, "Wrong config type");
61 }
62}
63
64} // namespace util::config
static constexpr bool Unsupported
used for compile time checking of unsupported types
Definition UnsupportedType.hpp:7